@aztec/builder 0.0.0-test.1 → 0.0.1-commit.0b941701

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=
@@ -6,4 +6,4 @@ export type GenerateCodeOptions = {
6
6
  * Generates Noir interface or Typescript interface for a folder or single file from a Noir compilation artifact.
7
7
  */
8
8
  export declare function generateCode(outputPath: string, fileOrDirPath: string, opts?: GenerateCodeOptions): Promise<string[]>;
9
- //# sourceMappingURL=codegen.d.ts.map
9
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29kZWdlbi5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NvbnRyYWN0LWludGVyZmFjZS1nZW4vY29kZWdlbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFZQSw0QkFBNEI7QUFDNUIsTUFBTSxNQUFNLG1CQUFtQixHQUFHO0lBQUUsS0FBSyxDQUFDLEVBQUUsT0FBTyxDQUFBO0NBQUUsQ0FBQztBQUV0RDs7R0FFRztBQUNILHdCQUFzQixZQUFZLENBQUMsVUFBVSxFQUFFLE1BQU0sRUFBRSxhQUFhLEVBQUUsTUFBTSxFQUFFLElBQUksR0FBRSxtQkFBd0IscUJBa0IzRyJ9
@@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXNjcmlwdC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NvbnRyYWN0LWludGVyZmFjZS1nZW4vdHlwZXNjcmlwdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBR0wsS0FBSyxnQkFBZ0IsRUFZdEIsTUFBTSxtQkFBbUIsQ0FBQztBQTRRM0I7Ozs7O0dBS0c7QUFDSCx3QkFBc0IsbUNBQW1DLENBQUMsS0FBSyxFQUFFLGdCQUFnQixFQUFFLGtCQUFrQixDQUFDLEVBQUUsTUFBTSxtQkFrRDdHIn0=
@@ -1 +1 @@
1
- {"version":3,"file":"typescript.d.ts","sourceRoot":"","sources":["../../src/contract-interface-gen/typescript.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,gBAAgB,EAStB,MAAM,mBAAmB,CAAC;AAyR3B;;;;;GAKG;AACH,wBAAsB,mCAAmC,CAAC,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,CAAC,EAAE,MAAM,mBA8E7G"}
1
+ {"version":3,"file":"typescript.d.ts","sourceRoot":"","sources":["../../src/contract-interface-gen/typescript.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,gBAAgB,EAYtB,MAAM,mBAAmB,CAAC;AA4Q3B;;;;;GAKG;AACH,wBAAsB,mCAAmC,CAAC,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,CAAC,EAAE,MAAM,mBAkD7G"}
@@ -1,4 +1,4 @@
1
- import { EventSelector, decodeFunctionSignature, getDefaultInitializer, isAztecAddressStruct, isEthAddressStruct, isFunctionSelectorStruct, isWrappedFieldStruct } from '@aztec/stdlib/abi';
1
+ import { EventSelector, decodeFunctionSignature, getAllFunctionAbis, getDefaultInitializer, isAztecAddressStruct, isBoundedVecStruct, isEthAddressStruct, isFunctionSelectorStruct, 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,9 +28,19 @@ import { EventSelector, decodeFunctionSignature, getDefaultInitializer, isAztecA
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
+ }
36
+ if (isBoundedVecStruct(type)) {
37
+ // To make BoundedVec easier to work with, we expect a simple array on the input and then we encode it
38
+ // as a BoundedVec in the ArgumentsEncoder.
39
+ return `${abiTypeToTypescript(type.fields[0].type)}`;
40
+ }
31
41
  return `{ ${type.fields.map((f)=>`${f.name}: ${abiTypeToTypescript(f.type)}`).join(', ')} }`;
32
42
  default:
33
- throw new Error(`Unknown type ${type}`);
43
+ throw new Error(`Unknown type ${type.kind}`);
34
44
  }
35
45
  }
36
46
  /**
@@ -64,14 +74,14 @@ import { EventSelector, decodeFunctionSignature, getDefaultInitializer, isAztecA
64
74
  * Creates a tx to deploy a new instance of this contract.
65
75
  */
66
76
  public static deploy(wallet: Wallet, ${args}) {
67
- return new DeployMethod<${contractName}>(PublicKeys.default(), wallet, ${artifactName}, ${contractName}.at, Array.from(arguments).slice(1));
77
+ return new DeployMethod<${contractName}>(PublicKeys.default(), wallet, ${artifactName}, (instance, wallet) => ${contractName}.at(instance.address, wallet), Array.from(arguments).slice(1));
68
78
  }
69
79
 
70
80
  /**
71
81
  * Creates a tx to deploy a new instance of this contract using the specified public keys hash to derive the address.
72
82
  */
73
83
  public static deployWithPublicKeys(publicKeys: PublicKeys, wallet: Wallet, ${args}) {
74
- return new DeployMethod<${contractName}>(publicKeys, wallet, ${artifactName}, ${contractName}.at, Array.from(arguments).slice(2));
84
+ return new DeployMethod<${contractName}>(publicKeys, wallet, ${artifactName}, (instance, wallet) => ${contractName}.at(instance.address, wallet), Array.from(arguments).slice(2));
75
85
  }
76
86
 
77
87
  /**
@@ -85,7 +95,7 @@ import { EventSelector, decodeFunctionSignature, getDefaultInitializer, isAztecA
85
95
  opts.publicKeys ?? PublicKeys.default(),
86
96
  opts.wallet,
87
97
  ${artifactName},
88
- ${contractName}.at,
98
+ (instance, wallet) => ${contractName}.at(instance.address, wallet),
89
99
  Array.from(arguments).slice(1),
90
100
  opts.method ?? 'constructor',
91
101
  );
@@ -96,14 +106,14 @@ import { EventSelector, decodeFunctionSignature, getDefaultInitializer, isAztecA
96
106
  * Generates the constructor by supplying the ABI to the parent class so the user doesn't have to.
97
107
  * @param name - Name of the contract to derive the ABI name from.
98
108
  * @returns A constructor method.
99
- * @remarks The constructor is private because we want to force the user to use the create method.
109
+ * @remarks The constructor is private because we want to force the user to use the at method.
100
110
  */ function generateConstructor(name) {
101
111
  return `
102
112
  private constructor(
103
- instance: ContractInstanceWithAddress,
113
+ address: AztecAddress,
104
114
  wallet: Wallet,
105
115
  ) {
106
- super(instance, ${name}ContractArtifact, wallet);
116
+ super(address, ${name}ContractArtifact, wallet);
107
117
  }
108
118
  `;
109
119
  }
@@ -111,26 +121,25 @@ import { EventSelector, decodeFunctionSignature, getDefaultInitializer, isAztecA
111
121
  * Generates the at method for this contract.
112
122
  * @param name - Name of the contract to derive the ABI name from.
113
123
  * @returns An at method.
114
- * @remarks We don't use constructor directly because of the async `wallet.getContractData` call.
115
124
  */ function generateAt(name) {
116
125
  return `
117
126
  /**
118
127
  * Creates a contract instance.
119
128
  * @param address - The deployed contract's address.
120
129
  * @param wallet - The wallet to use when interacting with the contract.
121
- * @returns A promise that resolves to a new Contract instance.
130
+ * @returns A new Contract instance.
122
131
  */
123
- public static async at(
132
+ public static at(
124
133
  address: AztecAddress,
125
134
  wallet: Wallet,
126
- ) {
127
- return Contract.at(address, ${name}Contract.artifact, wallet) as Promise<${name}Contract>;
135
+ ): ${name}Contract {
136
+ return Contract.at(address, ${name}Contract.artifact, wallet) as ${name}Contract;
128
137
  }`;
129
138
  }
130
139
  /**
131
- * Generates a static getter for the contract's artifact.
140
+ * Generates static getters for the contract's artifact.
132
141
  * @param name - Name of the contract used to derive name of the artifact import.
133
- */ function generateArtifactGetter(name) {
142
+ */ function generateArtifactGetters(name) {
134
143
  const artifactName = `${name}ContractArtifact`;
135
144
  return `
136
145
  /**
@@ -139,6 +148,13 @@ import { EventSelector, decodeFunctionSignature, getDefaultInitializer, isAztecA
139
148
  public static get artifact(): ContractArtifact {
140
149
  return ${artifactName};
141
150
  }
151
+
152
+ /**
153
+ * Returns this contract's artifact with public bytecode.
154
+ */
155
+ public static get artifactForPublic(): ContractArtifact {
156
+ return loadContractArtifactForPublic(${artifactName}Json as NoirCompiledContract);
157
+ }
142
158
  `;
143
159
  }
144
160
  /**
@@ -148,7 +164,7 @@ import { EventSelector, decodeFunctionSignature, getDefaultInitializer, isAztecA
148
164
  * @returns Code.
149
165
  */ function generateAbiStatement(name, artifactImportPath) {
150
166
  const stmts = [
151
- `import ${name}ContractArtifactJson from '${artifactImportPath}' assert { type: 'json' };`,
167
+ `import ${name}ContractArtifactJson from '${artifactImportPath}' with { type: 'json' };`,
152
168
  `export const ${name}ContractArtifact = loadContractArtifact(${name}ContractArtifactJson as NoirCompiledContract);`
153
169
  ];
154
170
  return stmts.join('\n');
@@ -172,25 +188,6 @@ import { EventSelector, decodeFunctionSignature, getDefaultInitializer, isAztecA
172
188
  }
173
189
  `;
174
190
  }
175
- /**
176
- * Generates a getter for the contract notes
177
- * @param input - The contract artifact.
178
- */ function generateNotesGetter(input) {
179
- const entries = Object.entries(input.notes);
180
- if (entries.length === 0) {
181
- return '';
182
- }
183
- const notesUnionType = entries.map(([name])=>`'${name}'`).join(' | ');
184
- const noteMetadata = entries.map(([name, { id }])=>`${name}: {
185
- id: new NoteSelector(${id.value}),
186
- }`).join(',\n');
187
- return `public static get notes(): ContractNotes<${notesUnionType}> {
188
- return {
189
- ${noteMetadata}
190
- } as ContractNotes<${notesUnionType}>;
191
- }
192
- `;
193
- }
194
191
  // events is of type AbiType
195
192
  async function generateEvents(events) {
196
193
  if (events === undefined) {
@@ -240,51 +237,25 @@ async function generateEvents(events) {
240
237
  * @param artifactImportPath - Optional path to import the artifact (if not set, will be required in the constructor).
241
238
  * @returns The corresponding ts code.
242
239
  */ export async function generateTypescriptContractInterface(input, artifactImportPath) {
243
- const methods = input.functions.filter((f)=>!f.isInternal).sort((a, b)=>a.name.localeCompare(b.name)).map(generateMethod);
240
+ const methods = getAllFunctionAbis(input).filter((f)=>!f.isOnlySelf).sort((a, b)=>a.name.localeCompare(b.name)).map(generateMethod);
244
241
  const deploy = artifactImportPath && generateDeploy(input);
245
242
  const ctor = artifactImportPath && generateConstructor(input.name);
246
243
  const at = artifactImportPath && generateAt(input.name);
247
244
  const artifactStatement = artifactImportPath && generateAbiStatement(input.name, artifactImportPath);
248
- const artifactGetter = artifactImportPath && generateArtifactGetter(input.name);
245
+ const artifactGetter = artifactImportPath && generateArtifactGetters(input.name);
249
246
  const storageLayoutGetter = artifactImportPath && generateStorageLayoutGetter(input);
250
- const notesGetter = artifactImportPath && generateNotesGetter(input);
251
247
  const { eventDefs, events } = await generateEvents(input.outputs.structs?.events);
252
248
  return `
253
249
  /* Autogenerated file, do not edit! */
254
250
 
255
251
  /* eslint-disable */
256
- import {
257
- type AbiType,
258
- AztecAddress,
259
- type AztecAddressLike,
260
- CompleteAddress,
261
- Contract,
262
- type ContractArtifact,
263
- ContractBase,
264
- ContractFunctionInteraction,
265
- type ContractInstanceWithAddress,
266
- type ContractMethod,
267
- type ContractStorageLayout,
268
- type ContractNotes,
269
- decodeFromAbi,
270
- DeployMethod,
271
- EthAddress,
272
- type EthAddressLike,
273
- EventSelector,
274
- type FieldLike,
275
- Fr,
276
- type FunctionSelectorLike,
277
- L1EventPayload,
278
- loadContractArtifact,
279
- type NoirCompiledContract,
280
- NoteSelector,
281
- Point,
282
- type PublicKey,
283
- PublicKeys,
284
- type Wallet,
285
- type U128Like,
286
- type WrappedFieldLike,
287
- } from '@aztec/aztec.js';
252
+ import { AztecAddress, CompleteAddress } from '@aztec/aztec.js/addresses';
253
+ 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';
254
+ import { Contract, ContractBase, ContractFunctionInteraction, type ContractMethod, type ContractStorageLayout, DeployMethod } from '@aztec/aztec.js/contracts';
255
+ import { EthAddress } from '@aztec/aztec.js/addresses';
256
+ import { Fr, Point } from '@aztec/aztec.js/fields';
257
+ import { type PublicKey, PublicKeys } from '@aztec/aztec.js/keys';
258
+ import type { Wallet } from '@aztec/aztec.js/wallet';
288
259
  ${artifactStatement}
289
260
 
290
261
  ${eventDefs}
@@ -303,8 +274,6 @@ export class ${input.name}Contract extends ContractBase {
303
274
 
304
275
  ${storageLayoutGetter}
305
276
 
306
- ${notesGetter}
307
-
308
277
  /** Type-safe wrappers for the public methods exposed by the contract. */
309
278
  public declare methods: {
310
279
  ${methods.join('\n')}
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.0-test.1",
3
+ "version": "0.0.1-commit.0b941701",
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,16 +14,11 @@
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
- "formatting": "run -T prettier --check ./src && run -T eslint ./src",
25
- "formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src",
26
22
  "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
27
23
  },
28
24
  "inherits": [
@@ -64,20 +60,25 @@
64
60
  "testTimeout": 120000,
65
61
  "setupFiles": [
66
62
  "../../foundation/src/jest/setup.mjs"
63
+ ],
64
+ "testEnvironment": "../../foundation/src/jest/env.mjs",
65
+ "setupFilesAfterEnv": [
66
+ "../../foundation/src/jest/setupAfterEnv.mjs"
67
67
  ]
68
68
  },
69
69
  "dependencies": {
70
- "@aztec/foundation": "0.0.0-test.1",
71
- "@aztec/stdlib": "0.0.0-test.1",
70
+ "@aztec/foundation": "0.0.1-commit.0b941701",
71
+ "@aztec/stdlib": "0.0.1-commit.0b941701",
72
72
  "commander": "^12.1.0"
73
73
  },
74
74
  "devDependencies": {
75
- "@jest/globals": "^29.5.0",
76
- "@types/jest": "^29.5.0",
77
- "@types/node": "^18.7.23",
78
- "jest": "^29.5.0",
75
+ "@jest/globals": "^30.0.0",
76
+ "@types/jest": "^30.0.0",
77
+ "@types/node": "^22.15.17",
78
+ "@typescript/native-preview": "7.0.0-dev.20260113.1",
79
+ "jest": "^30.0.0",
79
80
  "ts-node": "^10.9.1",
80
- "typescript": "^5.0.4"
81
+ "typescript": "^5.3.3"
81
82
  },
82
83
  "files": [
83
84
  "dest",
@@ -86,6 +87,6 @@
86
87
  ],
87
88
  "types": "./dest/index.d.ts",
88
89
  "engines": {
89
- "node": ">=18"
90
+ "node": ">=20.10"
90
91
  }
91
92
  }
@@ -0,0 +1 @@
1
+ export { generateTypescriptContractInterface } from './typescript.js';
@@ -3,12 +3,15 @@ import {
3
3
  type ABIVariable,
4
4
  type ContractArtifact,
5
5
  EventSelector,
6
- type FunctionArtifact,
6
+ type FunctionAbi,
7
7
  decodeFunctionSignature,
8
+ getAllFunctionAbis,
8
9
  getDefaultInitializer,
9
10
  isAztecAddressStruct,
11
+ isBoundedVecStruct,
10
12
  isEthAddressStruct,
11
13
  isFunctionSelectorStruct,
14
+ isPublicKeysStruct,
12
15
  isWrappedFieldStruct,
13
16
  } from '@aztec/stdlib/abi';
14
17
 
@@ -42,9 +45,19 @@ function abiTypeToTypescript(type: ABIParameter['type']): string {
42
45
  if (isWrappedFieldStruct(type)) {
43
46
  return 'WrappedFieldLike';
44
47
  }
48
+ if (isPublicKeysStruct(type)) {
49
+ // PublicKeys are special cased due to them being part of the preimage of contract addresses.
50
+ // The proper type is expected by the TS code that deals with the ContractInstanceRegistry protocol contract.
51
+ return 'PublicKeys';
52
+ }
53
+ if (isBoundedVecStruct(type)) {
54
+ // To make BoundedVec easier to work with, we expect a simple array on the input and then we encode it
55
+ // as a BoundedVec in the ArgumentsEncoder.
56
+ return `${abiTypeToTypescript(type.fields[0].type)}`;
57
+ }
45
58
  return `{ ${type.fields.map(f => `${f.name}: ${abiTypeToTypescript(f.type)}`).join(', ')} }`;
46
59
  default:
47
- throw new Error(`Unknown type ${type}`);
60
+ throw new Error(`Unknown type ${type.kind}`);
48
61
  }
49
62
  }
50
63
 
@@ -62,7 +75,7 @@ function generateParameter(param: ABIParameter) {
62
75
  * @param param - A Noir function.
63
76
  * @returns The corresponding ts code.
64
77
  */
65
- function generateMethod(entry: FunctionArtifact) {
78
+ function generateMethod(entry: FunctionAbi) {
66
79
  const args = entry.parameters.map(generateParameter).join(', ');
67
80
  return `
68
81
  /** ${entry.name}(${entry.parameters.map(p => `${p.name}: ${p.type.kind}`).join(', ')}) */
@@ -85,14 +98,14 @@ function generateDeploy(input: ContractArtifact) {
85
98
  * Creates a tx to deploy a new instance of this contract.
86
99
  */
87
100
  public static deploy(wallet: Wallet, ${args}) {
88
- return new DeployMethod<${contractName}>(PublicKeys.default(), wallet, ${artifactName}, ${contractName}.at, Array.from(arguments).slice(1));
101
+ return new DeployMethod<${contractName}>(PublicKeys.default(), wallet, ${artifactName}, (instance, wallet) => ${contractName}.at(instance.address, wallet), Array.from(arguments).slice(1));
89
102
  }
90
103
 
91
104
  /**
92
105
  * Creates a tx to deploy a new instance of this contract using the specified public keys hash to derive the address.
93
106
  */
94
107
  public static deployWithPublicKeys(publicKeys: PublicKeys, wallet: Wallet, ${args}) {
95
- return new DeployMethod<${contractName}>(publicKeys, wallet, ${artifactName}, ${contractName}.at, Array.from(arguments).slice(2));
108
+ return new DeployMethod<${contractName}>(publicKeys, wallet, ${artifactName}, (instance, wallet) => ${contractName}.at(instance.address, wallet), Array.from(arguments).slice(2));
96
109
  }
97
110
 
98
111
  /**
@@ -106,7 +119,7 @@ function generateDeploy(input: ContractArtifact) {
106
119
  opts.publicKeys ?? PublicKeys.default(),
107
120
  opts.wallet,
108
121
  ${artifactName},
109
- ${contractName}.at,
122
+ (instance, wallet) => ${contractName}.at(instance.address, wallet),
110
123
  Array.from(arguments).slice(1),
111
124
  opts.method ?? 'constructor',
112
125
  );
@@ -118,15 +131,15 @@ function generateDeploy(input: ContractArtifact) {
118
131
  * Generates the constructor by supplying the ABI to the parent class so the user doesn't have to.
119
132
  * @param name - Name of the contract to derive the ABI name from.
120
133
  * @returns A constructor method.
121
- * @remarks The constructor is private because we want to force the user to use the create method.
134
+ * @remarks The constructor is private because we want to force the user to use the at method.
122
135
  */
123
136
  function generateConstructor(name: string) {
124
137
  return `
125
138
  private constructor(
126
- instance: ContractInstanceWithAddress,
139
+ address: AztecAddress,
127
140
  wallet: Wallet,
128
141
  ) {
129
- super(instance, ${name}ContractArtifact, wallet);
142
+ super(address, ${name}ContractArtifact, wallet);
130
143
  }
131
144
  `;
132
145
  }
@@ -135,7 +148,6 @@ function generateConstructor(name: string) {
135
148
  * Generates the at method for this contract.
136
149
  * @param name - Name of the contract to derive the ABI name from.
137
150
  * @returns An at method.
138
- * @remarks We don't use constructor directly because of the async `wallet.getContractData` call.
139
151
  */
140
152
  function generateAt(name: string) {
141
153
  return `
@@ -143,21 +155,21 @@ function generateAt(name: string) {
143
155
  * Creates a contract instance.
144
156
  * @param address - The deployed contract's address.
145
157
  * @param wallet - The wallet to use when interacting with the contract.
146
- * @returns A promise that resolves to a new Contract instance.
158
+ * @returns A new Contract instance.
147
159
  */
148
- public static async at(
160
+ public static at(
149
161
  address: AztecAddress,
150
162
  wallet: Wallet,
151
- ) {
152
- return Contract.at(address, ${name}Contract.artifact, wallet) as Promise<${name}Contract>;
163
+ ): ${name}Contract {
164
+ return Contract.at(address, ${name}Contract.artifact, wallet) as ${name}Contract;
153
165
  }`;
154
166
  }
155
167
 
156
168
  /**
157
- * Generates a static getter for the contract's artifact.
169
+ * Generates static getters for the contract's artifact.
158
170
  * @param name - Name of the contract used to derive name of the artifact import.
159
171
  */
160
- function generateArtifactGetter(name: string) {
172
+ function generateArtifactGetters(name: string) {
161
173
  const artifactName = `${name}ContractArtifact`;
162
174
  return `
163
175
  /**
@@ -166,6 +178,13 @@ function generateArtifactGetter(name: string) {
166
178
  public static get artifact(): ContractArtifact {
167
179
  return ${artifactName};
168
180
  }
181
+
182
+ /**
183
+ * Returns this contract's artifact with public bytecode.
184
+ */
185
+ public static get artifactForPublic(): ContractArtifact {
186
+ return loadContractArtifactForPublic(${artifactName}Json as NoirCompiledContract);
187
+ }
169
188
  `;
170
189
  }
171
190
 
@@ -177,7 +196,7 @@ function generateArtifactGetter(name: string) {
177
196
  */
178
197
  function generateAbiStatement(name: string, artifactImportPath: string) {
179
198
  const stmts = [
180
- `import ${name}ContractArtifactJson from '${artifactImportPath}' assert { type: 'json' };`,
199
+ `import ${name}ContractArtifactJson from '${artifactImportPath}' with { type: 'json' };`,
181
200
  `export const ${name}ContractArtifact = loadContractArtifact(${name}ContractArtifactJson as NoirCompiledContract);`,
182
201
  ];
183
202
  return stmts.join('\n');
@@ -212,35 +231,6 @@ function generateStorageLayoutGetter(input: ContractArtifact) {
212
231
  `;
213
232
  }
214
233
 
215
- /**
216
- * Generates a getter for the contract notes
217
- * @param input - The contract artifact.
218
- */
219
- function generateNotesGetter(input: ContractArtifact) {
220
- const entries = Object.entries(input.notes);
221
-
222
- if (entries.length === 0) {
223
- return '';
224
- }
225
-
226
- const notesUnionType = entries.map(([name]) => `'${name}'`).join(' | ');
227
- const noteMetadata = entries
228
- .map(
229
- ([name, { id }]) =>
230
- `${name}: {
231
- id: new NoteSelector(${id.value}),
232
- }`,
233
- )
234
- .join(',\n');
235
-
236
- return `public static get notes(): ContractNotes<${notesUnionType}> {
237
- return {
238
- ${noteMetadata}
239
- } as ContractNotes<${notesUnionType}>;
240
- }
241
- `;
242
- }
243
-
244
234
  // events is of type AbiType
245
235
  async function generateEvents(events: any[] | undefined) {
246
236
  if (events === undefined) {
@@ -298,55 +288,29 @@ async function generateEvents(events: any[] | undefined) {
298
288
  * @returns The corresponding ts code.
299
289
  */
300
290
  export async function generateTypescriptContractInterface(input: ContractArtifact, artifactImportPath?: string) {
301
- const methods = input.functions
302
- .filter(f => !f.isInternal)
291
+ const methods = getAllFunctionAbis(input)
292
+ .filter(f => !f.isOnlySelf)
303
293
  .sort((a, b) => a.name.localeCompare(b.name))
304
294
  .map(generateMethod);
305
295
  const deploy = artifactImportPath && generateDeploy(input);
306
296
  const ctor = artifactImportPath && generateConstructor(input.name);
307
297
  const at = artifactImportPath && generateAt(input.name);
308
298
  const artifactStatement = artifactImportPath && generateAbiStatement(input.name, artifactImportPath);
309
- const artifactGetter = artifactImportPath && generateArtifactGetter(input.name);
299
+ const artifactGetter = artifactImportPath && generateArtifactGetters(input.name);
310
300
  const storageLayoutGetter = artifactImportPath && generateStorageLayoutGetter(input);
311
- const notesGetter = artifactImportPath && generateNotesGetter(input);
312
301
  const { eventDefs, events } = await generateEvents(input.outputs.structs?.events);
313
302
 
314
303
  return `
315
304
  /* Autogenerated file, do not edit! */
316
305
 
317
306
  /* eslint-disable */
318
- import {
319
- type AbiType,
320
- AztecAddress,
321
- type AztecAddressLike,
322
- CompleteAddress,
323
- Contract,
324
- type ContractArtifact,
325
- ContractBase,
326
- ContractFunctionInteraction,
327
- type ContractInstanceWithAddress,
328
- type ContractMethod,
329
- type ContractStorageLayout,
330
- type ContractNotes,
331
- decodeFromAbi,
332
- DeployMethod,
333
- EthAddress,
334
- type EthAddressLike,
335
- EventSelector,
336
- type FieldLike,
337
- Fr,
338
- type FunctionSelectorLike,
339
- L1EventPayload,
340
- loadContractArtifact,
341
- type NoirCompiledContract,
342
- NoteSelector,
343
- Point,
344
- type PublicKey,
345
- PublicKeys,
346
- type Wallet,
347
- type U128Like,
348
- type WrappedFieldLike,
349
- } from '@aztec/aztec.js';
307
+ import { AztecAddress, CompleteAddress } from '@aztec/aztec.js/addresses';
308
+ 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';
309
+ import { Contract, ContractBase, ContractFunctionInteraction, type ContractMethod, type ContractStorageLayout, DeployMethod } from '@aztec/aztec.js/contracts';
310
+ import { EthAddress } from '@aztec/aztec.js/addresses';
311
+ import { Fr, Point } from '@aztec/aztec.js/fields';
312
+ import { type PublicKey, PublicKeys } from '@aztec/aztec.js/keys';
313
+ import type { Wallet } from '@aztec/aztec.js/wallet';
350
314
  ${artifactStatement}
351
315
 
352
316
  ${eventDefs}
@@ -365,8 +329,6 @@ export class ${input.name}Contract extends ContractBase {
365
329
 
366
330
  ${storageLayoutGetter}
367
331
 
368
- ${notesGetter}
369
-
370
332
  /** Type-safe wrappers for the public methods exposed by the contract. */
371
333
  public declare methods: {
372
334
  ${methods.join('\n')}