Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions yarn-project/aztec.js/src/contract/deploy_method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,18 +140,18 @@ export class DeployMethod<TContract extends ContractBase = ContractBase> 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);
Expand Down
50 changes: 48 additions & 2 deletions yarn-project/aztec.js/src/wallet/deploy_account_method.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -86,8 +87,21 @@ export class DeployAccountMethod<TContract extends ContractBase = Contract> 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,
);
}

/**
Expand Down Expand Up @@ -195,4 +209,36 @@ export class DeployAccountMethod<TContract extends ContractBase = Contract> 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<TContract> {
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),
);
}
}
Loading