Skip to content

Commit

Permalink
Added EIP-1559 overrides to contracts (#1610).
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Jun 10, 2021
1 parent 7a12216 commit 5456c35
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/contracts/src.ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const logger = new Logger(version);
export interface Overrides {
gasLimit?: BigNumberish | Promise<BigNumberish>;
gasPrice?: BigNumberish | Promise<BigNumberish>;
maxFeePerGas?: BigNumberish | Promise<BigNumberish>;
maxPriorityFeePerGas?: BigNumberish | Promise<BigNumberish>;
nonce?: BigNumberish | Promise<BigNumberish>;
type?: number;
accessList?: AccessListish;
Expand Down Expand Up @@ -50,6 +52,9 @@ export interface PopulatedTransaction {

type?: number;
accessList?: AccessList;

maxFeePerGas?: BigNumber;
maxPriorityFeePerGas?: BigNumber;
};

export type EventFilter = {
Expand Down Expand Up @@ -101,6 +106,7 @@ 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
}

async function resolveName(resolver: Signer | Provider, nameOrPromise: string | Promise<string>): Promise<string> {
Expand Down Expand Up @@ -216,6 +222,8 @@ async function populateTransaction(contract: Contract, fragment: FunctionFragmen
if (ro.nonce != null) { tx.nonce = BigNumber.from(ro.nonce).toNumber(); }
if (ro.gasLimit != null) { tx.gasLimit = BigNumber.from(ro.gasLimit); }
if (ro.gasPrice != null) { tx.gasPrice = BigNumber.from(ro.gasPrice); }
if (ro.maxFeePerGas != null) { tx.maxFeePerGas = BigNumber.from(ro.maxFeePerGas); }
if (ro.maxPriorityFeePerGas != null) { tx.maxPriorityFeePerGas = BigNumber.from(ro.maxPriorityFeePerGas); }
if (ro.from != null) { tx.from = ro.from; }

if (ro.type != null) { tx.type = ro.type; }
Expand Down Expand Up @@ -259,6 +267,9 @@ async function populateTransaction(contract: Contract, fragment: FunctionFragmen
delete overrides.type;
delete overrides.accessList;

delete overrides.maxFeePerGas;
delete overrides.maxPriorityFeePerGas;

// 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 Expand Up @@ -693,7 +704,7 @@ export class BaseContract {
// Check that the signature is unique; if not the ABI generation has
// not been cleaned or may be incorrectly generated
if (uniqueSignatures[signature]) {
logger.warn(`Duplicate ABI entry for ${ JSON.stringify(name) }`);
logger.warn(`Duplicate ABI entry for ${ JSON.stringify(signature) }`);
return;
}
uniqueSignatures[signature] = true;
Expand Down

0 comments on commit 5456c35

Please sign in to comment.