diff --git a/apps/cic-eth/cic_eth/eth/erc20.py b/apps/cic-eth/cic_eth/eth/erc20.py index 4fbe2e57..52658c4a 100644 --- a/apps/cic-eth/cic_eth/eth/erc20.py +++ b/apps/cic-eth/cic_eth/eth/erc20.py @@ -10,6 +10,9 @@ from chainlib.eth.tx import ( TxFormat, unpack, ) +from chainlib.eth.contract import ( + ABIContractEncoder, + ) from cic_eth_registry import CICRegistry from cic_eth_registry.erc20 import ERC20Token from hexathon import ( @@ -155,7 +158,7 @@ def transfer_from(self, tokens, holder_address, receiver_address, value, chain_s session = self.create_session() nonce_oracle = CustodialTaskNonceOracle(holder_address, self.request.root_id, session=session) - gas_oracle = self.create_gas_oracle(rpc, MaxGasOracle.gas) + gas_oracle = self.create_gas_oracle(rpc, t['address'], MaxGasOracle.gas) c = ERC20(chain_spec, signer=rpc_signer, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle) try: (tx_hash_hex, tx_signed_raw_hex) = c.transfer_from(t['address'], spender_address, holder_address, receiver_address, value, tx_format=TxFormat.RLP_SIGNED) @@ -226,6 +229,11 @@ def transfer(self, tokens, holder_address, receiver_address, value, chain_spec_d session = self.create_session() nonce_oracle = CustodialTaskNonceOracle(holder_address, self.request.root_id, session=session) + + enc = ABIContractEncoder() + enc.method('transferFrom') + method = enc.get() + gas_oracle = self.create_gas_oracle(rpc, MaxGasOracle.gas) c = ERC20(chain_spec, signer=rpc_signer, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle) try: diff --git a/apps/cic-eth/cic_eth/eth/gas.py b/apps/cic-eth/cic_eth/eth/gas.py index c00ee05b..6dab6373 100644 --- a/apps/cic-eth/cic_eth/eth/gas.py +++ b/apps/cic-eth/cic_eth/eth/gas.py @@ -71,13 +71,6 @@ celery_app = celery.current_app logg = logging.getLogger() -MAXIMUM_FEE_UNITS = 8000000 - -class MaxGasOracle: - - def gas(code=None): - return MAXIMUM_FEE_UNITS - @celery_app.task(base=CriticalSQLAlchemyTask) def apply_gas_value_cache(address, method, value, tx_hash): @@ -85,8 +78,8 @@ def apply_gas_value_cache(address, method, value, tx_hash): def apply_gas_value_cache_local(address, method, value, tx_hash, session=None): - address = strip_0x(address) - tx_hash = strip_0x(tx_hash) + address = tx_normalize.executable_address(address) + tx_hash = tx_normalize.tx_hash(tx_hash) value = int(value) session = SessionBase.bind_session(session) diff --git a/apps/cic-eth/cic_eth/task.py b/apps/cic-eth/cic_eth/task.py index 149e1800..77a9fde4 100644 --- a/apps/cic-eth/cic_eth/task.py +++ b/apps/cic-eth/cic_eth/task.py @@ -10,7 +10,6 @@ from chainlib.chain import ChainSpec from chainlib.connection import RPCConnection from chainlib.eth.constant import ZERO_ADDRESS from chainlib.eth.nonce import RPCNonceOracle -from chainlib.eth.gas import RPCGasOracle from cic_eth_registry import CICRegistry from cic_eth_registry.error import UnknownContractError @@ -30,7 +29,7 @@ class BaseTask(celery.Task): call_address = ZERO_ADDRESS trusted_addresses = [] create_nonce_oracle = RPCNonceOracle - create_gas_oracle = RPCGasOracle + create_gas_oracle = CacheGasOracle default_token_address = None default_token_symbol = None default_token_name = None