Skip to content

Commit 68095a4

Browse files
committed
Adding customData support to transactions to assist L2 chains (ethers-io#1761).
1 parent 0e5419e commit 68095a4

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

packages/abstract-provider/src.ts/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ export type TransactionRequest = {
3232

3333
maxPriorityFeePerGas?: BigNumberish;
3434
maxFeePerGas?: BigNumberish;
35+
36+
customData?: Record<string, any>;
3537
}
3638

3739
export interface TransactionResponse extends Transaction {

packages/abstract-signer/src.ts/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { version } from "./_version";
1010
const logger = new Logger(version);
1111

1212
const allowedTransactionKeys: Array<string> = [
13-
"accessList", "chainId", "data", "from", "gasLimit", "gasPrice", "maxFeePerGas", "maxPriorityFeePerGas", "nonce", "to", "type", "value"
13+
"accessList", "chainId", "customData", "data", "from", "gasLimit", "gasPrice", "maxFeePerGas", "maxPriorityFeePerGas", "nonce", "to", "type", "value"
1414
];
1515

1616
const forwardErrors = [

packages/contracts/src.ts/index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export interface Overrides {
2222
nonce?: BigNumberish | Promise<BigNumberish>;
2323
type?: number;
2424
accessList?: AccessListish;
25+
customData?: Record<string, any>;
2526
};
2627

2728
export interface PayableOverrides extends Overrides {
@@ -55,6 +56,8 @@ export interface PopulatedTransaction {
5556

5657
maxFeePerGas?: BigNumber;
5758
maxPriorityFeePerGas?: BigNumber;
59+
60+
customData?: Record<string, any>;
5861
};
5962

6063
export type EventFilter = {
@@ -106,7 +109,8 @@ export interface ContractTransaction extends TransactionResponse {
106109
const allowedTransactionKeys: { [ key: string ]: boolean } = {
107110
chainId: true, data: true, from: true, gasLimit: true, gasPrice:true, nonce: true, to: true, value: true,
108111
type: true, accessList: true,
109-
maxFeePerGas: true, maxPriorityFeePerGas: true
112+
maxFeePerGas: true, maxPriorityFeePerGas: true,
113+
customData: true
110114
}
111115

112116
async function resolveName(resolver: Signer | Provider, nameOrPromise: string | Promise<string>): Promise<string> {
@@ -257,6 +261,10 @@ async function populateTransaction(contract: Contract, fragment: FunctionFragmen
257261
tx.value = roValue;
258262
}
259263

264+
if (ro.customData) {
265+
tx.customData = shallowCopy(ro.customData);
266+
}
267+
260268
// Remove the overrides
261269
delete overrides.nonce;
262270
delete overrides.gasLimit;
@@ -270,6 +278,8 @@ async function populateTransaction(contract: Contract, fragment: FunctionFragmen
270278
delete overrides.maxFeePerGas;
271279
delete overrides.maxPriorityFeePerGas;
272280

281+
delete overrides.customData;
282+
273283
// Make sure there are no stray overrides, which may indicate a
274284
// typo or using an unsupported key.
275285
const leftovers = Object.keys(overrides).filter((key) => ((<any>overrides)[key] != null));

0 commit comments

Comments
 (0)