@aztec/protocol-contracts 0.76.4 → 0.77.0-testnet-ignition.21
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.d.json.ts +1 -1
- package/artifacts/AuthRegistry.json +348 -416
- package/artifacts/ContractClassRegisterer.d.json.ts +1 -1
- package/artifacts/ContractClassRegisterer.json +347 -374
- package/artifacts/ContractInstanceDeployer.d.json.ts +1 -1
- package/artifacts/ContractInstanceDeployer.json +581 -174
- package/artifacts/FeeJuice.d.json.ts +1 -1
- package/artifacts/FeeJuice.json +593 -773
- package/artifacts/MultiCallEntrypoint.d.json.ts +1 -1
- package/artifacts/MultiCallEntrypoint.json +76 -156
- package/artifacts/Router.d.json.ts +1 -1
- package/artifacts/Router.json +361 -435
- package/dest/auth-registry/index.d.ts +2 -2
- package/dest/auth-registry/index.d.ts.map +1 -1
- package/dest/auth-registry/index.js +5 -5
- package/dest/auth-registry/lazy.d.ts +6 -0
- package/dest/auth-registry/lazy.d.ts.map +1 -0
- package/dest/auth-registry/lazy.js +23 -0
- package/dest/build_protocol_contract_tree.d.ts +5 -1
- package/dest/build_protocol_contract_tree.d.ts.map +1 -1
- package/dest/build_protocol_contract_tree.js +9 -5
- package/dest/class-registerer/contract_class_registered_event.d.ts +4 -3
- package/dest/class-registerer/contract_class_registered_event.d.ts.map +1 -1
- package/dest/class-registerer/contract_class_registered_event.js +21 -18
- package/dest/class-registerer/index.d.ts +2 -2
- package/dest/class-registerer/index.d.ts.map +1 -1
- package/dest/class-registerer/index.js +5 -5
- package/dest/class-registerer/lazy.d.ts +9 -0
- package/dest/class-registerer/lazy.d.ts.map +1 -0
- package/dest/class-registerer/lazy.js +26 -0
- package/dest/class-registerer/private_function_broadcasted_event.d.ts +10 -7
- package/dest/class-registerer/private_function_broadcasted_event.d.ts.map +1 -1
- package/dest/class-registerer/private_function_broadcasted_event.js +46 -48
- package/dest/class-registerer/unconstrained_function_broadcasted_event.d.ts +10 -7
- package/dest/class-registerer/unconstrained_function_broadcasted_event.d.ts.map +1 -1
- package/dest/class-registerer/unconstrained_function_broadcasted_event.js +39 -41
- package/dest/fee-juice/index.d.ts +12 -2
- package/dest/fee-juice/index.d.ts.map +1 -1
- package/dest/fee-juice/index.js +18 -5
- package/dest/fee-juice/lazy.d.ts +6 -0
- package/dest/fee-juice/lazy.d.ts.map +1 -0
- package/dest/fee-juice/lazy.js +23 -0
- package/dest/index.js +0 -1
- package/dest/instance-deployer/contract_instance_deployed_event.d.ts +4 -2
- package/dest/instance-deployer/contract_instance_deployed_event.d.ts.map +1 -1
- package/dest/instance-deployer/contract_instance_deployed_event.js +14 -8
- package/dest/instance-deployer/contract_instance_updated_event.d.ts +16 -0
- package/dest/instance-deployer/contract_instance_updated_event.d.ts.map +1 -0
- package/dest/instance-deployer/contract_instance_updated_event.js +36 -0
- package/dest/instance-deployer/index.d.ts +3 -2
- package/dest/instance-deployer/index.d.ts.map +1 -1
- package/dest/instance-deployer/index.js +6 -5
- package/dest/instance-deployer/lazy.d.ts +8 -0
- package/dest/instance-deployer/lazy.d.ts.map +1 -0
- package/dest/instance-deployer/lazy.js +25 -0
- package/dest/make_protocol_contract.d.ts +2 -2
- package/dest/make_protocol_contract.d.ts.map +1 -1
- package/dest/make_protocol_contract.js +10 -7
- package/dest/multi-call-entrypoint/index.d.ts +2 -2
- package/dest/multi-call-entrypoint/index.d.ts.map +1 -1
- package/dest/multi-call-entrypoint/index.js +5 -5
- package/dest/multi-call-entrypoint/lazy.d.ts +6 -0
- package/dest/multi-call-entrypoint/lazy.d.ts.map +1 -0
- package/dest/multi-call-entrypoint/lazy.js +23 -0
- package/dest/protocol_contract.d.ts +4 -2
- package/dest/protocol_contract.d.ts.map +1 -1
- package/dest/protocol_contract.js +1 -2
- package/dest/protocol_contract_data.d.ts +4 -2
- package/dest/protocol_contract_data.d.ts.map +1 -1
- package/dest/protocol_contract_data.js +16 -15
- package/dest/protocol_contract_tree.d.ts +4 -3
- package/dest/protocol_contract_tree.d.ts.map +1 -1
- package/dest/protocol_contract_tree.js +14 -12
- package/dest/provider/bundle.d.ts +9 -0
- package/dest/provider/bundle.d.ts.map +1 -0
- package/dest/provider/bundle.js +20 -0
- package/dest/provider/lazy.d.ts +7 -0
- package/dest/provider/lazy.d.ts.map +1 -0
- package/dest/provider/lazy.js +26 -0
- package/dest/provider/protocol_contracts_provider.d.ts +7 -0
- package/dest/provider/protocol_contracts_provider.d.ts.map +1 -0
- package/dest/provider/protocol_contracts_provider.js +1 -0
- package/dest/router/index.d.ts +2 -2
- package/dest/router/index.d.ts.map +1 -1
- package/dest/router/index.js +5 -5
- package/dest/router/lazy.d.ts +6 -0
- package/dest/router/lazy.d.ts.map +1 -0
- package/dest/router/lazy.js +23 -0
- package/dest/scripts/cleanup_artifacts.js +16 -0
- package/dest/scripts/generate_data.js +173 -0
- package/dest/tests/fixtures.js +0 -1
- package/package.json +12 -10
- package/src/auth-registry/index.ts +3 -3
- package/src/auth-registry/lazy.ts +29 -0
- package/src/build_protocol_contract_tree.ts +5 -9
- package/src/class-registerer/contract_class_registered_event.ts +15 -18
- package/src/class-registerer/index.ts +3 -3
- package/src/class-registerer/lazy.ts +33 -0
- package/src/class-registerer/private_function_broadcasted_event.ts +34 -44
- package/src/class-registerer/unconstrained_function_broadcasted_event.ts +31 -41
- package/src/fee-juice/index.ts +22 -3
- package/src/fee-juice/lazy.ts +29 -0
- package/src/instance-deployer/contract_instance_deployed_event.ts +6 -3
- package/src/instance-deployer/contract_instance_updated_event.ts +44 -0
- package/src/instance-deployer/index.ts +4 -3
- package/src/instance-deployer/lazy.ts +32 -0
- package/src/make_protocol_contract.ts +3 -3
- package/src/multi-call-entrypoint/index.ts +3 -3
- package/src/multi-call-entrypoint/lazy.ts +29 -0
- package/src/protocol_contract.ts +5 -7
- package/src/protocol_contract_data.ts +63 -57
- package/src/protocol_contract_tree.ts +12 -10
- package/src/provider/bundle.ts +27 -0
- package/src/provider/lazy.ts +30 -0
- package/src/provider/protocol_contracts_provider.ts +7 -0
- package/src/router/index.ts +3 -3
- package/src/router/lazy.ts +29 -0
- package/dest/bundle/index.d.ts +0 -7
- package/dest/bundle/index.d.ts.map +0 -1
- package/dest/bundle/index.js +0 -32
- package/src/bundle/index.ts +0 -36
|
@@ -1,15 +1,14 @@
|
|
|
1
|
+
import { PUBLIC_DISPATCH_SELECTOR } from '@aztec/constants';
|
|
2
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
3
|
+
import { FieldReader } from '@aztec/foundation/serialize';
|
|
4
|
+
import { FunctionSelector, bufferFromFields } from '@aztec/stdlib/abi';
|
|
1
5
|
import {
|
|
2
6
|
type ContractClassPublic,
|
|
3
|
-
PUBLIC_DISPATCH_SELECTOR,
|
|
4
7
|
type PublicFunction,
|
|
5
8
|
computeContractClassId,
|
|
6
9
|
computePublicBytecodeCommitment,
|
|
7
|
-
} from '@aztec/
|
|
8
|
-
import {
|
|
9
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
10
|
-
import { BufferReader } from '@aztec/foundation/serialize';
|
|
11
|
-
|
|
12
|
-
import chunk from 'lodash.chunk';
|
|
10
|
+
} from '@aztec/stdlib/contract';
|
|
11
|
+
import type { ContractClassLog } from '@aztec/stdlib/logs';
|
|
13
12
|
|
|
14
13
|
import { REGISTERER_CONTRACT_CLASS_REGISTERED_TAG } from '../protocol_contract_data.js';
|
|
15
14
|
|
|
@@ -23,19 +22,17 @@ export class ContractClassRegisteredEvent {
|
|
|
23
22
|
public readonly packedPublicBytecode: Buffer,
|
|
24
23
|
) {}
|
|
25
24
|
|
|
26
|
-
static isContractClassRegisteredEvent(log:
|
|
27
|
-
return log.
|
|
25
|
+
static isContractClassRegisteredEvent(log: ContractClassLog) {
|
|
26
|
+
return log.fields[0].equals(REGISTERER_CONTRACT_CLASS_REGISTERED_TAG);
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
static fromLog(log:
|
|
31
|
-
const reader = new
|
|
32
|
-
const contractClassId = reader.
|
|
33
|
-
const version = reader.
|
|
34
|
-
const artifactHash = reader.
|
|
35
|
-
const privateFunctionsRoot = reader.
|
|
36
|
-
const packedPublicBytecode = bufferFromFields(
|
|
37
|
-
chunk(reader.readToEnd(), Fr.SIZE_IN_BYTES).map(Buffer.from).map(Fr.fromBuffer),
|
|
38
|
-
);
|
|
29
|
+
static fromLog(log: ContractClassLog) {
|
|
30
|
+
const reader = new FieldReader(log.fields.slice(1));
|
|
31
|
+
const contractClassId = reader.readField();
|
|
32
|
+
const version = reader.readField().toNumber();
|
|
33
|
+
const artifactHash = reader.readField();
|
|
34
|
+
const privateFunctionsRoot = reader.readField();
|
|
35
|
+
const packedPublicBytecode = bufferFromFields(reader.readFieldArray(log.fields.slice(1).length - reader.cursor));
|
|
39
36
|
|
|
40
37
|
return new ContractClassRegisteredEvent(
|
|
41
38
|
contractClassId,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { loadContractArtifact } from '@aztec/
|
|
2
|
-
import {
|
|
1
|
+
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
2
|
+
import type { NoirCompiledContract } from '@aztec/stdlib/noir';
|
|
3
3
|
|
|
4
4
|
import ContractClassRegistererJson from '../../artifacts/ContractClassRegisterer.json' assert { type: 'json' };
|
|
5
5
|
import { makeProtocolContract } from '../make_protocol_contract.js';
|
|
6
|
-
import {
|
|
6
|
+
import type { ProtocolContract } from '../protocol_contract.js';
|
|
7
7
|
|
|
8
8
|
export * from './contract_class_registered_event.js';
|
|
9
9
|
export * from './private_function_broadcasted_event.js';
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
export * from './contract_class_registered_event.js';
|
|
7
|
+
export * from './private_function_broadcasted_event.js';
|
|
8
|
+
export * from './unconstrained_function_broadcasted_event.js';
|
|
9
|
+
|
|
10
|
+
let protocolContract: ProtocolContract;
|
|
11
|
+
let protocolContractArtifact: ContractArtifact;
|
|
12
|
+
|
|
13
|
+
export async function getContractClassRegistererArtifact(): Promise<ContractArtifact> {
|
|
14
|
+
if (!protocolContractArtifact) {
|
|
15
|
+
// Cannot assert this import as it's incompatible with browsers
|
|
16
|
+
// https://caniuse.com/mdn-javascript_statements_import_import_assertions_type_json
|
|
17
|
+
// Use the new "with" syntax once supported by firefox
|
|
18
|
+
// https://caniuse.com/mdn-javascript_statements_import_import_attributes_type_json
|
|
19
|
+
// In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
|
|
20
|
+
const { default: contractClassRegistererJson } = await import('../../artifacts/ContractClassRegisterer.json');
|
|
21
|
+
protocolContractArtifact = loadContractArtifact(contractClassRegistererJson);
|
|
22
|
+
}
|
|
23
|
+
return protocolContractArtifact;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Returns the canonical deployment of the auth registry. */
|
|
27
|
+
export async function getCanonicalClassRegisterer(): Promise<ProtocolContract> {
|
|
28
|
+
if (!protocolContract) {
|
|
29
|
+
const contractClassRegistererArtifact = await getContractClassRegistererArtifact();
|
|
30
|
+
protocolContract = await makeProtocolContract('ContractClassRegisterer', contractClassRegistererArtifact);
|
|
31
|
+
}
|
|
32
|
+
return protocolContract;
|
|
33
|
+
}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ARTIFACT_FUNCTION_TREE_MAX_HEIGHT,
|
|
3
|
-
type ExecutablePrivateFunctionWithMembershipProof,
|
|
4
3
|
FUNCTION_TREE_HEIGHT,
|
|
5
4
|
MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS,
|
|
6
|
-
|
|
7
|
-
REGISTERER_PRIVATE_FUNCTION_BROADCASTED_ADDITIONAL_FIELDS,
|
|
8
|
-
} from '@aztec/circuits.js';
|
|
9
|
-
import { FunctionSelector, bufferFromFields } from '@aztec/foundation/abi';
|
|
5
|
+
} from '@aztec/constants';
|
|
10
6
|
import { Fr } from '@aztec/foundation/fields';
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
import
|
|
7
|
+
import type { Tuple } from '@aztec/foundation/serialize';
|
|
8
|
+
import { FieldReader } from '@aztec/foundation/serialize';
|
|
9
|
+
import { FunctionSelector, bufferFromFields } from '@aztec/stdlib/abi';
|
|
10
|
+
import type { ExecutablePrivateFunctionWithMembershipProof, PrivateFunction } from '@aztec/stdlib/contract';
|
|
11
|
+
import type { ContractClassLog } from '@aztec/stdlib/logs';
|
|
14
12
|
|
|
15
13
|
import { REGISTERER_PRIVATE_FUNCTION_BROADCASTED_TAG } from '../protocol_contract_data.js';
|
|
16
14
|
|
|
@@ -27,42 +25,33 @@ export class PrivateFunctionBroadcastedEvent {
|
|
|
27
25
|
public readonly privateFunction: BroadcastedPrivateFunction,
|
|
28
26
|
) {}
|
|
29
27
|
|
|
30
|
-
static isPrivateFunctionBroadcastedEvent(log:
|
|
31
|
-
return log.
|
|
28
|
+
static isPrivateFunctionBroadcastedEvent(log: ContractClassLog) {
|
|
29
|
+
return log.fields[0].equals(REGISTERER_PRIVATE_FUNCTION_BROADCASTED_TAG);
|
|
32
30
|
}
|
|
33
31
|
|
|
34
|
-
static fromLog(log:
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const reader = new BufferReader(log.subarray(32));
|
|
46
|
-
const event = PrivateFunctionBroadcastedEvent.fromBuffer(reader);
|
|
47
|
-
if (!reader.isEmpty()) {
|
|
48
|
-
throw new Error(
|
|
49
|
-
`Unexpected data after parsing PrivateFunctionBroadcastedEvent: ${reader.readToEnd().toString('hex')}`,
|
|
50
|
-
);
|
|
32
|
+
static fromLog(log: ContractClassLog) {
|
|
33
|
+
const reader = new FieldReader(log.fields.slice(1));
|
|
34
|
+
const event = PrivateFunctionBroadcastedEvent.fromFields(reader);
|
|
35
|
+
while (!reader.isFinished()) {
|
|
36
|
+
const field = reader.readField();
|
|
37
|
+
if (!field.isZero()) {
|
|
38
|
+
throw new Error(`Unexpected data after parsing PrivateFunctionBroadcastedEvent: ${field.toString()}`);
|
|
39
|
+
}
|
|
51
40
|
}
|
|
52
41
|
|
|
53
42
|
return event;
|
|
54
43
|
}
|
|
55
44
|
|
|
56
|
-
static
|
|
57
|
-
const reader =
|
|
58
|
-
const contractClassId = reader.
|
|
59
|
-
const artifactMetadataHash = reader.
|
|
60
|
-
const unconstrainedFunctionsArtifactTreeRoot = reader.
|
|
61
|
-
const privateFunctionTreeSiblingPath = reader.
|
|
62
|
-
const privateFunctionTreeLeafIndex = reader.
|
|
63
|
-
const artifactFunctionTreeSiblingPath = reader.
|
|
64
|
-
const artifactFunctionTreeLeafIndex = reader.
|
|
65
|
-
const privateFunction = BroadcastedPrivateFunction.
|
|
45
|
+
static fromFields(fields: Fr[] | FieldReader) {
|
|
46
|
+
const reader = FieldReader.asReader(fields);
|
|
47
|
+
const contractClassId = reader.readField();
|
|
48
|
+
const artifactMetadataHash = reader.readField();
|
|
49
|
+
const unconstrainedFunctionsArtifactTreeRoot = reader.readField();
|
|
50
|
+
const privateFunctionTreeSiblingPath = reader.readFieldArray(FUNCTION_TREE_HEIGHT);
|
|
51
|
+
const privateFunctionTreeLeafIndex = reader.readField().toNumber();
|
|
52
|
+
const artifactFunctionTreeSiblingPath = reader.readFieldArray(ARTIFACT_FUNCTION_TREE_MAX_HEIGHT);
|
|
53
|
+
const artifactFunctionTreeLeafIndex = reader.readField().toNumber();
|
|
54
|
+
const privateFunction = BroadcastedPrivateFunction.fromFields(reader);
|
|
66
55
|
|
|
67
56
|
return new PrivateFunctionBroadcastedEvent(
|
|
68
57
|
contractClassId,
|
|
@@ -103,13 +92,14 @@ export class BroadcastedPrivateFunction implements PrivateFunction {
|
|
|
103
92
|
public readonly bytecode: Buffer,
|
|
104
93
|
) {}
|
|
105
94
|
|
|
106
|
-
static
|
|
107
|
-
const reader =
|
|
108
|
-
const selector = FunctionSelector.fromField(reader.
|
|
109
|
-
const metadataHash = reader.
|
|
110
|
-
const vkHash = reader.
|
|
111
|
-
|
|
112
|
-
const
|
|
95
|
+
static fromFields(fields: Fr[] | FieldReader) {
|
|
96
|
+
const reader = FieldReader.asReader(fields);
|
|
97
|
+
const selector = FunctionSelector.fromField(reader.readField());
|
|
98
|
+
const metadataHash = reader.readField();
|
|
99
|
+
const vkHash = reader.readField();
|
|
100
|
+
// The '* 1' removes the 'Type instantiation is excessively deep and possibly infinite. ts(2589)' err
|
|
101
|
+
const encodedBytecode = reader.readFieldArray(MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS * 1);
|
|
102
|
+
const bytecode = bufferFromFields(encodedBytecode);
|
|
113
103
|
return new BroadcastedPrivateFunction(selector, metadataHash, vkHash, bytecode);
|
|
114
104
|
}
|
|
115
105
|
}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ARTIFACT_FUNCTION_TREE_MAX_HEIGHT,
|
|
3
3
|
MAX_PACKED_BYTECODE_SIZE_PER_UNCONSTRAINED_FUNCTION_IN_FIELDS,
|
|
4
|
-
|
|
5
|
-
type UnconstrainedFunction,
|
|
6
|
-
type UnconstrainedFunctionWithMembershipProof,
|
|
7
|
-
} from '@aztec/circuits.js';
|
|
8
|
-
import { FunctionSelector, bufferFromFields } from '@aztec/foundation/abi';
|
|
4
|
+
} from '@aztec/constants';
|
|
9
5
|
import { removeArrayPaddingEnd } from '@aztec/foundation/collection';
|
|
10
6
|
import { Fr } from '@aztec/foundation/fields';
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
import
|
|
7
|
+
import type { Tuple } from '@aztec/foundation/serialize';
|
|
8
|
+
import { FieldReader } from '@aztec/foundation/serialize';
|
|
9
|
+
import { FunctionSelector, bufferFromFields } from '@aztec/stdlib/abi';
|
|
10
|
+
import type { UnconstrainedFunction, UnconstrainedFunctionWithMembershipProof } from '@aztec/stdlib/contract';
|
|
11
|
+
import type { ContractClassLog } from '@aztec/stdlib/logs';
|
|
14
12
|
|
|
15
13
|
import { REGISTERER_UNCONSTRAINED_FUNCTION_BROADCASTED_TAG } from '../protocol_contract_data.js';
|
|
16
14
|
|
|
@@ -25,40 +23,31 @@ export class UnconstrainedFunctionBroadcastedEvent {
|
|
|
25
23
|
public readonly unconstrainedFunction: BroadcastedUnconstrainedFunction,
|
|
26
24
|
) {}
|
|
27
25
|
|
|
28
|
-
static isUnconstrainedFunctionBroadcastedEvent(log:
|
|
29
|
-
return log.
|
|
26
|
+
static isUnconstrainedFunctionBroadcastedEvent(log: ContractClassLog) {
|
|
27
|
+
return log.fields[0].equals(REGISTERER_UNCONSTRAINED_FUNCTION_BROADCASTED_TAG);
|
|
30
28
|
}
|
|
31
29
|
|
|
32
|
-
static fromLog(log:
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const reader = new BufferReader(log.subarray(32));
|
|
44
|
-
const event = UnconstrainedFunctionBroadcastedEvent.fromBuffer(reader);
|
|
45
|
-
if (!reader.isEmpty()) {
|
|
46
|
-
throw new Error(
|
|
47
|
-
`Unexpected data after parsing UnconstrainedFunctionBroadcastedEvent: ${reader.readToEnd().toString('hex')}`,
|
|
48
|
-
);
|
|
30
|
+
static fromLog(log: ContractClassLog) {
|
|
31
|
+
const reader = new FieldReader(log.fields.slice(1));
|
|
32
|
+
const event = UnconstrainedFunctionBroadcastedEvent.fromFields(reader);
|
|
33
|
+
while (!reader.isFinished()) {
|
|
34
|
+
const field = reader.readField();
|
|
35
|
+
if (!field.isZero()) {
|
|
36
|
+
throw new Error(`Unexpected data after parsing UnconstrainedFunctionBroadcastedEvent: ${field.toString()}`);
|
|
37
|
+
}
|
|
49
38
|
}
|
|
50
39
|
|
|
51
40
|
return event;
|
|
52
41
|
}
|
|
53
42
|
|
|
54
|
-
static
|
|
55
|
-
const reader =
|
|
56
|
-
const contractClassId = reader.
|
|
57
|
-
const artifactMetadataHash = reader.
|
|
58
|
-
const privateFunctionsArtifactTreeRoot = reader.
|
|
59
|
-
const artifactFunctionTreeSiblingPath = reader.
|
|
60
|
-
const artifactFunctionTreeLeafIndex = reader.
|
|
61
|
-
const unconstrainedFunction = BroadcastedUnconstrainedFunction.
|
|
43
|
+
static fromFields(fields: Fr[] | FieldReader) {
|
|
44
|
+
const reader = FieldReader.asReader(fields);
|
|
45
|
+
const contractClassId = reader.readField();
|
|
46
|
+
const artifactMetadataHash = reader.readField();
|
|
47
|
+
const privateFunctionsArtifactTreeRoot = reader.readField();
|
|
48
|
+
const artifactFunctionTreeSiblingPath = reader.readFieldArray(ARTIFACT_FUNCTION_TREE_MAX_HEIGHT);
|
|
49
|
+
const artifactFunctionTreeLeafIndex = reader.readField().toNumber();
|
|
50
|
+
const unconstrainedFunction = BroadcastedUnconstrainedFunction.fromFields(reader);
|
|
62
51
|
|
|
63
52
|
return new UnconstrainedFunctionBroadcastedEvent(
|
|
64
53
|
contractClassId,
|
|
@@ -98,12 +87,13 @@ export class BroadcastedUnconstrainedFunction implements UnconstrainedFunction {
|
|
|
98
87
|
public readonly bytecode: Buffer,
|
|
99
88
|
) {}
|
|
100
89
|
|
|
101
|
-
static
|
|
102
|
-
const reader =
|
|
103
|
-
const selector = FunctionSelector.fromField(reader.
|
|
104
|
-
const metadataHash = reader.
|
|
105
|
-
|
|
106
|
-
const
|
|
90
|
+
static fromFields(fields: Fr[] | FieldReader) {
|
|
91
|
+
const reader = FieldReader.asReader(fields);
|
|
92
|
+
const selector = FunctionSelector.fromField(reader.readField());
|
|
93
|
+
const metadataHash = reader.readField();
|
|
94
|
+
// The '* 1' removes the 'Type instantiation is excessively deep and possibly infinite. ts(2589)' err
|
|
95
|
+
const encodedBytecode = reader.readFieldArray(MAX_PACKED_BYTECODE_SIZE_PER_UNCONSTRAINED_FUNCTION_IN_FIELDS * 1);
|
|
96
|
+
const bytecode = bufferFromFields(encodedBytecode);
|
|
107
97
|
return new BroadcastedUnconstrainedFunction(selector, metadataHash, bytecode);
|
|
108
98
|
}
|
|
109
99
|
}
|
package/src/fee-juice/index.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
3
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
import { computePublicDataTreeLeafSlot, deriveStorageSlotInMap } from '@aztec/stdlib/hash';
|
|
5
|
+
import type { NoirCompiledContract } from '@aztec/stdlib/noir';
|
|
3
6
|
|
|
4
7
|
import FeeJuiceJson from '../../artifacts/FeeJuice.json' assert { type: 'json' };
|
|
5
8
|
import { makeProtocolContract } from '../make_protocol_contract.js';
|
|
6
|
-
import {
|
|
9
|
+
import type { ProtocolContract } from '../protocol_contract.js';
|
|
10
|
+
import { ProtocolContractAddress } from '../protocol_contract_data.js';
|
|
7
11
|
|
|
8
12
|
export const FeeJuiceArtifact = loadContractArtifact(FeeJuiceJson as NoirCompiledContract);
|
|
9
13
|
|
|
@@ -16,3 +20,18 @@ export async function getCanonicalFeeJuice(): Promise<ProtocolContract> {
|
|
|
16
20
|
}
|
|
17
21
|
return protocolContract;
|
|
18
22
|
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Computes the storage slot within the Fee Juice contract for the balance of the fee payer.
|
|
26
|
+
*/
|
|
27
|
+
export function computeFeePayerBalanceStorageSlot(feePayer: AztecAddress): Promise<Fr> {
|
|
28
|
+
return deriveStorageSlotInMap(FeeJuiceArtifact.storageLayout.balances.slot, feePayer);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Computes the leaf slot in the public data tree for the balance of the fee payer in the Fee Juice.
|
|
33
|
+
*/
|
|
34
|
+
export async function computeFeePayerBalanceLeafSlot(feePayer: AztecAddress): Promise<Fr> {
|
|
35
|
+
const balanceSlot = await computeFeePayerBalanceStorageSlot(feePayer);
|
|
36
|
+
return computePublicDataTreeLeafSlot(ProtocolContractAddress.FeeJuice, balanceSlot);
|
|
37
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
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 getFeeJuiceArtifact(): Promise<ContractArtifact> {
|
|
10
|
+
if (!protocolContractArtifact) {
|
|
11
|
+
// Cannot assert this import as it's incompatible with browsers
|
|
12
|
+
// https://caniuse.com/mdn-javascript_statements_import_import_assertions_type_json
|
|
13
|
+
// Use the new "with" syntax once supported by firefox
|
|
14
|
+
// https://caniuse.com/mdn-javascript_statements_import_import_attributes_type_json
|
|
15
|
+
// In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
|
|
16
|
+
const { default: feeJuiceJson } = await import('../../artifacts/FeeJuice.json');
|
|
17
|
+
protocolContractArtifact = loadContractArtifact(feeJuiceJson);
|
|
18
|
+
}
|
|
19
|
+
return protocolContractArtifact;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Returns the canonical deployment of the auth registry. */
|
|
23
|
+
export async function getCanonicalFeeJuice(): Promise<ProtocolContract> {
|
|
24
|
+
if (!protocolContract) {
|
|
25
|
+
const feeJuiceArtifact = await getFeeJuiceArtifact();
|
|
26
|
+
protocolContract = await makeProtocolContract('FeeJuice', feeJuiceArtifact);
|
|
27
|
+
}
|
|
28
|
+
return protocolContract;
|
|
29
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { type ContractInstanceWithAddress, type PrivateLog, PublicKeys } from '@aztec/circuits.js';
|
|
2
|
-
import { AztecAddress } from '@aztec/foundation/aztec-address';
|
|
3
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
4
2
|
import { BufferReader } from '@aztec/foundation/serialize';
|
|
3
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
5
|
+
import { PublicKeys } from '@aztec/stdlib/keys';
|
|
6
|
+
import type { PrivateLog } from '@aztec/stdlib/logs';
|
|
5
7
|
|
|
6
8
|
import { DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_TAG } from '../protocol_contract_data.js';
|
|
7
9
|
|
|
@@ -51,7 +53,8 @@ export class ContractInstanceDeployedEvent {
|
|
|
51
53
|
return {
|
|
52
54
|
address: this.address,
|
|
53
55
|
version: this.version,
|
|
54
|
-
|
|
56
|
+
currentContractClassId: this.contractClassId,
|
|
57
|
+
originalContractClassId: this.contractClassId,
|
|
55
58
|
initializationHash: this.initializationHash,
|
|
56
59
|
publicKeys: this.publicKeys,
|
|
57
60
|
salt: this.salt,
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { BufferReader } from '@aztec/foundation/serialize';
|
|
3
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
import type { ContractInstanceUpdateWithAddress } from '@aztec/stdlib/contract';
|
|
5
|
+
import type { PublicLog } from '@aztec/stdlib/logs';
|
|
6
|
+
|
|
7
|
+
import { DEPLOYER_CONTRACT_INSTANCE_UPDATED_TAG, ProtocolContractAddress } from '../protocol_contract_data.js';
|
|
8
|
+
|
|
9
|
+
/** Event emitted from the ContractInstanceDeployer. */
|
|
10
|
+
export class ContractInstanceUpdatedEvent {
|
|
11
|
+
constructor(
|
|
12
|
+
public readonly address: AztecAddress,
|
|
13
|
+
public readonly prevContractClassId: Fr,
|
|
14
|
+
public readonly newContractClassId: Fr,
|
|
15
|
+
public readonly blockOfChange: number,
|
|
16
|
+
) {}
|
|
17
|
+
|
|
18
|
+
static isContractInstanceUpdatedEvent(log: PublicLog) {
|
|
19
|
+
return (
|
|
20
|
+
log.contractAddress.equals(ProtocolContractAddress.ContractInstanceDeployer) &&
|
|
21
|
+
log.log[0].equals(DEPLOYER_CONTRACT_INSTANCE_UPDATED_TAG)
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static fromLog(log: PublicLog) {
|
|
26
|
+
const bufferWithoutAddressAndTag = log.toBuffer().subarray(64);
|
|
27
|
+
const reader = new BufferReader(bufferWithoutAddressAndTag);
|
|
28
|
+
const address = reader.readObject(AztecAddress);
|
|
29
|
+
const prevContractClassId = reader.readObject(Fr);
|
|
30
|
+
const newContractClassId = reader.readObject(Fr);
|
|
31
|
+
const blockOfChange = reader.readObject(Fr).toNumber();
|
|
32
|
+
|
|
33
|
+
return new ContractInstanceUpdatedEvent(address, prevContractClassId, newContractClassId, blockOfChange);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
toContractInstanceUpdate(): ContractInstanceUpdateWithAddress {
|
|
37
|
+
return {
|
|
38
|
+
address: this.address,
|
|
39
|
+
prevContractClassId: this.prevContractClassId,
|
|
40
|
+
newContractClassId: this.newContractClassId,
|
|
41
|
+
blockOfChange: this.blockOfChange,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { loadContractArtifact } from '@aztec/
|
|
2
|
-
import {
|
|
1
|
+
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
2
|
+
import type { NoirCompiledContract } from '@aztec/stdlib/noir';
|
|
3
3
|
|
|
4
4
|
import ContractInstanceDeployerJson from '../../artifacts/ContractInstanceDeployer.json' assert { type: 'json' };
|
|
5
5
|
import { makeProtocolContract } from '../make_protocol_contract.js';
|
|
6
|
-
import {
|
|
6
|
+
import type { ProtocolContract } from '../protocol_contract.js';
|
|
7
7
|
|
|
8
8
|
export * from './contract_instance_deployed_event.js';
|
|
9
|
+
export * from './contract_instance_updated_event.js';
|
|
9
10
|
|
|
10
11
|
export const ContractInstanceDeployerArtifact = loadContractArtifact(
|
|
11
12
|
ContractInstanceDeployerJson as NoirCompiledContract,
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
export * from './contract_instance_deployed_event.js';
|
|
7
|
+
export * from './contract_instance_updated_event.js';
|
|
8
|
+
|
|
9
|
+
let protocolContract: ProtocolContract;
|
|
10
|
+
let protocolContractArtifact: ContractArtifact;
|
|
11
|
+
|
|
12
|
+
export async function getContractInstanceDeployerArtifact(): Promise<ContractArtifact> {
|
|
13
|
+
if (!protocolContractArtifact) {
|
|
14
|
+
// Cannot assert this import as it's incompatible with browsers
|
|
15
|
+
// https://caniuse.com/mdn-javascript_statements_import_import_assertions_type_json
|
|
16
|
+
// Use the new "with" syntax once supported by firefox
|
|
17
|
+
// https://caniuse.com/mdn-javascript_statements_import_import_attributes_type_json
|
|
18
|
+
// In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
|
|
19
|
+
const { default: contractInstanceDeployerJson } = await import('../../artifacts/ContractInstanceDeployer.json');
|
|
20
|
+
protocolContractArtifact = loadContractArtifact(contractInstanceDeployerJson);
|
|
21
|
+
}
|
|
22
|
+
return protocolContractArtifact;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Returns the canonical deployment of the auth registry. */
|
|
26
|
+
export async function getCanonicalInstanceDeployer(): Promise<ProtocolContract> {
|
|
27
|
+
if (!protocolContract) {
|
|
28
|
+
const contractInstanceDeployerArtifact = await getContractInstanceDeployerArtifact();
|
|
29
|
+
protocolContract = await makeProtocolContract('ContractInstanceDeployer', contractInstanceDeployerArtifact);
|
|
30
|
+
}
|
|
31
|
+
return protocolContract;
|
|
32
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
2
|
+
import { getContractClassFromArtifact, getContractInstanceFromDeployParams } from '@aztec/stdlib/contract';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import type { ProtocolContract } from './protocol_contract.js';
|
|
5
5
|
import { ProtocolContractAddress, type ProtocolContractName, ProtocolContractSalt } from './protocol_contract_data.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { loadContractArtifact } from '@aztec/
|
|
2
|
-
import {
|
|
1
|
+
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
2
|
+
import type { NoirCompiledContract } from '@aztec/stdlib/noir';
|
|
3
3
|
|
|
4
4
|
import MultiCallEntrypointJson from '../../artifacts/MultiCallEntrypoint.json' assert { type: 'json' };
|
|
5
5
|
import { makeProtocolContract } from '../make_protocol_contract.js';
|
|
6
|
-
import {
|
|
6
|
+
import type { ProtocolContract } from '../protocol_contract.js';
|
|
7
7
|
|
|
8
8
|
export const MultiCallEntrypointArtifact = loadContractArtifact(MultiCallEntrypointJson as NoirCompiledContract);
|
|
9
9
|
|
|
@@ -0,0 +1,29 @@
|
|
|
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 browsers
|
|
12
|
+
// https://caniuse.com/mdn-javascript_statements_import_import_assertions_type_json
|
|
13
|
+
// Use the new "with" syntax once supported by firefox
|
|
14
|
+
// https://caniuse.com/mdn-javascript_statements_import_import_attributes_type_json
|
|
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 = await makeProtocolContract('MultiCallEntrypoint', multiCallEntrypointArtifact);
|
|
27
|
+
}
|
|
28
|
+
return protocolContract;
|
|
29
|
+
}
|
package/src/protocol_contract.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
type ContractClassWithId,
|
|
5
|
-
type ContractInstanceWithAddress,
|
|
6
|
-
} from '@aztec/circuits.js';
|
|
7
|
-
import { type ContractArtifact } from '@aztec/foundation/abi';
|
|
1
|
+
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
2
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import type { ContractClassIdPreimage, ContractClassWithId, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
8
4
|
|
|
9
5
|
import { ProtocolContractAddress } from './protocol_contract_data.js';
|
|
10
6
|
|
|
@@ -23,3 +19,5 @@ export interface ProtocolContract {
|
|
|
23
19
|
export function isProtocolContract(address: AztecAddress) {
|
|
24
20
|
return Object.values(ProtocolContractAddress).some(a => a.equals(address));
|
|
25
21
|
}
|
|
22
|
+
|
|
23
|
+
export { type ProtocolContractsProvider } from './provider/protocol_contracts_provider.js';
|