@aztec/builder 0.0.1-commit.b655e406 → 0.0.1-commit.b9865e97

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dest/bin/cli.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  export {};
3
- //# sourceMappingURL=cli.d.ts.map
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2xpLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvYmluL2NsaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=
@@ -5,5 +5,5 @@ export type GenerateCodeOptions = {
5
5
  /**
6
6
  * Generates Noir interface or Typescript interface for a folder or single file from a Noir compilation artifact.
7
7
  */
8
- export declare function generateCode(outputPath: string, fileOrDirPath: string, opts?: GenerateCodeOptions): Promise<string[]>;
9
- //# sourceMappingURL=codegen.d.ts.map
8
+ export declare function generateCode(outputPath: string, fileOrDirPath: string, opts?: GenerateCodeOptions): Promise<(string | undefined)[]>;
9
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29kZWdlbi5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NvbnRyYWN0LWludGVyZmFjZS1nZW4vY29kZWdlbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFZQSw0QkFBNEI7QUFDNUIsTUFBTSxNQUFNLG1CQUFtQixHQUFHO0lBQUUsS0FBSyxDQUFDLEVBQUUsT0FBTyxDQUFBO0NBQUUsQ0FBQztBQUV0RDs7R0FFRztBQUNILHdCQUFzQixZQUFZLENBQUMsVUFBVSxFQUFFLE1BQU0sRUFBRSxhQUFhLEVBQUUsTUFBTSxFQUFFLElBQUksR0FBRSxtQkFBd0IsbUNBa0IzRyJ9
@@ -1 +1 @@
1
- {"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../../src/contract-interface-gen/codegen.ts"],"names":[],"mappings":"AAYA,4BAA4B;AAC5B,MAAM,MAAM,mBAAmB,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAEtD;;GAEG;AACH,wBAAsB,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,IAAI,GAAE,mBAAwB,qBAkB3G"}
1
+ {"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../../src/contract-interface-gen/codegen.ts"],"names":[],"mappings":"AAYA,4BAA4B;AAC5B,MAAM,MAAM,mBAAmB,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAEtD;;GAEG;AACH,wBAAsB,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,IAAI,GAAE,mBAAwB,mCAkB3G"}
@@ -38,6 +38,10 @@ let cache = {};
38
38
  }
39
39
  const file = await readFile(noirAbiPath, 'utf8');
40
40
  const contract = JSON.parse(file);
41
+ if (!Array.isArray(contract.functions)) {
42
+ console.log(`${fileName} is not a contract artifact. Skipping.`);
43
+ return;
44
+ }
41
45
  const aztecAbi = loadContractArtifact(contract);
42
46
  await mkdir(outputPath, {
43
47
  recursive: true
@@ -0,0 +1,2 @@
1
+ export { generateTypescriptContractInterface } from './typescript.js';
2
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb250cmFjdC1pbnRlcmZhY2UtZ2VuL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxtQ0FBbUMsRUFBRSxNQUFNLGlCQUFpQixDQUFDIn0=
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contract-interface-gen/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mCAAmC,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1 @@
1
+ export { generateTypescriptContractInterface } from './typescript.js';
@@ -6,4 +6,4 @@ import { type ContractArtifact } from '@aztec/stdlib/abi';
6
6
  * @returns The corresponding ts code.
7
7
  */
8
8
  export declare function generateTypescriptContractInterface(input: ContractArtifact, artifactImportPath?: string): Promise<string>;
9
- //# sourceMappingURL=typescript.d.ts.map
9
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXNjcmlwdC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NvbnRyYWN0LWludGVyZmFjZS1nZW4vdHlwZXNjcmlwdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBR0wsS0FBSyxnQkFBZ0IsRUFhdEIsTUFBTSxtQkFBbUIsQ0FBQztBQXVSM0I7Ozs7O0dBS0c7QUFDSCx3QkFBc0IsbUNBQW1DLENBQUMsS0FBSyxFQUFFLGdCQUFnQixFQUFFLGtCQUFrQixDQUFDLEVBQUUsTUFBTSxtQkFrRDdHIn0=
@@ -1 +1 @@
1
- {"version":3,"file":"typescript.d.ts","sourceRoot":"","sources":["../../src/contract-interface-gen/typescript.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,gBAAgB,EAWtB,MAAM,mBAAmB,CAAC;AAwQ3B;;;;;GAKG;AACH,wBAAsB,mCAAmC,CAAC,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,CAAC,EAAE,MAAM,mBAkD7G"}
1
+ {"version":3,"file":"typescript.d.ts","sourceRoot":"","sources":["../../src/contract-interface-gen/typescript.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,gBAAgB,EAatB,MAAM,mBAAmB,CAAC;AAuR3B;;;;;GAKG;AACH,wBAAsB,mCAAmC,CAAC,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,CAAC,EAAE,MAAM,mBAkD7G"}
@@ -1,4 +1,4 @@
1
- import { EventSelector, decodeFunctionSignature, getAllFunctionAbis, getDefaultInitializer, isAztecAddressStruct, isBoundedVecStruct, isEthAddressStruct, isFunctionSelectorStruct, isWrappedFieldStruct } from '@aztec/stdlib/abi';
1
+ import { EventSelector, decodeFunctionSignature, getAllFunctionAbis, getDefaultInitializer, isAztecAddressStruct, isBoundedVecStruct, isEthAddressStruct, isFunctionSelectorStruct, isOptionStruct, isPublicKeysStruct, isWrappedFieldStruct } from '@aztec/stdlib/abi';
2
2
  /**
3
3
  * Returns the corresponding typescript type for a given Noir type.
4
4
  * @param type - The input Noir type.
@@ -28,11 +28,19 @@ import { EventSelector, decodeFunctionSignature, getAllFunctionAbis, getDefaultI
28
28
  if (isWrappedFieldStruct(type)) {
29
29
  return 'WrappedFieldLike';
30
30
  }
31
+ if (isPublicKeysStruct(type)) {
32
+ // PublicKeys are special cased due to them being part of the preimage of contract addresses.
33
+ // The proper type is expected by the TS code that deals with the ContractInstanceRegistry protocol contract.
34
+ return 'PublicKeys';
35
+ }
31
36
  if (isBoundedVecStruct(type)) {
32
37
  // To make BoundedVec easier to work with, we expect a simple array on the input and then we encode it
33
38
  // as a BoundedVec in the ArgumentsEncoder.
34
39
  return `${abiTypeToTypescript(type.fields[0].type)}`;
35
40
  }
41
+ if (isOptionStruct(type)) {
42
+ return `OptionLike<${abiTypeToTypescript(type.fields[1].type)}>`;
43
+ }
36
44
  return `{ ${type.fields.map((f)=>`${f.name}: ${abiTypeToTypescript(f.type)}`).join(', ')} }`;
37
45
  default:
38
46
  throw new Error(`Unknown type ${type.kind}`);
@@ -61,38 +69,46 @@ import { EventSelector, decodeFunctionSignature, getAllFunctionAbis, getDefaultI
61
69
  * @returns A type-safe deploy method in ts.
62
70
  */ function generateDeploy(input) {
63
71
  const ctor = getDefaultInitializer(input);
64
- const args = (ctor?.parameters ?? []).map(generateParameter).join(', ');
72
+ const ctorParams = ctor?.parameters ?? [];
73
+ const args = ctorParams.map(generateParameter).join(', ');
74
+ const argNames = ctorParams.map((p)=>p.name).join(', ');
75
+ const argsForwarding = argNames ? `[${argNames}]` : '[]';
65
76
  const contractName = `${input.name}Contract`;
66
77
  const artifactName = `${contractName}Artifact`;
67
78
  return `
68
79
  /**
69
80
  * Creates a tx to deploy a new instance of this contract.
81
+ * @param instantiation - Optional address-affecting parameters (salt, deployer / universalDeploy, publicKeys).
82
+ * Salt defaults to a random value; the deployer is locked lazily from the first send-time \`from\`.
70
83
  */
71
- public static deploy(wallet: Wallet, ${args}) {
72
- return new DeployMethod<${contractName}>(PublicKeys.default(), wallet, ${artifactName}, ${contractName}.at, Array.from(arguments).slice(1));
73
- }
74
-
75
- /**
76
- * Creates a tx to deploy a new instance of this contract using the specified public keys hash to derive the address.
77
- */
78
- public static deployWithPublicKeys(publicKeys: PublicKeys, wallet: Wallet, ${args}) {
79
- return new DeployMethod<${contractName}>(publicKeys, wallet, ${artifactName}, ${contractName}.at, Array.from(arguments).slice(2));
84
+ public static deploy(wallet: Wallet, ${args ? `${args}, ` : ''}instantiation?: DeployInstantiationOptions) {
85
+ return DeployMethod.create<${contractName}>(
86
+ wallet,
87
+ {
88
+ artifact: ${artifactName},
89
+ postDeployCtor: (instance, wallet) => ${contractName}.at(instance.address, wallet),
90
+ args: ${argsForwarding},
91
+ },
92
+ instantiation,
93
+ );
80
94
  }
81
95
 
82
96
  /**
83
97
  * Creates a tx to deploy a new instance of this contract using the specified constructor method.
84
98
  */
85
99
  public static deployWithOpts<M extends keyof ${contractName}['methods']>(
86
- opts: { publicKeys?: PublicKeys; method?: M; wallet: Wallet },
100
+ opts: { method?: M; wallet: Wallet; instantiation?: DeployInstantiationOptions },
87
101
  ...args: Parameters<${contractName}['methods'][M]>
88
102
  ) {
89
- return new DeployMethod<${contractName}>(
90
- opts.publicKeys ?? PublicKeys.default(),
103
+ return DeployMethod.create<${contractName}>(
91
104
  opts.wallet,
92
- ${artifactName},
93
- ${contractName}.at,
94
- Array.from(arguments).slice(1),
95
- opts.method ?? 'constructor',
105
+ {
106
+ artifact: ${artifactName},
107
+ postDeployCtor: (instance, wallet) => ${contractName}.at(instance.address, wallet),
108
+ args,
109
+ constructorNameOrArtifact: opts.method ?? 'constructor',
110
+ },
111
+ opts.instantiation,
96
112
  );
97
113
  }
98
114
  `;
@@ -101,14 +117,14 @@ import { EventSelector, decodeFunctionSignature, getAllFunctionAbis, getDefaultI
101
117
  * Generates the constructor by supplying the ABI to the parent class so the user doesn't have to.
102
118
  * @param name - Name of the contract to derive the ABI name from.
103
119
  * @returns A constructor method.
104
- * @remarks The constructor is private because we want to force the user to use the create method.
120
+ * @remarks The constructor is private because we want to force the user to use the at method.
105
121
  */ function generateConstructor(name) {
106
122
  return `
107
123
  private constructor(
108
- instance: ContractInstanceWithAddress,
124
+ address: AztecAddress,
109
125
  wallet: Wallet,
110
126
  ) {
111
- super(instance, ${name}ContractArtifact, wallet);
127
+ super(address, ${name}ContractArtifact, wallet);
112
128
  }
113
129
  `;
114
130
  }
@@ -116,20 +132,19 @@ import { EventSelector, decodeFunctionSignature, getAllFunctionAbis, getDefaultI
116
132
  * Generates the at method for this contract.
117
133
  * @param name - Name of the contract to derive the ABI name from.
118
134
  * @returns An at method.
119
- * @remarks We don't use constructor directly because of the async `wallet.getContractData` call.
120
135
  */ function generateAt(name) {
121
136
  return `
122
137
  /**
123
138
  * Creates a contract instance.
124
139
  * @param address - The deployed contract's address.
125
140
  * @param wallet - The wallet to use when interacting with the contract.
126
- * @returns A promise that resolves to a new Contract instance.
141
+ * @returns A new Contract instance.
127
142
  */
128
- public static async at(
143
+ public static at(
129
144
  address: AztecAddress,
130
145
  wallet: Wallet,
131
- ) {
132
- return Contract.at(address, ${name}Contract.artifact, wallet) as Promise<${name}Contract>;
146
+ ): ${name}Contract {
147
+ return Contract.at(address, ${name}Contract.artifact, wallet) as ${name}Contract;
133
148
  }`;
134
149
  }
135
150
  /**
@@ -233,7 +248,7 @@ async function generateEvents(events) {
233
248
  * @param artifactImportPath - Optional path to import the artifact (if not set, will be required in the constructor).
234
249
  * @returns The corresponding ts code.
235
250
  */ export async function generateTypescriptContractInterface(input, artifactImportPath) {
236
- const methods = getAllFunctionAbis(input).filter((f)=>!f.isInternal).sort((a, b)=>a.name.localeCompare(b.name)).map(generateMethod);
251
+ const methods = getAllFunctionAbis(input).filter((f)=>!f.isOnlySelf).sort((a, b)=>a.name.localeCompare(b.name)).map(generateMethod);
237
252
  const deploy = artifactImportPath && generateDeploy(input);
238
253
  const ctor = artifactImportPath && generateConstructor(input.name);
239
254
  const at = artifactImportPath && generateAt(input.name);
@@ -246,8 +261,8 @@ async function generateEvents(events) {
246
261
 
247
262
  /* eslint-disable */
248
263
  import { AztecAddress, CompleteAddress } from '@aztec/aztec.js/addresses';
249
- import { type AbiType, type AztecAddressLike, type ContractArtifact, EventSelector, decodeFromAbi, type EthAddressLike, type FieldLike, type FunctionSelectorLike, loadContractArtifact, loadContractArtifactForPublic, type NoirCompiledContract, type U128Like, type WrappedFieldLike } from '@aztec/aztec.js/abi';
250
- import { Contract, ContractBase, ContractFunctionInteraction, type ContractInstanceWithAddress, type ContractMethod, type ContractStorageLayout, DeployMethod } from '@aztec/aztec.js/contracts';
264
+ import { type AbiType, type AztecAddressLike, type ContractArtifact, EventSelector, decodeFromAbi, type EthAddressLike, type FieldLike, type FunctionSelectorLike, loadContractArtifact, loadContractArtifactForPublic, type NoirCompiledContract, type OptionLike, type U128Like, type WrappedFieldLike } from '@aztec/aztec.js/abi';
265
+ import { Contract, ContractBase, ContractFunctionInteraction, type ContractMethod, type ContractStorageLayout, type DeployInstantiationOptions, DeployMethod } from '@aztec/aztec.js/contracts';
251
266
  import { EthAddress } from '@aztec/aztec.js/addresses';
252
267
  import { Fr, Point } from '@aztec/aztec.js/fields';
253
268
  import { type PublicKey, PublicKeys } from '@aztec/aztec.js/keys';
package/dest/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import type { Command } from 'commander';
2
2
  export declare function injectCommands(program: Command): Command;
3
- //# sourceMappingURL=index.d.ts.map
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxPQUFPLEVBQUUsTUFBTSxXQUFXLENBQUM7QUFHekMsd0JBQWdCLGNBQWMsQ0FBQyxPQUFPLEVBQUUsT0FBTyxXQVk5QyJ9
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@aztec/builder",
3
- "version": "0.0.1-commit.b655e406",
3
+ "version": "0.0.1-commit.b9865e97",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js",
7
- "./cli": "./dest/bin/cli.js"
7
+ "./cli": "./dest/bin/cli.js",
8
+ "./codegen": "./dest/contract-interface-gen/index.js"
8
9
  },
9
10
  "typedocOptions": {
10
11
  "entryPoints": [
@@ -13,13 +14,10 @@
13
14
  "name": "Aztec builder",
14
15
  "tsconfig": "./tsconfig.json"
15
16
  },
16
- "bin": {
17
- "aztec-builder": "dest/bin/cli.js"
18
- },
19
17
  "scripts": {
20
- "build": "yarn clean && tsc -b",
21
- "build:dev": "tsc -b --watch",
22
- "generate": "tsc -b",
18
+ "build": "yarn clean && ../scripts/tsc.sh",
19
+ "build:dev": "../scripts/tsc.sh --watch",
20
+ "generate": "../scripts/tsc.sh",
23
21
  "clean": "rm -rf ./dest .tsbuildinfo",
24
22
  "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
25
23
  },
@@ -69,14 +67,15 @@
69
67
  ]
70
68
  },
71
69
  "dependencies": {
72
- "@aztec/foundation": "0.0.1-commit.b655e406",
73
- "@aztec/stdlib": "0.0.1-commit.b655e406",
70
+ "@aztec/foundation": "0.0.1-commit.b9865e97",
71
+ "@aztec/stdlib": "0.0.1-commit.b9865e97",
74
72
  "commander": "^12.1.0"
75
73
  },
76
74
  "devDependencies": {
77
75
  "@jest/globals": "^30.0.0",
78
76
  "@types/jest": "^30.0.0",
79
77
  "@types/node": "^22.15.17",
78
+ "@typescript/native-preview": "7.0.0-dev.20260113.1",
80
79
  "jest": "^30.0.0",
81
80
  "ts-node": "^10.9.1",
82
81
  "typescript": "^5.3.3"
@@ -50,6 +50,12 @@ async function generateFromNoirAbi(outputPath: string, noirAbiPath: string, opts
50
50
 
51
51
  const file = await readFile(noirAbiPath, 'utf8');
52
52
  const contract = JSON.parse(file);
53
+
54
+ if (!Array.isArray(contract.functions)) {
55
+ console.log(`${fileName} is not a contract artifact. Skipping.`);
56
+ return;
57
+ }
58
+
53
59
  const aztecAbi = loadContractArtifact(contract);
54
60
 
55
61
  await mkdir(outputPath, { recursive: true });
@@ -0,0 +1 @@
1
+ export { generateTypescriptContractInterface } from './typescript.js';
@@ -11,6 +11,8 @@ import {
11
11
  isBoundedVecStruct,
12
12
  isEthAddressStruct,
13
13
  isFunctionSelectorStruct,
14
+ isOptionStruct,
15
+ isPublicKeysStruct,
14
16
  isWrappedFieldStruct,
15
17
  } from '@aztec/stdlib/abi';
16
18
 
@@ -44,11 +46,19 @@ function abiTypeToTypescript(type: ABIParameter['type']): string {
44
46
  if (isWrappedFieldStruct(type)) {
45
47
  return 'WrappedFieldLike';
46
48
  }
49
+ if (isPublicKeysStruct(type)) {
50
+ // PublicKeys are special cased due to them being part of the preimage of contract addresses.
51
+ // The proper type is expected by the TS code that deals with the ContractInstanceRegistry protocol contract.
52
+ return 'PublicKeys';
53
+ }
47
54
  if (isBoundedVecStruct(type)) {
48
55
  // To make BoundedVec easier to work with, we expect a simple array on the input and then we encode it
49
56
  // as a BoundedVec in the ArgumentsEncoder.
50
57
  return `${abiTypeToTypescript(type.fields[0].type)}`;
51
58
  }
59
+ if (isOptionStruct(type)) {
60
+ return `OptionLike<${abiTypeToTypescript(type.fields[1].type)}>`;
61
+ }
52
62
  return `{ ${type.fields.map(f => `${f.name}: ${abiTypeToTypescript(f.type)}`).join(', ')} }`;
53
63
  default:
54
64
  throw new Error(`Unknown type ${type.kind}`);
@@ -83,39 +93,47 @@ function generateMethod(entry: FunctionAbi) {
83
93
  */
84
94
  function generateDeploy(input: ContractArtifact) {
85
95
  const ctor = getDefaultInitializer(input);
86
- const args = (ctor?.parameters ?? []).map(generateParameter).join(', ');
96
+ const ctorParams = ctor?.parameters ?? [];
97
+ const args = ctorParams.map(generateParameter).join(', ');
98
+ const argNames = ctorParams.map(p => p.name).join(', ');
99
+ const argsForwarding = argNames ? `[${argNames}]` : '[]';
87
100
  const contractName = `${input.name}Contract`;
88
101
  const artifactName = `${contractName}Artifact`;
89
102
 
90
103
  return `
91
104
  /**
92
105
  * Creates a tx to deploy a new instance of this contract.
106
+ * @param instantiation - Optional address-affecting parameters (salt, deployer / universalDeploy, publicKeys).
107
+ * Salt defaults to a random value; the deployer is locked lazily from the first send-time \`from\`.
93
108
  */
94
- public static deploy(wallet: Wallet, ${args}) {
95
- return new DeployMethod<${contractName}>(PublicKeys.default(), wallet, ${artifactName}, ${contractName}.at, Array.from(arguments).slice(1));
96
- }
97
-
98
- /**
99
- * Creates a tx to deploy a new instance of this contract using the specified public keys hash to derive the address.
100
- */
101
- public static deployWithPublicKeys(publicKeys: PublicKeys, wallet: Wallet, ${args}) {
102
- return new DeployMethod<${contractName}>(publicKeys, wallet, ${artifactName}, ${contractName}.at, Array.from(arguments).slice(2));
109
+ public static deploy(wallet: Wallet, ${args ? `${args}, ` : ''}instantiation?: DeployInstantiationOptions) {
110
+ return DeployMethod.create<${contractName}>(
111
+ wallet,
112
+ {
113
+ artifact: ${artifactName},
114
+ postDeployCtor: (instance, wallet) => ${contractName}.at(instance.address, wallet),
115
+ args: ${argsForwarding},
116
+ },
117
+ instantiation,
118
+ );
103
119
  }
104
120
 
105
121
  /**
106
122
  * Creates a tx to deploy a new instance of this contract using the specified constructor method.
107
123
  */
108
124
  public static deployWithOpts<M extends keyof ${contractName}['methods']>(
109
- opts: { publicKeys?: PublicKeys; method?: M; wallet: Wallet },
125
+ opts: { method?: M; wallet: Wallet; instantiation?: DeployInstantiationOptions },
110
126
  ...args: Parameters<${contractName}['methods'][M]>
111
127
  ) {
112
- return new DeployMethod<${contractName}>(
113
- opts.publicKeys ?? PublicKeys.default(),
128
+ return DeployMethod.create<${contractName}>(
114
129
  opts.wallet,
115
- ${artifactName},
116
- ${contractName}.at,
117
- Array.from(arguments).slice(1),
118
- opts.method ?? 'constructor',
130
+ {
131
+ artifact: ${artifactName},
132
+ postDeployCtor: (instance, wallet) => ${contractName}.at(instance.address, wallet),
133
+ args,
134
+ constructorNameOrArtifact: opts.method ?? 'constructor',
135
+ },
136
+ opts.instantiation,
119
137
  );
120
138
  }
121
139
  `;
@@ -125,15 +143,15 @@ function generateDeploy(input: ContractArtifact) {
125
143
  * Generates the constructor by supplying the ABI to the parent class so the user doesn't have to.
126
144
  * @param name - Name of the contract to derive the ABI name from.
127
145
  * @returns A constructor method.
128
- * @remarks The constructor is private because we want to force the user to use the create method.
146
+ * @remarks The constructor is private because we want to force the user to use the at method.
129
147
  */
130
148
  function generateConstructor(name: string) {
131
149
  return `
132
150
  private constructor(
133
- instance: ContractInstanceWithAddress,
151
+ address: AztecAddress,
134
152
  wallet: Wallet,
135
153
  ) {
136
- super(instance, ${name}ContractArtifact, wallet);
154
+ super(address, ${name}ContractArtifact, wallet);
137
155
  }
138
156
  `;
139
157
  }
@@ -142,7 +160,6 @@ function generateConstructor(name: string) {
142
160
  * Generates the at method for this contract.
143
161
  * @param name - Name of the contract to derive the ABI name from.
144
162
  * @returns An at method.
145
- * @remarks We don't use constructor directly because of the async `wallet.getContractData` call.
146
163
  */
147
164
  function generateAt(name: string) {
148
165
  return `
@@ -150,13 +167,13 @@ function generateAt(name: string) {
150
167
  * Creates a contract instance.
151
168
  * @param address - The deployed contract's address.
152
169
  * @param wallet - The wallet to use when interacting with the contract.
153
- * @returns A promise that resolves to a new Contract instance.
170
+ * @returns A new Contract instance.
154
171
  */
155
- public static async at(
172
+ public static at(
156
173
  address: AztecAddress,
157
174
  wallet: Wallet,
158
- ) {
159
- return Contract.at(address, ${name}Contract.artifact, wallet) as Promise<${name}Contract>;
175
+ ): ${name}Contract {
176
+ return Contract.at(address, ${name}Contract.artifact, wallet) as ${name}Contract;
160
177
  }`;
161
178
  }
162
179
 
@@ -284,7 +301,7 @@ async function generateEvents(events: any[] | undefined) {
284
301
  */
285
302
  export async function generateTypescriptContractInterface(input: ContractArtifact, artifactImportPath?: string) {
286
303
  const methods = getAllFunctionAbis(input)
287
- .filter(f => !f.isInternal)
304
+ .filter(f => !f.isOnlySelf)
288
305
  .sort((a, b) => a.name.localeCompare(b.name))
289
306
  .map(generateMethod);
290
307
  const deploy = artifactImportPath && generateDeploy(input);
@@ -300,8 +317,8 @@ export async function generateTypescriptContractInterface(input: ContractArtifac
300
317
 
301
318
  /* eslint-disable */
302
319
  import { AztecAddress, CompleteAddress } from '@aztec/aztec.js/addresses';
303
- import { type AbiType, type AztecAddressLike, type ContractArtifact, EventSelector, decodeFromAbi, type EthAddressLike, type FieldLike, type FunctionSelectorLike, loadContractArtifact, loadContractArtifactForPublic, type NoirCompiledContract, type U128Like, type WrappedFieldLike } from '@aztec/aztec.js/abi';
304
- import { Contract, ContractBase, ContractFunctionInteraction, type ContractInstanceWithAddress, type ContractMethod, type ContractStorageLayout, DeployMethod } from '@aztec/aztec.js/contracts';
320
+ import { type AbiType, type AztecAddressLike, type ContractArtifact, EventSelector, decodeFromAbi, type EthAddressLike, type FieldLike, type FunctionSelectorLike, loadContractArtifact, loadContractArtifactForPublic, type NoirCompiledContract, type OptionLike, type U128Like, type WrappedFieldLike } from '@aztec/aztec.js/abi';
321
+ import { Contract, ContractBase, ContractFunctionInteraction, type ContractMethod, type ContractStorageLayout, type DeployInstantiationOptions, DeployMethod } from '@aztec/aztec.js/contracts';
305
322
  import { EthAddress } from '@aztec/aztec.js/addresses';
306
323
  import { Fr, Point } from '@aztec/aztec.js/fields';
307
324
  import { type PublicKey, PublicKeys } from '@aztec/aztec.js/keys';