@aztec/protocol-contracts 4.0.0-nightly.20250907 → 4.0.0-nightly.20260107
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/artifacts/AuthRegistry.json +1521 -1611
- package/artifacts/ContractClassRegistry.json +3565 -5273
- package/artifacts/ContractInstanceRegistry.json +1502 -1481
- package/artifacts/FeeJuice.json +3148 -1197
- package/artifacts/MultiCallEntrypoint.json +1156 -1116
- package/artifacts/Router.json +332 -3990
- package/dest/auth-registry/index.d.ts +1 -1
- package/dest/auth-registry/lazy.d.ts +1 -1
- package/dest/auth-registry/lazy.js +4 -4
- package/dest/class-registry/contract_class_published_event.d.ts +3 -2
- package/dest/class-registry/contract_class_published_event.d.ts.map +1 -1
- package/dest/class-registry/contract_class_published_event.js +4 -0
- package/dest/class-registry/index.d.ts +1 -1
- package/dest/class-registry/lazy.d.ts +1 -1
- package/dest/class-registry/lazy.js +4 -4
- package/dest/class-registry/private_function_broadcasted_event.d.ts +2 -6
- package/dest/class-registry/private_function_broadcasted_event.d.ts.map +1 -1
- package/dest/class-registry/utility_function_broadcasted_event.d.ts +2 -5
- package/dest/class-registry/utility_function_broadcasted_event.d.ts.map +1 -1
- package/dest/class-registry/utility_function_broadcasted_event.js +1 -1
- package/dest/fee-juice/index.d.ts +2 -2
- package/dest/fee-juice/index.d.ts.map +1 -1
- package/dest/fee-juice/lazy.d.ts +1 -1
- package/dest/fee-juice/lazy.js +4 -4
- package/dest/index.d.ts +1 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +0 -1
- package/dest/instance-registry/contract_instance_published_event.d.ts +3 -2
- package/dest/instance-registry/contract_instance_published_event.d.ts.map +1 -1
- package/dest/instance-registry/contract_instance_published_event.js +4 -1
- package/dest/instance-registry/contract_instance_updated_event.d.ts +2 -2
- package/dest/instance-registry/contract_instance_updated_event.d.ts.map +1 -1
- package/dest/instance-registry/contract_instance_updated_event.js +5 -7
- package/dest/instance-registry/index.d.ts +1 -1
- package/dest/instance-registry/lazy.d.ts +1 -1
- package/dest/instance-registry/lazy.js +4 -4
- package/dest/make_protocol_contract.d.ts +1 -1
- package/dest/multi-call-entrypoint/index.d.ts +1 -1
- package/dest/multi-call-entrypoint/lazy.d.ts +1 -1
- package/dest/multi-call-entrypoint/lazy.js +4 -4
- package/dest/protocol_contract.d.ts +1 -1
- package/dest/protocol_contract_data.d.ts +12 -10
- package/dest/protocol_contract_data.d.ts.map +1 -1
- package/dest/protocol_contract_data.js +23 -9
- package/dest/provider/bundle.d.ts +1 -1
- package/dest/provider/bundle.d.ts.map +1 -1
- package/dest/provider/lazy.d.ts +1 -1
- package/dest/provider/lazy.d.ts.map +1 -1
- package/dest/provider/protocol_contracts_provider.d.ts +1 -1
- package/dest/router/index.d.ts +1 -1
- package/dest/router/lazy.d.ts +1 -1
- package/dest/router/lazy.js +4 -4
- package/dest/scripts/generate_data.js +33 -76
- package/dest/tests/fixtures.d.ts +1 -1
- package/package.json +10 -9
- package/src/auth-registry/lazy.ts +4 -4
- package/src/class-registry/contract_class_published_event.ts +8 -1
- package/src/class-registry/lazy.ts +4 -4
- package/src/class-registry/private_function_broadcasted_event.ts +1 -1
- package/src/class-registry/utility_function_broadcasted_event.ts +1 -1
- package/src/fee-juice/index.ts +1 -1
- package/src/fee-juice/lazy.ts +4 -4
- package/src/index.ts +0 -1
- package/src/instance-registry/contract_instance_published_event.ts +7 -1
- package/src/instance-registry/contract_instance_updated_event.ts +6 -8
- package/src/instance-registry/lazy.ts +4 -4
- package/src/multi-call-entrypoint/lazy.ts +4 -4
- package/src/protocol_contract_data.ts +24 -9
- package/src/router/lazy.ts +4 -4
- package/dest/build_protocol_contract_tree.d.ts +0 -10
- package/dest/build_protocol_contract_tree.d.ts.map +0 -1
- package/dest/build_protocol_contract_tree.js +0 -20
- package/dest/protocol_contract_tree.d.ts +0 -7
- package/dest/protocol_contract_tree.d.ts.map +0 -1
- package/dest/protocol_contract_tree.js +0 -34
- package/src/build_protocol_contract_tree.ts +0 -29
- package/src/protocol_contract_tree.ts +0 -44
package/dest/router/lazy.js
CHANGED
|
@@ -4,10 +4,10 @@ let protocolContract;
|
|
|
4
4
|
let protocolContractArtifact;
|
|
5
5
|
export async function getRouterArtifact() {
|
|
6
6
|
if (!protocolContractArtifact) {
|
|
7
|
-
// Cannot assert this import as it's incompatible with
|
|
8
|
-
// https://
|
|
9
|
-
//
|
|
10
|
-
//
|
|
7
|
+
// Cannot assert this import as it's incompatible with bundlers like vite
|
|
8
|
+
// https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
|
|
9
|
+
// Even if now supported by al major browsers, the MIME type is replaced with
|
|
10
|
+
// "text/javascript"
|
|
11
11
|
// In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
|
|
12
12
|
const { default: routerJson } = await import('../../artifacts/Router.json');
|
|
13
13
|
protocolContractArtifact = loadContractArtifact(routerJson);
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { CANONICAL_AUTH_REGISTRY_ADDRESS, CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS, CONTRACT_INSTANCE_PUBLISHED_MAGIC_VALUE, CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS, FEE_JUICE_ADDRESS, MULTI_CALL_ENTRYPOINT_ADDRESS, ROUTER_ADDRESS } from '@aztec/constants';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { CANONICAL_AUTH_REGISTRY_ADDRESS, CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS, CONTRACT_INSTANCE_PUBLISHED_MAGIC_VALUE, CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS, FEE_JUICE_ADDRESS, MAX_PROTOCOL_CONTRACTS, MULTI_CALL_ENTRYPOINT_ADDRESS, ROUTER_ADDRESS } from '@aztec/constants';
|
|
2
|
+
import { makeTuple } from '@aztec/foundation/array';
|
|
3
|
+
import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
|
|
4
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
5
|
import { createConsoleLogger } from '@aztec/foundation/log';
|
|
5
6
|
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
6
7
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
8
|
import { getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
|
|
9
|
+
import { ProtocolContracts } from '@aztec/stdlib/tx';
|
|
8
10
|
import { promises as fs } from 'fs';
|
|
9
11
|
import path from 'path';
|
|
10
|
-
import { buildProtocolContractTree } from '../build_protocol_contract_tree.js';
|
|
11
12
|
const log = createConsoleLogger('autogenerate');
|
|
12
13
|
const noirContractsRoot = '../../noir-projects/noir-contracts';
|
|
13
14
|
const srcPath = path.join(noirContractsRoot, './target');
|
|
14
15
|
const destArtifactsDir = './artifacts';
|
|
15
16
|
const outputFilePath = './src/protocol_contract_data.ts';
|
|
16
|
-
const cppOutputFilePath = '../../barretenberg/cpp/src/barretenberg/vm2/common/protocol_contract_data.hpp';
|
|
17
17
|
const salt = new Fr(1);
|
|
18
18
|
const contractAddressMapping = {
|
|
19
19
|
AuthRegistry: CANONICAL_AUTH_REGISTRY_ADDRESS,
|
|
@@ -23,14 +23,6 @@ const contractAddressMapping = {
|
|
|
23
23
|
FeeJuice: FEE_JUICE_ADDRESS,
|
|
24
24
|
Router: ROUTER_ADDRESS
|
|
25
25
|
};
|
|
26
|
-
const contractAddressNameMapping = {
|
|
27
|
-
AuthRegistry: 'CANONICAL_AUTH_REGISTRY_ADDRESS',
|
|
28
|
-
ContractInstanceRegistry: 'CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS',
|
|
29
|
-
ContractClassRegistry: 'CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS',
|
|
30
|
-
MultiCallEntrypoint: 'MULTI_CALL_ENTRYPOINT_ADDRESS',
|
|
31
|
-
FeeJuice: 'FEE_JUICE_ADDRESS',
|
|
32
|
-
Router: 'ROUTER_ADDRESS'
|
|
33
|
-
};
|
|
34
26
|
async function clearDestDir() {
|
|
35
27
|
try {
|
|
36
28
|
await fs.access(destArtifactsDir);
|
|
@@ -58,20 +50,12 @@ async function copyArtifact(srcName, destName) {
|
|
|
58
50
|
await fs.copyFile(src, dest);
|
|
59
51
|
return artifact;
|
|
60
52
|
}
|
|
61
|
-
async function
|
|
53
|
+
async function computeAddress(artifact) {
|
|
62
54
|
const instance = await getContractInstanceFromInstantiationParams(loadContractArtifact(artifact), {
|
|
63
55
|
salt
|
|
64
56
|
});
|
|
65
57
|
return instance.address;
|
|
66
58
|
}
|
|
67
|
-
async function computeRoot(names, leaves) {
|
|
68
|
-
const data = names.map((name, i)=>({
|
|
69
|
-
address: new AztecAddress(new Fr(contractAddressMapping[name])),
|
|
70
|
-
leaf: leaves[i]
|
|
71
|
-
}));
|
|
72
|
-
const tree = await buildProtocolContractTree(data);
|
|
73
|
-
return Fr.fromBuffer(tree.root);
|
|
74
|
-
}
|
|
75
59
|
async function generateDeclarationFile(destName) {
|
|
76
60
|
const content = `
|
|
77
61
|
import type { NoirCompiledContract } from '@aztec/stdlib/noir';
|
|
@@ -104,17 +88,30 @@ function generateContractAddresses(names) {
|
|
|
104
88
|
};
|
|
105
89
|
`;
|
|
106
90
|
}
|
|
107
|
-
function
|
|
91
|
+
function generateDerivedAddresses(names, derivedAddresses) {
|
|
108
92
|
return `
|
|
109
|
-
export const
|
|
110
|
-
${
|
|
93
|
+
export const ProtocolContractDerivedAddress = {
|
|
94
|
+
${derivedAddresses.map((address, i)=>`${names[i]}: AztecAddress.fromString('${address.toString()}')`).join(',\n')}
|
|
111
95
|
};
|
|
112
96
|
`;
|
|
113
97
|
}
|
|
114
|
-
async function
|
|
115
|
-
const
|
|
98
|
+
async function generateProtocolContractsList(names, derivedAddresses) {
|
|
99
|
+
const list = makeTuple(MAX_PROTOCOL_CONTRACTS, ()=>AztecAddress.zero());
|
|
100
|
+
for(let i = 0; i < names.length; i++){
|
|
101
|
+
const name = names[i];
|
|
102
|
+
const address = contractAddressMapping[name];
|
|
103
|
+
const derivedAddressIndex = address - 1;
|
|
104
|
+
if (!list[derivedAddressIndex].equals(AztecAddress.zero())) {
|
|
105
|
+
throw new Error(`Duplicate protocol contract address: ${address.toString()}`);
|
|
106
|
+
}
|
|
107
|
+
list[derivedAddressIndex] = derivedAddresses[i];
|
|
108
|
+
}
|
|
116
109
|
return `
|
|
117
|
-
export const
|
|
110
|
+
export const ProtocolContractsList = new ProtocolContracts([
|
|
111
|
+
${list.map((address)=>`AztecAddress.fromString('${address.toString()}')`).join(',\n')}
|
|
112
|
+
]);
|
|
113
|
+
|
|
114
|
+
export const protocolContractsHash = Fr.fromString('${(await new ProtocolContracts(list).hash()).toString()}');
|
|
118
115
|
`;
|
|
119
116
|
}
|
|
120
117
|
// Generate the siloed log tags for events emitted via private logs.
|
|
@@ -126,11 +123,12 @@ async function generateLogTags() {
|
|
|
126
123
|
])}');
|
|
127
124
|
`;
|
|
128
125
|
}
|
|
129
|
-
async function generateOutputFile(names,
|
|
126
|
+
async function generateOutputFile(names, derivedAddresses) {
|
|
130
127
|
const content = `
|
|
131
128
|
// GENERATED FILE - DO NOT EDIT. RUN \`yarn generate\` or \`yarn generate:data\`
|
|
132
|
-
import { Fr } from '@aztec/foundation/
|
|
129
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
133
130
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
131
|
+
import { ProtocolContracts } from '@aztec/stdlib/tx';
|
|
134
132
|
|
|
135
133
|
${generateNames(names)}
|
|
136
134
|
|
|
@@ -138,68 +136,27 @@ async function generateOutputFile(names, leaves) {
|
|
|
138
136
|
|
|
139
137
|
${generateContractAddresses(names)}
|
|
140
138
|
|
|
141
|
-
${
|
|
139
|
+
${generateDerivedAddresses(names, derivedAddresses)}
|
|
142
140
|
|
|
143
|
-
${await
|
|
141
|
+
${await generateProtocolContractsList(names, derivedAddresses)}
|
|
144
142
|
|
|
145
143
|
${await generateLogTags()}
|
|
146
144
|
`;
|
|
147
145
|
await fs.writeFile(outputFilePath, content);
|
|
148
146
|
}
|
|
149
|
-
async function generateHppOutputFile() {
|
|
150
|
-
const content = `// GENERATED FILE - DO NOT EDIT, RUN yarn generate in yarn-project/protocol-contracts
|
|
151
|
-
#pragma once
|
|
152
|
-
|
|
153
|
-
#include "barretenberg/vm2/common/aztec_constants.hpp"
|
|
154
|
-
#include "barretenberg/vm2/common/aztec_types.hpp"
|
|
155
|
-
|
|
156
|
-
#include <unordered_map>
|
|
157
|
-
|
|
158
|
-
namespace bb::avm2 {
|
|
159
|
-
|
|
160
|
-
using CanonicalAddress = AztecAddress;
|
|
161
|
-
using DerivedAddress = AztecAddress;
|
|
162
|
-
|
|
163
|
-
extern const std::unordered_map<CanonicalAddress, DerivedAddress> derived_addresses;
|
|
164
|
-
|
|
165
|
-
} // namespace bb::avm2
|
|
166
|
-
`;
|
|
167
|
-
await fs.writeFile(cppOutputFilePath, content);
|
|
168
|
-
}
|
|
169
|
-
async function generateCppOutputFile(names, leaves) {
|
|
170
|
-
await generateHppOutputFile();
|
|
171
|
-
const data = names.map((name, i)=>({
|
|
172
|
-
name: contractAddressNameMapping[name],
|
|
173
|
-
addr: leaves[i].toString()
|
|
174
|
-
}));
|
|
175
|
-
const content = `// GENERATED FILE - DO NOT EDIT, RUN yarn generate in yarn-project/protocol-contracts
|
|
176
|
-
#include "protocol_contract_data.hpp"
|
|
177
|
-
|
|
178
|
-
namespace bb::avm2 {
|
|
179
|
-
|
|
180
|
-
const std::unordered_map<CanonicalAddress, DerivedAddress> derived_addresses = {
|
|
181
|
-
${data.map(({ name, addr })=>`{ ${name}, AztecAddress("${addr}") }`).join(',\n\t')}
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
} // namespace bb::avm2
|
|
185
|
-
`;
|
|
186
|
-
await fs.writeFile(cppOutputFilePath.replace('.hpp', '.cpp'), content);
|
|
187
|
-
}
|
|
188
147
|
async function main() {
|
|
189
148
|
await clearDestDir();
|
|
190
149
|
const srcNames = JSON.parse(await fs.readFile(path.join(noirContractsRoot, 'protocol_contracts.json'), 'utf8'));
|
|
191
|
-
const
|
|
150
|
+
const derivedAddresses = [];
|
|
192
151
|
const destNames = srcNames.map((n)=>n.split('-')[1]);
|
|
193
152
|
for(let i = 0; i < srcNames.length; i++){
|
|
194
153
|
const srcName = srcNames[i];
|
|
195
154
|
const destName = destNames[i];
|
|
196
155
|
const artifact = await copyArtifact(srcName, destName);
|
|
197
156
|
await generateDeclarationFile(destName);
|
|
198
|
-
|
|
199
|
-
leaves.push(contractLeaf.toField());
|
|
157
|
+
derivedAddresses.push(await computeAddress(artifact));
|
|
200
158
|
}
|
|
201
|
-
await
|
|
202
|
-
await generateOutputFile(destNames, leaves);
|
|
159
|
+
await generateOutputFile(destNames, derivedAddresses);
|
|
203
160
|
}
|
|
204
161
|
try {
|
|
205
162
|
await main();
|
package/dest/tests/fixtures.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ export declare function getSamplePrivateFunctionBroadcastedEventPayload(): Buffe
|
|
|
3
3
|
export declare function getSampleUtilityFunctionBroadcastedEventPayload(): Buffer;
|
|
4
4
|
export declare function getSampleContractInstancePublishedEventPayload(): Buffer;
|
|
5
5
|
export declare function getPathToFixture(name: string): string;
|
|
6
|
-
//# sourceMappingURL=
|
|
6
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZml4dHVyZXMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90ZXN0cy9maXh0dXJlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFLQSx3QkFBZ0IsMkNBQTJDLElBQUksTUFBTSxDQUdwRTtBQUdELHdCQUFnQiwrQ0FBK0MsSUFBSSxNQUFNLENBR3hFO0FBR0Qsd0JBQWdCLCtDQUErQyxJQUFJLE1BQU0sQ0FHeEU7QUFHRCx3QkFBZ0IsOENBQThDLElBQUksTUFBTSxDQUd2RTtBQUVELHdCQUFnQixnQkFBZ0IsQ0FBQyxJQUFJLEVBQUUsTUFBTSxVQUU1QyJ9
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@aztec/protocol-contracts",
|
|
3
3
|
"homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/protocol-contracts",
|
|
4
4
|
"description": "Canonical Noir contracts for the Aztec Network",
|
|
5
|
-
"version": "4.0.0-nightly.
|
|
5
|
+
"version": "4.0.0-nightly.20260107",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./dest/index.js",
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
"tsconfig": "./tsconfig.json"
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
|
-
"build": "yarn clean && yarn generate && yarn generate:cleanup-artifacts && tsc
|
|
25
|
-
"build:keep-debug-symbols": "yarn clean && yarn generate &&
|
|
24
|
+
"build": "yarn clean && yarn generate && yarn generate:cleanup-artifacts && ../scripts/tsc.sh",
|
|
25
|
+
"build:keep-debug-symbols": "yarn clean && yarn generate && tsgo -b",
|
|
26
26
|
"generate": "yarn generate:data",
|
|
27
27
|
"generate:cleanup-artifacts": "node --no-warnings --loader @swc-node/register/esm src/scripts/cleanup_artifacts.ts",
|
|
28
28
|
"generate:data": "node --no-warnings --loader @swc-node/register/esm src/scripts/generate_data.ts",
|
|
29
|
-
"build:dev": "tsc
|
|
30
|
-
"build:ts": "
|
|
29
|
+
"build:dev": "../scripts/tsc.sh --watch",
|
|
30
|
+
"build:ts": "tsgo -b",
|
|
31
31
|
"clean": "rm -rf ./dest .tsbuildinfo ./artifacts",
|
|
32
32
|
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
|
|
33
33
|
},
|
|
@@ -73,9 +73,9 @@
|
|
|
73
73
|
]
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
|
-
"@aztec/constants": "4.0.0-nightly.
|
|
77
|
-
"@aztec/foundation": "4.0.0-nightly.
|
|
78
|
-
"@aztec/stdlib": "4.0.0-nightly.
|
|
76
|
+
"@aztec/constants": "4.0.0-nightly.20260107",
|
|
77
|
+
"@aztec/foundation": "4.0.0-nightly.20260107",
|
|
78
|
+
"@aztec/stdlib": "4.0.0-nightly.20260107",
|
|
79
79
|
"lodash.chunk": "^4.2.0",
|
|
80
80
|
"lodash.omit": "^4.5.0",
|
|
81
81
|
"tslib": "^2.4.0"
|
|
@@ -86,9 +86,10 @@
|
|
|
86
86
|
"@types/lodash.chunk": "^4.2.9",
|
|
87
87
|
"@types/lodash.omit": "^4.5.9",
|
|
88
88
|
"@types/node": "^22.15.17",
|
|
89
|
+
"@typescript/native-preview": "7.0.0-dev.20251126.1",
|
|
89
90
|
"jest": "^30.0.0",
|
|
90
91
|
"jest-mock-extended": "^4.0.0",
|
|
91
|
-
"ts-loader": "^9.
|
|
92
|
+
"ts-loader": "^9.5.4",
|
|
92
93
|
"ts-node": "^10.9.1",
|
|
93
94
|
"typescript": "^5.3.3"
|
|
94
95
|
},
|
|
@@ -8,10 +8,10 @@ let protocolContractArtifact: ContractArtifact;
|
|
|
8
8
|
|
|
9
9
|
export async function getAuthRegistryArtifact(): Promise<ContractArtifact> {
|
|
10
10
|
if (!protocolContractArtifact) {
|
|
11
|
-
// Cannot assert this import as it's incompatible with
|
|
12
|
-
// https://
|
|
13
|
-
//
|
|
14
|
-
//
|
|
11
|
+
// Cannot assert this import as it's incompatible with bundlers like vite
|
|
12
|
+
// https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
|
|
13
|
+
// Even if now supported by al major browsers, the MIME type is replaced with
|
|
14
|
+
// "text/javascript"
|
|
15
15
|
// In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
|
|
16
16
|
const { default: authRegistryJson } = await import('../../artifacts/AuthRegistry.json');
|
|
17
17
|
protocolContractArtifact = loadContractArtifact(authRegistryJson);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CONTRACT_CLASS_PUBLISHED_MAGIC_VALUE } from '@aztec/constants';
|
|
2
|
-
import { Fr } from '@aztec/foundation/
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { FieldReader } from '@aztec/foundation/serialize';
|
|
4
4
|
import { bufferFromFields } from '@aztec/stdlib/abi';
|
|
5
5
|
import {
|
|
@@ -29,6 +29,7 @@ export class ContractClassPublishedEvent {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
static fromLog(log: ContractClassLog) {
|
|
32
|
+
// See how the log is serialized in `noir-projects/noir-contracts/contracts/protocol/contract_class_registry/src/events/class_published.nr`.
|
|
32
33
|
const fieldsWithoutTag = log.fields.fields.slice(1);
|
|
33
34
|
const reader = new FieldReader(fieldsWithoutTag);
|
|
34
35
|
const contractClassId = reader.readField();
|
|
@@ -73,4 +74,10 @@ export class ContractClassPublishedEvent {
|
|
|
73
74
|
utilityFunctions: [],
|
|
74
75
|
};
|
|
75
76
|
}
|
|
77
|
+
|
|
78
|
+
public static extractContractClassEvents(logs: ContractClassLog[]): ContractClassPublishedEvent[] {
|
|
79
|
+
return logs
|
|
80
|
+
.filter((log: ContractClassLog) => ContractClassPublishedEvent.isContractClassPublishedEvent(log))
|
|
81
|
+
.map((log: ContractClassLog) => ContractClassPublishedEvent.fromLog(log));
|
|
82
|
+
}
|
|
76
83
|
}
|
|
@@ -12,10 +12,10 @@ let protocolContractArtifact: ContractArtifact;
|
|
|
12
12
|
|
|
13
13
|
export async function getContractClassRegistryArtifact(): Promise<ContractArtifact> {
|
|
14
14
|
if (!protocolContractArtifact) {
|
|
15
|
-
// Cannot assert this import as it's incompatible with
|
|
16
|
-
// https://
|
|
17
|
-
//
|
|
18
|
-
//
|
|
15
|
+
// Cannot assert this import as it's incompatible with bundlers like vite
|
|
16
|
+
// https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
|
|
17
|
+
// Even if now supported by al major browsers, the MIME type is replaced with
|
|
18
|
+
// "text/javascript"
|
|
19
19
|
// In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
|
|
20
20
|
const { default: contractClassRegistryJson } = await import('../../artifacts/ContractClassRegistry.json');
|
|
21
21
|
protocolContractArtifact = loadContractArtifact(contractClassRegistryJson);
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
FUNCTION_TREE_HEIGHT,
|
|
5
5
|
MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS,
|
|
6
6
|
} from '@aztec/constants';
|
|
7
|
-
import { Fr } from '@aztec/foundation/
|
|
7
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
8
8
|
import type { Tuple } from '@aztec/foundation/serialize';
|
|
9
9
|
import { FieldReader } from '@aztec/foundation/serialize';
|
|
10
10
|
import { FunctionSelector, bufferFromFields } from '@aztec/stdlib/abi';
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
MAX_PACKED_BYTECODE_SIZE_PER_UTILITY_FUNCTION_IN_FIELDS,
|
|
5
5
|
} from '@aztec/constants';
|
|
6
6
|
import { removeArrayPaddingEnd } from '@aztec/foundation/collection';
|
|
7
|
-
import { Fr } from '@aztec/foundation/
|
|
7
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
8
8
|
import type { Tuple } from '@aztec/foundation/serialize';
|
|
9
9
|
import { FieldReader } from '@aztec/foundation/serialize';
|
|
10
10
|
import { FunctionSelector, bufferFromFields } from '@aztec/stdlib/abi';
|
package/src/fee-juice/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Fr } from '@aztec/foundation/
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
3
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import { computePublicDataTreeLeafSlot, deriveStorageSlotInMap } from '@aztec/stdlib/hash';
|
package/src/fee-juice/lazy.ts
CHANGED
|
@@ -8,10 +8,10 @@ let protocolContractArtifact: ContractArtifact;
|
|
|
8
8
|
|
|
9
9
|
export async function getFeeJuiceArtifact(): Promise<ContractArtifact> {
|
|
10
10
|
if (!protocolContractArtifact) {
|
|
11
|
-
// Cannot assert this import as it's incompatible with
|
|
12
|
-
// https://
|
|
13
|
-
//
|
|
14
|
-
//
|
|
11
|
+
// Cannot assert this import as it's incompatible with bundlers like vite
|
|
12
|
+
// https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
|
|
13
|
+
// Even if now supported by al major browsers, the MIME type is replaced with
|
|
14
|
+
// "text/javascript"
|
|
15
15
|
// In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
|
|
16
16
|
const { default: feeJuiceJson } = await import('../../artifacts/FeeJuice.json');
|
|
17
17
|
protocolContractArtifact = loadContractArtifact(feeJuiceJson);
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import { BufferReader } from '@aztec/foundation/serialize';
|
|
3
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
@@ -61,4 +61,10 @@ export class ContractInstancePublishedEvent {
|
|
|
61
61
|
deployer: this.deployer,
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
+
|
|
65
|
+
public static extractContractInstanceEvents(logs: PrivateLog[]): ContractInstancePublishedEvent[] {
|
|
66
|
+
return logs
|
|
67
|
+
.filter(log => ContractInstancePublishedEvent.isContractInstancePublishedEvent(log))
|
|
68
|
+
.map(log => ContractInstancePublishedEvent.fromLog(log));
|
|
69
|
+
}
|
|
64
70
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CONTRACT_INSTANCE_UPDATED_MAGIC_VALUE } from '@aztec/constants';
|
|
2
|
-
import { Fr } from '@aztec/foundation/
|
|
3
|
-
import {
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
+
import { FieldReader } from '@aztec/foundation/serialize';
|
|
4
4
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
5
|
import type { ContractInstanceUpdateWithAddress } from '@aztec/stdlib/contract';
|
|
6
6
|
import type { PublicLog } from '@aztec/stdlib/logs';
|
|
@@ -25,13 +25,11 @@ export class ContractInstanceUpdatedEvent {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
static fromLog(log: PublicLog) {
|
|
28
|
-
const
|
|
29
|
-
const reader = new BufferReader(bufferWithoutAddressAndTag);
|
|
28
|
+
const reader = new FieldReader(log.fields.slice(1) /* remove tag */);
|
|
30
29
|
const address = reader.readObject(AztecAddress);
|
|
31
|
-
const prevContractClassId = reader.
|
|
32
|
-
const newContractClassId = reader.
|
|
33
|
-
const timestampOfChange = reader.
|
|
34
|
-
|
|
30
|
+
const prevContractClassId = reader.readField();
|
|
31
|
+
const newContractClassId = reader.readField();
|
|
32
|
+
const timestampOfChange = reader.readField().toBigInt();
|
|
35
33
|
return new ContractInstanceUpdatedEvent(address, prevContractClassId, newContractClassId, timestampOfChange);
|
|
36
34
|
}
|
|
37
35
|
|
|
@@ -11,10 +11,10 @@ let protocolContractArtifact: ContractArtifact;
|
|
|
11
11
|
|
|
12
12
|
export async function getContractInstanceRegistryArtifact(): Promise<ContractArtifact> {
|
|
13
13
|
if (!protocolContractArtifact) {
|
|
14
|
-
// Cannot assert this import as it's incompatible with
|
|
15
|
-
// https://
|
|
16
|
-
//
|
|
17
|
-
//
|
|
14
|
+
// Cannot assert this import as it's incompatible with bundlers like vite
|
|
15
|
+
// https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
|
|
16
|
+
// Even if now supported by al major browsers, the MIME type is replaced with
|
|
17
|
+
// "text/javascript"
|
|
18
18
|
// In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
|
|
19
19
|
const { default: contractInstanceRegistryJson } = await import('../../artifacts/ContractInstanceRegistry.json');
|
|
20
20
|
protocolContractArtifact = loadContractArtifact(contractInstanceRegistryJson);
|
|
@@ -8,10 +8,10 @@ let protocolContractArtifact: ContractArtifact;
|
|
|
8
8
|
|
|
9
9
|
export async function getMultiCallEntrypointArtifact(): Promise<ContractArtifact> {
|
|
10
10
|
if (!protocolContractArtifact) {
|
|
11
|
-
// Cannot assert this import as it's incompatible with
|
|
12
|
-
// https://
|
|
13
|
-
//
|
|
14
|
-
//
|
|
11
|
+
// Cannot assert this import as it's incompatible with bundlers like vite
|
|
12
|
+
// https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
|
|
13
|
+
// Even if now supported by al major browsers, the MIME type is replaced with
|
|
14
|
+
// "text/javascript"
|
|
15
15
|
// In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
|
|
16
16
|
const { default: multiCallEntrypointJson } = await import('../../artifacts/MultiCallEntrypoint.json');
|
|
17
17
|
protocolContractArtifact = loadContractArtifact(multiCallEntrypointJson);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
// GENERATED FILE - DO NOT EDIT. RUN `yarn generate` or `yarn generate:data`
|
|
3
|
-
import { Fr } from '@aztec/foundation/
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
4
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
+
import { ProtocolContracts } from '@aztec/stdlib/tx';
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
export const protocolContractNames = [
|
|
@@ -39,18 +40,32 @@ Router: AztecAddress.fromBigInt(6n)
|
|
|
39
40
|
|
|
40
41
|
|
|
41
42
|
|
|
42
|
-
export const
|
|
43
|
-
AuthRegistry:
|
|
44
|
-
ContractInstanceRegistry:
|
|
45
|
-
ContractClassRegistry:
|
|
46
|
-
MultiCallEntrypoint:
|
|
47
|
-
FeeJuice:
|
|
48
|
-
Router:
|
|
43
|
+
export const ProtocolContractDerivedAddress = {
|
|
44
|
+
AuthRegistry: AztecAddress.fromString('0x121238ed308425d738ff26b3e38d2c225831ec84b86c75674c11a02a37fd23d2'),
|
|
45
|
+
ContractInstanceRegistry: AztecAddress.fromString('0x01fe9f10f75d1144d4f639cd1343f21dd6704d625862c656289d8d469260c8ec'),
|
|
46
|
+
ContractClassRegistry: AztecAddress.fromString('0x0644acbac1f08ca31c11c7ba5a499d5712df7328bef937abc2218939480888fd'),
|
|
47
|
+
MultiCallEntrypoint: AztecAddress.fromString('0x1942206ea40e346bc3d1199bd18d3fb195b9e55783555257ecec39cff517f07c'),
|
|
48
|
+
FeeJuice: AztecAddress.fromString('0x1372bed10ea17c9fa328aee7dde99c400acb65317dba45c38e27038ac01753a9'),
|
|
49
|
+
Router: AztecAddress.fromString('0x12b0c529d7c93c7bc94d3e08cf26c39c810762a91d2bbce2fc294706fe86028e')
|
|
49
50
|
};
|
|
50
51
|
|
|
51
52
|
|
|
52
53
|
|
|
53
|
-
export const
|
|
54
|
+
export const ProtocolContractsList = new ProtocolContracts([
|
|
55
|
+
AztecAddress.fromString('0x121238ed308425d738ff26b3e38d2c225831ec84b86c75674c11a02a37fd23d2'),
|
|
56
|
+
AztecAddress.fromString('0x01fe9f10f75d1144d4f639cd1343f21dd6704d625862c656289d8d469260c8ec'),
|
|
57
|
+
AztecAddress.fromString('0x0644acbac1f08ca31c11c7ba5a499d5712df7328bef937abc2218939480888fd'),
|
|
58
|
+
AztecAddress.fromString('0x1942206ea40e346bc3d1199bd18d3fb195b9e55783555257ecec39cff517f07c'),
|
|
59
|
+
AztecAddress.fromString('0x1372bed10ea17c9fa328aee7dde99c400acb65317dba45c38e27038ac01753a9'),
|
|
60
|
+
AztecAddress.fromString('0x12b0c529d7c93c7bc94d3e08cf26c39c810762a91d2bbce2fc294706fe86028e'),
|
|
61
|
+
AztecAddress.fromString('0x0000000000000000000000000000000000000000000000000000000000000000'),
|
|
62
|
+
AztecAddress.fromString('0x0000000000000000000000000000000000000000000000000000000000000000'),
|
|
63
|
+
AztecAddress.fromString('0x0000000000000000000000000000000000000000000000000000000000000000'),
|
|
64
|
+
AztecAddress.fromString('0x0000000000000000000000000000000000000000000000000000000000000000'),
|
|
65
|
+
AztecAddress.fromString('0x0000000000000000000000000000000000000000000000000000000000000000')
|
|
66
|
+
]);
|
|
67
|
+
|
|
68
|
+
export const protocolContractsHash = Fr.fromString('0x212efcf7079dce4d9696a3c5a3e742b46bfacbc842c274109cc2c7564760c4f0');
|
|
54
69
|
|
|
55
70
|
|
|
56
71
|
|
package/src/router/lazy.ts
CHANGED
|
@@ -8,10 +8,10 @@ let protocolContractArtifact: ContractArtifact;
|
|
|
8
8
|
|
|
9
9
|
export async function getRouterArtifact(): Promise<ContractArtifact> {
|
|
10
10
|
if (!protocolContractArtifact) {
|
|
11
|
-
// Cannot assert this import as it's incompatible with
|
|
12
|
-
// https://
|
|
13
|
-
//
|
|
14
|
-
//
|
|
11
|
+
// Cannot assert this import as it's incompatible with bundlers like vite
|
|
12
|
+
// https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
|
|
13
|
+
// Even if now supported by al major browsers, the MIME type is replaced with
|
|
14
|
+
// "text/javascript"
|
|
15
15
|
// In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
|
|
16
16
|
const { default: routerJson } = await import('../../artifacts/Router.json');
|
|
17
17
|
protocolContractArtifact = loadContractArtifact(routerJson);
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { PROTOCOL_CONTRACT_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
-
import type { Fr } from '@aztec/foundation/fields';
|
|
3
|
-
import { type IndexedMerkleTree } from '@aztec/foundation/trees';
|
|
4
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
-
import { ProtocolContractLeafPreimage } from '@aztec/stdlib/trees';
|
|
6
|
-
export declare function buildProtocolContractTree(contracts: {
|
|
7
|
-
address: AztecAddress;
|
|
8
|
-
leaf: Fr;
|
|
9
|
-
}[]): Promise<IndexedMerkleTree<ProtocolContractLeafPreimage, typeof PROTOCOL_CONTRACT_TREE_HEIGHT>>;
|
|
10
|
-
//# sourceMappingURL=build_protocol_contract_tree.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build_protocol_contract_tree.d.ts","sourceRoot":"","sources":["../src/build_protocol_contract_tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,6BAA6B,EAAE,MAAM,kBAAkB,CAAC;AAEzF,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,KAAK,iBAAiB,EAA+B,MAAM,yBAAyB,CAAC;AAC9F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAEnE,wBAAsB,yBAAyB,CAC7C,SAAS,EAAE;IAAE,OAAO,EAAE,YAAY,CAAC;IAAC,IAAI,EAAE,EAAE,CAAA;CAAE,EAAE,GAC/C,OAAO,CAAC,iBAAiB,CAAC,4BAA4B,EAAE,OAAO,6BAA6B,CAAC,CAAC,CAmBhG"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { MAX_PROTOCOL_CONTRACTS, PROTOCOL_CONTRACT_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
-
import { poseidon2Hash } from '@aztec/foundation/crypto';
|
|
3
|
-
import { IndexedMerkleTreeCalculator } from '@aztec/foundation/trees';
|
|
4
|
-
import { ProtocolContractLeafPreimage } from '@aztec/stdlib/trees';
|
|
5
|
-
export async function buildProtocolContractTree(contracts) {
|
|
6
|
-
const hasher = {
|
|
7
|
-
hash: async (l, r)=>(await poseidon2Hash([
|
|
8
|
-
l,
|
|
9
|
-
r
|
|
10
|
-
])).toBuffer(),
|
|
11
|
-
hashInputs: async (i)=>(await poseidon2Hash(i)).toBuffer()
|
|
12
|
-
};
|
|
13
|
-
const calculator = await IndexedMerkleTreeCalculator.create(PROTOCOL_CONTRACT_TREE_HEIGHT, hasher, ProtocolContractLeafPreimage);
|
|
14
|
-
const leaves = new Array(MAX_PROTOCOL_CONTRACTS).fill(Buffer.alloc(32));
|
|
15
|
-
for (const contract of contracts){
|
|
16
|
-
const index = contract.address.toField().toNumber();
|
|
17
|
-
leaves[index] = contract.leaf.toBuffer();
|
|
18
|
-
}
|
|
19
|
-
return calculator.computeTree(leaves);
|
|
20
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
2
|
-
import type { ProtocolContractLeafPreimage } from '@aztec/stdlib/trees';
|
|
3
|
-
export declare function getProtocolContractLeafAndMembershipWitness(contractAddress: AztecAddress, computedAddress: AztecAddress): Promise<{
|
|
4
|
-
lowLeaf: ProtocolContractLeafPreimage;
|
|
5
|
-
witness: import("@aztec/foundation/trees").MembershipWitness<3>;
|
|
6
|
-
}>;
|
|
7
|
-
//# sourceMappingURL=protocol_contract_tree.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"protocol_contract_tree.d.ts","sourceRoot":"","sources":["../src/protocol_contract_tree.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAsBxE,wBAAsB,2CAA2C,CAC/D,eAAe,EAAE,YAAY,EAC7B,eAAe,EAAE,YAAY;;;GAe9B"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { poseidon2Hash } from '@aztec/foundation/crypto';
|
|
2
|
-
import { buildProtocolContractTree } from './build_protocol_contract_tree.js';
|
|
3
|
-
import { isProtocolContract } from './protocol_contract.js';
|
|
4
|
-
import { ProtocolContractAddress, ProtocolContractLeaves, protocolContractNames } from './protocol_contract_data.js';
|
|
5
|
-
let protocolContractTree;
|
|
6
|
-
async function getTree() {
|
|
7
|
-
if (!protocolContractTree) {
|
|
8
|
-
const leaves = protocolContractNames.map((name)=>({
|
|
9
|
-
address: ProtocolContractAddress[name],
|
|
10
|
-
leaf: ProtocolContractLeaves[name]
|
|
11
|
-
}));
|
|
12
|
-
protocolContractTree = await buildProtocolContractTree(leaves);
|
|
13
|
-
}
|
|
14
|
-
return protocolContractTree;
|
|
15
|
-
}
|
|
16
|
-
// Computed address can be different from contract address due to upgrades
|
|
17
|
-
export async function getProtocolContractLeafAndMembershipWitness(contractAddress, computedAddress) {
|
|
18
|
-
const tree = await getTree();
|
|
19
|
-
let lowLeaf;
|
|
20
|
-
let witness;
|
|
21
|
-
if (isProtocolContract(contractAddress)) {
|
|
22
|
-
const index = contractAddress.toField().toNumber();
|
|
23
|
-
lowLeaf = tree.leafPreimages[index];
|
|
24
|
-
witness = tree.getMembershipWitness(index);
|
|
25
|
-
} else {
|
|
26
|
-
lowLeaf = tree.getLowLeaf(computedAddress.toBigInt());
|
|
27
|
-
const hashed = (await poseidon2Hash(lowLeaf.toHashInputs())).toBuffer();
|
|
28
|
-
witness = tree.getMembershipWitness(hashed);
|
|
29
|
-
}
|
|
30
|
-
return {
|
|
31
|
-
lowLeaf,
|
|
32
|
-
witness
|
|
33
|
-
};
|
|
34
|
-
}
|