Przeglądaj źródła

一些示例信息的添加。

skyfffire 5 miesięcy temu
rodzic
commit
3bd051a8b9
2 zmienionych plików z 57 dodań i 0 usunięć
  1. 9 0
      checker/ok_chain_client.py
  2. 48 0
      web3_py_client.py

+ 9 - 0
checker/ok_chain_client.py

@@ -150,6 +150,15 @@ def approve(chain_id, token_contract_address, approve_amount):
 
     return send_get_request(get_request_path, get_params)
 
+def history(chain_id, tx_hash):
+    get_request_path = '/api/v5/dex/aggregator/history'
+    get_params = {
+        'chainIndex': chain_id,
+        'txHash': tx_hash
+    }
+
+    return send_get_request(get_request_path, get_params)
+
 def gas_limit(chain_id, from_addr, to_addr, value, call_data=None):
     post_request_path = '/api/v5/dex/pre-transaction/gas-limit'
     post_params = {

+ 48 - 0
web3_py_client.py

@@ -403,6 +403,54 @@ if __name__ == "__main__":
         tx['maxPriorityFeePerGas'] = int(tx['maxPriorityFeePerGas'])
         tx['maxFeePerGas'] = int(int(latest_block['baseFeePerGas']) * 2 + tx['maxPriorityFeePerGas'])
 
+        '''
+        {'code': '0',
+        'data': {'chainId': '1',
+                'chainIndex': '1',
+                'dexRouter': '0x6088d94c5a40cecd3ae2d4e0710ca687b91c61d0',
+                'errorMsg': '',
+                'fromAddress': '0xb1f33026db86a86372493a3b124d7123e9045bb4',
+                'fromTokenDetails': {'amount': '10000000',
+                                    'symbol': 'USDT',
+                                    'tokenAddress': '0xdac17f958d2ee523a2206206994597c13d831ec7'},
+                'gasLimit': '285000',
+                'gasPrice': '2526360593',
+                'gasUsed': '216783',
+                'height': '22586403',
+                'referralAmount': '',
+                'status': 'success',
+                'toAddress': '0xc71835a042f4d870b0f4296cc89caeb921a9f3da',
+                'toTokenDetails': {'amount': '655477388084022',
+                                    'symbol': 'RATO',
+                                    'tokenAddress': '0xf816507e690f5aa4e29d164885eb5fa7a5627860'},
+                'txFee': '',
+                'txHash': '0xe54acd58923685fb132bc0d103b72fa538e59d54dec44b3dc8e0314de7d8b126',
+                'txTime': '1748497463',
+                'txType': 'swap'},
+                'msg': ''}
+        '''
+        # pprint(ok_chain_client.history(CHAIN_ID, '0xe54acd58923685fb132bc0d103b72fa538e59d54dec44b3dc8e0314de7d8b126'))
+        '''
+        {
+            'code': '0',
+            'data': {'chainId': '1',
+                    'chainIndex': '1',
+                    'errorMsg': 'execution reverted',
+                    'fromAddress': '0xc36b5466d88d3ebe9e538ed650f61b7f9902e6cc',
+                    'gasLimit': '285000',
+                    'gasPrice': '4907400618',
+                    'gasUsed': '282898',
+                    'height': '22587649',
+                    'status': 'fail',
+                    'txFee': '',
+                    'txHash': '0x344d2d0a9efdfb46b6130a58a40e117bb3bf6181b03b09b65b4d6cc8256f1e2f',
+                    'txTime': '1748512535',
+                    'txType': ''},
+            'msg': ''
+        }
+        '''
+        pprint(ok_chain_client.history(CHAIN_ID, '0x344d2d0a9efdfb46b6130a58a40e117bb3bf6181b03b09b65b4d6cc8256f1e2f'))
+
         # pprint(ok_chain_client.gas_limit(CHAIN_ID, tx['from'], tx['to'], tx['value']))
 
         # pprint(tx)