1-
2-
31# Copyright 2021 Injective Labs
42#
53# Licensed under the Apache License, Version 2.0 (the "License");
2018import logging
2119import json
2220
23- from .._transaction import Transaction as Transaction
24- from .._wallet import generate_wallet as generate_wallet
25- from .._wallet import privkey_to_address as privkey_to_address
26- from .._wallet import privkey_to_pubkey as privkey_to_pubkey
27- from .._wallet import pubkey_to_address as pubkey_to_address
28- from .._wallet import seed_to_privkey as seed_to_privkey
21+ from injective .chain_client ._transaction import Transaction
22+ from injective .chain_client ._wallet import (
23+ generate_wallet ,
24+ privkey_to_address ,
25+ privkey_to_pubkey ,
26+ pubkey_to_address ,
27+ seed_to_privkey ,
28+ )
2929
3030
3131MIN_GAS_PRICE = 500000000
3232
3333
3434async def main () -> None :
3535 # user1 @ e2e-multinode
36- sender_pk = seed_to_privkey ("physical page glare junk return scale subject river token door mirror title" )
36+ sender_pk = seed_to_privkey (
37+ "physical page glare junk return scale subject river token door mirror title"
38+ )
3739 sender_acc_addr = privkey_to_address (sender_pk )
3840 print ("Sender Account:" , sender_acc_addr )
3941
@@ -49,7 +51,7 @@ async def main() -> None:
4951 sequence = acc_seq ,
5052 gas = 200000 ,
5153 fee = 200000 * MIN_GAS_PRICE ,
52- sync_mode = "block"
54+ sync_mode = "block" ,
5355 )
5456 tx .add_cosmos_bank_msg_send (
5557 recipient = "inj1qy69k458ppmj45c3vqwcd6wvlcuvk23x0hsz58" , # maxim @ e2e-multinode
@@ -64,42 +66,47 @@ async def main() -> None:
6466
6567 tx_json = tx .get_signed ()
6668
67- print (' Signed Tx:' , tx_json )
68- print (' Sent Tx:' , await post_tx (tx_json ))
69+ print (" Signed Tx:" , tx_json )
70+ print (" Sent Tx:" , await post_tx (tx_json ))
6971
7072
7173async def get_account_num_seq (address : str ) -> (int , int ):
7274 async with aiohttp .ClientSession () as session :
7375 async with session .request (
74- 'GET' , 'http://localhost:10337/cosmos/auth/v1beta1/accounts/' + address ,
75- headers = {'Accept-Encoding' : 'application/json' },
76+ "GET" ,
77+ "http://localhost:10337/cosmos/auth/v1beta1/accounts/" + address ,
78+ headers = {"Accept-Encoding" : "application/json" },
7679 ) as response :
7780 if response .status != 200 :
7881 print (await response .text ())
7982 raise ValueError ("HTTP response status" , response .status )
8083
8184 resp = json .loads (await response .text ())
82- acc = resp [' account' ][ ' base_account' ]
83- return acc [' account_number' ], acc [' sequence' ]
85+ acc = resp [" account" ][ " base_account" ]
86+ return acc [" account_number" ], acc [" sequence" ]
8487
8588
8689async def post_tx (tx_json : str ):
8790 async with aiohttp .ClientSession () as session :
8891 async with session .request (
89- 'POST' , 'http://localhost:10337/txs' , data = tx_json ,
90- headers = {'Content-Type' : 'application/json' },
92+ "POST" ,
93+ "http://localhost:10337/txs" ,
94+ data = tx_json ,
95+ headers = {"Content-Type" : "application/json" },
9196 ) as response :
9297 if response .status != 200 :
9398 print (await response .text ())
9499 raise ValueError ("HTTP response status" , response .status )
95100
96101 resp = json .loads (await response .text ())
97- if ' code' in resp :
102+ if " code" in resp :
98103 print ("Response:" , resp )
99- raise ValueError (' sdk error %d: %s' % (resp [' code' ], resp [' raw_log' ]))
104+ raise ValueError (" sdk error %d: %s" % (resp [" code" ], resp [" raw_log" ]))
100105
101- return resp [' txhash' ]
106+ return resp [" txhash" ]
102107
103- if __name__ == '__main__' :
108+
109+ if __name__ == "__main__" :
104110 logging .basicConfig (level = logging .INFO )
105- asyncio .get_event_loop ().run_until_complete (main ())
111+ asyncio .get_event_loop ().run_until_complete (main ())
112+
0 commit comments