mirror of
git://holbrook.no/eth-accounts-index
synced 2024-11-05 10:16:47 +01:00
Add bytecode to registry object
This commit is contained in:
parent
6defef8df8
commit
a8ed83dde4
@ -4,18 +4,19 @@ import os
|
|||||||
|
|
||||||
logg = logging.getLogger()
|
logg = logging.getLogger()
|
||||||
|
|
||||||
|
moddir = os.path.dirname(__file__)
|
||||||
|
datadir = os.path.join(moddir, 'data')
|
||||||
|
|
||||||
|
|
||||||
class AccountRegistry:
|
class AccountRegistry:
|
||||||
|
|
||||||
abi = None
|
__abi = None
|
||||||
|
__bytecode = None
|
||||||
|
|
||||||
def __init__(self, w3, address, signer_address=None):
|
def __init__(self, w3, address, signer_address=None):
|
||||||
if AccountRegistry.abi == None:
|
abi = AccountRegistry.abi()
|
||||||
moddir = os.path.dirname(__file__)
|
AccountRegistry.bytecode()
|
||||||
datadir = os.path.join(moddir, 'data')
|
self.contract = w3.eth.contract(abi=abi, address=address)
|
||||||
f = open(os.path.join(datadir, 'registry.abi.json'), 'r')
|
|
||||||
AccountRegistry.abi = json.load(f)
|
|
||||||
f.close()
|
|
||||||
self.contract = w3.eth.contract(abi=AccountRegistry.abi, address=address)
|
|
||||||
self.w3 = w3
|
self.w3 = w3
|
||||||
if signer_address != None:
|
if signer_address != None:
|
||||||
self.signer_address = signer_address
|
self.signer_address = signer_address
|
||||||
@ -25,6 +26,24 @@ class AccountRegistry:
|
|||||||
self.signer_address = self.w3.eth.defaultAccount
|
self.signer_address = self.w3.eth.defaultAccount
|
||||||
|
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def abi():
|
||||||
|
if AccountRegistry.__abi == None:
|
||||||
|
f = open(os.path.join(datadir, 'registry.abi.json'), 'r')
|
||||||
|
AccountRegistry.__abi = json.load(f)
|
||||||
|
f.close()
|
||||||
|
return AccountRegistry.__abi
|
||||||
|
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def bytecode():
|
||||||
|
if AccountRegistry.__bytecode == None:
|
||||||
|
f = open(os.path.join(datadir, 'registry.bin'))
|
||||||
|
AccountRegistry.__bytecode = f.read()
|
||||||
|
f.close()
|
||||||
|
return AccountRegistry.__bytecode
|
||||||
|
|
||||||
|
|
||||||
def add(self, address):
|
def add(self, address):
|
||||||
gasPrice = self.w3.eth.gasPrice;
|
gasPrice = self.w3.eth.gasPrice;
|
||||||
tx_hash = self.contract.functions.add(address).transact({
|
tx_hash = self.contract.functions.add(address).transact({
|
||||||
|
Loading…
Reference in New Issue
Block a user