From cebe5eed91de0db5931b7847e76ee27cb2ce9219 Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Thu, 30 May 2024 17:20:42 -0400 Subject: [PATCH] Copy EIP-4844 properties during estimateGas and call (#4728). --- src.ts/providers/provider-etherscan.ts | 11 +++++++++++ src.ts/providers/provider-jsonrpc.ts | 12 +++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src.ts/providers/provider-etherscan.ts b/src.ts/providers/provider-etherscan.ts index 3f089845c6..469417b9d4 100644 --- a/src.ts/providers/provider-etherscan.ts +++ b/src.ts/providers/provider-etherscan.ts @@ -340,10 +340,21 @@ export class EtherscanProvider extends AbstractProvider { // Quantity-types require no leading zero, unless 0 if (({ type: true, gasLimit: true, gasPrice: true, maxFeePerGs: true, maxPriorityFeePerGas: true, nonce: true, value: true })[key]) { value = toQuantity(value); + } else if (key === "accessList") { value = "[" + accessListify(value).map((set) => { return `{address:"${ set.address }",storageKeys:["${ set.storageKeys.join('","') }"]}`; }).join(",") + "]"; + + } else if (key === "blobVersionedHashes") { + if (value.length === 0) { continue; } + + // @TODO: update this once the API supports blobs + assert(false, "Etherscan API does not support blobVersionedHashes", "UNSUPPORTED_OPERATION", { + operation: "_getTransactionPostData", + info: { transaction } + }); + } else { value = hexlify(value); } diff --git a/src.ts/providers/provider-jsonrpc.ts b/src.ts/providers/provider-jsonrpc.ts index bc449ce90c..fb993249ae 100644 --- a/src.ts/providers/provider-jsonrpc.ts +++ b/src.ts/providers/provider-jsonrpc.ts @@ -655,7 +655,7 @@ export abstract class JsonRpcApiProvider extends AbstractProvider { if (req.method === "call" || req.method === "estimateGas") { let tx = req.transaction; if (tx && tx.type != null && getBigInt(tx.type)) { - // If there are no EIP-1559 properties, it might be non-EIP-a559 + // If there are no EIP-1559 or newer properties, it might be pre-EIP-1559 if (tx.maxFeePerGas == null && tx.maxPriorityFeePerGas == null) { const feeData = await this.getFeeData(); if (feeData.maxFeePerGas == null && feeData.maxPriorityFeePerGas == null) { @@ -845,6 +845,16 @@ export abstract class JsonRpcApiProvider extends AbstractProvider { result["accessList"] = accessListify(tx.accessList); } + if (tx.blobVersionedHashes) { + // @TODO: Remove this case once EIP-4844 added to prepared tx + (result)["blobVersionedHashes"] = tx.blobVersionedHashes.map(h => h.toLowerCase()); + } + + // @TODO: blobs should probably also be copied over, optionally + // accounting for the kzg property to backfill blobVersionedHashes + // using the commitment. Or should that be left as an exercise to + // the caller? + return result; }