Initial commit
This commit is contained in:
25
python/ge_capped_token/__init__.py
Normal file
25
python/ge_capped_token/__init__.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# external imports
|
||||
from giftable_erc20_token import GiftableToken
|
||||
|
||||
# local imports
|
||||
from ge_capped_token.data import data_dir
|
||||
|
||||
|
||||
class CappedToken(GiftableToken):
|
||||
|
||||
@staticmethod
|
||||
def abi():
|
||||
if CappedToken.__abi == None:
|
||||
f = open(os.path.join(data_dir, 'CappedToken.json'), 'r')
|
||||
CappedToken.__abi = json.load(f)
|
||||
f.close()
|
||||
return CappedToken.__abi
|
||||
|
||||
|
||||
@staticmethod
|
||||
def bytecode(version=None):
|
||||
if CappedToken.__bytecode == None:
|
||||
f = open(os.path.join(data_dir, 'CappedToken.bin'))
|
||||
CappedToken.__bytecode = f.read()
|
||||
f.close()
|
||||
return CappedToken.__bytecode
|
||||
1
python/ge_capped_token/data/CappedToken.bin
Normal file
1
python/ge_capped_token/data/CappedToken.bin
Normal file
File diff suppressed because one or more lines are too long
1
python/ge_capped_token/data/CappedToken.json
Normal file
1
python/ge_capped_token/data/CappedToken.json
Normal file
File diff suppressed because one or more lines are too long
1
python/ge_capped_token/data/CappedToken.metadata.json
Normal file
1
python/ge_capped_token/data/CappedToken.metadata.json
Normal file
File diff suppressed because one or more lines are too long
3
python/ge_capped_token/data/__init__.py
Normal file
3
python/ge_capped_token/data/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
import os
|
||||
|
||||
data_dir = os.path.realpath(os.path.dirname(__file__))
|
||||
51
python/ge_capped_token/unittest/__init__.py
Normal file
51
python/ge_capped_token/unittest/__init__.py
Normal file
@@ -0,0 +1,51 @@
|
||||
# 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 ge_capped_token import CappedToken
|
||||
|
||||
logg = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TestCappedToken(EthTesterCase):
|
||||
|
||||
expire = 0
|
||||
|
||||
def setUp(self):
|
||||
super(TestCappedToken, self).setUp()
|
||||
self.conn = RPCConnection.connect(self.chain_spec, 'default')
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[0], conn=self.conn)
|
||||
c = CappedToken(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
|
||||
(tx_hash, o) = c.mint_to(self.address, self.accounts[0], self.accounts[0], self.initial_supply)
|
||||
r = self.conn.do(o)
|
||||
o = receipt(tx_hash)
|
||||
r = self.conn.do(o)
|
||||
self.assertEqual(r['status'], 1)
|
||||
|
||||
|
||||
class TestCappedExpireToken(TestCappedToken):
|
||||
|
||||
expire = int(time.time()) + 100000
|
||||
|
||||
def setUp(self):
|
||||
super(TestCappedExpireToken, self).setUp()
|
||||
Reference in New Issue
Block a user