@aztec/aztec.js 0.0.1-commit.f2ce05ee → 0.0.1-commit.f8ca9b2f3
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/api/contract.d.ts +2 -2
- package/dest/api/contract.js +2 -2
- package/dest/api/deployment.d.ts +1 -2
- package/dest/api/deployment.d.ts.map +1 -1
- package/dest/api/deployment.js +0 -1
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts +2 -13
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts.map +1 -1
- package/dest/contract/protocol_contracts/contract-class-registry.js +0 -258
- package/package.json +9 -9
- package/src/api/contract.ts +2 -2
- package/src/api/deployment.ts +0 -1
- package/src/contract/protocol_contracts/contract-class-registry.ts +0 -145
- package/dest/deployment/broadcast_function.d.ts +0 -24
- package/dest/deployment/broadcast_function.d.ts.map +0 -1
- package/dest/deployment/broadcast_function.js +0 -74
- package/src/deployment/broadcast_function.ts +0 -148
package/dest/api/contract.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The `contract` module provides utilities for deploying and interacting with contracts, based on a
|
|
3
3
|
* `Wallet` instance and a compiled artifact. Refer to the {@link account} module for how to obtain a valid
|
|
4
|
-
* `Wallet` instance, and to the {@link https://docs.aztec.network/developers/aztec-nr/
|
|
4
|
+
* `Wallet` instance, and to the {@link https://docs.aztec.network/developers/aztec-nr/compiling_contracts | Compiling contracts}
|
|
5
5
|
* section of the documentation for how to generate an artifact out of your Noir source code.
|
|
6
6
|
*
|
|
7
7
|
* The {@link Contract} class is the main class in this module, and provides static methods for deploying
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
* If you pass `wait: NO_WAIT` in the options, it will return a {@link TxHash} immediately without waiting.
|
|
38
38
|
*
|
|
39
39
|
* @remarks If you are using typescript, consider using the
|
|
40
|
-
* {@link https://docs.aztec.network/developers/aztec-nr/
|
|
40
|
+
* {@link https://docs.aztec.network/developers/aztec-nr/compiling_contracts#use-generated-interfaces | autogenerated type-safe interfaces}
|
|
41
41
|
* for interacting with your contracts.
|
|
42
42
|
*
|
|
43
43
|
* @packageDocumentation
|
package/dest/api/contract.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The `contract` module provides utilities for deploying and interacting with contracts, based on a
|
|
3
3
|
* `Wallet` instance and a compiled artifact. Refer to the {@link account} module for how to obtain a valid
|
|
4
|
-
* `Wallet` instance, and to the {@link https://docs.aztec.network/developers/aztec-nr/
|
|
4
|
+
* `Wallet` instance, and to the {@link https://docs.aztec.network/developers/aztec-nr/compiling_contracts | Compiling contracts}
|
|
5
5
|
* section of the documentation for how to generate an artifact out of your Noir source code.
|
|
6
6
|
*
|
|
7
7
|
* The {@link Contract} class is the main class in this module, and provides static methods for deploying
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
* If you pass `wait: NO_WAIT` in the options, it will return a {@link TxHash} immediately without waiting.
|
|
38
38
|
*
|
|
39
39
|
* @remarks If you are using typescript, consider using the
|
|
40
|
-
* {@link https://docs.aztec.network/developers/aztec-nr/
|
|
40
|
+
* {@link https://docs.aztec.network/developers/aztec-nr/compiling_contracts#use-generated-interfaces | autogenerated type-safe interfaces}
|
|
41
41
|
* for interacting with your contracts.
|
|
42
42
|
*
|
|
43
43
|
* @packageDocumentation
|
package/dest/api/deployment.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { publishContractClass } from '../deployment/publish_class.js';
|
|
2
|
-
export { broadcastPrivateFunction, broadcastUtilityFunction } from '../deployment/broadcast_function.js';
|
|
3
2
|
export { publishInstance } from '../deployment/publish_instance.js';
|
|
4
3
|
export { ContractDeployer } from '../deployment/contract_deployer.js';
|
|
5
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVwbG95bWVudC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2FwaS9kZXBsb3ltZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxvQkFBb0IsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3RFLE9BQU8sRUFBRSxlQUFlLEVBQUUsTUFBTSxtQ0FBbUMsQ0FBQztBQUNwRSxPQUFPLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxvQ0FBb0MsQ0FBQyJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deployment.d.ts","sourceRoot":"","sources":["../../src/api/deployment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"deployment.d.ts","sourceRoot":"","sources":["../../src/api/deployment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC"}
|
package/dest/api/deployment.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export { publishContractClass } from '../deployment/publish_class.js';
|
|
2
|
-
export { broadcastPrivateFunction, broadcastUtilityFunction } from '../deployment/broadcast_function.js';
|
|
3
2
|
export { publishInstance } from '../deployment/publish_instance.js';
|
|
4
3
|
export { ContractDeployer } from '../deployment/contract_deployer.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FieldLike
|
|
1
|
+
import type { FieldLike } from '../../utils/abi_types.js';
|
|
2
2
|
import type { Wallet } from '../../wallet/wallet.js';
|
|
3
3
|
import { ContractBase, type ContractMethod } from '../contract_base.js';
|
|
4
4
|
import { ContractFunctionInteraction } from '../contract_function_interaction.js';
|
|
@@ -6,21 +6,10 @@ export declare class ContractClassRegistryContract extends ContractBase {
|
|
|
6
6
|
private constructor();
|
|
7
7
|
static at(wallet: Wallet): ContractClassRegistryContract;
|
|
8
8
|
methods: {
|
|
9
|
-
/** broadcast_private_function(contract_class_id: struct, artifact_metadata_hash: field, utility_functions_artifact_tree_root: field, private_function_tree_sibling_path: array, private_function_tree_leaf_index: field, artifact_function_tree_sibling_path: array, artifact_function_tree_leaf_index: field, function_data: struct) */
|
|
10
|
-
broadcast_private_function: ((contract_class_id: WrappedFieldLike, artifact_metadata_hash: FieldLike, utility_functions_artifact_tree_root: FieldLike, private_function_tree_sibling_path: FieldLike[], private_function_tree_leaf_index: FieldLike, artifact_function_tree_sibling_path: FieldLike[], artifact_function_tree_leaf_index: FieldLike, function_data: {
|
|
11
|
-
selector: FunctionSelectorLike;
|
|
12
|
-
metadata_hash: FieldLike;
|
|
13
|
-
vk_hash: FieldLike;
|
|
14
|
-
}) => ContractFunctionInteraction) & Pick<ContractMethod, 'selector'>;
|
|
15
|
-
/** broadcast_utility_function(contract_class_id: struct, artifact_metadata_hash: field, private_functions_artifact_tree_root: field, artifact_function_tree_sibling_path: array, artifact_function_tree_leaf_index: field, function_data: struct) */
|
|
16
|
-
broadcast_utility_function: ((contract_class_id: WrappedFieldLike, artifact_metadata_hash: FieldLike, private_functions_artifact_tree_root: FieldLike, artifact_function_tree_sibling_path: FieldLike[], artifact_function_tree_leaf_index: FieldLike, function_data: {
|
|
17
|
-
selector: FunctionSelectorLike;
|
|
18
|
-
metadata_hash: FieldLike;
|
|
19
|
-
}) => ContractFunctionInteraction) & Pick<ContractMethod, 'selector'>;
|
|
20
9
|
/** public_dispatch(selector: field) */
|
|
21
10
|
public_dispatch: ((selector: FieldLike) => ContractFunctionInteraction) & Pick<ContractMethod, 'selector'>;
|
|
22
11
|
/** publish(artifact_hash: field, private_functions_root: field, public_bytecode_commitment: field) */
|
|
23
12
|
publish: ((artifact_hash: FieldLike, private_functions_root: FieldLike, public_bytecode_commitment: FieldLike) => ContractFunctionInteraction) & Pick<ContractMethod, 'selector'>;
|
|
24
13
|
};
|
|
25
14
|
}
|
|
26
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
15
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udHJhY3QtY2xhc3MtcmVnaXN0cnkuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9jb250cmFjdC9wcm90b2NvbF9jb250cmFjdHMvY29udHJhY3QtY2xhc3MtcmVnaXN0cnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBT0EsT0FBTyxLQUFLLEVBR1YsU0FBUyxFQUdWLE1BQU0sMEJBQTBCLENBQUM7QUFDbEMsT0FBTyxLQUFLLEVBQUUsTUFBTSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFDckQsT0FBTyxFQUFFLFlBQVksRUFBRSxLQUFLLGNBQWMsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBQ3hFLE9BQU8sRUFBRSwyQkFBMkIsRUFBRSxNQUFNLHFDQUFxQyxDQUFDO0FBMERsRixxQkFBYSw2QkFBOEIsU0FBUSxZQUFZO0lBQzdELE9BQU8sZUFFTjtJQUVELE9BQWMsRUFBRSxDQUFDLE1BQU0sRUFBRSxNQUFNLEdBQUcsNkJBQTZCLENBRTlEO0lBRWMsT0FBTyxFQUFFO1FBQ3RCLHVDQUF1QztRQUN2QyxlQUFlLEVBQUUsQ0FBQyxDQUFDLFFBQVEsRUFBRSxTQUFTLEtBQUssMkJBQTJCLENBQUMsR0FBRyxJQUFJLENBQUMsY0FBYyxFQUFFLFVBQVUsQ0FBQyxDQUFDO1FBRTNHLHNHQUFzRztRQUN0RyxPQUFPLEVBQUUsQ0FBQyxDQUNSLGFBQWEsRUFBRSxTQUFTLEVBQ3hCLHNCQUFzQixFQUFFLFNBQVMsRUFDakMsMEJBQTBCLEVBQUUsU0FBUyxLQUNsQywyQkFBMkIsQ0FBQyxHQUMvQixJQUFJLENBQUMsY0FBYyxFQUFFLFVBQVUsQ0FBQyxDQUFDO0tBQ3BDLENBQUM7Q0FDSCJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract-class-registry.d.ts","sourceRoot":"","sources":["../../../src/contract/protocol_contracts/contract-class-registry.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAGV,SAAS,
|
|
1
|
+
{"version":3,"file":"contract-class-registry.d.ts","sourceRoot":"","sources":["../../../src/contract/protocol_contracts/contract-class-registry.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAGV,SAAS,EAGV,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AA0DlF,qBAAa,6BAA8B,SAAQ,YAAY;IAC7D,OAAO,eAEN;IAED,OAAc,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,6BAA6B,CAE9D;IAEc,OAAO,EAAE;QACtB,uCAAuC;QACvC,eAAe,EAAE,CAAC,CAAC,QAAQ,EAAE,SAAS,KAAK,2BAA2B,CAAC,GAAG,IAAI,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;QAE3G,sGAAsG;QACtG,OAAO,EAAE,CAAC,CACR,aAAa,EAAE,SAAS,EACxB,sBAAsB,EAAE,SAAS,EACjC,0BAA0B,EAAE,SAAS,KAClC,2BAA2B,CAAC,GAC/B,IAAI,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;KACpC,CAAC;CACH"}
|
|
@@ -4,264 +4,6 @@ import { ContractBase } from '../contract_base.js';
|
|
|
4
4
|
const ContractClassRegistryContractArtifact = {
|
|
5
5
|
name: 'ContractClassRegistry',
|
|
6
6
|
functions: [
|
|
7
|
-
{
|
|
8
|
-
...{
|
|
9
|
-
functionType: FunctionType.PRIVATE,
|
|
10
|
-
name: 'broadcast_private_function',
|
|
11
|
-
isOnlySelf: false,
|
|
12
|
-
isStatic: false,
|
|
13
|
-
isInitializer: false,
|
|
14
|
-
parameters: [
|
|
15
|
-
{
|
|
16
|
-
name: 'contract_class_id',
|
|
17
|
-
type: {
|
|
18
|
-
kind: 'struct',
|
|
19
|
-
fields: [
|
|
20
|
-
{
|
|
21
|
-
name: 'inner',
|
|
22
|
-
type: {
|
|
23
|
-
kind: 'field'
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
],
|
|
27
|
-
path: 'aztec::protocol_types::contract_class_id::ContractClassId'
|
|
28
|
-
},
|
|
29
|
-
visibility: 'private'
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
name: 'artifact_metadata_hash',
|
|
33
|
-
type: {
|
|
34
|
-
kind: 'field'
|
|
35
|
-
},
|
|
36
|
-
visibility: 'private'
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
name: 'utility_functions_artifact_tree_root',
|
|
40
|
-
type: {
|
|
41
|
-
kind: 'field'
|
|
42
|
-
},
|
|
43
|
-
visibility: 'private'
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
name: 'private_function_tree_sibling_path',
|
|
47
|
-
type: {
|
|
48
|
-
kind: 'array',
|
|
49
|
-
length: 7,
|
|
50
|
-
type: {
|
|
51
|
-
kind: 'field'
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
visibility: 'private'
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
name: 'private_function_tree_leaf_index',
|
|
58
|
-
type: {
|
|
59
|
-
kind: 'field'
|
|
60
|
-
},
|
|
61
|
-
visibility: 'private'
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
name: 'artifact_function_tree_sibling_path',
|
|
65
|
-
type: {
|
|
66
|
-
kind: 'array',
|
|
67
|
-
length: 7,
|
|
68
|
-
type: {
|
|
69
|
-
kind: 'field'
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
visibility: 'private'
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
name: 'artifact_function_tree_leaf_index',
|
|
76
|
-
type: {
|
|
77
|
-
kind: 'field'
|
|
78
|
-
},
|
|
79
|
-
visibility: 'private'
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
name: 'function_data',
|
|
83
|
-
type: {
|
|
84
|
-
kind: 'struct',
|
|
85
|
-
fields: [
|
|
86
|
-
{
|
|
87
|
-
name: 'selector',
|
|
88
|
-
type: {
|
|
89
|
-
kind: 'struct',
|
|
90
|
-
fields: [
|
|
91
|
-
{
|
|
92
|
-
name: 'inner',
|
|
93
|
-
type: {
|
|
94
|
-
kind: 'integer',
|
|
95
|
-
sign: 'unsigned',
|
|
96
|
-
width: 32
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
],
|
|
100
|
-
path: 'aztec::protocol_types::abis::function_selector::FunctionSelector'
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
name: 'metadata_hash',
|
|
105
|
-
type: {
|
|
106
|
-
kind: 'field'
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
name: 'vk_hash',
|
|
111
|
-
type: {
|
|
112
|
-
kind: 'field'
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
],
|
|
116
|
-
path: 'events::private_function_broadcasted::InnerPrivateFunction'
|
|
117
|
-
},
|
|
118
|
-
visibility: 'private'
|
|
119
|
-
}
|
|
120
|
-
],
|
|
121
|
-
returnTypes: [],
|
|
122
|
-
errorTypes: {
|
|
123
|
-
'1998584279744703196': {
|
|
124
|
-
error_kind: 'string',
|
|
125
|
-
string: 'attempt to subtract with overflow'
|
|
126
|
-
},
|
|
127
|
-
'14990209321349310352': {
|
|
128
|
-
error_kind: 'string',
|
|
129
|
-
string: 'attempt to add with overflow'
|
|
130
|
-
},
|
|
131
|
-
'15764276373176857197': {
|
|
132
|
-
error_kind: 'string',
|
|
133
|
-
string: 'Stack too deep'
|
|
134
|
-
},
|
|
135
|
-
'16431471497789672479': {
|
|
136
|
-
error_kind: 'string',
|
|
137
|
-
string: 'Index out of bounds'
|
|
138
|
-
},
|
|
139
|
-
'17655676068928457687': {
|
|
140
|
-
error_kind: 'string',
|
|
141
|
-
string: 'Reader did not read all data'
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
},
|
|
145
|
-
bytecode: Buffer.from([]),
|
|
146
|
-
debugSymbols: ''
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
...{
|
|
150
|
-
functionType: FunctionType.PRIVATE,
|
|
151
|
-
name: 'broadcast_utility_function',
|
|
152
|
-
isOnlySelf: false,
|
|
153
|
-
isStatic: false,
|
|
154
|
-
isInitializer: false,
|
|
155
|
-
parameters: [
|
|
156
|
-
{
|
|
157
|
-
name: 'contract_class_id',
|
|
158
|
-
type: {
|
|
159
|
-
kind: 'struct',
|
|
160
|
-
fields: [
|
|
161
|
-
{
|
|
162
|
-
name: 'inner',
|
|
163
|
-
type: {
|
|
164
|
-
kind: 'field'
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
],
|
|
168
|
-
path: 'aztec::protocol_types::contract_class_id::ContractClassId'
|
|
169
|
-
},
|
|
170
|
-
visibility: 'private'
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
name: 'artifact_metadata_hash',
|
|
174
|
-
type: {
|
|
175
|
-
kind: 'field'
|
|
176
|
-
},
|
|
177
|
-
visibility: 'private'
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
name: 'private_functions_artifact_tree_root',
|
|
181
|
-
type: {
|
|
182
|
-
kind: 'field'
|
|
183
|
-
},
|
|
184
|
-
visibility: 'private'
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
name: 'artifact_function_tree_sibling_path',
|
|
188
|
-
type: {
|
|
189
|
-
kind: 'array',
|
|
190
|
-
length: 7,
|
|
191
|
-
type: {
|
|
192
|
-
kind: 'field'
|
|
193
|
-
}
|
|
194
|
-
},
|
|
195
|
-
visibility: 'private'
|
|
196
|
-
},
|
|
197
|
-
{
|
|
198
|
-
name: 'artifact_function_tree_leaf_index',
|
|
199
|
-
type: {
|
|
200
|
-
kind: 'field'
|
|
201
|
-
},
|
|
202
|
-
visibility: 'private'
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
name: 'function_data',
|
|
206
|
-
type: {
|
|
207
|
-
kind: 'struct',
|
|
208
|
-
fields: [
|
|
209
|
-
{
|
|
210
|
-
name: 'selector',
|
|
211
|
-
type: {
|
|
212
|
-
kind: 'struct',
|
|
213
|
-
fields: [
|
|
214
|
-
{
|
|
215
|
-
name: 'inner',
|
|
216
|
-
type: {
|
|
217
|
-
kind: 'integer',
|
|
218
|
-
sign: 'unsigned',
|
|
219
|
-
width: 32
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
],
|
|
223
|
-
path: 'aztec::protocol_types::abis::function_selector::FunctionSelector'
|
|
224
|
-
}
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
name: 'metadata_hash',
|
|
228
|
-
type: {
|
|
229
|
-
kind: 'field'
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
],
|
|
233
|
-
path: 'events::utility_function_broadcasted::InnerUtilityFunction'
|
|
234
|
-
},
|
|
235
|
-
visibility: 'private'
|
|
236
|
-
}
|
|
237
|
-
],
|
|
238
|
-
returnTypes: [],
|
|
239
|
-
errorTypes: {
|
|
240
|
-
'1998584279744703196': {
|
|
241
|
-
error_kind: 'string',
|
|
242
|
-
string: 'attempt to subtract with overflow'
|
|
243
|
-
},
|
|
244
|
-
'14990209321349310352': {
|
|
245
|
-
error_kind: 'string',
|
|
246
|
-
string: 'attempt to add with overflow'
|
|
247
|
-
},
|
|
248
|
-
'15764276373176857197': {
|
|
249
|
-
error_kind: 'string',
|
|
250
|
-
string: 'Stack too deep'
|
|
251
|
-
},
|
|
252
|
-
'16431471497789672479': {
|
|
253
|
-
error_kind: 'string',
|
|
254
|
-
string: 'Index out of bounds'
|
|
255
|
-
},
|
|
256
|
-
'17655676068928457687': {
|
|
257
|
-
error_kind: 'string',
|
|
258
|
-
string: 'Reader did not read all data'
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
},
|
|
262
|
-
bytecode: Buffer.from([]),
|
|
263
|
-
debugSymbols: ''
|
|
264
|
-
},
|
|
265
7
|
{
|
|
266
8
|
...{
|
|
267
9
|
functionType: FunctionType.PRIVATE,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/aztec.js",
|
|
3
3
|
"homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/aztec.js",
|
|
4
|
-
"version": "0.0.1-commit.
|
|
4
|
+
"version": "0.0.1-commit.f8ca9b2f3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./abi": "./dest/api/abi.js",
|
|
@@ -94,20 +94,20 @@
|
|
|
94
94
|
]
|
|
95
95
|
},
|
|
96
96
|
"dependencies": {
|
|
97
|
-
"@aztec/constants": "0.0.1-commit.
|
|
98
|
-
"@aztec/entrypoints": "0.0.1-commit.
|
|
99
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
100
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
101
|
-
"@aztec/l1-artifacts": "0.0.1-commit.
|
|
102
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
103
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
97
|
+
"@aztec/constants": "0.0.1-commit.f8ca9b2f3",
|
|
98
|
+
"@aztec/entrypoints": "0.0.1-commit.f8ca9b2f3",
|
|
99
|
+
"@aztec/ethereum": "0.0.1-commit.f8ca9b2f3",
|
|
100
|
+
"@aztec/foundation": "0.0.1-commit.f8ca9b2f3",
|
|
101
|
+
"@aztec/l1-artifacts": "0.0.1-commit.f8ca9b2f3",
|
|
102
|
+
"@aztec/protocol-contracts": "0.0.1-commit.f8ca9b2f3",
|
|
103
|
+
"@aztec/stdlib": "0.0.1-commit.f8ca9b2f3",
|
|
104
104
|
"axios": "^1.12.0",
|
|
105
105
|
"tslib": "^2.4.0",
|
|
106
106
|
"viem": "npm:@aztec/viem@2.38.2",
|
|
107
107
|
"zod": "^3.23.8"
|
|
108
108
|
},
|
|
109
109
|
"devDependencies": {
|
|
110
|
-
"@aztec/builder": "0.0.1-commit.
|
|
110
|
+
"@aztec/builder": "0.0.1-commit.f8ca9b2f3",
|
|
111
111
|
"@jest/globals": "^30.0.0",
|
|
112
112
|
"@types/jest": "^30.0.0",
|
|
113
113
|
"@types/node": "^22.15.17",
|
package/src/api/contract.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The `contract` module provides utilities for deploying and interacting with contracts, based on a
|
|
3
3
|
* `Wallet` instance and a compiled artifact. Refer to the {@link account} module for how to obtain a valid
|
|
4
|
-
* `Wallet` instance, and to the {@link https://docs.aztec.network/developers/aztec-nr/
|
|
4
|
+
* `Wallet` instance, and to the {@link https://docs.aztec.network/developers/aztec-nr/compiling_contracts | Compiling contracts}
|
|
5
5
|
* section of the documentation for how to generate an artifact out of your Noir source code.
|
|
6
6
|
*
|
|
7
7
|
* The {@link Contract} class is the main class in this module, and provides static methods for deploying
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
* If you pass `wait: NO_WAIT` in the options, it will return a {@link TxHash} immediately without waiting.
|
|
38
38
|
*
|
|
39
39
|
* @remarks If you are using typescript, consider using the
|
|
40
|
-
* {@link https://docs.aztec.network/developers/aztec-nr/
|
|
40
|
+
* {@link https://docs.aztec.network/developers/aztec-nr/compiling_contracts#use-generated-interfaces | autogenerated type-safe interfaces}
|
|
41
41
|
* for interacting with your contracts.
|
|
42
42
|
*
|
|
43
43
|
* @packageDocumentation
|
package/src/api/deployment.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export { publishContractClass } from '../deployment/publish_class.js';
|
|
2
|
-
export { broadcastPrivateFunction, broadcastUtilityFunction } from '../deployment/broadcast_function.js';
|
|
3
2
|
export { publishInstance } from '../deployment/publish_instance.js';
|
|
4
3
|
export { ContractDeployer } from '../deployment/contract_deployer.js';
|
|
@@ -19,127 +19,6 @@ import { ContractFunctionInteraction } from '../contract_function_interaction.js
|
|
|
19
19
|
const ContractClassRegistryContractArtifact: ContractArtifact = {
|
|
20
20
|
name: 'ContractClassRegistry',
|
|
21
21
|
functions: [
|
|
22
|
-
{
|
|
23
|
-
...{
|
|
24
|
-
functionType: FunctionType.PRIVATE,
|
|
25
|
-
name: 'broadcast_private_function',
|
|
26
|
-
isOnlySelf: false,
|
|
27
|
-
isStatic: false,
|
|
28
|
-
isInitializer: false,
|
|
29
|
-
parameters: [
|
|
30
|
-
{
|
|
31
|
-
name: 'contract_class_id',
|
|
32
|
-
type: {
|
|
33
|
-
kind: 'struct',
|
|
34
|
-
fields: [{ name: 'inner', type: { kind: 'field' } }],
|
|
35
|
-
path: 'aztec::protocol_types::contract_class_id::ContractClassId',
|
|
36
|
-
},
|
|
37
|
-
visibility: 'private',
|
|
38
|
-
},
|
|
39
|
-
{ name: 'artifact_metadata_hash', type: { kind: 'field' }, visibility: 'private' },
|
|
40
|
-
{ name: 'utility_functions_artifact_tree_root', type: { kind: 'field' }, visibility: 'private' },
|
|
41
|
-
{
|
|
42
|
-
name: 'private_function_tree_sibling_path',
|
|
43
|
-
type: { kind: 'array', length: 7, type: { kind: 'field' } },
|
|
44
|
-
visibility: 'private',
|
|
45
|
-
},
|
|
46
|
-
{ name: 'private_function_tree_leaf_index', type: { kind: 'field' }, visibility: 'private' },
|
|
47
|
-
{
|
|
48
|
-
name: 'artifact_function_tree_sibling_path',
|
|
49
|
-
type: { kind: 'array', length: 7, type: { kind: 'field' } },
|
|
50
|
-
visibility: 'private',
|
|
51
|
-
},
|
|
52
|
-
{ name: 'artifact_function_tree_leaf_index', type: { kind: 'field' }, visibility: 'private' },
|
|
53
|
-
{
|
|
54
|
-
name: 'function_data',
|
|
55
|
-
type: {
|
|
56
|
-
kind: 'struct',
|
|
57
|
-
fields: [
|
|
58
|
-
{
|
|
59
|
-
name: 'selector',
|
|
60
|
-
type: {
|
|
61
|
-
kind: 'struct',
|
|
62
|
-
fields: [{ name: 'inner', type: { kind: 'integer', sign: 'unsigned', width: 32 } }],
|
|
63
|
-
path: 'aztec::protocol_types::abis::function_selector::FunctionSelector',
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
{ name: 'metadata_hash', type: { kind: 'field' } },
|
|
67
|
-
{ name: 'vk_hash', type: { kind: 'field' } },
|
|
68
|
-
],
|
|
69
|
-
path: 'events::private_function_broadcasted::InnerPrivateFunction',
|
|
70
|
-
},
|
|
71
|
-
visibility: 'private',
|
|
72
|
-
},
|
|
73
|
-
],
|
|
74
|
-
returnTypes: [],
|
|
75
|
-
errorTypes: {
|
|
76
|
-
'1998584279744703196': { error_kind: 'string', string: 'attempt to subtract with overflow' },
|
|
77
|
-
'14990209321349310352': { error_kind: 'string', string: 'attempt to add with overflow' },
|
|
78
|
-
'15764276373176857197': { error_kind: 'string', string: 'Stack too deep' },
|
|
79
|
-
'16431471497789672479': { error_kind: 'string', string: 'Index out of bounds' },
|
|
80
|
-
'17655676068928457687': { error_kind: 'string', string: 'Reader did not read all data' },
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
bytecode: Buffer.from([]),
|
|
84
|
-
debugSymbols: '',
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
...{
|
|
88
|
-
functionType: FunctionType.PRIVATE,
|
|
89
|
-
name: 'broadcast_utility_function',
|
|
90
|
-
isOnlySelf: false,
|
|
91
|
-
isStatic: false,
|
|
92
|
-
isInitializer: false,
|
|
93
|
-
parameters: [
|
|
94
|
-
{
|
|
95
|
-
name: 'contract_class_id',
|
|
96
|
-
type: {
|
|
97
|
-
kind: 'struct',
|
|
98
|
-
fields: [{ name: 'inner', type: { kind: 'field' } }],
|
|
99
|
-
path: 'aztec::protocol_types::contract_class_id::ContractClassId',
|
|
100
|
-
},
|
|
101
|
-
visibility: 'private',
|
|
102
|
-
},
|
|
103
|
-
{ name: 'artifact_metadata_hash', type: { kind: 'field' }, visibility: 'private' },
|
|
104
|
-
{ name: 'private_functions_artifact_tree_root', type: { kind: 'field' }, visibility: 'private' },
|
|
105
|
-
{
|
|
106
|
-
name: 'artifact_function_tree_sibling_path',
|
|
107
|
-
type: { kind: 'array', length: 7, type: { kind: 'field' } },
|
|
108
|
-
visibility: 'private',
|
|
109
|
-
},
|
|
110
|
-
{ name: 'artifact_function_tree_leaf_index', type: { kind: 'field' }, visibility: 'private' },
|
|
111
|
-
{
|
|
112
|
-
name: 'function_data',
|
|
113
|
-
type: {
|
|
114
|
-
kind: 'struct',
|
|
115
|
-
fields: [
|
|
116
|
-
{
|
|
117
|
-
name: 'selector',
|
|
118
|
-
type: {
|
|
119
|
-
kind: 'struct',
|
|
120
|
-
fields: [{ name: 'inner', type: { kind: 'integer', sign: 'unsigned', width: 32 } }],
|
|
121
|
-
path: 'aztec::protocol_types::abis::function_selector::FunctionSelector',
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
{ name: 'metadata_hash', type: { kind: 'field' } },
|
|
125
|
-
],
|
|
126
|
-
path: 'events::utility_function_broadcasted::InnerUtilityFunction',
|
|
127
|
-
},
|
|
128
|
-
visibility: 'private',
|
|
129
|
-
},
|
|
130
|
-
],
|
|
131
|
-
returnTypes: [],
|
|
132
|
-
errorTypes: {
|
|
133
|
-
'1998584279744703196': { error_kind: 'string', string: 'attempt to subtract with overflow' },
|
|
134
|
-
'14990209321349310352': { error_kind: 'string', string: 'attempt to add with overflow' },
|
|
135
|
-
'15764276373176857197': { error_kind: 'string', string: 'Stack too deep' },
|
|
136
|
-
'16431471497789672479': { error_kind: 'string', string: 'Index out of bounds' },
|
|
137
|
-
'17655676068928457687': { error_kind: 'string', string: 'Reader did not read all data' },
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
bytecode: Buffer.from([]),
|
|
141
|
-
debugSymbols: '',
|
|
142
|
-
},
|
|
143
22
|
{
|
|
144
23
|
...{
|
|
145
24
|
functionType: FunctionType.PRIVATE,
|
|
@@ -203,30 +82,6 @@ export class ContractClassRegistryContract extends ContractBase {
|
|
|
203
82
|
}
|
|
204
83
|
|
|
205
84
|
declare public methods: {
|
|
206
|
-
/** broadcast_private_function(contract_class_id: struct, artifact_metadata_hash: field, utility_functions_artifact_tree_root: field, private_function_tree_sibling_path: array, private_function_tree_leaf_index: field, artifact_function_tree_sibling_path: array, artifact_function_tree_leaf_index: field, function_data: struct) */
|
|
207
|
-
broadcast_private_function: ((
|
|
208
|
-
contract_class_id: WrappedFieldLike,
|
|
209
|
-
artifact_metadata_hash: FieldLike,
|
|
210
|
-
utility_functions_artifact_tree_root: FieldLike,
|
|
211
|
-
private_function_tree_sibling_path: FieldLike[],
|
|
212
|
-
private_function_tree_leaf_index: FieldLike,
|
|
213
|
-
artifact_function_tree_sibling_path: FieldLike[],
|
|
214
|
-
artifact_function_tree_leaf_index: FieldLike,
|
|
215
|
-
function_data: { selector: FunctionSelectorLike; metadata_hash: FieldLike; vk_hash: FieldLike },
|
|
216
|
-
) => ContractFunctionInteraction) &
|
|
217
|
-
Pick<ContractMethod, 'selector'>;
|
|
218
|
-
|
|
219
|
-
/** broadcast_utility_function(contract_class_id: struct, artifact_metadata_hash: field, private_functions_artifact_tree_root: field, artifact_function_tree_sibling_path: array, artifact_function_tree_leaf_index: field, function_data: struct) */
|
|
220
|
-
broadcast_utility_function: ((
|
|
221
|
-
contract_class_id: WrappedFieldLike,
|
|
222
|
-
artifact_metadata_hash: FieldLike,
|
|
223
|
-
private_functions_artifact_tree_root: FieldLike,
|
|
224
|
-
artifact_function_tree_sibling_path: FieldLike[],
|
|
225
|
-
artifact_function_tree_leaf_index: FieldLike,
|
|
226
|
-
function_data: { selector: FunctionSelectorLike; metadata_hash: FieldLike },
|
|
227
|
-
) => ContractFunctionInteraction) &
|
|
228
|
-
Pick<ContractMethod, 'selector'>;
|
|
229
|
-
|
|
230
85
|
/** public_dispatch(selector: field) */
|
|
231
86
|
public_dispatch: ((selector: FieldLike) => ContractFunctionInteraction) & Pick<ContractMethod, 'selector'>;
|
|
232
87
|
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { type ContractArtifact, FunctionSelector } from '@aztec/stdlib/abi';
|
|
2
|
-
import type { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
3
|
-
import type { Wallet } from '../wallet/index.js';
|
|
4
|
-
/**
|
|
5
|
-
* Sets up a call to broadcast a private function's bytecode via the ClassRegistry contract.
|
|
6
|
-
* Note that this is not required for users to call the function, but is rather a convenience to make
|
|
7
|
-
* this code publicly available so dapps or wallets do not need to redistribute it.
|
|
8
|
-
* @param wallet - Wallet to send the transaction.
|
|
9
|
-
* @param artifact - Contract artifact that contains the function to be broadcast.
|
|
10
|
-
* @param selector - Selector of the function to be broadcast.
|
|
11
|
-
* @returns A ContractFunctionInteraction object that can be used to send the transaction.
|
|
12
|
-
*/
|
|
13
|
-
export declare function broadcastPrivateFunction(wallet: Wallet, artifact: ContractArtifact, selector: FunctionSelector): Promise<ContractFunctionInteraction>;
|
|
14
|
-
/**
|
|
15
|
-
* Sets up a call to broadcast a utility function's bytecode via the ClassRegistry contract.
|
|
16
|
-
* Note that this is not required for users to call the function, but is rather a convenience to make
|
|
17
|
-
* this code publicly available so dapps or wallets do not need to redistribute it.
|
|
18
|
-
* @param wallet - Wallet to send the transaction.
|
|
19
|
-
* @param artifact - Contract artifact that contains the function to be broadcast.
|
|
20
|
-
* @param selector - Selector of the function to be broadcast.
|
|
21
|
-
* @returns A ContractFunctionInteraction object that can be used to send the transaction.
|
|
22
|
-
*/
|
|
23
|
-
export declare function broadcastUtilityFunction(wallet: Wallet, artifact: ContractArtifact, selector: FunctionSelector): Promise<ContractFunctionInteraction>;
|
|
24
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnJvYWRjYXN0X2Z1bmN0aW9uLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZGVwbG95bWVudC9icm9hZGNhc3RfZnVuY3Rpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBUUEsT0FBTyxFQUFFLEtBQUssZ0JBQWdCLEVBQUUsZ0JBQWdCLEVBQWdDLE1BQU0sbUJBQW1CLENBQUM7QUFTMUcsT0FBTyxLQUFLLEVBQUUsMkJBQTJCLEVBQUUsTUFBTSw4Q0FBOEMsQ0FBQztBQUVoRyxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUVqRDs7Ozs7Ozs7R0FRRztBQUNILHdCQUFzQix3QkFBd0IsQ0FDNUMsTUFBTSxFQUFFLE1BQU0sRUFDZCxRQUFRLEVBQUUsZ0JBQWdCLEVBQzFCLFFBQVEsRUFBRSxnQkFBZ0IsR0FDekIsT0FBTyxDQUFDLDJCQUEyQixDQUFDLENBb0R0QztBQUVEOzs7Ozs7OztHQVFHO0FBQ0gsd0JBQXNCLHdCQUF3QixDQUM1QyxNQUFNLEVBQUUsTUFBTSxFQUNkLFFBQVEsRUFBRSxnQkFBZ0IsRUFDMUIsUUFBUSxFQUFFLGdCQUFnQixHQUN6QixPQUFPLENBQUMsMkJBQTJCLENBQUMsQ0E4Q3RDIn0=
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"broadcast_function.d.ts","sourceRoot":"","sources":["../../src/deployment/broadcast_function.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,gBAAgB,EAAE,gBAAgB,EAAgC,MAAM,mBAAmB,CAAC;AAS1G,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAEhG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;;;;;;;GAQG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,2BAA2B,CAAC,CAoDtC;AAED;;;;;;;;GAQG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,2BAA2B,CAAC,CA8CtC"}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { ARTIFACT_FUNCTION_TREE_MAX_HEIGHT, CONTRACT_CLASS_REGISTRY_BYTECODE_CAPSULE_SLOT, MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS } from '@aztec/constants';
|
|
2
|
-
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
3
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
-
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
5
|
-
import { FunctionSelector, FunctionType, bufferAsFields } from '@aztec/stdlib/abi';
|
|
6
|
-
import { computeVerificationKeyHash, createPrivateFunctionMembershipProof, createUtilityFunctionMembershipProof, getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
7
|
-
import { Capsule } from '@aztec/stdlib/tx';
|
|
8
|
-
import { ContractClassRegistryContract } from '../contract/protocol_contracts/contract-class-registry.js';
|
|
9
|
-
/**
|
|
10
|
-
* Sets up a call to broadcast a private function's bytecode via the ClassRegistry contract.
|
|
11
|
-
* Note that this is not required for users to call the function, but is rather a convenience to make
|
|
12
|
-
* this code publicly available so dapps or wallets do not need to redistribute it.
|
|
13
|
-
* @param wallet - Wallet to send the transaction.
|
|
14
|
-
* @param artifact - Contract artifact that contains the function to be broadcast.
|
|
15
|
-
* @param selector - Selector of the function to be broadcast.
|
|
16
|
-
* @returns A ContractFunctionInteraction object that can be used to send the transaction.
|
|
17
|
-
*/ export async function broadcastPrivateFunction(wallet, artifact, selector) {
|
|
18
|
-
const contractClass = await getContractClassFromArtifact(artifact);
|
|
19
|
-
const privateFunctions = artifact.functions.filter((fn)=>fn.functionType === FunctionType.PRIVATE);
|
|
20
|
-
const functionsAndSelectors = await Promise.all(privateFunctions.map(async (fn)=>({
|
|
21
|
-
f: fn,
|
|
22
|
-
selector: await FunctionSelector.fromNameAndParameters(fn.name, fn.parameters)
|
|
23
|
-
})));
|
|
24
|
-
const privateFunctionArtifact = functionsAndSelectors.find((fn)=>selector.equals(fn.selector))?.f;
|
|
25
|
-
if (!privateFunctionArtifact) {
|
|
26
|
-
throw new Error(`Private function with selector ${selector.toString()} not found`);
|
|
27
|
-
}
|
|
28
|
-
const { artifactTreeSiblingPath, artifactTreeLeafIndex, artifactMetadataHash, functionMetadataHash, utilityFunctionsTreeRoot, privateFunctionTreeSiblingPath, privateFunctionTreeLeafIndex } = await createPrivateFunctionMembershipProof(selector, artifact);
|
|
29
|
-
const vkHash = await computeVerificationKeyHash(privateFunctionArtifact);
|
|
30
|
-
const classRegistry = ContractClassRegistryContract.at(wallet);
|
|
31
|
-
const bytecode = bufferAsFields(privateFunctionArtifact.bytecode, MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS);
|
|
32
|
-
return classRegistry.methods.broadcast_private_function(contractClass.id, artifactMetadataHash, utilityFunctionsTreeRoot, privateFunctionTreeSiblingPath, privateFunctionTreeLeafIndex, padArrayEnd(artifactTreeSiblingPath, Fr.ZERO, ARTIFACT_FUNCTION_TREE_MAX_HEIGHT), artifactTreeLeafIndex, // eslint-disable-next-line camelcase
|
|
33
|
-
{
|
|
34
|
-
selector,
|
|
35
|
-
metadata_hash: functionMetadataHash,
|
|
36
|
-
vk_hash: vkHash
|
|
37
|
-
}).with({
|
|
38
|
-
capsules: [
|
|
39
|
-
new Capsule(ProtocolContractAddress.ContractClassRegistry, new Fr(CONTRACT_CLASS_REGISTRY_BYTECODE_CAPSULE_SLOT), bytecode)
|
|
40
|
-
]
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Sets up a call to broadcast a utility function's bytecode via the ClassRegistry contract.
|
|
45
|
-
* Note that this is not required for users to call the function, but is rather a convenience to make
|
|
46
|
-
* this code publicly available so dapps or wallets do not need to redistribute it.
|
|
47
|
-
* @param wallet - Wallet to send the transaction.
|
|
48
|
-
* @param artifact - Contract artifact that contains the function to be broadcast.
|
|
49
|
-
* @param selector - Selector of the function to be broadcast.
|
|
50
|
-
* @returns A ContractFunctionInteraction object that can be used to send the transaction.
|
|
51
|
-
*/ export async function broadcastUtilityFunction(wallet, artifact, selector) {
|
|
52
|
-
const contractClass = await getContractClassFromArtifact(artifact);
|
|
53
|
-
const utilityFunctions = artifact.functions.filter((fn)=>fn.functionType === FunctionType.UTILITY);
|
|
54
|
-
const utilityFunctionsAndSelectors = await Promise.all(utilityFunctions.map(async (fn)=>({
|
|
55
|
-
f: fn,
|
|
56
|
-
selector: await FunctionSelector.fromNameAndParameters(fn.name, fn.parameters)
|
|
57
|
-
})));
|
|
58
|
-
const utilityFunctionArtifact = utilityFunctionsAndSelectors.find((fn)=>selector.equals(fn.selector))?.f;
|
|
59
|
-
if (!utilityFunctionArtifact) {
|
|
60
|
-
throw new Error(`Utility function with selector ${selector.toString()} not found`);
|
|
61
|
-
}
|
|
62
|
-
const { artifactMetadataHash, artifactTreeLeafIndex, artifactTreeSiblingPath, functionMetadataHash, privateFunctionsArtifactTreeRoot } = await createUtilityFunctionMembershipProof(selector, artifact);
|
|
63
|
-
const classRegistry = ContractClassRegistryContract.at(wallet);
|
|
64
|
-
const bytecode = bufferAsFields(utilityFunctionArtifact.bytecode, MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS);
|
|
65
|
-
return classRegistry.methods.broadcast_utility_function(contractClass.id, artifactMetadataHash, privateFunctionsArtifactTreeRoot, padArrayEnd(artifactTreeSiblingPath, Fr.ZERO, ARTIFACT_FUNCTION_TREE_MAX_HEIGHT), artifactTreeLeafIndex, // eslint-disable-next-line camelcase
|
|
66
|
-
{
|
|
67
|
-
selector,
|
|
68
|
-
metadata_hash: functionMetadataHash
|
|
69
|
-
}).with({
|
|
70
|
-
capsules: [
|
|
71
|
-
new Capsule(ProtocolContractAddress.ContractClassRegistry, new Fr(CONTRACT_CLASS_REGISTRY_BYTECODE_CAPSULE_SLOT), bytecode)
|
|
72
|
-
]
|
|
73
|
-
});
|
|
74
|
-
}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ARTIFACT_FUNCTION_TREE_MAX_HEIGHT,
|
|
3
|
-
CONTRACT_CLASS_REGISTRY_BYTECODE_CAPSULE_SLOT,
|
|
4
|
-
MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS,
|
|
5
|
-
} from '@aztec/constants';
|
|
6
|
-
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
7
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
8
|
-
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
9
|
-
import { type ContractArtifact, FunctionSelector, FunctionType, bufferAsFields } from '@aztec/stdlib/abi';
|
|
10
|
-
import {
|
|
11
|
-
computeVerificationKeyHash,
|
|
12
|
-
createPrivateFunctionMembershipProof,
|
|
13
|
-
createUtilityFunctionMembershipProof,
|
|
14
|
-
getContractClassFromArtifact,
|
|
15
|
-
} from '@aztec/stdlib/contract';
|
|
16
|
-
import { Capsule } from '@aztec/stdlib/tx';
|
|
17
|
-
|
|
18
|
-
import type { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
19
|
-
import { ContractClassRegistryContract } from '../contract/protocol_contracts/contract-class-registry.js';
|
|
20
|
-
import type { Wallet } from '../wallet/index.js';
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Sets up a call to broadcast a private function's bytecode via the ClassRegistry contract.
|
|
24
|
-
* Note that this is not required for users to call the function, but is rather a convenience to make
|
|
25
|
-
* this code publicly available so dapps or wallets do not need to redistribute it.
|
|
26
|
-
* @param wallet - Wallet to send the transaction.
|
|
27
|
-
* @param artifact - Contract artifact that contains the function to be broadcast.
|
|
28
|
-
* @param selector - Selector of the function to be broadcast.
|
|
29
|
-
* @returns A ContractFunctionInteraction object that can be used to send the transaction.
|
|
30
|
-
*/
|
|
31
|
-
export async function broadcastPrivateFunction(
|
|
32
|
-
wallet: Wallet,
|
|
33
|
-
artifact: ContractArtifact,
|
|
34
|
-
selector: FunctionSelector,
|
|
35
|
-
): Promise<ContractFunctionInteraction> {
|
|
36
|
-
const contractClass = await getContractClassFromArtifact(artifact);
|
|
37
|
-
const privateFunctions = artifact.functions.filter(fn => fn.functionType === FunctionType.PRIVATE);
|
|
38
|
-
const functionsAndSelectors = await Promise.all(
|
|
39
|
-
privateFunctions.map(async fn => ({
|
|
40
|
-
f: fn,
|
|
41
|
-
selector: await FunctionSelector.fromNameAndParameters(fn.name, fn.parameters),
|
|
42
|
-
})),
|
|
43
|
-
);
|
|
44
|
-
const privateFunctionArtifact = functionsAndSelectors.find(fn => selector.equals(fn.selector))?.f;
|
|
45
|
-
if (!privateFunctionArtifact) {
|
|
46
|
-
throw new Error(`Private function with selector ${selector.toString()} not found`);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const {
|
|
50
|
-
artifactTreeSiblingPath,
|
|
51
|
-
artifactTreeLeafIndex,
|
|
52
|
-
artifactMetadataHash,
|
|
53
|
-
functionMetadataHash,
|
|
54
|
-
utilityFunctionsTreeRoot,
|
|
55
|
-
privateFunctionTreeSiblingPath,
|
|
56
|
-
privateFunctionTreeLeafIndex,
|
|
57
|
-
} = await createPrivateFunctionMembershipProof(selector, artifact);
|
|
58
|
-
|
|
59
|
-
const vkHash = await computeVerificationKeyHash(privateFunctionArtifact);
|
|
60
|
-
|
|
61
|
-
const classRegistry = ContractClassRegistryContract.at(wallet);
|
|
62
|
-
const bytecode = bufferAsFields(
|
|
63
|
-
privateFunctionArtifact.bytecode,
|
|
64
|
-
MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS,
|
|
65
|
-
);
|
|
66
|
-
return classRegistry.methods
|
|
67
|
-
.broadcast_private_function(
|
|
68
|
-
contractClass.id,
|
|
69
|
-
artifactMetadataHash,
|
|
70
|
-
utilityFunctionsTreeRoot,
|
|
71
|
-
privateFunctionTreeSiblingPath,
|
|
72
|
-
privateFunctionTreeLeafIndex,
|
|
73
|
-
padArrayEnd(artifactTreeSiblingPath, Fr.ZERO, ARTIFACT_FUNCTION_TREE_MAX_HEIGHT),
|
|
74
|
-
artifactTreeLeafIndex,
|
|
75
|
-
// eslint-disable-next-line camelcase
|
|
76
|
-
{ selector, metadata_hash: functionMetadataHash, vk_hash: vkHash },
|
|
77
|
-
)
|
|
78
|
-
.with({
|
|
79
|
-
capsules: [
|
|
80
|
-
new Capsule(
|
|
81
|
-
ProtocolContractAddress.ContractClassRegistry,
|
|
82
|
-
new Fr(CONTRACT_CLASS_REGISTRY_BYTECODE_CAPSULE_SLOT),
|
|
83
|
-
bytecode,
|
|
84
|
-
),
|
|
85
|
-
],
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Sets up a call to broadcast a utility function's bytecode via the ClassRegistry contract.
|
|
91
|
-
* Note that this is not required for users to call the function, but is rather a convenience to make
|
|
92
|
-
* this code publicly available so dapps or wallets do not need to redistribute it.
|
|
93
|
-
* @param wallet - Wallet to send the transaction.
|
|
94
|
-
* @param artifact - Contract artifact that contains the function to be broadcast.
|
|
95
|
-
* @param selector - Selector of the function to be broadcast.
|
|
96
|
-
* @returns A ContractFunctionInteraction object that can be used to send the transaction.
|
|
97
|
-
*/
|
|
98
|
-
export async function broadcastUtilityFunction(
|
|
99
|
-
wallet: Wallet,
|
|
100
|
-
artifact: ContractArtifact,
|
|
101
|
-
selector: FunctionSelector,
|
|
102
|
-
): Promise<ContractFunctionInteraction> {
|
|
103
|
-
const contractClass = await getContractClassFromArtifact(artifact);
|
|
104
|
-
const utilityFunctions = artifact.functions.filter(fn => fn.functionType === FunctionType.UTILITY);
|
|
105
|
-
const utilityFunctionsAndSelectors = await Promise.all(
|
|
106
|
-
utilityFunctions.map(async fn => ({
|
|
107
|
-
f: fn,
|
|
108
|
-
selector: await FunctionSelector.fromNameAndParameters(fn.name, fn.parameters),
|
|
109
|
-
})),
|
|
110
|
-
);
|
|
111
|
-
const utilityFunctionArtifact = utilityFunctionsAndSelectors.find(fn => selector.equals(fn.selector))?.f;
|
|
112
|
-
if (!utilityFunctionArtifact) {
|
|
113
|
-
throw new Error(`Utility function with selector ${selector.toString()} not found`);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const {
|
|
117
|
-
artifactMetadataHash,
|
|
118
|
-
artifactTreeLeafIndex,
|
|
119
|
-
artifactTreeSiblingPath,
|
|
120
|
-
functionMetadataHash,
|
|
121
|
-
privateFunctionsArtifactTreeRoot,
|
|
122
|
-
} = await createUtilityFunctionMembershipProof(selector, artifact);
|
|
123
|
-
|
|
124
|
-
const classRegistry = ContractClassRegistryContract.at(wallet);
|
|
125
|
-
const bytecode = bufferAsFields(
|
|
126
|
-
utilityFunctionArtifact.bytecode,
|
|
127
|
-
MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS,
|
|
128
|
-
);
|
|
129
|
-
return classRegistry.methods
|
|
130
|
-
.broadcast_utility_function(
|
|
131
|
-
contractClass.id,
|
|
132
|
-
artifactMetadataHash,
|
|
133
|
-
privateFunctionsArtifactTreeRoot,
|
|
134
|
-
padArrayEnd(artifactTreeSiblingPath, Fr.ZERO, ARTIFACT_FUNCTION_TREE_MAX_HEIGHT),
|
|
135
|
-
artifactTreeLeafIndex,
|
|
136
|
-
// eslint-disable-next-line camelcase
|
|
137
|
-
{ selector, metadata_hash: functionMetadataHash },
|
|
138
|
-
)
|
|
139
|
-
.with({
|
|
140
|
-
capsules: [
|
|
141
|
-
new Capsule(
|
|
142
|
-
ProtocolContractAddress.ContractClassRegistry,
|
|
143
|
-
new Fr(CONTRACT_CLASS_REGISTRY_BYTECODE_CAPSULE_SLOT),
|
|
144
|
-
bytecode,
|
|
145
|
-
),
|
|
146
|
-
],
|
|
147
|
-
});
|
|
148
|
-
}
|