Skip to content

Commit aa6bbfb

Browse files
authored
Merge pull request #381 from InjectiveLabs/cp-396/add_support_for_v1_16
[CP-396] Add support for v1.16
2 parents b8f4603 + d8112fb commit aa6bbfb

31 files changed

+1297
-157
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ All notable changes to this project will be documented in this file.
55
## [Unreleased] - 9999-99-99
66
### Added
77
- Added support for Exchange V2 proto queries and types
8+
- Added support for ERC20 proto queries and types
9+
- Added support for EVM proto queries and types
810
- Updated all chain exchange module examples to use the new Exchange V2 proto queries and types
11+
- Added examples for ERC20 queries and messages
12+
- Added examples for EVM queries
913

1014
### Removed
1115
- Removed all methods marked as deprecated in AsyncClient and Composer

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.16.0-rc2 --depth 1 --single-branch
34+
git clone https://github.com/InjectiveLabs/injective-indexer.git -b v1.16.3 --depth 1 --single-branch
3535

3636
clone-all: clone-injective-indexer
3737

buf.gen.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ inputs:
1616
- git_repo: https://github.com/InjectiveLabs/wasmd
1717
tag: v0.53.2-evm-comet1-inj
1818
- git_repo: https://github.com/InjectiveLabs/cometbft
19-
tag: v1.0.1-inj
19+
tag: v1.0.1-inj.2
2020
- git_repo: https://github.com/InjectiveLabs/cosmos-sdk
21-
tag: v0.50.13-evm-comet1-inj.2
21+
tag: v0.50.13-evm-comet1-inj.3
2222
# - git_repo: https://github.com/InjectiveLabs/wasmd
2323
# branch: v0.51.x-inj
2424
# subdir: proto
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import asyncio
2+
import json
3+
import os
4+
5+
import dotenv
6+
7+
from pyinjective.async_client import AsyncClient
8+
from pyinjective.core.broadcaster import MsgBroadcasterWithPk
9+
from pyinjective.core.network import Network
10+
from pyinjective.wallet import PrivateKey
11+
12+
13+
async def main() -> None:
14+
dotenv.load_dotenv()
15+
configured_private_key = os.getenv("INJECTIVE_PRIVATE_KEY")
16+
17+
# select network: local, testnet, mainnet
18+
network = Network.testnet()
19+
20+
# initialize grpc client
21+
client = AsyncClient(network)
22+
composer = await client.composer()
23+
24+
gas_price = await client.current_chain_gas_price()
25+
# adjust gas price to make it valid even if it changes between the time it is requested and the TX is broadcasted
26+
gas_price = int(gas_price * 1.1)
27+
28+
message_broadcaster = MsgBroadcasterWithPk.new_using_gas_heuristics(
29+
network=network,
30+
private_key=configured_private_key,
31+
gas_price=gas_price,
32+
client=client,
33+
composer=composer,
34+
)
35+
36+
# load account
37+
priv_key = PrivateKey.from_hex(configured_private_key)
38+
pub_key = priv_key.to_public_key()
39+
address = pub_key.to_address()
40+
await client.fetch_account(address.to_acc_bech32())
41+
42+
usdt_denom = "factory/inj10vkkttgxdeqcgeppu20x9qtyvuaxxev8qh0awq/usdt"
43+
usdt_erc20 = "0xdAC17F958D2ee523a2206206994597C13D831ec7"
44+
45+
# prepare tx msg
46+
msg = composer.msg_create_token_pair(
47+
sender=address.to_acc_bech32(),
48+
bank_denom=usdt_denom,
49+
erc20_address=usdt_erc20,
50+
)
51+
52+
# broadcast the transaction
53+
result = await message_broadcaster.broadcast([msg])
54+
print("---Transaction Response---")
55+
print(json.dumps(result, indent=2))
56+
57+
gas_price = await client.current_chain_gas_price()
58+
# adjust gas price to make it valid even if it changes between the time it is requested and the TX is broadcasted
59+
gas_price = int(gas_price * 1.1)
60+
message_broadcaster.update_gas_price(gas_price=gas_price)
61+
62+
63+
if __name__ == "__main__":
64+
asyncio.get_event_loop().run_until_complete(main())
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import asyncio
2+
import json
3+
import os
4+
5+
import dotenv
6+
7+
from pyinjective.async_client import AsyncClient
8+
from pyinjective.core.broadcaster import MsgBroadcasterWithPk
9+
from pyinjective.core.network import Network
10+
from pyinjective.wallet import PrivateKey
11+
12+
13+
async def main() -> None:
14+
dotenv.load_dotenv()
15+
configured_private_key = os.getenv("INJECTIVE_PRIVATE_KEY")
16+
17+
# select network: local, testnet, mainnet
18+
network = Network.testnet()
19+
20+
# initialize grpc client
21+
client = AsyncClient(network)
22+
composer = await client.composer()
23+
24+
gas_price = await client.current_chain_gas_price()
25+
# adjust gas price to make it valid even if it changes between the time it is requested and the TX is broadcasted
26+
gas_price = int(gas_price * 1.1)
27+
28+
message_broadcaster = MsgBroadcasterWithPk.new_using_gas_heuristics(
29+
network=network,
30+
private_key=configured_private_key,
31+
gas_price=gas_price,
32+
client=client,
33+
composer=composer,
34+
)
35+
36+
# load account
37+
priv_key = PrivateKey.from_hex(configured_private_key)
38+
pub_key = priv_key.to_public_key()
39+
address = pub_key.to_address()
40+
await client.fetch_account(address.to_acc_bech32())
41+
42+
usdt_denom = "factory/inj10vkkttgxdeqcgeppu20x9qtyvuaxxev8qh0awq/usdt"
43+
44+
# prepare tx msg
45+
msg = composer.msg_delete_token_pair(
46+
sender=address.to_acc_bech32(),
47+
bank_denom=usdt_denom,
48+
)
49+
50+
# broadcast the transaction
51+
result = await message_broadcaster.broadcast([msg])
52+
print("---Transaction Response---")
53+
print(json.dumps(result, indent=2))
54+
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+
message_broadcaster.update_gas_price(gas_price=gas_price)
59+
60+
61+
if __name__ == "__main__":
62+
asyncio.get_event_loop().run_until_complete(main())
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import asyncio
2+
import json
3+
import os
4+
5+
import dotenv
6+
7+
from pyinjective import PrivateKey
8+
from pyinjective.async_client import AsyncClient
9+
from pyinjective.core.network import Network
10+
11+
12+
async def main() -> None:
13+
dotenv.load_dotenv()
14+
configured_private_key = os.getenv("INJECTIVE_PRIVATE_KEY")
15+
16+
# select network: local, testnet, mainnet
17+
network = Network.testnet()
18+
19+
# initialize grpc client
20+
client = AsyncClient(network)
21+
22+
# load account
23+
priv_key = PrivateKey.from_hex(configured_private_key)
24+
pub_key = priv_key.to_public_key()
25+
address = pub_key.to_address()
26+
await client.fetch_account(address.to_acc_bech32())
27+
28+
pairs = await client.fetch_erc20_all_token_pairs()
29+
print(json.dumps(pairs, indent=2))
30+
31+
32+
if __name__ == "__main__":
33+
asyncio.get_event_loop().run_until_complete(main())
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import asyncio
2+
import json
3+
import os
4+
5+
import dotenv
6+
7+
from pyinjective import PrivateKey
8+
from pyinjective.async_client import AsyncClient
9+
from pyinjective.core.network import Network
10+
11+
12+
async def main() -> None:
13+
dotenv.load_dotenv()
14+
configured_private_key = os.getenv("INJECTIVE_PRIVATE_KEY")
15+
16+
# select network: local, testnet, mainnet
17+
network = Network.testnet()
18+
19+
# initialize grpc client
20+
client = AsyncClient(network)
21+
22+
# load account
23+
priv_key = PrivateKey.from_hex(configured_private_key)
24+
pub_key = priv_key.to_public_key()
25+
address = pub_key.to_address()
26+
await client.fetch_account(address.to_acc_bech32())
27+
28+
result = await client.fetch_erc20_token_pair_by_denom(bank_denom="usdt")
29+
print(json.dumps(result, indent=2))
30+
31+
32+
if __name__ == "__main__":
33+
asyncio.get_event_loop().run_until_complete(main())
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import asyncio
2+
import json
3+
import os
4+
5+
import dotenv
6+
7+
from pyinjective import PrivateKey
8+
from pyinjective.async_client import AsyncClient
9+
from pyinjective.core.network import Network
10+
11+
12+
async def main() -> None:
13+
dotenv.load_dotenv()
14+
configured_private_key = os.getenv("INJECTIVE_PRIVATE_KEY")
15+
16+
# select network: local, testnet, mainnet
17+
network = Network.testnet()
18+
19+
# initialize grpc client
20+
client = AsyncClient(network)
21+
22+
# load account
23+
priv_key = PrivateKey.from_hex(configured_private_key)
24+
pub_key = priv_key.to_public_key()
25+
address = pub_key.to_address()
26+
await client.fetch_account(address.to_acc_bech32())
27+
28+
erc20_address = "0xdAC17F958D2ee523a2206206994597C13D831ec7"
29+
result = await client.fetch_erc20_token_pair_by_erc20_address(erc20_address=erc20_address)
30+
print(json.dumps(result, indent=2))
31+
32+
33+
if __name__ == "__main__":
34+
asyncio.get_event_loop().run_until_complete(main())
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import asyncio
2+
import json
3+
import os
4+
5+
import dotenv
6+
7+
from pyinjective import PrivateKey
8+
from pyinjective.async_client import AsyncClient
9+
from pyinjective.core.network import Network
10+
11+
12+
async def main() -> None:
13+
dotenv.load_dotenv()
14+
configured_private_key = os.getenv("INJECTIVE_PRIVATE_KEY")
15+
16+
# select network: local, testnet, mainnet
17+
network = Network.testnet()
18+
19+
# initialize grpc client
20+
client = AsyncClient(network)
21+
22+
# load account
23+
priv_key = PrivateKey.from_hex(configured_private_key)
24+
pub_key = priv_key.to_public_key()
25+
address = pub_key.to_address()
26+
await client.fetch_account(address.to_acc_bech32())
27+
28+
erc20_address = "0xDFd5293D8e347dFe59E90eFd55b2956a1343963d"
29+
result = await client.fetch_evm_account(address=erc20_address)
30+
print(json.dumps(result, indent=2))
31+
32+
33+
if __name__ == "__main__":
34+
asyncio.get_event_loop().run_until_complete(main())
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import asyncio
2+
import json
3+
import os
4+
5+
import dotenv
6+
7+
from pyinjective import PrivateKey
8+
from pyinjective.async_client import AsyncClient
9+
from pyinjective.core.network import Network
10+
11+
12+
async def main() -> None:
13+
dotenv.load_dotenv()
14+
configured_private_key = os.getenv("INJECTIVE_PRIVATE_KEY")
15+
16+
# select network: local, testnet, mainnet
17+
network = Network.testnet()
18+
19+
# initialize grpc client
20+
client = AsyncClient(network)
21+
22+
# load account
23+
priv_key = PrivateKey.from_hex(configured_private_key)
24+
pub_key = priv_key.to_public_key()
25+
address = pub_key.to_address()
26+
await client.fetch_account(address.to_acc_bech32())
27+
28+
erc20_address = "0xDFd5293D8e347dFe59E90eFd55b2956a1343963d"
29+
result = await client.fetch_evm_cosmos_account(address=erc20_address)
30+
print(json.dumps(result, indent=2))
31+
32+
33+
if __name__ == "__main__":
34+
asyncio.get_event_loop().run_until_complete(main())

0 commit comments

Comments
 (0)