erc20-vend

Create ERC20 tokens the can be minted by existing ERC20 token balance
Log | Files | Refs

commit feb46724e0612fa2909848ae60c16f235d273291
parent f47e9b96e87de5c2dbc5343156ab5349c5d3e613
Author: lash <dev@holbrook.no>
Date:   Mon,  8 May 2023 05:25:30 +0100

Implement chainlib-gen

Diffstat:
Mpython/erc20_vend/__init__.py | 3+++
Apython/erc20_vend/data/.chainlib | 0
Mpython/erc20_vend/vend.py | 17+++++++++++++++++
Msolidity/Vend.sol | 30+++++++++++++++---------------
4 files changed, 35 insertions(+), 15 deletions(-)

diff --git a/python/erc20_vend/__init__.py b/python/erc20_vend/__init__.py @@ -1 +1,4 @@ from .vend import Vend +from .vend import bytecode +from .vend import create +from .vend import args diff --git a/python/erc20_vend/data/.chainlib b/python/erc20_vend/data/.chainlib diff --git a/python/erc20_vend/vend.py b/python/erc20_vend/vend.py @@ -141,3 +141,20 @@ class Vend(TxFactory): dec.val(v) r = dec.get() return r[0] + + + +def bytecode(**kwargs): + return Voter.bytecode(version=kwargs.get('version')) + + +def create(**kwargs): + return Voter.cargs(kwargs['token_address'], decimals=kwargs.get('decimals'), mint=kwargs.get('mint'), version=kwargs.get('version')) + + +def args(v): + if v == 'create': + return (['token_address'], ['decimals', 'mint'],) + elif v == 'default' or v == 'bytecode': + return ([], ['version'],) + raise ValueError('unknown command: ' + v) diff --git a/solidity/Vend.sol b/solidity/Vend.sol @@ -171,21 +171,21 @@ contract ERC20Vend { return l_balance; } - // burn used vend tokens. - // should self-destruct contract if possible when supply reaches 0. - function burnFor(address _token) public returns(uint256) { - bool r; - bytes memory v; - uint256 l_burnValue; - - l_burnValue = returned[_token]; - (r, v) = _token.call(abi.encodeWithSignature("burn(uint256)", l_burnValue)); - require(r, "ERR_TOKEN"); - r = abi.decode(v, (bool)); - require(r, "ERR_TOKEN_BURN"); - returned[_token] = 0; - return l_burnValue; - } +// // burn used vend tokens. +// // should self-destruct contract if possible when supply reaches 0. +// function burnFor(address _token) public returns(uint256) { +// bool r; +// bytes memory v; +// uint256 l_burnValue; +// +// l_burnValue = returned[_token]; +// (r, v) = _token.call(abi.encodeWithSignature("burn(uint256)", l_burnValue)); +// require(r, "ERR_TOKEN"); +// r = abi.decode(v, (bool)); +// require(r, "ERR_TOKEN_BURN"); +// returned[_token] = 0; +// return l_burnValue; +// } // returns UINT256_MAX if lock is inactive // reverts if target does not have the original balance