@aztec-labs/txe 6.0.0-nightly.20260829

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.
Files changed (173) hide show
  1. package/dest/AuthRegistry-D4XJULH3.js +3 -0
  2. package/dest/AuthRegistry-D4XJULH3.js.map +7 -0
  3. package/dest/ContractClassRegistry-Q76MXQZD.js +3 -0
  4. package/dest/ContractClassRegistry-Q76MXQZD.js.map +7 -0
  5. package/dest/ContractInstanceRegistry-CTRARU77.js +3 -0
  6. package/dest/ContractInstanceRegistry-CTRARU77.js.map +7 -0
  7. package/dest/FeeJuice-YLTJXWYJ.js +3 -0
  8. package/dest/FeeJuice-YLTJXWYJ.js.map +7 -0
  9. package/dest/HandshakeRegistry-BRPEG7GL.js +3 -0
  10. package/dest/HandshakeRegistry-BRPEG7GL.js.map +7 -0
  11. package/dest/MultiCallEntrypoint-CJHMYQT5.js +3 -0
  12. package/dest/MultiCallEntrypoint-CJHMYQT5.js.map +7 -0
  13. package/dest/SchnorrAccount-OB4N4QIM.js +3 -0
  14. package/dest/SchnorrAccount-OB4N4QIM.js.map +7 -0
  15. package/dest/SchnorrInitializerlessAccount-TWGKRUSY.js +3 -0
  16. package/dest/SchnorrInitializerlessAccount-TWGKRUSY.js.map +7 -0
  17. package/dest/bin/check_txe_oracle_version.d.ts +2 -0
  18. package/dest/bin/check_txe_oracle_version.d.ts.map +1 -0
  19. package/dest/bin/check_txe_oracle_version.js +22 -0
  20. package/dest/bin/index.d.ts +3 -0
  21. package/dest/bin/index.d.ts.map +1 -0
  22. package/dest/bin/index.js +4 -0
  23. package/dest/bin/index.js.map +7 -0
  24. package/dest/bin/oracle_test_server.d.ts +3 -0
  25. package/dest/bin/oracle_test_server.d.ts.map +1 -0
  26. package/dest/bin/oracle_test_server.js +41 -0
  27. package/dest/chunk-32UHX7YY.js +3 -0
  28. package/dest/chunk-32UHX7YY.js.map +7 -0
  29. package/dest/chunk-F4QVFWNM.js +258 -0
  30. package/dest/chunk-F4QVFWNM.js.map +7 -0
  31. package/dest/chunk-LILEKW2X.js +304 -0
  32. package/dest/chunk-LILEKW2X.js.map +7 -0
  33. package/dest/constants.d.ts +7 -0
  34. package/dest/constants.d.ts.map +1 -0
  35. package/dest/constants.js +10 -0
  36. package/dest/dispatcher_pool.d.ts +67 -0
  37. package/dest/dispatcher_pool.d.ts.map +1 -0
  38. package/dest/dispatcher_pool.js +288 -0
  39. package/dest/index.d.ts +52 -0
  40. package/dest/index.d.ts.map +1 -0
  41. package/dest/index.js +102 -0
  42. package/dest/metafile.json +38805 -0
  43. package/dest/msgpackr_fr_extension.d.ts +2 -0
  44. package/dest/msgpackr_fr_extension.d.ts.map +1 -0
  45. package/dest/msgpackr_fr_extension.js +21 -0
  46. package/dest/oracle/interfaces.d.ts +90 -0
  47. package/dest/oracle/interfaces.d.ts.map +1 -0
  48. package/dest/oracle/interfaces.js +3 -0
  49. package/dest/oracle/noir-structs/gas_settings_data.d.ts +14 -0
  50. package/dest/oracle/noir-structs/gas_settings_data.d.ts.map +1 -0
  51. package/dest/oracle/noir-structs/gas_settings_data.js +1 -0
  52. package/dest/oracle/noir-structs/tx_effects_data.d.ts +11 -0
  53. package/dest/oracle/noir-structs/tx_effects_data.d.ts.map +1 -0
  54. package/dest/oracle/noir-structs/tx_effects_data.js +1 -0
  55. package/dest/oracle/tagging_secret_strategy.d.ts +12 -0
  56. package/dest/oracle/tagging_secret_strategy.d.ts.map +1 -0
  57. package/dest/oracle/tagging_secret_strategy.js +12 -0
  58. package/dest/oracle/test-resolver/default_fixtures.d.ts +16 -0
  59. package/dest/oracle/test-resolver/default_fixtures.d.ts.map +1 -0
  60. package/dest/oracle/test-resolver/default_fixtures.js +207 -0
  61. package/dest/oracle/test-resolver/index.d.ts +9 -0
  62. package/dest/oracle/test-resolver/index.d.ts.map +1 -0
  63. package/dest/oracle/test-resolver/index.js +32 -0
  64. package/dest/oracle/test-resolver/resolver.d.ts +48 -0
  65. package/dest/oracle/test-resolver/resolver.d.ts.map +1 -0
  66. package/dest/oracle/test-resolver/resolver.js +181 -0
  67. package/dest/oracle/txe_oracle_public_context.d.ts +58 -0
  68. package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -0
  69. package/dest/oracle/txe_oracle_public_context.js +170 -0
  70. package/dest/oracle/txe_oracle_registry.d.ts +164 -0
  71. package/dest/oracle/txe_oracle_registry.d.ts.map +1 -0
  72. package/dest/oracle/txe_oracle_registry.js +753 -0
  73. package/dest/oracle/txe_oracle_top_level_context.d.ts +128 -0
  74. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -0
  75. package/dest/oracle/txe_oracle_top_level_context.js +815 -0
  76. package/dest/oracle/txe_oracle_version.d.ts +17 -0
  77. package/dest/oracle/txe_oracle_version.d.ts.map +1 -0
  78. package/dest/oracle/txe_oracle_version.js +14 -0
  79. package/dest/oracle/txe_private_execution_oracle.d.ts +17 -0
  80. package/dest/oracle/txe_private_execution_oracle.d.ts.map +1 -0
  81. package/dest/oracle/txe_private_execution_oracle.js +15 -0
  82. package/dest/rpc_server.d.ts +14 -0
  83. package/dest/rpc_server.d.ts.map +1 -0
  84. package/dest/rpc_server.js +78 -0
  85. package/dest/rpc_translator.d.ts +140 -0
  86. package/dest/rpc_translator.d.ts.map +1 -0
  87. package/dest/rpc_translator.js +976 -0
  88. package/dest/server.bundle.js +3 -0
  89. package/dest/server.bundle.js.map +7 -0
  90. package/dest/state_machine/archiver.d.ts +32 -0
  91. package/dest/state_machine/archiver.d.ts.map +1 -0
  92. package/dest/state_machine/archiver.js +95 -0
  93. package/dest/state_machine/dummy_p2p_client.d.ts +69 -0
  94. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -0
  95. package/dest/state_machine/dummy_p2p_client.js +180 -0
  96. package/dest/state_machine/global_variable_builder.d.ts +15 -0
  97. package/dest/state_machine/global_variable_builder.d.ts.map +1 -0
  98. package/dest/state_machine/global_variable_builder.js +25 -0
  99. package/dest/state_machine/index.d.ts +22 -0
  100. package/dest/state_machine/index.d.ts.map +1 -0
  101. package/dest/state_machine/index.js +110 -0
  102. package/dest/state_machine/mock_epoch_cache.d.ts +43 -0
  103. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -0
  104. package/dest/state_machine/mock_epoch_cache.js +88 -0
  105. package/dest/state_machine/synchronizer.d.ts +41 -0
  106. package/dest/state_machine/synchronizer.d.ts.map +1 -0
  107. package/dest/state_machine/synchronizer.js +70 -0
  108. package/dest/txe_session.d.ts +179 -0
  109. package/dest/txe_session.d.ts.map +1 -0
  110. package/dest/txe_session.js +697 -0
  111. package/dest/utils/block_creation.d.ts +28 -0
  112. package/dest/utils/block_creation.d.ts.map +1 -0
  113. package/dest/utils/block_creation.js +59 -0
  114. package/dest/utils/encoding.d.ts +194 -0
  115. package/dest/utils/encoding.d.ts.map +1 -0
  116. package/dest/utils/encoding.js +136 -0
  117. package/dest/utils/expected_failure_error.d.ts +4 -0
  118. package/dest/utils/expected_failure_error.d.ts.map +1 -0
  119. package/dest/utils/expected_failure_error.js +5 -0
  120. package/dest/utils/tx_effect_creation.d.ts +5 -0
  121. package/dest/utils/tx_effect_creation.d.ts.map +1 -0
  122. package/dest/utils/tx_effect_creation.js +12 -0
  123. package/dest/utils/txe_account_store.d.ts +10 -0
  124. package/dest/utils/txe_account_store.d.ts.map +1 -0
  125. package/dest/utils/txe_account_store.js +17 -0
  126. package/dest/utils/txe_artifact_resolver.d.ts +36 -0
  127. package/dest/utils/txe_artifact_resolver.d.ts.map +1 -0
  128. package/dest/utils/txe_artifact_resolver.js +160 -0
  129. package/dest/utils/txe_public_contract_data_source.d.ts +20 -0
  130. package/dest/utils/txe_public_contract_data_source.d.ts.map +1 -0
  131. package/dest/utils/txe_public_contract_data_source.js +51 -0
  132. package/dest/worker.bundle.js +3 -0
  133. package/dest/worker.bundle.js.map +7 -0
  134. package/dest/worker.d.ts +2 -0
  135. package/dest/worker.d.ts.map +1 -0
  136. package/dest/worker.js +92 -0
  137. package/package.json +115 -0
  138. package/src/bin/check_txe_oracle_version.ts +31 -0
  139. package/src/bin/index.ts +49 -0
  140. package/src/bin/oracle_test_server.ts +51 -0
  141. package/src/constants.ts +13 -0
  142. package/src/dispatcher_pool.ts +319 -0
  143. package/src/index.ts +152 -0
  144. package/src/msgpackr_fr_extension.ts +22 -0
  145. package/src/oracle/interfaces.ts +125 -0
  146. package/src/oracle/noir-structs/gas_settings_data.ts +16 -0
  147. package/src/oracle/noir-structs/tx_effects_data.ts +11 -0
  148. package/src/oracle/tagging_secret_strategy.ts +25 -0
  149. package/src/oracle/test-resolver/default_fixtures.ts +278 -0
  150. package/src/oracle/test-resolver/index.ts +43 -0
  151. package/src/oracle/test-resolver/resolver.ts +245 -0
  152. package/src/oracle/txe_oracle_public_context.ts +220 -0
  153. package/src/oracle/txe_oracle_registry.ts +501 -0
  154. package/src/oracle/txe_oracle_top_level_context.ts +1086 -0
  155. package/src/oracle/txe_oracle_version.ts +17 -0
  156. package/src/oracle/txe_private_execution_oracle.ts +30 -0
  157. package/src/rpc_server.ts +86 -0
  158. package/src/rpc_translator.ts +1229 -0
  159. package/src/state_machine/archiver.ts +118 -0
  160. package/src/state_machine/dummy_p2p_client.ts +264 -0
  161. package/src/state_machine/global_variable_builder.ts +39 -0
  162. package/src/state_machine/index.ts +152 -0
  163. package/src/state_machine/mock_epoch_cache.ts +111 -0
  164. package/src/state_machine/synchronizer.ts +105 -0
  165. package/src/txe_session.ts +1107 -0
  166. package/src/utils/block_creation.ts +91 -0
  167. package/src/utils/encoding.ts +171 -0
  168. package/src/utils/expected_failure_error.ts +5 -0
  169. package/src/utils/tx_effect_creation.ts +28 -0
  170. package/src/utils/txe_account_store.ts +23 -0
  171. package/src/utils/txe_artifact_resolver.ts +217 -0
  172. package/src/utils/txe_public_contract_data_source.ts +60 -0
  173. package/src/worker.ts +98 -0
@@ -0,0 +1,28 @@
1
+ import { BlockNumber } from '@aztec-labs/foundation/branded-types';
2
+ import { Fr } from '@aztec-labs/foundation/curves/bn254';
3
+ import { L2Block } from '@aztec-labs/stdlib/block';
4
+ import { type MerkleTreeWriteOperations } from '@aztec-labs/stdlib/trees';
5
+ import { BlockHeader, GlobalVariables, TxEffect } from '@aztec-labs/stdlib/tx';
6
+ /**
7
+ * Returns a transaction request hash that is valid for transactions that are the only ones in a block.
8
+ * @param blockNumber The number for the block in which there is a single transaction.
9
+ * @returns The transaction request hash.
10
+ */
11
+ export declare function getSingleTxBlockRequestHash(blockNumber: BlockNumber): Fr;
12
+ export declare function insertTxEffectIntoWorldTrees(txEffect: TxEffect, worldTrees: MerkleTreeWriteOperations, l1ToL2Messages?: Fr[]): Promise<void>;
13
+ export declare function makeTXEBlockHeader(worldTrees: MerkleTreeWriteOperations, globalVariables: GlobalVariables): Promise<BlockHeader>;
14
+ /**
15
+ * Creates an L2Block with proper archive chaining.
16
+ * This function:
17
+ * 1. Gets the current archive state as lastArchive for the header
18
+ * 2. Creates the block header
19
+ * 3. Updates the archive tree with the header hash
20
+ * 4. Gets the new archive state for the block's archive
21
+ *
22
+ * @param worldTrees - The world trees to read/write from
23
+ * @param globalVariables - Global variables for the block
24
+ * @param txEffects - Transaction effects to include in the block
25
+ * @returns The created L2Block with proper archive chaining
26
+ */
27
+ export declare function makeTXEBlock(worldTrees: MerkleTreeWriteOperations, globalVariables: GlobalVariables, txEffects: TxEffect[]): Promise<L2Block>;
28
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmxvY2tfY3JlYXRpb24uZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9ibG9ja19jcmVhdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEVBQUUsV0FBVyxFQUEyQyxNQUFNLHNDQUFzQyxDQUFDO0FBRTVHLE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSxxQ0FBcUMsQ0FBQztBQUN6RCxPQUFPLEVB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AAO,EAAE,WAAW,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAE/E;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,WAAW,GAAG,EAAE,CAExE;AAED,wBAAsB,4BAA4B,CAChD,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,yBAAyB,EACrC,cAAc,GAAE,EAAE,EAAO,GACxB,OAAO,CAAC,IAAI,CAAC,CAgBf;AAED,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,yBAAyB,EACrC,eAAe,EAAE,eAAe,GAC/B,OAAO,CAAC,WAAW,CAAC,CAYtB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,YAAY,CAChC,UAAU,EAAE,yBAAyB,EACrC,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,QAAQ,EAAE,GACpB,OAAO,CAAC,OAAO,CAAC,CAiBlB"}
@@ -0,0 +1,59 @@
1
+ import { MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, NULLIFIER_SUBTREE_HEIGHT } from '@aztec-labs/constants';
2
+ import { CheckpointNumber, IndexWithinCheckpoint } from '@aztec-labs/foundation/branded-types';
3
+ import { padArrayEnd } from '@aztec-labs/foundation/collection';
4
+ import { Fr } from '@aztec-labs/foundation/curves/bn254';
5
+ import { Body, L2Block } from '@aztec-labs/stdlib/block';
6
+ import { AppendOnlyTreeSnapshot, MerkleTreeId } from '@aztec-labs/stdlib/trees';
7
+ import { BlockHeader } from '@aztec-labs/stdlib/tx';
8
+ /**
9
+ * Returns a transaction request hash that is valid for transactions that are the only ones in a block.
10
+ * @param blockNumber The number for the block in which there is a single transaction.
11
+ * @returns The transaction request hash.
12
+ */ export function getSingleTxBlockRequestHash(blockNumber) {
13
+ return new Fr(blockNumber + 9999); // Why does this need to be a high number? Why do small numbered nullifiers already exist?
14
+ }
15
+ export async function insertTxEffectIntoWorldTrees(txEffect, worldTrees, l1ToL2Messages = []) {
16
+ await worldTrees.appendLeaves(MerkleTreeId.NOTE_HASH_TREE, padArrayEnd(txEffect.noteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX));
17
+ await worldTrees.batchInsert(MerkleTreeId.NULLIFIER_TREE, padArrayEnd(txEffect.nullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX).map((nullifier)=>nullifier.toBuffer()), NULLIFIER_SUBTREE_HEIGHT);
18
+ // Append the block's real message leaves unpadded at compact indices.
19
+ await worldTrees.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, l1ToL2Messages);
20
+ // We do not need to add public data writes because we apply them as we go.
21
+ }
22
+ export async function makeTXEBlockHeader(worldTrees, globalVariables) {
23
+ const stateReference = await worldTrees.getStateReference();
24
+ const archiveInfo = await worldTrees.getTreeInfo(MerkleTreeId.ARCHIVE);
25
+ return BlockHeader.from({
26
+ lastArchive: new AppendOnlyTreeSnapshot(new Fr(archiveInfo.root), Number(archiveInfo.size)),
27
+ spongeBlobHash: Fr.ZERO,
28
+ state: stateReference,
29
+ globalVariables,
30
+ totalFees: Fr.ZERO,
31
+ totalManaUsed: Fr.ZERO
32
+ });
33
+ }
34
+ /**
35
+ * Creates an L2Block with proper archive chaining.
36
+ * This function:
37
+ * 1. Gets the current archive state as lastArchive for the header
38
+ * 2. Creates the block header
39
+ * 3. Updates the archive tree with the header hash
40
+ * 4. Gets the new archive state for the block's archive
41
+ *
42
+ * @param worldTrees - The world trees to read/write from
43
+ * @param globalVariables - Global variables for the block
44
+ * @param txEffects - Transaction effects to include in the block
45
+ * @returns The created L2Block with proper archive chaining
46
+ */ export async function makeTXEBlock(worldTrees, globalVariables, txEffects) {
47
+ const header = await makeTXEBlockHeader(worldTrees, globalVariables);
48
+ // Update the archive tree with this block's header hash
49
+ await worldTrees.updateArchive(header);
50
+ // Get the new archive state after updating
51
+ const newArchiveInfo = await worldTrees.getTreeInfo(MerkleTreeId.ARCHIVE);
52
+ const newArchive = new AppendOnlyTreeSnapshot(new Fr(newArchiveInfo.root), Number(newArchiveInfo.size));
53
+ // L2Block requires checkpointNumber and indexWithinCheckpoint.
54
+ // TXE uses 1-block-per-checkpoint for testing simplicity, so we can use block number as checkpoint number.
55
+ // This uses the deprecated fromBlockNumber method intentionally for the TXE testing environment.
56
+ const checkpointNumber = CheckpointNumber.fromBlockNumber(globalVariables.blockNumber);
57
+ const indexWithinCheckpoint = IndexWithinCheckpoint(0);
58
+ return new L2Block(newArchive, header, new Body(txEffects), checkpointNumber, indexWithinCheckpoint);
59
+ }
@@ -0,0 +1,194 @@
1
+ import { Fr } from '@aztec-labs/foundation/curves/bn254';
2
+ import type { EthAddress } from '@aztec-labs/foundation/eth-address';
3
+ import { type ContractArtifact } from '@aztec-labs/stdlib/abi';
4
+ import { AztecAddress } from '@aztec-labs/stdlib/aztec-address';
5
+ import { BlockHash } from '@aztec-labs/stdlib/block';
6
+ import { type ContractInstanceWithAddress } from '@aztec-labs/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-labs/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-labs/stdlib/abi").AbiType, unknown, z.core.$ZodTypeInternals<import("@aztec-labs/stdlib/abi").AbiType, unknown>>;
72
+ visibility: z.ZodEnum<{
73
+ databus: "databus";
74
+ private: "private";
75
+ public: "public";
76
+ }>;
77
+ }, z.core.$strip>>;
78
+ returnType: z.ZodOptional<z.ZodType<import("@aztec-labs/stdlib/abi").AbiType, unknown, z.core.$ZodTypeInternals<import("@aztec-labs/stdlib/abi").AbiType, unknown>>>;
79
+ returnTypes: z.ZodOptional<z.ZodArray<z.ZodType<import("@aztec-labs/stdlib/abi").AbiType, unknown, z.core.$ZodTypeInternals<import("@aztec-labs/stdlib/abi").AbiType, unknown>>>>;
80
+ errorTypes: z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
81
+ error_kind: z.ZodLiteral<"string">;
82
+ string: z.ZodString;
83
+ }, z.core.$strip>, z.ZodObject<{
84
+ error_kind: z.ZodLiteral<"fmtstring">;
85
+ length: z.ZodNumber;
86
+ item_types: z.ZodArray<z.ZodType<import("@aztec-labs/stdlib/abi").AbiType, unknown, z.core.$ZodTypeInternals<import("@aztec-labs/stdlib/abi").AbiType, unknown>>>;
87
+ }, z.core.$strip>, z.ZodIntersection<z.ZodObject<{
88
+ error_kind: z.ZodLiteral<"custom">;
89
+ }, z.core.$strip>, z.ZodType<import("@aztec-labs/stdlib/abi").AbiType, unknown, z.core.$ZodTypeInternals<import("@aztec-labs/stdlib/abi").AbiType, unknown>>>]>>>;
90
+ }, z.core.$strip>, z.ZodObject<{
91
+ bytecode: import("@aztec-labs/foundation/schemas").ZodFor<Buffer<ArrayBufferLike>>;
92
+ verificationKey: z.ZodOptional<z.ZodString>;
93
+ debugSymbols: z.ZodString;
94
+ debug: z.ZodOptional<z.ZodObject<{
95
+ debugSymbols: z.ZodObject<{
96
+ location_tree: z.ZodObject<{
97
+ locations: z.ZodArray<z.ZodObject<{
98
+ parent: z.ZodNullable<z.ZodNumber>;
99
+ value: z.ZodObject<{
100
+ span: z.ZodObject<{
101
+ start: z.ZodNumber;
102
+ end: z.ZodNumber;
103
+ }, z.core.$strip>;
104
+ file: z.ZodNumber;
105
+ }, z.core.$strip>;
106
+ }, z.core.$strip>>;
107
+ }, z.core.$strip>;
108
+ acir_locations: z.ZodRecord<z.ZodString, z.ZodNumber>;
109
+ brillig_locations: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>;
110
+ }, z.core.$strip>;
111
+ files: z.ZodRecord<z.ZodString, z.ZodObject<{
112
+ source: z.ZodString;
113
+ path: z.ZodString;
114
+ function_locations: z.ZodArray<z.ZodObject<{
115
+ start: z.ZodNumber;
116
+ name: z.ZodString;
117
+ }, z.core.$strip>>;
118
+ }, z.core.$strip>>;
119
+ }, z.core.$strip>>;
120
+ }, z.core.$strip>>>;
121
+ nonDispatchPublicFunctions: z.ZodArray<z.ZodObject<{
122
+ name: z.ZodString;
123
+ functionType: z.ZodEnum<typeof import("@aztec-labs/stdlib/abi").FunctionType>;
124
+ isOnlySelf: z.ZodBoolean;
125
+ isStatic: z.ZodBoolean;
126
+ isInitializer: z.ZodBoolean;
127
+ parameters: z.ZodArray<z.ZodObject<{
128
+ name: z.ZodString;
129
+ type: z.ZodType<import("@aztec-labs/stdlib/abi").AbiType, unknown, z.core.$ZodTypeInternals<import("@aztec-labs/stdlib/abi").AbiType, unknown>>;
130
+ visibility: z.ZodEnum<{
131
+ databus: "databus";
132
+ private: "private";
133
+ public: "public";
134
+ }>;
135
+ }, z.core.$strip>>;
136
+ returnType: z.ZodOptional<z.ZodType<import("@aztec-labs/stdlib/abi").AbiType, unknown, z.core.$ZodTypeInternals<import("@aztec-labs/stdlib/abi").AbiType, unknown>>>;
137
+ returnTypes: z.ZodOptional<z.ZodArray<z.ZodType<import("@aztec-labs/stdlib/abi").AbiType, unknown, z.core.$ZodTypeInternals<import("@aztec-labs/stdlib/abi").AbiType, unknown>>>>;
138
+ errorTypes: z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
139
+ error_kind: z.ZodLiteral<"string">;
140
+ string: z.ZodString;
141
+ }, z.core.$strip>, z.ZodObject<{
142
+ error_kind: z.ZodLiteral<"fmtstring">;
143
+ length: z.ZodNumber;
144
+ item_types: z.ZodArray<z.ZodType<import("@aztec-labs/stdlib/abi").AbiType, unknown, z.core.$ZodTypeInternals<import("@aztec-labs/stdlib/abi").AbiType, unknown>>>;
145
+ }, z.core.$strip>, z.ZodIntersection<z.ZodObject<{
146
+ error_kind: z.ZodLiteral<"custom">;
147
+ }, z.core.$strip>, z.ZodType<import("@aztec-labs/stdlib/abi").AbiType, unknown, z.core.$ZodTypeInternals<import("@aztec-labs/stdlib/abi").AbiType, unknown>>>]>>>;
148
+ }, z.core.$strip>>;
149
+ outputs: z.ZodObject<{
150
+ structs: z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodType<import("@aztec-labs/stdlib/abi").AbiType, unknown, z.core.$ZodTypeInternals<import("@aztec-labs/stdlib/abi").AbiType, unknown>>>>, z.ZodTransform<Record<string, import("@aztec-labs/stdlib/abi").AbiType[]>, Record<string, import("@aztec-labs/stdlib/abi").AbiType[]>>>;
151
+ globals: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodType<import("@aztec-labs/stdlib/abi").AbiNamedValue, unknown, z.core.$ZodTypeInternals<import("@aztec-labs/stdlib/abi").AbiNamedValue, unknown>>>>;
152
+ }, z.core.$strip>;
153
+ storageLayout: z.ZodRecord<z.ZodString, z.ZodObject<{
154
+ slot: z.ZodType<Fr, string, z.core.$ZodTypeInternals<Fr, string>>;
155
+ }, z.core.$strip>>;
156
+ fileMap: z.ZodRecord<z.ZodCoercedNumber<unknown>, z.ZodObject<{
157
+ source: z.ZodString;
158
+ path: z.ZodString;
159
+ function_locations: z.ZodArray<z.ZodObject<{
160
+ start: z.ZodNumber;
161
+ name: z.ZodString;
162
+ }, z.core.$strip>>;
163
+ }, z.core.$strip>>;
164
+ }, z.core.$strip>, z.ZodIntersection<z.ZodIntersection<z.ZodObject<{
165
+ version: z.ZodLiteral<2>;
166
+ salt: import("@aztec-labs/foundation/schemas").ZodFor<Fr>;
167
+ deployer: import("@aztec-labs/foundation/schemas").ZodFor<AztecAddress>;
168
+ originalContractClassId: import("@aztec-labs/foundation/schemas").ZodFor<Fr>;
169
+ initializationHash: import("@aztec-labs/foundation/schemas").ZodFor<Fr>;
170
+ immutablesHash: import("@aztec-labs/foundation/schemas").ZodFor<Fr>;
171
+ publicKeys: z.ZodPipe<z.ZodObject<{
172
+ npkMHash: z.ZodType<Fr, string, z.core.$ZodTypeInternals<Fr, string>>;
173
+ ivpkM: z.ZodType<import("@aztec-labs/foundation/schemas").Point, string, z.core.$ZodTypeInternals<import("@aztec-labs/foundation/schemas").Point, string>>;
174
+ ovpkMHash: z.ZodType<Fr, string, z.core.$ZodTypeInternals<Fr, string>>;
175
+ tpkMHash: z.ZodType<Fr, string, z.core.$ZodTypeInternals<Fr, string>>;
176
+ mspkMHash: z.ZodType<Fr, string, z.core.$ZodTypeInternals<Fr, string>>;
177
+ fbpkMHash: z.ZodType<Fr, string, z.core.$ZodTypeInternals<Fr, string>>;
178
+ }, z.core.$strip>, z.ZodTransform<import("@aztec-labs/stdlib/keys").PublicKeys, {
179
+ npkMHash: Fr;
180
+ ivpkM: import("@aztec-labs/foundation/schemas").Point;
181
+ ovpkMHash: Fr;
182
+ tpkMHash: Fr;
183
+ mspkMHash: Fr;
184
+ fbpkMHash: Fr;
185
+ }>>;
186
+ }, z.core.$strip>, z.ZodObject<{
187
+ currentContractClassId: import("@aztec-labs/foundation/schemas").ZodFor<Fr>;
188
+ }, z.core.$strip>>, z.ZodObject<{
189
+ address: import("@aztec-labs/foundation/schemas").ZodFor<AztecAddress>;
190
+ }, z.core.$strip>>]>>;
191
+ export declare const ForeignCallResultSchema: z.ZodObject<{
192
+ values: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
193
+ }, z.core.$strip>;
194
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZW5jb2RpbmcuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9lbmNvZGluZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0scUNBQXFDLENBQUM7QUFDekQsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0sb0NBQW9DLENBQUM7QUFFckUsT0FBTyxFQUFFLEtBQUssZ0JBQWdCLEVBQTBCLE1BQU0sd0JBQXdCLENBQUM7QUFDdkYsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLGtDQUFrQyxDQUFDO0FBQ2hFLE9BQU8sRUFBRSxTQUFTLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUNyRCxPQUFPLEVBQUUsS0FBSywyQkFBMkIsRUFBcUMsTUFBTSw2QkFBNkIsQ0FBQztBQUNsSCxPQUFPLEVBQUUsQ0FBQyxFQUFFLE1BQU0sS0FBSyxDQUFDO0FBRXhCLE1BQU0sTUFBTSxpQkFBaUIsR0FBRyxNQUFNLENBQUM7QUFFdkMsTUFB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M,CAOpH;AAID,wBAAgB,QAAQ,CACtB,KAAK,EAAE,YAAY,GAAG,UAAU,GAAG,EAAE,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GACzE,iBAAiB,CAYnB;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,gBAAgB,CAEpD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,qBAE/C;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAEhE;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,gBAAgB,EAC7B,MAAM,EAAE,MAAM,GACb,CAAC,gBAAgB,EAAE,iBAAiB,CAAC,CAYvC;AAED;;;;;;GAMG;AACH,wBAAgB,iCAAiC,CAC/C,WAAW,EAAE,gBAAgB,EAAE,EAC/B,MAAM,EAAE,MAAM,EACd,iBAAiB,EAAE,MAAM,GACxB,CAAC,gBAAgB,EAAE,iBAAiB,CAAC,CAsBvC;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,CAAC,iBAAiB,GAAG,gBAAgB,CAAC,EAAE;;EAEhF;AAED,eAAO,MAAM,uBAAuB,aAAa,CAAC;AAElD,eAAO,MAAM,sBAAsB,yBAAsB,CAAC;AAE1D,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAEjC,CAAC;AAEF,eAAO,MAAM,uBAAuB;;iBAElC,CAAC"}
@@ -0,0 +1,136 @@
1
+ import { Fr } from '@aztec-labs/foundation/curves/bn254';
2
+ import { hexToBuffer } from '@aztec-labs/foundation/string';
3
+ import { ContractArtifactSchema } from '@aztec-labs/stdlib/abi';
4
+ import { AztecAddress } from '@aztec-labs/stdlib/aztec-address';
5
+ import { BlockHash } from '@aztec-labs/stdlib/block';
6
+ import { ContractInstanceWithAddressSchema } from '@aztec-labs/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
+ export class ExpectedFailureError extends Error {
2
+ constructor(message){
3
+ super(message);
4
+ }
5
+ }
@@ -0,0 +1,5 @@
1
+ import { BlockNumber } from '@aztec-labs/foundation/branded-types';
2
+ import type { ExecutionNoteCache } from '@aztec-labs/pxe/simulator';
3
+ import { TxEffect } from '@aztec-labs/stdlib/tx';
4
+ export declare function makeTxEffect(noteCache: ExecutionNoteCache, txBlockNumber: BlockNumber): Promise<TxEffect>;
5
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhfZWZmZWN0X2NyZWF0aW9uLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbHMvdHhfZWZmZWN0X2NyZWF0aW9uLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSxzQ0FBc0MsQ0FBQztBQUVuRSxPQUFPLEtBQUssRUFBRSxrQkFBa0IsRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBRXBFLE9BQU8sRUFBRSxRQUFRLEVBQVUsTUFBTSx1QkFBdUIsQ0FBQztBQUV6RCx3QkFBc0IsWUFBWSxDQUFDLFNBQVMsRUFBRSxrQkFBa0IsRUFBRSxhQUFhLEVBQUUsV0FBVyxHQUFHLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0FxQi9HIn0=
@@ -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,sCAAsC,CAAC;AAEnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,QAAQ,EAAU,MAAM,uBAAuB,CAAC;AAEzD,wBAAsB,YAAY,CAAC,SAAS,EAAE,kBAAkB,EAAE,aAAa,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAqB/G"}
@@ -0,0 +1,12 @@
1
+ import { Fr } from '@aztec-labs/foundation/curves/bn254';
2
+ import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash } from '@aztec-labs/stdlib/hash';
3
+ import { TxEffect, TxHash } from '@aztec-labs/stdlib/tx';
4
+ export async function makeTxEffect(noteCache, txBlockNumber) {
5
+ const txEffect = TxEffect.empty();
6
+ const nonceGenerator = noteCache.getNonceGenerator();
7
+ txEffect.noteHashes = await Promise.all(noteCache.getAllNotes().map(async (pendingNote, i)=>computeUniqueNoteHash(await computeNoteHashNonce(nonceGenerator, i), await siloNoteHash(pendingNote.note.contractAddress, pendingNote.noteHashForConsumption))));
8
+ // Nullifiers are already siloed
9
+ txEffect.nullifiers = noteCache.getAllNullifiers();
10
+ txEffect.txHash = new TxHash(new Fr(txBlockNumber));
11
+ return txEffect;
12
+ }
@@ -0,0 +1,10 @@
1
+ import type { AztecAsyncKVStore } from '@aztec-labs/kv-store';
2
+ import type { AztecAddress } from '@aztec-labs/stdlib/aztec-address';
3
+ import { CompleteAddress } from '@aztec-labs/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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX2FjY291bnRfc3RvcmUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy90eGVfYWNjb3VudF9zdG9yZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxpQkFBaUIsRUFBaUIsTUFBTSxzQkFBc0IsQ0FBQztBQUM3RSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSxrQ0FBa0MsQ0FBQztBQUNyRSxPQUFPLEVBQUUsZUFBZSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFFOUQscUJBQWEsZUFBZTs7SUFHMUIsWUFBWSxLQUFLLEVBQUUsaUJBQWlCLEVBRW5DO0lBRUssVUFBVSxDQUFDLEdBQUcsRUFBRSxZQUFZLDRCQU1qQztJQUVLLFVBQVUsQ0FBQyxHQUFHLEVBQUUsWUFBWSxFQUFFLEtBQUssRUFBRSxlQUFlLGlCQUV6RDtDQUNGIn0=
@@ -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,sBAAsB,CAAC;AAC7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,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,17 @@
1
+ import { CompleteAddress } from '@aztec-labs/stdlib/contract';
2
+ export class TXEAccountStore {
3
+ #accounts;
4
+ constructor(store){
5
+ this.#accounts = store.openMap('accounts');
6
+ }
7
+ async getAccount(key) {
8
+ const completeAddress = await this.#accounts.getAsync(key.toString());
9
+ if (!completeAddress) {
10
+ throw new Error(`Account not found: ${key.toString()}`);
11
+ }
12
+ return CompleteAddress.fromBuffer(completeAddress);
13
+ }
14
+ async setAccount(key, value) {
15
+ await this.#accounts.set(key.toString(), value.toBuffer());
16
+ }
17
+ }
@@ -0,0 +1,36 @@
1
+ import { Fr } from '@aztec-labs/foundation/curves/bn254';
2
+ import type { ContractStore } from '@aztec-labs/pxe/client/lazy';
3
+ import { AztecAddress } from '@aztec-labs/stdlib/aztec-address';
4
+ import { type ContractArtifactWithHash, type ContractInstanceWithAddress } from '@aztec-labs/stdlib/contract';
5
+ export interface ResolvedArtifact {
6
+ artifact: ContractArtifactWithHash;
7
+ instance: ContractInstanceWithAddress;
8
+ }
9
+ /**
10
+ * Resolves and caches contract artifacts and their associated instances.
11
+ *
12
+ * Artifact hash computation is expensive, so this service deduplicates both completed and in-flight computations.
13
+ * Two cache levels are kept: full deploys (artifact + computed instance) keyed by the full deploy context, and loaded +
14
+ * hashed artifacts keyed by the compiled-bytecode hash so deploys of the same contract with different args / salt /
15
+ * deployer reuse the same `ContractArtifactWithHash`.
16
+ */
17
+ export declare class TXEArtifactResolver {
18
+ #private;
19
+ private readonly contractStore;
20
+ private readonly schnorrClassId;
21
+ constructor(contractStore: ContractStore, schnorrClassId: Fr);
22
+ /** Resolves the Schnorr account contract artifact and instance for the given secret, caching the result. */
23
+ resolveAccountArtifact(secret: Fr): Promise<ResolvedArtifact>;
24
+ /** Resolves a contract artifact from disk by path, computes its instance, and caches the result. */
25
+ resolveDeployArtifact({ rootPath, packageName, contractPath, initializer, args, secret, salt, deployer }: {
26
+ rootPath: string;
27
+ packageName: string;
28
+ contractPath: string;
29
+ initializer: string;
30
+ args: Fr[];
31
+ secret: Fr;
32
+ salt: Fr;
33
+ deployer: AztecAddress;
34
+ }): Promise<ResolvedArtifact>;
35
+ }
36
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX2FydGlmYWN0X3Jlc29sdmVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbHMvdHhlX2FydGlmYWN0X3Jlc29sdmVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSxxQ0FBcUMsQ0FBQztBQUV6RCxPQUFPLEtBQUssRUFBRSxhQUFhLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUVqRSxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sa0NBQWtDLENBQUM7QUFDaEUsT0FBTyxFQUNMLEtBQUssd0JBQXdCLEVBQzdCLEtBQUssMkJBQTJCLEVBR2pDLE1BQU0sNkJBQTZCLENBQUM7QUFRckMsTUFBTSxXQUFXLGdCQUFnQjtJQUMvQixRQUFRLEVBQUUsd0JBQXdCLENBQUM7SUFDbkMsUUFBUSxFQUFFLDJCQUEyQixDQUFDO0NBQ3ZDO0FBaUNEOzs7Ozs7O0dBT0c7QUFDSCxxQkFBYSxtQkFBbUI7O0lBTTVCLE9BQU8sQ0FBQyxRQUFRLENBQUMsYUFBYTtJQUM5QixPQUFPLENBQUMsUUFBUSxDQUFDLGNBQWM7SUFGakMsWUFDbUIsYUFBYSxFQUFFLGFBQWEsRUFDNUIsY0FBYyxFQUFFLEVBQUUsRUFDakM7SUFFSiw0R0FBNEc7SUFDNUcsc0JBQXNCLENBQUMsTUFBTSxFQUFFLEVBQUUsR0FBRyxPQUFPLENBQU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