Skip to content

Commit 70f11a1

Browse files
Merge pull request #119 from InjectiveLabs/f/add_requests
feat: release v0.5.6.8
2 parents d7fe7d2 + 9976a5d commit 70f11a1

File tree

11 files changed

+229
-8
lines changed

11 files changed

+229
-8
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ Note that the [sync client](https://github.com/InjectiveLabs/sdk-python/blob/mas
8181
**0.5.6.8**
8282
* Add skip & limit params to Exchange API methods
8383
* Add more methods in ExplorerRPC
84+
* Add bank balance chain queries
85+
* Add Peggy & IBC transfers in ExplorerRPC
8486
* Remove LB endpoint and keep K8S as default
8587
* Refactored local order hash computation
8688
* Re-gen ini files

examples/chain_client/23_MsgRelayPriceFeedPrice.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ async def main() -> None:
3636
pub_key = priv_key.to_public_key()
3737
address = await pub_key.to_address().async_init_num_seq(network.lcd_endpoint)
3838

39-
quote_decimals = 18
4039
price = 100
41-
price_to_send = [str(int(price * 10 ** quote_decimals))]
40+
price_to_send = [str(int(price * 10 ** 18))]
4241
base = ["BAYC"]
4342
quote = ["WETH"]
4443

examples/exchange_client/authz_rpc/1_Grants.py renamed to examples/chain_client/27_Grants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ async def main() -> None:
3030

3131
if __name__ == '__main__':
3232
logging.basicConfig(level=logging.INFO)
33-
asyncio.get_event_loop().run_until_complete(main())
33+
asyncio.get_event_loop().run_until_complete(main())
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright 2021 Injective Labs
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
"""Injective Exchange API client for Python. Example only."""
15+
16+
import asyncio
17+
import logging
18+
19+
from pyinjective.async_client import AsyncClient
20+
from pyinjective.constant import Network
21+
22+
async def main() -> None:
23+
network = Network.testnet()
24+
client = AsyncClient(network, insecure=False)
25+
address = "inj1cml96vmptgw99syqrrz8az79xer2pcgp0a885r"
26+
all_bank_balances = await client.get_bank_balances(address=address)
27+
print(all_bank_balances)
28+
29+
if __name__ == '__main__':
30+
logging.basicConfig(level=logging.INFO)
31+
asyncio.get_event_loop().run_until_complete(main())
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright 2021 Injective Labs
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
"""Injective Exchange API client for Python. Example only."""
15+
16+
import asyncio
17+
import logging
18+
19+
from pyinjective.async_client import AsyncClient
20+
from pyinjective.constant import Network
21+
22+
async def main() -> None:
23+
network = Network.testnet()
24+
client = AsyncClient(network, insecure=False)
25+
address = "inj1cml96vmptgw99syqrrz8az79xer2pcgp0a885r"
26+
denom = "inj"
27+
bank_balance = await client.get_bank_balance(address=address, denom=denom)
28+
print(bank_balance)
29+
30+
if __name__ == '__main__':
31+
logging.basicConfig(level=logging.INFO)
32+
asyncio.get_event_loop().run_until_complete(main())
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright 2021 Injective Labs
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
"""Injective Exchange API client for Python. Example only."""
15+
16+
import asyncio
17+
import logging
18+
19+
from pyinjective.async_client import AsyncClient
20+
from pyinjective.constant import Network
21+
22+
async def main() -> None:
23+
network = Network.testnet()
24+
client = AsyncClient(network, insecure=False)
25+
receiver = "inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r"
26+
ibc_transfers = await client.get_ibc_transfers(receiver=receiver)
27+
print(ibc_transfers)
28+
29+
if __name__ == '__main__':
30+
logging.basicConfig(level=logging.INFO)
31+
asyncio.get_event_loop().run_until_complete(main())
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright 2021 Injective Labs
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
"""Injective Exchange API client for Python. Example only."""
15+
16+
import asyncio
17+
import logging
18+
19+
from pyinjective.async_client import AsyncClient
20+
from pyinjective.constant import Network
21+
22+
async def main() -> None:
23+
network = Network.testnet()
24+
client = AsyncClient(network, insecure=False)
25+
receiver = "inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r"
26+
peggy_deposits = await client.get_peggy_deposits(receiver=receiver)
27+
print(peggy_deposits)
28+
29+
if __name__ == '__main__':
30+
logging.basicConfig(level=logging.INFO)
31+
asyncio.get_event_loop().run_until_complete(main())
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright 2021 Injective Labs
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
"""Injective Exchange API client for Python. Example only."""
15+
16+
import asyncio
17+
import logging
18+
19+
from pyinjective.async_client import AsyncClient
20+
from pyinjective.constant import Network
21+
22+
async def main() -> None:
23+
network = Network.testnet()
24+
client = AsyncClient(network, insecure=False)
25+
sender = "inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku"
26+
peggy_deposits = await client.get_peggy_withdrawals(sender=sender)
27+
print(peggy_deposits)
28+
29+
if __name__ == '__main__':
30+
logging.basicConfig(level=logging.INFO)
31+
asyncio.get_event_loop().run_until_complete(main())

pyinjective/async_client.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
query_pb2 as authz_query,
3030
authz_pb2 as authz_type,
3131
)
32+
from .proto.cosmos.bank.v1beta1 import (
33+
query_pb2_grpc as bank_query_grpc,
34+
query_pb2 as bank_query,
35+
)
3236
from .proto.cosmos.tx.v1beta1 import (
3337
service_pb2_grpc as tx_service_grpc,
3438
service_pb2 as tx_service,
@@ -92,6 +96,7 @@ def __init__(
9296
self.stubCosmosTendermint = tendermint_query_grpc.ServiceStub(self.chain_channel)
9397
self.stubAuth = auth_query_grpc.QueryStub(self.chain_channel)
9498
self.stubAuthz = authz_query_grpc.QueryStub(self.chain_channel)
99+
self.stubBank = bank_query_grpc.QueryStub(self.chain_channel)
95100
self.stubTx = tx_service_grpc.ServiceStub(self.chain_channel)
96101

97102
# attempt to load from disk
@@ -304,6 +309,21 @@ async def get_grants(self, granter: str, grantee: str, **kwargs):
304309
)
305310
)
306311

312+
async def get_bank_balances(self, address: str):
313+
return await self.stubBank.AllBalances(
314+
bank_query.QueryAllBalancesRequest(
315+
address=address
316+
)
317+
)
318+
319+
async def get_bank_balance(self, address: str, denom: str):
320+
return await self.stubBank.Balance(
321+
bank_query.QueryBalanceRequest(
322+
address=address,
323+
denom=denom
324+
)
325+
)
326+
307327
# Injective Exchange client methods
308328

309329
# Auction RPC
@@ -387,6 +407,37 @@ async def stream_blocks(self):
387407
req = explorer_rpc_pb.StreamBlocksRequest()
388408
return self.stubExplorer.StreamBlocks(req)
389409

410+
async def get_peggy_deposits(self, **kwargs):
411+
req = explorer_rpc_pb.GetPeggyDepositTxsRequest(
412+
sender=kwargs.get("sender"),
413+
receiver=kwargs.get("receiver"),
414+
limit=kwargs.get("limit"),
415+
skip=kwargs.get("skip")
416+
)
417+
return await self.stubExplorer.GetPeggyDepositTxs(req)
418+
419+
async def get_peggy_withdrawals(self, **kwargs):
420+
req = explorer_rpc_pb.GetPeggyWithdrawalTxsRequest(
421+
sender=kwargs.get("sender"),
422+
receiver=kwargs.get("receiver"),
423+
limit=kwargs.get("limit"),
424+
skip=kwargs.get("skip")
425+
)
426+
return await self.stubExplorer.GetPeggyWithdrawalTxs(req)
427+
428+
async def get_ibc_transfers(self, **kwargs):
429+
req = explorer_rpc_pb.GetIBCTransferTxsRequest(
430+
sender=kwargs.get("sender"),
431+
receiver=kwargs.get("receiver"),
432+
src_channel=kwargs.get("src_channel"),
433+
src_port=kwargs.get("src_port"),
434+
dest_channel=kwargs.get("dest_channel"),
435+
dest_port=kwargs.get("dest_port"),
436+
limit=kwargs.get("limit"),
437+
skip=kwargs.get("skip")
438+
)
439+
return await self.stubExplorer.GetIBCTransferTxs(req)
440+
390441
# AccountsRPC
391442

392443
async def stream_subaccount_balance(self, subaccount_id: str):

pyinjective/denoms_mainnet.ini

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ min_display_quantity_tick_size = 0.01
218218
description = 'Mainnet Spot LUNA/UST'
219219
base = 6
220220
quote = 6
221-
min_price_tick_size = 0.01
222-
min_display_price_tick_size = 0.01
221+
min_price_tick_size = 0.00000001
222+
min_display_price_tick_size = 0.00000001
223223
min_quantity_tick_size = 100000
224224
min_display_quantity_tick_size = 0.1
225225

@@ -268,6 +268,15 @@ min_display_price_tick_size = 0.0001
268268
min_quantity_tick_size = 1000
269269
min_display_quantity_tick_size = 0.001
270270

271+
[0xd5f5895102b67300a2f8f2c2e4b8d7c4c820d612bc93c039ba8cb5b93ccedf22]
272+
description = 'Mainnet Spot DOT/USDT'
273+
base = 10
274+
quote = 6
275+
min_price_tick_size = 0.000001
276+
min_display_price_tick_size = 0.01
277+
min_quantity_tick_size = 100000000
278+
min_display_quantity_tick_size = 0.01
279+
271280
[0x4ca0f92fc28be0c9761326016b5a1a2177dd6375558365116b5bdda9abc229ce]
272281
description = 'Mainnet Derivative BTC/USDT PERP'
273282
base = 0
@@ -308,8 +317,8 @@ min_display_quantity_tick_size = 0.001
308317
description = 'Mainnet Derivative LUNA/UST PERP'
309318
base = 0
310319
quote = 6
311-
min_price_tick_size = 10000
312-
min_display_price_tick_size = 0.01
320+
min_price_tick_size = 0.01
321+
min_display_price_tick_size = 0.00000001
313322
min_quantity_tick_size = 0.1
314323
min_display_quantity_tick_size = 0.1
315324

@@ -455,3 +464,7 @@ decimals = 18
455464
peggy_denom = ibc/B786E7CBBF026F6F15A8DA248E0F18C62A0F7A70CB2DABD9239398C8B5150ABB
456465
decimals = 6
457466

467+
[DOT]
468+
peggy_denom = ibc/624BA9DD171915A2B9EA70F69638B2CEA179959850C1A586F6C485498F29EDD4
469+
decimals = 10
470+

0 commit comments

Comments
 (0)