Skip to content

Commit

Permalink
Copy EIP-4844 properties during estimateGas and call (#4728).
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed May 30, 2024
1 parent 5463aa0 commit cebe5ee
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src.ts/providers/provider-etherscan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,21 @@ export class EtherscanProvider extends AbstractProvider {
// Quantity-types require no leading zero, unless 0
if ((<any>{ 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);
}
Expand Down
12 changes: 11 additions & 1 deletion src.ts/providers/provider-jsonrpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -845,6 +845,16 @@ export abstract class JsonRpcApiProvider extends AbstractProvider {
result["accessList"] = accessListify(tx.accessList);
}

if (tx.blobVersionedHashes) {
// @TODO: Remove this <any> case once EIP-4844 added to prepared tx
(<any>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;
}

Expand Down

0 comments on commit cebe5ee

Please sign in to comment.