mirror of
https://github.com/chaintool-py/eth-erc20.git
synced 2024-11-23 10:16:47 +01:00
Implement bytecode and contract constructor code for chainlib find tool
This commit is contained in:
parent
d218d93fba
commit
fc9fa18e1c
@ -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
|
||||
|
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()
|
||||
|
@ -1,3 +1,4 @@
|
||||
confini~=0.6.1
|
||||
chainlib-eth~=0.4.15
|
||||
chainlib~=0.4.8
|
||||
potaahto~=0.1.1
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user