Adding customData support to transactions to assist L2 chains (#1761).

This commit is contained in:
Richard Moore 2021-10-05 15:47:26 -04:00
parent 0e5419ec79
commit 68095a48ae
No known key found for this signature in database
GPG Key ID: 665176BE8E9DC651
3 changed files with 14 additions and 2 deletions

View File

@ -32,6 +32,8 @@ export type TransactionRequest = {
maxPriorityFeePerGas?: BigNumberish;
maxFeePerGas?: BigNumberish;
customData?: Record<string, any>;
}
export interface TransactionResponse extends Transaction {

View File

@ -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 = [

View File

@ -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));