mirror of
https://github.com/chaintool-py/eth-erc20.git
synced 2024-11-22 01:36:46 +01:00
Add eth adapter enhancement from crypto-dev-signer
This commit is contained in:
parent
c07bc3f976
commit
b51872c2ad
@ -20,7 +20,7 @@ from enum import Enum
|
|||||||
import web3
|
import web3
|
||||||
from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer
|
from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer
|
||||||
from crypto_dev_signer.keystore import DictKeystore
|
from crypto_dev_signer.keystore import DictKeystore
|
||||||
from crypto_dev_signer.helper import TxExecutor
|
from crypto_dev_signer.eth.helper import EthTxExecutor
|
||||||
|
|
||||||
logging.basicConfig(level=logging.WARNING)
|
logging.basicConfig(level=logging.WARNING)
|
||||||
logg = logging.getLogger()
|
logg = logging.getLogger()
|
||||||
@ -68,36 +68,15 @@ signer = EIP155Signer(keystore)
|
|||||||
chain_pair = args.i.split(':')
|
chain_pair = args.i.split(':')
|
||||||
chain_id = int(chain_pair[1])
|
chain_id = int(chain_pair[1])
|
||||||
|
|
||||||
|
helper = EthTxExecutor(
|
||||||
def gas_helper(signer_address, code, inputs):
|
w3,
|
||||||
return 8000000
|
|
||||||
|
|
||||||
def gas_price_helper():
|
|
||||||
return 20000000000
|
|
||||||
|
|
||||||
def translateTx(tx):
|
|
||||||
return {
|
|
||||||
'from': tx['from'],
|
|
||||||
'chainId': tx['chainId'],
|
|
||||||
'gas': tx['feeUnits'],
|
|
||||||
'gasPrice': tx['feePrice'],
|
|
||||||
'nonce': tx['nonce'],
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce = w3.eth.getTransactionCount(signer_address, 'pending')
|
|
||||||
|
|
||||||
helper = TxExecutor(
|
|
||||||
signer_address,
|
signer_address,
|
||||||
signer,
|
signer,
|
||||||
w3.eth.sendRawTransaction,
|
|
||||||
w3.eth.getTransactionReceipt,
|
|
||||||
nonce,
|
|
||||||
chain_id,
|
chain_id,
|
||||||
fee_helper=gas_helper,
|
|
||||||
fee_price_helper=gas_price_helper,
|
|
||||||
block=args.ww,
|
block=args.ww,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
f = open(os.path.join(args.abi_dir, 'GiftableToken.json'), 'r')
|
f = open(os.path.join(args.abi_dir, 'GiftableToken.json'), 'r')
|
||||||
@ -111,7 +90,6 @@ def main():
|
|||||||
c = w3.eth.contract(abi=abi, bytecode=bytecode)
|
c = w3.eth.contract(abi=abi, bytecode=bytecode)
|
||||||
(tx_hash, rcpt) = helper.sign_and_send(
|
(tx_hash, rcpt) = helper.sign_and_send(
|
||||||
[
|
[
|
||||||
translateTx,
|
|
||||||
c.constructor(args.n, args.s, args.d).buildTransaction
|
c.constructor(args.n, args.s, args.d).buildTransaction
|
||||||
],
|
],
|
||||||
force_wait=True,
|
force_wait=True,
|
||||||
@ -131,7 +109,6 @@ def main():
|
|||||||
continue
|
continue
|
||||||
(tx_hash, rcpt) = helper.sign_and_send(
|
(tx_hash, rcpt) = helper.sign_and_send(
|
||||||
[
|
[
|
||||||
translateTx,
|
|
||||||
c.functions.addMinter(a).buildTransaction,
|
c.functions.addMinter(a).buildTransaction,
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@ -141,7 +118,6 @@ def main():
|
|||||||
tx = c.functions.mint(mint_total)
|
tx = c.functions.mint(mint_total)
|
||||||
(tx_hash, rcpt) = helper.sign_and_send(
|
(tx_hash, rcpt) = helper.sign_and_send(
|
||||||
[
|
[
|
||||||
translateTx,
|
|
||||||
c.functions.mint(mint_total).buildTransaction,
|
c.functions.mint(mint_total).buildTransaction,
|
||||||
],
|
],
|
||||||
force_wait=True,
|
force_wait=True,
|
||||||
@ -150,7 +126,6 @@ def main():
|
|||||||
for a in args.account:
|
for a in args.account:
|
||||||
(tx_hash, rcpt) = helper.sign_and_send(
|
(tx_hash, rcpt) = helper.sign_and_send(
|
||||||
[
|
[
|
||||||
translateTx,
|
|
||||||
c.functions.transfer(a, args.amount).buildTransaction,
|
c.functions.transfer(a, args.amount).buildTransaction,
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -20,7 +20,7 @@ import web3
|
|||||||
from eth_keys import keys
|
from eth_keys import keys
|
||||||
from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer
|
from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer
|
||||||
from crypto_dev_signer.keystore import DictKeystore
|
from crypto_dev_signer.keystore import DictKeystore
|
||||||
from crypto_dev_signer.helper import TxExecutor
|
from crypto_dev_signer.eth.helper import EthTxExecutor
|
||||||
|
|
||||||
logging.basicConfig(level=logging.WARNING)
|
logging.basicConfig(level=logging.WARNING)
|
||||||
logg = logging.getLogger()
|
logg = logging.getLogger()
|
||||||
@ -64,37 +64,15 @@ signer = EIP155Signer(keystore)
|
|||||||
chain_pair = args.i.split(':')
|
chain_pair = args.i.split(':')
|
||||||
chain_id = int(chain_pair[1])
|
chain_id = int(chain_pair[1])
|
||||||
|
|
||||||
def gas_helper(signer_address, code, inputs):
|
helper = EthTxExecutor(
|
||||||
return 8000000
|
w3,
|
||||||
|
|
||||||
def gas_price_helper():
|
|
||||||
return 20000000000
|
|
||||||
|
|
||||||
def translateTx(tx):
|
|
||||||
return {
|
|
||||||
'from': tx['from'],
|
|
||||||
'chainId': tx['chainId'],
|
|
||||||
'gas': tx['feeUnits'],
|
|
||||||
'gasPrice': tx['feePrice'],
|
|
||||||
'nonce': tx['nonce'],
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce = w3.eth.getTransactionCount(signer_address, 'pending')
|
|
||||||
|
|
||||||
helper = TxExecutor(
|
|
||||||
signer_address,
|
signer_address,
|
||||||
signer,
|
signer,
|
||||||
w3.eth.sendRawTransaction,
|
|
||||||
w3.eth.getTransactionReceipt,
|
|
||||||
nonce,
|
|
||||||
chain_id,
|
chain_id,
|
||||||
fee_helper=gas_helper,
|
|
||||||
fee_price_helper=gas_price_helper,
|
|
||||||
block=args.ww,
|
block=args.ww,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
f = open(os.path.join(args.abi_dir, 'GiftableToken.json'), 'r')
|
f = open(os.path.join(args.abi_dir, 'GiftableToken.json'), 'r')
|
||||||
@ -115,7 +93,6 @@ def main():
|
|||||||
|
|
||||||
(tx_hash, rcpt) = helper.sign_and_send(
|
(tx_hash, rcpt) = helper.sign_and_send(
|
||||||
[
|
[
|
||||||
translateTx,
|
|
||||||
c.functions.mint(args.amount).buildTransaction,
|
c.functions.mint(args.amount).buildTransaction,
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@ -124,7 +101,6 @@ def main():
|
|||||||
|
|
||||||
(tx_hash, rcpt) = helper.sign_and_send(
|
(tx_hash, rcpt) = helper.sign_and_send(
|
||||||
[
|
[
|
||||||
translateTx,
|
|
||||||
c.functions.transfer(recipient, args.amount).buildTransaction,
|
c.functions.transfer(recipient, args.amount).buildTransaction,
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = giftable-erc20-token
|
name = giftable-erc20-token
|
||||||
version = 0.0.7a1
|
version = 0.0.7a2
|
||||||
description = Simple ERC20 contract with deployment script that lets any address mint and gift itself tokens.
|
description = Simple ERC20 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
|
||||||
|
Loading…
Reference in New Issue
Block a user