diff --git a/yarn-project/aztec.js/src/contract/deploy_method.ts b/yarn-project/aztec.js/src/contract/deploy_method.ts index 3fdf8ac60f37..8d062499a392 100644 --- a/yarn-project/aztec.js/src/contract/deploy_method.ts +++ b/yarn-project/aztec.js/src/contract/deploy_method.ts @@ -140,18 +140,18 @@ export class DeployMethod extends private instance?: ContractInstanceWithAddress = undefined; /** Constructor function to call. */ - private constructorArtifact: FunctionAbi | undefined; + protected constructorArtifact: FunctionAbi | undefined; constructor( - private publicKeys: PublicKeys, + protected publicKeys: PublicKeys, wallet: Wallet, protected artifact: ContractArtifact, protected postDeployCtor: (instance: ContractInstanceWithAddress, wallet: Wallet) => TContract, - private args: any[] = [], + protected args: any[] = [], constructorNameOrArtifact?: string | FunctionArtifact, authWitnesses: AuthWitness[] = [], capsules: Capsule[] = [], - private extraHashedArgs: HashedValues[] = [], + protected extraHashedArgs: HashedValues[] = [], ) { super(wallet, authWitnesses, capsules); this.constructorArtifact = getInitializer(artifact, constructorNameOrArtifact); diff --git a/yarn-project/aztec.js/src/wallet/deploy_account_method.ts b/yarn-project/aztec.js/src/wallet/deploy_account_method.ts index c77b45f8c338..59f818807b40 100644 --- a/yarn-project/aztec.js/src/wallet/deploy_account_method.ts +++ b/yarn-project/aztec.js/src/wallet/deploy_account_method.ts @@ -1,10 +1,11 @@ import { DefaultMultiCallEntrypoint } from '@aztec/entrypoints/multicall'; import { Fr } from '@aztec/foundation/curves/bn254'; import type { ContractArtifact, FunctionArtifact } from '@aztec/stdlib/abi'; +import type { AuthWitness } from '@aztec/stdlib/auth-witness'; import { AztecAddress } from '@aztec/stdlib/aztec-address'; import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract'; import type { PublicKeys } from '@aztec/stdlib/keys'; -import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx'; +import { type Capsule, ExecutionPayload, type HashedValues, mergeExecutionPayloads } from '@aztec/stdlib/tx'; import type { Account } from '../account/account.js'; import type { Contract } from '../contract/contract.js'; @@ -86,8 +87,21 @@ export class DeployAccountMethod exte private account: Account, args: any[] = [], constructorNameOrArtifact?: string | FunctionArtifact, + authWitnesses: AuthWitness[] = [], + capsules: Capsule[] = [], + extraHashedArgs: HashedValues[] = [], ) { - super(publicKeys, wallet, artifact, postDeployCtor, args, constructorNameOrArtifact); + super( + publicKeys, + wallet, + artifact, + postDeployCtor, + args, + constructorNameOrArtifact, + authWitnesses, + capsules, + extraHashedArgs, + ); } /** @@ -195,4 +209,36 @@ export class DeployAccountMethod exte const existing = options.additionalScopes ?? []; return { ...options, additionalScopes: [...existing, this.address] }; } + + /** + * Augments this DeployAccountMethod with additional metadata, such as authWitnesses and capsules. + * @param options - An object containing the metadata to add to the interaction + * @returns A new DeployAccountMethod with the added metadata + */ + public override with({ + authWitnesses = [], + capsules = [], + extraHashedArgs = [], + }: { + /** The authWitnesses to add to the deployment */ + authWitnesses?: AuthWitness[]; + /** The capsules to add to the deployment */ + capsules?: Capsule[]; + /** The extra hashed args to add to the deployment */ + extraHashedArgs?: HashedValues[]; + }): DeployAccountMethod { + return new DeployAccountMethod( + this.publicKeys, + this.wallet, + this.artifact, + this.postDeployCtor, + this.salt, + this.account, + this.args, + this.constructorArtifact?.name, + this.authWitnesses.concat(authWitnesses), + this.capsules.concat(capsules), + this.extraHashedArgs.concat(extraHashedArgs), + ); + } }