Skip to content

Commit

Permalink
Merge pull request #53 from ChainSafe/52-set-default-from-at-contactf…
Browse files Browse the repository at this point in the history
…actory-and-allow-passing-not-as-an-array-to-it-deploy-method-if-there-was-only-one-parameter

fix: set default `from` at `ContactFactory` and allow passing not as an array to it `deploy` method, if there was only one parameter
  • Loading branch information
Muhammad-Altabba authored Sep 10, 2024
2 parents 9e889dd + c258c38 commit 4c922b3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/contract-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ export class ContractFactory<Abi extends ContractAbi> extends Web3Context {

this.deploymentType = deploymentType || 'create';

this.contractToBeDeployed = new zkWallet.provider!.eth.Contract(this.abi);
this.contractToBeDeployed = new zkWallet.provider!.eth.Contract(this.abi, {
from: this.zkWallet.getAddress() ?? this.defaultAccount ?? undefined,
});
}

private encodeCalldata(
Expand Down Expand Up @@ -274,7 +276,13 @@ export class ContractFactory<Abi extends ContractAbi> extends Web3Context {
deploymentTransaction(): web3Types.TransactionReceipt;
}
> {
const tx = await this.getDeployTransaction(args, overrides);
let modArgs = args;
if (!Array.isArray(args)) {
// tolerate if there was only one parameter for deploy,
// which was passed as-is without wrapping it inside an array.
modArgs = [args] as any;
}
const tx = await this.getDeployTransaction(modArgs, overrides);

const receipt = await (await this.zkWallet?.sendTransaction(tx)).wait();

Expand Down

0 comments on commit 4c922b3

Please sign in to comment.