From 86f2121f83bbccbb642da58e091c2550b8f6c0d8 Mon Sep 17 00:00:00 2001 From: Leon Date: Sun, 22 Dec 2024 10:27:31 +0800 Subject: [PATCH] fix: Optimize EIP-1559 support detection for custom networks (#6390) --- .../src/vaults/impls/evm/sdkEvm/ClientEvm.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/kit-bg/src/vaults/impls/evm/sdkEvm/ClientEvm.ts b/packages/kit-bg/src/vaults/impls/evm/sdkEvm/ClientEvm.ts index d3e3674ed3f..8b822153546 100644 --- a/packages/kit-bg/src/vaults/impls/evm/sdkEvm/ClientEvm.ts +++ b/packages/kit-bg/src/vaults/impls/evm/sdkEvm/ClientEvm.ts @@ -28,10 +28,20 @@ export class ClientEvm extends JsonRPCRequest { baseFeePerGas: string; }>('eth_getBlockByNumber', ['latest', false]); const baseFeePerGas = new BigNumber(hexBlock.baseFeePerGas); - const isEIP1559FeeEnabled = !( - baseFeePerGas.isNaN() || baseFeePerGas.isEqualTo(0) - ); // 0 also means not 1559 - return { isEIP1559FeeEnabled }; + + // 0 also means not 1559 + if (baseFeePerGas.isNaN() || baseFeePerGas.isEqualTo(0)) { + return { isEIP1559FeeEnabled: false }; + } + + let maxPriorityFeeSupported = true; + try { + await this.call('eth_maxPriorityFeePerGas'); + } catch (error) { + maxPriorityFeeSupported = false; + } + + return { isEIP1559FeeEnabled: maxPriorityFeeSupported }; } async broadcastTransaction(rawTx: string): Promise {