From 228d18efccca9211dab5d0568e23726fc66b02f4 Mon Sep 17 00:00:00 2001 From: Arnaud Date: Mon, 19 May 2025 11:32:56 +0200 Subject: [PATCH] Call eth_maxPriorityFeePerGas and returns a manual defined maxPriorityFeePerGas as a fallback --- ethers/provider.nim | 2 +- ethers/providers/jsonrpc.nim | 12 +++++++++--- ethers/providers/jsonrpc/signatures.nim | 1 + ethers/signer.nim | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ethers/provider.nim b/ethers/provider.nim index c75df60..55cc07c 100644 --- a/ethers/provider.nim +++ b/ethers/provider.nim @@ -124,7 +124,7 @@ method getGasPrice*( method getMaxPriorityFeePerGas*( provider: Provider -): Future[UInt256] {.base, async: (raises: [ProviderError, CancelledError]).} = +): Future[UInt256] {.base, async: (raises: [CancelledError]).} = doAssert false, "not implemented" method getTransactionCount*( diff --git a/ethers/providers/jsonrpc.nim b/ethers/providers/jsonrpc.nim index f2ce53f..f2abe85 100644 --- a/ethers/providers/jsonrpc.nim +++ b/ethers/providers/jsonrpc.nim @@ -156,9 +156,15 @@ method getGasPrice*( method getMaxPriorityFeePerGas*( provider: JsonRpcProvider -): Future[UInt256] {.async: (raises: [ProviderError, CancelledError]).} = - convertError: - return provider.maxPriorityFeePerGas +): Future[UInt256] {.async: (raises: [CancelledError]).} = + try: + convertError: + let client = await provider.client + return await client.eth_maxPriorityFeePerGas() + except ProviderError: + # If the provider does not provide the implementation + # let's just remove the manual value + return provider.maxPriorityFeePerGas method getTransactionCount*( provider: JsonRpcProvider, address: Address, blockTag = BlockTag.latest diff --git a/ethers/providers/jsonrpc/signatures.nim b/ethers/providers/jsonrpc/signatures.nim index 60aded4..9e78bc1 100644 --- a/ethers/providers/jsonrpc/signatures.nim +++ b/ethers/providers/jsonrpc/signatures.nim @@ -21,3 +21,4 @@ proc eth_newBlockFilter(): JsonNode proc eth_newFilter(filter: EventFilter): JsonNode proc eth_getFilterChanges(id: JsonNode): JsonNode proc eth_uninstallFilter(id: JsonNode): bool +proc eth_maxPriorityFeePerGas(): UInt256 diff --git a/ethers/signer.nim b/ethers/signer.nim index d3b6b04..9646a5c 100644 --- a/ethers/signer.nim +++ b/ethers/signer.nim @@ -58,7 +58,7 @@ method getGasPrice*( method getMaxPriorityFeePerGas*( signer: Signer -): Future[UInt256] {.async: (raises: [ProviderError, SignerError, CancelledError]).} = +): Future[UInt256] {.async: (raises: [SignerError, CancelledError]).} = return await signer.provider.getMaxPriorityFeePerGas() method getTransactionCount*(