@aztec/txe 0.0.0-test.1 → 0.0.1-commit.017a351
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/dest/ContractClassRegistry-PII7Q556.js +3 -0
- package/dest/ContractClassRegistry-PII7Q556.js.map +7 -0
- package/dest/ContractInstanceRegistry-3MHLGFNZ.js +3 -0
- package/dest/ContractInstanceRegistry-3MHLGFNZ.js.map +7 -0
- package/dest/FeeJuice-TQV5AQK7.js +3 -0
- package/dest/FeeJuice-TQV5AQK7.js.map +7 -0
- package/dest/MultiCallEntrypoint-SBJUIJY7.js +3 -0
- package/dest/MultiCallEntrypoint-SBJUIJY7.js.map +7 -0
- package/dest/SchnorrAccount-MQXPIZ44.js +3 -0
- package/dest/SchnorrAccount-MQXPIZ44.js.map +7 -0
- package/dest/bin/check_txe_oracle_version.d.ts +2 -0
- package/dest/bin/check_txe_oracle_version.d.ts.map +1 -0
- package/dest/bin/check_txe_oracle_version.js +61 -0
- package/dest/bin/index.d.ts +1 -1
- package/dest/bin/index.js +3 -29
- package/dest/bin/index.js.map +7 -0
- package/dest/bin/oracle_test_server.d.ts +3 -0
- package/dest/bin/oracle_test_server.d.ts.map +1 -0
- package/dest/bin/oracle_test_server.js +41 -0
- package/dest/chunk-BA54BEZH.js +265 -0
- package/dest/chunk-BA54BEZH.js.map +7 -0
- package/dest/chunk-BJVAAXNA.js +3 -0
- package/dest/chunk-BJVAAXNA.js.map +7 -0
- package/dest/chunk-ZKW35DT6.js +304 -0
- package/dest/chunk-ZKW35DT6.js.map +7 -0
- package/dest/constants.d.ts +7 -0
- package/dest/constants.d.ts.map +1 -0
- package/dest/constants.js +10 -0
- package/dest/dispatcher_pool.d.ts +67 -0
- package/dest/dispatcher_pool.d.ts.map +1 -0
- package/dest/dispatcher_pool.js +284 -0
- package/dest/index.d.ts +185 -7
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +76 -132
- package/dest/metafile.json +38691 -0
- package/dest/msgpackr_fr_extension.d.ts +2 -0
- package/dest/msgpackr_fr_extension.d.ts.map +1 -0
- package/dest/msgpackr_fr_extension.js +21 -0
- package/dest/oracle/interfaces.d.ts +83 -0
- package/dest/oracle/interfaces.d.ts.map +1 -0
- package/dest/oracle/interfaces.js +3 -0
- package/dest/oracle/test-resolver/fixtures.d.ts +43 -0
- package/dest/oracle/test-resolver/fixtures.d.ts.map +1 -0
- package/dest/oracle/test-resolver/fixtures.js +39 -0
- package/dest/oracle/test-resolver/index.d.ts +9 -0
- package/dest/oracle/test-resolver/index.d.ts.map +1 -0
- package/dest/oracle/test-resolver/index.js +33 -0
- package/dest/oracle/test-resolver/resolver.d.ts +34 -0
- package/dest/oracle/test-resolver/resolver.d.ts.map +1 -0
- package/dest/oracle/test-resolver/resolver.js +114 -0
- package/dest/oracle/txe_oracle_public_context.d.ts +58 -0
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -0
- package/dest/oracle/txe_oracle_public_context.js +164 -0
- package/dest/oracle/txe_oracle_registry.d.ts +147 -0
- package/dest/oracle/txe_oracle_registry.d.ts.map +1 -0
- package/dest/oracle/txe_oracle_registry.js +562 -0
- package/dest/oracle/txe_oracle_top_level_context.d.ts +85 -0
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -0
- package/dest/oracle/txe_oracle_top_level_context.js +634 -0
- package/dest/oracle/txe_oracle_version.d.ts +17 -0
- package/dest/oracle/txe_oracle_version.d.ts.map +1 -0
- package/dest/oracle/txe_oracle_version.js +14 -0
- package/dest/oracle/txe_private_execution_oracle.d.ts +17 -0
- package/dest/oracle/txe_private_execution_oracle.d.ts.map +1 -0
- package/dest/oracle/txe_private_execution_oracle.js +15 -0
- package/dest/rpc_server.d.ts +14 -0
- package/dest/rpc_server.d.ts.map +1 -0
- package/dest/rpc_server.js +78 -0
- package/dest/rpc_translator.d.ts +120 -0
- package/dest/rpc_translator.d.ts.map +1 -0
- package/dest/rpc_translator.js +882 -0
- package/dest/server.bundle.js +3 -0
- package/dest/server.bundle.js.map +7 -0
- package/dest/state_machine/archiver.d.ts +32 -0
- package/dest/state_machine/archiver.d.ts.map +1 -0
- package/dest/state_machine/archiver.js +96 -0
- package/dest/state_machine/dummy_p2p_client.d.ts +65 -0
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -0
- package/dest/state_machine/dummy_p2p_client.js +165 -0
- package/dest/state_machine/global_variable_builder.d.ts +16 -0
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -0
- package/dest/state_machine/global_variable_builder.js +28 -0
- package/dest/state_machine/index.d.ts +20 -0
- package/dest/state_machine/index.d.ts.map +1 -0
- package/dest/state_machine/index.js +86 -0
- package/dest/state_machine/mock_epoch_cache.d.ts +42 -0
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -0
- package/dest/state_machine/mock_epoch_cache.js +85 -0
- package/dest/state_machine/synchronizer.d.ts +33 -0
- package/dest/state_machine/synchronizer.d.ts.map +1 -0
- package/dest/state_machine/synchronizer.js +59 -0
- package/dest/txe_session.d.ts +140 -0
- package/dest/txe_session.d.ts.map +1 -0
- package/dest/txe_session.js +499 -0
- package/dest/utils/block_creation.d.ts +28 -0
- package/dest/utils/block_creation.d.ts.map +1 -0
- package/dest/utils/block_creation.js +58 -0
- package/dest/utils/encoding.d.ts +191 -0
- package/dest/utils/encoding.d.ts.map +1 -0
- package/dest/utils/encoding.js +136 -0
- package/dest/utils/expected_failure_error.d.ts +4 -0
- package/dest/utils/expected_failure_error.d.ts.map +1 -0
- package/dest/utils/tx_effect_creation.d.ts +5 -0
- package/dest/utils/tx_effect_creation.d.ts.map +1 -0
- package/dest/utils/tx_effect_creation.js +13 -0
- package/dest/utils/txe_account_store.d.ts +10 -0
- package/dest/utils/txe_account_store.d.ts.map +1 -0
- package/dest/{util/txe_account_data_provider.js → utils/txe_account_store.js} +1 -1
- package/dest/utils/txe_artifact_resolver.d.ts +37 -0
- package/dest/utils/txe_artifact_resolver.d.ts.map +1 -0
- package/dest/utils/txe_artifact_resolver.js +161 -0
- package/dest/utils/txe_public_contract_data_source.d.ts +20 -0
- package/dest/utils/txe_public_contract_data_source.d.ts.map +1 -0
- package/dest/utils/txe_public_contract_data_source.js +48 -0
- package/dest/worker.bundle.js +3 -0
- package/dest/worker.bundle.js.map +7 -0
- package/dest/worker.d.ts +2 -0
- package/dest/worker.d.ts.map +1 -0
- package/dest/worker.js +92 -0
- package/package.json +52 -29
- package/src/bin/check_txe_oracle_version.ts +70 -0
- package/src/bin/index.ts +14 -4
- package/src/bin/oracle_test_server.ts +51 -0
- package/src/constants.ts +13 -0
- package/src/dispatcher_pool.ts +316 -0
- package/src/index.ts +113 -175
- package/src/msgpackr_fr_extension.ts +23 -0
- package/src/oracle/interfaces.ts +109 -0
- package/src/oracle/test-resolver/fixtures.ts +84 -0
- package/src/oracle/test-resolver/index.ts +45 -0
- package/src/oracle/test-resolver/resolver.ts +165 -0
- package/src/oracle/txe_oracle_public_context.ts +218 -0
- package/src/oracle/txe_oracle_registry.ts +401 -0
- package/src/oracle/txe_oracle_top_level_context.ts +898 -0
- package/src/oracle/txe_oracle_version.ts +17 -0
- package/src/oracle/txe_private_execution_oracle.ts +30 -0
- package/src/rpc_server.ts +87 -0
- package/src/rpc_translator.ts +1103 -0
- package/src/state_machine/archiver.ts +119 -0
- package/src/state_machine/dummy_p2p_client.ts +247 -0
- package/src/state_machine/global_variable_builder.ts +53 -0
- package/src/state_machine/index.ts +135 -0
- package/src/state_machine/mock_epoch_cache.ts +107 -0
- package/src/state_machine/synchronizer.ts +88 -0
- package/src/txe_session.ts +799 -0
- package/src/utils/block_creation.ts +97 -0
- package/src/utils/encoding.ts +172 -0
- package/src/utils/tx_effect_creation.ts +30 -0
- package/src/{util/txe_account_data_provider.ts → utils/txe_account_store.ts} +1 -1
- package/src/utils/txe_artifact_resolver.ts +217 -0
- package/src/utils/txe_public_contract_data_source.ts +58 -0
- package/src/worker.ts +98 -0
- package/dest/node/txe_node.d.ts +0 -358
- package/dest/node/txe_node.d.ts.map +0 -1
- package/dest/node/txe_node.js +0 -504
- package/dest/oracle/txe_oracle.d.ts +0 -152
- package/dest/oracle/txe_oracle.d.ts.map +0 -1
- package/dest/oracle/txe_oracle.js +0 -833
- package/dest/txe_service/txe_service.d.ts +0 -212
- package/dest/txe_service/txe_service.d.ts.map +0 -1
- package/dest/txe_service/txe_service.js +0 -572
- package/dest/util/encoding.d.ts +0 -103
- package/dest/util/encoding.d.ts.map +0 -1
- package/dest/util/encoding.js +0 -76
- package/dest/util/expected_failure_error.d.ts +0 -4
- package/dest/util/expected_failure_error.d.ts.map +0 -1
- package/dest/util/txe_account_data_provider.d.ts +0 -10
- package/dest/util/txe_account_data_provider.d.ts.map +0 -1
- package/dest/util/txe_public_contract_data_source.d.ts +0 -20
- package/dest/util/txe_public_contract_data_source.d.ts.map +0 -1
- package/dest/util/txe_public_contract_data_source.js +0 -88
- package/dest/util/txe_world_state_db.d.ts +0 -14
- package/dest/util/txe_world_state_db.d.ts.map +0 -1
- package/dest/util/txe_world_state_db.js +0 -27
- package/src/node/txe_node.ts +0 -725
- package/src/oracle/txe_oracle.ts +0 -1241
- package/src/txe_service/txe_service.ts +0 -749
- package/src/util/encoding.ts +0 -92
- package/src/util/txe_public_contract_data_source.ts +0 -101
- package/src/util/txe_world_state_db.ts +0 -38
- /package/dest/{util → utils}/expected_failure_error.js +0 -0
- /package/src/{util → utils}/expected_failure_error.ts +0 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
+
import { type ContractArtifact } from '@aztec/stdlib/abi';
|
|
4
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
+
import { BlockHash } from '@aztec/stdlib/block';
|
|
6
|
+
import { type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
export type ForeignCallSingle = string;
|
|
9
|
+
export type ForeignCallArray = string[];
|
|
10
|
+
export type ForeignCallArgs = (ForeignCallSingle | ForeignCallArray | ContractArtifact | ContractInstanceWithAddress)[];
|
|
11
|
+
export type ForeignCallResult = {
|
|
12
|
+
values: (ForeignCallSingle | ForeignCallArray)[];
|
|
13
|
+
};
|
|
14
|
+
export declare function fromSingle(obj: ForeignCallSingle): Fr;
|
|
15
|
+
export declare function addressFromSingle(obj: ForeignCallSingle): AztecAddress;
|
|
16
|
+
export declare function blockHashFromSingle(obj: ForeignCallSingle): BlockHash;
|
|
17
|
+
export declare function fromArray(obj: ForeignCallArray): Fr[];
|
|
18
|
+
/**
|
|
19
|
+
* Converts an array of Noir unsigned integers to a single tightly-packed buffer.
|
|
20
|
+
* @param uintBitSize If it's an array of Noir u8's, put `8`, etc.
|
|
21
|
+
* @returns A buffer where each byte is correctly represented as a single byte in the buffer.
|
|
22
|
+
*/
|
|
23
|
+
export declare function fromUintArray(obj: ForeignCallArray, uintBitSize: number): Buffer;
|
|
24
|
+
/**
|
|
25
|
+
* Converts a Noir BoundedVec of unsigned integers into a Buffer. Note that BoundedVecs are structs, and therefore
|
|
26
|
+
* translated as two separate ForeignCallArray and ForeignCallSingle values (an array and a single field).
|
|
27
|
+
*
|
|
28
|
+
* @param storage The array with the BoundedVec's storage (i.e. BoundedVec::storage())
|
|
29
|
+
* @param length The length of the BoundedVec (i.e. BoundedVec::len())
|
|
30
|
+
* @param uintBitSize If it's an array of Noir u8's, put `8`, etc.
|
|
31
|
+
* @returns A buffer containing the unsigned integers tightly packed
|
|
32
|
+
*/
|
|
33
|
+
export declare function fromUintBoundedVec(storage: ForeignCallArray, length: ForeignCallSingle, uintBitSize: number): Buffer;
|
|
34
|
+
export declare function toSingle(value: AztecAddress | EthAddress | Fr | Buffer | boolean | number | bigint): ForeignCallSingle;
|
|
35
|
+
export declare function toArray(objs: Fr[]): ForeignCallArray;
|
|
36
|
+
export declare function toSingleOrArray(value: Fr | Fr[]): string | string[];
|
|
37
|
+
export declare function bufferToU8Array(buffer: Buffer): ForeignCallArray;
|
|
38
|
+
/**
|
|
39
|
+
* Converts a ForeignCallArray into a tuple which represents a nr BoundedVec.
|
|
40
|
+
* If the input array is shorter than the maxLen, it pads the result with zeros,
|
|
41
|
+
* so that nr can correctly coerce this result into a BoundedVec.
|
|
42
|
+
* @param bVecStorage - The array underlying the BoundedVec.
|
|
43
|
+
* @param maxLen - the max length of the BoundedVec.
|
|
44
|
+
* @returns a tuple representing a BoundedVec.
|
|
45
|
+
*/
|
|
46
|
+
export declare function arrayToBoundedVec(bVecStorage: ForeignCallArray, maxLen: number): [ForeignCallArray, ForeignCallSingle];
|
|
47
|
+
/**
|
|
48
|
+
* Converts an array of arrays representing Noir BoundedVec of nested arrays into its Noir serialized form.
|
|
49
|
+
* @param bVecStorage - The array underlying the BoundedVec.
|
|
50
|
+
* @param maxLen - The max length of the BoundedVec (max num of the nested arrays in the BoundedVec).
|
|
51
|
+
* @param nestedArrayLength - The length of the nested arrays (each nested array has to have the same length).
|
|
52
|
+
* @returns Serialized BoundedVec following Noir intrinsic serialization.
|
|
53
|
+
*/
|
|
54
|
+
export declare function arrayOfArraysToBoundedVecOfArrays(bVecStorage: ForeignCallArray[], maxLen: number, nestedArrayLength: number): [ForeignCallArray, ForeignCallSingle];
|
|
55
|
+
export declare function toForeignCallResult(obj: (ForeignCallSingle | ForeignCallArray)[]): {
|
|
56
|
+
values: (string | ForeignCallArray)[];
|
|
57
|
+
};
|
|
58
|
+
export declare const ForeignCallSingleSchema: z.ZodString;
|
|
59
|
+
export declare const ForeignCallArraySchema: z.ZodArray<z.ZodString>;
|
|
60
|
+
export declare const ForeignCallArgsSchema: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodObject<{
|
|
61
|
+
name: z.ZodString;
|
|
62
|
+
aztecVersion: z.ZodDefault<z.ZodString>;
|
|
63
|
+
functions: z.ZodArray<z.ZodIntersection<z.ZodObject<{
|
|
64
|
+
name: z.ZodString;
|
|
65
|
+
functionType: z.ZodEnum<typeof import("@aztec/stdlib/abi").FunctionType>;
|
|
66
|
+
isOnlySelf: z.ZodBoolean;
|
|
67
|
+
isStatic: z.ZodBoolean;
|
|
68
|
+
isInitializer: z.ZodBoolean;
|
|
69
|
+
parameters: z.ZodArray<z.ZodObject<{
|
|
70
|
+
name: z.ZodString;
|
|
71
|
+
type: z.ZodType<import("@aztec/stdlib/abi").AbiType, unknown, z.core.$ZodTypeInternals<import("@aztec/stdlib/abi").AbiType, unknown>>;
|
|
72
|
+
visibility: z.ZodEnum<{
|
|
73
|
+
databus: "databus";
|
|
74
|
+
private: "private";
|
|
75
|
+
public: "public";
|
|
76
|
+
}>;
|
|
77
|
+
}, z.core.$strip>>;
|
|
78
|
+
returnTypes: z.ZodArray<z.ZodType<import("@aztec/stdlib/abi").AbiType, unknown, z.core.$ZodTypeInternals<import("@aztec/stdlib/abi").AbiType, unknown>>>;
|
|
79
|
+
errorTypes: z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
80
|
+
error_kind: z.ZodLiteral<"string">;
|
|
81
|
+
string: z.ZodString;
|
|
82
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
83
|
+
error_kind: z.ZodLiteral<"fmtstring">;
|
|
84
|
+
length: z.ZodNumber;
|
|
85
|
+
item_types: z.ZodArray<z.ZodType<import("@aztec/stdlib/abi").AbiType, unknown, z.core.$ZodTypeInternals<import("@aztec/stdlib/abi").AbiType, unknown>>>;
|
|
86
|
+
}, z.core.$strip>, z.ZodIntersection<z.ZodObject<{
|
|
87
|
+
error_kind: z.ZodLiteral<"custom">;
|
|
88
|
+
}, z.core.$strip>, z.ZodType<import("@aztec/stdlib/abi").AbiType, unknown, z.core.$ZodTypeInternals<import("@aztec/stdlib/abi").AbiType, unknown>>>]>>>;
|
|
89
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
90
|
+
bytecode: import("@aztec/foundation/schemas").ZodFor<Buffer<ArrayBufferLike>>;
|
|
91
|
+
verificationKey: z.ZodOptional<z.ZodString>;
|
|
92
|
+
debugSymbols: z.ZodString;
|
|
93
|
+
debug: z.ZodOptional<z.ZodObject<{
|
|
94
|
+
debugSymbols: z.ZodObject<{
|
|
95
|
+
location_tree: z.ZodObject<{
|
|
96
|
+
locations: z.ZodArray<z.ZodObject<{
|
|
97
|
+
parent: z.ZodNullable<z.ZodNumber>;
|
|
98
|
+
value: z.ZodObject<{
|
|
99
|
+
span: z.ZodObject<{
|
|
100
|
+
start: z.ZodNumber;
|
|
101
|
+
end: z.ZodNumber;
|
|
102
|
+
}, z.core.$strip>;
|
|
103
|
+
file: z.ZodNumber;
|
|
104
|
+
}, z.core.$strip>;
|
|
105
|
+
}, z.core.$strip>>;
|
|
106
|
+
}, z.core.$strip>;
|
|
107
|
+
acir_locations: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
108
|
+
brillig_locations: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
109
|
+
}, z.core.$strip>;
|
|
110
|
+
files: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
111
|
+
source: z.ZodString;
|
|
112
|
+
path: z.ZodString;
|
|
113
|
+
function_locations: z.ZodArray<z.ZodObject<{
|
|
114
|
+
start: z.ZodNumber;
|
|
115
|
+
name: z.ZodString;
|
|
116
|
+
}, z.core.$strip>>;
|
|
117
|
+
}, z.core.$strip>>;
|
|
118
|
+
}, z.core.$strip>>;
|
|
119
|
+
}, z.core.$strip>>>;
|
|
120
|
+
nonDispatchPublicFunctions: z.ZodArray<z.ZodObject<{
|
|
121
|
+
name: z.ZodString;
|
|
122
|
+
functionType: z.ZodEnum<typeof import("@aztec/stdlib/abi").FunctionType>;
|
|
123
|
+
isOnlySelf: z.ZodBoolean;
|
|
124
|
+
isStatic: z.ZodBoolean;
|
|
125
|
+
isInitializer: z.ZodBoolean;
|
|
126
|
+
parameters: z.ZodArray<z.ZodObject<{
|
|
127
|
+
name: z.ZodString;
|
|
128
|
+
type: z.ZodType<import("@aztec/stdlib/abi").AbiType, unknown, z.core.$ZodTypeInternals<import("@aztec/stdlib/abi").AbiType, unknown>>;
|
|
129
|
+
visibility: z.ZodEnum<{
|
|
130
|
+
databus: "databus";
|
|
131
|
+
private: "private";
|
|
132
|
+
public: "public";
|
|
133
|
+
}>;
|
|
134
|
+
}, z.core.$strip>>;
|
|
135
|
+
returnTypes: z.ZodArray<z.ZodType<import("@aztec/stdlib/abi").AbiType, unknown, z.core.$ZodTypeInternals<import("@aztec/stdlib/abi").AbiType, unknown>>>;
|
|
136
|
+
errorTypes: z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
137
|
+
error_kind: z.ZodLiteral<"string">;
|
|
138
|
+
string: z.ZodString;
|
|
139
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
140
|
+
error_kind: z.ZodLiteral<"fmtstring">;
|
|
141
|
+
length: z.ZodNumber;
|
|
142
|
+
item_types: z.ZodArray<z.ZodType<import("@aztec/stdlib/abi").AbiType, unknown, z.core.$ZodTypeInternals<import("@aztec/stdlib/abi").AbiType, unknown>>>;
|
|
143
|
+
}, z.core.$strip>, z.ZodIntersection<z.ZodObject<{
|
|
144
|
+
error_kind: z.ZodLiteral<"custom">;
|
|
145
|
+
}, z.core.$strip>, z.ZodType<import("@aztec/stdlib/abi").AbiType, unknown, z.core.$ZodTypeInternals<import("@aztec/stdlib/abi").AbiType, unknown>>>]>>>;
|
|
146
|
+
}, z.core.$strip>>;
|
|
147
|
+
outputs: z.ZodObject<{
|
|
148
|
+
structs: z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodType<import("@aztec/stdlib/abi").AbiType, unknown, z.core.$ZodTypeInternals<import("@aztec/stdlib/abi").AbiType, unknown>>>>, z.ZodTransform<Record<string, import("@aztec/stdlib/abi").AbiType[]>, Record<string, import("@aztec/stdlib/abi").AbiType[]>>>;
|
|
149
|
+
globals: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodType<import("@aztec/stdlib/abi").AbiValue, unknown, z.core.$ZodTypeInternals<import("@aztec/stdlib/abi").AbiValue, unknown>>>>;
|
|
150
|
+
}, z.core.$strip>;
|
|
151
|
+
storageLayout: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
152
|
+
slot: z.ZodType<Fr, string, z.core.$ZodTypeInternals<Fr, string>>;
|
|
153
|
+
}, z.core.$strip>>;
|
|
154
|
+
fileMap: z.ZodRecord<z.ZodCoercedNumber<unknown>, z.ZodObject<{
|
|
155
|
+
source: z.ZodString;
|
|
156
|
+
path: z.ZodString;
|
|
157
|
+
function_locations: z.ZodArray<z.ZodObject<{
|
|
158
|
+
start: z.ZodNumber;
|
|
159
|
+
name: z.ZodString;
|
|
160
|
+
}, z.core.$strip>>;
|
|
161
|
+
}, z.core.$strip>>;
|
|
162
|
+
}, z.core.$strip>, z.ZodIntersection<z.ZodObject<{
|
|
163
|
+
version: z.ZodLiteral<2>;
|
|
164
|
+
salt: import("@aztec/foundation/schemas").ZodFor<Fr>;
|
|
165
|
+
deployer: import("@aztec/foundation/schemas").ZodFor<AztecAddress>;
|
|
166
|
+
currentContractClassId: import("@aztec/foundation/schemas").ZodFor<Fr>;
|
|
167
|
+
originalContractClassId: import("@aztec/foundation/schemas").ZodFor<Fr>;
|
|
168
|
+
initializationHash: import("@aztec/foundation/schemas").ZodFor<Fr>;
|
|
169
|
+
immutablesHash: import("@aztec/foundation/schemas").ZodFor<Fr>;
|
|
170
|
+
publicKeys: z.ZodPipe<z.ZodObject<{
|
|
171
|
+
npkMHash: z.ZodType<Fr, string, z.core.$ZodTypeInternals<Fr, string>>;
|
|
172
|
+
ivpkM: z.ZodType<import("@aztec/foundation/schemas").Point, string, z.core.$ZodTypeInternals<import("@aztec/foundation/schemas").Point, string>>;
|
|
173
|
+
ovpkMHash: z.ZodType<Fr, string, z.core.$ZodTypeInternals<Fr, string>>;
|
|
174
|
+
tpkMHash: z.ZodType<Fr, string, z.core.$ZodTypeInternals<Fr, string>>;
|
|
175
|
+
mspkMHash: z.ZodType<Fr, string, z.core.$ZodTypeInternals<Fr, string>>;
|
|
176
|
+
fbpkMHash: z.ZodType<Fr, string, z.core.$ZodTypeInternals<Fr, string>>;
|
|
177
|
+
}, z.core.$strip>, z.ZodTransform<import("@aztec/stdlib/keys").PublicKeys, {
|
|
178
|
+
npkMHash: Fr;
|
|
179
|
+
ivpkM: import("@aztec/foundation/schemas").Point;
|
|
180
|
+
ovpkMHash: Fr;
|
|
181
|
+
tpkMHash: Fr;
|
|
182
|
+
mspkMHash: Fr;
|
|
183
|
+
fbpkMHash: Fr;
|
|
184
|
+
}>>;
|
|
185
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
186
|
+
address: import("@aztec/foundation/schemas").ZodFor<AztecAddress>;
|
|
187
|
+
}, z.core.$strip>>]>>;
|
|
188
|
+
export declare const ForeignCallResultSchema: z.ZodObject<{
|
|
189
|
+
values: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
190
|
+
}, z.core.$strip>;
|
|
191
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZW5jb2RpbmcuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9lbmNvZGluZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDcEQsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0sK0JBQStCLENBQUM7QUFFaEUsT0FBTyxFQUFFLEtBQUssZ0JBQWdCLEVBQTBCLE1BQU0sbUJBQW1CLENBQUM7QUFDbEYsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBQzNELE9BQU8sRUFBRSxTQUFTLEVB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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAEjC,CAAC;AAEF,eAAO,MAAM,uBAAuB;;iBAElC,CAAC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { hexToBuffer } from '@aztec/foundation/string';
|
|
3
|
+
import { ContractArtifactSchema } from '@aztec/stdlib/abi';
|
|
4
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
+
import { BlockHash } from '@aztec/stdlib/block';
|
|
6
|
+
import { ContractInstanceWithAddressSchema } from '@aztec/stdlib/contract';
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
export function fromSingle(obj) {
|
|
9
|
+
return Fr.fromBuffer(Buffer.from(obj, 'hex'));
|
|
10
|
+
}
|
|
11
|
+
export function addressFromSingle(obj) {
|
|
12
|
+
return new AztecAddress(fromSingle(obj));
|
|
13
|
+
}
|
|
14
|
+
export function blockHashFromSingle(obj) {
|
|
15
|
+
return new BlockHash(fromSingle(obj));
|
|
16
|
+
}
|
|
17
|
+
export function fromArray(obj) {
|
|
18
|
+
return obj.map((str)=>Fr.fromBuffer(hexToBuffer(str)));
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Converts an array of Noir unsigned integers to a single tightly-packed buffer.
|
|
22
|
+
* @param uintBitSize If it's an array of Noir u8's, put `8`, etc.
|
|
23
|
+
* @returns A buffer where each byte is correctly represented as a single byte in the buffer.
|
|
24
|
+
*/ export function fromUintArray(obj, uintBitSize) {
|
|
25
|
+
if (uintBitSize % 8 !== 0) {
|
|
26
|
+
throw new Error(`u${uintBitSize} is not a supported type in Noir`);
|
|
27
|
+
}
|
|
28
|
+
const uintByteSize = uintBitSize / 8;
|
|
29
|
+
return Buffer.concat(obj.map((str)=>hexToBuffer(str).slice(-uintByteSize)));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Converts a Noir BoundedVec of unsigned integers into a Buffer. Note that BoundedVecs are structs, and therefore
|
|
33
|
+
* translated as two separate ForeignCallArray and ForeignCallSingle values (an array and a single field).
|
|
34
|
+
*
|
|
35
|
+
* @param storage The array with the BoundedVec's storage (i.e. BoundedVec::storage())
|
|
36
|
+
* @param length The length of the BoundedVec (i.e. BoundedVec::len())
|
|
37
|
+
* @param uintBitSize If it's an array of Noir u8's, put `8`, etc.
|
|
38
|
+
* @returns A buffer containing the unsigned integers tightly packed
|
|
39
|
+
*/ export function fromUintBoundedVec(storage, length, uintBitSize) {
|
|
40
|
+
if (uintBitSize % 8 !== 0) {
|
|
41
|
+
throw new Error(`u${uintBitSize} is not a supported type in Noir`);
|
|
42
|
+
}
|
|
43
|
+
const uintByteSize = uintBitSize / 8;
|
|
44
|
+
const boundedStorage = storage.slice(0, fromSingle(length).toNumber());
|
|
45
|
+
return Buffer.concat(boundedStorage.map((str)=>hexToBuffer(str).slice(-uintByteSize)));
|
|
46
|
+
}
|
|
47
|
+
// Just like toACVMField in yarn-project/simulator/src/private/acvm/serialize.ts but returns a ForeignCallSingle
|
|
48
|
+
// instead of an ACVMField.
|
|
49
|
+
export function toSingle(value) {
|
|
50
|
+
let valueAsField;
|
|
51
|
+
if (Buffer.isBuffer(value)) {
|
|
52
|
+
valueAsField = Fr.fromBuffer(value);
|
|
53
|
+
} else if (typeof value === 'boolean' || typeof value === 'number' || typeof value === 'bigint') {
|
|
54
|
+
valueAsField = new Fr(value);
|
|
55
|
+
} else if (typeof value === 'string') {
|
|
56
|
+
valueAsField = Fr.fromHexString(value);
|
|
57
|
+
} else {
|
|
58
|
+
valueAsField = value;
|
|
59
|
+
}
|
|
60
|
+
return valueAsField.toString().slice(2);
|
|
61
|
+
}
|
|
62
|
+
export function toArray(objs) {
|
|
63
|
+
return objs.map((obj)=>obj.toString());
|
|
64
|
+
}
|
|
65
|
+
export function toSingleOrArray(value) {
|
|
66
|
+
return Array.isArray(value) ? value.map(toSingle) : toSingle(value);
|
|
67
|
+
}
|
|
68
|
+
export function bufferToU8Array(buffer) {
|
|
69
|
+
return toArray(Array.from(buffer).map((byte)=>new Fr(byte)));
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Converts a ForeignCallArray into a tuple which represents a nr BoundedVec.
|
|
73
|
+
* If the input array is shorter than the maxLen, it pads the result with zeros,
|
|
74
|
+
* so that nr can correctly coerce this result into a BoundedVec.
|
|
75
|
+
* @param bVecStorage - The array underlying the BoundedVec.
|
|
76
|
+
* @param maxLen - the max length of the BoundedVec.
|
|
77
|
+
* @returns a tuple representing a BoundedVec.
|
|
78
|
+
*/ export function arrayToBoundedVec(bVecStorage, maxLen) {
|
|
79
|
+
if (bVecStorage.length > maxLen) {
|
|
80
|
+
throw new Error(`Array of length ${bVecStorage.length} larger than maxLen ${maxLen}`);
|
|
81
|
+
}
|
|
82
|
+
const lengthDiff = maxLen - bVecStorage.length;
|
|
83
|
+
// We pad the array to the maxLen of the BoundedVec.
|
|
84
|
+
const zeroPaddingArray = toArray(Array(lengthDiff).fill(new Fr(0)));
|
|
85
|
+
// These variable names match with the BoundedVec members in nr:
|
|
86
|
+
const storage = bVecStorage.concat(zeroPaddingArray);
|
|
87
|
+
const len = toSingle(new Fr(bVecStorage.length));
|
|
88
|
+
return [
|
|
89
|
+
storage,
|
|
90
|
+
len
|
|
91
|
+
];
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Converts an array of arrays representing Noir BoundedVec of nested arrays into its Noir serialized form.
|
|
95
|
+
* @param bVecStorage - The array underlying the BoundedVec.
|
|
96
|
+
* @param maxLen - The max length of the BoundedVec (max num of the nested arrays in the BoundedVec).
|
|
97
|
+
* @param nestedArrayLength - The length of the nested arrays (each nested array has to have the same length).
|
|
98
|
+
* @returns Serialized BoundedVec following Noir intrinsic serialization.
|
|
99
|
+
*/ export function arrayOfArraysToBoundedVecOfArrays(bVecStorage, maxLen, nestedArrayLength) {
|
|
100
|
+
if (bVecStorage.length > maxLen) {
|
|
101
|
+
throw new Error(`Array of length ${bVecStorage.length} larger than maxLen ${maxLen}`);
|
|
102
|
+
}
|
|
103
|
+
// Check that all nested arrays have length nestedArrayLength
|
|
104
|
+
if (!bVecStorage.every((nestedArray)=>nestedArray.length === nestedArrayLength)) {
|
|
105
|
+
throw new Error(`Nested array length passed in from Noir does not correspond to the length obtained in TS: ${nestedArrayLength} !== ${bVecStorage[0].length}`);
|
|
106
|
+
}
|
|
107
|
+
const flattenedStorage = bVecStorage.flat();
|
|
108
|
+
const numFieldsToPad = maxLen * nestedArrayLength - flattenedStorage.length;
|
|
109
|
+
// Pad with hex-encoded zeros so the result is uniformly `ForeignCallSingle` (string); raw Fr
|
|
110
|
+
// instances would JSON-serialize as `{ asBigInt: "0" }` and nargo would reject the response.
|
|
111
|
+
const flattenedStorageWithPadding = flattenedStorage.concat(toArray(Array(numFieldsToPad).fill(new Fr(0))));
|
|
112
|
+
const len = toSingle(new Fr(bVecStorage.length));
|
|
113
|
+
return [
|
|
114
|
+
flattenedStorageWithPadding,
|
|
115
|
+
len
|
|
116
|
+
];
|
|
117
|
+
}
|
|
118
|
+
export function toForeignCallResult(obj) {
|
|
119
|
+
return {
|
|
120
|
+
values: obj
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
export const ForeignCallSingleSchema = z.string();
|
|
124
|
+
export const ForeignCallArraySchema = z.array(z.string());
|
|
125
|
+
export const ForeignCallArgsSchema = z.array(z.union([
|
|
126
|
+
ForeignCallSingleSchema,
|
|
127
|
+
ForeignCallArraySchema,
|
|
128
|
+
ContractArtifactSchema,
|
|
129
|
+
ContractInstanceWithAddressSchema
|
|
130
|
+
]));
|
|
131
|
+
export const ForeignCallResultSchema = z.object({
|
|
132
|
+
values: z.array(z.union([
|
|
133
|
+
ForeignCallSingleSchema,
|
|
134
|
+
ForeignCallArraySchema
|
|
135
|
+
]))
|
|
136
|
+
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare class ExpectedFailureError extends Error {
|
|
2
|
+
constructor(message: string);
|
|
3
|
+
}
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXhwZWN0ZWRfZmFpbHVyZV9lcnJvci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3V0aWxzL2V4cGVjdGVkX2ZhaWx1cmVfZXJyb3IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEscUJBQWEsb0JBQXFCLFNBQVEsS0FBSztJQUM3QyxZQUFZLE9BQU8sRUFBRSxNQUFNLEVBRTFCO0NBQ0YifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expected_failure_error.d.ts","sourceRoot":"","sources":["../../src/utils/expected_failure_error.ts"],"names":[],"mappings":"AAAA,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,YAAY,OAAO,EAAE,MAAM,EAE1B;CACF"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import type { ExecutionNoteCache } from '@aztec/pxe/simulator';
|
|
3
|
+
import { TxEffect } from '@aztec/stdlib/tx';
|
|
4
|
+
export declare function makeTxEffect(noteCache: ExecutionNoteCache, txBlockNumber: BlockNumber): Promise<TxEffect>;
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhfZWZmZWN0X2NyZWF0aW9uLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbHMvdHhfZWZmZWN0X2NyZWF0aW9uLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUU5RCxPQUFPLEtBQUssRUFBRSxrQkFBa0IsRUFBRSxNQUFNLHNCQUFzQixDQUFDO0FBRS9ELE9BQU8sRUFBRSxRQUFRLEVBQVUsTUFBTSxrQkFBa0IsQ0FBQztBQUVwRCx3QkFBc0IsWUFBWSxDQUFDLFNBQVMsRUFBRSxrQkFBa0IsRUFBRSxhQUFhLEVBQUUsV0FBVyxHQUFHLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0F1Qi9HIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tx_effect_creation.d.ts","sourceRoot":"","sources":["../../src/utils/tx_effect_creation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,OAAO,EAAE,QAAQ,EAAU,MAAM,kBAAkB,CAAC;AAEpD,wBAAsB,YAAY,CAAC,SAAS,EAAE,kBAAkB,EAAE,aAAa,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAuB/G"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash } from '@aztec/stdlib/hash';
|
|
3
|
+
import { TxEffect, TxHash } from '@aztec/stdlib/tx';
|
|
4
|
+
export async function makeTxEffect(noteCache, txBlockNumber) {
|
|
5
|
+
const txEffect = TxEffect.empty();
|
|
6
|
+
noteCache.finish();
|
|
7
|
+
const nonceGenerator = noteCache.getNonceGenerator();
|
|
8
|
+
txEffect.noteHashes = await Promise.all(noteCache.getAllNotes().map(async (pendingNote, i)=>computeUniqueNoteHash(await computeNoteHashNonce(nonceGenerator, i), await siloNoteHash(pendingNote.note.contractAddress, pendingNote.noteHashForConsumption))));
|
|
9
|
+
// Nullifiers are already siloed
|
|
10
|
+
txEffect.nullifiers = noteCache.getAllNullifiers();
|
|
11
|
+
txEffect.txHash = new TxHash(new Fr(txBlockNumber));
|
|
12
|
+
return txEffect;
|
|
13
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
2
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import { CompleteAddress } from '@aztec/stdlib/contract';
|
|
4
|
+
export declare class TXEAccountStore {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(store: AztecAsyncKVStore);
|
|
7
|
+
getAccount(key: AztecAddress): Promise<CompleteAddress>;
|
|
8
|
+
setAccount(key: AztecAddress, value: CompleteAddress): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX2FjY291bnRfc3RvcmUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy90eGVfYWNjb3VudF9zdG9yZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxpQkFBaUIsRUFBaUIsTUFBTSxpQkFBaUIsQ0FBQztBQUN4RSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUNoRSxPQUFPLEVBQUUsZUFBZSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFFekQscUJBQWEsZUFBZTs7SUFHMUIsWUFBWSxLQUFLLEVBQUUsaUJBQWlCLEVBRW5DO0lBRUssVUFBVSxDQUFDLEdBQUcsRUFBRSxZQUFZLDRCQU1qQztJQUVLLFVBQVUsQ0FBQyxHQUFHLEVBQUUsWUFBWSxFQUFFLEtBQUssRUFBRSxlQUFlLGlCQUV6RDtDQUNGIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"txe_account_store.d.ts","sourceRoot":"","sources":["../../src/utils/txe_account_store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,qBAAa,eAAe;;IAG1B,YAAY,KAAK,EAAE,iBAAiB,EAEnC;IAEK,UAAU,CAAC,GAAG,EAAE,YAAY,4BAMjC;IAEK,UAAU,CAAC,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,eAAe,iBAEzD;CACF"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { type ContractInstanceWithAddress } from '@aztec/aztec.js/contracts';
|
|
3
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
4
|
+
import type { ContractStore } from '@aztec/pxe/client/lazy';
|
|
5
|
+
import type { ContractArtifactWithHash } from '@aztec/stdlib/contract';
|
|
6
|
+
export interface ResolvedArtifact {
|
|
7
|
+
artifact: ContractArtifactWithHash;
|
|
8
|
+
instance: ContractInstanceWithAddress;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Resolves and caches contract artifacts and their associated instances.
|
|
12
|
+
*
|
|
13
|
+
* Artifact hash computation is expensive, so this service deduplicates both completed and in-flight computations.
|
|
14
|
+
* Two cache levels are kept: full deploys (artifact + computed instance) keyed by the full deploy context, and loaded +
|
|
15
|
+
* hashed artifacts keyed by the compiled-bytecode hash so deploys of the same contract with different args / salt /
|
|
16
|
+
* deployer reuse the same `ContractArtifactWithHash`.
|
|
17
|
+
*/
|
|
18
|
+
export declare class TXEArtifactResolver {
|
|
19
|
+
#private;
|
|
20
|
+
private readonly contractStore;
|
|
21
|
+
private readonly schnorrClassId;
|
|
22
|
+
constructor(contractStore: ContractStore, schnorrClassId: Fr);
|
|
23
|
+
/** Resolves the Schnorr account contract artifact and instance for the given secret, caching the result. */
|
|
24
|
+
resolveAccountArtifact(secret: Fr): Promise<ResolvedArtifact>;
|
|
25
|
+
/** Resolves a contract artifact from disk by path, computes its instance, and caches the result. */
|
|
26
|
+
resolveDeployArtifact({ rootPath, packageName, contractPath, initializer, args, secret, salt, deployer }: {
|
|
27
|
+
rootPath: string;
|
|
28
|
+
packageName: string;
|
|
29
|
+
contractPath: string;
|
|
30
|
+
initializer: string;
|
|
31
|
+
args: Fr[];
|
|
32
|
+
secret: Fr;
|
|
33
|
+
salt: Fr;
|
|
34
|
+
deployer: AztecAddress;
|
|
35
|
+
}): Promise<ResolvedArtifact>;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX2FydGlmYWN0X3Jlc29sdmVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbHMvdHhlX2FydGlmYWN0X3Jlc29sdmVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUN6RCxPQUFPLEVBQ0wsS0FBSywyQkFBMkIsRUFFakMsTUFBTSwyQkFBMkIsQ0FBQztBQUNuQyxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFHNUMsT0FBTyxLQUFLLEVBQUUsYUFBYSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFDNUQsT0FBTyxLQUFLLEVBQUUsd0JBQXdCLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQVF2RSxNQUFNLFdBQVcsZ0JBQWdCO0lBQy9CLFFBQVEsRUFBRSx3QkFBd0IsQ0FBQztJQUNuQyxRQUFRLEVBQUUsMkJBQTJCLENBQUM7Q0FDdkM7QUFpQ0Q7Ozs7Ozs7R0FPRztBQUNILHFCQUFhLG1CQUFtQjs7SUFNNUIsT0FBTyxDQUFDLFFBQVEsQ0FBQyxhQUFhO0lBQzlCLE9BQU8sQ0FBQyxRQUFRLEN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,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,wBAAwB,CAAC;IACnC,QAAQ,EAAE,2BAA2B,CAAC;CACvC;AAiCD;;;;;;;GAOG;AACH,qBAAa,mBAAmB;;IAM5B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,cAAc;IAFjC,YACmB,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,EAAE,EACjC;IAEJ,4GAA4G;IAC5G,sBAAsB,CAAC,MAAM,EAAE,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAI5D;IAED,oGAAoG;IAC9F,qBAAqB,CAAC,EAC1B,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,WAAW,EACX,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,QAAQ,EACT,EAAE;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;QACpB,IAAI,EAAE,EAAE,EAAE,CAAC;QACX,MAAM,EAAE,EAAE,CAAC;QACX,IAAI,EAAE,EAAE,CAAC;QACT,QAAQ,EAAE,YAAY,CAAC;KACxB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAwB5B;CA8FF"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { loadContractArtifact } from '@aztec/aztec.js/abi';
|
|
2
|
+
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
3
|
+
import { getContractInstanceFromInstantiationParams } from '@aztec/aztec.js/contracts';
|
|
4
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
5
|
+
import { PublicKeys, deriveKeys } from '@aztec/aztec.js/keys';
|
|
6
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
7
|
+
import { computeArtifactHash } from '@aztec/stdlib/contract';
|
|
8
|
+
import { createHash } from 'crypto';
|
|
9
|
+
import { createReadStream } from 'fs';
|
|
10
|
+
import { readFile, readdir } from 'fs/promises';
|
|
11
|
+
import { join, parse } from 'path';
|
|
12
|
+
/**
|
|
13
|
+
* Cache + in-flight map pair. Lookup hits the cache, then awaits an in-flight `compute()` if one
|
|
14
|
+
* exists, otherwise starts one and stores it. Guarantees `compute()` runs at most once per `key`
|
|
15
|
+
* across concurrent callers, which matters because `computeArtifactHash` is expensive.
|
|
16
|
+
*/ class AsyncCache {
|
|
17
|
+
#cache = new Map();
|
|
18
|
+
#inFlight = new Map();
|
|
19
|
+
getOrCompute(key, compute) {
|
|
20
|
+
const cached = this.#cache.get(key);
|
|
21
|
+
if (cached !== undefined) {
|
|
22
|
+
return Promise.resolve(cached);
|
|
23
|
+
}
|
|
24
|
+
let pending = this.#inFlight.get(key);
|
|
25
|
+
if (!pending) {
|
|
26
|
+
pending = (async ()=>{
|
|
27
|
+
try {
|
|
28
|
+
const value = await compute();
|
|
29
|
+
this.#cache.set(key, value);
|
|
30
|
+
return value;
|
|
31
|
+
} finally{
|
|
32
|
+
this.#inFlight.delete(key);
|
|
33
|
+
}
|
|
34
|
+
})();
|
|
35
|
+
this.#inFlight.set(key, pending);
|
|
36
|
+
}
|
|
37
|
+
return pending;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Resolves and caches contract artifacts and their associated instances.
|
|
42
|
+
*
|
|
43
|
+
* Artifact hash computation is expensive, so this service deduplicates both completed and in-flight computations.
|
|
44
|
+
* Two cache levels are kept: full deploys (artifact + computed instance) keyed by the full deploy context, and loaded +
|
|
45
|
+
* hashed artifacts keyed by the compiled-bytecode hash so deploys of the same contract with different args / salt /
|
|
46
|
+
* deployer reuse the same `ContractArtifactWithHash`.
|
|
47
|
+
*/ export class TXEArtifactResolver {
|
|
48
|
+
contractStore;
|
|
49
|
+
schnorrClassId;
|
|
50
|
+
#deployments;
|
|
51
|
+
#artifacts;
|
|
52
|
+
#logger;
|
|
53
|
+
constructor(contractStore, schnorrClassId){
|
|
54
|
+
this.contractStore = contractStore;
|
|
55
|
+
this.schnorrClassId = schnorrClassId;
|
|
56
|
+
this.#deployments = new AsyncCache();
|
|
57
|
+
this.#artifacts = new AsyncCache();
|
|
58
|
+
this.#logger = createLogger('txe:artifact_resolver');
|
|
59
|
+
}
|
|
60
|
+
/** Resolves the Schnorr account contract artifact and instance for the given secret, caching the result. */ resolveAccountArtifact(secret) {
|
|
61
|
+
return this.#deployments.getOrCompute(`SchnorrAccountContract-${secret}`, ()=>this.#computeAccountArtifact(secret));
|
|
62
|
+
}
|
|
63
|
+
/** Resolves a contract artifact from disk by path, computes its instance, and caches the result. */ async resolveDeployArtifact({ rootPath, packageName, contractPath, initializer, args, secret, salt, deployer }) {
|
|
64
|
+
const publicKeys = secret.equals(Fr.ZERO) ? PublicKeys.default() : (await deriveKeys(secret)).publicKeys;
|
|
65
|
+
const publicKeysHash = await publicKeys.hash();
|
|
66
|
+
const artifactPath = await this.#resolveArtifactPath(rootPath, packageName, contractPath);
|
|
67
|
+
const fileHash = await this.#fastHashFile(artifactPath);
|
|
68
|
+
const { dir: contractDirectory, base: contractFilename } = parse(contractPath);
|
|
69
|
+
const cacheKey = `${contractDirectory ?? ''}-${contractFilename}-${initializer}-${args.map((arg)=>arg.toString()).join('-')}-${publicKeysHash}-${salt}-${deployer}-${fileHash}`;
|
|
70
|
+
return this.#deployments.getOrCompute(cacheKey, ()=>this.#computeDeployArtifact(artifactPath, fileHash, initializer, args, salt, publicKeys, publicKeysHash, deployer));
|
|
71
|
+
}
|
|
72
|
+
async #resolveArtifactPath(rootPath, packageName, contractPath) {
|
|
73
|
+
const { dir: contractDirectory, base: contractFilename } = parse(contractPath);
|
|
74
|
+
if (contractDirectory) {
|
|
75
|
+
if (contractDirectory.includes('@')) {
|
|
76
|
+
// env.deploy("../path/to/workspace/root@packageName/contractName")
|
|
77
|
+
const [workspace, pkg] = contractDirectory.split('@');
|
|
78
|
+
const targetPath = join(rootPath, workspace, '/target');
|
|
79
|
+
this.#logger.debug(`Looking for compiled artifact in workspace ${targetPath}`);
|
|
80
|
+
return join(targetPath, `${pkg}-${contractFilename}.json`);
|
|
81
|
+
} else {
|
|
82
|
+
// env.deploy("../path/to/contract/root/contractName")
|
|
83
|
+
const targetPath = join(rootPath, contractDirectory, '/target');
|
|
84
|
+
this.#logger.debug(`Looking for compiled artifact in ${targetPath}`);
|
|
85
|
+
const [artifactPath] = (await readdir(targetPath)).filter((file)=>file.endsWith(`-${contractFilename}.json`));
|
|
86
|
+
return artifactPath;
|
|
87
|
+
}
|
|
88
|
+
} else {
|
|
89
|
+
// env.deploy("contractName")
|
|
90
|
+
return join(rootPath, './target', `${packageName}-${contractFilename}.json`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async #computeAccountArtifact(secret) {
|
|
94
|
+
const [artifactFromStore, classWithPreimage] = await Promise.all([
|
|
95
|
+
this.contractStore.getContractArtifact(this.schnorrClassId),
|
|
96
|
+
this.contractStore.getContractClassWithPreimage(this.schnorrClassId)
|
|
97
|
+
]);
|
|
98
|
+
if (!artifactFromStore || !classWithPreimage) {
|
|
99
|
+
throw new Error(`SchnorrAccount not found in shared contract store at class id ${this.schnorrClassId.toString()}`);
|
|
100
|
+
}
|
|
101
|
+
const artifact = {
|
|
102
|
+
...artifactFromStore,
|
|
103
|
+
artifactHash: classWithPreimage.artifactHash
|
|
104
|
+
};
|
|
105
|
+
const keys = await deriveKeys(secret);
|
|
106
|
+
const args = [
|
|
107
|
+
keys.publicKeys.ivpkM.x,
|
|
108
|
+
keys.publicKeys.ivpkM.y
|
|
109
|
+
];
|
|
110
|
+
const instance = await getContractInstanceFromInstantiationParams(artifact, {
|
|
111
|
+
constructorArgs: args,
|
|
112
|
+
skipArgsDecoding: true,
|
|
113
|
+
salt: Fr.ONE,
|
|
114
|
+
publicKeys: keys.publicKeys,
|
|
115
|
+
constructorArtifact: 'constructor',
|
|
116
|
+
deployer: AztecAddress.ZERO
|
|
117
|
+
});
|
|
118
|
+
return {
|
|
119
|
+
artifact,
|
|
120
|
+
instance
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
async #computeDeployArtifact(artifactPath, fileHash, initializer, args, salt, publicKeys, publicKeysHash, deployer) {
|
|
124
|
+
// Inner cache: artifact load + hash depends only on the compiled bytecode (`fileHash`), so subsequent deploys of
|
|
125
|
+
// the same contract — regardless of constructor args / deployer / salt — reuse the same `ContractArtifactWithHash`.
|
|
126
|
+
const artifact = await this.#artifacts.getOrCompute(fileHash, async ()=>{
|
|
127
|
+
this.#logger.debug(`Loading compiled artifact ${artifactPath}`);
|
|
128
|
+
const artifactJSON = JSON.parse(await readFile(artifactPath, 'utf-8'));
|
|
129
|
+
const artifactWithoutHash = loadContractArtifact(artifactJSON);
|
|
130
|
+
return {
|
|
131
|
+
...artifactWithoutHash,
|
|
132
|
+
artifactHash: await computeArtifactHash(artifactWithoutHash)
|
|
133
|
+
};
|
|
134
|
+
});
|
|
135
|
+
this.#logger.debug(`Deploy ${artifact.name} with initializer ${initializer}(${args}) and public keys hash ${publicKeysHash}`);
|
|
136
|
+
const instance = await getContractInstanceFromInstantiationParams(artifact, {
|
|
137
|
+
constructorArgs: args,
|
|
138
|
+
skipArgsDecoding: true,
|
|
139
|
+
salt,
|
|
140
|
+
publicKeys,
|
|
141
|
+
constructorArtifact: initializer || undefined,
|
|
142
|
+
deployer
|
|
143
|
+
});
|
|
144
|
+
return {
|
|
145
|
+
artifact,
|
|
146
|
+
instance
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
#fastHashFile(path) {
|
|
150
|
+
return new Promise((resolve)=>{
|
|
151
|
+
const fd = createReadStream(path);
|
|
152
|
+
const hash = createHash('sha1');
|
|
153
|
+
hash.setEncoding('hex');
|
|
154
|
+
fd.on('end', function() {
|
|
155
|
+
hash.end();
|
|
156
|
+
resolve(hash.read());
|
|
157
|
+
});
|
|
158
|
+
fd.pipe(hash);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
+
import type { ContractStore } from '@aztec/pxe/server';
|
|
4
|
+
import { type ContractArtifact, FunctionSelector } from '@aztec/stdlib/abi';
|
|
5
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
+
import type { ContractClassPublic, ContractDataSource, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
7
|
+
export declare class TXEPublicContractDataSource implements ContractDataSource {
|
|
8
|
+
private blockNumber;
|
|
9
|
+
private contractStore;
|
|
10
|
+
constructor(blockNumber: BlockNumber, contractStore: ContractStore);
|
|
11
|
+
getBlockNumber(): Promise<BlockNumber>;
|
|
12
|
+
getContractClass(id: Fr): Promise<ContractClassPublic | undefined>;
|
|
13
|
+
getBytecodeCommitment(id: Fr): Promise<Fr | undefined>;
|
|
14
|
+
getContract(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined>;
|
|
15
|
+
getContractClassIds(): Promise<Fr[]>;
|
|
16
|
+
getContractArtifact(address: AztecAddress): Promise<ContractArtifact | undefined>;
|
|
17
|
+
getDebugFunctionName(address: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
|
|
18
|
+
registerContractFunctionSignatures(_signatures: []): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX3B1YmxpY19jb250cmFjdF9kYXRhX3NvdXJjZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3V0aWxzL3R4ZV9wdWJsaWNfY29udHJhY3RfZGF0YV9zb3VyY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFdBQVcsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQzlELE9BQU8sRUFBRSxFQUFFLEVBQU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