@aztec/protocol-contracts 0.0.0-test.1 → 0.0.1-commit.5daedc8
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/README.md +2 -2
- package/artifacts/AuthRegistry.json +2095 -1241
- package/artifacts/ContractClassRegistry.json +6635 -0
- package/artifacts/ContractInstanceRegistry.json +3629 -0
- package/artifacts/FeeJuice.json +2848 -2146
- package/artifacts/MultiCallEntrypoint.json +1594 -855
- package/artifacts/Router.json +698 -3537
- package/dest/auth-registry/index.d.ts +3 -2
- package/dest/auth-registry/index.d.ts.map +1 -1
- package/dest/auth-registry/index.js +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 +17 -0
- package/dest/class-registry/contract_class_published_event.d.ts.map +1 -0
- package/dest/{class-registerer/contract_class_registered_event.js → class-registry/contract_class_published_event.js} +15 -20
- package/dest/class-registry/index.d.ts +8 -0
- package/dest/class-registry/index.d.ts.map +1 -0
- package/dest/class-registry/index.js +17 -0
- package/dest/class-registry/lazy.d.ts +9 -0
- package/dest/class-registry/lazy.d.ts.map +1 -0
- package/dest/class-registry/lazy.js +26 -0
- package/dest/class-registry/private_function_broadcasted_event.d.ts +40 -0
- package/dest/class-registry/private_function_broadcasted_event.d.ts.map +1 -0
- package/dest/{class-registerer → class-registry}/private_function_broadcasted_event.js +11 -11
- package/dest/class-registry/utility_function_broadcasted_event.d.ts +35 -0
- package/dest/class-registry/utility_function_broadcasted_event.d.ts.map +1 -0
- package/dest/{class-registerer/unconstrained_function_broadcasted_event.js → class-registry/utility_function_broadcasted_event.js} +19 -19
- package/dest/fee-juice/index.d.ts +1 -1
- package/dest/fee-juice/index.js +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 +21 -0
- package/dest/instance-registry/contract_instance_published_event.d.ts.map +1 -0
- package/dest/{instance-deployer/contract_instance_deployed_event.js → instance-registry/contract_instance_published_event.js} +8 -5
- package/dest/instance-registry/contract_instance_updated_event.d.ts +17 -0
- package/dest/instance-registry/contract_instance_updated_event.d.ts.map +1 -0
- package/dest/instance-registry/contract_instance_updated_event.js +35 -0
- package/dest/instance-registry/index.d.ts +7 -0
- package/dest/instance-registry/index.d.ts.map +1 -0
- package/dest/{instance-deployer → instance-registry}/index.js +5 -5
- package/dest/instance-registry/lazy.d.ts +8 -0
- package/dest/{instance-deployer → instance-registry}/lazy.d.ts.map +1 -1
- package/dest/instance-registry/lazy.js +25 -0
- package/dest/make_protocol_contract.d.ts +1 -1
- package/dest/make_protocol_contract.js +2 -2
- package/dest/multi-call-entrypoint/index.d.ts +1 -1
- package/dest/multi-call-entrypoint/index.js +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 +13 -15
- package/dest/protocol_contract_data.d.ts.map +1 -1
- package/dest/protocol_contract_data.js +29 -19
- package/dest/provider/bundle.d.ts +1 -1
- package/dest/provider/bundle.d.ts.map +1 -1
- package/dest/provider/bundle.js +4 -4
- package/dest/provider/lazy.d.ts +1 -1
- package/dest/provider/lazy.d.ts.map +1 -1
- package/dest/provider/lazy.js +6 -6
- package/dest/provider/protocol_contracts_provider.d.ts +1 -1
- package/dest/router/index.d.ts +1 -1
- package/dest/router/index.js +1 -1
- package/dest/router/lazy.d.ts +1 -1
- package/dest/router/lazy.js +4 -4
- package/dest/scripts/cleanup_artifacts.js +2 -2
- package/dest/scripts/generate_data.js +38 -45
- package/dest/tests/fixtures.d.ts +4 -6
- package/dest/tests/fixtures.d.ts.map +1 -1
- package/dest/tests/fixtures.js +6 -6
- package/package.json +23 -20
- package/src/auth-registry/index.ts +3 -3
- package/src/auth-registry/lazy.ts +4 -4
- package/src/class-registry/__snapshots__/README.md +9 -0
- package/src/{class-registerer/contract_class_registered_event.ts → class-registry/contract_class_published_event.ts} +22 -22
- package/src/{class-registerer → class-registry}/index.ts +7 -9
- package/src/class-registry/lazy.ts +33 -0
- package/src/{class-registerer → class-registry}/private_function_broadcasted_event.ts +12 -8
- package/src/{class-registerer/unconstrained_function_broadcasted_event.ts → class-registry/utility_function_broadcasted_event.ts} +25 -21
- 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/__snapshots__/README.md +9 -0
- package/src/{instance-deployer/contract_instance_deployed_event.ts → instance-registry/contract_instance_published_event.ts} +12 -6
- package/src/{instance-deployer → instance-registry}/contract_instance_updated_event.ts +14 -14
- package/src/{instance-deployer → instance-registry}/index.ts +6 -6
- package/src/{instance-deployer → instance-registry}/lazy.ts +11 -11
- package/src/make_protocol_contract.ts +2 -2
- package/src/multi-call-entrypoint/index.ts +1 -1
- package/src/multi-call-entrypoint/lazy.ts +4 -4
- package/src/protocol_contract_data.ts +30 -19
- package/src/provider/bundle.ts +4 -4
- package/src/provider/lazy.ts +6 -6
- package/src/router/index.ts +1 -1
- package/src/router/lazy.ts +4 -4
- package/src/tests/fixtures.ts +6 -6
- package/artifacts/ContractClassRegisterer.json +0 -7219
- package/artifacts/ContractInstanceDeployer.json +0 -2984
- 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/class-registerer/contract_class_registered_event.d.ts +0 -18
- package/dest/class-registerer/contract_class_registered_event.d.ts.map +0 -1
- package/dest/class-registerer/index.d.ts +0 -8
- package/dest/class-registerer/index.d.ts.map +0 -1
- package/dest/class-registerer/index.js +0 -17
- package/dest/class-registerer/lazy.d.ts +0 -9
- package/dest/class-registerer/lazy.d.ts.map +0 -1
- package/dest/class-registerer/lazy.js +0 -26
- package/dest/class-registerer/private_function_broadcasted_event.d.ts +0 -46
- package/dest/class-registerer/private_function_broadcasted_event.d.ts.map +0 -1
- package/dest/class-registerer/unconstrained_function_broadcasted_event.d.ts +0 -40
- package/dest/class-registerer/unconstrained_function_broadcasted_event.d.ts.map +0 -1
- package/dest/instance-deployer/contract_instance_deployed_event.d.ts +0 -20
- package/dest/instance-deployer/contract_instance_deployed_event.d.ts.map +0 -1
- package/dest/instance-deployer/contract_instance_updated_event.d.ts +0 -16
- package/dest/instance-deployer/contract_instance_updated_event.d.ts.map +0 -1
- package/dest/instance-deployer/contract_instance_updated_event.js +0 -36
- package/dest/instance-deployer/index.d.ts +0 -7
- package/dest/instance-deployer/index.d.ts.map +0 -1
- package/dest/instance-deployer/lazy.d.ts +0 -8
- package/dest/instance-deployer/lazy.js +0 -25
- 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/class-registerer/lazy.ts +0 -33
- package/src/protocol_contract_tree.ts +0 -44
- /package/artifacts/{ContractClassRegisterer.d.json.ts → ContractClassRegistry.d.json.ts} +0 -0
- /package/artifacts/{ContractInstanceDeployer.d.json.ts → ContractInstanceRegistry.d.json.ts} +0 -0
|
@@ -1,39 +1,43 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ARTIFACT_FUNCTION_TREE_MAX_HEIGHT,
|
|
3
|
-
|
|
3
|
+
CONTRACT_CLASS_REGISTRY_UTILITY_FUNCTION_BROADCASTED_MAGIC_VALUE,
|
|
4
|
+
MAX_PACKED_BYTECODE_SIZE_PER_UTILITY_FUNCTION_IN_FIELDS,
|
|
4
5
|
} from '@aztec/constants';
|
|
5
6
|
import { removeArrayPaddingEnd } from '@aztec/foundation/collection';
|
|
6
7
|
import { Fr } from '@aztec/foundation/fields';
|
|
7
8
|
import type { Tuple } from '@aztec/foundation/serialize';
|
|
8
9
|
import { FieldReader } from '@aztec/foundation/serialize';
|
|
9
10
|
import { FunctionSelector, bufferFromFields } from '@aztec/stdlib/abi';
|
|
10
|
-
import type {
|
|
11
|
+
import type { UtilityFunction, UtilityFunctionWithMembershipProof } from '@aztec/stdlib/contract';
|
|
11
12
|
import type { ContractClassLog } from '@aztec/stdlib/logs';
|
|
12
13
|
|
|
13
|
-
import {
|
|
14
|
+
import { ProtocolContractAddress } from '../protocol_contract_data.js';
|
|
14
15
|
|
|
15
|
-
/** Event emitted from the
|
|
16
|
-
export class
|
|
16
|
+
/** Event emitted from the ContractClassRegistry. */
|
|
17
|
+
export class UtilityFunctionBroadcastedEvent {
|
|
17
18
|
constructor(
|
|
18
19
|
public readonly contractClassId: Fr,
|
|
19
20
|
public readonly artifactMetadataHash: Fr,
|
|
20
21
|
public readonly privateFunctionsArtifactTreeRoot: Fr,
|
|
21
22
|
public readonly artifactFunctionTreeSiblingPath: Tuple<Fr, typeof ARTIFACT_FUNCTION_TREE_MAX_HEIGHT>,
|
|
22
23
|
public readonly artifactFunctionTreeLeafIndex: number,
|
|
23
|
-
public readonly
|
|
24
|
+
public readonly utilityFunction: BroadcastedUtilityFunction,
|
|
24
25
|
) {}
|
|
25
26
|
|
|
26
|
-
static
|
|
27
|
-
return
|
|
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
|
+
);
|
|
28
32
|
}
|
|
29
33
|
|
|
30
34
|
static fromLog(log: ContractClassLog) {
|
|
31
|
-
const reader = new FieldReader(log.fields.slice(1));
|
|
32
|
-
const event =
|
|
35
|
+
const reader = new FieldReader(log.fields.fields.slice(1));
|
|
36
|
+
const event = UtilityFunctionBroadcastedEvent.fromFields(reader);
|
|
33
37
|
while (!reader.isFinished()) {
|
|
34
38
|
const field = reader.readField();
|
|
35
39
|
if (!field.isZero()) {
|
|
36
|
-
throw new Error(`Unexpected data after parsing
|
|
40
|
+
throw new Error(`Unexpected data after parsing UtilityFunctionBroadcastedEvent: ${field.toString()}`);
|
|
37
41
|
}
|
|
38
42
|
}
|
|
39
43
|
|
|
@@ -47,28 +51,28 @@ export class UnconstrainedFunctionBroadcastedEvent {
|
|
|
47
51
|
const privateFunctionsArtifactTreeRoot = reader.readField();
|
|
48
52
|
const artifactFunctionTreeSiblingPath = reader.readFieldArray(ARTIFACT_FUNCTION_TREE_MAX_HEIGHT);
|
|
49
53
|
const artifactFunctionTreeLeafIndex = reader.readField().toNumber();
|
|
50
|
-
const
|
|
54
|
+
const utilityFunction = BroadcastedUtilityFunction.fromFields(reader);
|
|
51
55
|
|
|
52
|
-
return new
|
|
56
|
+
return new UtilityFunctionBroadcastedEvent(
|
|
53
57
|
contractClassId,
|
|
54
58
|
artifactMetadataHash,
|
|
55
59
|
privateFunctionsArtifactTreeRoot,
|
|
56
60
|
artifactFunctionTreeSiblingPath,
|
|
57
61
|
artifactFunctionTreeLeafIndex,
|
|
58
|
-
|
|
62
|
+
utilityFunction,
|
|
59
63
|
);
|
|
60
64
|
}
|
|
61
65
|
|
|
62
|
-
toFunctionWithMembershipProof():
|
|
66
|
+
toFunctionWithMembershipProof(): UtilityFunctionWithMembershipProof {
|
|
63
67
|
// We should be able to safely remove the zero elements that pad the variable-length sibling path,
|
|
64
68
|
// since a sibling with value zero can only occur on the tree leaves, so the sibling path will never end
|
|
65
69
|
// in a zero. The only exception is a tree with depth 2 with one non-zero leaf, where the sibling path would
|
|
66
70
|
// be a single zero element, but in that case the artifact tree should be just the single leaf.
|
|
67
71
|
const artifactTreeSiblingPath = removeArrayPaddingEnd(this.artifactFunctionTreeSiblingPath, Fr.isZero);
|
|
68
72
|
return {
|
|
69
|
-
...this.
|
|
70
|
-
bytecode: this.
|
|
71
|
-
functionMetadataHash: this.
|
|
73
|
+
...this.utilityFunction,
|
|
74
|
+
bytecode: this.utilityFunction.bytecode,
|
|
75
|
+
functionMetadataHash: this.utilityFunction.metadataHash,
|
|
72
76
|
artifactMetadataHash: this.artifactMetadataHash,
|
|
73
77
|
privateFunctionsArtifactTreeRoot: this.privateFunctionsArtifactTreeRoot,
|
|
74
78
|
artifactTreeSiblingPath,
|
|
@@ -77,7 +81,7 @@ export class UnconstrainedFunctionBroadcastedEvent {
|
|
|
77
81
|
}
|
|
78
82
|
}
|
|
79
83
|
|
|
80
|
-
export class
|
|
84
|
+
export class BroadcastedUtilityFunction implements UtilityFunction {
|
|
81
85
|
constructor(
|
|
82
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. */
|
|
83
87
|
public readonly selector: FunctionSelector,
|
|
@@ -92,8 +96,8 @@ export class BroadcastedUnconstrainedFunction implements UnconstrainedFunction {
|
|
|
92
96
|
const selector = FunctionSelector.fromField(reader.readField());
|
|
93
97
|
const metadataHash = reader.readField();
|
|
94
98
|
// The '* 1' removes the 'Type instantiation is excessively deep and possibly infinite. ts(2589)' err
|
|
95
|
-
const encodedBytecode = reader.readFieldArray(
|
|
99
|
+
const encodedBytecode = reader.readFieldArray(MAX_PACKED_BYTECODE_SIZE_PER_UTILITY_FUNCTION_IN_FIELDS * 1);
|
|
96
100
|
const bytecode = bufferFromFields(encodedBytecode);
|
|
97
|
-
return new
|
|
101
|
+
return new BroadcastedUtilityFunction(selector, metadataHash, bytecode);
|
|
98
102
|
}
|
|
99
103
|
}
|
package/src/fee-juice/index.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
4
4
|
import { computePublicDataTreeLeafSlot, deriveStorageSlotInMap } from '@aztec/stdlib/hash';
|
|
5
5
|
import type { NoirCompiledContract } from '@aztec/stdlib/noir';
|
|
6
6
|
|
|
7
|
-
import FeeJuiceJson from '../../artifacts/FeeJuice.json'
|
|
7
|
+
import FeeJuiceJson from '../../artifacts/FeeJuice.json' with { type: 'json' };
|
|
8
8
|
import { makeProtocolContract } from '../make_protocol_contract.js';
|
|
9
9
|
import type { ProtocolContract } from '../protocol_contract.js';
|
|
10
10
|
import { ProtocolContractAddress } from '../protocol_contract_data.js';
|
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
|
@@ -5,10 +5,10 @@ import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
|
5
5
|
import { PublicKeys } from '@aztec/stdlib/keys';
|
|
6
6
|
import type { PrivateLog } from '@aztec/stdlib/logs';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { CONTRACT_INSTANCE_PUBLISHED_EVENT_TAG } from '../protocol_contract_data.js';
|
|
9
9
|
|
|
10
|
-
/** Event emitted from the
|
|
11
|
-
export class
|
|
10
|
+
/** Event emitted from the ContractInstanceRegistry. */
|
|
11
|
+
export class ContractInstancePublishedEvent {
|
|
12
12
|
constructor(
|
|
13
13
|
public readonly address: AztecAddress,
|
|
14
14
|
public readonly version: number,
|
|
@@ -19,8 +19,8 @@ export class ContractInstanceDeployedEvent {
|
|
|
19
19
|
public readonly deployer: AztecAddress,
|
|
20
20
|
) {}
|
|
21
21
|
|
|
22
|
-
static
|
|
23
|
-
return log.fields[0].equals(
|
|
22
|
+
static isContractInstancePublishedEvent(log: PrivateLog) {
|
|
23
|
+
return log.fields[0].equals(CONTRACT_INSTANCE_PUBLISHED_EVENT_TAG);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
static fromLog(log: PrivateLog) {
|
|
@@ -34,7 +34,7 @@ export class ContractInstanceDeployedEvent {
|
|
|
34
34
|
const publicKeys = reader.readObject(PublicKeys);
|
|
35
35
|
const deployer = reader.readObject(AztecAddress);
|
|
36
36
|
|
|
37
|
-
return new
|
|
37
|
+
return new ContractInstancePublishedEvent(
|
|
38
38
|
address,
|
|
39
39
|
version,
|
|
40
40
|
salt,
|
|
@@ -61,4 +61,10 @@ export class ContractInstanceDeployedEvent {
|
|
|
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,36 +1,36 @@
|
|
|
1
|
+
import { CONTRACT_INSTANCE_UPDATED_MAGIC_VALUE } from '@aztec/constants';
|
|
1
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
-
import {
|
|
3
|
+
import { FieldReader } from '@aztec/foundation/serialize';
|
|
3
4
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
5
|
import type { ContractInstanceUpdateWithAddress } from '@aztec/stdlib/contract';
|
|
5
6
|
import type { PublicLog } from '@aztec/stdlib/logs';
|
|
7
|
+
import type { UInt64 } from '@aztec/stdlib/types';
|
|
6
8
|
|
|
7
|
-
import {
|
|
9
|
+
import { ProtocolContractAddress } from '../protocol_contract_data.js';
|
|
8
10
|
|
|
9
|
-
/** Event emitted from the
|
|
11
|
+
/** Event emitted from the ContractInstanceRegistry. */
|
|
10
12
|
export class ContractInstanceUpdatedEvent {
|
|
11
13
|
constructor(
|
|
12
14
|
public readonly address: AztecAddress,
|
|
13
15
|
public readonly prevContractClassId: Fr,
|
|
14
16
|
public readonly newContractClassId: Fr,
|
|
15
|
-
public readonly
|
|
17
|
+
public readonly timestampOfChange: UInt64,
|
|
16
18
|
) {}
|
|
17
19
|
|
|
18
20
|
static isContractInstanceUpdatedEvent(log: PublicLog) {
|
|
19
21
|
return (
|
|
20
|
-
log.contractAddress.equals(ProtocolContractAddress.
|
|
21
|
-
log.
|
|
22
|
+
log.contractAddress.equals(ProtocolContractAddress.ContractInstanceRegistry) &&
|
|
23
|
+
log.fields[0].toBigInt() === CONTRACT_INSTANCE_UPDATED_MAGIC_VALUE
|
|
22
24
|
);
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
static fromLog(log: PublicLog) {
|
|
26
|
-
const
|
|
27
|
-
const reader = new BufferReader(bufferWithoutAddressAndTag);
|
|
28
|
+
const reader = new FieldReader(log.fields.slice(1) /* remove tag */);
|
|
28
29
|
const address = reader.readObject(AztecAddress);
|
|
29
|
-
const prevContractClassId = reader.
|
|
30
|
-
const newContractClassId = reader.
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
return new ContractInstanceUpdatedEvent(address, prevContractClassId, newContractClassId, blockOfChange);
|
|
30
|
+
const prevContractClassId = reader.readField();
|
|
31
|
+
const newContractClassId = reader.readField();
|
|
32
|
+
const timestampOfChange = reader.readField().toBigInt();
|
|
33
|
+
return new ContractInstanceUpdatedEvent(address, prevContractClassId, newContractClassId, timestampOfChange);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
toContractInstanceUpdate(): ContractInstanceUpdateWithAddress {
|
|
@@ -38,7 +38,7 @@ export class ContractInstanceUpdatedEvent {
|
|
|
38
38
|
address: this.address,
|
|
39
39
|
prevContractClassId: this.prevContractClassId,
|
|
40
40
|
newContractClassId: this.newContractClassId,
|
|
41
|
-
|
|
41
|
+
timestampOfChange: this.timestampOfChange,
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
2
2
|
import type { NoirCompiledContract } from '@aztec/stdlib/noir';
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import ContractInstanceRegistryJson from '../../artifacts/ContractInstanceRegistry.json' with { type: 'json' };
|
|
5
5
|
import { makeProtocolContract } from '../make_protocol_contract.js';
|
|
6
6
|
import type { ProtocolContract } from '../protocol_contract.js';
|
|
7
7
|
|
|
8
|
-
export * from './
|
|
8
|
+
export * from './contract_instance_published_event.js';
|
|
9
9
|
export * from './contract_instance_updated_event.js';
|
|
10
10
|
|
|
11
|
-
export const
|
|
12
|
-
|
|
11
|
+
export const ContractInstanceRegistryArtifact = loadContractArtifact(
|
|
12
|
+
ContractInstanceRegistryJson as NoirCompiledContract,
|
|
13
13
|
);
|
|
14
14
|
|
|
15
15
|
let protocolContract: ProtocolContract;
|
|
16
16
|
|
|
17
17
|
/** Returns the canonical deployment of the contract. */
|
|
18
|
-
export async function
|
|
18
|
+
export async function getCanonicalInstanceRegistry(): Promise<ProtocolContract> {
|
|
19
19
|
if (!protocolContract) {
|
|
20
|
-
protocolContract = await makeProtocolContract('
|
|
20
|
+
protocolContract = await makeProtocolContract('ContractInstanceRegistry', ContractInstanceRegistryArtifact);
|
|
21
21
|
}
|
|
22
22
|
return protocolContract;
|
|
23
23
|
}
|
|
@@ -3,30 +3,30 @@ import { type ContractArtifact, loadContractArtifact } from '@aztec/stdlib/abi';
|
|
|
3
3
|
import { makeProtocolContract } from '../make_protocol_contract.js';
|
|
4
4
|
import type { ProtocolContract } from '../protocol_contract.js';
|
|
5
5
|
|
|
6
|
-
export * from './
|
|
6
|
+
export * from './contract_instance_published_event.js';
|
|
7
7
|
export * from './contract_instance_updated_event.js';
|
|
8
8
|
|
|
9
9
|
let protocolContract: ProtocolContract;
|
|
10
10
|
let protocolContractArtifact: ContractArtifact;
|
|
11
11
|
|
|
12
|
-
export async function
|
|
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
|
-
const { default:
|
|
20
|
-
protocolContractArtifact = loadContractArtifact(
|
|
19
|
+
const { default: contractInstanceRegistryJson } = await import('../../artifacts/ContractInstanceRegistry.json');
|
|
20
|
+
protocolContractArtifact = loadContractArtifact(contractInstanceRegistryJson);
|
|
21
21
|
}
|
|
22
22
|
return protocolContractArtifact;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/** Returns the canonical deployment of the auth registry. */
|
|
26
|
-
export async function
|
|
26
|
+
export async function getCanonicalInstanceRegistry(): Promise<ProtocolContract> {
|
|
27
27
|
if (!protocolContract) {
|
|
28
|
-
const
|
|
29
|
-
protocolContract = await makeProtocolContract('
|
|
28
|
+
const contractInstanceRegistryArtifact = await getContractInstanceRegistryArtifact();
|
|
29
|
+
protocolContract = await makeProtocolContract('ContractInstanceRegistry', contractInstanceRegistryArtifact);
|
|
30
30
|
}
|
|
31
31
|
return protocolContract;
|
|
32
32
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
2
|
-
import { getContractClassFromArtifact,
|
|
2
|
+
import { getContractClassFromArtifact, getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
|
|
3
3
|
|
|
4
4
|
import type { ProtocolContract } from './protocol_contract.js';
|
|
5
5
|
import { ProtocolContractAddress, type ProtocolContractName, ProtocolContractSalt } from './protocol_contract_data.js';
|
|
@@ -16,7 +16,7 @@ export async function makeProtocolContract(
|
|
|
16
16
|
const salt = ProtocolContractSalt[name];
|
|
17
17
|
// TODO(@spalladino): This computes the contract class from the artifact twice.
|
|
18
18
|
const contractClass = await getContractClassFromArtifact(artifact);
|
|
19
|
-
const instance = await
|
|
19
|
+
const instance = await getContractInstanceFromInstantiationParams(artifact, { salt });
|
|
20
20
|
return {
|
|
21
21
|
instance: { ...instance, address },
|
|
22
22
|
contractClass,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
2
2
|
import type { NoirCompiledContract } from '@aztec/stdlib/noir';
|
|
3
3
|
|
|
4
|
-
import MultiCallEntrypointJson from '../../artifacts/MultiCallEntrypoint.json'
|
|
4
|
+
import MultiCallEntrypointJson from '../../artifacts/MultiCallEntrypoint.json' with { type: 'json' };
|
|
5
5
|
import { makeProtocolContract } from '../make_protocol_contract.js';
|
|
6
6
|
import type { ProtocolContract } from '../protocol_contract.js';
|
|
7
7
|
|
|
@@ -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);
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
// GENERATED FILE - DO NOT EDIT. RUN `yarn generate` or `yarn generate:data`
|
|
3
3
|
import { Fr } from '@aztec/foundation/fields';
|
|
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 = [
|
|
8
9
|
'AuthRegistry',
|
|
9
|
-
'
|
|
10
|
-
'
|
|
10
|
+
'ContractInstanceRegistry',
|
|
11
|
+
'ContractClassRegistry',
|
|
11
12
|
'MultiCallEntrypoint',
|
|
12
13
|
'FeeJuice',
|
|
13
14
|
'Router'
|
|
@@ -19,8 +20,8 @@
|
|
|
19
20
|
|
|
20
21
|
export const ProtocolContractSalt: Record<ProtocolContractName, Fr> = {
|
|
21
22
|
AuthRegistry: new Fr(1),
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
ContractInstanceRegistry: new Fr(1),
|
|
24
|
+
ContractClassRegistry: new Fr(1),
|
|
24
25
|
MultiCallEntrypoint: new Fr(1),
|
|
25
26
|
FeeJuice: new Fr(1),
|
|
26
27
|
Router: new Fr(1)
|
|
@@ -30,8 +31,8 @@ Router: new Fr(1)
|
|
|
30
31
|
|
|
31
32
|
export const ProtocolContractAddress: Record<ProtocolContractName, AztecAddress> = {
|
|
32
33
|
AuthRegistry: AztecAddress.fromBigInt(1n),
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
ContractInstanceRegistry: AztecAddress.fromBigInt(2n),
|
|
35
|
+
ContractClassRegistry: AztecAddress.fromBigInt(3n),
|
|
35
36
|
MultiCallEntrypoint: AztecAddress.fromBigInt(4n),
|
|
36
37
|
FeeJuice: AztecAddress.fromBigInt(5n),
|
|
37
38
|
Router: AztecAddress.fromBigInt(6n)
|
|
@@ -39,25 +40,35 @@ Router: AztecAddress.fromBigInt(6n)
|
|
|
39
40
|
|
|
40
41
|
|
|
41
42
|
|
|
42
|
-
export const
|
|
43
|
-
AuthRegistry:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
MultiCallEntrypoint:
|
|
47
|
-
FeeJuice:
|
|
48
|
-
Router:
|
|
43
|
+
export const ProtocolContractDerivedAddress = {
|
|
44
|
+
AuthRegistry: AztecAddress.fromString('0x1dc64374e96b37a36d94b737a049efb4686f45f628457f5d6d74f5d45817944b'),
|
|
45
|
+
ContractInstanceRegistry: AztecAddress.fromString('0x24b7c46308ae93c05e3bac8201935effd50b61504954eef96d7b0384f27ee80c'),
|
|
46
|
+
ContractClassRegistry: AztecAddress.fromString('0x2f6b4852b69e0381596da99b3aad9b8d493312f47e1c0e3523928e010e1f9df2'),
|
|
47
|
+
MultiCallEntrypoint: AztecAddress.fromString('0x1c93c2cb51b87faa1ee26b5f933a8136642cec5cdf95216bdd9aa4873d4b38ff'),
|
|
48
|
+
FeeJuice: AztecAddress.fromString('0x2223ff211abddd65cb27b3fd9ef6cbcdfed867b1b5c2421f87624c6fe86c39ff'),
|
|
49
|
+
Router: AztecAddress.fromString('0x090dc318c793abc5ee9a560dcf9f0ba54c73902086dd7258cd48da8c79ef201a')
|
|
49
50
|
};
|
|
50
51
|
|
|
51
52
|
|
|
52
53
|
|
|
53
|
-
export const
|
|
54
|
+
export const ProtocolContractsList = new ProtocolContracts([
|
|
55
|
+
AztecAddress.fromString('0x1dc64374e96b37a36d94b737a049efb4686f45f628457f5d6d74f5d45817944b'),
|
|
56
|
+
AztecAddress.fromString('0x24b7c46308ae93c05e3bac8201935effd50b61504954eef96d7b0384f27ee80c'),
|
|
57
|
+
AztecAddress.fromString('0x2f6b4852b69e0381596da99b3aad9b8d493312f47e1c0e3523928e010e1f9df2'),
|
|
58
|
+
AztecAddress.fromString('0x1c93c2cb51b87faa1ee26b5f933a8136642cec5cdf95216bdd9aa4873d4b38ff'),
|
|
59
|
+
AztecAddress.fromString('0x2223ff211abddd65cb27b3fd9ef6cbcdfed867b1b5c2421f87624c6fe86c39ff'),
|
|
60
|
+
AztecAddress.fromString('0x090dc318c793abc5ee9a560dcf9f0ba54c73902086dd7258cd48da8c79ef201a'),
|
|
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('0x12f22ad1b89f09c9a684cb5f36820a7d678527270547e489536c586d3c1756a4');
|
|
54
69
|
|
|
55
70
|
|
|
56
71
|
|
|
57
|
-
export const
|
|
58
|
-
export const REGISTERER_PRIVATE_FUNCTION_BROADCASTED_TAG = Fr.fromHexString('0x0abf338154e355442d9916d630da0491036d5a7b23c42b477c1395ba3bf9b42d');
|
|
59
|
-
export const REGISTERER_UNCONSTRAINED_FUNCTION_BROADCASTED_TAG = Fr.fromHexString('0x27774539896271d6dbe0c1de45ddc44709d1e8d9a9fb686ca3c105d87c417bb8');
|
|
60
|
-
export const DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_TAG = Fr.fromHexString('0x2ec28b91a5f838506d6042915005ff55cf7a0a5f889a83b11faed33a31b486f2');
|
|
61
|
-
export const DEPLOYER_CONTRACT_INSTANCE_UPDATED_TAG = new Fr(1534834688047131268740281708431107902615560100979874281215533519862n);
|
|
72
|
+
export const CONTRACT_INSTANCE_PUBLISHED_EVENT_TAG = Fr.fromHexString('0x28da3fc471387d4e20b646b77abc8cdfc02a339a7507285a73d84f9b97b13486');
|
|
62
73
|
|
|
63
74
|
|
package/src/provider/bundle.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
2
2
|
|
|
3
3
|
import { AuthRegistryArtifact } from '../auth-registry/index.js';
|
|
4
|
-
import {
|
|
4
|
+
import { ContractClassRegistryArtifact } from '../class-registry/index.js';
|
|
5
5
|
import { FeeJuiceArtifact } from '../fee-juice/index.js';
|
|
6
|
-
import {
|
|
6
|
+
import { ContractInstanceRegistryArtifact } from '../instance-registry/index.js';
|
|
7
7
|
import { makeProtocolContract } from '../make_protocol_contract.js';
|
|
8
8
|
import { MultiCallEntrypointArtifact } from '../multi-call-entrypoint/index.js';
|
|
9
9
|
import type { ProtocolContract } from '../protocol_contract.js';
|
|
@@ -13,8 +13,8 @@ import type { ProtocolContractsProvider } from './protocol_contracts_provider.js
|
|
|
13
13
|
|
|
14
14
|
export const ProtocolContractArtifact: Record<ProtocolContractName, ContractArtifact> = {
|
|
15
15
|
AuthRegistry: AuthRegistryArtifact,
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
ContractInstanceRegistry: ContractInstanceRegistryArtifact,
|
|
17
|
+
ContractClassRegistry: ContractClassRegistryArtifact,
|
|
18
18
|
MultiCallEntrypoint: MultiCallEntrypointArtifact,
|
|
19
19
|
FeeJuice: FeeJuiceArtifact,
|
|
20
20
|
Router: RouterArtifact,
|
package/src/provider/lazy.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getCanonicalAuthRegistry } from '../auth-registry/lazy.js';
|
|
2
|
-
import {
|
|
2
|
+
import { getCanonicalClassRegistry } from '../class-registry/lazy.js';
|
|
3
3
|
import { getCanonicalFeeJuice } from '../fee-juice/lazy.js';
|
|
4
|
-
import {
|
|
4
|
+
import { getCanonicalInstanceRegistry } from '../instance-registry/lazy.js';
|
|
5
5
|
import { getCanonicalMultiCallEntrypoint } from '../multi-call-entrypoint/lazy.js';
|
|
6
6
|
import type { ProtocolContract } from '../protocol_contract.js';
|
|
7
7
|
import type { ProtocolContractName } from '../protocol_contract_data.js';
|
|
@@ -13,10 +13,10 @@ export class LazyProtocolContractsProvider implements ProtocolContractsProvider
|
|
|
13
13
|
switch (name) {
|
|
14
14
|
case 'AuthRegistry':
|
|
15
15
|
return getCanonicalAuthRegistry();
|
|
16
|
-
case '
|
|
17
|
-
return
|
|
18
|
-
case '
|
|
19
|
-
return
|
|
16
|
+
case 'ContractInstanceRegistry':
|
|
17
|
+
return getCanonicalInstanceRegistry();
|
|
18
|
+
case 'ContractClassRegistry':
|
|
19
|
+
return getCanonicalClassRegistry();
|
|
20
20
|
case 'MultiCallEntrypoint':
|
|
21
21
|
return getCanonicalMultiCallEntrypoint();
|
|
22
22
|
case 'FeeJuice':
|
package/src/router/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
2
2
|
import type { NoirCompiledContract } from '@aztec/stdlib/noir';
|
|
3
3
|
|
|
4
|
-
import RouterJson from '../../artifacts/Router.json'
|
|
4
|
+
import RouterJson from '../../artifacts/Router.json' with { type: 'json' };
|
|
5
5
|
import { makeProtocolContract } from '../make_protocol_contract.js';
|
|
6
6
|
import type { ProtocolContract } from '../protocol_contract.js';
|
|
7
7
|
|
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);
|
package/src/tests/fixtures.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { dirname, resolve } from 'path';
|
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
|
|
5
5
|
// Generated from end-to-end/src/e2e_deploy_contract/contract_class_registration.test.ts with AZTEC_GENERATE_TEST_DATA=1
|
|
6
|
-
export function
|
|
7
|
-
const path = getPathToFixture('
|
|
6
|
+
export function getSampleContractClassPublishedEventPayload(): Buffer {
|
|
7
|
+
const path = getPathToFixture('ContractClassPublishedEventData.hex');
|
|
8
8
|
return Buffer.from(readFileSync(path).toString(), 'hex');
|
|
9
9
|
}
|
|
10
10
|
|
|
@@ -15,14 +15,14 @@ export function getSamplePrivateFunctionBroadcastedEventPayload(): Buffer {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
// Generated from end-to-end/src/e2e_deploy_contract/contract_class_registration.test.ts with AZTEC_GENERATE_TEST_DATA=1
|
|
18
|
-
export function
|
|
19
|
-
const path = getPathToFixture('
|
|
18
|
+
export function getSampleUtilityFunctionBroadcastedEventPayload(): Buffer {
|
|
19
|
+
const path = getPathToFixture('UtilityFunctionBroadcastedEventData.hex');
|
|
20
20
|
return Buffer.from(readFileSync(path).toString(), 'hex');
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
// Generated from end-to-end/src/e2e_deploy_contract/contract_class_registration.test.ts with AZTEC_GENERATE_TEST_DATA=1
|
|
24
|
-
export function
|
|
25
|
-
const path = getPathToFixture('
|
|
24
|
+
export function getSampleContractInstancePublishedEventPayload(): Buffer {
|
|
25
|
+
const path = getPathToFixture('ContractInstancePublishedEventData.hex');
|
|
26
26
|
return Buffer.from(readFileSync(path).toString(), 'hex');
|
|
27
27
|
}
|
|
28
28
|
|