Skip to content

Commit f9b9b3f

Browse files
authored
Release/v1.10 for chain upgrade v1.15 (#379)
* fix: renamed fetch_subaccount_orders_list to fetch_derivative_subaccount_orders_list * Cp 235/update gas estimator for fixed exchange gas (#375) * feat: updated changelog and version number for v1.9.0 release * fix: updated the oracle stream prices script to send the oracle type always in lowercase * fix: added quantization in the functions that convert notional values to chain format * cp-235: updated the gas limit estimator logic to reflect the new logic for gas heuristics in exchange module (chain v1.15) * cp-235: updated all proto definitions with the candidate indexer and chain core versions for v1.15 chain upgrade * feat: added a new message based fee calculator supporting the Exchange module gas heuristics * fix: fix broadcaster creation example scripts * fix: pointed to the correct injective-core branch for the proto generation * fix: updated gas heuristics per message gas cost to sync with latest changes on chain * fix: added cleanup code in AsyncClient for the object destruction phase * feat: updated proto definitions for chain v1.15 upgrade and Indexer v1.14.48 * feat: made the gas calculator using gas heuristics the default one for the MsgBroadcasterWithPk when broadcasting without simulation * fix: fixed gas calculation using heuristics to not duplicate the required gas for post only orders * fix: updated chain version to v1.15 and indexer version to v1.15.6
1 parent 17293cc commit f9b9b3f

File tree

114 files changed

+5140
-1904
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+5140
-1904
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [1.10.0] - 2025-04-16
6+
### Added
7+
- Added support for the queries in the new TXFees module
8+
9+
### Changed
10+
- Update in the implementation of the gas limit estimator to use the same values as the chain for the fixed gas messages
11+
- Updated all compiled protos for compatibility with Injective core v1.15 and Indexer v1.15.6
12+
513
## [1.9.1] - 2025-03-03
614
### Fixed
715
- Added quantization in the functions that convert notional values to chain format

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ clean-all:
3131
$(call clean_repos)
3232

3333
clone-injective-indexer:
34-
git clone https://github.com/InjectiveLabs/injective-indexer.git -b v1.14.1-RC.6 --depth 1 --single-branch
34+
git clone https://github.com/InjectiveLabs/injective-indexer.git -b v1.15.6 --depth 1 --single-branch
3535

3636
clone-all: clone-injective-indexer
3737

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ $ poetry install
3535

3636
# connecting to Injective Exchange API
3737
# and listening for new orders from a specific spot market
38-
$ poetry run python examples/exchange_client/spot_exchange_rpc/8_StreamOrders.py
38+
$ poetry run python examples/exchange_client/spot_exchange_rpc/8_StreamOrderbookUpdate.py
3939

4040
# sending a msg with bank transfer
4141
# signs and posts a transaction to the Injective Chain
42-
$ poetry run python examples/chain_client/1_MsgSend.py
42+
$ poetry run python examples/chain_client/bank/1_MsgSend.py
4343
```
4444
Upgrade `pip` to the latest version, if you see these warnings:
4545
```

buf.gen.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ inputs:
1212
- module: buf.build/googleapis/googleapis
1313
- module: buf.build/cosmos/ics23
1414
- git_repo: https://github.com/InjectiveLabs/cosmos-sdk
15-
tag: v0.50.9-inj-2
15+
tag: v0.50.9-inj.5
1616
- git_repo: https://github.com/InjectiveLabs/ibc-go
17-
tag: v8.3.2-inj-0
17+
tag: v8.7.0-inj
1818
- git_repo: https://github.com/InjectiveLabs/wasmd
19-
tag: v0.53.2-inj-1
19+
tag: v0.53.2-inj.2
2020
# - git_repo: https://github.com/InjectiveLabs/wasmd
2121
# branch: v0.51.x-inj
2222
# subdir: proto
2323
- git_repo: https://github.com/InjectiveLabs/injective-core
24-
tag: v1.14.0
24+
tag: v1.15.0
2525
subdir: proto
26-
# - git_repo: https://github.com/InjectiveLabs/injective-core
27-
# branch: testnet
28-
# subdir: proto
26+
# - git_repo: https://github.com/InjectiveLabs/injective-core
27+
# branch: release/v1.15.x
28+
# subdir: proto
2929
- directory: proto

examples/chain_client/1_LocalOrderHash.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import dotenv
77

88
from pyinjective.async_client import AsyncClient
9-
from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE
9+
from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT
1010
from pyinjective.core.network import Network
1111
from pyinjective.orderhash import OrderHashManager
1212
from pyinjective.transaction import Transaction
@@ -111,7 +111,11 @@ async def main() -> None:
111111
.with_account_num(client.get_number())
112112
.with_chain_id(network.chain_id)
113113
)
114-
gas_price = GAS_PRICE
114+
115+
gas_price = await client.current_chain_gas_price()
116+
# adjust gas price to make it valid even if it changes between the time it is requested and the TX is broadcasted
117+
gas_price = int(gas_price * 1.1)
118+
115119
base_gas = 85000
116120
gas_limit = base_gas + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation
117121
gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0")
@@ -148,7 +152,11 @@ async def main() -> None:
148152
.with_account_num(client.get_number())
149153
.with_chain_id(network.chain_id)
150154
)
151-
gas_price = GAS_PRICE
155+
156+
gas_price = await client.current_chain_gas_price()
157+
# adjust gas price to make it valid even if it changes between the time it is requested and the TX is broadcasted
158+
gas_price = int(gas_price * 1.1)
159+
152160
base_gas = 85000
153161
gas_limit = base_gas + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation
154162
gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0")
@@ -240,7 +248,11 @@ async def main() -> None:
240248
.with_account_num(client.get_number())
241249
.with_chain_id(network.chain_id)
242250
)
243-
gas_price = GAS_PRICE
251+
252+
gas_price = await client.current_chain_gas_price()
253+
# adjust gas price to make it valid even if it changes between the time it is requested and the TX is broadcasted
254+
gas_price = int(gas_price * 1.1)
255+
244256
base_gas = 85000
245257
gas_limit = base_gas + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation
246258
gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0")

examples/chain_client/3_MessageBroadcaster.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import asyncio
2+
import json
23
import os
34
import uuid
45
from decimal import Decimal
56

67
import dotenv
78

8-
from pyinjective.composer import Composer as ProtoMsgComposer
9+
from pyinjective.async_client import AsyncClient
910
from pyinjective.core.broadcaster import MsgBroadcasterWithPk
1011
from pyinjective.core.network import Network
1112
from pyinjective.wallet import PrivateKey
@@ -17,11 +18,20 @@ async def main() -> None:
1718

1819
# select network: local, testnet, mainnet
1920
network = Network.testnet()
20-
composer = ProtoMsgComposer(network=network.string())
21+
22+
client = AsyncClient(network)
23+
composer = await client.composer()
24+
25+
gas_price = await client.current_chain_gas_price()
26+
# adjust gas price to make it valid even if it changes between the time it is requested and the TX is broadcasted
27+
gas_price = int(gas_price * 1.1)
2128

2229
message_broadcaster = MsgBroadcasterWithPk.new_using_simulation(
2330
network=network,
2431
private_key=private_key_in_hexa,
32+
gas_price=gas_price,
33+
client=client,
34+
composer=composer,
2535
)
2636

2737
priv_key = PrivateKey.from_hex(private_key_in_hexa)
@@ -64,7 +74,12 @@ async def main() -> None:
6474
# broadcast the transaction
6575
result = await message_broadcaster.broadcast([msg])
6676
print("---Transaction Response---")
67-
print(result)
77+
print(json.dumps(result, indent=2))
78+
79+
gas_price = await client.current_chain_gas_price()
80+
# adjust gas price to make it valid even if it changes between the time it is requested and the TX is broadcasted
81+
gas_price = int(gas_price * 1.1)
82+
message_broadcaster.update_gas_price(gas_price=gas_price)
6883

6984

7085
if __name__ == "__main__":

examples/chain_client/4_MessageBroadcasterWithGranteeAccount.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import asyncio
2+
import json
23
import os
34
import uuid
45
from decimal import Decimal
56

67
import dotenv
78

89
from pyinjective.async_client import AsyncClient
9-
from pyinjective.composer import Composer as ProtoMsgComposer
1010
from pyinjective.core.broadcaster import MsgBroadcasterWithPk
1111
from pyinjective.core.network import Network
1212
from pyinjective.wallet import Address, PrivateKey
@@ -19,20 +19,27 @@ async def main() -> None:
1919

2020
# select network: local, testnet, mainnet
2121
network = Network.testnet()
22-
composer = ProtoMsgComposer(network=network.string())
2322

2423
# initialize grpc client
2524
client = AsyncClient(network)
25+
composer = await client.composer()
2626
await client.sync_timeout_height()
2727

2828
# load account
2929
priv_key = PrivateKey.from_hex(private_key_in_hexa)
3030
pub_key = priv_key.to_public_key()
3131
address = pub_key.to_address()
3232

33+
gas_price = await client.current_chain_gas_price()
34+
# adjust gas price to make it valid even if it changes between the time it is requested and the TX is broadcasted
35+
gas_price = int(gas_price * 1.1)
36+
3337
message_broadcaster = MsgBroadcasterWithPk.new_for_grantee_account_using_simulation(
3438
network=network,
3539
grantee_private_key=private_key_in_hexa,
40+
gas_price=gas_price,
41+
client=client,
42+
composer=composer,
3643
)
3744

3845
# prepare tx msg
@@ -55,7 +62,12 @@ async def main() -> None:
5562
# broadcast the transaction
5663
result = await message_broadcaster.broadcast([msg])
5764
print("---Transaction Response---")
58-
print(result)
65+
print(json.dumps(result, indent=2))
66+
67+
gas_price = await client.current_chain_gas_price()
68+
# adjust gas price to make it valid even if it changes between the time it is requested and the TX is broadcasted
69+
gas_price = int(gas_price * 1.1)
70+
message_broadcaster.update_gas_price(gas_price=gas_price)
5971

6072

6173
if __name__ == "__main__":

examples/chain_client/5_MessageBroadcasterWithoutSimulation.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import asyncio
2+
import json
23
import os
34
import uuid
45
from decimal import Decimal
56

67
import dotenv
78

8-
from pyinjective.composer import Composer as ProtoMsgComposer
9+
from pyinjective.async_client import AsyncClient
910
from pyinjective.core.broadcaster import MsgBroadcasterWithPk
1011
from pyinjective.core.network import Network
1112
from pyinjective.wallet import PrivateKey
@@ -17,11 +18,21 @@ async def main() -> None:
1718

1819
# select network: local, testnet, mainnet
1920
network = Network.testnet()
20-
composer = ProtoMsgComposer(network=network.string())
21+
22+
client = AsyncClient(network)
23+
composer = await client.composer()
24+
await client.sync_timeout_height()
25+
26+
gas_price = await client.current_chain_gas_price()
27+
# adjust gas price to make it valid even if it changes between the time it is requested and the TX is broadcasted
28+
gas_price = int(gas_price * 1.1)
2129

2230
message_broadcaster = MsgBroadcasterWithPk.new_without_simulation(
2331
network=network,
2432
private_key=private_key_in_hexa,
33+
gas_price=gas_price,
34+
client=client,
35+
composer=composer,
2536
)
2637

2738
priv_key = PrivateKey.from_hex(private_key_in_hexa)
@@ -64,7 +75,12 @@ async def main() -> None:
6475
# broadcast the transaction
6576
result = await message_broadcaster.broadcast([msg])
6677
print("---Transaction Response---")
67-
print(result)
78+
print(json.dumps(result, indent=2))
79+
80+
gas_price = await client.current_chain_gas_price()
81+
# adjust gas price to make it valid even if it changes between the time it is requested and the TX is broadcasted
82+
gas_price = int(gas_price * 1.1)
83+
message_broadcaster.update_gas_price(gas_price=gas_price)
6884

6985

7086
if __name__ == "__main__":

examples/chain_client/6_MessageBroadcasterWithGranteeAccountWithoutSimulation.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import asyncio
2+
import json
23
import os
34
import uuid
45
from decimal import Decimal
56

67
import dotenv
78

89
from pyinjective.async_client import AsyncClient
9-
from pyinjective.composer import Composer as ProtoMsgComposer
1010
from pyinjective.core.broadcaster import MsgBroadcasterWithPk
1111
from pyinjective.core.network import Network
1212
from pyinjective.wallet import Address, PrivateKey
@@ -19,20 +19,26 @@ async def main() -> None:
1919

2020
# select network: local, testnet, mainnet
2121
network = Network.testnet()
22-
composer = ProtoMsgComposer(network=network.string())
2322

2423
# initialize grpc client
2524
client = AsyncClient(network)
26-
await client.sync_timeout_height()
25+
composer = await client.composer()
2726

2827
# load account
2928
priv_key = PrivateKey.from_hex(private_key_in_hexa)
3029
pub_key = priv_key.to_public_key()
3130
address = pub_key.to_address()
3231

32+
gas_price = await client.current_chain_gas_price()
33+
# adjust gas price to make it valid even if it changes between the time it is requested and the TX is broadcasted
34+
gas_price = int(gas_price * 1.1)
35+
3336
message_broadcaster = MsgBroadcasterWithPk.new_for_grantee_account_without_simulation(
3437
network=network,
3538
grantee_private_key=private_key_in_hexa,
39+
gas_price=gas_price,
40+
client=client,
41+
composer=composer,
3642
)
3743

3844
# prepare tx msg
@@ -54,7 +60,12 @@ async def main() -> None:
5460
# broadcast the transaction
5561
result = await message_broadcaster.broadcast([msg])
5662
print("---Transaction Response---")
57-
print(result)
63+
print(json.dumps(result, indent=2))
64+
65+
gas_price = await client.current_chain_gas_price()
66+
# adjust gas price to make it valid even if it changes between the time it is requested and the TX is broadcasted
67+
gas_price = int(gas_price * 1.1)
68+
message_broadcaster.update_gas_price(gas_price=gas_price)
5869

5970

6071
if __name__ == "__main__":

examples/chain_client/auction/1_MsgBid.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from grpc import RpcError
66

77
from pyinjective.async_client import AsyncClient
8-
from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE
8+
from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT
99
from pyinjective.core.network import Network
1010
from pyinjective.transaction import Transaction
1111
from pyinjective.wallet import PrivateKey
@@ -52,7 +52,10 @@ async def main() -> None:
5252
return
5353

5454
# build tx
55-
gas_price = GAS_PRICE
55+
gas_price = await client.current_chain_gas_price()
56+
# adjust gas price to make it valid even if it changes between the time it is requested and the TX is broadcasted
57+
gas_price = int(gas_price * 1.1)
58+
5659
gas_limit = int(sim_res["gasInfo"]["gasUsed"]) + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation
5760
gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0")
5861
fee = [

0 commit comments

Comments
 (0)