function/method renames
This commit is contained in:
parent
4e825a58ef
commit
a94ddb5f01
10 changed files with 18 additions and 18 deletions
|
|
@ -53,7 +53,7 @@ class help_notes:
|
|||
def swaptxcreate_args(self):
|
||||
return 'COIN1 [AMT CHG_ADDR] COIN2 [ADDR]'
|
||||
|
||||
def account_info_desc(self):
|
||||
def acct_info_desc(self):
|
||||
return 'unspent outputs' if self.proto.base_proto == 'Bitcoin' else 'account info'
|
||||
|
||||
def fee_spec_letters(self, *, use_quotes=False, proto=None):
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ opts_data = {
|
|||
'options': lambda cfg, proto, help_notes, s: s.format(
|
||||
cfg = cfg,
|
||||
cu = proto.coin,
|
||||
a_info = help_notes('account_info_desc'),
|
||||
a_info = help_notes('acct_info_desc'),
|
||||
fu = help_notes('rel_fee_desc'),
|
||||
fl = help_notes('fee_spec_letters', use_quotes=True),
|
||||
tp = fmt_dict(tx_priorities, fmt='equal_compact'),
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ column below:{n_fc}{n_cx}"""
|
|||
cu = proto.coin,
|
||||
pnm = gc.proj_name,
|
||||
pnl = gc.proj_name.lower(),
|
||||
a_info = help_notes('account_info_desc'),
|
||||
a_info = help_notes('acct_info_desc'),
|
||||
kgs = help_notes('keygen_backends'),
|
||||
coin_id = help_notes('coin_id'),
|
||||
fu = help_notes('rel_fee_desc'),
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class THORChainRemoteRPCClient(RemoteRPCClient):
|
|||
self.rest_api = ThornodeRemoteRESTClient(cfg, proto)
|
||||
self.rpc_api = ThornodeRemoteRPCClient(cfg, proto)
|
||||
|
||||
def get_balance(self, addr: str, *, block=None):
|
||||
def balance(self, addr: str, *, block=None):
|
||||
"get balance for a given address, optionally at a given block height"
|
||||
res = process_response(
|
||||
self.rest_api.get(path=f'/bank/balances/{addr}'),
|
||||
|
|
@ -68,13 +68,13 @@ class THORChainRemoteRPCClient(RemoteRPCClient):
|
|||
assert len(rune_res) == 1, f'{rune_res}: result length is not one!'
|
||||
return self.proto.coin_amt(int(rune_res[0]['amount']), from_unit='satoshi')
|
||||
|
||||
def get_account_info(self, addr: str, *, block=None):
|
||||
def acct_info(self, addr: str, *, block=None):
|
||||
"get account information for a given address, optionally at a given block height"
|
||||
return process_response(
|
||||
self.rest_api.get(path=f'/auth/accounts/{addr}'),
|
||||
errmsg = f'address ‘{addr}’ not found in blockchain')['value']
|
||||
|
||||
def get_tx_info(self, txid: str):
|
||||
def tx_info(self, txid: str):
|
||||
"get transaction information for a given TxID"
|
||||
return process_response(
|
||||
self.rpc_api.post(
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class THORChainTwCtl(TwCtlWithStore):
|
|||
async def rpc_get_balance(self, addr, block='latest'):
|
||||
assert self.rpc.is_remote, 'tw.store.rpc_get_balance(): RPC is not remote!'
|
||||
try:
|
||||
return self.rpc.get_balance(addr, block=block)
|
||||
return self.rpc.balance(addr, block=block)
|
||||
except Exception as e:
|
||||
ymsg(f'{type(e).__name__}: {e}')
|
||||
ymsg(f'Unable to get balance for address ‘{addr}’')
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class New(VmNew, Base, TxBase.New):
|
|||
({'memo': self.swap_memo} if self.is_swap else {}))
|
||||
|
||||
async def make_txobj(self): # called by create_serialized()
|
||||
acct_info = self.rpc.get_account_info(self.inputs[0].addr)
|
||||
acct_info = self.rpc.acct_info(self.inputs[0].addr)
|
||||
self.txobj = {
|
||||
'from': self.inputs[0].addr,
|
||||
'to': self.outputs[0].addr if self.outputs else None,
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class OnlineSigned(Signed, TxBase.OnlineSigned):
|
|||
|
||||
async def get_receipt(self, txid, *, receipt_only=False):
|
||||
try:
|
||||
return self.rpc.get_tx_info(txid)
|
||||
return self.rpc.tx_info(txid)
|
||||
except Exception as e:
|
||||
msg(f'{type(e).__name__}: {e}')
|
||||
return False
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class Status(TxBase.Status):
|
|||
async def display(self, *, idx=''):
|
||||
|
||||
try:
|
||||
self.tx.rpc.get_tx_info(self.tx.coin_txid)
|
||||
self.tx.rpc.tx_info(self.tx.coin_txid)
|
||||
except Exception as e:
|
||||
msg(f'{type(e).__name__}: {e}')
|
||||
return 2
|
||||
|
|
|
|||
|
|
@ -27,13 +27,13 @@ class ThornodeRPCServer(ThornodeServer):
|
|||
|
||||
# pylint: disable=unsubscriptable-object
|
||||
|
||||
def get_balance(m, length):
|
||||
def balance(m, length):
|
||||
return [
|
||||
{'denom': 'foocoin', 'amount': 321321321321},
|
||||
{'denom': 'rune', 'amount': 987654321321},
|
||||
{'denom': 'barcoin', 'amount': 123123123123}]
|
||||
|
||||
def get_account_info(m, length):
|
||||
def acct_info(m, length):
|
||||
return {
|
||||
'value': {
|
||||
'address': m[1],
|
||||
|
|
@ -41,7 +41,7 @@ class ThornodeRPCServer(ThornodeServer):
|
|||
'account_number': '1234',
|
||||
'sequence': '333444'}}
|
||||
|
||||
def get_tx_info(m, length):
|
||||
def tx_info(m, length):
|
||||
txid = environ['wsgi.input'].read(length).decode().removeprefix('hash=0x').upper()
|
||||
return {
|
||||
'hash': txid,
|
||||
|
|
@ -75,9 +75,9 @@ class ThornodeRPCServer(ThornodeServer):
|
|||
return res
|
||||
|
||||
pat_info = (
|
||||
('get_balance', 'GET', r'/bank/balances/(\S+)'),
|
||||
('get_account_info', 'GET', r'/auth/accounts/(\S+)'),
|
||||
('get_tx_info', 'POST', r'/tx$'),
|
||||
('balance', 'GET', r'/bank/balances/(\S+)'),
|
||||
('acct_info', 'GET', r'/auth/accounts/(\S+)'),
|
||||
('tx_info', 'POST', r'/tx$'),
|
||||
('check_tx', 'POST', r'/check_tx$'),
|
||||
('broadcast_tx_sync', 'POST', r'/broadcast_tx_sync$'))
|
||||
|
||||
|
|
|
|||
|
|
@ -211,12 +211,12 @@ class unit_tests:
|
|||
|
||||
rpc = await rpc_init(regtest_cfg)
|
||||
|
||||
res = rpc.get_account_info(addr)
|
||||
res = rpc.acct_info(addr)
|
||||
assert res['address'] == addr
|
||||
assert res['account_number']
|
||||
assert res['sequence']
|
||||
|
||||
res = rpc.get_tx_info(txhash)
|
||||
res = rpc.tx_info(txhash)
|
||||
assert res['hash'] == txhash.upper()
|
||||
|
||||
res = rpc.tx_op(txbytes.hex(), op='check_tx')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue