Skip to content

Commit d67b6b8

Browse files
author
abel
committed
Merge branch 'master' of https://github.com/InjectiveLabs/sdk-python into dev
2 parents 485a27b + aa191ae commit d67b6b8

37 files changed

+511
-169
lines changed

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,34 @@ make tests
8787
```
8888

8989
### Changelogs
90-
**0.7.1**(change before release)
90+
**0.8**(change before release)
9191
* Refactor Composer to be created with all the markets and tokens. The Composer now uses the real markets and tokens to convert human-readable values to chain format
9292
* The Composer can still be instantiated without markets and tokens. When markets and tokens are not provided the Composer loads the required information from the Denoms used in previous versions
9393
* Change in AsyncClient to be able to create Composer instances for the client network, markets and tokens
9494
* Examples have been adapted to create Composer instances using the AsyncClient
9595

96+
**0.7.1.1**
97+
* Fixed Testnet network URLs
98+
99+
**0.7.1**
100+
* Include implementation of the MessageBroadcaster, to simplify the transaction creation and broadcasting process.
101+
102+
**0.7.0.6**
103+
* ADD SEI/USDT in metadata
104+
105+
**0.7.0.5**
106+
* Added the required logic in the MsgSubaccountTransfer message to translate amounts and token into the correct amount and token name representation for the chain
107+
108+
**0.7.0.4**
109+
* Synchronized decimals for ATOM and WETH in Testnet with the configuration provided by the indexer
110+
111+
**0.7.0.3**
112+
* Add FRCOIN testnet
113+
114+
**0.7.0.2**
115+
* Removed from AsyncClient all references to the deprecated OrderBook RPC endpoints (replaced them with OrderBookV2)
116+
* Updated all orderbook examples
117+
96118
**0.7**
97119
* Removed references to pysha3 library (and also eip712-struct that required it) and replaced it with other implementation to allow the project to work with Python 3.11
98120
* Updated sentry nodes LCD URL, for each sentry node to use its own service

examples/chain_client/0_LocalOrderHash.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ async def main() -> None:
3131

3232
# prepare trade info
3333
spot_market_id = "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe"
34-
deriv_market_id = "0x90e662193fa29a3a7e6c07be4407c94833e762d9ee82136a2cc712d6b87d7de3"
34+
deriv_market_id = "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6"
3535
fee_recipient = "inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r"
3636

3737
spot_orders = [

examples/chain_client/13_MsgIncreasePositionMargin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async def main() -> None:
2323
subaccount_id = address.get_subaccount_id(index=0)
2424

2525
# prepare trade info
26-
market_id = "0x90e662193fa29a3a7e6c07be4407c94833e762d9ee82136a2cc712d6b87d7de3"
26+
market_id = "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6"
2727

2828
# prepare tx msg
2929
msg = composer.MsgIncreasePositionMargin(

examples/chain_client/16_MsgSubaccountTransfer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ async def main() -> None:
2929
source_subaccount_id=subaccount_id,
3030
destination_subaccount_id=dest_subaccount_id,
3131
amount=100,
32-
denom="inj"
32+
denom="INJ"
3333
)
3434

3535
# build sim tx

examples/chain_client/17_MsgBatchUpdateOrders.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ async def main() -> None:
2525
# prepare trade info
2626
fee_recipient = "inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r"
2727

28-
derivative_market_id_create = "0x90e662193fa29a3a7e6c07be4407c94833e762d9ee82136a2cc712d6b87d7de3"
28+
derivative_market_id_create = "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6"
2929
spot_market_id_create = "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe"
3030

3131
derivative_market_id_cancel = "0xd5e4b12b19ecf176e4e14b42944731c27677819d2ed93be4104ad7025529c7ff"
32-
derivative_market_id_cancel_2 = "0x90e662193fa29a3a7e6c07be4407c94833e762d9ee82136a2cc712d6b87d7de3"
32+
derivative_market_id_cancel_2 = "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6"
3333
spot_market_id_cancel = "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe"
3434
spot_market_id_cancel_2 = "0x7a57e705bb4e09c88aecfc295569481dbf2fe1d5efe364651fbe72385938e9b0"
3535

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import asyncio
2+
3+
from pyinjective.composer import Composer as ProtoMsgComposer
4+
from pyinjective.core.broadcaster import MsgBroadcasterWithPk
5+
from pyinjective.constant import Network
6+
from pyinjective.wallet import PrivateKey
7+
8+
9+
async def main() -> None:
10+
# select network: local, testnet, mainnet
11+
network = Network.testnet()
12+
composer = ProtoMsgComposer(network=network.string())
13+
private_key_in_hexa = "f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3"
14+
15+
message_broadcaster = MsgBroadcasterWithPk.new_using_simulation(
16+
network=network,
17+
private_key=private_key_in_hexa,
18+
use_secure_connection=True
19+
)
20+
21+
priv_key = PrivateKey.from_hex(private_key_in_hexa)
22+
pub_key = priv_key.to_public_key()
23+
address = pub_key.to_address()
24+
subaccount_id = address.get_subaccount_id(index=0)
25+
26+
# prepare trade info
27+
fee_recipient = "inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r"
28+
29+
spot_market_id_create = "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe"
30+
31+
spot_orders_to_create = [
32+
composer.SpotOrder(
33+
market_id=spot_market_id_create,
34+
subaccount_id=subaccount_id,
35+
fee_recipient=fee_recipient,
36+
price=3,
37+
quantity=55,
38+
is_buy=True,
39+
is_po=False
40+
),
41+
composer.SpotOrder(
42+
market_id=spot_market_id_create,
43+
subaccount_id=subaccount_id,
44+
fee_recipient=fee_recipient,
45+
price=300,
46+
quantity=55,
47+
is_buy=False,
48+
is_po=False
49+
),
50+
]
51+
52+
# prepare tx msg
53+
msg = composer.MsgBatchUpdateOrders(
54+
sender=address.to_acc_bech32(),
55+
spot_orders_to_create=spot_orders_to_create,
56+
)
57+
58+
# broadcast the transaction
59+
result = await message_broadcaster.broadcast([msg])
60+
print("---Transaction Response---")
61+
print(result)
62+
63+
if __name__ == "__main__":
64+
asyncio.get_event_loop().run_until_complete(main())
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import asyncio
2+
3+
from pyinjective.composer import Composer as ProtoMsgComposer
4+
from pyinjective.async_client import AsyncClient
5+
from pyinjective.core.broadcaster import MsgBroadcasterWithPk
6+
from pyinjective.constant import Network
7+
from pyinjective.wallet import PrivateKey, Address
8+
9+
10+
async def main() -> None:
11+
# select network: local, testnet, mainnet
12+
network = Network.testnet()
13+
composer = ProtoMsgComposer(network=network.string())
14+
15+
# initialize grpc client
16+
client = AsyncClient(network, insecure=False)
17+
await client.sync_timeout_height()
18+
19+
# load account
20+
private_key_in_hexa = "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e"
21+
priv_key = PrivateKey.from_hex(private_key_in_hexa)
22+
pub_key = priv_key.to_public_key()
23+
address = pub_key.to_address()
24+
25+
message_broadcaster = MsgBroadcasterWithPk.new_for_grantee_account_using_simulation(
26+
network=network,
27+
grantee_private_key=private_key_in_hexa,
28+
use_secure_connection=True
29+
)
30+
31+
# prepare tx msg
32+
market_id = "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe"
33+
granter_inj_address = "inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r"
34+
granter_address = Address.from_acc_bech32(granter_inj_address)
35+
granter_subaccount_id = granter_address.get_subaccount_id(index=0)
36+
37+
msg = composer.MsgCreateSpotLimitOrder(
38+
sender=granter_inj_address,
39+
market_id=market_id,
40+
subaccount_id=granter_subaccount_id,
41+
fee_recipient=address.to_acc_bech32(),
42+
price=7.523,
43+
quantity=0.01,
44+
is_buy=True,
45+
is_po=False
46+
)
47+
48+
# broadcast the transaction
49+
result = await message_broadcaster.broadcast([msg])
50+
print("---Transaction Response---")
51+
print(result)
52+
53+
if __name__ == "__main__":
54+
asyncio.get_event_loop().run_until_complete(main())

examples/chain_client/6_MsgCreateDerivativeLimitOrder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async def main() -> None:
2323
subaccount_id = address.get_subaccount_id(index=0)
2424

2525
# prepare trade info
26-
market_id = "0x141e3c92ed55107067ceb60ee412b86256cedef67b1227d6367b4cdf30c55a74"
26+
market_id = "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6"
2727
fee_recipient = "inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r"
2828

2929
# prepare tx msg

examples/chain_client/7_MsgCreateDerivativeMarketOrder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async def main() -> None:
2323
subaccount_id = address.get_subaccount_id(index=0)
2424

2525
# prepare trade info
26-
market_id = "0x90e662193fa29a3a7e6c07be4407c94833e762d9ee82136a2cc712d6b87d7de3"
26+
market_id = "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6"
2727
fee_recipient = "inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r"
2828

2929
# prepare tx msg

examples/chain_client/8_MsgCancelDerivativeOrder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async def main() -> None:
2323
subaccount_id = address.get_subaccount_id(index=0)
2424

2525
# prepare trade info
26-
market_id = "0x90e662193fa29a3a7e6c07be4407c94833e762d9ee82136a2cc712d6b87d7de3"
26+
market_id = "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6"
2727
order_hash = "0x667ee6f37f6d06bf473f4e1434e92ac98ff43c785405e2a511a0843daeca2de9"
2828

2929
# prepare tx msg

0 commit comments

Comments
 (0)