Rehabilitate view command

This commit is contained in:
lash 2023-02-25 20:27:46 +00:00
parent c71c9d6c0b
commit bcd56d06a0
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
5 changed files with 28 additions and 9 deletions

View File

@ -1,3 +1,9 @@
- 0.6.1
* Fix broken calls for some chains; force block height parameter
- 0.6.0
* Upgrade deps
- 0.5.0
* Upgrade deps
- 0.4.0 - 0.4.0
* Upgrade chainlib * Upgrade chainlib
- 0.3.0 - 0.3.0

View File

@ -19,6 +19,8 @@ from chainlib.eth.contract import (
) )
from chainlib.jsonrpc import JSONRPCRequest from chainlib.jsonrpc import JSONRPCRequest
from chainlib.eth.constant import ZERO_ADDRESS from chainlib.eth.constant import ZERO_ADDRESS
from chainlib.block import BlockSpec
from chainlib.eth.jsonrpc import to_blockheight_param
logg = logging.getLogger(__name__) logg = logging.getLogger(__name__)
@ -39,7 +41,7 @@ class Declarator(TxFactory):
return tx return tx
def declarator_count(self, contract_address, subject_address, sender_address=ZERO_ADDRESS, id_generator=None): def declarator_count(self, contract_address, subject_address, sender_address=ZERO_ADDRESS, id_generator=None, height=BlockSpec.LATEST):
j = JSONRPCRequest(id_generator) j = JSONRPCRequest(id_generator)
o = j.template() o = j.template()
o['method'] = 'eth_call' o['method'] = 'eth_call'
@ -51,11 +53,13 @@ class Declarator(TxFactory):
tx = self.template(sender_address, contract_address) tx = self.template(sender_address, contract_address)
tx = self.set_code(tx, data) tx = self.set_code(tx, data)
o['params'].append(self.normalize(tx)) o['params'].append(self.normalize(tx))
height = to_blockheight_param(height)
o['params'].append(height)
o = j.finalize(o) o = j.finalize(o)
return o return o
def declaration(self, contract_address, declarator_address, subject_address, sender_address=ZERO_ADDRESS, id_generator=None): def declaration(self, contract_address, declarator_address, subject_address, sender_address=ZERO_ADDRESS, id_generator=None, height=BlockSpec.LATEST):
j = JSONRPCRequest(id_generator) j = JSONRPCRequest(id_generator)
o = j.template() o = j.template()
o['method'] = 'eth_call' o['method'] = 'eth_call'
@ -69,11 +73,13 @@ class Declarator(TxFactory):
tx = self.template(sender_address, contract_address) tx = self.template(sender_address, contract_address)
tx = self.set_code(tx, data) tx = self.set_code(tx, data)
o['params'].append(self.normalize(tx)) o['params'].append(self.normalize(tx))
height = to_blockheight_param(height)
o['params'].append(height)
o = j.finalize(o) o = j.finalize(o)
return o return o
def declaration_address_at(self, contract_address, declarator_address, idx, sender_address=ZERO_ADDRESS, id_generator=None): def declaration_address_at(self, contract_address, declarator_address, idx, sender_address=ZERO_ADDRESS, id_generator=None, height=BlockSpec.LATEST):
j = JSONRPCRequest(id_generator) j = JSONRPCRequest(id_generator)
o = j.template() o = j.template()
o['method'] = 'eth_call' o['method'] = 'eth_call'
@ -87,11 +93,13 @@ class Declarator(TxFactory):
tx = self.template(sender_address, contract_address) tx = self.template(sender_address, contract_address)
tx = self.set_code(tx, data) tx = self.set_code(tx, data)
o['params'].append(self.normalize(tx)) o['params'].append(self.normalize(tx))
height = to_blockheight_param(height)
o['params'].append(height)
o = j.finalize(o) o = j.finalize(o)
return o return o
def declarator_address_at(self, contract_address, subject_address, idx, sender_address=ZERO_ADDRESS, id_generator=None): def declarator_address_at(self, contract_address, subject_address, idx, sender_address=ZERO_ADDRESS, id_generator=None, height=BlockSpec.LATEST):
j = JSONRPCRequest(id_generator) j = JSONRPCRequest(id_generator)
o = j.template() o = j.template()
o['method'] = 'eth_call' o['method'] = 'eth_call'
@ -105,6 +113,8 @@ class Declarator(TxFactory):
tx = self.template(sender_address, contract_address) tx = self.template(sender_address, contract_address)
tx = self.set_code(tx, data) tx = self.set_code(tx, data)
o['params'].append(self.normalize(tx)) o['params'].append(self.normalize(tx))
height = to_blockheight_param(height)
o['params'].append(height)
o = j.finalize(o) o = j.finalize(o)
return o return o

View File

@ -15,6 +15,7 @@ import chainlib.eth.cli
from chainlib.chain import ChainSpec from chainlib.chain import ChainSpec
from chainlib.error import JSONRPCException from chainlib.error import JSONRPCException
from chainlib.eth.address import to_checksum_address from chainlib.eth.address import to_checksum_address
from chainlib.eth.constant import ZERO_ADDRESS
from hexathon import ( from hexathon import (
add_0x, add_0x,
strip_0x, strip_0x,
@ -55,7 +56,7 @@ def process_config_local(config, arg, args, flags):
arg_flags = ArgFlag() arg_flags = ArgFlag()
arg = Arg(arg_flags) arg = Arg(arg_flags)
flags = arg_flags.STD_WRITE | arg_flags.WALLET | arg_flags.EXEC flags = arg_flags.STD_WRITE | arg_flags.WALLET | arg_flags.EXEC | arg_flags.SENDER
argparser = chainlib.eth.cli.ArgumentParser() argparser = chainlib.eth.cli.ArgumentParser()
argparser = process_args(argparser, arg, flags) argparser = process_args(argparser, arg, flags)
@ -78,8 +79,8 @@ def out_element(e, w=sys.stdout):
w.write(e[1] + '\n') w.write(e[1] + '\n')
def ls(ifc, conn, contract_address, declarator_address, subject_address, w=sys.stdout): def ls(ifc, conn, contract_address, declarator_address, subject_address, w=sys.stdout, sender_address=ZERO_ADDRESS):
o = ifc.declaration(contract_address, declarator_address, subject_address) o = ifc.declaration(contract_address, declarator_address, subject_address, sender_address=sender_address)
r = conn.do(o) r = conn.do(o)
declarations = ifc.parse_declaration(r) declarations = ifc.parse_declaration(r)
@ -99,6 +100,7 @@ def main():
settings.get('EXEC'), settings.get('EXEC'),
config.get('_DECLARATOR'), config.get('_DECLARATOR'),
settings.get('RECIPIENT'), settings.get('RECIPIENT'),
sender_address=settings.get('SENDER_ADDRESS'),
) )
declarations = [] declarations = []

View File

@ -1,2 +1,3 @@
confini~=0.6.0 confini~=0.6.0
chainlib-eth~=0.4.7 chainlib-eth~=0.4.16
chainlib==0.4.12

View File

@ -1,6 +1,6 @@
[metadata] [metadata]
name = eth-address-index name = eth-address-index
version = 0.6.0 version = 0.6.1
description = Signed metadata declarations for ethereum addresses description = Signed metadata declarations for ethereum addresses
author = Louis Holbrook author = Louis Holbrook
author_email = dev@holbrook.no author_email = dev@holbrook.no