Skip to content

Commit

Permalink
Better error message when passing invalid overrides object into a con…
Browse files Browse the repository at this point in the history
…tract deployment (#4182).
  • Loading branch information
ricmoo committed Jul 28, 2023
1 parent bcc4d8c commit aa2ea3d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src.ts/contract/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,12 @@ function getProvider(value: null | ContractRunner): null | Provider {
*/
export async function copyOverrides<O extends string = "data" | "to">(arg: any, allowed?: Array<string>): Promise<Omit<ContractTransaction, O>> {

// Make sure the overrides passed in are a valid overrides object
const _overrides = Typed.dereference(arg, "overrides");
assertArgument(typeof(_overrides) === "object", "invalid overrides parameter", "overrides", arg);

// Create a shallow copy (we'll deep-ify anything needed during normalizing)
const overrides = copyRequest(Typed.dereference(arg, "overrides"));
const overrides = copyRequest(_overrides);

assertArgument(overrides.to == null || (allowed || [ ]).indexOf("to") >= 0,
"cannot override to", "overrides.to", overrides.to);
Expand Down

0 comments on commit aa2ea3d

Please # to comment.