Add supply / mint step
This commit is contained in:
parent
95483d4c79
commit
ab4976d809
@ -3,6 +3,6 @@
|
|||||||
"symbol": "",
|
"symbol": "",
|
||||||
"precision": 0,
|
"precision": 0,
|
||||||
"code": null,
|
"code": null,
|
||||||
|
"supply": 0,
|
||||||
"extra": {}
|
"extra": {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ from hexathon import add_0x
|
|||||||
from eth_token_index import TokenUniqueSymbolIndex
|
from eth_token_index import TokenUniqueSymbolIndex
|
||||||
from eth_address_declarator import Declarator
|
from eth_address_declarator import Declarator
|
||||||
from eth_address_declarator.declarator import AddressDeclarator
|
from eth_address_declarator.declarator import AddressDeclarator
|
||||||
|
from giftable_erc20_token import GiftableToken
|
||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
from cic.ext.eth.rpc import parse_adapter
|
from cic.ext.eth.rpc import parse_adapter
|
||||||
@ -155,10 +156,22 @@ class CICEth(Extension):
|
|||||||
|
|
||||||
if r == None:
|
if r == None:
|
||||||
r = code
|
r = code
|
||||||
|
|
||||||
writer.write('token_address', self.token_address.encode('utf-8'))
|
|
||||||
writer.write('token', r.encode('utf-8'))
|
writer.write('token', r.encode('utf-8'))
|
||||||
|
writer.write('token_address', self.token_address.encode('utf-8'))
|
||||||
self.add_outputs('token', r.encode('utf-8'))
|
self.add_outputs('token', r.encode('utf-8'))
|
||||||
|
|
||||||
|
if self.token_details['supply'] > 0:
|
||||||
|
c = GiftableToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle, gas_oracle=self.fee_oracle)
|
||||||
|
o = c.mint_to(self.token_address, self.resources['token']['key_account'], self.resources['token']['key_account'], self.token_details['supply'])
|
||||||
|
r = None
|
||||||
|
if self.rpc != None:
|
||||||
|
r = self.rpc.do(o[1])
|
||||||
|
self.rpc.wait(r)
|
||||||
|
elif self.signer != None:
|
||||||
|
r = o[1]
|
||||||
|
else:
|
||||||
|
r = o
|
||||||
|
writer.write('token_supply', r.encode('utf-8'))
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,15 +23,16 @@ class Extension:
|
|||||||
|
|
||||||
# TODO: apply / prepare token can be factored out
|
# TODO: apply / prepare token can be factored out
|
||||||
def apply_token(self, token):
|
def apply_token(self, token):
|
||||||
return self.prepare_token(token.name, token.symbol, token.precision, token.code)
|
return self.prepare_token(token.name, token.symbol, token.precision, token.code, token.supply)
|
||||||
|
|
||||||
|
|
||||||
def prepare_token(self, name, symbol, precision, code, extra=[], extra_types=[], positions=None):
|
def prepare_token(self, name, symbol, precision, code, supply, extra=[], extra_types=[], positions=None):
|
||||||
self.token_details = {
|
self.token_details = {
|
||||||
'name': name,
|
'name': name,
|
||||||
'symbol': symbol,
|
'symbol': symbol,
|
||||||
'precision': precision,
|
'precision': precision,
|
||||||
'code': code,
|
'code': code,
|
||||||
|
'supply': supply,
|
||||||
'extra': extra,
|
'extra': extra,
|
||||||
'extra_types': extra_types,
|
'extra_types': extra_types,
|
||||||
'positions': positions,
|
'positions': positions,
|
||||||
|
@ -33,6 +33,7 @@ class Token(Data):
|
|||||||
self.symbol = o['symbol']
|
self.symbol = o['symbol']
|
||||||
self.precision = o['precision']
|
self.precision = o['precision']
|
||||||
self.code = o['code']
|
self.code = o['code']
|
||||||
|
self.supply = o['supply']
|
||||||
self.extra_args = o['extra']
|
self.extra_args = o['extra']
|
||||||
|
|
||||||
self.inited = True
|
self.inited = True
|
||||||
@ -51,6 +52,7 @@ class Token(Data):
|
|||||||
o['symbol'] = self.symbol
|
o['symbol'] = self.symbol
|
||||||
o['precision'] = self.precision
|
o['precision'] = self.precision
|
||||||
o['code'] = self.code
|
o['code'] = self.code
|
||||||
|
o['supply'] = self.supply
|
||||||
|
|
||||||
f = open(self.token_path, 'w')
|
f = open(self.token_path, 'w')
|
||||||
json.dump(o, f)
|
json.dump(o, f)
|
||||||
|
Loading…
Reference in New Issue
Block a user