Adding customData support to transactions to assist L2 chains (#1761).
This commit is contained in:
parent
0e5419ec79
commit
68095a48ae
@ -32,6 +32,8 @@ export type TransactionRequest = {
|
||||
|
||||
maxPriorityFeePerGas?: BigNumberish;
|
||||
maxFeePerGas?: BigNumberish;
|
||||
|
||||
customData?: Record<string, any>;
|
||||
}
|
||||
|
||||
export interface TransactionResponse extends Transaction {
|
||||
|
@ -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 = [
|
||||
|
@ -22,6 +22,7 @@ export interface Overrides {
|
||||
nonce?: BigNumberish | Promise<BigNumberish>;
|
||||
type?: number;
|
||||
accessList?: AccessListish;
|
||||
customData?: Record<string, any>;
|
||||
};
|
||||
|
||||
export interface PayableOverrides extends Overrides {
|
||||
@ -55,6 +56,8 @@ export interface PopulatedTransaction {
|
||||
|
||||
maxFeePerGas?: BigNumber;
|
||||
maxPriorityFeePerGas?: BigNumber;
|
||||
|
||||
customData?: Record<string, any>;
|
||||
};
|
||||
|
||||
export type EventFilter = {
|
||||
@ -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> {
|
||||
@ -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;
|
||||
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user