@aztec-labs/aztec.js 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 (275) hide show
  1. package/README.md +44 -0
  2. package/dest/account/account.d.ts +44 -0
  3. package/dest/account/account.d.ts.map +1 -0
  4. package/dest/account/account.js +31 -0
  5. package/dest/account/account_contract.d.ts +49 -0
  6. package/dest/account/account_contract.d.ts.map +1 -0
  7. package/dest/account/account_contract.js +20 -0
  8. package/dest/account/index.d.ts +11 -0
  9. package/dest/account/index.d.ts.map +1 -0
  10. package/dest/account/index.js +6 -0
  11. package/dest/api/abi.d.ts +4 -0
  12. package/dest/api/abi.d.ts.map +1 -0
  13. package/dest/api/abi.js +1 -0
  14. package/dest/api/account.d.ts +5 -0
  15. package/dest/api/account.d.ts.map +1 -0
  16. package/dest/api/account.js +3 -0
  17. package/dest/api/addresses.d.ts +4 -0
  18. package/dest/api/addresses.d.ts.map +1 -0
  19. package/dest/api/addresses.js +3 -0
  20. package/dest/api/authorization.d.ts +5 -0
  21. package/dest/api/authorization.d.ts.map +1 -0
  22. package/dest/api/authorization.js +4 -0
  23. package/dest/api/block.d.ts +3 -0
  24. package/dest/api/block.d.ts.map +1 -0
  25. package/dest/api/block.js +2 -0
  26. package/dest/api/contract.d.ts +48 -0
  27. package/dest/api/contract.d.ts.map +1 -0
  28. package/dest/api/contract.js +46 -0
  29. package/dest/api/crypto.d.ts +2 -0
  30. package/dest/api/crypto.d.ts.map +1 -0
  31. package/dest/api/crypto.js +1 -0
  32. package/dest/api/deployment.d.ts +4 -0
  33. package/dest/api/deployment.d.ts.map +1 -0
  34. package/dest/api/deployment.js +3 -0
  35. package/dest/api/eth_address.d.ts +2 -0
  36. package/dest/api/eth_address.d.ts.map +1 -0
  37. package/dest/api/eth_address.js +1 -0
  38. package/dest/api/ethereum.d.ts +2 -0
  39. package/dest/api/ethereum.d.ts.map +1 -0
  40. package/dest/api/ethereum.js +1 -0
  41. package/dest/api/event_cursor.d.ts +44 -0
  42. package/dest/api/event_cursor.d.ts.map +1 -0
  43. package/dest/api/event_cursor.js +42 -0
  44. package/dest/api/events.d.ts +36 -0
  45. package/dest/api/events.d.ts.map +1 -0
  46. package/dest/api/events.js +59 -0
  47. package/dest/api/fee.d.ts +6 -0
  48. package/dest/api/fee.d.ts.map +1 -0
  49. package/dest/api/fee.js +4 -0
  50. package/dest/api/fee_testing.d.ts +2 -0
  51. package/dest/api/fee_testing.d.ts.map +1 -0
  52. package/dest/api/fee_testing.js +1 -0
  53. package/dest/api/fields.d.ts +4 -0
  54. package/dest/api/fields.d.ts.map +1 -0
  55. package/dest/api/fields.js +3 -0
  56. package/dest/api/keys.d.ts +4 -0
  57. package/dest/api/keys.d.ts.map +1 -0
  58. package/dest/api/keys.js +3 -0
  59. package/dest/api/log.d.ts +3 -0
  60. package/dest/api/log.d.ts.map +1 -0
  61. package/dest/api/log.js +2 -0
  62. package/dest/api/messaging.d.ts +3 -0
  63. package/dest/api/messaging.d.ts.map +1 -0
  64. package/dest/api/messaging.js +2 -0
  65. package/dest/api/node.d.ts +25 -0
  66. package/dest/api/node.d.ts.map +1 -0
  67. package/dest/api/node.js +22 -0
  68. package/dest/api/note.d.ts +2 -0
  69. package/dest/api/note.d.ts.map +1 -0
  70. package/dest/api/note.js +1 -0
  71. package/dest/api/protocol.d.ts +6 -0
  72. package/dest/api/protocol.d.ts.map +1 -0
  73. package/dest/api/protocol.js +5 -0
  74. package/dest/api/trees.d.ts +3 -0
  75. package/dest/api/trees.d.ts.map +1 -0
  76. package/dest/api/trees.js +2 -0
  77. package/dest/api/tx.d.ts +3 -0
  78. package/dest/api/tx.d.ts.map +1 -0
  79. package/dest/api/tx.js +1 -0
  80. package/dest/api/utils.d.ts +13 -0
  81. package/dest/api/utils.d.ts.map +1 -0
  82. package/dest/api/utils.js +12 -0
  83. package/dest/api/wallet.d.ts +8 -0
  84. package/dest/api/wallet.d.ts.map +1 -0
  85. package/dest/api/wallet.js +7 -0
  86. package/dest/authorization/call_authorization_request.d.ts +46 -0
  87. package/dest/authorization/call_authorization_request.d.ts.map +1 -0
  88. package/dest/authorization/call_authorization_request.js +72 -0
  89. package/dest/contract/base_contract_interaction.d.ts +32 -0
  90. package/dest/contract/base_contract_interaction.d.ts.map +1 -0
  91. package/dest/contract/base_contract_interaction.js +24 -0
  92. package/dest/contract/batch_call.d.ts +27 -0
  93. package/dest/contract/batch_call.d.ts.map +1 -0
  94. package/dest/contract/batch_call.js +152 -0
  95. package/dest/contract/checker.d.ts +11 -0
  96. package/dest/contract/checker.d.ts.map +1 -0
  97. package/dest/contract/checker.js +107 -0
  98. package/dest/contract/contract.d.ts +33 -0
  99. package/dest/contract/contract.d.ts.map +1 -0
  100. package/dest/contract/contract.js +36 -0
  101. package/dest/contract/contract_base.d.ts +51 -0
  102. package/dest/contract/contract_base.d.ts.map +1 -0
  103. package/dest/contract/contract_base.js +38 -0
  104. package/dest/contract/contract_function_interaction.d.ts +67 -0
  105. package/dest/contract/contract_function_interaction.d.ts.map +1 -0
  106. package/dest/contract/contract_function_interaction.js +218 -0
  107. package/dest/contract/deploy_method.d.ts +433 -0
  108. package/dest/contract/deploy_method.d.ts.map +1 -0
  109. package/dest/contract/deploy_method.js +471 -0
  110. package/dest/contract/fastforward_contract_update.d.ts +25 -0
  111. package/dest/contract/fastforward_contract_update.d.ts.map +1 -0
  112. package/dest/contract/fastforward_contract_update.js +57 -0
  113. package/dest/contract/interaction_options.d.ts +213 -0
  114. package/dest/contract/interaction_options.d.ts.map +1 -0
  115. package/dest/contract/interaction_options.js +87 -0
  116. package/dest/contract/protocol_contracts/contract-class-registry.d.ts +18 -0
  117. package/dest/contract/protocol_contracts/contract-class-registry.d.ts.map +1 -0
  118. package/dest/contract/protocol_contracts/contract-class-registry.js +137 -0
  119. package/dest/contract/protocol_contracts/contract-instance-registry.d.ts +25 -0
  120. package/dest/contract/protocol_contracts/contract-instance-registry.d.ts.map +1 -0
  121. package/dest/contract/protocol_contracts/contract-instance-registry.js +366 -0
  122. package/dest/contract/protocol_contracts/fee-juice.d.ts +24 -0
  123. package/dest/contract/protocol_contracts/fee-juice.d.ts.map +1 -0
  124. package/dest/contract/protocol_contracts/fee-juice.js +383 -0
  125. package/dest/contract/wait_for_proven.d.ts +18 -0
  126. package/dest/contract/wait_for_proven.d.ts.map +1 -0
  127. package/dest/contract/wait_for_proven.js +17 -0
  128. package/dest/contract/wait_opts.d.ts +21 -0
  129. package/dest/contract/wait_opts.d.ts.map +1 -0
  130. package/dest/contract/wait_opts.js +5 -0
  131. package/dest/deployment/contract_deployer.d.ts +28 -0
  132. package/dest/deployment/contract_deployer.d.ts.map +1 -0
  133. package/dest/deployment/contract_deployer.js +35 -0
  134. package/dest/deployment/publish_class.d.ts +6 -0
  135. package/dest/deployment/publish_class.d.ts.map +1 -0
  136. package/dest/deployment/publish_class.js +17 -0
  137. package/dest/deployment/publish_instance.d.ts +10 -0
  138. package/dest/deployment/publish_instance.d.ts.map +1 -0
  139. package/dest/deployment/publish_instance.js +11 -0
  140. package/dest/ethereum/portal_manager.d.ts +146 -0
  141. package/dest/ethereum/portal_manager.d.ts.map +1 -0
  142. package/dest/ethereum/portal_manager.js +415 -0
  143. package/dest/fee/fee_juice_payment_method_with_claim.d.ts +23 -0
  144. package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -0
  145. package/dest/fee/fee_juice_payment_method_with_claim.js +46 -0
  146. package/dest/fee/fee_payment_method.d.ts +26 -0
  147. package/dest/fee/fee_payment_method.d.ts.map +1 -0
  148. package/dest/fee/fee_payment_method.js +3 -0
  149. package/dest/fee/private_fee_payment_method.d.ts +69 -0
  150. package/dest/fee/private_fee_payment_method.d.ts.map +1 -0
  151. package/dest/fee/private_fee_payment_method.js +122 -0
  152. package/dest/fee/public_fee_payment_method.d.ts +59 -0
  153. package/dest/fee/public_fee_payment_method.d.ts.map +1 -0
  154. package/dest/fee/public_fee_payment_method.js +116 -0
  155. package/dest/fee/sponsored_fee_payment.d.ts +17 -0
  156. package/dest/fee/sponsored_fee_payment.d.ts.map +1 -0
  157. package/dest/fee/sponsored_fee_payment.js +33 -0
  158. package/dest/scripts/generate_protocol_contract_types.d.ts +2 -0
  159. package/dest/scripts/generate_protocol_contract_types.d.ts.map +1 -0
  160. package/dest/scripts/generate_protocol_contract_types.js +128 -0
  161. package/dest/test/fixtures.d.ts +13 -0
  162. package/dest/test/fixtures.d.ts.map +1 -0
  163. package/dest/test/fixtures.js +185 -0
  164. package/dest/utils/abi_types.d.ts +32 -0
  165. package/dest/utils/abi_types.d.ts.map +1 -0
  166. package/dest/utils/abi_types.js +1 -0
  167. package/dest/utils/authwit.d.ts +119 -0
  168. package/dest/utils/authwit.d.ts.map +1 -0
  169. package/dest/utils/authwit.js +266 -0
  170. package/dest/utils/cross_chain.d.ts +28 -0
  171. package/dest/utils/cross_chain.d.ts.map +1 -0
  172. package/dest/utils/cross_chain.js +26 -0
  173. package/dest/utils/fee_juice.d.ts +8 -0
  174. package/dest/utils/fee_juice.d.ts.map +1 -0
  175. package/dest/utils/fee_juice.js +10 -0
  176. package/dest/utils/field_compressed_string.d.ts +17 -0
  177. package/dest/utils/field_compressed_string.d.ts.map +1 -0
  178. package/dest/utils/field_compressed_string.js +15 -0
  179. package/dest/utils/node.d.ts +24 -0
  180. package/dest/utils/node.d.ts.map +1 -0
  181. package/dest/utils/node.js +80 -0
  182. package/dest/utils/pub_key.d.ts +9 -0
  183. package/dest/utils/pub_key.d.ts.map +1 -0
  184. package/dest/utils/pub_key.js +8 -0
  185. package/dest/wallet/account_entrypoint_meta_payment_method.d.ts +33 -0
  186. package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -0
  187. package/dest/wallet/account_entrypoint_meta_payment_method.js +63 -0
  188. package/dest/wallet/account_manager.d.ts +73 -0
  189. package/dest/wallet/account_manager.d.ts.map +1 -0
  190. package/dest/wallet/account_manager.js +102 -0
  191. package/dest/wallet/capabilities.d.ts +456 -0
  192. package/dest/wallet/capabilities.d.ts.map +1 -0
  193. package/dest/wallet/capabilities.js +3 -0
  194. package/dest/wallet/deploy_account_method.d.ts +97 -0
  195. package/dest/wallet/deploy_account_method.d.ts.map +1 -0
  196. package/dest/wallet/deploy_account_method.js +127 -0
  197. package/dest/wallet/index.d.ts +5 -0
  198. package/dest/wallet/index.d.ts.map +1 -0
  199. package/dest/wallet/index.js +4 -0
  200. package/dest/wallet/tx_simulation_result_with_app_offset.d.ts +40 -0
  201. package/dest/wallet/tx_simulation_result_with_app_offset.d.ts.map +1 -0
  202. package/dest/wallet/tx_simulation_result_with_app_offset.js +65 -0
  203. package/dest/wallet/wallet.d.ts +1451 -0
  204. package/dest/wallet/wallet.d.ts.map +1 -0
  205. package/dest/wallet/wallet.js +430 -0
  206. package/package.json +138 -0
  207. package/src/account/account.ts +72 -0
  208. package/src/account/account_contract.ts +80 -0
  209. package/src/account/index.ts +12 -0
  210. package/src/api/README.md +7 -0
  211. package/src/api/abi.ts +42 -0
  212. package/src/api/account.ts +12 -0
  213. package/src/api/addresses.ts +3 -0
  214. package/src/api/authorization.ts +15 -0
  215. package/src/api/block.ts +2 -0
  216. package/src/api/contract.ts +86 -0
  217. package/src/api/crypto.ts +1 -0
  218. package/src/api/deployment.ts +3 -0
  219. package/src/api/eth_address.ts +1 -0
  220. package/src/api/ethereum.ts +10 -0
  221. package/src/api/event_cursor.ts +60 -0
  222. package/src/api/events.ts +79 -0
  223. package/src/api/fee.ts +5 -0
  224. package/src/api/fee_testing.ts +1 -0
  225. package/src/api/fields.ts +3 -0
  226. package/src/api/keys.ts +8 -0
  227. package/src/api/log.ts +2 -0
  228. package/src/api/messaging.ts +2 -0
  229. package/src/api/node.ts +30 -0
  230. package/src/api/note.ts +1 -0
  231. package/src/api/protocol.ts +6 -0
  232. package/src/api/trees.ts +2 -0
  233. package/src/api/tx.ts +20 -0
  234. package/src/api/utils.ts +14 -0
  235. package/src/api/wallet.ts +83 -0
  236. package/src/authorization/call_authorization_request.ts +93 -0
  237. package/src/contract/base_contract_interaction.ts +62 -0
  238. package/src/contract/batch_call.ts +188 -0
  239. package/src/contract/checker.ts +122 -0
  240. package/src/contract/contract.ts +52 -0
  241. package/src/contract/contract_base.ts +73 -0
  242. package/src/contract/contract_function_interaction.ts +297 -0
  243. package/src/contract/deploy_method.ts +877 -0
  244. package/src/contract/fastforward_contract_update.ts +71 -0
  245. package/src/contract/interaction_options.ts +301 -0
  246. package/src/contract/protocol_contracts/contract-class-registry.ts +104 -0
  247. package/src/contract/protocol_contracts/contract-instance-registry.ts +241 -0
  248. package/src/contract/protocol_contracts/fee-juice.ts +257 -0
  249. package/src/contract/wait_for_proven.ts +43 -0
  250. package/src/contract/wait_opts.ts +26 -0
  251. package/src/deployment/contract_deployer.ts +40 -0
  252. package/src/deployment/publish_class.ts +34 -0
  253. package/src/deployment/publish_instance.ts +24 -0
  254. package/src/ethereum/portal_manager.ts +539 -0
  255. package/src/fee/fee_juice_payment_method_with_claim.ts +63 -0
  256. package/src/fee/fee_payment_method.ts +26 -0
  257. package/src/fee/private_fee_payment_method.ts +145 -0
  258. package/src/fee/public_fee_payment_method.ts +145 -0
  259. package/src/fee/sponsored_fee_payment.ts +45 -0
  260. package/src/scripts/generate_protocol_contract_types.ts +160 -0
  261. package/src/test/fixtures.ts +126 -0
  262. package/src/utils/abi_types.ts +32 -0
  263. package/src/utils/authwit.ts +327 -0
  264. package/src/utils/cross_chain.ts +55 -0
  265. package/src/utils/fee_juice.ts +14 -0
  266. package/src/utils/field_compressed_string.ts +27 -0
  267. package/src/utils/node.ts +110 -0
  268. package/src/utils/pub_key.ts +12 -0
  269. package/src/wallet/account_entrypoint_meta_payment_method.ts +76 -0
  270. package/src/wallet/account_manager.ts +164 -0
  271. package/src/wallet/capabilities.ts +505 -0
  272. package/src/wallet/deploy_account_method.ts +234 -0
  273. package/src/wallet/index.ts +4 -0
  274. package/src/wallet/tx_simulation_result_with_app_offset.ts +100 -0
  275. package/src/wallet/wallet.ts +668 -0
@@ -0,0 +1,71 @@
1
+ import { Fr } from '@aztec-labs/foundation/curves/bn254';
2
+ import { ProtocolContractAddress } from '@aztec-labs/protocol-contracts';
3
+ import type { AztecAddress } from '@aztec-labs/stdlib/aztec-address';
4
+ import {
5
+ DelayedPublicMutableValuesWithHash,
6
+ ScheduledDelayChange,
7
+ ScheduledValueChange,
8
+ } from '@aztec-labs/stdlib/delayed-public-mutable';
9
+ import type { AztecNode } from '@aztec-labs/stdlib/interfaces/client';
10
+ import { SimulationOverrides } from '@aztec-labs/stdlib/tx';
11
+
12
+ /**
13
+ * Builds `SimulationOverrides` that simulate a deployed instance as if it had already been upgraded to a
14
+ * new contract class. Mirrors a real onchain upgrade (scheduling the new class and waiting out the delay):
15
+ *
16
+ * - `publicStorage` rewrites the `ContractInstanceRegistry`'s delayed-public-mutable storage so the AVM's
17
+ * `UpdateCheck` resolves to the new class id.
18
+ * - `contracts` swaps the deployed instance for one whose `currentContractClassId` is bumped to the new class.
19
+ *
20
+ * The new class must already be registered on chain.
21
+ *
22
+ * @throws If the instance is not deployed, the class is not registered on chain, or the instance is already on the target class.
23
+ */
24
+ export async function fastForwardContractUpdate(args: {
25
+ /** Address of the deployed instance to upgrade. */
26
+ instanceAddress: AztecAddress;
27
+ /** ID of the (already-registered) class to upgrade to. */
28
+ newClassId: Fr;
29
+ /** Node used to fetch the existing instance and validate the class is registered. */
30
+ node: AztecNode;
31
+ }): Promise<SimulationOverrides> {
32
+ const { instanceAddress, newClassId, node } = args;
33
+
34
+ const instance = await node.getContract(instanceAddress);
35
+ if (!instance) {
36
+ throw new Error(`Instance not deployed at ${instanceAddress}. Deploy it before fast-forwarding an update.`);
37
+ }
38
+
39
+ const klass = await node.getContractClass(newClassId);
40
+ if (!klass) {
41
+ throw new Error(
42
+ `Contract class ${newClassId} is not registered on chain. Publish it before fast-forwarding to it.`,
43
+ );
44
+ }
45
+
46
+ if (instance.currentContractClassId.equals(newClassId)) {
47
+ throw new Error(`Instance ${instanceAddress} is already on class ${newClassId}. Nothing to fast-forward.`);
48
+ }
49
+
50
+ // Build the SVC the same way `ContractInstanceRegistry::update` would have, but with a timestamp_of_change
51
+ // safely in the past so the AVM's UpdateCheck resolves to the post-upgrade class id at any sim timestamp.
52
+ const svc = new ScheduledValueChange(/*previous=*/ [new Fr(0)], /*post=*/ [newClassId], /*timestampOfChange=*/ 1n);
53
+ const sdc = ScheduledDelayChange.empty();
54
+ const dpmv = new DelayedPublicMutableValuesWithHash(svc, sdc);
55
+
56
+ const { delayedPublicMutableSlot } = await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(instanceAddress);
57
+ const fields = await dpmv.toFields();
58
+
59
+ const publicStorage = fields.map((value, i) => ({
60
+ contract: ProtocolContractAddress.ContractInstanceRegistry,
61
+ slot: delayedPublicMutableSlot.add(new Fr(i)),
62
+ value,
63
+ }));
64
+
65
+ const upgradedInstance = { ...instance, currentContractClassId: newClassId };
66
+
67
+ return new SimulationOverrides({
68
+ publicStorage,
69
+ contracts: { [instanceAddress.toString()]: { instance: upgradedInstance } },
70
+ });
71
+ }
@@ -0,0 +1,301 @@
1
+ import type { Fr } from '@aztec-labs/foundation/curves/bn254';
2
+ import type { FieldsOf } from '@aztec-labs/foundation/types';
3
+ import type { AuthWitness } from '@aztec-labs/stdlib/auth-witness';
4
+ import { AztecAddress } from '@aztec-labs/stdlib/aztec-address';
5
+ import type { GasSettings, GasUsed, ManaUsageEstimate } from '@aztec-labs/stdlib/gas';
6
+ import {
7
+ type Capsule,
8
+ OFFCHAIN_MESSAGE_IDENTIFIER,
9
+ type OffchainEffect,
10
+ type SimulationOverrides,
11
+ type SimulationStats,
12
+ type TxHash,
13
+ type TxReceipt,
14
+ } from '@aztec-labs/stdlib/tx';
15
+
16
+ import type { FeePaymentMethod } from '../fee/fee_payment_method.js';
17
+ import type { ProfileOptions, SendOptions, SimulateOptions } from '../wallet/index.js';
18
+ import type { WaitOpts } from './wait_opts.js';
19
+
20
+ /**
21
+ * Interactions allow configuring a custom fee payment method that gets bundled with the transaction before
22
+ * sending it to the wallet
23
+ */
24
+ export type FeePaymentMethodOption = {
25
+ /** Fee payment method to embed in the interaction */
26
+ paymentMethod?: FeePaymentMethod;
27
+ };
28
+
29
+ /**
30
+ * User-defined partial gas settings for the interaction. This type is completely optional since
31
+ * the wallet will fill in the missing options
32
+ */
33
+ export type GasSettingsOption = {
34
+ /** The gas settings */
35
+ gasSettings?: Partial<FieldsOf<GasSettings>>;
36
+ /**
37
+ * Assumed network congestion level for fee prediction. Controls how aggressively the wallet
38
+ * estimates future fees: None assumes empty blocks, Target assumes steady-state usage,
39
+ * and Limit assumes blocks at maximum capacity. Higher estimates produce higher fee predictions,
40
+ * reducing the risk of underpriced transactions during congestion spikes.
41
+ * Defaults to Limit (worst case) when not specified.
42
+ */
43
+ congestionEstimate?: ManaUsageEstimate;
44
+ };
45
+
46
+ /** Fee options as set by a user. */
47
+ export type InteractionFeeOptions = GasSettingsOption & FeePaymentMethodOption;
48
+
49
+ /**
50
+ * Represents the options to configure a request from a contract interaction.
51
+ * Allows specifying additional auth witnesses and capsules to use during execution
52
+ */
53
+ export type RequestInteractionOptions = {
54
+ /** Extra authwits to use during execution */
55
+ authWitnesses?: AuthWitness[];
56
+ /** Extra capsules to use during execution */
57
+ capsules?: Capsule[];
58
+ /** Fee payment method to embed in the interaction request */
59
+ fee?: FeePaymentMethodOption;
60
+ };
61
+
62
+ /**
63
+ * Constant for explicitly not waiting for transaction confirmation.
64
+ * We use this instead of false to avoid confusion with falsy checks.
65
+ */
66
+ export const NO_WAIT = 'NO_WAIT' as const;
67
+
68
+ /**
69
+ * Type for the NO_WAIT constant.
70
+ */
71
+ export type NoWait = typeof NO_WAIT;
72
+
73
+ /**
74
+ * Constant for explicitly opting out of account contract mediation.
75
+ * When used as the `from` parameter, the wallet executes the payload directly
76
+ * via the DefaultEntrypoint without wrapping it in an account contract entrypoint.
77
+ * The app is responsible for assembling the complete execution payload, including
78
+ * any entrypoint wrapping (e.g. multicall) if needed. This will result in the
79
+ * first call of the chain receiving msg_sender as Option::none
80
+ */
81
+ export const NO_FROM = 'NO_FROM' as const;
82
+
83
+ /**
84
+ * Type for the NO_FROM constant.
85
+ */
86
+ export type NoFrom = typeof NO_FROM;
87
+
88
+ /**
89
+ * Type for wait options in interactions.
90
+ * - NO_WAIT symbol: Don't wait for confirmation, return TxHash immediately
91
+ * - WaitOpts object: Wait with custom options and return receipt/result
92
+ * - undefined: Wait with default options and return receipt/result
93
+ */
94
+ export type InteractionWaitOptions = NoWait | WaitOpts | undefined;
95
+
96
+ /**
97
+ * Base options for calling a (constrained) function in a contract, without wait parameter.
98
+ */
99
+ export type SendInteractionOptionsWithoutWait = RequestInteractionOptions & {
100
+ /** The sender's Aztec address, or NO_FROM to execute without account contract mediation. */
101
+ from: AztecAddress | NoFrom;
102
+ /** The fee options for the transaction. */
103
+ fee?: InteractionFeeOptions;
104
+ /**
105
+ * Additional addresses whose private state and keys should be accessible during execution,
106
+ * beyond the sender's. Required when the transaction needs to access private state or keys
107
+ * belonging to an address other than `from`, e.g. withdrawing from an escrow that holds
108
+ * its own private notes.
109
+ */
110
+ additionalScopes?: AztecAddress[];
111
+ /**
112
+ * Overrides the sender address used to derive discovery tags for private messages (notes, events, logs).
113
+ * Recipients use these tags to find messages addressed to them.
114
+ *
115
+ * Defaults to `from`. Typically set when `from === NO_FROM`, since there is no account address to derive tags from.
116
+ */
117
+ sendMessagesAs?: AztecAddress;
118
+ };
119
+
120
+ /**
121
+ * Represents options for calling a (constrained) function in a contract.
122
+ */
123
+ export type SendInteractionOptions<W extends InteractionWaitOptions = undefined> = SendInteractionOptionsWithoutWait & {
124
+ /**
125
+ * Whether to wait for the transaction to be mined.
126
+ * - undefined (default): wait with default options and return TxReceipt
127
+ * - WaitOpts object: wait with custom options and return TxReceipt
128
+ * - NO_WAIT: return txHash immediately without waiting
129
+ */
130
+ wait?: W;
131
+ };
132
+
133
+ /**
134
+ * Represents the options for simulating a contract function interaction.
135
+ * Allows specifying the address from which the method should be called.
136
+ * Disregarded for simulation of public functions
137
+ */
138
+ export type SimulateInteractionOptions = Omit<SendInteractionOptions, 'fee'> & {
139
+ /** The fee options for the transaction. */
140
+ fee?: InteractionFeeOptions;
141
+ /** Simulate without checking for the validity of the resulting transaction, e.g. whether it emits any existing nullifiers. */
142
+ skipTxValidation?: boolean;
143
+ /** Whether to ensure the fee payer is not empty and has enough balance to pay for the fee. */
144
+ skipFeeEnforcement?: boolean;
145
+ /** Whether to include metadata such as performance statistics (e.g. timing information of the different circuits and oracles) and simulated gas usage
146
+ * in the simulation result, in addition to the return value and offchain effects */
147
+ includeMetadata?: boolean;
148
+ /** Pre-simulation overrides applied to the ephemeral fork and contract DB (publicStorage writes, contract instance overrides). */
149
+ overrides?: SimulationOverrides;
150
+ };
151
+
152
+ /**
153
+ * Represents the options for profiling an interaction.
154
+ */
155
+ export type ProfileInteractionOptions = SimulateInteractionOptions & {
156
+ /** Whether to return gates information or the bytecode/witnesses. */
157
+ profileMode: 'gates' | 'execution-steps' | 'full';
158
+ /** Whether to generate a Chonk proof or not */
159
+ skipProofGeneration?: boolean;
160
+ };
161
+
162
+ /** A message emitted during execution or proving, to be delivered offchain. */
163
+ export type OffchainMessage = {
164
+ /** The intended recipient of the message. */
165
+ recipient: AztecAddress;
166
+ /** The message payload (typically encrypted). */
167
+ payload: Fr[];
168
+ /** The contract that emitted the message. */
169
+ contractAddress: AztecAddress;
170
+ /** Anchor block timestamp at message emission. */
171
+ anchorBlockTimestamp: bigint;
172
+ };
173
+
174
+ /** Groups all unproven outputs from private execution that are returned to the client. */
175
+ export type OffchainOutput = {
176
+ /** Raw offchain effects emitted during execution. */
177
+ offchainEffects: OffchainEffect[];
178
+ /** Messages emitted during execution, to be delivered offchain. */
179
+ offchainMessages: OffchainMessage[];
180
+ };
181
+
182
+ /**
183
+ * Splits an array of offchain effects into decoded offchain messages and remaining effects.
184
+ * Effects whose data starts with `OFFCHAIN_MESSAGE_IDENTIFIER` are parsed as messages and removed
185
+ * from the effects array.
186
+ */
187
+ export function extractOffchainOutput(effects: OffchainEffect[], anchorBlockTimestamp: bigint): OffchainOutput {
188
+ const offchainEffects: OffchainEffect[] = [];
189
+ const offchainMessages: OffchainMessage[] = [];
190
+
191
+ for (const effect of effects) {
192
+ if (effect.data.length >= 2 && effect.data[0].equals(OFFCHAIN_MESSAGE_IDENTIFIER)) {
193
+ offchainMessages.push({
194
+ recipient: AztecAddress.fromFieldUnsafe(effect.data[1]),
195
+ payload: effect.data.slice(2),
196
+ contractAddress: effect.contractAddress,
197
+ anchorBlockTimestamp,
198
+ });
199
+ } else {
200
+ offchainEffects.push(effect);
201
+ }
202
+ }
203
+
204
+ return { offchainEffects, offchainMessages };
205
+ }
206
+
207
+ /**
208
+ * Represents the result of a simulation.
209
+ * Always includes the return value and offchain output.
210
+ * When `includeMetadata` is set, also includes stats and the simulated gas usage.
211
+ */
212
+ export type SimulationResult = {
213
+ /** Return value of the function */
214
+ result: any;
215
+ /** Additional stats about the simulation. Present when `includeMetadata` is set. */
216
+ stats?: SimulationStats;
217
+ /**
218
+ * Raw gas consumed by the simulated transaction. Present when `includeMetadata` is set. Apps that want to
219
+ * declare explicit gas limits should derive their own from this (e.g. pad `totalGas`) and pass them via the
220
+ * fee options; otherwise the wallet fills in the network's per-tx admission limits automatically.
221
+ */
222
+ gasUsed?: GasUsed;
223
+ } & OffchainOutput;
224
+
225
+ /** Result of sendTx when not waiting for mining. */
226
+ export type TxSendResultImmediate = {
227
+ /** The hash of the sent transaction. */
228
+ txHash: TxHash;
229
+ } & OffchainOutput;
230
+
231
+ /** Result of sendTx when waiting for mining. */
232
+ export type TxSendResultMined<TReturn = TxReceipt> = {
233
+ /** The transaction receipt. */
234
+ receipt: TReturn;
235
+ } & OffchainOutput;
236
+
237
+ /**
238
+ * Represents the result type of sending a transaction.
239
+ * If `wait` is NO_WAIT, returns TxSendResultImmediate.
240
+ * Otherwise returns TxSendResultMined.
241
+ */
242
+ export type SendReturn<T extends InteractionWaitOptions, TReturn = TxReceipt> = T extends NoWait
243
+ ? TxSendResultImmediate
244
+ : TxSendResultMined<TReturn>;
245
+
246
+ /**
247
+ * Transforms and cleans up the higher level SendInteractionOptions defined by the interaction into
248
+ * SendOptions, which are the ones that can be serialized and forwarded to the wallet
249
+ * @param options - The send interaction options with optional wait parameter
250
+ * @returns The send options to forward to the wallet
251
+ */
252
+ export function toSendOptions<W extends InteractionWaitOptions = undefined>(
253
+ options: SendInteractionOptions<W>,
254
+ ): SendOptions<W> {
255
+ return {
256
+ ...options,
257
+ fee: {
258
+ // If a payment method that includes gas settings was used,
259
+ // try to reuse as much as possible while still allowing
260
+ // manual override. CAREFUL: this can cause mismatches during proving
261
+ gasSettings: {
262
+ ...options.fee?.paymentMethod?.getGasSettings(),
263
+ ...options.fee?.gasSettings,
264
+ },
265
+ congestionEstimate: options.fee?.congestionEstimate,
266
+ },
267
+ wait: options.wait, // Pass through wait option
268
+ };
269
+ }
270
+
271
+ /**
272
+ * Transforms and cleans up the higher level SimulateInteractionOptions defined by the interaction into
273
+ * SimulateOptions, which are the ones that can be serialized and forwarded to the wallet
274
+ */
275
+ export function toSimulateOptions(options: SimulateInteractionOptions): SimulateOptions {
276
+ return {
277
+ ...options,
278
+ fee: {
279
+ // If a payment method that includes gas settings was used,
280
+ // try to reuse as much as possible while still allowing
281
+ // manual override. CAREFUL: this can cause mismatches during proving
282
+ gasSettings: {
283
+ ...options.fee?.paymentMethod?.getGasSettings(),
284
+ ...options.fee?.gasSettings,
285
+ },
286
+ congestionEstimate: options.fee?.congestionEstimate,
287
+ },
288
+ };
289
+ }
290
+
291
+ /**
292
+ * Transforms and cleans up the higher level ProfileInteractionOptions defined by the interaction into
293
+ * ProfileOptions, which are the ones that can be serialized and forwarded to the wallet
294
+ */
295
+ export function toProfileOptions(options: ProfileInteractionOptions): ProfileOptions {
296
+ return {
297
+ ...toSimulateOptions(options),
298
+ profileMode: options.profileMode,
299
+ skipProofGeneration: options.skipProofGeneration,
300
+ };
301
+ }
@@ -0,0 +1,104 @@
1
+ /* Autogenerated file, do not edit! */
2
+ /* eslint-disable */
3
+ import { ProtocolContractAddress } from '@aztec-labs/protocol-contracts';
4
+ import { FunctionType } from '@aztec-labs/stdlib/abi';
5
+
6
+ import type { ContractArtifact } from '../../api/abi.js';
7
+ import { PublicKeys } from '../../api/keys.js';
8
+ import type {
9
+ AztecAddressLike,
10
+ EthAddressLike,
11
+ FieldLike,
12
+ FunctionSelectorLike,
13
+ OptionLike,
14
+ WrappedFieldLike,
15
+ } from '../../utils/abi_types.js';
16
+ import type { Wallet } from '../../wallet/wallet.js';
17
+ import { ContractBase, type ContractMethod } from '../contract_base.js';
18
+ import { ContractFunctionInteraction } from '../contract_function_interaction.js';
19
+
20
+ const ContractClassRegistryContractArtifact: ContractArtifact = {
21
+ name: 'ContractClassRegistry',
22
+ aztecVersion: '6.0.0-nightly.20260826',
23
+ functions: [
24
+ {
25
+ ...{
26
+ functionType: FunctionType.PRIVATE,
27
+ name: 'publish',
28
+ isOnlySelf: false,
29
+ isStatic: false,
30
+ isInitializer: false,
31
+ parameters: [
32
+ { name: 'artifact_hash', type: { kind: 'field' }, visibility: 'private' },
33
+ { name: 'private_functions_root', type: { kind: 'field' }, visibility: 'private' },
34
+ { name: 'public_bytecode_commitment', type: { kind: 'field' }, visibility: 'private' },
35
+ ],
36
+ errorTypes: {
37
+ '10965409165809799877': {
38
+ error_kind: 'string',
39
+ string: 'Given in_len to absorb is larger than the input array len',
40
+ },
41
+ '12469291177396340830': { error_kind: 'string', string: 'call to assert_max_bit_size' },
42
+ '14990209321349310352': { error_kind: 'string', string: 'attempt to add with overflow' },
43
+ '15669273164684982983': { error_kind: 'string', string: 'num_permutations is greater than MAX_PERMUTATIONS' },
44
+ '15835548349546956319': { error_kind: 'string', string: 'Field failed to decompose into specified 32 limbs' },
45
+ '16431471497789672479': { error_kind: 'string', string: 'Index out of bounds' },
46
+ '16450579948625159707': { error_kind: 'string', string: 'Sponge must be in cache_size=1' },
47
+ '17655676068928457687': { error_kind: 'string', string: 'Reader did not read all data' },
48
+ '1998584279744703196': { error_kind: 'string', string: 'attempt to subtract with overflow' },
49
+ '361444214588792908': { error_kind: 'string', string: 'attempt to multiply with overflow' },
50
+ '922421554006670918': { error_kind: 'string', string: 'num_items is greater than MAX_ITEMS' },
51
+ '9475115977882098926': { error_kind: 'string', string: 'Extra bytes in the last field of the bytecode' },
52
+ },
53
+ },
54
+ bytecode: Buffer.from([]),
55
+ debugSymbols: '',
56
+ },
57
+ {
58
+ ...{
59
+ functionType: FunctionType.PUBLIC,
60
+ name: 'public_dispatch',
61
+ isOnlySelf: false,
62
+ isStatic: false,
63
+ isInitializer: false,
64
+ parameters: [{ name: 'selector', type: { kind: 'field' }, visibility: 'private' }],
65
+ errorTypes: { '1335198680857977525': { error_kind: 'string', string: 'No public functions' } },
66
+ },
67
+ bytecode: Buffer.from([]),
68
+ debugSymbols: '',
69
+ },
70
+ ],
71
+ nonDispatchPublicFunctions: [],
72
+ outputs: { structs: {}, globals: {} },
73
+ storageLayout: {},
74
+ fileMap: {},
75
+ };
76
+
77
+ export class ContractClassRegistryContract extends ContractBase {
78
+ private constructor(wallet: Wallet) {
79
+ super(ProtocolContractAddress.ContractClassRegistry, ContractClassRegistryContractArtifact, wallet);
80
+ }
81
+
82
+ /** Returns an interface to the canonical ContractClassRegistryContract instance, bound to the given wallet. */
83
+ public static withWallet(wallet: Wallet): ContractClassRegistryContract {
84
+ return new ContractClassRegistryContract(wallet);
85
+ }
86
+
87
+ /** @deprecated Use `withWallet` instead. */
88
+ public static at(wallet: Wallet): ContractClassRegistryContract {
89
+ return ContractClassRegistryContract.withWallet(wallet);
90
+ }
91
+
92
+ declare public methods: {
93
+ /** public_dispatch(selector: field) */
94
+ public_dispatch: ((selector: FieldLike) => ContractFunctionInteraction) & Pick<ContractMethod, 'selector'>;
95
+
96
+ /** publish(artifact_hash: field, private_functions_root: field, public_bytecode_commitment: field) */
97
+ publish: ((
98
+ artifact_hash: FieldLike,
99
+ private_functions_root: FieldLike,
100
+ public_bytecode_commitment: FieldLike,
101
+ ) => ContractFunctionInteraction) &
102
+ Pick<ContractMethod, 'selector'>;
103
+ };
104
+ }