Skip to content

Commit

Permalink
Adding customData support to transactions to assist L2 chains (#1761).
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Oct 5, 2021
1 parent 0e5419e commit 68095a4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/abstract-provider/src.ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export type TransactionRequest = {

maxPriorityFeePerGas?: BigNumberish;
maxFeePerGas?: BigNumberish;

customData?: Record<string, any>;
}

export interface TransactionResponse extends Transaction {
Expand Down
2 changes: 1 addition & 1 deletion packages/abstract-signer/src.ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { version } from "./_version";
const logger = new Logger(version);

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

const forwardErrors = [
Expand Down
12 changes: 11 additions & 1 deletion packages/contracts/src.ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface Overrides {
nonce?: BigNumberish | Promise<BigNumberish>;
type?: number;
accessList?: AccessListish;
customData?: Record<string, any>;
};

export interface PayableOverrides extends Overrides {
Expand Down Expand Up @@ -55,6 +56,8 @@ export interface PopulatedTransaction {

maxFeePerGas?: BigNumber;
maxPriorityFeePerGas?: BigNumber;

customData?: Record<string, any>;
};

export type EventFilter = {
Expand Down Expand Up @@ -106,7 +109,8 @@ export interface ContractTransaction extends TransactionResponse {
const allowedTransactionKeys: { [ key: string ]: boolean } = {
chainId: true, data: true, from: true, gasLimit: true, gasPrice:true, nonce: true, to: true, value: true,
type: true, accessList: true,
maxFeePerGas: true, maxPriorityFeePerGas: true
maxFeePerGas: true, maxPriorityFeePerGas: true,
customData: true
}

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

if (ro.customData) {
tx.customData = shallowCopy(ro.customData);
}

// Remove the overrides
delete overrides.nonce;
delete overrides.gasLimit;
Expand All @@ -270,6 +278,8 @@ async function populateTransaction(contract: Contract, fragment: FunctionFragmen
delete overrides.maxFeePerGas;
delete overrides.maxPriorityFeePerGas;

delete overrides.customData;

// Make sure there are no stray overrides, which may indicate a
// typo or using an unsupported key.
const leftovers = Object.keys(overrides).filter((key) => ((<any>overrides)[key] != null));
Expand Down

0 comments on commit 68095a4

Please sign in to comment.