From f6ed757a1ccbf7a76d659ec17aa33b7378183ca5 Mon Sep 17 00:00:00 2001 From: zhl Date: Thu, 2 Feb 2023 17:09:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A6=82=E6=9E=9C=E4=BA=A4=E6=98=93=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E6=B2=A1=E6=9C=89gasPrice=EF=BC=8C=E9=82=A3=E4=B9=88?= =?UTF-8?q?=E6=A0=B9=E6=8D=AEmaxFeePerGas=E5=92=8CmaxPriorityFeePerGas?= =?UTF-8?q?=E6=9D=A5=E8=AE=A1=E7=AE=97gasPrice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/util/chain.util.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/util/chain.util.ts b/src/util/chain.util.ts index 6e2259e..7b0e385 100644 --- a/src/util/chain.util.ts +++ b/src/util/chain.util.ts @@ -91,9 +91,22 @@ export function universalChainCb(reqData: any, req: any) { return req .on("presend", function (dataObj: any) { if (jc.wallet.isInternal) { - console.log("before send tran: ", dataObj); + console.log("before send tran: ", JSON.stringify(dataObj)); + let gasPrice; + if ( + !dataObj.gasPrice && + dataObj.maxPriorityFeePerGas && + dataObj.maxFeePerGas + ) { + gasPrice = toBN(dataObj.maxFeePerGas) + .sub(toBN(dataObj.maxPriorityFeePerGas)) + .div(toBN(2)) + .mul(toBN(1000000000)); + } else if (dataObj.gasPrice) { + gasPrice = toBN(dataObj.gasPrice); + } reqData.gas = toBN(dataObj.gas).toString(); - reqData.gasPrice = toBN(dataObj.gasPrice).toString(); + reqData.gasPrice = gasPrice.toString(); reqData.transactionHash = dataObj.transactionHash; reqData.chain = jc.wallet.currentChain.id; reqData.startTime = Date.now();