Skip to content

Commit 52033b4

Browse files
authored
Merge pull request #311 from InjectiveLabs/release/release_v140_to_master
Release/release v140 to master
2 parents 83152b2 + ec1fb93 commit 52033b4

File tree

172 files changed

+11174
-1557
lines changed

Some content is hidden

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

172 files changed

+11174
-1557
lines changed

.coderabbit.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
reviews:
2+
auto_review:
3+
base_branches:
4+
- "master"
5+
- "dev"
6+
- "feat/.*"
7+
chat:
8+
auto_reply: true

CHANGELOG.md

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

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

5+
## [1.4.0] - 2024-03-11
6+
### Added
7+
- Added support for all queries and messages in the chain 'distribution' module
8+
- Added support for all queries and messages in the chain 'exchange' module
9+
- Use of python-dotenv in all example scripts to load private keys from a .env file
10+
511
## [1.3.1] - 2024-02-29
612
### Changed
713
- Updated cookie assistant logic to support the Indexer exchange server not using cookies and the chain server using them

examples/SendToInjective.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
import asyncio
22
import json
3+
import os
4+
5+
import dotenv
36

47
from pyinjective.core.network import Network
58
from pyinjective.sendtocosmos import Peggo
69

710

811
async def main() -> None:
12+
dotenv.load_dotenv()
13+
private_key = os.getenv("INJECTIVE_PRIVATE_KEY")
14+
915
# select network: testnet, mainnet
1016
network = Network.testnet()
1117
peggo_composer = Peggo(network=network.string())
1218

13-
private_key = "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e"
1419
ethereum_endpoint = "https://eth-goerli.g.alchemy.com/v2/q-7JVv4mTfsNh1y_djKkKn3maRBGILLL"
1520

1621
maxFeePerGas_Gwei = 4

examples/chain_client/0_LocalOrderHash.py renamed to examples/chain_client/1_LocalOrderHash.py

Lines changed: 63 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import asyncio
2+
import os
23
import uuid
4+
from decimal import Decimal
5+
6+
import dotenv
37

48
from pyinjective.async_client import AsyncClient
59
from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE
@@ -10,6 +14,9 @@
1014

1115

1216
async def main() -> None:
17+
dotenv.load_dotenv()
18+
configured_private_key = os.getenv("INJECTIVE_PRIVATE_KEY")
19+
1320
# select network: local, testnet, mainnet
1421
network = Network.testnet()
1522

@@ -19,7 +26,7 @@ async def main() -> None:
1926
await client.sync_timeout_height()
2027

2128
# load account
22-
priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3")
29+
priv_key = PrivateKey.from_hex(configured_private_key)
2330
pub_key = priv_key.to_public_key()
2431
address = pub_key.to_address()
2532
await client.fetch_account(address.to_acc_bech32())
@@ -34,57 +41,59 @@ async def main() -> None:
3441
fee_recipient = "inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r"
3542

3643
spot_orders = [
37-
composer.SpotOrder(
44+
composer.spot_order(
3845
market_id=spot_market_id,
3946
subaccount_id=subaccount_id,
4047
fee_recipient=fee_recipient,
41-
price=0.524,
42-
quantity=0.01,
43-
is_buy=True,
44-
is_po=False,
48+
price=Decimal("0.524"),
49+
quantity=Decimal("0.01"),
50+
order_type="BUY",
4551
cid=str(uuid.uuid4()),
4652
),
47-
composer.SpotOrder(
53+
composer.spot_order(
4854
market_id=spot_market_id,
4955
subaccount_id=subaccount_id,
5056
fee_recipient=fee_recipient,
51-
price=27.92,
52-
quantity=0.01,
53-
is_buy=False,
54-
is_po=False,
57+
price=Decimal("27.92"),
58+
quantity=Decimal("0.01"),
59+
order_type="SELL",
5560
cid=str(uuid.uuid4()),
5661
),
5762
]
5863

5964
derivative_orders = [
60-
composer.DerivativeOrder(
65+
composer.derivative_order(
6166
market_id=deriv_market_id,
6267
subaccount_id=subaccount_id,
6368
fee_recipient=fee_recipient,
64-
price=10500,
65-
quantity=0.01,
66-
leverage=1.5,
67-
is_buy=True,
68-
is_po=False,
69+
price=Decimal(10500),
70+
quantity=Decimal(0.01),
71+
margin=composer.calculate_margin(
72+
quantity=Decimal(0.01), price=Decimal(10500), leverage=Decimal(2), is_reduce_only=False
73+
),
74+
order_type="BUY",
6975
cid=str(uuid.uuid4()),
7076
),
71-
composer.DerivativeOrder(
77+
composer.derivative_order(
7278
market_id=deriv_market_id,
7379
subaccount_id=subaccount_id,
7480
fee_recipient=fee_recipient,
75-
price=65111,
76-
quantity=0.01,
77-
leverage=2,
78-
is_buy=False,
79-
is_reduce_only=False,
81+
price=Decimal(65111),
82+
quantity=Decimal(0.01),
83+
margin=composer.calculate_margin(
84+
quantity=Decimal(0.01), price=Decimal(65111), leverage=Decimal(2), is_reduce_only=False
85+
),
86+
order_type="SELL",
8087
cid=str(uuid.uuid4()),
8188
),
8289
]
8390

8491
# prepare tx msg
85-
spot_msg = composer.MsgBatchCreateSpotLimitOrders(sender=address.to_acc_bech32(), orders=spot_orders)
92+
spot_msg = composer.msg_batch_create_spot_limit_orders(sender=address.to_acc_bech32(), orders=spot_orders)
8693

87-
deriv_msg = composer.MsgBatchCreateDerivativeLimitOrders(sender=address.to_acc_bech32(), orders=derivative_orders)
94+
deriv_msg = composer.msg_batch_create_derivative_limit_orders(
95+
sender=address.to_acc_bech32(), orders=derivative_orders
96+
)
8897

8998
# compute order hashes
9099
order_hashes = order_hash_manager.compute_order_hashes(
@@ -107,7 +116,7 @@ async def main() -> None:
107116
gas_limit = base_gas + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation
108117
gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0")
109118
fee = [
110-
composer.Coin(
119+
composer.coin(
111120
amount=gas_price * gas_limit,
112121
denom=network.fee_denom,
113122
)
@@ -144,7 +153,7 @@ async def main() -> None:
144153
gas_limit = base_gas + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation
145154
gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0")
146155
fee = [
147-
composer.Coin(
156+
composer.coin(
148157
amount=gas_price * gas_limit,
149158
denom=network.fee_denom,
150159
)
@@ -161,57 +170,59 @@ async def main() -> None:
161170
print("gas fee: {} INJ".format(gas_fee))
162171

163172
spot_orders = [
164-
composer.SpotOrder(
173+
composer.spot_order(
165174
market_id=spot_market_id,
166175
subaccount_id=subaccount_id_2,
167176
fee_recipient=fee_recipient,
168-
price=1.524,
169-
quantity=0.01,
170-
is_buy=True,
171-
is_po=True,
177+
price=Decimal("1.524"),
178+
quantity=Decimal("0.01"),
179+
order_type="BUY_PO",
172180
cid=str(uuid.uuid4()),
173181
),
174-
composer.SpotOrder(
182+
composer.spot_order(
175183
market_id=spot_market_id,
176184
subaccount_id=subaccount_id_2,
177185
fee_recipient=fee_recipient,
178-
price=27.92,
179-
quantity=0.01,
180-
is_buy=False,
181-
is_po=False,
186+
price=Decimal("27.92"),
187+
quantity=Decimal("0.01"),
188+
order_type="SELL_PO",
182189
cid=str(uuid.uuid4()),
183190
),
184191
]
185192

186193
derivative_orders = [
187-
composer.DerivativeOrder(
194+
composer.derivative_order(
188195
market_id=deriv_market_id,
189196
subaccount_id=subaccount_id_2,
190197
fee_recipient=fee_recipient,
191-
price=25111,
192-
quantity=0.01,
193-
leverage=1.5,
194-
is_buy=True,
195-
is_po=False,
198+
price=Decimal(25111),
199+
quantity=Decimal(0.01),
200+
margin=composer.calculate_margin(
201+
quantity=Decimal(0.01), price=Decimal(25111), leverage=Decimal("1.5"), is_reduce_only=False
202+
),
203+
order_type="BUY",
196204
cid=str(uuid.uuid4()),
197205
),
198-
composer.DerivativeOrder(
206+
composer.derivative_order(
199207
market_id=deriv_market_id,
200208
subaccount_id=subaccount_id_2,
201209
fee_recipient=fee_recipient,
202-
price=65111,
203-
quantity=0.01,
204-
leverage=2,
205-
is_buy=False,
206-
is_reduce_only=False,
210+
price=Decimal(65111),
211+
quantity=Decimal(0.01),
212+
margin=composer.calculate_margin(
213+
quantity=Decimal(0.01), price=Decimal(25111), leverage=Decimal(2), is_reduce_only=False
214+
),
215+
order_type="SELL",
207216
cid=str(uuid.uuid4()),
208217
),
209218
]
210219

211220
# prepare tx msg
212-
spot_msg = composer.MsgBatchCreateSpotLimitOrders(sender=address.to_acc_bech32(), orders=spot_orders)
221+
spot_msg = composer.msg_batch_create_spot_limit_orders(sender=address.to_acc_bech32(), orders=spot_orders)
213222

214-
deriv_msg = composer.MsgBatchCreateDerivativeLimitOrders(sender=address.to_acc_bech32(), orders=derivative_orders)
223+
deriv_msg = composer.msg_batch_create_derivative_limit_orders(
224+
sender=address.to_acc_bech32(), orders=derivative_orders
225+
)
215226

216227
# compute order hashes
217228
order_hashes = order_hash_manager.compute_order_hashes(
@@ -234,7 +245,7 @@ async def main() -> None:
234245
gas_limit = base_gas + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation
235246
gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0")
236247
fee = [
237-
composer.Coin(
248+
composer.coin(
238249
amount=gas_price * gas_limit,
239250
denom=network.fee_denom,
240251
)

examples/chain_client/26_MsgWithdrawDelegatorReward.py

Lines changed: 0 additions & 76 deletions
This file was deleted.

0 commit comments

Comments
 (0)