mirror of
git://holbrook.no/eth-address-index
synced 2026-05-18 18:35:22 +02:00
Add test for address index for declarator implementation
This commit is contained in:
1
python/eth_address_declarator/accounts_index/__init__.py
Normal file
1
python/eth_address_declarator/accounts_index/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from .accounts_index import *
|
||||
@@ -0,0 +1,54 @@
|
||||
# standard imports
|
||||
import os
|
||||
|
||||
# external imports
|
||||
from chainlib.eth.tx import (
|
||||
TxFormat,
|
||||
)
|
||||
from chainlib.eth.contract import (
|
||||
ABIContractEncoder,
|
||||
ABIContractType,
|
||||
)
|
||||
from eth_accounts_index.interface import AccountsIndex
|
||||
|
||||
moddir = os.path.dirname(__file__)
|
||||
datadir = os.path.join(moddir, '..', 'data')
|
||||
|
||||
|
||||
class AccountsIndexAddressDeclarator(AccountsIndex):
|
||||
|
||||
__abi = None
|
||||
__bytecode = None
|
||||
|
||||
@staticmethod
|
||||
def abi():
|
||||
if AccountsIndexAddressDeclarator.__abi == None:
|
||||
f = open(os.path.join(datadir, 'AccountsIndexAddressDeclarator.json'), 'r')
|
||||
AccountsIndexAddressDeclarator.__abi = json.load(f)
|
||||
f.close()
|
||||
return AccountsIndexAddressDeclarator.__abi
|
||||
|
||||
|
||||
@staticmethod
|
||||
def bytecode():
|
||||
if AccountsIndexAddressDeclarator.__bytecode == None:
|
||||
f = open(os.path.join(datadir, 'AccountsIndexAddressDeclarator.bin'))
|
||||
AccountsIndexAddressDeclarator.__bytecode = f.read()
|
||||
f.close()
|
||||
return AccountsIndexAddressDeclarator.__bytecode
|
||||
|
||||
|
||||
@staticmethod
|
||||
def gas(code=None):
|
||||
return 1200000
|
||||
|
||||
|
||||
def constructor(self, sender_address, context_address, address_declarator_address):
|
||||
code = AccountsIndexAddressDeclarator.bytecode()
|
||||
tx = self.template(sender_address, None, use_nonce=True)
|
||||
enc = ABIContractEncoder()
|
||||
enc.address(context_address)
|
||||
enc.address(address_declarator_address)
|
||||
code += enc.get()
|
||||
tx = self.set_code(tx, code)
|
||||
return self.build(tx)
|
||||
Reference in New Issue
Block a user