Skip to content

Commit

Permalink
fix: throw error only when nonce is not provided with contract.invoke
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvkelawala committed Sep 5, 2022
1 parent 1af16f4 commit c6bba65
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/contract/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -578,9 +578,21 @@ export class Contract implements ContractInterface {
});
}

if (!options.nonce) {
throw new Error(`Nonce is required when invoking a function without an account`);
}

// eslint-disable-next-line no-console
throw new Error(
`Invoking ${method} without an account is not supported. Please use account.execute`
console.warn(`Invoking ${method} without an account. This will not work on a public node.`);

return this.providerOrAccount.invokeFunction(
{
...invocation,
signature: options.signature || [],
},
{
nonce: options.nonce,
}
);
}

Expand Down

0 comments on commit c6bba65

Please sign in to comment.