mirror of
https://github.com/chaintool-py/eth-erc20.git
synced 2025-04-20 20:11:02 +02:00
Compare commits
No commits in common. "master" and "v0.7.1" have entirely different histories.
2
.gitignore
vendored
2
.gitignore
vendored
@ -6,5 +6,3 @@ gmon.out
|
|||||||
*.egg-info
|
*.egg-info
|
||||||
.venv/
|
.venv/
|
||||||
.idea
|
.idea
|
||||||
solidity/*.json
|
|
||||||
solidity/*.bin
|
|
||||||
|
@ -1,14 +1,3 @@
|
|||||||
* 0.7.5
|
|
||||||
- Factor out token publish method in unittest fixture
|
|
||||||
* 0.7.4
|
|
||||||
- Add missing unittest module to python package
|
|
||||||
* 0.7.3
|
|
||||||
- Add ERC5679Ext20 fills
|
|
||||||
* 0.7.2
|
|
||||||
- Update python classifiers
|
|
||||||
- Upgrade to beta
|
|
||||||
* 0.7.1
|
|
||||||
- Upgrade deps
|
|
||||||
* 0.7.0
|
* 0.7.0
|
||||||
- Implement proper burner interface method
|
- Implement proper burner interface method
|
||||||
* 0.6.2
|
* 0.6.2
|
||||||
|
@ -100,6 +100,16 @@ def main():
|
|||||||
decimals = int(strip_0x(r), 16)
|
decimals = int(strip_0x(r), 16)
|
||||||
logg.info('decimals {}'.format(decimals))
|
logg.info('decimals {}'.format(decimals))
|
||||||
|
|
||||||
|
# name_o = g.name(token_address, sender_address=sender_address)
|
||||||
|
# r = conn.do(name_o)
|
||||||
|
# token_name = g.parse_name(r)
|
||||||
|
# logg.info('name {}'.format(token_name))
|
||||||
|
#
|
||||||
|
# symbol_o = g.symbol(token_address, sender_address=sender_address)
|
||||||
|
# r = conn.do(symbol_o)
|
||||||
|
# token_symbol = g.parse_symbol(r)
|
||||||
|
# logg.info('symbol {}'.format(token_symbol))
|
||||||
|
|
||||||
# get balance
|
# get balance
|
||||||
balance_o = g.balance(token_address, settings.get('RECIPIENT'), sender_address=sender_address)
|
balance_o = g.balance(token_address, settings.get('RECIPIENT'), sender_address=sender_address)
|
||||||
r = conn.do(balance_o)
|
r = conn.do(balance_o)
|
||||||
|
@ -1 +0,0 @@
|
|||||||
from .base import *
|
|
@ -12,6 +12,7 @@ from chainlib.eth.tx import (
|
|||||||
from hexathon import strip_0x
|
from hexathon import strip_0x
|
||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
|
from giftable_erc20_token.unittest import TestGiftableToken
|
||||||
from eth_erc20 import ERC20
|
from eth_erc20 import ERC20
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
@ -52,13 +53,12 @@ class TestInterface:
|
|||||||
self.assertEqual(self.symbol, symbol)
|
self.assertEqual(self.symbol, symbol)
|
||||||
|
|
||||||
|
|
||||||
def test_direct_transfer(self):
|
def test_transfer(self):
|
||||||
nonce_oracle = RPCNonceOracle(self.accounts[0], conn=self.conn)
|
nonce_oracle = RPCNonceOracle(self.accounts[0], conn=self.conn)
|
||||||
gas_oracle = OverrideGasOracle(limit=100000, conn=self.conn)
|
gas_oracle = OverrideGasOracle(limit=100000, conn=self.conn)
|
||||||
c = ERC20(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle, gas_oracle=gas_oracle)
|
c = ERC20(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle, gas_oracle=gas_oracle)
|
||||||
|
|
||||||
(tx_hash, o) = c.transfer(self.address, self.accounts[0], self.accounts[1], 1000)
|
(tx_hash, o) = c.transfer(self.address, self.accounts[0], self.accounts[1], 1000)
|
||||||
self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
o = receipt(tx_hash)
|
o = receipt(tx_hash)
|
||||||
r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
self.assertEqual(r['status'], 1)
|
self.assertEqual(r['status'], 1)
|
||||||
@ -85,7 +85,7 @@ class TestInterface:
|
|||||||
gas_oracle = OverrideGasOracle(limit=100000, conn=self.conn)
|
gas_oracle = OverrideGasOracle(limit=100000, conn=self.conn)
|
||||||
c = ERC20(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle, gas_oracle=gas_oracle)
|
c = ERC20(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle, gas_oracle=gas_oracle)
|
||||||
(tx_hash, o) = c.approve(self.address, self.accounts[0], self.accounts[1], 1000)
|
(tx_hash, o) = c.approve(self.address, self.accounts[0], self.accounts[1], 1000)
|
||||||
self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
o = receipt(tx_hash)
|
o = receipt(tx_hash)
|
||||||
r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
self.assertEqual(r['status'], 1)
|
self.assertEqual(r['status'], 1)
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
|||||||
{"compiler":{"version":"0.8.18+commit.87f61d96"},"language":"Solidity","output":{"abi":[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint8","name":"_decimals","type":"uint8"},{"internalType":"uint256","name":"_supply","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"address","name":"_spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":true,"internalType":"address","name":"_spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"TransferFrom","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_sum","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}],"devdoc":{"kind":"dev","methods":{},"version":1},"userdoc":{"kind":"user","methods":{},"version":1}},"settings":{"compilationTarget":{"StaticToken.sol":"StaticToken"},"evmVersion":"byzantium","libraries":{},"metadata":{"bytecodeHash":"ipfs"},"optimizer":{"enabled":false,"runs":200},"remappings":[]},"sources":{"StaticToken.sol":{"keccak256":"0xfb467ccf3465a3f2c8ad23bc4933f7e1ac1964d7ee1aa185e72e4698b015b5b3","license":"AGPL-3.0-or-later","urls":["bzz-raw://6c2230ba6ddadf062f5f3391f2a852da8617fbefd0c0511d9bc372c6c66c6424","dweb:/ipfs/QmWSYF3WxmKyDEHp3NZMWjE6Yu7mY6XVB6tuTeFKpjxL9P"]}},"version":1}
|
{"compiler":{"version":"0.8.18+commit.87f61d96"},"language":"Solidity","output":{"abi":[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint8","name":"_decimals","type":"uint8"},{"internalType":"uint256","name":"_supply","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"address","name":"_spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":true,"internalType":"address","name":"_spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"TransferFrom","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_sum","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}],"devdoc":{"kind":"dev","methods":{},"version":1},"userdoc":{"kind":"user","methods":{},"version":1}},"settings":{"compilationTarget":{"StaticToken.sol":"StaticToken"},"evmVersion":"byzantium","libraries":{},"metadata":{"bytecodeHash":"ipfs"},"optimizer":{"enabled":false,"runs":200},"remappings":[]},"sources":{"StaticToken.sol":{"keccak256":"0x7afcc41cbaaaeeac2e372c50ed4cf6962035af89e33b500a65927f46d8bf31f2","license":"GPL-3.0-or-later","urls":["bzz-raw://4077171f628fd470cb7f72ca80426297132050f4d08380b55ca74c87e3df2727","dweb:/ipfs/QmWvgFNWrRtzQFejyfjy6LaerghSnYQ86R5WVTnXS7wiuD"]}},"version":1}
|
||||||
|
@ -45,9 +45,7 @@ class GiftableToken(ERC20):
|
|||||||
enc.string(symbol)
|
enc.string(symbol)
|
||||||
enc.uint256(decimals)
|
enc.uint256(decimals)
|
||||||
enc.uint256(expire)
|
enc.uint256(expire)
|
||||||
args = enc.get()
|
code += enc.get()
|
||||||
code += args
|
|
||||||
logg.debug('constructor code: ' + args)
|
|
||||||
return code
|
return code
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,11 +22,19 @@ class TestGiftableToken(EthTesterCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestGiftableToken, self).setUp()
|
super(TestGiftableToken, self).setUp()
|
||||||
self.conn = RPCConnection.connect(self.chain_spec, 'default')
|
self.conn = RPCConnection.connect(self.chain_spec, 'default')
|
||||||
|
|
||||||
address = self.publish_giftable_token('Foo Token', 'FOO', 16, expire=self.expire)
|
|
||||||
self.address = to_checksum_address(address)
|
|
||||||
nonce_oracle = RPCNonceOracle(self.accounts[0], conn=self.conn)
|
nonce_oracle = RPCNonceOracle(self.accounts[0], conn=self.conn)
|
||||||
c = GiftableToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
c = GiftableToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
|
self.symbol = 'FOO'
|
||||||
|
self.name = 'Foo Token'
|
||||||
|
self.decimals = 16
|
||||||
|
(tx_hash, o) = c.constructor(self.accounts[0], self.name, self.symbol, self.decimals, expire=self.expire)
|
||||||
|
self.rpc.do(o)
|
||||||
|
o = receipt(tx_hash)
|
||||||
|
r = self.rpc.do(o)
|
||||||
|
self.assertEqual(r['status'], 1)
|
||||||
|
self.address = to_checksum_address(r['contract_address'])
|
||||||
|
logg.debug('published on address {} with hash {}'.format(self.address, tx_hash))
|
||||||
|
|
||||||
self.initial_supply = 1 << 40
|
self.initial_supply = 1 << 40
|
||||||
(tx_hash, o) = c.mint_to(self.address, self.accounts[0], self.accounts[0], self.initial_supply)
|
(tx_hash, o) = c.mint_to(self.address, self.accounts[0], self.accounts[0], self.initial_supply)
|
||||||
r = self.conn.do(o)
|
r = self.conn.do(o)
|
||||||
@ -35,22 +43,6 @@ class TestGiftableToken(EthTesterCase):
|
|||||||
self.assertEqual(r['status'], 1)
|
self.assertEqual(r['status'], 1)
|
||||||
|
|
||||||
|
|
||||||
def publish_giftable_token(self, name, symbol, decimals=16, expire=None):
|
|
||||||
nonce_oracle = RPCNonceOracle(self.accounts[0], conn=self.conn)
|
|
||||||
c = GiftableToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
|
||||||
self.symbol = name
|
|
||||||
self.name = symbol
|
|
||||||
self.decimals = decimals
|
|
||||||
(tx_hash, o) = c.constructor(self.accounts[0], self.name, self.symbol, self.decimals, expire=expire)
|
|
||||||
self.rpc.do(o)
|
|
||||||
o = receipt(tx_hash)
|
|
||||||
r = self.rpc.do(o)
|
|
||||||
self.assertEqual(r['status'], 1)
|
|
||||||
address = r['contract_address']
|
|
||||||
logg.debug('published on address {} with hash {}'.format(address, tx_hash))
|
|
||||||
return address
|
|
||||||
|
|
||||||
|
|
||||||
class TestGiftableExpireToken(TestGiftableToken):
|
class TestGiftableExpireToken(TestGiftableToken):
|
||||||
|
|
||||||
expire = int(time.time()) + 100000
|
expire = int(time.time()) + 100000
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
confini~=0.6.1
|
confini~=0.6.1
|
||||||
chainlib-eth~=0.6.0
|
chainlib-eth~=0.4.17
|
||||||
chainlib~=0.5.0
|
chainlib~=0.4.12
|
||||||
potaahto~=0.1.1
|
potaahto~=0.1.1
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
export PYTHONPATH=${PYTHONPATH}:.
|
export PYTHONPATH=${PYTHONPATH}:.
|
||||||
>&2 echo "using pythonpath $PYTHONPATH"
|
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
set -x
|
set -x
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = eth-erc20
|
name = eth-erc20
|
||||||
version = 0.9.0
|
version = 0.7.1
|
||||||
description = ERC20 interface and simple contract with deployment script that lets any address mint and gift itself tokens.
|
description = ERC20 interface and simple contract with deployment script that lets any address mint and gift itself tokens.
|
||||||
author = Louis Holbrook
|
author = Louis Holbrook
|
||||||
author_email = dev@holbrook.no
|
author_email = dev@holbrook.no
|
||||||
@ -14,12 +14,11 @@ keywords =
|
|||||||
classifiers =
|
classifiers =
|
||||||
Programming Language :: Python :: 3
|
Programming Language :: Python :: 3
|
||||||
Operating System :: OS Independent
|
Operating System :: OS Independent
|
||||||
Development Status :: 4 - Beta
|
Development Status :: 3 - Alpha
|
||||||
Environment :: Console
|
Environment :: No Input/Output (Daemon)
|
||||||
Intended Audience :: Developers
|
Intended Audience :: Developers
|
||||||
License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
|
License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
|
||||||
Topic :: Internet
|
Topic :: Internet
|
||||||
Topic :: Software Development :: Libraries
|
|
||||||
#Topic :: Blockchain :: EVM
|
#Topic :: Blockchain :: EVM
|
||||||
license = AGPLv3+
|
license = AGPLv3+
|
||||||
licence_files =
|
licence_files =
|
||||||
@ -27,7 +26,7 @@ licence_files =
|
|||||||
|
|
||||||
[options]
|
[options]
|
||||||
include_package_data = True
|
include_package_data = True
|
||||||
python_requires = >= 3.8
|
python_requires = >= 3.7
|
||||||
packages =
|
packages =
|
||||||
giftable_erc20_token
|
giftable_erc20_token
|
||||||
giftable_erc20_token.runnable
|
giftable_erc20_token.runnable
|
||||||
@ -36,7 +35,6 @@ packages =
|
|||||||
eth_erc20
|
eth_erc20
|
||||||
eth_erc20.data
|
eth_erc20.data
|
||||||
eth_erc20.runnable
|
eth_erc20.runnable
|
||||||
eth_erc20.unittest
|
|
||||||
static_token.data
|
static_token.data
|
||||||
|
|
||||||
[options.package_data]
|
[options.package_data]
|
||||||
|
@ -1 +0,0 @@
|
|||||||
from .factory import *
|
|
@ -1,3 +0,0 @@
|
|||||||
import os
|
|
||||||
|
|
||||||
data_dir = os.path.realpath(os.path.dirname(__file__))
|
|
@ -1,60 +0,0 @@
|
|||||||
# standard imports
|
|
||||||
import os
|
|
||||||
import logging
|
|
||||||
|
|
||||||
# external imports
|
|
||||||
from chainlib.eth.tx import (
|
|
||||||
TxFactory,
|
|
||||||
TxFormat,
|
|
||||||
)
|
|
||||||
from chainlib.hash import keccak256_string_to_hex
|
|
||||||
from chainlib.eth.contract import (
|
|
||||||
ABIContractEncoder,
|
|
||||||
ABIContractType,
|
|
||||||
)
|
|
||||||
|
|
||||||
# local imports
|
|
||||||
from static_token.data import data_dir
|
|
||||||
|
|
||||||
logg = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class StaticToken(TxFactory):
|
|
||||||
|
|
||||||
__abi = None
|
|
||||||
__bytecode = None
|
|
||||||
|
|
||||||
def constructor(self, sender_address, name, symbol, decimals, supply, tx_format=TxFormat.JSONRPC):
|
|
||||||
code = StaticToken.bytecode()
|
|
||||||
enc = ABIContractEncoder()
|
|
||||||
enc.string(name)
|
|
||||||
enc.string(symbol)
|
|
||||||
enc.uint256(decimals)
|
|
||||||
enc.uint256(supply)
|
|
||||||
code += enc.get()
|
|
||||||
tx = self.template(sender_address, None, use_nonce=True)
|
|
||||||
tx = self.set_code(tx, code)
|
|
||||||
return self.finalize(tx, tx_format)
|
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def gas(code=None):
|
|
||||||
return 2000000
|
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def abi():
|
|
||||||
if StaticToken.__abi == None:
|
|
||||||
f = open(os.path.join(data_dir, 'StaticToken.json'), 'r')
|
|
||||||
StaticToken.__abi = json.load(f)
|
|
||||||
f.close()
|
|
||||||
return StaticToken.__abi
|
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def bytecode():
|
|
||||||
if StaticToken.__bytecode == None:
|
|
||||||
f = open(os.path.join(data_dir, 'StaticToken.bin'))
|
|
||||||
StaticToken.__bytecode = f.read()
|
|
||||||
f.close()
|
|
||||||
return StaticToken.__bytecode
|
|
@ -1 +0,0 @@
|
|||||||
from .base import TestStaticToken
|
|
@ -1,36 +0,0 @@
|
|||||||
# standard imports
|
|
||||||
import logging
|
|
||||||
import time
|
|
||||||
|
|
||||||
# external imports
|
|
||||||
from chainlib.eth.unittest.ethtester import EthTesterCase
|
|
||||||
from chainlib.connection import RPCConnection
|
|
||||||
from chainlib.eth.nonce import RPCNonceOracle
|
|
||||||
from chainlib.eth.tx import receipt
|
|
||||||
from chainlib.eth.address import to_checksum_address
|
|
||||||
|
|
||||||
# local imports
|
|
||||||
from static_token import StaticToken
|
|
||||||
from eth_erc20.unittest import TestInterface
|
|
||||||
|
|
||||||
logg = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class TestStaticToken(EthTesterCase, TestInterface):
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
super(TestStaticToken, self).setUp()
|
|
||||||
self.conn = RPCConnection.connect(self.chain_spec, 'default')
|
|
||||||
nonce_oracle = RPCNonceOracle(self.accounts[0], conn=self.conn)
|
|
||||||
c = StaticToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
|
||||||
self.symbol = 'FOO'
|
|
||||||
self.name = 'Foo Token'
|
|
||||||
self.decimals = 16
|
|
||||||
self.initial_supply = 1 << 24
|
|
||||||
(tx_hash, o) = c.constructor(self.accounts[0], self.name, self.symbol, self.decimals, self.initial_supply)
|
|
||||||
self.rpc.do(o)
|
|
||||||
o = receipt(tx_hash)
|
|
||||||
r = self.rpc.do(o)
|
|
||||||
self.assertEqual(r['status'], 1)
|
|
||||||
self.address = to_checksum_address(r['contract_address'])
|
|
||||||
logg.debug('published statictoken on address {} with hash {}'.format(self.address, tx_hash))
|
|
@ -1,3 +1,3 @@
|
|||||||
eth_tester==0.10.0b4
|
eth_tester==0.5.0b3
|
||||||
py-evm==0.10.0b4
|
py-evm==0.3.0a20
|
||||||
pytest==6.0.1
|
pytest==6.0.1
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
# standard imports
|
|
||||||
import os
|
|
||||||
import unittest
|
|
||||||
import json
|
|
||||||
import logging
|
|
||||||
import datetime
|
|
||||||
|
|
||||||
# external imports
|
|
||||||
from chainlib.eth.constant import ZERO_ADDRESS
|
|
||||||
from chainlib.eth.nonce import RPCNonceOracle
|
|
||||||
from chainlib.eth.tx import receipt
|
|
||||||
from chainlib.eth.block import (
|
|
||||||
block_latest,
|
|
||||||
block_by_number,
|
|
||||||
)
|
|
||||||
|
|
||||||
# local imports
|
|
||||||
from static_token import StaticToken
|
|
||||||
from static_token.unittest import TestStaticToken
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
|
||||||
logg = logging.getLogger()
|
|
||||||
|
|
||||||
testdir = os.path.dirname(__file__)
|
|
||||||
|
|
||||||
|
|
||||||
class TestExpire(TestStaticToken):
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
super(TestExpire, self).setUp()
|
|
||||||
|
|
||||||
|
|
||||||
def test_static_interface(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
unittest.main()
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,7 +1,7 @@
|
|||||||
pragma solidity >=0.8.0;
|
pragma solidity >=0.6.11;
|
||||||
|
|
||||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
// File-Version: 3
|
// File-Version: 2
|
||||||
|
|
||||||
contract GiftableToken {
|
contract GiftableToken {
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ contract GiftableToken {
|
|||||||
// Implements Burner
|
// Implements Burner
|
||||||
uint256 public totalBurned;
|
uint256 public totalBurned;
|
||||||
|
|
||||||
// Implements Expire
|
// Implements expire
|
||||||
uint256 public expires;
|
uint256 public expires;
|
||||||
bool expired;
|
bool expired;
|
||||||
|
|
||||||
@ -65,9 +65,8 @@ contract GiftableToken {
|
|||||||
return totalMinted - totalBurned;
|
return totalMinted - totalBurned;
|
||||||
}
|
}
|
||||||
|
|
||||||
mapping(address => bool) writers;
|
|
||||||
|
|
||||||
// Implements Minter
|
// Implements Minter
|
||||||
|
mapping(address => bool) writers;
|
||||||
function mintTo(address _to, uint256 _value) public returns (bool) {
|
function mintTo(address _to, uint256 _value) public returns (bool) {
|
||||||
require(writers[msg.sender] || msg.sender == owner);
|
require(writers[msg.sender] || msg.sender == owner);
|
||||||
|
|
||||||
@ -79,13 +78,6 @@ contract GiftableToken {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements Minter
|
|
||||||
// Implements ERC5679Ext20
|
|
||||||
function mint(address _to, uint256 _value, bytes calldata _data) public {
|
|
||||||
_data;
|
|
||||||
mintTo(_to, _value);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Implements Writer
|
// Implements Writer
|
||||||
function addWriter(address _minter) public returns (bool) {
|
function addWriter(address _minter) public returns (bool) {
|
||||||
require(msg.sender == owner);
|
require(msg.sender == owner);
|
||||||
@ -96,7 +88,7 @@ contract GiftableToken {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Implements Writer
|
// Implements Writer
|
||||||
function deleteWriter(address _minter) public returns (bool) {
|
function removeWriter(address _minter) public returns (bool) {
|
||||||
require(msg.sender == owner || msg.sender == _minter);
|
require(msg.sender == owner || msg.sender == _minter);
|
||||||
|
|
||||||
writers[_minter] = false;
|
writers[_minter] = false;
|
||||||
@ -148,19 +140,6 @@ contract GiftableToken {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements Burner
|
|
||||||
function burn() public returns(bool) {
|
|
||||||
return burn(balanceOf[msg.sender]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Implements Burner
|
|
||||||
// Implements ERC5679Ext20
|
|
||||||
function burn(address _from, uint256 _value, bytes calldata _data) public {
|
|
||||||
require(msg.sender == _from, 'ERR_NOT_SELF');
|
|
||||||
_data;
|
|
||||||
burn(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Implements ERC20
|
// Implements ERC20
|
||||||
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
|
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
|
||||||
require(applyExpiry() == 0);
|
require(applyExpiry() == 0);
|
||||||
@ -211,9 +190,6 @@ contract GiftableToken {
|
|||||||
if (_sum == 0xb1110c1b) { // Burner
|
if (_sum == 0xb1110c1b) { // Burner
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (_sum == 0x841a0e94) { // Expire
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
|||||||
pragma solidity >=0.8.0;
|
pragma solidity >0.6.11;
|
||||||
|
|
||||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
contract StaticToken {
|
contract StaticToken {
|
||||||
|
|
||||||
@ -20,11 +20,8 @@ contract StaticToken {
|
|||||||
// Implements ERC20
|
// Implements ERC20
|
||||||
mapping (address => mapping (address => uint256)) public allowance;
|
mapping (address => mapping (address => uint256)) public allowance;
|
||||||
|
|
||||||
// Implements ERC20
|
|
||||||
event Transfer(address indexed _from, address indexed _to, uint256 _value);
|
event Transfer(address indexed _from, address indexed _to, uint256 _value);
|
||||||
// Implements ERC20
|
|
||||||
event TransferFrom(address indexed _from, address indexed _to, address indexed _spender, uint256 _value);
|
event TransferFrom(address indexed _from, address indexed _to, address indexed _spender, uint256 _value);
|
||||||
// Implements ERC20
|
|
||||||
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
|
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
|
||||||
|
|
||||||
constructor(string memory _name, string memory _symbol, uint8 _decimals, uint256 _supply) {
|
constructor(string memory _name, string memory _symbol, uint8 _decimals, uint256 _supply) {
|
||||||
@ -68,7 +65,7 @@ contract StaticToken {
|
|||||||
|
|
||||||
// Implements EIP165
|
// Implements EIP165
|
||||||
function supportsInterface(bytes4 _sum) public pure returns (bool) {
|
function supportsInterface(bytes4 _sum) public pure returns (bool) {
|
||||||
if (_sum == 0xb61bc941) { // ERC20
|
if (_sum == 0xc6bb4b70) { // ERC20
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (_sum == 0x01ffc9a7) { // EIP165
|
if (_sum == 0x01ffc9a7) { // EIP165
|
||||||
|
Loading…
Reference in New Issue
Block a user