Skip to content

Commit e660d24

Browse files
committed
"wip : change makefile + pull from betaTrading core"
1 parent ec27603 commit e660d24

File tree

532 files changed

+124
-46146
lines changed

Some content is hidden

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

532 files changed

+124
-46146
lines changed

Makefile

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@ all:
22

33
gen: gen-client
44

5-
gen-client: clone-all copy-proto
5+
gen-client:
6+
git clone --depth 1 --branch v1.13.2 https://github.com/InjectiveLabs/injective-core
7+
mkdir -p proto
8+
9+
cp -r injective-core/proto/* proto/
610
mkdir -p ./pyinjective/proto
711
buf generate --template buf.gen.yaml
812
rm -rf proto
913
$(call clean_repos)
1014
$(MAKE) fix-generated-proto-imports
1115

12-
PROTO_MODULES := cosmwasm exchange gogoproto cosmos_proto cosmos testpb ibc amino tendermint injective
16+
PROTO_MODULES := cosmwasm gogoproto cosmos_proto cosmos testpb ibc amino tendermint injective
1317

1418
fix-generated-proto-imports:
1519
@touch pyinjective/proto/__init__.py
@@ -29,17 +33,6 @@ endef
2933

3034
clean-all:
3135
$(call clean_repos)
32-
33-
clone-injective-indexer:
34-
git clone https://github.com/InjectiveLabs/injective-indexer.git -b v1.13.4 --depth 1 --single-branch
35-
36-
clone-all: clone-injective-indexer
37-
38-
copy-proto:
39-
rm -rf pyinjective/proto
40-
mkdir -p proto/exchange
41-
find ./injective-indexer/api/gen/grpc -type f -name "*.proto" -exec cp {} ./proto/exchange/ \;
42-
4336
tests:
4437
poetry run pytest -v
4538

buf.gen.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ inputs:
2121
# branch: v0.51.x-inj
2222
# subdir: proto
2323
- git_repo: https://github.com/InjectiveLabs/injective-core
24-
tag: v1.13.0
24+
tag: v1.13.2
2525
subdir: proto
2626
# - git_repo: https://github.com/InjectiveLabs/injective-core
2727
# branch: master

pyinjective/async_client.py

Lines changed: 12 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def __init__(
9898
self.timeout_height = 1
9999

100100
# exchange stubs
101-
101+
102102
self.chain_stream_channel = self.network.create_chain_stream_grpc_channel()
103103
self.chain_stream_stub = stream_rpc_grpc.StreamStub(channel=self.chain_stream_channel)
104104

@@ -174,68 +174,6 @@ def __init__(
174174
cookie_assistant=network.chain_cookie_assistant,
175175
)
176176

177-
# self.exchange_account_api = IndexerGrpcAccountApi(
178-
# channel=self.exchange_channel,
179-
# cookie_assistant=network.exchange_cookie_assistant,
180-
# )
181-
# self.exchange_auction_api = IndexerGrpcAuctionApi(
182-
# channel=self.exchange_channel,
183-
# cookie_assistant=network.exchange_cookie_assistant,
184-
# )
185-
# self.exchange_derivative_api = IndexerGrpcDerivativeApi(
186-
# channel=self.exchange_channel,
187-
# cookie_assistant=network.exchange_cookie_assistant,
188-
# )
189-
# self.exchange_insurance_api = IndexerGrpcInsuranceApi(
190-
# channel=self.exchange_channel,
191-
# cookie_assistant=network.exchange_cookie_assistant,
192-
# )
193-
# self.exchange_meta_api = IndexerGrpcMetaApi(
194-
# channel=self.exchange_channel,
195-
# cookie_assistant=network.exchange_cookie_assistant,
196-
# )
197-
# self.exchange_oracle_api = IndexerGrpcOracleApi(
198-
# channel=self.exchange_channel,
199-
# cookie_assistant=network.exchange_cookie_assistant,
200-
# )
201-
# self.exchange_portfolio_api = IndexerGrpcPortfolioApi(
202-
# channel=self.exchange_channel,
203-
# cookie_assistant=network.exchange_cookie_assistant,
204-
# )
205-
# self.exchange_spot_api = IndexerGrpcSpotApi(
206-
# channel=self.exchange_channel,
207-
# cookie_assistant=network.exchange_cookie_assistant,
208-
# )
209-
#
210-
# self.exchange_account_stream_api = IndexerGrpcAccountStream(
211-
# channel=self.exchange_channel,
212-
# cookie_assistant=network.exchange_cookie_assistant,
213-
# )
214-
# self.exchange_auction_stream_api = IndexerGrpcAuctionStream(
215-
# channel=self.exchange_channel,
216-
# cookie_assistant=network.exchange_cookie_assistant,
217-
# )
218-
# self.exchange_derivative_stream_api = IndexerGrpcDerivativeStream(
219-
# channel=self.exchange_channel,
220-
# cookie_assistant=network.exchange_cookie_assistant,
221-
# )
222-
# self.exchange_meta_stream_api = IndexerGrpcMetaStream(
223-
# channel=self.exchange_channel,
224-
# cookie_assistant=network.exchange_cookie_assistant,
225-
# )
226-
# self.exchange_oracle_stream_api = IndexerGrpcOracleStream(
227-
# channel=self.exchange_channel,
228-
# cookie_assistant=network.exchange_cookie_assistant,
229-
# )
230-
# self.exchange_portfolio_stream_api = IndexerGrpcPortfolioStream(
231-
# channel=self.exchange_channel,
232-
# cookie_assistant=network.exchange_cookie_assistant,
233-
# )
234-
# self.exchange_spot_stream_api = IndexerGrpcSpotStream(
235-
# channel=self.exchange_channel,
236-
# cookie_assistant=network.exchange_cookie_assistant,
237-
# )
238-
239177
async def all_tokens(self) -> Dict[str, Token]:
240178
if self._tokens_by_symbol is None:
241179
async with self._tokens_and_markets_initialization_lock:
@@ -835,9 +773,7 @@ async def fetch_subaccount_position_in_market(self, subaccount_id: str, market_i
835773
market_id=market_id,
836774
)
837775

838-
async def fetch_subaccount_effective_position_in_market(
839-
self, subaccount_id: str, market_id: str
840-
) -> Dict[str, Any]:
776+
async def fetch_subaccount_effective_position_in_market(self, subaccount_id: str, market_id: str) -> Dict[str, Any]:
841777
return await self.chain_exchange_api.fetch_subaccount_effective_position_in_market(
842778
subaccount_id=subaccount_id,
843779
market_id=market_id,
@@ -1118,11 +1054,9 @@ async def fetch_spot_markets(
11181054
async def fetch_spot_orderbook(self, market_id: str) -> Dict[str, Any]:
11191055
return await self.chain_exchange_api.fetch_orderbook_v2(market_id=market_id)
11201056

1121-
1122-
11231057
# DerivativeRPC
11241058
####MASSIVE TODO : NEED TO WRITE A LIQUIDABLE POSITIONS WATCHER#######
1125-
#async def get_derivative_liquidable_positions(self, **kwargs):
1059+
# async def get_derivative_liquidable_positions(self, **kwargs):
11261060
# """
11271061
# This method is deprecated and will be removed soon. Please use `fetch_derivative_liquidable_positions` instead
11281062
# """
@@ -1138,16 +1072,16 @@ async def fetch_spot_orderbook(self, market_id: str) -> Dict[str, Any]:
11381072
# )
11391073
# return await self.stubDerivativeExchange.LiquidablePositions(req)
11401074

1141-
#async def fetch_derivative_liquidable_positions(
1075+
# async def fetch_derivative_liquidable_positions(
11421076
# self,
11431077
# market_id: Optional[str] = None,
11441078
# pagination: Optional[PaginationOption] = None,
1145-
#) -> Dict[str, Any]:
1079+
# ) -> Dict[str, Any]:
11461080
# return await self.exchange_derivative_api.fetch_liquidable_positions(
11471081
# market_id=market_id,
11481082
# pagination=pagination,
11491083
# )
1150-
# PortfolioRPC
1084+
# PortfolioRPC
11511085
async def chain_stream(
11521086
self,
11531087
bank_balances_filter: Optional[chain_stream_query.BankBalancesFilter] = None,
@@ -1501,9 +1435,7 @@ async def _initialize_tokens_and_markets(self):
15011435

15021436
spot_markets[market.id] = market
15031437

1504-
markets_info = (await self.fetch_derivative_markets(status="Active", with_mid_price_and_tob=False))[
1505-
"markets"
1506-
]
1438+
markets_info = (await self.fetch_derivative_markets(status="Active", with_mid_price_and_tob=False))["markets"]
15071439
for market_info in markets_info:
15081440
market = market_info["market"]
15091441
quote_token = self._tokens_by_denom.get(market["quoteDenom"])
@@ -1566,9 +1498,11 @@ async def _initialize_tokens_and_markets(self):
15661498
Decimal(market_info["minQuantityTickSize"])
15671499
),
15681500
min_notional=Token.convert_value_from_extended_decimal_format(Decimal(market_info["minNotional"])),
1569-
settlement_price=None
1570-
if market_info["settlementPrice"] == ""
1571-
else Token.convert_value_from_extended_decimal_format(Decimal(market_info["settlementPrice"])),
1501+
settlement_price=(
1502+
None
1503+
if market_info["settlementPrice"] == ""
1504+
else Token.convert_value_from_extended_decimal_format(Decimal(market_info["settlementPrice"]))
1505+
),
15721506
)
15731507

15741508
binary_option_markets[market.id] = market

pyinjective/composer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ def MsgPrivilegedExecuteContract(
937937
sender=sender,
938938
contract_address=contract,
939939
data=msg,
940-
funds=kwargs.get("funds") # funds is a string of Coin strings, comma separated,
940+
funds=kwargs.get("funds"), # funds is a string of Coin strings, comma separated,
941941
# e.g. 100000inj,20000000000usdt
942942
)
943943

@@ -2105,7 +2105,7 @@ def MsgExecuteContract(self, sender: str, contract: str, msg: str, **kwargs):
21052105
sender=sender,
21062106
contract=contract,
21072107
msg=bytes(msg, "utf-8"),
2108-
funds=kwargs.get("funds") # funds is a list of base_coin_pb.Coin.
2108+
funds=kwargs.get("funds"), # funds is a list of base_coin_pb.Coin.
21092109
# The coins in the list must be sorted in alphabetical order by denoms.
21102110
)
21112111

pyinjective/core/broadcaster.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,18 @@
1818
class BroadcasterAccountConfig(ABC):
1919
@property
2020
@abstractmethod
21-
def trading_injective_address(self) -> str:
22-
...
21+
def trading_injective_address(self) -> str: ...
2322

2423
@property
2524
@abstractmethod
26-
def trading_private_key(self) -> PrivateKey:
27-
...
25+
def trading_private_key(self) -> PrivateKey: ...
2826

2927
@property
3028
@abstractmethod
31-
def trading_public_key(self) -> PublicKey:
32-
...
29+
def trading_public_key(self) -> PublicKey: ...
3330

3431
@abstractmethod
35-
def messages_prepared_for_transaction(self, messages: List[any_pb2.Any]) -> List[any_pb2.Any]:
36-
...
32+
def messages_prepared_for_transaction(self, messages: List[any_pb2.Any]) -> List[any_pb2.Any]: ...
3733

3834

3935
class TransactionFeeCalculator(ABC):
@@ -45,8 +41,7 @@ async def configure_gas_fee_for_transaction(
4541
transaction: Transaction,
4642
private_key: PrivateKey,
4743
public_key: PublicKey,
48-
):
49-
...
44+
): ...
5045

5146

5247
class MsgBroadcasterWithPk:

pyinjective/core/gas_limit_estimator.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ class GasLimitEstimator(ABC):
2727

2828
@classmethod
2929
@abstractmethod
30-
def applies_to(cls, message: any_pb2.Any) -> bool:
31-
...
30+
def applies_to(cls, message: any_pb2.Any) -> bool: ...
3231

3332
@classmethod
3433
def for_message(cls, message: any_pb2.Any):
@@ -48,8 +47,7 @@ def for_message(cls, message: any_pb2.Any):
4847
return estimator
4948

5049
@abstractmethod
51-
def gas_limit(self) -> int:
52-
...
50+
def gas_limit(self) -> int: ...
5351

5452
@staticmethod
5553
def message_type(message: any_pb2.Any) -> str:
@@ -60,8 +58,7 @@ def message_type(message: any_pb2.Any) -> str:
6058
return message_type
6159

6260
@abstractmethod
63-
def _message_class(self, message: any_pb2.Any):
64-
...
61+
def _message_class(self, message: any_pb2.Any): ...
6562

6663
def _parsed_message(self, message: any_pb2.Any) -> any_pb2.Any:
6764
if isinstance(message, any_pb2.Any):

pyinjective/core/network.py

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

1212
class CookieAssistant(ABC):
1313
@abstractmethod
14-
def cookie(self) -> Optional[str]:
15-
...
14+
def cookie(self) -> Optional[str]: ...
1615

1716
@abstractmethod
18-
async def process_response_metadata(self, grpc_call: Call):
19-
...
17+
async def process_response_metadata(self, grpc_call: Call): ...
2018

2119
def metadata(self) -> Metadata:
2220
cookie = self.cookie()

pyinjective/proto/__init__.py

Whitespace-only changes.

pyinjective/proto/amino/amino_pb2.py

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

pyinjective/proto/amino/amino_pb2_grpc.py

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

0 commit comments

Comments
 (0)