@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,185 @@
1
+ import { MEGA_APP_VK_LENGTH_IN_FIELDS } from '@aztec-labs/constants';
2
+ import { Fr } from '@aztec-labs/foundation/curves/bn254';
3
+ import { FunctionType } from '@aztec-labs/stdlib/abi';
4
+ import { DEV_VERSION } from '@aztec-labs/stdlib/update-checker';
5
+ /**
6
+ * A minimal but representative `ContractArtifact` shared by unit tests in this package. Covers
7
+ * every function shape the tests exercise: a private initializer (`constructor`), the standard
8
+ * `public_dispatch` entry, a private function with mixed-visibility params (`bar`), a utility
9
+ * function (`qux`), and two functions exercising Noir `Option<Field>` parameters (`optionEcho`,
10
+ * `mixedParams`).
11
+ *
12
+ * We deliberately do not depend on `@aztec-labs/noir-test-contracts.js` here: that package depends on
13
+ * `@aztec-labs/aztec.js`, so importing from it would create a workspace cycle.
14
+ */ export const testContractArtifact = {
15
+ name: 'TestContract',
16
+ aztecVersion: DEV_VERSION,
17
+ functions: [
18
+ {
19
+ name: 'constructor',
20
+ isInitializer: true,
21
+ functionType: FunctionType.PRIVATE,
22
+ isOnlySelf: false,
23
+ isStatic: false,
24
+ debugSymbols: '',
25
+ parameters: [],
26
+ errorTypes: {},
27
+ bytecode: Buffer.alloc(8, 0xfa),
28
+ verificationKey: Buffer.alloc(MEGA_APP_VK_LENGTH_IN_FIELDS * Fr.SIZE_IN_BYTES).toString('base64')
29
+ },
30
+ {
31
+ name: 'public_dispatch',
32
+ isInitializer: false,
33
+ isStatic: false,
34
+ functionType: FunctionType.PUBLIC,
35
+ isOnlySelf: false,
36
+ parameters: [
37
+ {
38
+ name: 'selector',
39
+ type: {
40
+ kind: 'field'
41
+ },
42
+ visibility: 'public'
43
+ }
44
+ ],
45
+ errorTypes: {},
46
+ bytecode: Buffer.alloc(8, 0xfb),
47
+ debugSymbols: ''
48
+ },
49
+ {
50
+ name: 'bar',
51
+ isInitializer: false,
52
+ functionType: FunctionType.PRIVATE,
53
+ isOnlySelf: false,
54
+ isStatic: false,
55
+ debugSymbols: '',
56
+ parameters: [
57
+ {
58
+ name: 'value',
59
+ type: {
60
+ kind: 'field'
61
+ },
62
+ visibility: 'public'
63
+ },
64
+ {
65
+ name: 'value',
66
+ type: {
67
+ kind: 'field'
68
+ },
69
+ visibility: 'private'
70
+ }
71
+ ],
72
+ errorTypes: {},
73
+ bytecode: Buffer.alloc(8, 0xfa),
74
+ verificationKey: Buffer.alloc(MEGA_APP_VK_LENGTH_IN_FIELDS * Fr.SIZE_IN_BYTES).toString('base64')
75
+ },
76
+ {
77
+ name: 'qux',
78
+ isInitializer: false,
79
+ isStatic: false,
80
+ functionType: FunctionType.UTILITY,
81
+ isOnlySelf: false,
82
+ parameters: [
83
+ {
84
+ name: 'value',
85
+ type: {
86
+ kind: 'field'
87
+ },
88
+ visibility: 'public'
89
+ }
90
+ ],
91
+ returnType: {
92
+ kind: 'integer',
93
+ sign: 'unsigned',
94
+ width: 32
95
+ },
96
+ bytecode: Buffer.alloc(8, 0xfc),
97
+ debugSymbols: '',
98
+ errorTypes: {}
99
+ },
100
+ {
101
+ name: 'optionEcho',
102
+ isInitializer: false,
103
+ functionType: FunctionType.PRIVATE,
104
+ isOnlySelf: false,
105
+ isStatic: false,
106
+ parameters: [
107
+ {
108
+ name: 'value',
109
+ type: {
110
+ kind: 'struct',
111
+ path: 'std::option::Option',
112
+ fields: [
113
+ {
114
+ name: '_is_some',
115
+ type: {
116
+ kind: 'boolean'
117
+ }
118
+ },
119
+ {
120
+ name: '_value',
121
+ type: {
122
+ kind: 'field'
123
+ }
124
+ }
125
+ ]
126
+ },
127
+ visibility: 'private'
128
+ }
129
+ ],
130
+ errorTypes: {},
131
+ bytecode: Buffer.alloc(8, 0xfd),
132
+ verificationKey: Buffer.alloc(MEGA_APP_VK_LENGTH_IN_FIELDS * Fr.SIZE_IN_BYTES).toString('base64'),
133
+ debugSymbols: ''
134
+ },
135
+ {
136
+ name: 'mixedParams',
137
+ isInitializer: false,
138
+ functionType: FunctionType.PRIVATE,
139
+ isOnlySelf: false,
140
+ isStatic: false,
141
+ parameters: [
142
+ {
143
+ name: 'optValue',
144
+ type: {
145
+ kind: 'struct',
146
+ path: 'std::option::Option',
147
+ fields: [
148
+ {
149
+ name: '_is_some',
150
+ type: {
151
+ kind: 'boolean'
152
+ }
153
+ },
154
+ {
155
+ name: '_value',
156
+ type: {
157
+ kind: 'field'
158
+ }
159
+ }
160
+ ]
161
+ },
162
+ visibility: 'private'
163
+ },
164
+ {
165
+ name: 'aField',
166
+ type: {
167
+ kind: 'field'
168
+ },
169
+ visibility: 'private'
170
+ }
171
+ ],
172
+ errorTypes: {},
173
+ bytecode: Buffer.alloc(8, 0xfe),
174
+ verificationKey: Buffer.alloc(MEGA_APP_VK_LENGTH_IN_FIELDS * Fr.SIZE_IN_BYTES).toString('base64'),
175
+ debugSymbols: ''
176
+ }
177
+ ],
178
+ nonDispatchPublicFunctions: [],
179
+ outputs: {
180
+ structs: {},
181
+ globals: {}
182
+ },
183
+ fileMap: {},
184
+ storageLayout: {}
185
+ };
@@ -0,0 +1,32 @@
1
+ import type { Fr } from '@aztec-labs/foundation/curves/bn254';
2
+ import type { EthAddress } from '@aztec-labs/foundation/eth-address';
3
+ import type { EventSelector, FunctionSelector } from '@aztec-labs/stdlib/abi';
4
+ import type { AztecAddress } from '@aztec-labs/stdlib/aztec-address';
5
+ /** Any type that can be converted into a field for a contract call. */
6
+ export type FieldLike = Fr | Buffer | bigint | number | {
7
+ toField: () => Fr;
8
+ };
9
+ /** Any type that can be converted into an EthAddress Aztec.nr struct. */
10
+ export type EthAddressLike = {
11
+ address: FieldLike;
12
+ } | EthAddress;
13
+ /** Any type that can be converted into an AztecAddress Aztec.nr struct. */
14
+ export type AztecAddressLike = {
15
+ address: FieldLike;
16
+ } | AztecAddress;
17
+ /** Any type that can be converted into a FunctionSelector Aztec.nr struct. */
18
+ export type FunctionSelectorLike = FieldLike | FunctionSelector;
19
+ /** Any type that can be converted into an EventSelector Aztec.nr struct. */
20
+ export type EventSelectorLike = FieldLike | EventSelector;
21
+ /** Any type that can be converted into a U128. */
22
+ export type U128Like = bigint | number;
23
+ /** Any type that can be converted into a struct with a single `inner` field. */
24
+ export type WrappedFieldLike = {
25
+ inner: FieldLike;
26
+ } | FieldLike;
27
+ /** Noir `Option<T>` lowered ABI shape, plus ergonomic direct `T | null | undefined` inputs. */
28
+ export type OptionLike<T> = T | null | undefined | {
29
+ _is_some: boolean; /** Wrapped value */
30
+ _value: T;
31
+ };
32
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWJpX3R5cGVzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbHMvYWJpX3R5cGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLEVBQUUsRUFBRSxNQUFNLHFDQUFxQyxDQUFDO0FBQzlELE9BQU8sS0FBSyxFQUFFLFVBQVUsRUFBRSxNQUFNLG9DQUFvQyxDQUFDO0FBQ3JFLE9BQU8sS0FBSyxFQUFFLGFBQWEsRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBQzlFLE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLGtDQUFrQyxDQUFDO0FBRXJFLHVFQUF1RTtBQUN2RSxNQUFNLE1BQU0sU0FBUyxHQUFHLEVBQUUsR0FBRyxNQUFNLEdBQUcsTUFBTSxHQUFHLE1BQU0sR0FBRztJQUEyQixPQUFPLEVBQUUsTUFBTSxFQUFFLENBQUE7Q0FBRSxDQUFDO0FBRXZHLHlFQUF5RTtBQUN6RSxNQUFNLE1BQU0sY0FBYyxHQUFHO0lBQXlCLE9BQU8sRUFBRSxTQUFTLENBQUE7Q0FBRSxHQUFHLFVBQVUsQ0FBQztBQUV4RiwyRUFBMkU7QUFDM0UsTUFBTSxNQUFNLGdCQUFnQixHQUFHO0lBQXlCLE9BQU8sRUFBRSxTQUFTL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AM,cAAc,GAAG;IAAyB,OAAO,EAAE,SAAS,CAAA;CAAE,GAAG,UAAU,CAAC;AAExF,2EAA2E;AAC3E,MAAM,MAAM,gBAAgB,GAAG;IAAyB,OAAO,EAAE,SAAS,CAAA;CAAE,GAAG,YAAY,CAAC;AAE5F,8EAA8E;AAC9E,MAAM,MAAM,oBAAoB,GAAG,SAAS,GAAG,gBAAgB,CAAC;AAEhE,4EAA4E;AAC5E,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,aAAa,CAAC;AAE1D,kDAAkD;AAClD,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAEvC,gFAAgF;AAChF,MAAM,MAAM,gBAAgB,GAAG;IAAuB,KAAK,EAAE,SAAS,CAAA;CAAE,GAAG,SAAS,CAAC;AAErF,+FAA+F;AAC/F,MAAM,MAAM,UAAU,CAAC,CAAC,IACpB,CAAC,GACD,IAAI,GACJ,SAAS,GACT;IAAyC,QAAQ,EAAE,OAAO,CAAC,CAAC,oBAAoB;IAAC,MAAM,EAAE,CAAC,CAAA;CAAE,CAAC"}
@@ -0,0 +1 @@
1
+ /** Noir `Option<T>` lowered ABI shape, plus ergonomic direct `T | null | undefined` inputs. */ export { };
@@ -0,0 +1,119 @@
1
+ import type { ChainInfo } from '@aztec-labs/entrypoints/interfaces';
2
+ import { Fr } from '@aztec-labs/foundation/curves/bn254';
3
+ import { type FunctionCall } from '@aztec-labs/stdlib/abi';
4
+ import { AuthWitness } from '@aztec-labs/stdlib/auth-witness';
5
+ import type { AztecAddress } from '@aztec-labs/stdlib/aztec-address';
6
+ import type { TxProfileResult } from '@aztec-labs/stdlib/tx';
7
+ import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
8
+ import type { InteractionWaitOptions, ProfileInteractionOptions, SendInteractionOptions, SendInteractionOptionsWithoutWait, SendReturn, SimulateInteractionOptions, SimulationResult, TxSendResultMined } from '../contract/interaction_options.js';
9
+ import type { Wallet } from '../wallet/index.js';
10
+ /** Intent with an inner hash */
11
+ export type IntentInnerHash = {
12
+ /** The consumer */
13
+ consumer: AztecAddress;
14
+ /** The action to approve */
15
+ innerHash: Fr;
16
+ };
17
+ /** Intent with a call */
18
+ export type CallIntent = {
19
+ /** The caller to approve */
20
+ caller: AztecAddress;
21
+ /** The call to approve */
22
+ call: FunctionCall;
23
+ };
24
+ /** Intent with a ContractFunctionInteraction */
25
+ export type ContractFunctionInteractionCallIntent = {
26
+ /** The caller to approve */
27
+ caller: AztecAddress;
28
+ /** The action to approve */
29
+ action: ContractFunctionInteraction;
30
+ };
31
+ /** Identifies ContractFunctionInteractionCallIntents */
32
+ export declare function isContractFunctionInteractionCallIntent(messageHashOrIntent: Fr | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent): messageHashOrIntent is ContractFunctionInteractionCallIntent;
33
+ /**
34
+ * Compute an authentication witness message hash from an intent and metadata
35
+ *
36
+ * If using the `IntentInnerHash`, the consumer is the address that can "consume" the authwit, for token approvals it is the token contract itself.
37
+ * The `innerHash` itself will be the message that a contract is allowed to execute.
38
+ * At the point of "approval checking", the validating contract (account for private and registry for public) will be computing the message hash
39
+ * (`H(consumer, chainid, version, inner_hash)`) where the all but the `inner_hash` is injected from the context (consumer = msg_sender),
40
+ * and use it for the authentication check.
41
+ * Therefore, any allowed `innerHash` will therefore also have information around where it can be spent (version, chainId) and who can spend it (consumer).
42
+ *
43
+ * If using the `CallIntent`, the caller is the address that is making the call, for a token approval from Alice to Bob, this would be Bob.
44
+ * The action is then used along with the `caller` to compute the `innerHash` and the consumer.
45
+ *
46
+ *
47
+ * @param intent - The intent to approve (consumer and innerHash or caller and action)
48
+ * The consumer is the address that can "consume" the authwit, for token approvals it is the token contract itself.
49
+ * The caller is the address that is making the call, for a token approval from Alice to Bob, this would be Bob.
50
+ * The caller becomes part of the `inner_hash` and is dealt with entirely in application logic.
51
+ * @param metadata - The metadata for the intent (chainId, version)
52
+ * @returns The message hash for the action
53
+ */
54
+ export declare const computeAuthWitMessageHash: (intent: CallIntent | ContractFunctionInteractionCallIntent | IntentInnerHash, metadata: ChainInfo) => Promise<Fr>;
55
+ /**
56
+ * Compute an authentication witness message hash from an intent and metadata. This is just
57
+ * a wrapper around computeAuthwitMessageHash that allows receiving an already computed messageHash as input
58
+ * @param messageHashOrIntent - The precomputed messageHash or intent to approve (consumer and innerHash or caller and call/action)
59
+ * @param metadata - The metadata for the intent (chainId, version)
60
+ * @returns The message hash for the intent
61
+ */
62
+ export declare function getMessageHashFromIntent(messageHashOrIntent: Fr | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent, chainInfo: ChainInfo): Promise<Fr>;
63
+ /**
64
+ * Computes the inner authwitness hash for either a function call or an action, for it to later be combined with the metadata
65
+ * required for the outer hash and eventually the full AuthWitness.
66
+ * @param caller - Who is going to be calling the function
67
+ * @param action - The action to compute the inner hash from
68
+ * @returns The inner hash for the action
69
+ **/
70
+ export declare const computeInnerAuthWitHashFromAction: (caller: AztecAddress, action: ContractFunctionInteraction | FunctionCall) => Promise<Fr>;
71
+ /**
72
+ * Lookup the validity of an authwit in private and public contexts.
73
+ *
74
+ * Uses the chain id and version of the wallet.
75
+ *
76
+ * @param wallet - The wallet use to simulate and read the public data
77
+ * @param onBehalfOf - The address of the "approver"
78
+ * @param intent - The consumer and inner hash or the caller and action to lookup
79
+ * @param witness - The computed authentication witness to check
80
+ * @returns - A struct containing the validity of the authwit in private and public contexts.
81
+ */
82
+ export declare function lookupValidity(wallet: Wallet, onBehalfOf: AztecAddress, intent: IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent, witness: AuthWitness): Promise<{
83
+ /** boolean flag indicating if the authwit is valid in private context */
84
+ isValidInPrivate: boolean;
85
+ /** boolean flag indicating if the authwit is valid in public context */
86
+ isValidInPublic: boolean;
87
+ }>;
88
+ /**
89
+ * Convenience class designed to wrap the very common interaction of setting a public authwit in the AuthRegistry contract
90
+ */
91
+ export declare class SetPublicAuthwitContractInteraction extends ContractFunctionInteraction {
92
+ private from;
93
+ private constructor();
94
+ static create(wallet: Wallet, from: AztecAddress, messageHashOrIntent: Fr | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent, authorized: boolean): Promise<SetPublicAuthwitContractInteraction>;
95
+ /**
96
+ * Overrides the simulate method, adding the sender of the authwit (authorizer) as from
97
+ * and preventing misuse
98
+ * @param options - An optional object containing additional configuration for the transaction.
99
+ * @returns The result of the transaction as returned by the contract function.
100
+ */
101
+ simulate(options?: Omit<SimulateInteractionOptions, 'from'>): Promise<SimulationResult>;
102
+ /**
103
+ * Overrides the profile method, adding the sender of the authwit (authorizer) as from
104
+ * and preventing misuse
105
+ * @param options - Same options as `simulate`, plus profiling method
106
+ * @returns An object containing the function return value and profile result.
107
+ */
108
+ profile(options?: Omit<ProfileInteractionOptions, 'from'>): Promise<TxProfileResult>;
109
+ /**
110
+ * Overrides the send method, adding the sender of the authwit (authorizer) as from
111
+ * and preventing misuse
112
+ * @param options - An optional object containing 'fee' options information
113
+ * @returns A TxReceipt (if wait is true/undefined) or TxHash (if wait is false)
114
+ */
115
+ send(options?: Omit<SendInteractionOptionsWithoutWait, 'from'>): Promise<TxSendResultMined>;
116
+ send<W extends InteractionWaitOptions>(options?: Omit<SendInteractionOptions<W>, 'from'>): Promise<SendReturn<W>>;
117
+ private static getSetAuthorizedAbi;
118
+ }
119
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXV0aHdpdC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3V0aWxzL2F1dGh3aXQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0sb0NBQW9DLENBQUM7QUFDcEUsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLHFDQUFxQyxDQUFDO0FBRXpELE9BQU8sRUFBaUQsS0FBSyxZQUFZLEVBQWdCLE1BQU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/constants';
3
+ import { FunctionType } from '@aztec-labs/stdlib/abi';
4
+ import { computeInnerAuthWitHash, computeOuterAuthWitHash } from '@aztec-labs/stdlib/auth-witness';
5
+ import { computeVarArgsHash } from '@aztec-labs/stdlib/hash';
6
+ import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
7
+ /** Identifies ContractFunctionInteractionCallIntents */ export function isContractFunctionInteractionCallIntent(messageHashOrIntent) {
8
+ return 'caller' in messageHashOrIntent && 'action' in messageHashOrIntent && messageHashOrIntent.action instanceof ContractFunctionInteraction;
9
+ }
10
+ /**
11
+ * Compute an authentication witness message hash from an intent and metadata
12
+ *
13
+ * If using the `IntentInnerHash`, the consumer is the address that can "consume" the authwit, for token approvals it is the token contract itself.
14
+ * The `innerHash` itself will be the message that a contract is allowed to execute.
15
+ * At the point of "approval checking", the validating contract (account for private and registry for public) will be computing the message hash
16
+ * (`H(consumer, chainid, version, inner_hash)`) where the all but the `inner_hash` is injected from the context (consumer = msg_sender),
17
+ * and use it for the authentication check.
18
+ * Therefore, any allowed `innerHash` will therefore also have information around where it can be spent (version, chainId) and who can spend it (consumer).
19
+ *
20
+ * If using the `CallIntent`, the caller is the address that is making the call, for a token approval from Alice to Bob, this would be Bob.
21
+ * The action is then used along with the `caller` to compute the `innerHash` and the consumer.
22
+ *
23
+ *
24
+ * @param intent - The intent to approve (consumer and innerHash or caller and action)
25
+ * The consumer is the address that can "consume" the authwit, for token approvals it is the token contract itself.
26
+ * The caller is the address that is making the call, for a token approval from Alice to Bob, this would be Bob.
27
+ * The caller becomes part of the `inner_hash` and is dealt with entirely in application logic.
28
+ * @param metadata - The metadata for the intent (chainId, version)
29
+ * @returns The message hash for the action
30
+ */ export const computeAuthWitMessageHash = async (intent, metadata)=>{
31
+ const chainId = metadata.chainId;
32
+ const version = metadata.version;
33
+ if ('caller' in intent) {
34
+ const call = isContractFunctionInteractionCallIntent(intent) ? await intent.action.getFunctionCall() : intent.call;
35
+ return computeOuterAuthWitHash(call.to, chainId, version, await computeInnerAuthWitHashFromAction(intent.caller, call));
36
+ } else {
37
+ const inner = Buffer.isBuffer(intent.innerHash) ? Fr.fromBuffer(intent.innerHash) : intent.innerHash;
38
+ return computeOuterAuthWitHash(intent.consumer, chainId, version, inner);
39
+ }
40
+ };
41
+ /**
42
+ * Compute an authentication witness message hash from an intent and metadata. This is just
43
+ * a wrapper around computeAuthwitMessageHash that allows receiving an already computed messageHash as input
44
+ * @param messageHashOrIntent - The precomputed messageHash or intent to approve (consumer and innerHash or caller and call/action)
45
+ * @param metadata - The metadata for the intent (chainId, version)
46
+ * @returns The message hash for the intent
47
+ */ export async function getMessageHashFromIntent(messageHashOrIntent, chainInfo) {
48
+ let messageHash;
49
+ const { chainId, version } = chainInfo;
50
+ if (messageHashOrIntent instanceof Fr) {
51
+ messageHash = messageHashOrIntent;
52
+ } else {
53
+ messageHash = await computeAuthWitMessageHash(messageHashOrIntent, {
54
+ chainId,
55
+ version
56
+ });
57
+ }
58
+ return messageHash;
59
+ }
60
+ /**
61
+ * Computes the inner authwitness hash for either a function call or an action, for it to later be combined with the metadata
62
+ * required for the outer hash and eventually the full AuthWitness.
63
+ * @param caller - Who is going to be calling the function
64
+ * @param action - The action to compute the inner hash from
65
+ * @returns The inner hash for the action
66
+ **/ export const computeInnerAuthWitHashFromAction = async (caller, action)=>{
67
+ const call = action instanceof ContractFunctionInteraction ? await action.getFunctionCall() : action;
68
+ return computeInnerAuthWitHash([
69
+ caller.toField(),
70
+ call.selector.toField(),
71
+ await computeVarArgsHash(call.args)
72
+ ]);
73
+ };
74
+ /**
75
+ * Lookup the validity of an authwit in private and public contexts.
76
+ *
77
+ * Uses the chain id and version of the wallet.
78
+ *
79
+ * @param wallet - The wallet use to simulate and read the public data
80
+ * @param onBehalfOf - The address of the "approver"
81
+ * @param intent - The consumer and inner hash or the caller and action to lookup
82
+ * @param witness - The computed authentication witness to check
83
+ * @returns - A struct containing the validity of the authwit in private and public contexts.
84
+ */ export async function lookupValidity(wallet, onBehalfOf, intent, witness) {
85
+ let innerHash, consumer;
86
+ if ('caller' in intent) {
87
+ const call = isContractFunctionInteractionCallIntent(intent) ? await intent.action.getFunctionCall() : intent.call;
88
+ innerHash = await computeInnerAuthWitHashFromAction(intent.caller, call);
89
+ consumer = call.to;
90
+ } else {
91
+ ({ innerHash, consumer } = intent);
92
+ }
93
+ const chainInfo = await wallet.getChainInfo();
94
+ const messageHash = await getMessageHashFromIntent(intent, chainInfo);
95
+ const results = {
96
+ isValidInPrivate: false,
97
+ isValidInPublic: false
98
+ };
99
+ // Check private
100
+ const lookupValidityAbi = {
101
+ name: 'lookup_validity',
102
+ isInitializer: false,
103
+ functionType: FunctionType.UTILITY,
104
+ isOnlySelf: false,
105
+ isStatic: false,
106
+ parameters: [
107
+ {
108
+ name: 'consumer',
109
+ type: {
110
+ fields: [
111
+ {
112
+ name: 'inner',
113
+ type: {
114
+ kind: 'field'
115
+ }
116
+ }
117
+ ],
118
+ kind: 'struct',
119
+ path: 'aztec::protocol_types::address::aztec_address::AztecAddress'
120
+ },
121
+ visibility: 'private'
122
+ },
123
+ {
124
+ name: 'inner_hash',
125
+ type: {
126
+ kind: 'field'
127
+ },
128
+ visibility: 'private'
129
+ }
130
+ ],
131
+ returnType: {
132
+ kind: 'boolean'
133
+ },
134
+ errorTypes: {}
135
+ };
136
+ try {
137
+ results.isValidInPrivate = (await new ContractFunctionInteraction(wallet, onBehalfOf, lookupValidityAbi, [
138
+ consumer,
139
+ innerHash
140
+ ]).simulate({
141
+ from: onBehalfOf,
142
+ authWitnesses: [
143
+ witness
144
+ ]
145
+ })).result;
146
+ // TODO: Narrow down the error to make sure simulation failed due to an invalid authwit
147
+ // eslint-disable-next-line no-empty
148
+ } catch {}
149
+ // check public
150
+ const isConsumableAbi = {
151
+ name: 'utility_is_consumable',
152
+ isInitializer: false,
153
+ functionType: FunctionType.UTILITY,
154
+ isOnlySelf: false,
155
+ isStatic: false,
156
+ parameters: [
157
+ {
158
+ name: 'address',
159
+ type: {
160
+ fields: [
161
+ {
162
+ name: 'inner',
163
+ type: {
164
+ kind: 'field'
165
+ }
166
+ }
167
+ ],
168
+ kind: 'struct',
169
+ path: 'authwit::aztec::protocol_types::address::aztec_address::AztecAddress'
170
+ },
171
+ visibility: 'private'
172
+ },
173
+ {
174
+ name: 'message_hash',
175
+ type: {
176
+ kind: 'field'
177
+ },
178
+ visibility: 'private'
179
+ }
180
+ ],
181
+ returnType: {
182
+ kind: 'boolean'
183
+ },
184
+ errorTypes: {}
185
+ };
186
+ results.isValidInPublic = (await new ContractFunctionInteraction(wallet, STANDARD_AUTH_REGISTRY_ADDRESS, isConsumableAbi, [
187
+ onBehalfOf,
188
+ messageHash
189
+ ]).simulate({
190
+ from: onBehalfOf
191
+ })).result;
192
+ return results;
193
+ }
194
+ /**
195
+ * Convenience class designed to wrap the very common interaction of setting a public authwit in the AuthRegistry contract
196
+ */ export class SetPublicAuthwitContractInteraction extends ContractFunctionInteraction {
197
+ from;
198
+ constructor(wallet, from, messageHash, authorized){
199
+ super(wallet, STANDARD_AUTH_REGISTRY_ADDRESS, SetPublicAuthwitContractInteraction.getSetAuthorizedAbi(), [
200
+ messageHash,
201
+ authorized
202
+ ]), this.from = from;
203
+ }
204
+ static async create(wallet, from, messageHashOrIntent, authorized) {
205
+ const chainInfo = await wallet.getChainInfo();
206
+ const messageHash = await getMessageHashFromIntent(messageHashOrIntent, chainInfo);
207
+ return new SetPublicAuthwitContractInteraction(wallet, from, messageHash, authorized);
208
+ }
209
+ /**
210
+ * Overrides the simulate method, adding the sender of the authwit (authorizer) as from
211
+ * and preventing misuse
212
+ * @param options - An optional object containing additional configuration for the transaction.
213
+ * @returns The result of the transaction as returned by the contract function.
214
+ */ simulate(options = {}) {
215
+ return super.simulate({
216
+ ...options,
217
+ from: this.from
218
+ });
219
+ }
220
+ /**
221
+ * Overrides the profile method, adding the sender of the authwit (authorizer) as from
222
+ * and preventing misuse
223
+ * @param options - Same options as `simulate`, plus profiling method
224
+ * @returns An object containing the function return value and profile result.
225
+ */ profile(options = {
226
+ profileMode: 'gates'
227
+ }) {
228
+ return super.profile({
229
+ ...options,
230
+ from: this.from
231
+ });
232
+ }
233
+ // eslint-disable-next-line jsdoc/require-jsdoc
234
+ send(options) {
235
+ return super.send({
236
+ ...options,
237
+ from: this.from
238
+ });
239
+ }
240
+ static getSetAuthorizedAbi() {
241
+ return {
242
+ name: 'set_authorized',
243
+ isInitializer: false,
244
+ functionType: FunctionType.PUBLIC,
245
+ isOnlySelf: true,
246
+ isStatic: false,
247
+ parameters: [
248
+ {
249
+ name: 'message_hash',
250
+ type: {
251
+ kind: 'field'
252
+ },
253
+ visibility: 'private'
254
+ },
255
+ {
256
+ name: 'authorize',
257
+ type: {
258
+ kind: 'boolean'
259
+ },
260
+ visibility: 'private'
261
+ }
262
+ ],
263
+ errorTypes: {}
264
+ };
265
+ }
266
+ }
@@ -0,0 +1,28 @@
1
+ import type { Fr } from '@aztec-labs/foundation/curves/bn254';
2
+ import type { BlockTag } from '@aztec-labs/stdlib/block';
3
+ import type { AztecNode } from '@aztec-labs/stdlib/interfaces/client';
4
+ /**
5
+ * Waits for the L1 to L2 message to be ready to be consumed.
6
+ * @param node - Aztec node instance used to obtain the information about the message
7
+ * @param l1ToL2MessageHash - Hash of the L1 to L2 message
8
+ * @param opts - Options
9
+ */
10
+ export declare function waitForL1ToL2MessageReady(node: Pick<AztecNode, 'getBlockData' | 'getL1ToL2MessageIndex'>, l1ToL2MessageHash: Fr, opts: {
11
+ /** Timeout for the operation in seconds */ timeoutSeconds: number;
12
+ /**
13
+ * Chain tip to evaluate readiness against. Defaults to `'latest'`. Set this to the tip the consuming PXE syncs to
14
+ * (e.g. `'proven'`) so readiness answers whether the message is present at the same block the transaction
15
+ * simulation will anchor to, not at a newer tip.
16
+ */
17
+ chainTip?: BlockTag;
18
+ }): Promise<boolean>;
19
+ /**
20
+ * Returns whether the L1 to L2 message is ready to be consumed.
21
+ * @param node - Aztec node instance used to obtain the information about the message
22
+ * @param l1ToL2MessageHash - Hash of the L1 to L2 message
23
+ * @param chainTip - Chain tip to evaluate readiness against. Defaults to `'latest'`. Pass the tip the consuming PXE
24
+ * syncs to (e.g. `'proven'`) so readiness is checked at the block the transaction simulation will anchor to.
25
+ * @returns True if the message is ready to be consumed, false otherwise
26
+ */
27
+ export declare function isL1ToL2MessageReady(node: Pick<AztecNode, 'getBlockData' | 'getL1ToL2MessageIndex'>, l1ToL2MessageHash: Fr, chainTip?: BlockTag): Promise<boolean>;
28
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3Jvc3NfY2hhaW4uZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9jcm9zc19jaGFpbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxFQUFFLEVBQUUsTUFBTSxxQ0FBcUMsQ0FBQztBQUU5RCxPQUFPLEtBQUssRUFBRSxRQUFRLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUN6RCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxzQ0FBc0MsQ0FBQztBQUV0RTs7Ozs7R0FLRztBQUNILHdCQUFnQix5QkFBeUIsQ0FDdkMsSUFBSSxFQUFFLElBQUksQ0FBQyxTQUFTLEVBQUUsY0FBYyxHQUFHLHVCQUF1QixDQUFDLEVBQy9ELGlCQUFpQixFQUFFLEVBQUUsRUFDckIsSUFBSSxFQUFFO0lBQ0osMkNBQTJDLENBQUMsY0FBYyxFQUFFLE1BQU0sQ0FBQztJQUNuRTs7OztPQUlHO0lBQ0gsUUFBUSxDQUFDLEVBQUUsUUFBUSxDQUFDO0NBQ3JCLEdBQ0EsT0FBTyxDQUFDLE9BQU8sQ0FBQyxDQU9sQjtBQUVEOzs7Ozs7O0dBT0c7QUFDSCx3QkFBc0Isb0JBQW9CLENBQ3hDLElBQUksRUFBR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