Skip to content

Commit 593b488

Browse files
committed
Prevent overriding value for non-payble constructors (ethers-io#1785).
1 parent 6d1904c commit 593b488

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/contracts/src.ts/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,16 @@ export class ContractFactory {
11661166
logger.throwError("cannot override " + key, Logger.errors.UNSUPPORTED_OPERATION, { operation: key })
11671167
});
11681168

1169+
if (tx.value) {
1170+
const value = BigNumber.from(tx.value);
1171+
if (!value.isZero() && !this.interface.deploy.payable) {
1172+
logger.throwError("non-payable constructor cannot override value", Logger.errors.UNSUPPORTED_OPERATION, {
1173+
operation: "overrides.value",
1174+
value: tx.value
1175+
});
1176+
}
1177+
}
1178+
11691179
// Make sure the call matches the constructor signature
11701180
logger.checkArgumentCount(args.length, this.interface.deploy.inputs.length, " in Contract constructor");
11711181

0 commit comments

Comments
 (0)