@aztec/protocol-contracts 5.0.0-private.20260318 → 5.0.0-rc.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/ContractClassRegistry.json +2592 -460
- package/artifacts/ContractInstanceRegistry.json +3492 -937
- package/artifacts/FeeJuice.json +3799 -944
- package/dest/class-registry/contract_class_published_event.d.ts +6 -3
- package/dest/class-registry/contract_class_published_event.d.ts.map +1 -1
- package/dest/class-registry/contract_class_published_event.js +10 -16
- package/dest/class-registry/index.d.ts +1 -3
- package/dest/class-registry/index.d.ts.map +1 -1
- package/dest/class-registry/index.js +0 -2
- package/dest/class-registry/lazy.d.ts +1 -3
- package/dest/class-registry/lazy.d.ts.map +1 -1
- package/dest/class-registry/lazy.js +1 -3
- package/dest/fee-juice/lazy.js +1 -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 +7 -3
- package/dest/instance-registry/lazy.js +1 -1
- package/dest/make_protocol_contract.d.ts +1 -1
- package/dest/make_protocol_contract.d.ts.map +1 -1
- package/dest/make_protocol_contract.js +3 -1
- package/dest/protocol_contract_data.d.ts +2 -5
- package/dest/protocol_contract_data.d.ts.map +1 -1
- package/dest/protocol_contract_data.js +32 -78
- package/dest/provider/bundle.d.ts +1 -1
- package/dest/provider/bundle.d.ts.map +1 -1
- package/dest/provider/bundle.js +1 -7
- package/dest/provider/lazy.d.ts +1 -1
- package/dest/provider/lazy.d.ts.map +1 -1
- package/dest/provider/lazy.js +0 -9
- package/dest/scripts/generate_data.js +4 -6
- package/dest/tests/fixtures.d.ts +1 -3
- package/dest/tests/fixtures.d.ts.map +1 -1
- package/dest/tests/fixtures.js +0 -10
- package/package.json +4 -4
- package/src/class-registry/contract_class_published_event.ts +10 -21
- package/src/class-registry/index.ts +0 -2
- package/src/class-registry/lazy.ts +1 -3
- package/src/fee-juice/lazy.ts +1 -1
- package/src/instance-registry/contract_instance_published_event.ts +5 -1
- package/src/instance-registry/lazy.ts +1 -1
- package/src/make_protocol_contract.ts +3 -1
- package/src/protocol_contract_data.ts +34 -70
- package/src/provider/bundle.ts +0 -6
- package/src/provider/lazy.ts +0 -9
- package/src/tests/fixtures.ts +0 -12
- package/artifacts/AuthRegistry.d.json.ts +0 -5
- package/artifacts/AuthRegistry.json +0 -3721
- package/artifacts/MultiCallEntrypoint.d.json.ts +0 -5
- package/artifacts/MultiCallEntrypoint.json +0 -2969
- package/artifacts/PublicChecks.d.json.ts +0 -5
- package/artifacts/PublicChecks.json +0 -1180
- package/dest/auth-registry/index.d.ts +0 -6
- package/dest/auth-registry/index.d.ts.map +0 -1
- package/dest/auth-registry/index.js +0 -13
- package/dest/auth-registry/lazy.d.ts +0 -6
- package/dest/auth-registry/lazy.d.ts.map +0 -1
- package/dest/auth-registry/lazy.js +0 -23
- package/dest/class-registry/private_function_broadcasted_event.d.ts +0 -44
- package/dest/class-registry/private_function_broadcasted_event.d.ts.map +0 -1
- package/dest/class-registry/private_function_broadcasted_event.js +0 -85
- package/dest/class-registry/utility_function_broadcasted_event.d.ts +0 -38
- package/dest/class-registry/utility_function_broadcasted_event.d.ts.map +0 -1
- package/dest/class-registry/utility_function_broadcasted_event.js +0 -81
- package/dest/multi-call-entrypoint/index.d.ts +0 -5
- package/dest/multi-call-entrypoint/index.d.ts.map +0 -1
- package/dest/multi-call-entrypoint/index.js +0 -13
- package/dest/multi-call-entrypoint/lazy.d.ts +0 -6
- package/dest/multi-call-entrypoint/lazy.d.ts.map +0 -1
- package/dest/multi-call-entrypoint/lazy.js +0 -23
- package/dest/public-checks/index.d.ts +0 -5
- package/dest/public-checks/index.d.ts.map +0 -1
- package/dest/public-checks/index.js +0 -13
- package/dest/public-checks/lazy.d.ts +0 -6
- package/dest/public-checks/lazy.d.ts.map +0 -1
- package/dest/public-checks/lazy.js +0 -23
- package/src/auth-registry/index.ts +0 -18
- package/src/auth-registry/lazy.ts +0 -29
- package/src/class-registry/private_function_broadcasted_event.ts +0 -109
- package/src/class-registry/utility_function_broadcasted_event.ts +0 -103
- package/src/multi-call-entrypoint/index.ts +0 -18
- package/src/multi-call-entrypoint/lazy.ts +0 -29
- package/src/public-checks/index.ts +0 -18
- package/src/public-checks/lazy.ts +0 -29
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ARTIFACT_FUNCTION_TREE_MAX_HEIGHT,
|
|
3
|
-
CONTRACT_CLASS_REGISTRY_UTILITY_FUNCTION_BROADCASTED_MAGIC_VALUE,
|
|
4
|
-
MAX_PACKED_BYTECODE_SIZE_PER_UTILITY_FUNCTION_IN_FIELDS,
|
|
5
|
-
} from '@aztec/constants';
|
|
6
|
-
import { removeArrayPaddingEnd } from '@aztec/foundation/collection';
|
|
7
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
8
|
-
import type { Tuple } from '@aztec/foundation/serialize';
|
|
9
|
-
import { FieldReader } from '@aztec/foundation/serialize';
|
|
10
|
-
import { FunctionSelector, bufferFromFields } from '@aztec/stdlib/abi';
|
|
11
|
-
import type { UtilityFunction, UtilityFunctionWithMembershipProof } from '@aztec/stdlib/contract';
|
|
12
|
-
import type { ContractClassLog } from '@aztec/stdlib/logs';
|
|
13
|
-
|
|
14
|
-
import { ProtocolContractAddress } from '../protocol_contract_data.js';
|
|
15
|
-
|
|
16
|
-
/** Event emitted from the ContractClassRegistry. */
|
|
17
|
-
export class UtilityFunctionBroadcastedEvent {
|
|
18
|
-
constructor(
|
|
19
|
-
public readonly contractClassId: Fr,
|
|
20
|
-
public readonly artifactMetadataHash: Fr,
|
|
21
|
-
public readonly privateFunctionsArtifactTreeRoot: Fr,
|
|
22
|
-
public readonly artifactFunctionTreeSiblingPath: Tuple<Fr, typeof ARTIFACT_FUNCTION_TREE_MAX_HEIGHT>,
|
|
23
|
-
public readonly artifactFunctionTreeLeafIndex: number,
|
|
24
|
-
public readonly utilityFunction: BroadcastedUtilityFunction,
|
|
25
|
-
) {}
|
|
26
|
-
|
|
27
|
-
static isUtilityFunctionBroadcastedEvent(log: ContractClassLog) {
|
|
28
|
-
return (
|
|
29
|
-
log.contractAddress.equals(ProtocolContractAddress.ContractClassRegistry) &&
|
|
30
|
-
log.fields.fields[0].toBigInt() === CONTRACT_CLASS_REGISTRY_UTILITY_FUNCTION_BROADCASTED_MAGIC_VALUE
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
static fromLog(log: ContractClassLog) {
|
|
35
|
-
const reader = new FieldReader(log.fields.fields.slice(1));
|
|
36
|
-
const event = UtilityFunctionBroadcastedEvent.fromFields(reader);
|
|
37
|
-
while (!reader.isFinished()) {
|
|
38
|
-
const field = reader.readField();
|
|
39
|
-
if (!field.isZero()) {
|
|
40
|
-
throw new Error(`Unexpected data after parsing UtilityFunctionBroadcastedEvent: ${field.toString()}`);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return event;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
static fromFields(fields: Fr[] | FieldReader) {
|
|
48
|
-
const reader = FieldReader.asReader(fields);
|
|
49
|
-
const contractClassId = reader.readField();
|
|
50
|
-
const artifactMetadataHash = reader.readField();
|
|
51
|
-
const privateFunctionsArtifactTreeRoot = reader.readField();
|
|
52
|
-
const artifactFunctionTreeSiblingPath = reader.readFieldArray(ARTIFACT_FUNCTION_TREE_MAX_HEIGHT);
|
|
53
|
-
const artifactFunctionTreeLeafIndex = reader.readField().toNumber();
|
|
54
|
-
const utilityFunction = BroadcastedUtilityFunction.fromFields(reader);
|
|
55
|
-
|
|
56
|
-
return new UtilityFunctionBroadcastedEvent(
|
|
57
|
-
contractClassId,
|
|
58
|
-
artifactMetadataHash,
|
|
59
|
-
privateFunctionsArtifactTreeRoot,
|
|
60
|
-
artifactFunctionTreeSiblingPath,
|
|
61
|
-
artifactFunctionTreeLeafIndex,
|
|
62
|
-
utilityFunction,
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
toFunctionWithMembershipProof(): UtilityFunctionWithMembershipProof {
|
|
67
|
-
// We should be able to safely remove the zero elements that pad the variable-length sibling path,
|
|
68
|
-
// since a sibling with value zero can only occur on the tree leaves, so the sibling path will never end
|
|
69
|
-
// in a zero. The only exception is a tree with depth 2 with one non-zero leaf, where the sibling path would
|
|
70
|
-
// be a single zero element, but in that case the artifact tree should be just the single leaf.
|
|
71
|
-
const artifactTreeSiblingPath = removeArrayPaddingEnd(this.artifactFunctionTreeSiblingPath, Fr.isZero);
|
|
72
|
-
return {
|
|
73
|
-
...this.utilityFunction,
|
|
74
|
-
bytecode: this.utilityFunction.bytecode,
|
|
75
|
-
functionMetadataHash: this.utilityFunction.metadataHash,
|
|
76
|
-
artifactMetadataHash: this.artifactMetadataHash,
|
|
77
|
-
privateFunctionsArtifactTreeRoot: this.privateFunctionsArtifactTreeRoot,
|
|
78
|
-
artifactTreeSiblingPath,
|
|
79
|
-
artifactTreeLeafIndex: this.artifactFunctionTreeLeafIndex,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export class BroadcastedUtilityFunction implements UtilityFunction {
|
|
85
|
-
constructor(
|
|
86
|
-
/** Selector of the function. Calculated as the hash of the method name and parameters. The specification of this is not enforced by the protocol. */
|
|
87
|
-
public readonly selector: FunctionSelector,
|
|
88
|
-
/** Artifact metadata hash */
|
|
89
|
-
public readonly metadataHash: Fr,
|
|
90
|
-
/** Brillig bytecode */
|
|
91
|
-
public readonly bytecode: Buffer,
|
|
92
|
-
) {}
|
|
93
|
-
|
|
94
|
-
static fromFields(fields: Fr[] | FieldReader) {
|
|
95
|
-
const reader = FieldReader.asReader(fields);
|
|
96
|
-
const selector = FunctionSelector.fromField(reader.readField());
|
|
97
|
-
const metadataHash = reader.readField();
|
|
98
|
-
// The '* 1' removes the 'Type instantiation is excessively deep and possibly infinite. ts(2589)' err
|
|
99
|
-
const encodedBytecode = reader.readFieldArray(MAX_PACKED_BYTECODE_SIZE_PER_UTILITY_FUNCTION_IN_FIELDS * 1);
|
|
100
|
-
const bytecode = bufferFromFields(encodedBytecode);
|
|
101
|
-
return new BroadcastedUtilityFunction(selector, metadataHash, bytecode);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
2
|
-
import type { NoirCompiledContract } from '@aztec/stdlib/noir';
|
|
3
|
-
|
|
4
|
-
import MultiCallEntrypointJson from '../../artifacts/MultiCallEntrypoint.json' with { type: 'json' };
|
|
5
|
-
import { makeProtocolContract } from '../make_protocol_contract.js';
|
|
6
|
-
import type { ProtocolContract } from '../protocol_contract.js';
|
|
7
|
-
|
|
8
|
-
export const MultiCallEntrypointArtifact = loadContractArtifact(MultiCallEntrypointJson as NoirCompiledContract);
|
|
9
|
-
|
|
10
|
-
let protocolContract: ProtocolContract;
|
|
11
|
-
|
|
12
|
-
/** Returns the canonical deployment of the contract. */
|
|
13
|
-
export function getCanonicalMultiCallEntrypoint(): Promise<ProtocolContract> {
|
|
14
|
-
if (!protocolContract) {
|
|
15
|
-
protocolContract = makeProtocolContract('MultiCallEntrypoint', MultiCallEntrypointArtifact);
|
|
16
|
-
}
|
|
17
|
-
return Promise.resolve(protocolContract);
|
|
18
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { type ContractArtifact, loadContractArtifact } from '@aztec/stdlib/abi';
|
|
2
|
-
|
|
3
|
-
import { makeProtocolContract } from '../make_protocol_contract.js';
|
|
4
|
-
import type { ProtocolContract } from '../protocol_contract.js';
|
|
5
|
-
|
|
6
|
-
let protocolContract: ProtocolContract;
|
|
7
|
-
let protocolContractArtifact: ContractArtifact;
|
|
8
|
-
|
|
9
|
-
export async function getMultiCallEntrypointArtifact(): Promise<ContractArtifact> {
|
|
10
|
-
if (!protocolContractArtifact) {
|
|
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
|
-
// In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
|
|
16
|
-
const { default: multiCallEntrypointJson } = await import('../../artifacts/MultiCallEntrypoint.json');
|
|
17
|
-
protocolContractArtifact = loadContractArtifact(multiCallEntrypointJson);
|
|
18
|
-
}
|
|
19
|
-
return protocolContractArtifact;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/** Returns the canonical deployment of the auth registry. */
|
|
23
|
-
export async function getCanonicalMultiCallEntrypoint(): Promise<ProtocolContract> {
|
|
24
|
-
if (!protocolContract) {
|
|
25
|
-
const multiCallEntrypointArtifact = await getMultiCallEntrypointArtifact();
|
|
26
|
-
protocolContract = makeProtocolContract('MultiCallEntrypoint', multiCallEntrypointArtifact);
|
|
27
|
-
}
|
|
28
|
-
return protocolContract;
|
|
29
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
2
|
-
import type { NoirCompiledContract } from '@aztec/stdlib/noir';
|
|
3
|
-
|
|
4
|
-
import PublicChecksJson from '../../artifacts/PublicChecks.json' with { type: 'json' };
|
|
5
|
-
import { makeProtocolContract } from '../make_protocol_contract.js';
|
|
6
|
-
import type { ProtocolContract } from '../protocol_contract.js';
|
|
7
|
-
|
|
8
|
-
export const PublicChecksArtifact = loadContractArtifact(PublicChecksJson as NoirCompiledContract);
|
|
9
|
-
|
|
10
|
-
let protocolContract: ProtocolContract;
|
|
11
|
-
|
|
12
|
-
/** Returns the canonical deployment of the contract. */
|
|
13
|
-
export function getCanonicalPublicChecks(): Promise<ProtocolContract> {
|
|
14
|
-
if (!protocolContract) {
|
|
15
|
-
protocolContract = makeProtocolContract('PublicChecks', PublicChecksArtifact);
|
|
16
|
-
}
|
|
17
|
-
return Promise.resolve(protocolContract);
|
|
18
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { type ContractArtifact, loadContractArtifact } from '@aztec/stdlib/abi';
|
|
2
|
-
|
|
3
|
-
import { makeProtocolContract } from '../make_protocol_contract.js';
|
|
4
|
-
import type { ProtocolContract } from '../protocol_contract.js';
|
|
5
|
-
|
|
6
|
-
let protocolContract: ProtocolContract;
|
|
7
|
-
let protocolContractArtifact: ContractArtifact;
|
|
8
|
-
|
|
9
|
-
export async function getPublicChecksArtifact(): Promise<ContractArtifact> {
|
|
10
|
-
if (!protocolContractArtifact) {
|
|
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
|
-
// In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
|
|
16
|
-
const { default: publicChecksJson } = await import('../../artifacts/PublicChecks.json');
|
|
17
|
-
protocolContractArtifact = loadContractArtifact(publicChecksJson);
|
|
18
|
-
}
|
|
19
|
-
return protocolContractArtifact;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/** Returns the canonical deployment of the public checks contract. */
|
|
23
|
-
export async function getCanonicalPublicChecks(): Promise<ProtocolContract> {
|
|
24
|
-
if (!protocolContract) {
|
|
25
|
-
const publicChecksArtifact = await getPublicChecksArtifact();
|
|
26
|
-
protocolContract = makeProtocolContract('PublicChecks', publicChecksArtifact);
|
|
27
|
-
}
|
|
28
|
-
return protocolContract;
|
|
29
|
-
}
|