@aztec/builder 0.79.0 → 0.80.0
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.d.ts","sourceRoot":"","sources":["../../src/contract-interface-gen/typescript.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,gBAAgB,
|
|
1
|
+
{"version":3,"file":"typescript.d.ts","sourceRoot":"","sources":["../../src/contract-interface-gen/typescript.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,gBAAgB,EAUtB,MAAM,mBAAmB,CAAC;AAgS3B;;;;;GAKG;AACH,wBAAsB,mCAAmC,CAAC,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,CAAC,EAAE,MAAM,mBA+E7G"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EventSelector, decodeFunctionSignature, getDefaultInitializer, isAztecAddressStruct, isEthAddressStruct, isFunctionSelectorStruct, isWrappedFieldStruct } from '@aztec/stdlib/abi';
|
|
1
|
+
import { EventSelector, decodeFunctionSignature, getAllFunctionAbis, getDefaultInitializer, isAztecAddressStruct, isEthAddressStruct, isFunctionSelectorStruct, 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.
|
|
@@ -128,9 +128,9 @@ import { EventSelector, decodeFunctionSignature, getDefaultInitializer, isAztecA
|
|
|
128
128
|
}`;
|
|
129
129
|
}
|
|
130
130
|
/**
|
|
131
|
-
* Generates
|
|
131
|
+
* Generates static getters for the contract's artifact.
|
|
132
132
|
* @param name - Name of the contract used to derive name of the artifact import.
|
|
133
|
-
*/ function
|
|
133
|
+
*/ function generateArtifactGetters(name) {
|
|
134
134
|
const artifactName = `${name}ContractArtifact`;
|
|
135
135
|
return `
|
|
136
136
|
/**
|
|
@@ -139,6 +139,13 @@ import { EventSelector, decodeFunctionSignature, getDefaultInitializer, isAztecA
|
|
|
139
139
|
public static get artifact(): ContractArtifact {
|
|
140
140
|
return ${artifactName};
|
|
141
141
|
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Returns this contract's artifact with public bytecode.
|
|
145
|
+
*/
|
|
146
|
+
public static get artifactForPublic(): ContractArtifact {
|
|
147
|
+
return loadContractArtifactForPublic(${artifactName}Json as NoirCompiledContract);
|
|
148
|
+
}
|
|
142
149
|
`;
|
|
143
150
|
}
|
|
144
151
|
/**
|
|
@@ -240,12 +247,12 @@ async function generateEvents(events) {
|
|
|
240
247
|
* @param artifactImportPath - Optional path to import the artifact (if not set, will be required in the constructor).
|
|
241
248
|
* @returns The corresponding ts code.
|
|
242
249
|
*/ export async function generateTypescriptContractInterface(input, artifactImportPath) {
|
|
243
|
-
const methods = input.
|
|
250
|
+
const methods = getAllFunctionAbis(input).filter((f)=>!f.isInternal).sort((a, b)=>a.name.localeCompare(b.name)).map(generateMethod);
|
|
244
251
|
const deploy = artifactImportPath && generateDeploy(input);
|
|
245
252
|
const ctor = artifactImportPath && generateConstructor(input.name);
|
|
246
253
|
const at = artifactImportPath && generateAt(input.name);
|
|
247
254
|
const artifactStatement = artifactImportPath && generateAbiStatement(input.name, artifactImportPath);
|
|
248
|
-
const artifactGetter = artifactImportPath &&
|
|
255
|
+
const artifactGetter = artifactImportPath && generateArtifactGetters(input.name);
|
|
249
256
|
const storageLayoutGetter = artifactImportPath && generateStorageLayoutGetter(input);
|
|
250
257
|
const notesGetter = artifactImportPath && generateNotesGetter(input);
|
|
251
258
|
const { eventDefs, events } = await generateEvents(input.outputs.structs?.events);
|
|
@@ -276,6 +283,7 @@ import {
|
|
|
276
283
|
type FunctionSelectorLike,
|
|
277
284
|
L1EventPayload,
|
|
278
285
|
loadContractArtifact,
|
|
286
|
+
loadContractArtifactForPublic,
|
|
279
287
|
type NoirCompiledContract,
|
|
280
288
|
NoteSelector,
|
|
281
289
|
Point,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/builder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.80.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -67,8 +67,8 @@
|
|
|
67
67
|
]
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@aztec/foundation": "0.
|
|
71
|
-
"@aztec/stdlib": "0.
|
|
70
|
+
"@aztec/foundation": "0.80.0",
|
|
71
|
+
"@aztec/stdlib": "0.80.0",
|
|
72
72
|
"commander": "^12.1.0"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
@@ -3,8 +3,9 @@ import {
|
|
|
3
3
|
type ABIVariable,
|
|
4
4
|
type ContractArtifact,
|
|
5
5
|
EventSelector,
|
|
6
|
-
type
|
|
6
|
+
type FunctionAbi,
|
|
7
7
|
decodeFunctionSignature,
|
|
8
|
+
getAllFunctionAbis,
|
|
8
9
|
getDefaultInitializer,
|
|
9
10
|
isAztecAddressStruct,
|
|
10
11
|
isEthAddressStruct,
|
|
@@ -62,7 +63,7 @@ function generateParameter(param: ABIParameter) {
|
|
|
62
63
|
* @param param - A Noir function.
|
|
63
64
|
* @returns The corresponding ts code.
|
|
64
65
|
*/
|
|
65
|
-
function generateMethod(entry:
|
|
66
|
+
function generateMethod(entry: FunctionAbi) {
|
|
66
67
|
const args = entry.parameters.map(generateParameter).join(', ');
|
|
67
68
|
return `
|
|
68
69
|
/** ${entry.name}(${entry.parameters.map(p => `${p.name}: ${p.type.kind}`).join(', ')}) */
|
|
@@ -154,10 +155,10 @@ function generateAt(name: string) {
|
|
|
154
155
|
}
|
|
155
156
|
|
|
156
157
|
/**
|
|
157
|
-
* Generates
|
|
158
|
+
* Generates static getters for the contract's artifact.
|
|
158
159
|
* @param name - Name of the contract used to derive name of the artifact import.
|
|
159
160
|
*/
|
|
160
|
-
function
|
|
161
|
+
function generateArtifactGetters(name: string) {
|
|
161
162
|
const artifactName = `${name}ContractArtifact`;
|
|
162
163
|
return `
|
|
163
164
|
/**
|
|
@@ -166,6 +167,13 @@ function generateArtifactGetter(name: string) {
|
|
|
166
167
|
public static get artifact(): ContractArtifact {
|
|
167
168
|
return ${artifactName};
|
|
168
169
|
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Returns this contract's artifact with public bytecode.
|
|
173
|
+
*/
|
|
174
|
+
public static get artifactForPublic(): ContractArtifact {
|
|
175
|
+
return loadContractArtifactForPublic(${artifactName}Json as NoirCompiledContract);
|
|
176
|
+
}
|
|
169
177
|
`;
|
|
170
178
|
}
|
|
171
179
|
|
|
@@ -298,7 +306,7 @@ async function generateEvents(events: any[] | undefined) {
|
|
|
298
306
|
* @returns The corresponding ts code.
|
|
299
307
|
*/
|
|
300
308
|
export async function generateTypescriptContractInterface(input: ContractArtifact, artifactImportPath?: string) {
|
|
301
|
-
const methods = input
|
|
309
|
+
const methods = getAllFunctionAbis(input)
|
|
302
310
|
.filter(f => !f.isInternal)
|
|
303
311
|
.sort((a, b) => a.name.localeCompare(b.name))
|
|
304
312
|
.map(generateMethod);
|
|
@@ -306,7 +314,7 @@ export async function generateTypescriptContractInterface(input: ContractArtifac
|
|
|
306
314
|
const ctor = artifactImportPath && generateConstructor(input.name);
|
|
307
315
|
const at = artifactImportPath && generateAt(input.name);
|
|
308
316
|
const artifactStatement = artifactImportPath && generateAbiStatement(input.name, artifactImportPath);
|
|
309
|
-
const artifactGetter = artifactImportPath &&
|
|
317
|
+
const artifactGetter = artifactImportPath && generateArtifactGetters(input.name);
|
|
310
318
|
const storageLayoutGetter = artifactImportPath && generateStorageLayoutGetter(input);
|
|
311
319
|
const notesGetter = artifactImportPath && generateNotesGetter(input);
|
|
312
320
|
const { eventDefs, events } = await generateEvents(input.outputs.structs?.events);
|
|
@@ -338,6 +346,7 @@ import {
|
|
|
338
346
|
type FunctionSelectorLike,
|
|
339
347
|
L1EventPayload,
|
|
340
348
|
loadContractArtifact,
|
|
349
|
+
loadContractArtifactForPublic,
|
|
341
350
|
type NoirCompiledContract,
|
|
342
351
|
NoteSelector,
|
|
343
352
|
Point,
|