@aztec/protocol-contracts 3.0.0-canary.a9708bd → 3.0.0-devnet.2-patch.1
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 +870 -833
- package/artifacts/ContractClassRegistry.json +941 -2661
- package/artifacts/ContractInstanceRegistry.json +965 -956
- package/artifacts/FeeJuice.json +2451 -508
- package/artifacts/MultiCallEntrypoint.json +424 -396
- package/artifacts/Router.json +360 -4030
- 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 -27
- 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,13 +1,14 @@
|
|
|
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');
|
|
@@ -49,20 +50,12 @@ async function copyArtifact(srcName, destName) {
|
|
|
49
50
|
await fs.copyFile(src, dest);
|
|
50
51
|
return artifact;
|
|
51
52
|
}
|
|
52
|
-
async function
|
|
53
|
+
async function computeAddress(artifact) {
|
|
53
54
|
const instance = await getContractInstanceFromInstantiationParams(loadContractArtifact(artifact), {
|
|
54
55
|
salt
|
|
55
56
|
});
|
|
56
57
|
return instance.address;
|
|
57
58
|
}
|
|
58
|
-
async function computeRoot(names, leaves) {
|
|
59
|
-
const data = names.map((name, i)=>({
|
|
60
|
-
address: new AztecAddress(new Fr(contractAddressMapping[name])),
|
|
61
|
-
leaf: leaves[i]
|
|
62
|
-
}));
|
|
63
|
-
const tree = await buildProtocolContractTree(data);
|
|
64
|
-
return Fr.fromBuffer(tree.root);
|
|
65
|
-
}
|
|
66
59
|
async function generateDeclarationFile(destName) {
|
|
67
60
|
const content = `
|
|
68
61
|
import type { NoirCompiledContract } from '@aztec/stdlib/noir';
|
|
@@ -95,17 +88,30 @@ function generateContractAddresses(names) {
|
|
|
95
88
|
};
|
|
96
89
|
`;
|
|
97
90
|
}
|
|
98
|
-
function
|
|
91
|
+
function generateDerivedAddresses(names, derivedAddresses) {
|
|
99
92
|
return `
|
|
100
|
-
export const
|
|
101
|
-
${
|
|
93
|
+
export const ProtocolContractDerivedAddress = {
|
|
94
|
+
${derivedAddresses.map((address, i)=>`${names[i]}: AztecAddress.fromString('${address.toString()}')`).join(',\n')}
|
|
102
95
|
};
|
|
103
96
|
`;
|
|
104
97
|
}
|
|
105
|
-
async function
|
|
106
|
-
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
|
+
}
|
|
107
109
|
return `
|
|
108
|
-
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()}');
|
|
109
115
|
`;
|
|
110
116
|
}
|
|
111
117
|
// Generate the siloed log tags for events emitted via private logs.
|
|
@@ -117,11 +123,12 @@ async function generateLogTags() {
|
|
|
117
123
|
])}');
|
|
118
124
|
`;
|
|
119
125
|
}
|
|
120
|
-
async function generateOutputFile(names,
|
|
126
|
+
async function generateOutputFile(names, derivedAddresses) {
|
|
121
127
|
const content = `
|
|
122
128
|
// GENERATED FILE - DO NOT EDIT. RUN \`yarn generate\` or \`yarn generate:data\`
|
|
123
|
-
import { Fr } from '@aztec/foundation/
|
|
129
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
124
130
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
131
|
+
import { ProtocolContracts } from '@aztec/stdlib/tx';
|
|
125
132
|
|
|
126
133
|
${generateNames(names)}
|
|
127
134
|
|
|
@@ -129,9 +136,9 @@ async function generateOutputFile(names, leaves) {
|
|
|
129
136
|
|
|
130
137
|
${generateContractAddresses(names)}
|
|
131
138
|
|
|
132
|
-
${
|
|
139
|
+
${generateDerivedAddresses(names, derivedAddresses)}
|
|
133
140
|
|
|
134
|
-
${await
|
|
141
|
+
${await generateProtocolContractsList(names, derivedAddresses)}
|
|
135
142
|
|
|
136
143
|
${await generateLogTags()}
|
|
137
144
|
`;
|
|
@@ -140,17 +147,16 @@ async function generateOutputFile(names, leaves) {
|
|
|
140
147
|
async function main() {
|
|
141
148
|
await clearDestDir();
|
|
142
149
|
const srcNames = JSON.parse(await fs.readFile(path.join(noirContractsRoot, 'protocol_contracts.json'), 'utf8'));
|
|
143
|
-
const
|
|
150
|
+
const derivedAddresses = [];
|
|
144
151
|
const destNames = srcNames.map((n)=>n.split('-')[1]);
|
|
145
152
|
for(let i = 0; i < srcNames.length; i++){
|
|
146
153
|
const srcName = srcNames[i];
|
|
147
154
|
const destName = destNames[i];
|
|
148
155
|
const artifact = await copyArtifact(srcName, destName);
|
|
149
156
|
await generateDeclarationFile(destName);
|
|
150
|
-
|
|
151
|
-
leaves.push(contractLeaf.toField());
|
|
157
|
+
derivedAddresses.push(await computeAddress(artifact));
|
|
152
158
|
}
|
|
153
|
-
await generateOutputFile(destNames,
|
|
159
|
+
await generateOutputFile(destNames, derivedAddresses);
|
|
154
160
|
}
|
|
155
161
|
try {
|
|
156
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": "3.0.0-
|
|
5
|
+
"version": "3.0.0-devnet.2-patch.1",
|
|
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": "3.0.0-
|
|
77
|
-
"@aztec/foundation": "3.0.0-
|
|
78
|
-
"@aztec/stdlib": "3.0.0-
|
|
76
|
+
"@aztec/constants": "3.0.0-devnet.2-patch.1",
|
|
77
|
+
"@aztec/foundation": "3.0.0-devnet.2-patch.1",
|
|
78
|
+
"@aztec/stdlib": "3.0.0-devnet.2-patch.1",
|
|
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('0x154bc3dc5cea44ef4c3d3578cdce2f81f34300d2d7819a8d72ef0d4d135cdfd4'),
|
|
45
|
+
ContractInstanceRegistry: AztecAddress.fromString('0x04265e72412c0b74d741e805252a0cb54e703a68f513cd91306ad0b400a24b0d'),
|
|
46
|
+
ContractClassRegistry: AztecAddress.fromString('0x0b7a3b99c7051ee329d2c905b9f646d3706ed031fa1f97b0c19274e5773ebec5'),
|
|
47
|
+
MultiCallEntrypoint: AztecAddress.fromString('0x0961995245e0f34801e7ca5e83a0a6fbf2d78cfce788134b6ef6e877715d594a'),
|
|
48
|
+
FeeJuice: AztecAddress.fromString('0x13d932791f9e77dce1dcbdbb0a562ceab5dcb491866905471cf7cfc1136001b0'),
|
|
49
|
+
Router: AztecAddress.fromString('0x2fed59e101da3e1f0f7e959fd154d042ca447729a80925faf4da42bc8ff05865')
|
|
49
50
|
};
|
|
50
51
|
|
|
51
52
|
|
|
52
53
|
|
|
53
|
-
export const
|
|
54
|
+
export const ProtocolContractsList = new ProtocolContracts([
|
|
55
|
+
AztecAddress.fromString('0x154bc3dc5cea44ef4c3d3578cdce2f81f34300d2d7819a8d72ef0d4d135cdfd4'),
|
|
56
|
+
AztecAddress.fromString('0x04265e72412c0b74d741e805252a0cb54e703a68f513cd91306ad0b400a24b0d'),
|
|
57
|
+
AztecAddress.fromString('0x0b7a3b99c7051ee329d2c905b9f646d3706ed031fa1f97b0c19274e5773ebec5'),
|
|
58
|
+
AztecAddress.fromString('0x0961995245e0f34801e7ca5e83a0a6fbf2d78cfce788134b6ef6e877715d594a'),
|
|
59
|
+
AztecAddress.fromString('0x13d932791f9e77dce1dcbdbb0a562ceab5dcb491866905471cf7cfc1136001b0'),
|
|
60
|
+
AztecAddress.fromString('0x2fed59e101da3e1f0f7e959fd154d042ca447729a80925faf4da42bc8ff05865'),
|
|
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('0x2348b12e0edd63c38dbb849b6c788c4975ed3f1f3706fcb5e17431e805da672d');
|
|
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
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { MAX_PROTOCOL_CONTRACTS, PROTOCOL_CONTRACT_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
-
import { poseidon2Hash } from '@aztec/foundation/crypto';
|
|
3
|
-
import type { Fr } from '@aztec/foundation/fields';
|
|
4
|
-
import { type IndexedMerkleTree, IndexedMerkleTreeCalculator } from '@aztec/foundation/trees';
|
|
5
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
-
import { ProtocolContractLeafPreimage } from '@aztec/stdlib/trees';
|
|
7
|
-
|
|
8
|
-
export async function buildProtocolContractTree(
|
|
9
|
-
contracts: { address: AztecAddress; leaf: Fr }[],
|
|
10
|
-
): Promise<IndexedMerkleTree<ProtocolContractLeafPreimage, typeof PROTOCOL_CONTRACT_TREE_HEIGHT>> {
|
|
11
|
-
const hasher = {
|
|
12
|
-
hash: async (l: Buffer, r: Buffer) => (await poseidon2Hash([l, r])).toBuffer() as Buffer<ArrayBuffer>,
|
|
13
|
-
hashInputs: async (i: Buffer[]) => (await poseidon2Hash(i)).toBuffer() as Buffer<ArrayBuffer>,
|
|
14
|
-
};
|
|
15
|
-
const calculator = await IndexedMerkleTreeCalculator.create(
|
|
16
|
-
PROTOCOL_CONTRACT_TREE_HEIGHT,
|
|
17
|
-
hasher,
|
|
18
|
-
ProtocolContractLeafPreimage,
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
const leaves = new Array(MAX_PROTOCOL_CONTRACTS).fill(Buffer.alloc(32));
|
|
22
|
-
|
|
23
|
-
for (const contract of contracts) {
|
|
24
|
-
const index = contract.address.toField().toNumber();
|
|
25
|
-
leaves[index] = contract.leaf.toBuffer();
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return calculator.computeTree(leaves);
|
|
29
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { PROTOCOL_CONTRACT_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
-
import { poseidon2Hash } from '@aztec/foundation/crypto';
|
|
3
|
-
import type { IndexedMerkleTree } from '@aztec/foundation/trees';
|
|
4
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
-
import type { ProtocolContractLeafPreimage } from '@aztec/stdlib/trees';
|
|
6
|
-
|
|
7
|
-
import { buildProtocolContractTree } from './build_protocol_contract_tree.js';
|
|
8
|
-
import { isProtocolContract } from './protocol_contract.js';
|
|
9
|
-
import { ProtocolContractAddress, ProtocolContractLeaves, protocolContractNames } from './protocol_contract_data.js';
|
|
10
|
-
|
|
11
|
-
let protocolContractTree:
|
|
12
|
-
| IndexedMerkleTree<ProtocolContractLeafPreimage, typeof PROTOCOL_CONTRACT_TREE_HEIGHT>
|
|
13
|
-
| undefined;
|
|
14
|
-
|
|
15
|
-
async function getTree() {
|
|
16
|
-
if (!protocolContractTree) {
|
|
17
|
-
const leaves = protocolContractNames.map(name => ({
|
|
18
|
-
address: ProtocolContractAddress[name],
|
|
19
|
-
leaf: ProtocolContractLeaves[name],
|
|
20
|
-
}));
|
|
21
|
-
protocolContractTree = await buildProtocolContractTree(leaves);
|
|
22
|
-
}
|
|
23
|
-
return protocolContractTree;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Computed address can be different from contract address due to upgrades
|
|
27
|
-
export async function getProtocolContractLeafAndMembershipWitness(
|
|
28
|
-
contractAddress: AztecAddress,
|
|
29
|
-
computedAddress: AztecAddress,
|
|
30
|
-
) {
|
|
31
|
-
const tree = await getTree();
|
|
32
|
-
let lowLeaf;
|
|
33
|
-
let witness;
|
|
34
|
-
if (isProtocolContract(contractAddress)) {
|
|
35
|
-
const index = contractAddress.toField().toNumber();
|
|
36
|
-
lowLeaf = tree.leafPreimages[index];
|
|
37
|
-
witness = tree.getMembershipWitness(index);
|
|
38
|
-
} else {
|
|
39
|
-
lowLeaf = tree.getLowLeaf(computedAddress.toBigInt());
|
|
40
|
-
const hashed = (await poseidon2Hash(lowLeaf.toHashInputs())).toBuffer();
|
|
41
|
-
witness = tree.getMembershipWitness(hashed);
|
|
42
|
-
}
|
|
43
|
-
return { lowLeaf, witness };
|
|
44
|
-
}
|