Skip to content

Commit 92bad88

Browse files
committed
Added EIP-4844 broadcast support.
1 parent 12772e9 commit 92bad88

File tree

7 files changed

+282
-49
lines changed

7 files changed

+282
-49
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
"url": "https://www.buymeacoffee.com/ricmoo"
9494
}
9595
],
96-
"gitHead": "556fdd91d9b6bf7db4041bb099e66b2080e1a985",
96+
"gitHead": "12772e9498b70f8538838f30e16f3792ea90e173",
9797
"homepage": "https://ethers.org",
9898
"keywords": [
9999
"ethereum",
@@ -106,7 +106,7 @@
106106
"name": "ethers",
107107
"publishConfig": {
108108
"access": "public",
109-
"tag": "latest"
109+
"tag": "next"
110110
},
111111
"repository": {
112112
"type": "git",
@@ -131,5 +131,5 @@
131131
"test-esm": "mocha --trace-warnings --reporter ./reporter.cjs ./lib.esm/_tests/test-*.js"
132132
},
133133
"sideEffects": false,
134-
"version": "6.11.1"
134+
"version": "6.12.0-beta.1"
135135
}

src.ts/_version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
/**
44
* The current version of Ethers.
55
*/
6-
export const version: string = "6.11.1";
6+
export const version: string = "6.12.0-beta.1";

src.ts/ethers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ export type {
177177

178178
export type {
179179
AccessList, AccessListish, AccessListEntry,
180+
Blob, BlobLike, KzgLibrary,
180181
TransactionLike
181182
} from "./transaction/index.js";
182183

src.ts/providers/abstract-signer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ export abstract class AbstractSigner<P extends null | Provider = null | Provider
194194
operation: "signer.getFeeData" });
195195
}
196196

197-
} else if (pop.type === 2) {
198-
// Explicitly using EIP-1559
197+
} else if (pop.type === 2 || pop.type === 3) {
198+
// Explicitly using EIP-1559 or EIP-4844
199199

200200
// Populate missing fee data
201201
if (pop.maxFeePerGas == null) {

src.ts/providers/provider.ts

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
//import { resolveAddress } from "@ethersproject/address";
22
import {
3-
defineProperties, getBigInt, getNumber, hexlify, resolveProperties,
3+
defineProperties, getBigInt, getNumber, hexlify, isBytesLike,
4+
resolveProperties,
45
assert, assertArgument, isError, makeError
56
} from "../utils/index.js";
67
import { accessListify } from "../transaction/index.js";
78

89
import type { AddressLike, NameResolver } from "../address/index.js";
910
import type { BigNumberish, EventEmitterable } from "../utils/index.js";
1011
import type { Signature } from "../crypto/index.js";
11-
import type { AccessList, AccessListish, TransactionLike } from "../transaction/index.js";
12+
import type {
13+
AccessList, AccessListish, BlobLike, KzgLibrary, TransactionLike
14+
} from "../transaction/index.js";
1215

1316
import type { ContractRunner } from "./contracts.js";
1417
import type { Network } from "./network.js";
@@ -214,6 +217,30 @@ export interface TransactionRequest {
214217
*/
215218
enableCcipRead?: boolean;
216219

220+
/**
221+
* The blob versioned hashes (see [[link-eip-4844]]).
222+
*/
223+
blobVersionedHashes?: null | Array<string>
224+
225+
/**
226+
* The maximum fee per blob gas (see [[link-eip-4844]]).
227+
*/
228+
maxFeePerBlobGas?: null | BigNumberish;
229+
230+
/**
231+
* Any blobs to include in the transaction (see [[link-eip-4844]]).
232+
*/
233+
blobs?: null | Array<BlobLike>;
234+
235+
/**
236+
* An external library for computing the KZG commitments and
237+
* proofs necessary for EIP-4844 transactions (see [[link-eip-4844]]).
238+
*
239+
* This is generally ``null``, unless you are creating BLOb
240+
* transactions.
241+
*/
242+
kzg?: null | KzgLibrary;
243+
217244
// Todo?
218245
//gasMultiplier?: number;
219246
};
@@ -332,7 +359,7 @@ export function copyRequest(req: TransactionRequest): PreparedTransactionRequest
332359

333360
if (req.data) { result.data = hexlify(req.data); }
334361

335-
const bigIntKeys = "chainId,gasLimit,gasPrice,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);
362+
const bigIntKeys = "chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);
336363
for (const key of bigIntKeys) {
337364
if (!(key in req) || (<any>req)[key] == null) { continue; }
338365
result[key] = getBigInt((<any>req)[key], `request.${ key }`);
@@ -358,6 +385,19 @@ export function copyRequest(req: TransactionRequest): PreparedTransactionRequest
358385
result.customData = req.customData;
359386
}
360387

388+
if ("blobVersionedHashes" in req && req.blobVersionedHashes) {
389+
result.blobVersionedHashes = req.blobVersionedHashes.slice();
390+
}
391+
392+
if ("kzg" in req) { result.kzg = req.kzg; }
393+
394+
if ("blobs" in req && req.blobs) {
395+
result.blobs = req.blobs.map((b) => {
396+
if (isBytesLike(b)) { return hexlify(b); }
397+
return Object.assign({ }, b);
398+
});
399+
}
400+
361401
return result;
362402
}
363403

src.ts/transaction/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,6 @@ export { accessListify } from "./accesslist.js";
2828
export { computeAddress, recoverAddress } from "./address.js";
2929
export { Transaction } from "./transaction.js";
3030

31-
export type { TransactionLike } from "./transaction.js";
31+
export type {
32+
Blob, BlobLike, KzgLibrary, TransactionLike
33+
} from "./transaction.js";

0 commit comments

Comments
 (0)