Skip to content

Commit c7c04c5

Browse files
bug fix (#38)
* bug fix * delete duplicated stubExchangeAccount * add coincurve to dependence * add sync init_num_seq * Regen * fix type hints * change secure_channel to async * merge master push * update denoms Co-authored-by: nhannamsiu <[email protected]>
1 parent fe6eb11 commit c7c04c5

File tree

7 files changed

+34
-15
lines changed

7 files changed

+34
-15
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
**Ubuntu**
66
```bash
7-
sudo apt install python3.X-dev
7+
sudo apt install python3.X-dev autoconf automake build-essential libffi-dev libtool pkg-config
88
```
99
**Fedora**
1010
```bash
11-
sudo dnf install python3-devel
11+
sudo dnf install python3-devel autoconf automake gcc gcc-c++ libffi-devel libtool make pkgconfig
1212
```
1313

1414
**macOS**

pyinjective/async_client.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,13 @@ def __init__(
6363
self.exchange_channel = (
6464
grpc.aio.insecure_channel(network.grpc_exchange_endpoint)
6565
if insecure
66-
else grpc.secure_channel(
66+
else grpc.aio.secure_channel(
6767
network.grpc_endpoint,
6868
credentials or grpc.ssl_channel_credentials(),
6969
)
7070
)
7171
self.stubMeta = exchange_meta_rpc_grpc.InjectiveMetaRPCStub(self.exchange_channel)
7272
self.stubExchangeAccount = exchange_accounts_rpc_grpc.InjectiveAccountsRPCStub(self.exchange_channel)
73-
self.stubExchangeAccount = exchange_accounts_rpc_grpc.InjectiveAccountsRPCStub(self.exchange_channel)
7473
self.stubOracle = oracle_rpc_grpc.InjectiveOracleRPCStub(self.exchange_channel)
7574
self.stubInsurance = insurance_rpc_grpc.InjectiveInsuranceRPCStub(self.exchange_channel)
7675
self.stubSpotExchange = spot_exchange_rpc_grpc.InjectiveSpotExchangeRPCStub(self.exchange_channel)
@@ -256,7 +255,7 @@ async def get_spot_subaccount_trades(self, subaccount_id: str, market_id: str =
256255
# DerivativeRPC
257256

258257
async def get_derivative_market(self, market_id: str):
259-
req = spot_exchange_rpc_pb.MarketRequest(market_id=market_id)
258+
req = derivative_exchange_rpc_pb.MarketRequest(market_id=market_id)
260259
return await self.stubDerivativeExchange.Market(req)
261260

262261
async def get_derivative_markets(self, market_status: str = '', quote_denom: str = ''):

pyinjective/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ def get_spot_subaccount_trades(
376376
# DerivativeRPC
377377

378378
def get_derivative_market(self, market_id: str):
379-
req = spot_exchange_rpc_pb.MarketRequest(market_id=market_id)
379+
req = derivative_exchange_rpc_pb.MarketRequest(market_id=market_id)
380380
return self.stubDerivativeExchange.Market(req)
381381

382382
def get_derivative_markets(self, market_status: str = "", quote_denom: str = ""):

pyinjective/constant.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ def __init__(
3131

3232
@classmethod
3333
def load_market(cls, network, market_id):
34-
config = None
3534
if network == 'devnet':
3635
config = devnet_config
3736
elif network == 'testnet':
@@ -49,7 +48,6 @@ def load_market(cls, network, market_id):
4948

5049
@classmethod
5150
def load_peggy_denom(cls, network, symbol):
52-
config = None
5351
if network == 'devnet':
5452
config = devnet_config
5553
elif network == 'testnet':
@@ -62,12 +60,12 @@ def load_peggy_denom(cls, network, symbol):
6260
class Network:
6361
def __init__(
6462
self,
65-
lcd_endpoint: str = None,
66-
grpc_endpoint: str = None,
67-
grpc_exchange_endpoint: str = None,
68-
chain_id: str = None,
69-
fee_denom: str = None,
70-
env: str = None
63+
lcd_endpoint: str ,
64+
grpc_endpoint: str ,
65+
grpc_exchange_endpoint: str ,
66+
chain_id: str ,
67+
fee_denom: str ,
68+
env: str
7169
):
7270
self.lcd_endpoint = lcd_endpoint
7371
self.grpc_endpoint = grpc_endpoint

pyinjective/denoms_devnet.ini

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,15 @@ min_display_price_tick_size = 0.001
7979
min_quantity_tick_size = 1000
8080
min_display_quantity_tick_size = 0.001
8181

82+
[0x0511ddc4e6586f3bfe1acb2dd905f8b8a82c97e1edaef654b12ca7e6031ca0fa]
83+
description = 'Devnet Spot ATOM/USDT'
84+
base = 0
85+
quote = 6
86+
min_price_tick_size = 1000000000
87+
min_display_price_tick_size = 1000.0
88+
min_quantity_tick_size = 1000000000000000
89+
min_display_quantity_tick_size = 1000000000000000.0
90+
8291
[0x4ca0f92fc28be0c9761326016b5a1a2177dd6375558365116b5bdda9abc229ce]
8392
description = 'Devnet Derivative BTC/USDT PERP'
8493
base = 0

pyinjective/wallet.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import bech32
55
import aiohttp
66
import json
7+
import requests
78
from typing import Tuple
89
from bech32 import bech32_encode, bech32_decode, convertbits
910
from bip32 import BIP32
@@ -262,7 +263,7 @@ def get_subaccount_id(self, index: int) -> str:
262263
id = index.to_bytes(12, byteorder='big').hex()
263264
return '0x' + self.addr.hex() + id
264265

265-
async def init_num_seq(self, lcd_endpoint: str) -> "Address":
266+
async def async_init_num_seq(self, lcd_endpoint: str) -> "Address":
266267
async with aiohttp.ClientSession() as session:
267268
async with session.request(
268269
'GET', lcd_endpoint + '/cosmos/auth/v1beta1/accounts/' + self.to_acc_bech32(),
@@ -278,6 +279,17 @@ async def init_num_seq(self, lcd_endpoint: str) -> "Address":
278279
self.sequence = int(acc['sequence'])
279280
return self
280281

282+
def init_num_seq(self, lcd_endpoint: str)-> "Address":
283+
response = requests.get(f"{lcd_endpoint}/cosmos/auth/v1beta1/accounts/{self.to_acc_bech32()}",
284+
headers={'Accept-Encoding': 'application/json'})
285+
if response.status_code != 200:
286+
raise ValueError("HTTP response status", response.status_code)
287+
resp = json.loads(response.text)
288+
acc = resp['account']['base_account']
289+
self.number = int(acc['account_number'])
290+
self.sequence = int(acc['sequence'])
291+
return self
292+
281293
def get_sequence(self):
282294
current_seq = self.sequence
283295
self.sequence += 1

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"pysha3",
3131
"protobuf",
3232
"bip32",
33+
"coincurve",
3334
]
3435

3536
# The rest you shouldn't have to touch too much :)

0 commit comments

Comments
 (0)