@aztec/builder 0.0.1-fake-ceab37513c → 0.0.6-commit.a2d1860fe9
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 +1 -1
- package/dest/contract-interface-gen/codegen.d.ts +2 -2
- package/dest/contract-interface-gen/codegen.d.ts.map +1 -1
- package/dest/contract-interface-gen/codegen.js +4 -0
- package/dest/contract-interface-gen/index.d.ts +2 -0
- package/dest/contract-interface-gen/index.d.ts.map +1 -0
- package/dest/contract-interface-gen/index.js +1 -0
- package/dest/contract-interface-gen/typescript.d.ts +1 -1
- package/dest/contract-interface-gen/typescript.d.ts.map +1 -1
- package/dest/contract-interface-gen/typescript.js +24 -43
- package/dest/index.d.ts +1 -1
- package/package.json +9 -10
- package/src/contract-interface-gen/codegen.ts +6 -0
- package/src/contract-interface-gen/index.ts +1 -0
- package/src/contract-interface-gen/typescript.ts +24 -42
package/dest/bin/cli.d.ts
CHANGED
|
@@ -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=
|
|
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,
|
|
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=
|
|
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,
|
|
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, getAllFunctionAbis, getDefaultInitializer, isAztecAddressStruct, isBoundedVecStruct, 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,6 +28,11 @@ 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.
|
|
@@ -69,14 +74,14 @@ import { EventSelector, decodeFunctionSignature, getAllFunctionAbis, getDefaultI
|
|
|
69
74
|
* Creates a tx to deploy a new instance of this contract.
|
|
70
75
|
*/
|
|
71
76
|
public static deploy(wallet: Wallet, ${args}) {
|
|
72
|
-
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));
|
|
73
78
|
}
|
|
74
79
|
|
|
75
80
|
/**
|
|
76
81
|
* Creates a tx to deploy a new instance of this contract using the specified public keys hash to derive the address.
|
|
77
82
|
*/
|
|
78
83
|
public static deployWithPublicKeys(publicKeys: PublicKeys, wallet: Wallet, ${args}) {
|
|
79
|
-
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));
|
|
80
85
|
}
|
|
81
86
|
|
|
82
87
|
/**
|
|
@@ -90,7 +95,7 @@ import { EventSelector, decodeFunctionSignature, getAllFunctionAbis, getDefaultI
|
|
|
90
95
|
opts.publicKeys ?? PublicKeys.default(),
|
|
91
96
|
opts.wallet,
|
|
92
97
|
${artifactName},
|
|
93
|
-
${contractName}.at,
|
|
98
|
+
(instance, wallet) => ${contractName}.at(instance.address, wallet),
|
|
94
99
|
Array.from(arguments).slice(1),
|
|
95
100
|
opts.method ?? 'constructor',
|
|
96
101
|
);
|
|
@@ -101,14 +106,14 @@ import { EventSelector, decodeFunctionSignature, getAllFunctionAbis, getDefaultI
|
|
|
101
106
|
* Generates the constructor by supplying the ABI to the parent class so the user doesn't have to.
|
|
102
107
|
* @param name - Name of the contract to derive the ABI name from.
|
|
103
108
|
* @returns A constructor method.
|
|
104
|
-
* @remarks The constructor is private because we want to force the user to use the
|
|
109
|
+
* @remarks The constructor is private because we want to force the user to use the at method.
|
|
105
110
|
*/ function generateConstructor(name) {
|
|
106
111
|
return `
|
|
107
112
|
private constructor(
|
|
108
|
-
|
|
113
|
+
address: AztecAddress,
|
|
109
114
|
wallet: Wallet,
|
|
110
115
|
) {
|
|
111
|
-
super(
|
|
116
|
+
super(address, ${name}ContractArtifact, wallet);
|
|
112
117
|
}
|
|
113
118
|
`;
|
|
114
119
|
}
|
|
@@ -116,20 +121,19 @@ import { EventSelector, decodeFunctionSignature, getAllFunctionAbis, getDefaultI
|
|
|
116
121
|
* Generates the at method for this contract.
|
|
117
122
|
* @param name - Name of the contract to derive the ABI name from.
|
|
118
123
|
* @returns An at method.
|
|
119
|
-
* @remarks We don't use constructor directly because of the async `wallet.getContractData` call.
|
|
120
124
|
*/ function generateAt(name) {
|
|
121
125
|
return `
|
|
122
126
|
/**
|
|
123
127
|
* Creates a contract instance.
|
|
124
128
|
* @param address - The deployed contract's address.
|
|
125
129
|
* @param wallet - The wallet to use when interacting with the contract.
|
|
126
|
-
* @returns A
|
|
130
|
+
* @returns A new Contract instance.
|
|
127
131
|
*/
|
|
128
|
-
public static
|
|
132
|
+
public static at(
|
|
129
133
|
address: AztecAddress,
|
|
130
134
|
wallet: Wallet,
|
|
131
|
-
) {
|
|
132
|
-
return Contract.at(address, ${name}Contract.artifact, wallet) as
|
|
135
|
+
): ${name}Contract {
|
|
136
|
+
return Contract.at(address, ${name}Contract.artifact, wallet) as ${name}Contract;
|
|
133
137
|
}`;
|
|
134
138
|
}
|
|
135
139
|
/**
|
|
@@ -233,7 +237,7 @@ async function generateEvents(events) {
|
|
|
233
237
|
* @param artifactImportPath - Optional path to import the artifact (if not set, will be required in the constructor).
|
|
234
238
|
* @returns The corresponding ts code.
|
|
235
239
|
*/ export async function generateTypescriptContractInterface(input, artifactImportPath) {
|
|
236
|
-
const methods = getAllFunctionAbis(input).filter((f)=>!f.
|
|
240
|
+
const methods = getAllFunctionAbis(input).filter((f)=>!f.isOnlySelf).sort((a, b)=>a.name.localeCompare(b.name)).map(generateMethod);
|
|
237
241
|
const deploy = artifactImportPath && generateDeploy(input);
|
|
238
242
|
const ctor = artifactImportPath && generateConstructor(input.name);
|
|
239
243
|
const at = artifactImportPath && generateAt(input.name);
|
|
@@ -245,36 +249,13 @@ async function generateEvents(events) {
|
|
|
245
249
|
/* Autogenerated file, do not edit! */
|
|
246
250
|
|
|
247
251
|
/* eslint-disable */
|
|
248
|
-
import {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
ContractBase,
|
|
256
|
-
ContractFunctionInteraction,
|
|
257
|
-
type ContractInstanceWithAddress,
|
|
258
|
-
type ContractMethod,
|
|
259
|
-
type ContractStorageLayout,
|
|
260
|
-
decodeFromAbi,
|
|
261
|
-
DeployMethod,
|
|
262
|
-
EthAddress,
|
|
263
|
-
type EthAddressLike,
|
|
264
|
-
EventSelector,
|
|
265
|
-
type FieldLike,
|
|
266
|
-
Fr,
|
|
267
|
-
type FunctionSelectorLike,
|
|
268
|
-
loadContractArtifact,
|
|
269
|
-
loadContractArtifactForPublic,
|
|
270
|
-
type NoirCompiledContract,
|
|
271
|
-
Point,
|
|
272
|
-
type PublicKey,
|
|
273
|
-
PublicKeys,
|
|
274
|
-
type Wallet,
|
|
275
|
-
type U128Like,
|
|
276
|
-
type WrappedFieldLike,
|
|
277
|
-
} 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';
|
|
278
259
|
${artifactStatement}
|
|
279
260
|
|
|
280
261
|
${eventDefs}
|
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=
|
|
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.
|
|
3
|
+
"version": "0.0.6-commit.a2d1860fe9",
|
|
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
|
|
21
|
-
"build:dev": "tsc
|
|
22
|
-
"generate": "tsc
|
|
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.
|
|
73
|
-
"@aztec/stdlib": "0.0.
|
|
70
|
+
"@aztec/foundation": "0.0.6-commit.a2d1860fe9",
|
|
71
|
+
"@aztec/stdlib": "0.0.6-commit.a2d1860fe9",
|
|
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,7 @@ import {
|
|
|
11
11
|
isBoundedVecStruct,
|
|
12
12
|
isEthAddressStruct,
|
|
13
13
|
isFunctionSelectorStruct,
|
|
14
|
+
isPublicKeysStruct,
|
|
14
15
|
isWrappedFieldStruct,
|
|
15
16
|
} from '@aztec/stdlib/abi';
|
|
16
17
|
|
|
@@ -44,6 +45,11 @@ function abiTypeToTypescript(type: ABIParameter['type']): string {
|
|
|
44
45
|
if (isWrappedFieldStruct(type)) {
|
|
45
46
|
return 'WrappedFieldLike';
|
|
46
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
|
+
}
|
|
47
53
|
if (isBoundedVecStruct(type)) {
|
|
48
54
|
// To make BoundedVec easier to work with, we expect a simple array on the input and then we encode it
|
|
49
55
|
// as a BoundedVec in the ArgumentsEncoder.
|
|
@@ -92,14 +98,14 @@ function generateDeploy(input: ContractArtifact) {
|
|
|
92
98
|
* Creates a tx to deploy a new instance of this contract.
|
|
93
99
|
*/
|
|
94
100
|
public static deploy(wallet: Wallet, ${args}) {
|
|
95
|
-
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));
|
|
96
102
|
}
|
|
97
103
|
|
|
98
104
|
/**
|
|
99
105
|
* Creates a tx to deploy a new instance of this contract using the specified public keys hash to derive the address.
|
|
100
106
|
*/
|
|
101
107
|
public static deployWithPublicKeys(publicKeys: PublicKeys, wallet: Wallet, ${args}) {
|
|
102
|
-
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));
|
|
103
109
|
}
|
|
104
110
|
|
|
105
111
|
/**
|
|
@@ -113,7 +119,7 @@ function generateDeploy(input: ContractArtifact) {
|
|
|
113
119
|
opts.publicKeys ?? PublicKeys.default(),
|
|
114
120
|
opts.wallet,
|
|
115
121
|
${artifactName},
|
|
116
|
-
${contractName}.at,
|
|
122
|
+
(instance, wallet) => ${contractName}.at(instance.address, wallet),
|
|
117
123
|
Array.from(arguments).slice(1),
|
|
118
124
|
opts.method ?? 'constructor',
|
|
119
125
|
);
|
|
@@ -125,15 +131,15 @@ function generateDeploy(input: ContractArtifact) {
|
|
|
125
131
|
* Generates the constructor by supplying the ABI to the parent class so the user doesn't have to.
|
|
126
132
|
* @param name - Name of the contract to derive the ABI name from.
|
|
127
133
|
* @returns A constructor method.
|
|
128
|
-
* @remarks The constructor is private because we want to force the user to use the
|
|
134
|
+
* @remarks The constructor is private because we want to force the user to use the at method.
|
|
129
135
|
*/
|
|
130
136
|
function generateConstructor(name: string) {
|
|
131
137
|
return `
|
|
132
138
|
private constructor(
|
|
133
|
-
|
|
139
|
+
address: AztecAddress,
|
|
134
140
|
wallet: Wallet,
|
|
135
141
|
) {
|
|
136
|
-
super(
|
|
142
|
+
super(address, ${name}ContractArtifact, wallet);
|
|
137
143
|
}
|
|
138
144
|
`;
|
|
139
145
|
}
|
|
@@ -142,7 +148,6 @@ function generateConstructor(name: string) {
|
|
|
142
148
|
* Generates the at method for this contract.
|
|
143
149
|
* @param name - Name of the contract to derive the ABI name from.
|
|
144
150
|
* @returns An at method.
|
|
145
|
-
* @remarks We don't use constructor directly because of the async `wallet.getContractData` call.
|
|
146
151
|
*/
|
|
147
152
|
function generateAt(name: string) {
|
|
148
153
|
return `
|
|
@@ -150,13 +155,13 @@ function generateAt(name: string) {
|
|
|
150
155
|
* Creates a contract instance.
|
|
151
156
|
* @param address - The deployed contract's address.
|
|
152
157
|
* @param wallet - The wallet to use when interacting with the contract.
|
|
153
|
-
* @returns A
|
|
158
|
+
* @returns A new Contract instance.
|
|
154
159
|
*/
|
|
155
|
-
public static
|
|
160
|
+
public static at(
|
|
156
161
|
address: AztecAddress,
|
|
157
162
|
wallet: Wallet,
|
|
158
|
-
) {
|
|
159
|
-
return Contract.at(address, ${name}Contract.artifact, wallet) as
|
|
163
|
+
): ${name}Contract {
|
|
164
|
+
return Contract.at(address, ${name}Contract.artifact, wallet) as ${name}Contract;
|
|
160
165
|
}`;
|
|
161
166
|
}
|
|
162
167
|
|
|
@@ -284,7 +289,7 @@ async function generateEvents(events: any[] | undefined) {
|
|
|
284
289
|
*/
|
|
285
290
|
export async function generateTypescriptContractInterface(input: ContractArtifact, artifactImportPath?: string) {
|
|
286
291
|
const methods = getAllFunctionAbis(input)
|
|
287
|
-
.filter(f => !f.
|
|
292
|
+
.filter(f => !f.isOnlySelf)
|
|
288
293
|
.sort((a, b) => a.name.localeCompare(b.name))
|
|
289
294
|
.map(generateMethod);
|
|
290
295
|
const deploy = artifactImportPath && generateDeploy(input);
|
|
@@ -299,36 +304,13 @@ export async function generateTypescriptContractInterface(input: ContractArtifac
|
|
|
299
304
|
/* Autogenerated file, do not edit! */
|
|
300
305
|
|
|
301
306
|
/* eslint-disable */
|
|
302
|
-
import {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
ContractBase,
|
|
310
|
-
ContractFunctionInteraction,
|
|
311
|
-
type ContractInstanceWithAddress,
|
|
312
|
-
type ContractMethod,
|
|
313
|
-
type ContractStorageLayout,
|
|
314
|
-
decodeFromAbi,
|
|
315
|
-
DeployMethod,
|
|
316
|
-
EthAddress,
|
|
317
|
-
type EthAddressLike,
|
|
318
|
-
EventSelector,
|
|
319
|
-
type FieldLike,
|
|
320
|
-
Fr,
|
|
321
|
-
type FunctionSelectorLike,
|
|
322
|
-
loadContractArtifact,
|
|
323
|
-
loadContractArtifactForPublic,
|
|
324
|
-
type NoirCompiledContract,
|
|
325
|
-
Point,
|
|
326
|
-
type PublicKey,
|
|
327
|
-
PublicKeys,
|
|
328
|
-
type Wallet,
|
|
329
|
-
type U128Like,
|
|
330
|
-
type WrappedFieldLike,
|
|
331
|
-
} 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';
|
|
332
314
|
${artifactStatement}
|
|
333
315
|
|
|
334
316
|
${eventDefs}
|