Implement bytecode and contract constructor code for chainlib find tool

This commit is contained in:
lash 2023-02-13 15:06:02 +00:00
parent d218d93fba
commit fc9fa18e1c
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
5 changed files with 36 additions and 8 deletions

View File

@ -1 +1 @@
include **/data/ERC20.json **/data/GiftableToken.json **/data/GiftableToken.bin *requirements.txt CHANGELOG LICENSE WAIVER WAIVER.asc
include **/data/ERC20.json **/data/GiftableToken.json **/data/GiftableToken.bin *requirements.txt CHANGELOG LICENSE WAIVER WAIVER.asc **/data/.chainlib

View 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

View File

@ -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()

View File

@ -1,3 +1,4 @@
confini~=0.6.1
chainlib-eth~=0.4.15
chainlib~=0.4.8
potaahto~=0.1.1

View File

@ -1,6 +1,6 @@
[metadata]
name = eth-erc20
version = 0.5.4
version = 0.5.5
description = ERC20 interface and simple contract with deployment script that lets any address mint and gift itself tokens.
author = Louis Holbrook
author_email = dev@holbrook.no