Add address declarator
This commit is contained in:
parent
5f126d8d59
commit
7f18b6d6d2
@ -7,6 +7,7 @@ from chainlib.chain import ChainSpec
|
|||||||
from chainlib.eth.tx import TxFormat
|
from chainlib.eth.tx import TxFormat
|
||||||
from chainlib.eth.connection import RPCConnection
|
from chainlib.eth.connection import RPCConnection
|
||||||
from eth_token_index import TokenUniqueSymbolIndex
|
from eth_token_index import TokenUniqueSymbolIndex
|
||||||
|
from eth_address_declarator import Declarator
|
||||||
|
|
||||||
logg = logging.getLogger(__name__)
|
logg = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -37,7 +38,7 @@ class CICEth:
|
|||||||
|
|
||||||
|
|
||||||
def process_token_index(self):
|
def process_token_index(self):
|
||||||
c = TokenUniqueSymbolIndex(self.chain_spec, signer=self.signer) # tx_format = None
|
c = TokenUniqueSymbolIndex(self.chain_spec, signer=self.signer)
|
||||||
|
|
||||||
contract_address = self.resources['token_index']['reference']
|
contract_address = self.resources['token_index']['reference']
|
||||||
signer_address = self.resources['token_index']['key_address']
|
signer_address = self.resources['token_index']['key_address']
|
||||||
@ -54,6 +55,26 @@ class CICEth:
|
|||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
||||||
|
def process_address_declarator(self):
|
||||||
|
c = Declarator(self.chain_spec, signer=self.signer)
|
||||||
|
|
||||||
|
contract_address = self.resources['address_declarator']['reference']
|
||||||
|
signer_address = self.resources['address_declarator']['key_address']
|
||||||
|
|
||||||
|
r = []
|
||||||
|
for proof in self.proofs:
|
||||||
|
o = c.add_declaration(contract_address, signer_address, self.token_address, proof, tx_format=self.tx_format)
|
||||||
|
if self.rpc != None:
|
||||||
|
r.append(self.rpc.do(o[1]))
|
||||||
|
elif self.signer != None:
|
||||||
|
r.append(o[1])
|
||||||
|
else:
|
||||||
|
r.append(o)
|
||||||
|
|
||||||
|
self.outputs += r
|
||||||
|
return r
|
||||||
|
|
||||||
|
|
||||||
def process(self):
|
def process(self):
|
||||||
self.token_address = self.resources['token']['reference']
|
self.token_address = self.resources['token']['reference']
|
||||||
if self.token_address == None:
|
if self.token_address == None:
|
||||||
|
@ -35,6 +35,10 @@ class TestCICEthBase(EthTesterCase):
|
|||||||
'reference': self.token_index_address,
|
'reference': self.token_index_address,
|
||||||
'key_address': addresses[1],
|
'key_address': addresses[1],
|
||||||
},
|
},
|
||||||
|
'address_declarator': {
|
||||||
|
'reference': self.token_index_address,
|
||||||
|
'key_address': addresses[2],
|
||||||
|
},
|
||||||
}
|
}
|
||||||
self.proofs = []
|
self.proofs = []
|
||||||
for i in range(3):
|
for i in range(3):
|
||||||
|
@ -22,7 +22,11 @@ class TestCICEthOffline(TestCICEthBase):
|
|||||||
|
|
||||||
|
|
||||||
def test_offline_address_declarator(self):
|
def test_offline_address_declarator(self):
|
||||||
pass
|
self.adapter.token_address = self.token_address
|
||||||
|
v = self.adapter.process_address_declarator()
|
||||||
|
self.assertEqual(v[0][:8], 'ae47ece0')
|
||||||
|
self.assertEqual(len(v), 3)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
Reference in New Issue
Block a user