From 60ad11c710f0b07b5cc00ce175a02176fc6e6372 Mon Sep 17 00:00:00 2001 From: Anton Lisanin Date: Mon, 14 Mar 2022 13:27:55 +0300 Subject: [PATCH] Fix eth_estimageGas for Metamask transfer --- proxy/common_neon/estimate.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/proxy/common_neon/estimate.py b/proxy/common_neon/estimate.py index 354afd7a4..9da3f34c4 100644 --- a/proxy/common_neon/estimate.py +++ b/proxy/common_neon/estimate.py @@ -13,11 +13,20 @@ @logged_group("neon.Proxy") class GasEstimate: def __init__(self, request: dict, solana: SolanaInteractor): - self.sender = request.get('from', "0x0000000000000000000000000000000000000000")[2:] - self.contract = request.get('to', '0x')[2:] - self.value = request.get('value', '0x00') - self.data = request.get('data', '0x')[2:] + self.sender = request.get('from') or '0x0000000000000000000000000000000000000000' + if self.sender: + self.sender = self.sender[2:] + self.contract = request.get('to') or '' + if self.contract: + self.contract = self.contract[2:] + + self.data = request.get('data') or '' + if self.data: + self.data = self.data[2:] + + self.value = request.get('value') or '0x00' + self.solana = solana def execution_cost(self) -> int: @@ -76,10 +85,8 @@ def estimate(self): overhead = self.iterative_overhead_cost() gas = execution_cost + trx_size_cost + overhead + EXTRA_GAS - - # TODO: MM restriction. Uncomment ? - # if gas < 21000: - # gas = 21000 + if gas < 21000: + gas = 21000 self.debug(f'execution_cost: {execution_cost}, ' + f'trx_size_cost: {trx_size_cost}, ' +