Skip to content

Commit

Permalink
fix: Optimize EIP-1559 support detection for custom networks (#6390)
Browse files Browse the repository at this point in the history
  • Loading branch information
originalix authored Dec 22, 2024
1 parent f451be0 commit 86f2121
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions packages/kit-bg/src/vaults/impls/evm/sdkEvm/ClientEvm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> {
Expand Down

0 comments on commit 86f2121

Please sign in to comment.