mirror of
https://github.com/chaintool-py/eth-erc20.git
synced 2026-04-27 21:01:04 +02:00
Implement bytecode and contract constructor code for chainlib find tool
This commit is contained in:
21
python/giftable_erc20_token/_clf.py
Normal file
21
python/giftable_erc20_token/_clf.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# local imports
|
||||
from .factory import GiftableToken
|
||||
|
||||
|
||||
def code(v):
|
||||
version = None
|
||||
if v != None:
|
||||
version = v[0]
|
||||
return GiftableToken.bytecode(version=version)
|
||||
|
||||
|
||||
def init(v):
|
||||
if v == None or len(v) < 3:
|
||||
raise ValueError('minimum 3 arguments required')
|
||||
version = None
|
||||
if len(v) == 4:
|
||||
version = v[4]
|
||||
return GiftableToken.cargs(v[0], v[1], v[2], version=version)
|
||||
|
||||
|
||||
default = code
|
||||
@@ -24,16 +24,22 @@ class GiftableToken(TxFactory):
|
||||
__abi = None
|
||||
__bytecode = None
|
||||
|
||||
def constructor(self, sender_address, name, symbol, decimals, tx_format=TxFormat.JSONRPC):
|
||||
code = GiftableToken.bytecode()
|
||||
def constructor(self, sender_address, name, symbol, decimals, tx_format=TxFormat.JSONRPC, version=None):
|
||||
code = constructor_arg(name, symbol, decimals)
|
||||
tx = self.template(sender_address, None, use_nonce=True)
|
||||
tx = self.set_code(tx, code)
|
||||
return self.finalize(tx, tx_format)
|
||||
|
||||
|
||||
@staticmethod
|
||||
def cargs(name, symbol, decimals, version=None):
|
||||
code = GiftableToken.bytecode(version=version)
|
||||
enc = ABIContractEncoder()
|
||||
enc.string(name)
|
||||
enc.string(symbol)
|
||||
enc.uint256(decimals)
|
||||
code += enc.get()
|
||||
tx = self.template(sender_address, None, use_nonce=True)
|
||||
tx = self.set_code(tx, code)
|
||||
return self.finalize(tx, tx_format)
|
||||
return code
|
||||
|
||||
|
||||
@staticmethod
|
||||
@@ -51,7 +57,7 @@ class GiftableToken(TxFactory):
|
||||
|
||||
|
||||
@staticmethod
|
||||
def bytecode():
|
||||
def bytecode(version=None):
|
||||
if GiftableToken.__bytecode == None:
|
||||
f = open(os.path.join(data_dir, 'GiftableToken.bin'))
|
||||
GiftableToken.__bytecode = f.read()
|
||||
|
||||
Reference in New Issue
Block a user