@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,127 @@
1
+ import { DefaultMultiCallEntrypoint } from '@aztec-labs/entrypoints/multicall';
2
+ import { mergeExecutionPayloads } from '@aztec-labs/stdlib/tx';
3
+ import { UniversalDeployMethod } from '../contract/deploy_method.js';
4
+ import { NO_FROM } from '../contract/interaction_options.js';
5
+ import { AccountEntrypointMetaPaymentMethod } from './account_entrypoint_meta_payment_method.js';
6
+ /**
7
+ * Modified version of the DeployMethod used to deploy account contracts. Supports deploying
8
+ * contracts that can pay for their own fee, plus some preconfigured options to avoid errors.
9
+ */ export class DeployAccountMethod extends UniversalDeployMethod {
10
+ account;
11
+ constructor(publicKeys, wallet, artifact, postDeployCtor, salt, immutablesHash, account, args = [], constructorNameOrArtifact, authWitnesses = [], capsules = [], extraHashedArgs = []){
12
+ super(wallet, {
13
+ artifact,
14
+ postDeployCtor,
15
+ args,
16
+ constructorNameOrArtifact
17
+ }, // Account contracts are always deployed universally.
18
+ {
19
+ salt,
20
+ universalDeploy: true,
21
+ publicKeys,
22
+ immutablesHash
23
+ }, {
24
+ authWitnesses,
25
+ capsules,
26
+ extraHashedArgs
27
+ }), this.account = account;
28
+ }
29
+ /**
30
+ * Returns a FeePaymentMethod that routes the original one provided as an argument
31
+ * through the account's entrypoint. This allows an account contract to pay
32
+ * for its own deployment and initialization.
33
+ *
34
+ * For more details on how the fee payment routing works see documentation of AccountEntrypointMetaPaymentMethod class.
35
+ *
36
+ * @param originalPaymentMethod - originalPaymentMethod The original payment method to be wrapped.
37
+ * @param feeEntrypointOptions - Optional entrypoint-specific options for wrapping. If not provided, will be auto-computed based on the payment method.
38
+ * @returns A FeePaymentMethod that routes the original one through the account's entrypoint (AccountEntrypointMetaPaymentMethod)
39
+ */ async getSelfFeePaymentMethod(originalPaymentMethod, feeEntrypointOptions) {
40
+ const chainInfo = await this.wallet.getChainInfo();
41
+ return new AccountEntrypointMetaPaymentMethod(this.account, chainInfo, originalPaymentMethod, feeEntrypointOptions);
42
+ }
43
+ /**
44
+ * Returns the execution payload that allows this operation to happen on chain.
45
+ * For self-deployments (from === NO_FROM), the payload is wrapped through the
46
+ * multicall entrypoint on the app side so the wallet can execute it directly.
47
+ * @param opts - Configuration options.
48
+ * @returns The execution payload for this operation
49
+ */ async request(opts) {
50
+ const optionsWithDefaults = {
51
+ ...opts,
52
+ skipClassPublication: opts?.skipClassPublication ?? true,
53
+ skipInstancePublication: opts?.skipInstancePublication ?? true,
54
+ skipInitialization: opts?.skipInitialization ?? false
55
+ };
56
+ // Override the fee to undefined, since we'll replace it
57
+ const deploymentExecutionPayload = await super.request({
58
+ ...optionsWithDefaults,
59
+ fee: undefined
60
+ });
61
+ const executionPayloads = [
62
+ deploymentExecutionPayload
63
+ ];
64
+ // If this is a self-paid deployment (the to-be-deployed account pays for its own deploy),
65
+ // wrap the payload through the multicall entrypoint after attaching the fee.
66
+ if (opts?.from === NO_FROM) {
67
+ const feePaymentMethod = await this.getSelfFeePaymentMethod(opts?.fee?.paymentMethod, opts?.fee?.feeEntrypointOptions);
68
+ const feeExecutionPayload = await feePaymentMethod.getExecutionPayload();
69
+ // Notice they are reversed (fee payment usually goes first):
70
+ // this is because we need to construct the contract BEFORE it can pay for its own fee
71
+ executionPayloads.push(feeExecutionPayload);
72
+ // Wrap the merged payload through the multicall entrypoint,
73
+ // producing a single-call payload that DefaultEntrypoint can execute directly.
74
+ const multicall = new DefaultMultiCallEntrypoint();
75
+ const chainInfo = await this.wallet.getChainInfo();
76
+ return multicall.wrapExecutionPayload(mergeExecutionPayloads(executionPayloads), chainInfo);
77
+ } else {
78
+ const feeExecutionPayload = opts?.fee?.paymentMethod ? await opts.fee.paymentMethod.getExecutionPayload() : undefined;
79
+ if (feeExecutionPayload) {
80
+ executionPayloads.unshift(feeExecutionPayload);
81
+ }
82
+ return mergeExecutionPayloads(executionPayloads);
83
+ }
84
+ }
85
+ convertDeployOptionsToSendOptions(options) {
86
+ return super.convertDeployOptionsToSendOptions(this.prepareDeployOptions(options));
87
+ }
88
+ convertDeployOptionsToSimulateOptions(options) {
89
+ return super.convertDeployOptionsToSimulateOptions(this.prepareDeployOptions(options));
90
+ }
91
+ convertDeployOptionsToProfileOptions(options) {
92
+ return super.convertDeployOptionsToProfileOptions(this.prepareDeployOptions(options));
93
+ }
94
+ /**
95
+ * Augments deploy options so that the PXE has the context it needs to simulate/prove the deploy.
96
+ *
97
+ * - Injects the contract's own address into scopes so the constructor can access its own keys.
98
+ * - When `from === NO_FROM` (self-paid deploy), supplies the to-be-deployed address as `sendMessagesAs`. Without
99
+ * this, fee-payment calls would have no sender for message tagging, and any private log they emit would fail
100
+ * the "Sender for tags is not set" assertion.
101
+ *
102
+ * Note: this reads the cached instance synchronously via `getCachedInstance()`. Because every code path that
103
+ * calls `prepareDeployOptions` (send/simulate/profile) flows through `request()` first, which calls
104
+ * `getInstance()`, the cache is always populated by the time we get here.
105
+ *
106
+ * @param options - The deploy options to augment.
107
+ */ prepareDeployOptions(options) {
108
+ const { address } = this.getCachedInstanceOrThrow();
109
+ const existing = options.additionalScopes ?? [];
110
+ const sendMessagesAs = options.sendMessagesAs ?? (options.from === NO_FROM ? address : undefined);
111
+ return {
112
+ ...options,
113
+ additionalScopes: [
114
+ ...existing,
115
+ address
116
+ ],
117
+ sendMessagesAs
118
+ };
119
+ }
120
+ /**
121
+ * Augments this DeployAccountMethod with additional metadata, such as authWitnesses and capsules.
122
+ * @param options - An object containing the metadata to add to the interaction
123
+ * @returns A new DeployAccountMethod with the added metadata
124
+ */ with({ authWitnesses = [], capsules = [], extraHashedArgs = [] }) {
125
+ return new DeployAccountMethod(this.publicKeys, this.wallet, this.artifact, this.postDeployCtor, this.salt, this.immutablesHash, this.account, this.args, this.constructorArtifact?.name, this.authWitnesses.concat(authWitnesses), this.capsules.concat(capsules), this.extraHashedArgs.concat(extraHashedArgs));
126
+ }
127
+ }
@@ -0,0 +1,5 @@
1
+ export * from './wallet.js';
2
+ export * from './account_manager.js';
3
+ export * from './capabilities.js';
4
+ export * from './tx_simulation_result_with_app_offset.js';
5
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy93YWxsZXQvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyxhQUFhLENBQUM7QUFDNUIsY0FBYyxzQkFBc0IsQ0FBQztBQUNyQyxjQUFjLG1CQUFtQixDQUFDO0FBQ2xDLGNBQWMsMkNBQTJDLENBQUMifQ==
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/wallet/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,2CAA2C,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './wallet.js';
2
+ export * from './account_manager.js';
3
+ export * from './capabilities.js';
4
+ export * from './tx_simulation_result_with_app_offset.js';
@@ -0,0 +1,40 @@
1
+ import type { ZodFor } from '@aztec-labs/foundation/schemas';
2
+ import { PrivateKernelTailCircuitPublicInputs } from '@aztec-labs/stdlib/kernel';
3
+ import { type NestedProcessReturnValues, PrivateExecutionResult, PublicSimulationOutput, type SimulationStats, TxSimulationResult } from '@aztec-labs/stdlib/tx';
4
+ /**
5
+ * Extends TxSimulationResult with the app call offset, which tracks where the app's calls begin in the flattened
6
+ * array of calls. Tracking of app call offset is a wallet-level concern: the wallet may wrap the app payload in an
7
+ * entrypoint or may prepend calls (this is typically done for fee payments).
8
+ */
9
+ export declare class TxSimulationResultWithAppOffset extends TxSimulationResult {
10
+ /**
11
+ * Index of the app's first call in a flattened array of calls.
12
+ * 0 = app call is the root execution itself (DefaultEntrypoint / NO_FROM).
13
+ * 1..N = wallet prepended calls before the app call.
14
+ * undefined = wallet did not send the field; use heuristic fallback.
15
+ */
16
+ readonly appCallOffset: number | undefined;
17
+ constructor(privateExecutionResult: PrivateExecutionResult, publicInputs: PrivateKernelTailCircuitPublicInputs, publicOutput?: PublicSimulationOutput, stats?: SimulationStats,
18
+ /**
19
+ * Index of the app's first call in a flattened array of calls.
20
+ * 0 = app call is the root execution itself (DefaultEntrypoint / NO_FROM).
21
+ * 1..N = wallet prepended calls before the app call.
22
+ * undefined = wallet did not send the field; use heuristic fallback.
23
+ */
24
+ appCallOffset?: number | undefined);
25
+ /**
26
+ * Returns the private return values that correspond to the provided app call.
27
+ * @param appCallIndex - Index of the app call within the app calls.
28
+ */
29
+ getPrivateReturnValuesOfAppCall(appCallIndex?: number): NestedProcessReturnValues | undefined;
30
+ /**
31
+ * Creates a TxSimulationResultWithAppOffset from an existing TxSimulationResult, attaching the app call offset
32
+ * computed by the wallet (i.e. how many calls precede the first app call in the flattened execution tree).
33
+ * @param result - The simulation result to wrap.
34
+ * @param appCallOffset - The index of the app's first call in the flattened execution tree.
35
+ */
36
+ static fromResultAndOffset(result: TxSimulationResult, appCallOffset: number): TxSimulationResultWithAppOffset;
37
+ static random(): Promise<TxSimulationResultWithAppOffset>;
38
+ static get schema(): ZodFor<TxSimulationResultWithAppOffset>;
39
+ }
40
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhfc2ltdWxhdGlvbl9yZXN1bHRfd2l0aF9hcHBfb2Zmc2V0LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvd2FsbGV0L3R4X3NpbXVsYXRpb25fcmVzdWx0X3dpdGhfYXBwX29mZnNldC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUU3RCxPQUFPLEVBQUUsb0NBQW9DLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUNqRixPQUFPLEVBQ0wsS0FBSyx5QkFBeUIsRUFDOUIsc0JBQXNCLEVBQ3RCLHNCQUFzQixFQUN0QixLQUFLLGVBQWUsRUFFcEIsa0JBQWtCLEVBQ25CLE1BQU0sdUJBQXVCLENBQUM7QUFHL0I7Ozs7R0FJRztBQUNILHFCQUFhLCtCQUFnQyxTQUFRLGtCQUFrQjtJQU1uRTs7Ozs7T0FLRzthQUNhLGFBQWEsRUFBRSxNQUFNLEdBQUcsU0FBUztJQVhuRCxZQUNFLHNCQUFzQixFQUFFLHNCQUFzQixFQUM5QyxZQUFZLEVBQUUsb0NBQW9DLEVBQ2xELFlBQVksQ0FBQyxFQUFFLHNCQUFzQixFQUNyQyxLQUFLLENBQUMsRUFBRSxlQUFlO0lBQ3ZCOzs7OztPQUtHO0lBQ2EsYUFBYSxHQUFFLE1BQU0sR0FBRyxTQUFxQixFQUc5RDtJQUVEOzs7T0FHRztJQUNILCtCQUErQixDQUFDLFlBQVksR0FBRSxNQUFVLEdBQUcseUJBQXlCLEdBQUcsU0FBUyxDQXVCL0Y7SUFFRDs7Ozs7T0FLRztJQUNILE1BQU0sQ0FBQyxtQkFBbUIsQ0FBQyxNQUFNLEVBQUUsa0JBQWtCLEVBQUUsYUFBYSxFQUFFLE1BQU0sR0FBRywrQkFBK0IsQ0FRN0c7SUFFRCxPQUFzQixNQUFNLDZDQUczQjtJQUVELFdBQW9CLE1BQU0sSUFBSSxNQUFNLENBQUMsK0JBQStCLENBQUMsQ0FhcEU7Q0FDRiJ9
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tx_simulation_result_with_app_offset.d.ts","sourceRoot":"","sources":["../../src/wallet/tx_simulation_result_with_app_offset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAE7D,OAAO,EAAE,oCAAoC,EAAE,MAAM,2BAA2B,CAAC;AACjF,OAAO,EACL,KAAK,yBAAyB,EAC9B,sBAAsB,EACtB,sBAAsB,EACtB,KAAK,eAAe,EAEpB,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAG/B;;;;GAIG;AACH,qBAAa,+BAAgC,SAAQ,kBAAkB;IAMnE;;;;;OAKG;aACa,aAAa,EAAE,MAAM,GAAG,SAAS;IAXnD,YACE,sBAAsB,EAAE,sBAAsB,EAC9C,YAAY,EAAE,oCAAoC,EAClD,YAAY,CAAC,EAAE,sBAAsB,EACrC,KAAK,CAAC,EAAE,eAAe;IACvB;;;;;OAKG;IACa,aAAa,GAAE,MAAM,GAAG,SAAqB,EAG9D;IAED;;;OAGG;IACH,+BAA+B,CAAC,YAAY,GAAE,MAAU,GAAG,yBAAyB,GAAG,SAAS,CAuB/F;IAED;;;;;OAKG;IACH,MAAM,CAAC,mBAAmB,CAAC,MAAM,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,GAAG,+BAA+B,CAQ7G;IAED,OAAsB,MAAM,6CAG3B;IAED,WAAoB,MAAM,IAAI,MAAM,CAAC,+BAA+B,CAAC,CAapE;CACF"}
@@ -0,0 +1,65 @@
1
+ import { optional } from '@aztec-labs/foundation/schemas';
2
+ import { PrivateKernelTailCircuitPublicInputs } from '@aztec-labs/stdlib/kernel';
3
+ import { PrivateExecutionResult, PublicSimulationOutput, SimulationStatsSchema, TxSimulationResult } from '@aztec-labs/stdlib/tx';
4
+ import { z } from 'zod';
5
+ /**
6
+ * Extends TxSimulationResult with the app call offset, which tracks where the app's calls begin in the flattened
7
+ * array of calls. Tracking of app call offset is a wallet-level concern: the wallet may wrap the app payload in an
8
+ * entrypoint or may prepend calls (this is typically done for fee payments).
9
+ */ export class TxSimulationResultWithAppOffset extends TxSimulationResult {
10
+ appCallOffset;
11
+ constructor(privateExecutionResult, publicInputs, publicOutput, stats, /**
12
+ * Index of the app's first call in a flattened array of calls.
13
+ * 0 = app call is the root execution itself (DefaultEntrypoint / NO_FROM).
14
+ * 1..N = wallet prepended calls before the app call.
15
+ * undefined = wallet did not send the field; use heuristic fallback.
16
+ */ appCallOffset = undefined){
17
+ super(privateExecutionResult, publicInputs, publicOutput, stats), this.appCallOffset = appCallOffset;
18
+ }
19
+ /**
20
+ * Returns the private return values that correspond to the provided app call.
21
+ * @param appCallIndex - Index of the app call within the app calls.
22
+ */ getPrivateReturnValuesOfAppCall(appCallIndex = 0) {
23
+ const all = this.getPrivateReturnValues();
24
+ if (this.appCallOffset === undefined) {
25
+ // appCallOffset was not sent. Apply the pre-offset heuristic for backwards compatibility.
26
+ // If there are nested calls, the app was wrapped in an account contract entrypoint and its return values
27
+ // live in nested[appCallIndex]. Otherwise the app call is the root execution.
28
+ if ((all?.nested?.length ?? 0) > 0) {
29
+ return all?.nested?.[appCallIndex];
30
+ }
31
+ if (appCallIndex !== 0) {
32
+ throw new Error('App call index cannot be defined when there is single root app call');
33
+ }
34
+ return all;
35
+ }
36
+ // appCallOffset is defined on the flattened array of calls where entrypoint occupies index 0 and the app's
37
+ // first call occupies index appCallOffset. appCallIndex 0 with appCallOffset 0 means the root itself.
38
+ if (this.appCallOffset === 0 && appCallIndex === 0) {
39
+ return all;
40
+ }
41
+ // For all other cases, index into nested: subtract 1 because nested[0] corresponds to flat index 1 (first nested).
42
+ return all?.nested?.[appCallIndex + this.appCallOffset - 1];
43
+ }
44
+ /**
45
+ * Creates a TxSimulationResultWithAppOffset from an existing TxSimulationResult, attaching the app call offset
46
+ * computed by the wallet (i.e. how many calls precede the first app call in the flattened execution tree).
47
+ * @param result - The simulation result to wrap.
48
+ * @param appCallOffset - The index of the app's first call in the flattened execution tree.
49
+ */ static fromResultAndOffset(result, appCallOffset) {
50
+ return new TxSimulationResultWithAppOffset(result.privateExecutionResult, result.publicInputs, result.publicOutput, result.stats, appCallOffset);
51
+ }
52
+ static async random() {
53
+ const base = await TxSimulationResult.random();
54
+ return TxSimulationResultWithAppOffset.fromResultAndOffset(base, 0);
55
+ }
56
+ static get schema() {
57
+ return z.object({
58
+ privateExecutionResult: PrivateExecutionResult.schema,
59
+ publicInputs: PrivateKernelTailCircuitPublicInputs.schema,
60
+ publicOutput: PublicSimulationOutput.schema.optional(),
61
+ stats: optional(SimulationStatsSchema),
62
+ appCallOffset: optional(z.number())
63
+ }).transform(({ privateExecutionResult, publicInputs, publicOutput, stats, appCallOffset })=>new TxSimulationResultWithAppOffset(privateExecutionResult, publicInputs, publicOutput, stats, appCallOffset));
64
+ }
65
+ }