Skip to content

Commit b928e2e

Browse files
authored
Merge pull request #410 from InjectiveLabs/ic-985/create-python-sdk-final-release-for-v1190
[CHORE] regenerate protos for injective-core/indexer and align v1.19.0-beta
2 parents 33cd59e + e041678 commit b928e2e

150 files changed

Lines changed: 2946 additions & 18795 deletions

File tree

Some content is hidden

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

.pre-commit-config.yaml

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,11 @@ repos:
66
- id: trailing-whitespace
77
- id: end-of-file-fixer
88
- id: check-yaml
9-
- repo: https://github.com/flakeheaven/flakeheaven
10-
rev: 3.3.0
9+
- repo: https://github.com/astral-sh/ruff-pre-commit
10+
rev: v0.15.10
1111
hooks:
12-
- id: flakeheaven
13-
name: flakeheaven
14-
description: '`flakeheaven` is a `flake8` wrapper.'
15-
entry: flakeheaven lint
16-
language: python
17-
types_or: [ python, jupyter, markdown, rst, yaml ]
18-
require_serial: true
19-
minimum_pre_commit_version: 2.9.0
20-
- repo: https://github.com/pycqa/isort
21-
rev: 5.12.0
22-
hooks:
23-
- id: isort
24-
name: isort (python)
12+
- id: ruff
13+
args: [--fix]
2514
- repo: https://github.com/psf/black-pre-commit-mirror
2615
rev: 23.9.1
2716
hooks:

Makefile

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

2828
clone-injective-indexer:
29-
git clone https://github.com/InjectiveLabs/injective-indexer.git -b v1.18.3 --depth 1 --single-branch
29+
git clone https://github.com/InjectiveLabs/injective-indexer.git -b v1.18.59 --depth 1 --single-branch
3030

3131
clone-all: clone-injective-indexer
3232

README.md

Lines changed: 15 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -72,45 +72,21 @@ poetry run pytest -v
7272

7373
---
7474

75-
## Choose Exchange V1 or Exchange V2 queries
76-
77-
The Injective Python SDK provides two different clients for interacting with the exchange:
78-
79-
1. **Exchange V1 Client** (`async_client` module):
80-
- Use this client if you need to interact with the original Injective Exchange API
81-
- Import using: `from pyinjective.async_client import AsyncClient`
82-
- Suitable for applications that need to maintain compatibility with the original exchange interface
83-
- Example:
84-
```python
85-
from pyinjective.async_client import AsyncClient
86-
from pyinjective.network import Network
87-
88-
async def main():
89-
# Initialize client with mainnet
90-
client = AsyncClient(network=Network.mainnet())
91-
# Or use testnet
92-
# client = AsyncClient(network=Network.testnet())
93-
# Use V1 exchange queries here
94-
```
95-
96-
2. **Exchange V2 Client** (`async_client_v2` module):
97-
- Use this client for the latest exchange features and improvements
98-
- Import using: `from pyinjective.async_client_v2 import AsyncClient`
99-
- Recommended for new applications and when you need access to the latest exchange features
100-
- Example:
101-
```python
102-
from pyinjective.async_client_v2 import AsyncClient
103-
from pyinjective.network import Network
104-
105-
async def main():
106-
# Initialize client with mainnet
107-
client = AsyncClient(network=Network.mainnet())
108-
# Or use testnet
109-
# client = AsyncClient(network=Network.testnet())
110-
# Use V2 exchange queries here
111-
```
112-
113-
Both clients provide similar interfaces but with different underlying implementations. Choose V2 for new projects unless you have specific requirements for V1 compatibility.
75+
## Async client (exchange V2)
76+
77+
The Injective Python SDK exposes `AsyncClient` from the `async_client_v2` module:
78+
79+
- Import using: `from pyinjective.async_client_v2 import AsyncClient`
80+
- Example:
81+
```python
82+
from pyinjective.async_client_v2 import AsyncClient
83+
from pyinjective.network import Network
84+
85+
async def main():
86+
client = AsyncClient(network=Network.mainnet())
87+
# Or use testnet
88+
# client = AsyncClient(network=Network.testnet())
89+
```
11490

11591
> **Market Format Differences**:
11692
> - V1 AsyncClient: Markets are initialized with values in chain format (raw blockchain values)

buf.gen.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@ inputs:
1212
- module: buf.build/googleapis/googleapis
1313
- module: buf.build/cosmos/ics23
1414
- git_repo: https://github.com/InjectiveLabs/ibc-go
15-
tag: v8.7.0-inj.3
15+
tag: v8.7.0-inj.4
1616
- git_repo: https://github.com/InjectiveLabs/wasmd
17-
tag: v0.53.3-inj.2
17+
tag: v0.53.3-inj.3
1818
- git_repo: https://github.com/InjectiveLabs/cometbft
19-
tag: v1.0.1-inj.6
19+
tag: v1.0.1-inj.7
2020
- git_repo: https://github.com/InjectiveLabs/cosmos-sdk
21-
tag: v0.50.14-inj.4
21+
tag: v0.50.14-inj.9
2222
# - git_repo: https://github.com/InjectiveLabs/wasmd
2323
# branch: v0.51.x-inj
2424
# subdir: proto
25-
- git_repo: https://github.com/InjectiveLabs/hyperlane-cosmos
26-
tag: v1.0.1-inj
27-
subdir: proto
25+
# - git_repo: https://github.com/InjectiveLabs/hyperlane-cosmos
26+
# tag: v1.0.1-inj
27+
# subdir: proto
2828
- git_repo: https://github.com/InjectiveLabs/injective-core
29-
tag: v1.18.0
29+
tag: v1.19.0-beta
3030
subdir: proto
3131
# - git_repo: https://github.com/InjectiveLabs/injective-core
3232
# branch: c-655/add_chainlink_data_streams_oracle
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import asyncio
2+
import json
3+
import os
4+
5+
import dotenv
6+
7+
from pyinjective.async_client_v2 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+
private_key_in_hexa = os.getenv("INJECTIVE_PRIVATE_KEY")
16+
17+
network = Network.devnet()
18+
19+
client = AsyncClient(network)
20+
composer = await client.composer()
21+
22+
gas_price = await client.current_chain_gas_price()
23+
gas_price = int(gas_price * 1.1)
24+
25+
message_broadcaster = MsgBroadcasterWithPk.new_using_simulation(
26+
network=network,
27+
private_key=private_key_in_hexa,
28+
gas_price=gas_price,
29+
client=client,
30+
composer=composer,
31+
)
32+
33+
priv_key = PrivateKey.from_hex(private_key_in_hexa)
34+
pub_key = priv_key.to_public_key()
35+
address = pub_key.to_address()
36+
37+
denom = "factory/inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r/inj_test"
38+
39+
message = composer.msg_auction_claim_voucher(
40+
sender=address.to_acc_bech32(),
41+
denom=denom,
42+
)
43+
44+
result = await message_broadcaster.broadcast([message])
45+
print("---Transaction Response---")
46+
print(json.dumps(result, indent=2))
47+
48+
gas_price = await client.current_chain_gas_price()
49+
gas_price = int(gas_price * 1.1)
50+
message_broadcaster.update_gas_price(gas_price=gas_price)
51+
52+
53+
if __name__ == "__main__":
54+
asyncio.get_event_loop().run_until_complete(main())
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import asyncio
2+
3+
from pyinjective.async_client_v2 import AsyncClient
4+
from pyinjective.core.network import Network
5+
6+
7+
async def main() -> None:
8+
network = Network.testnet()
9+
client = AsyncClient(network)
10+
11+
denom = "inj"
12+
vouchers = await client.fetch_auction_vouchers(denom=denom)
13+
print(vouchers)
14+
15+
16+
if __name__ == "__main__":
17+
asyncio.get_event_loop().run_until_complete(main())
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import asyncio
2+
3+
from pyinjective.async_client_v2 import AsyncClient
4+
from pyinjective.core.network import Network
5+
6+
7+
async def main() -> None:
8+
network = Network.testnet()
9+
client = AsyncClient(network)
10+
11+
denom = "inj"
12+
address = "inj1knhahceyp57j5x7xh69p7utegnnnfgxavmahjr"
13+
voucher = await client.fetch_auction_voucher(denom=denom, address=address)
14+
print(voucher)
15+
16+
17+
if __name__ == "__main__":
18+
asyncio.get_event_loop().run_until_complete(main())

examples/chain_client/distribution/1_SetWithdrawAddress.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
import dotenv
66

7-
from pyinjective import AsyncClient, PrivateKey
7+
from pyinjective import PrivateKey
8+
from pyinjective.async_client_v2 import AsyncClient
89
from pyinjective.core.broadcaster import MsgBroadcasterWithPk
910
from pyinjective.core.network import Network
1011

examples/chain_client/distribution/4_FundCommunityPool.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
import dotenv
77

8-
from pyinjective import AsyncClient, PrivateKey
8+
from pyinjective import PrivateKey
9+
from pyinjective.async_client_v2 import AsyncClient
910
from pyinjective.core.broadcaster import MsgBroadcasterWithPk
1011
from pyinjective.core.network import Network
1112

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import asyncio
2+
import json
3+
import os
4+
5+
import dotenv
6+
7+
from pyinjective.async_client_v2 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+
private_key_in_hexa = os.getenv("INJECTIVE_PRIVATE_KEY")
16+
17+
network = Network.devnet()
18+
19+
client = AsyncClient(network)
20+
composer = await client.composer()
21+
22+
gas_price = await client.current_chain_gas_price()
23+
gas_price = int(gas_price * 1.1)
24+
25+
message_broadcaster = MsgBroadcasterWithPk.new_using_simulation(
26+
network=network,
27+
private_key=private_key_in_hexa,
28+
gas_price=gas_price,
29+
client=client,
30+
composer=composer,
31+
)
32+
33+
priv_key = PrivateKey.from_hex(private_key_in_hexa)
34+
pub_key = priv_key.to_public_key()
35+
address = pub_key.to_address()
36+
37+
denom = "factory/inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r/inj_test"
38+
39+
message = composer.msg_insurance_claim_voucher(
40+
sender=address.to_acc_bech32(),
41+
denom=denom,
42+
)
43+
44+
result = await message_broadcaster.broadcast([message])
45+
print("---Transaction Response---")
46+
print(json.dumps(result, indent=2))
47+
48+
gas_price = await client.current_chain_gas_price()
49+
gas_price = int(gas_price * 1.1)
50+
message_broadcaster.update_gas_price(gas_price=gas_price)
51+
52+
53+
if __name__ == "__main__":
54+
asyncio.get_event_loop().run_until_complete(main())

0 commit comments

Comments
 (0)