Skip to content

Commit

Permalink
Prevent overriding value for non-payble constructors (#1785).
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Jul 29, 2021
1 parent 6d1904c commit 593b488
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/contracts/src.ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,16 @@ export class ContractFactory {
logger.throwError("cannot override " + key, Logger.errors.UNSUPPORTED_OPERATION, { operation: key })
});

if (tx.value) {
const value = BigNumber.from(tx.value);
if (!value.isZero() && !this.interface.deploy.payable) {
logger.throwError("non-payable constructor cannot override value", Logger.errors.UNSUPPORTED_OPERATION, {
operation: "overrides.value",
value: tx.value
});
}
}

// Make sure the call matches the constructor signature
logger.checkArgumentCount(args.length, this.interface.deploy.inputs.length, " in Contract constructor");

Expand Down

0 comments on commit 593b488

Please sign in to comment.