Skip to content

Commit 02ec7b5

Browse files
authored
feat: merge-train/fairies (#22323)
BEGIN_COMMIT_OVERRIDE fix: preserve DeployAccountMethod type in with() method chaining (#22322) END_COMMIT_OVERRIDE
2 parents ee65fa5 + 24c99f6 commit 02ec7b5

File tree

2 files changed

+52
-6
lines changed

2 files changed

+52
-6
lines changed

yarn-project/aztec.js/src/contract/deploy_method.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,18 +140,18 @@ export class DeployMethod<TContract extends ContractBase = ContractBase> extends
140140
private instance?: ContractInstanceWithAddress = undefined;
141141

142142
/** Constructor function to call. */
143-
private constructorArtifact: FunctionAbi | undefined;
143+
protected constructorArtifact: FunctionAbi | undefined;
144144

145145
constructor(
146-
private publicKeys: PublicKeys,
146+
protected publicKeys: PublicKeys,
147147
wallet: Wallet,
148148
protected artifact: ContractArtifact,
149149
protected postDeployCtor: (instance: ContractInstanceWithAddress, wallet: Wallet) => TContract,
150-
private args: any[] = [],
150+
protected args: any[] = [],
151151
constructorNameOrArtifact?: string | FunctionArtifact,
152152
authWitnesses: AuthWitness[] = [],
153153
capsules: Capsule[] = [],
154-
private extraHashedArgs: HashedValues[] = [],
154+
protected extraHashedArgs: HashedValues[] = [],
155155
) {
156156
super(wallet, authWitnesses, capsules);
157157
this.constructorArtifact = getInitializer(artifact, constructorNameOrArtifact);

yarn-project/aztec.js/src/wallet/deploy_account_method.ts

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { DefaultMultiCallEntrypoint } from '@aztec/entrypoints/multicall';
22
import { Fr } from '@aztec/foundation/curves/bn254';
33
import type { ContractArtifact, FunctionArtifact } from '@aztec/stdlib/abi';
4+
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
45
import { AztecAddress } from '@aztec/stdlib/aztec-address';
56
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
67
import type { PublicKeys } from '@aztec/stdlib/keys';
7-
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
8+
import { type Capsule, ExecutionPayload, type HashedValues, mergeExecutionPayloads } from '@aztec/stdlib/tx';
89

910
import type { Account } from '../account/account.js';
1011
import type { Contract } from '../contract/contract.js';
@@ -86,8 +87,21 @@ export class DeployAccountMethod<TContract extends ContractBase = Contract> exte
8687
private account: Account,
8788
args: any[] = [],
8889
constructorNameOrArtifact?: string | FunctionArtifact,
90+
authWitnesses: AuthWitness[] = [],
91+
capsules: Capsule[] = [],
92+
extraHashedArgs: HashedValues[] = [],
8993
) {
90-
super(publicKeys, wallet, artifact, postDeployCtor, args, constructorNameOrArtifact);
94+
super(
95+
publicKeys,
96+
wallet,
97+
artifact,
98+
postDeployCtor,
99+
args,
100+
constructorNameOrArtifact,
101+
authWitnesses,
102+
capsules,
103+
extraHashedArgs,
104+
);
91105
}
92106

93107
/**
@@ -195,4 +209,36 @@ export class DeployAccountMethod<TContract extends ContractBase = Contract> exte
195209
const existing = options.additionalScopes ?? [];
196210
return { ...options, additionalScopes: [...existing, this.address] };
197211
}
212+
213+
/**
214+
* Augments this DeployAccountMethod with additional metadata, such as authWitnesses and capsules.
215+
* @param options - An object containing the metadata to add to the interaction
216+
* @returns A new DeployAccountMethod with the added metadata
217+
*/
218+
public override with({
219+
authWitnesses = [],
220+
capsules = [],
221+
extraHashedArgs = [],
222+
}: {
223+
/** The authWitnesses to add to the deployment */
224+
authWitnesses?: AuthWitness[];
225+
/** The capsules to add to the deployment */
226+
capsules?: Capsule[];
227+
/** The extra hashed args to add to the deployment */
228+
extraHashedArgs?: HashedValues[];
229+
}): DeployAccountMethod<TContract> {
230+
return new DeployAccountMethod(
231+
this.publicKeys,
232+
this.wallet,
233+
this.artifact,
234+
this.postDeployCtor,
235+
this.salt,
236+
this.account,
237+
this.args,
238+
this.constructorArtifact?.name,
239+
this.authWitnesses.concat(authWitnesses),
240+
this.capsules.concat(capsules),
241+
this.extraHashedArgs.concat(extraHashedArgs),
242+
);
243+
}
198244
}

0 commit comments

Comments
 (0)