commit 6ec0f053026393fe10ec92f985b42faece49fc64
parent 873f55720770273ecf2c54d87bda9d9c90d36e3a
Author: lash <dev@holbrook.no>
Date: Tue, 14 Feb 2023 07:06:29 +0000
Implement chainlib gen
Diffstat:
5 files changed, 35 insertions(+), 10 deletions(-)
diff --git a/python/eth_badgetoken/__init__.py b/python/eth_badgetoken/__init__.py
@@ -1 +1,4 @@
from .token import BadgeToken
+from .token import create
+from .token import bytecode
+from .token import args
diff --git a/python/eth_badgetoken/data/.chainlib b/python/eth_badgetoken/data/.chainlib
diff --git a/python/eth_badgetoken/token.py b/python/eth_badgetoken/token.py
@@ -40,7 +40,7 @@ class BadgeToken(ERC721):
@staticmethod
- def bytecode():
+ def bytecode(version=None):
if BadgeToken.__bytecode == None:
f = open(os.path.join(datadir, 'BadgeToken.bin'))
BadgeToken.__bytecode = f.read()
@@ -53,7 +53,14 @@ class BadgeToken(ERC721):
return 3500000
- def constructor(self, sender_address, name, symbol, declarator, tx_format=TxFormat.JSONRPC):
+ def constructor(self, sender_address, name, symbol, declarator, tx_format=TxFormat.JSONRPC, version=None):
+ code = self.cargs(name, symbol, declarator, version=version)
+ 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, declarator, version=None):
declarator = strip_0x(declarator)
code = BadgeToken.bytecode()
enc = ABIContractEncoder()
@@ -61,9 +68,7 @@ class BadgeToken(ERC721):
enc.string(symbol)
enc.address(declarator)
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
def mint_to(self, contract_address, sender_address, address, token_id, tx_format=TxFormat.JSONRPC):
@@ -101,3 +106,19 @@ class BadgeToken(ERC721):
@classmethod
def parse_minted_at(self, v):
return abi_decode_single(ABIContractType.UINT256, v)
+
+
+def bytecode(**kwargs):
+ return BadgeToken.bytecode(version=kwargs.get('version'))
+
+
+def create(**kwargs):
+ return BadgeToken.cargs(kwargs['name'], kwargs['symbol'], kwargs['declarator'], version=kwargs.get('version'))
+
+
+def args(v):
+ if v == 'create':
+ return (['name', 'symbol', 'declarator'], ['version'],)
+ elif v == 'default' or v == 'bytecode':
+ return ([], ['version'],)
+ raise ValueError('unknown command: ' + v)
diff --git a/python/requirements.txt b/python/requirements.txt
@@ -1,3 +1,4 @@
-chainlib-eth~=0.4.3
-eth-erc20~=0.5.0
-eth-owned~=0.0.4
+chainlib-eth~=0.4.8
+chainlib~=0.4.8
+eth-erc20~=0.5.5
+eth-owned~=0.0.5
diff --git a/python/setup.cfg b/python/setup.cfg
@@ -1,10 +1,10 @@
[metadata]
name = eth-erc721
-version = 0.0.5
+version = 0.0.6
description = ERC721 interface and simple contract with deployment script providing arbitrary minting of NFTs with freely settable tokenids
author = Louis Holbrook
author_email = dev@holbrook.no
-url = https://git.defalsify.org/eth-erc721.git
+url = https://git.defalsify.org/eth-erc721
keywords =
dlt
blockchain