From de50ef1ae2319947abc486d78470f6fcef127087 Mon Sep 17 00:00:00 2001 From: Muhammad-Altabba <24407834+Muhammad-Altabba@users.noreply.github.com> Date: Tue, 3 Sep 2024 16:56:58 +0200 Subject: [PATCH 1/2] fix: set the default `from` for the contract created by ContractFactory --- src/contract-factory.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/contract-factory.ts b/src/contract-factory.ts index 9d82e72..cbc4b3d 100644 --- a/src/contract-factory.ts +++ b/src/contract-factory.ts @@ -79,7 +79,9 @@ export class ContractFactory 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( From c258c38bb4b6e9f5667753b4bb888a4b1842fea1 Mon Sep 17 00:00:00 2001 From: Muhammad-Altabba <24407834+Muhammad-Altabba@users.noreply.github.com> Date: Tue, 3 Sep 2024 16:47:47 +0200 Subject: [PATCH 2/2] tolerate if there was only one parameter for deploy, which was passed as-is without wrapping it inside an array --- src/contract-factory.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/contract-factory.ts b/src/contract-factory.ts index cbc4b3d..e205f01 100644 --- a/src/contract-factory.ts +++ b/src/contract-factory.ts @@ -276,7 +276,13 @@ export class ContractFactory 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();