defi-state-querier 0.4.28__py3-none-any.whl → 0.4.30__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
defi_services/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.4.28"
1
+ __version__ = "0.4.30"
@@ -3,6 +3,7 @@ import logging
3
3
  from web3 import Web3
4
4
 
5
5
  from defi_services.constants.entities.lending_services import LendingServices
6
+ from defi_services.constants.query_constant import Query
6
7
  from defi_services.jobs.queriers.state_querier import StateQuerier
7
8
  from defi_services.services.nft_services import NFTServices
8
9
  from defi_services.services.protocol_services import ProtocolServices
@@ -44,6 +45,15 @@ class MultiStateProcessor:
44
45
  if entity_id in self.services:
45
46
  entity_service: ProtocolServices = self.services.get(entity_id)
46
47
  rpc_calls.update(entity_service.get_function_info([query_type], wallet, block_number, **kwargs))
48
+
49
+ if query_type == Query.token_balance:
50
+ entity_service: TokenServices = self.token_service
51
+ rpc_calls.update(entity_service.get_function_info(wallet, entity_id, block_number))
52
+
53
+ if query_type == Query.nft_balance:
54
+ entity_service: NFTServices = self.nft_service
55
+ rpc_calls.update(entity_service.get_function_info(wallet, entity_id, block_number))
56
+
47
57
  queries[entity_id] = rpc_calls
48
58
 
49
59
  return {query_id: queries}
@@ -77,7 +87,17 @@ class MultiStateProcessor:
77
87
  query_value = decoded_data.get(query_id)
78
88
  for entity, entity_value in query_value.items():
79
89
  result["entity_id"] = entity
80
- if entity in self.lending_services:
90
+ if query_type == Query.token_balance:
91
+ entity_service: TokenServices = self.token_service
92
+ data = entity_service.get_data(
93
+ wallet, entity, entity_value, block_number, **kwargs
94
+ )
95
+ elif query_type == Query.nft_balance:
96
+ entity_service: NFTServices = self.nft_service
97
+ data = entity_service.get_data(
98
+ wallet, entity, entity_value, block_number, **kwargs
99
+ )
100
+ elif entity in self.lending_services:
81
101
  entity_service: ProtocolServices = self.services.get(entity)
82
102
  data = entity_service.get_data(
83
103
  [query_type], wallet, entity_value, block_number, **kwargs)
@@ -2,9 +2,8 @@ import logging
2
2
 
3
3
  from query_state_lib.base.mappers.eth_call_mapper import EthCall
4
4
  from query_state_lib.base.mappers.get_balance_mapper import GetBalance
5
- from query_state_lib.base.utils.encoder import encode_eth_call_data
6
5
  from query_state_lib.client.client_querier import ClientQuerier
7
- from web3 import Web3
6
+ from web3 import Web3, contract
8
7
  from web3.middleware import geth_poa_middleware
9
8
 
10
9
  from defi_services.constants.query_constant import Query
@@ -124,7 +123,11 @@ class StateQuerier:
124
123
  item = self._w3.to_checksum_address(item)
125
124
  args.append(item)
126
125
 
127
- data_call = encode_eth_call_data(abi=abi, fn_name=fn_name, args=args)
126
+ c = contract.Contract
127
+ c.w3 = self._w3
128
+ c.abi = abi
129
+ data_call = c.encodeABI(fn_name=fn_name, args=args)
130
+ # data_call = encode_eth_call_data(abi=abi, fn_name=fn_name, args=args)
128
131
  eth_call = EthCall(to=self._w3.to_checksum_address(contract_address), block_number=block_number,
129
132
  data=data_call, abi=abi, fn_name=fn_name, id=call_id)
130
133
  return eth_call
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: defi-state-querier
3
- Version: 0.4.28
3
+ Version: 0.4.30
4
4
  Summary: Calculate apy, apr, and wallet information,... in decentralized applications.
5
5
  Home-page: https://github.com/Centic-io/defi-state-querier
6
6
  Author: Viet-Bang Pham
@@ -1,4 +1,4 @@
1
- defi_services/__init__.py,sha256=QZ0p7EqvqxpClz_YH3XtlxgPmyXKcK-CGg_B_p5Z7w0,23
1
+ defi_services/__init__.py,sha256=oJL8XtG8mmnvRfpE8L0X7P-SyENhGR162XgumWN6O4A,23
2
2
  defi_services/abis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  defi_services/abis/dex/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  defi_services/abis/dex/biswap/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -311,13 +311,13 @@ defi_services/constants/entities/vault_services.py,sha256=IMmQc15wS1KA7EuQqM_Ara
311
311
  defi_services/jobs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
312
312
  defi_services/jobs/processors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
313
313
  defi_services/jobs/processors/cosmos_state_processor.py,sha256=2S5fhqHQ4pUtRaLnbFJNUo4jKc5MHq7HA-0FHebOJyo,1334
314
- defi_services/jobs/processors/multi_state_processor.py,sha256=uMv1kVkkBV_GkYnMVaE8UgAhdnu7J_FzU6-fAoXCqjo,4752
314
+ defi_services/jobs/processors/multi_state_processor.py,sha256=W-5qLwIFj4kfx0V2Tj7eg0mjrRb3jyPdxEBB2TBxbW4,5726
315
315
  defi_services/jobs/processors/solana_state_processor.py,sha256=szsBYrkEV8kBzuA_iaSVescnwKJ2MHoTbut5kORbWTs,4065
316
316
  defi_services/jobs/processors/state_processor.py,sha256=Ze_5isU_l_APB262E-VV_4KZwEG6W0XE6PikJZIcAoM,7291
317
317
  defi_services/jobs/processors/substrate_state_processor.py,sha256=KkiY1NkaxnizNJBTfn4twB-zuQo3fT3akOlbie8VF5g,3940
318
318
  defi_services/jobs/queriers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
319
319
  defi_services/jobs/queriers/solana_state_querier.py,sha256=TQELYo6GUoF8s-LfetqYbclNaH8bakQqC7y2ifACIb8,3239
320
- defi_services/jobs/queriers/state_querier.py,sha256=-bx71x2ZobwuAlc2pVp5Ju_fxYt48wLrs8IdLN1KJVs,7306
320
+ defi_services/jobs/queriers/state_querier.py,sha256=q7cAW395urZjcWTpqw8m_nDunLyyTuAXJ3DRx_1HOxo,7384
321
321
  defi_services/jobs/queriers/substrate_state_querier.py,sha256=_T0Dk06sP_uBKaxgj2J_EBtJDoq-hi8jU7Np4iuO0LA,3858
322
322
  defi_services/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
323
323
  defi_services/services/cosmos_token_services.py,sha256=6z_eE7lF5tY461VJ6uVoG18hOdXKeWR4NgDDP-MGI0k,1603
@@ -452,8 +452,8 @@ defi_services/utils/market_service.py,sha256=imPtPHBkpEx5JnhqeIWYqbCjsIEm8IKBYHN
452
452
  defi_services/utils/memory_storage.py,sha256=BOT8laB0iVSCGE-oDlpWJQLbSC6X2blKX4zuQbs4inc,851
453
453
  defi_services/utils/sqrt_price_math.py,sha256=9lgUeWFT4wjl3Vq3b7-jZ2bGvvZx7dDBSfVnM3lsZ8o,5575
454
454
  defi_services/utils/thread_proxy.py,sha256=5Z8biAyEReUkh3vfJSvEv7GwMe3CsE5M8CbghkQtePw,2951
455
- defi_state_querier-0.4.28.dist-info/LICENSE,sha256=6jmfxa8nUIwfKnzZUxAHJSJ_IS7h7mpbJq26cWjoo-o,1063
456
- defi_state_querier-0.4.28.dist-info/METADATA,sha256=7q5kqwd2KpWPPDeCmBNTzhCmB4FOfBkMlrojFhs75qA,4388
457
- defi_state_querier-0.4.28.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
458
- defi_state_querier-0.4.28.dist-info/top_level.txt,sha256=C-OTxHK6MknKK-nAbEzCPDUl1M6pktRhgJrmsozdf6g,14
459
- defi_state_querier-0.4.28.dist-info/RECORD,,
455
+ defi_state_querier-0.4.30.dist-info/LICENSE,sha256=6jmfxa8nUIwfKnzZUxAHJSJ_IS7h7mpbJq26cWjoo-o,1063
456
+ defi_state_querier-0.4.30.dist-info/METADATA,sha256=9gw44vjCnsAPTaMyK6PNHXp9WKHXuOtnvVGCN2zWtrs,4388
457
+ defi_state_querier-0.4.30.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
458
+ defi_state_querier-0.4.30.dist-info/top_level.txt,sha256=C-OTxHK6MknKK-nAbEzCPDUl1M6pktRhgJrmsozdf6g,14
459
+ defi_state_querier-0.4.30.dist-info/RECORD,,