@aztec/aztec.js 0.0.0-test.0

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 (299) hide show
  1. package/README.md +44 -0
  2. package/dest/account/contract.d.ts +37 -0
  3. package/dest/account/contract.d.ts.map +1 -0
  4. package/dest/account/contract.js +16 -0
  5. package/dest/account/index.d.ts +15 -0
  6. package/dest/account/index.d.ts.map +1 -0
  7. package/dest/account/index.js +9 -0
  8. package/dest/account/interface.d.ts +31 -0
  9. package/dest/account/interface.d.ts.map +1 -0
  10. package/dest/account/interface.js +4 -0
  11. package/dest/account/wallet.d.ts +11 -0
  12. package/dest/account/wallet.d.ts.map +1 -0
  13. package/dest/account/wallet.js +3 -0
  14. package/dest/account_manager/deploy_account_method.d.ts +15 -0
  15. package/dest/account_manager/deploy_account_method.d.ts.map +1 -0
  16. package/dest/account_manager/deploy_account_method.js +43 -0
  17. package/dest/account_manager/deploy_account_sent_tx.d.ts +30 -0
  18. package/dest/account_manager/deploy_account_sent_tx.d.ts.map +1 -0
  19. package/dest/account_manager/deploy_account_sent_tx.js +29 -0
  20. package/dest/account_manager/index.d.ts +108 -0
  21. package/dest/account_manager/index.d.ts.map +1 -0
  22. package/dest/account_manager/index.js +159 -0
  23. package/dest/api/abi.d.ts +3 -0
  24. package/dest/api/abi.d.ts.map +1 -0
  25. package/dest/api/abi.js +1 -0
  26. package/dest/api/account.d.ts +3 -0
  27. package/dest/api/account.d.ts.map +1 -0
  28. package/dest/api/account.js +2 -0
  29. package/dest/api/addresses.d.ts +3 -0
  30. package/dest/api/addresses.d.ts.map +1 -0
  31. package/dest/api/addresses.js +2 -0
  32. package/dest/api/cheat_codes.d.ts +26 -0
  33. package/dest/api/cheat_codes.d.ts.map +1 -0
  34. package/dest/api/cheat_codes.js +25 -0
  35. package/dest/api/deployment.d.ts +4 -0
  36. package/dest/api/deployment.d.ts.map +1 -0
  37. package/dest/api/deployment.js +3 -0
  38. package/dest/api/entrypoint.d.ts +2 -0
  39. package/dest/api/entrypoint.d.ts.map +1 -0
  40. package/dest/api/entrypoint.js +1 -0
  41. package/dest/api/eth_address.d.ts +2 -0
  42. package/dest/api/eth_address.d.ts.map +1 -0
  43. package/dest/api/eth_address.js +1 -0
  44. package/dest/api/ethereum/anvil_test_watcher.d.ts +32 -0
  45. package/dest/api/ethereum/anvil_test_watcher.d.ts.map +1 -0
  46. package/dest/api/ethereum/anvil_test_watcher.js +133 -0
  47. package/dest/api/ethereum/chain_monitor.d.ts +25 -0
  48. package/dest/api/ethereum/chain_monitor.d.ts.map +1 -0
  49. package/dest/api/ethereum/chain_monitor.js +74 -0
  50. package/dest/api/ethereum/cheat_codes.d.ts +63 -0
  51. package/dest/api/ethereum/cheat_codes.d.ts.map +1 -0
  52. package/dest/api/ethereum/cheat_codes.js +162 -0
  53. package/dest/api/ethereum/index.d.ts +7 -0
  54. package/dest/api/ethereum/index.d.ts.map +1 -0
  55. package/dest/api/ethereum/index.js +6 -0
  56. package/dest/api/ethereum/l1_contracts.d.ts +3 -0
  57. package/dest/api/ethereum/l1_contracts.d.ts.map +1 -0
  58. package/dest/api/ethereum/l1_contracts.js +13 -0
  59. package/dest/api/ethereum/portal_manager.d.ts +136 -0
  60. package/dest/api/ethereum/portal_manager.d.ts.map +1 -0
  61. package/dest/api/ethereum/portal_manager.js +286 -0
  62. package/dest/api/fee.d.ts +6 -0
  63. package/dest/api/fee.d.ts.map +1 -0
  64. package/dest/api/fee.js +4 -0
  65. package/dest/api/fields.d.ts +2 -0
  66. package/dest/api/fields.d.ts.map +1 -0
  67. package/dest/api/fields.js +1 -0
  68. package/dest/api/interfaces/pxe.d.ts +2 -0
  69. package/dest/api/interfaces/pxe.d.ts.map +1 -0
  70. package/dest/api/interfaces/pxe.js +1 -0
  71. package/dest/api/log.d.ts +2 -0
  72. package/dest/api/log.d.ts.map +1 -0
  73. package/dest/api/log.js +1 -0
  74. package/dest/api/log_id.d.ts +2 -0
  75. package/dest/api/log_id.d.ts.map +1 -0
  76. package/dest/api/log_id.js +1 -0
  77. package/dest/api/tx_hash.d.ts +2 -0
  78. package/dest/api/tx_hash.d.ts.map +1 -0
  79. package/dest/api/tx_hash.js +1 -0
  80. package/dest/api/wallet.d.ts +2 -0
  81. package/dest/api/wallet.d.ts.map +1 -0
  82. package/dest/api/wallet.js +1 -0
  83. package/dest/contract/base_contract_interaction.d.ts +98 -0
  84. package/dest/contract/base_contract_interaction.d.ts.map +1 -0
  85. package/dest/contract/base_contract_interaction.js +149 -0
  86. package/dest/contract/batch_call.d.ts +28 -0
  87. package/dest/contract/batch_call.d.ts.map +1 -0
  88. package/dest/contract/batch_call.js +91 -0
  89. package/dest/contract/checker.d.ts +11 -0
  90. package/dest/contract/checker.d.ts.map +1 -0
  91. package/dest/contract/checker.js +107 -0
  92. package/dest/contract/contract.d.ts +41 -0
  93. package/dest/contract/contract.d.ts.map +1 -0
  94. package/dest/contract/contract.js +52 -0
  95. package/dest/contract/contract_base.d.ts +61 -0
  96. package/dest/contract/contract_base.d.ts.map +1 -0
  97. package/dest/contract/contract_base.js +45 -0
  98. package/dest/contract/contract_function_interaction.d.ts +68 -0
  99. package/dest/contract/contract_function_interaction.d.ts.map +1 -0
  100. package/dest/contract/contract_function_interaction.js +122 -0
  101. package/dest/contract/deploy_method.d.ts +113 -0
  102. package/dest/contract/deploy_method.d.ts.map +1 -0
  103. package/dest/contract/deploy_method.js +212 -0
  104. package/dest/contract/deploy_proven_tx.d.ts +21 -0
  105. package/dest/contract/deploy_proven_tx.d.ts.map +1 -0
  106. package/dest/contract/deploy_proven_tx.js +19 -0
  107. package/dest/contract/deploy_sent_tx.d.ts +45 -0
  108. package/dest/contract/deploy_sent_tx.d.ts.map +1 -0
  109. package/dest/contract/deploy_sent_tx.js +43 -0
  110. package/dest/contract/get_gas_limits.d.ts +18 -0
  111. package/dest/contract/get_gas_limits.d.ts.map +1 -0
  112. package/dest/contract/get_gas_limits.js +10 -0
  113. package/dest/contract/index.d.ts +45 -0
  114. package/dest/contract/index.d.ts.map +1 -0
  115. package/dest/contract/index.js +43 -0
  116. package/dest/contract/protocol_contracts.d.ts +9 -0
  117. package/dest/contract/protocol_contracts.d.ts.map +1 -0
  118. package/dest/contract/protocol_contracts.js +26 -0
  119. package/dest/contract/proven_tx.d.ts +17 -0
  120. package/dest/contract/proven_tx.d.ts.map +1 -0
  121. package/dest/contract/proven_tx.js +22 -0
  122. package/dest/contract/sent_tx.d.ts +61 -0
  123. package/dest/contract/sent_tx.d.ts.map +1 -0
  124. package/dest/contract/sent_tx.js +102 -0
  125. package/dest/contract/unsafe_contract.d.ts +15 -0
  126. package/dest/contract/unsafe_contract.d.ts.map +1 -0
  127. package/dest/contract/unsafe_contract.js +6 -0
  128. package/dest/deployment/broadcast_function.d.ts +24 -0
  129. package/dest/deployment/broadcast_function.d.ts.map +1 -0
  130. package/dest/deployment/broadcast_function.js +70 -0
  131. package/dest/deployment/contract_deployer.d.ts +27 -0
  132. package/dest/deployment/contract_deployer.d.ts.map +1 -0
  133. package/dest/deployment/contract_deployer.js +30 -0
  134. package/dest/deployment/deploy_instance.d.ts +10 -0
  135. package/dest/deployment/deploy_instance.d.ts.map +1 -0
  136. package/dest/deployment/deploy_instance.js +14 -0
  137. package/dest/deployment/index.d.ts +2 -0
  138. package/dest/deployment/index.d.ts.map +1 -0
  139. package/dest/deployment/index.js +1 -0
  140. package/dest/deployment/register_class.d.ts +6 -0
  141. package/dest/deployment/register_class.d.ts.map +1 -0
  142. package/dest/deployment/register_class.js +22 -0
  143. package/dest/entrypoint/default_entrypoint.d.ts +12 -0
  144. package/dest/entrypoint/default_entrypoint.d.ts.map +1 -0
  145. package/dest/entrypoint/default_entrypoint.js +28 -0
  146. package/dest/entrypoint/default_multi_call_entrypoint.d.ts +15 -0
  147. package/dest/entrypoint/default_multi_call_entrypoint.d.ts.map +1 -0
  148. package/dest/entrypoint/default_multi_call_entrypoint.js +130 -0
  149. package/dest/entrypoint/entrypoint.d.ts +35 -0
  150. package/dest/entrypoint/entrypoint.d.ts.map +1 -0
  151. package/dest/entrypoint/entrypoint.js +4 -0
  152. package/dest/entrypoint/payload.d.ts +128 -0
  153. package/dest/entrypoint/payload.d.ts.map +1 -0
  154. package/dest/entrypoint/payload.js +143 -0
  155. package/dest/fee/fee_juice_payment_method.d.ts +14 -0
  156. package/dest/fee/fee_juice_payment_method.d.ts.map +1 -0
  157. package/dest/fee/fee_juice_payment_method.js +20 -0
  158. package/dest/fee/fee_juice_payment_method_with_claim.d.ts +18 -0
  159. package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -0
  160. package/dest/fee/fee_juice_payment_method_with_claim.js +37 -0
  161. package/dest/fee/fee_payment_method.d.ts +22 -0
  162. package/dest/fee/fee_payment_method.d.ts.map +1 -0
  163. package/dest/fee/fee_payment_method.js +3 -0
  164. package/dest/fee/private_fee_payment_method.d.ts +51 -0
  165. package/dest/fee/private_fee_payment_method.d.ts.map +1 -0
  166. package/dest/fee/private_fee_payment_method.js +103 -0
  167. package/dest/fee/public_fee_payment_method.d.ts +41 -0
  168. package/dest/fee/public_fee_payment_method.d.ts.map +1 -0
  169. package/dest/fee/public_fee_payment_method.js +97 -0
  170. package/dest/index.d.ts +66 -0
  171. package/dest/index.d.ts.map +1 -0
  172. package/dest/index.js +69 -0
  173. package/dest/rpc_clients/index.d.ts +3 -0
  174. package/dest/rpc_clients/index.d.ts.map +1 -0
  175. package/dest/rpc_clients/index.js +2 -0
  176. package/dest/rpc_clients/node/index.d.ts +12 -0
  177. package/dest/rpc_clients/node/index.d.ts.map +1 -0
  178. package/dest/rpc_clients/node/index.js +78 -0
  179. package/dest/rpc_clients/pxe_client.d.ts +10 -0
  180. package/dest/rpc_clients/pxe_client.d.ts.map +1 -0
  181. package/dest/rpc_clients/pxe_client.js +23 -0
  182. package/dest/utils/abi_types.d.ts +29 -0
  183. package/dest/utils/abi_types.d.ts.map +1 -0
  184. package/dest/utils/abi_types.js +1 -0
  185. package/dest/utils/authwit.d.ts +60 -0
  186. package/dest/utils/authwit.d.ts.map +1 -0
  187. package/dest/utils/authwit.js +74 -0
  188. package/dest/utils/aztec_cheatcodes.d.ts +59 -0
  189. package/dest/utils/aztec_cheatcodes.d.ts.map +1 -0
  190. package/dest/utils/aztec_cheatcodes.js +62 -0
  191. package/dest/utils/fee_juice.d.ts +7 -0
  192. package/dest/utils/fee_juice.d.ts.map +1 -0
  193. package/dest/utils/fee_juice.js +9 -0
  194. package/dest/utils/field_compressed_string.d.ts +17 -0
  195. package/dest/utils/field_compressed_string.d.ts.map +1 -0
  196. package/dest/utils/field_compressed_string.js +15 -0
  197. package/dest/utils/index.d.ts +8 -0
  198. package/dest/utils/index.d.ts.map +1 -0
  199. package/dest/utils/index.js +6 -0
  200. package/dest/utils/node.d.ts +5 -0
  201. package/dest/utils/node.d.ts.map +1 -0
  202. package/dest/utils/node.js +15 -0
  203. package/dest/utils/pub_key.d.ts +9 -0
  204. package/dest/utils/pub_key.d.ts.map +1 -0
  205. package/dest/utils/pub_key.js +9 -0
  206. package/dest/utils/pxe.d.ts +4 -0
  207. package/dest/utils/pxe.d.ts.map +1 -0
  208. package/dest/utils/pxe.js +14 -0
  209. package/dest/wallet/account_wallet.d.ts +76 -0
  210. package/dest/wallet/account_wallet.d.ts.map +1 -0
  211. package/dest/wallet/account_wallet.js +231 -0
  212. package/dest/wallet/account_wallet_with_private_key.d.ts +26 -0
  213. package/dest/wallet/account_wallet_with_private_key.d.ts.map +1 -0
  214. package/dest/wallet/account_wallet_with_private_key.js +22 -0
  215. package/dest/wallet/base_wallet.d.ts +73 -0
  216. package/dest/wallet/base_wallet.d.ts.map +1 -0
  217. package/dest/wallet/base_wallet.js +123 -0
  218. package/dest/wallet/index.d.ts +17 -0
  219. package/dest/wallet/index.d.ts.map +1 -0
  220. package/dest/wallet/index.js +20 -0
  221. package/dest/wallet/signerless_wallet.d.ts +25 -0
  222. package/dest/wallet/signerless_wallet.d.ts.map +1 -0
  223. package/dest/wallet/signerless_wallet.js +36 -0
  224. package/package.json +116 -0
  225. package/src/account/contract.ts +56 -0
  226. package/src/account/index.ts +16 -0
  227. package/src/account/interface.ts +36 -0
  228. package/src/account/wallet.ts +13 -0
  229. package/src/account_manager/deploy_account_method.ts +86 -0
  230. package/src/account_manager/deploy_account_sent_tx.ts +42 -0
  231. package/src/account_manager/index.ts +229 -0
  232. package/src/api/README.md +7 -0
  233. package/src/api/abi.ts +10 -0
  234. package/src/api/account.ts +10 -0
  235. package/src/api/addresses.ts +2 -0
  236. package/src/api/cheat_codes.ts +35 -0
  237. package/src/api/deployment.ts +3 -0
  238. package/src/api/entrypoint.ts +1 -0
  239. package/src/api/eth_address.ts +1 -0
  240. package/src/api/ethereum/anvil_test_watcher.ts +158 -0
  241. package/src/api/ethereum/chain_monitor.ts +88 -0
  242. package/src/api/ethereum/cheat_codes.ts +184 -0
  243. package/src/api/ethereum/index.ts +19 -0
  244. package/src/api/ethereum/l1_contracts.ts +21 -0
  245. package/src/api/ethereum/portal_manager.ts +410 -0
  246. package/src/api/fee.ts +5 -0
  247. package/src/api/fields.ts +1 -0
  248. package/src/api/interfaces/pxe.ts +1 -0
  249. package/src/api/log.ts +1 -0
  250. package/src/api/log_id.ts +1 -0
  251. package/src/api/tx_hash.ts +1 -0
  252. package/src/api/wallet.ts +7 -0
  253. package/src/contract/base_contract_interaction.ts +192 -0
  254. package/src/contract/batch_call.ts +95 -0
  255. package/src/contract/checker.ts +117 -0
  256. package/src/contract/contract.ts +69 -0
  257. package/src/contract/contract_base.ts +90 -0
  258. package/src/contract/contract_function_interaction.ts +173 -0
  259. package/src/contract/deploy_method.ts +271 -0
  260. package/src/contract/deploy_proven_tx.ts +34 -0
  261. package/src/contract/deploy_sent_tx.ts +74 -0
  262. package/src/contract/get_gas_limits.ts +26 -0
  263. package/src/contract/index.ts +48 -0
  264. package/src/contract/protocol_contracts.ts +35 -0
  265. package/src/contract/proven_tx.ts +42 -0
  266. package/src/contract/sent_tx.ts +141 -0
  267. package/src/contract/unsafe_contract.ts +19 -0
  268. package/src/deployment/broadcast_function.ts +148 -0
  269. package/src/deployment/contract_deployer.ts +41 -0
  270. package/src/deployment/deploy_instance.ts +31 -0
  271. package/src/deployment/index.ts +1 -0
  272. package/src/deployment/register_class.ts +44 -0
  273. package/src/entrypoint/default_entrypoint.ts +39 -0
  274. package/src/entrypoint/default_multi_call_entrypoint.ts +93 -0
  275. package/src/entrypoint/entrypoint.ts +39 -0
  276. package/src/entrypoint/payload.ts +238 -0
  277. package/src/fee/fee_juice_payment_method.ts +26 -0
  278. package/src/fee/fee_juice_payment_method_with_claim.ts +49 -0
  279. package/src/fee/fee_payment_method.ts +22 -0
  280. package/src/fee/private_fee_payment_method.ts +118 -0
  281. package/src/fee/public_fee_payment_method.ts +114 -0
  282. package/src/index.ts +106 -0
  283. package/src/rpc_clients/index.ts +2 -0
  284. package/src/rpc_clients/node/index.ts +77 -0
  285. package/src/rpc_clients/pxe_client.ts +25 -0
  286. package/src/utils/abi_types.ts +25 -0
  287. package/src/utils/authwit.ts +110 -0
  288. package/src/utils/aztec_cheatcodes.ts +77 -0
  289. package/src/utils/fee_juice.ts +14 -0
  290. package/src/utils/field_compressed_string.ts +27 -0
  291. package/src/utils/index.ts +21 -0
  292. package/src/utils/node.ts +19 -0
  293. package/src/utils/pub_key.ts +13 -0
  294. package/src/utils/pxe.ts +17 -0
  295. package/src/wallet/account_wallet.ts +242 -0
  296. package/src/wallet/account_wallet_with_private_key.ts +40 -0
  297. package/src/wallet/base_wallet.ts +198 -0
  298. package/src/wallet/index.ts +33 -0
  299. package/src/wallet/signerless_wallet.ts +52 -0
@@ -0,0 +1,23 @@
1
+ import { createSafeJsonRpcClient, makeFetch } from '@aztec/foundation/json-rpc/client';
2
+ import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
3
+ import { PXESchema } from '@aztec/stdlib/interfaces/client';
4
+ import { getVersioningResponseHandler } from '@aztec/stdlib/versioning';
5
+ /**
6
+ * Creates a JSON-RPC client to remotely talk to PXE.
7
+ * @param url - The URL of the PXE.
8
+ * @param fetch - The fetch implementation to use.
9
+ * @returns A JSON-RPC client of PXE.
10
+ */ export function createPXEClient(url, versions = {}, fetch = makeFetch([
11
+ 1,
12
+ 2,
13
+ 3
14
+ ], false)) {
15
+ return createSafeJsonRpcClient(url, PXESchema, {
16
+ namespaceMethods: 'pxe',
17
+ fetch,
18
+ onResponse: getVersioningResponseHandler({
19
+ l2ProtocolContractsTreeRoot: protocolContractTreeRoot.toString(),
20
+ ...versions
21
+ })
22
+ });
23
+ }
@@ -0,0 +1,29 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ /// <reference types="node" resolution-mode="require"/>
3
+ import type { EthAddress } from '@aztec/foundation/eth-address';
4
+ import type { Fr } from '@aztec/foundation/fields';
5
+ import type { EventSelector, FunctionSelector } from '@aztec/stdlib/abi';
6
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
7
+ /** Any type that can be converted into a field for a contract call. */
8
+ export type FieldLike = Fr | Buffer | bigint | number | {
9
+ toField: () => Fr;
10
+ };
11
+ /** Any type that can be converted into an EthAddress Aztec.nr struct. */
12
+ export type EthAddressLike = {
13
+ address: FieldLike;
14
+ } | EthAddress;
15
+ /** Any type that can be converted into an AztecAddress Aztec.nr struct. */
16
+ export type AztecAddressLike = {
17
+ address: FieldLike;
18
+ } | AztecAddress;
19
+ /** Any type that can be converted into a FunctionSelector Aztec.nr struct. */
20
+ export type FunctionSelectorLike = FieldLike | FunctionSelector;
21
+ /** Any type that can be converted into an EventSelector Aztec.nr struct. */
22
+ export type EventSelectorLike = FieldLike | EventSelector;
23
+ /** Any type that can be converted into a U128. */
24
+ export type U128Like = bigint | number;
25
+ /** Any type that can be converted into a struct with a single `inner` field. */
26
+ export type WrappedFieldLike = {
27
+ inner: FieldLike;
28
+ } | FieldLike;
29
+ //# sourceMappingURL=abi_types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abi_types.d.ts","sourceRoot":"","sources":["../../src/utils/abi_types.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,uEAAuE;AACvE,MAAM,MAAM,SAAS,GAAG,EAAE,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG;IAA2B,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAEvG,yEAAyE;AACzE,MAAM,MAAM,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"}
@@ -0,0 +1 @@
1
+ /** Any type that can be converted into a struct with a single `inner` field. */ export { };
@@ -0,0 +1,60 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ /// <reference types="node" resolution-mode="require"/>
3
+ import { Fr } from '@aztec/foundation/fields';
4
+ import type { FunctionCall } from '@aztec/stdlib/abi';
5
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
6
+ import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
7
+ /** Metadata for the intent */
8
+ export type IntentMetadata = {
9
+ /** The chain id to approve */
10
+ chainId: Fr;
11
+ /** The version to approve */
12
+ version: Fr;
13
+ };
14
+ /** Intent with an inner hash */
15
+ export type IntentInnerHash = {
16
+ /** The consumer */
17
+ consumer: AztecAddress;
18
+ /** The action to approve */
19
+ innerHash: Buffer | Fr;
20
+ };
21
+ /** Intent with an action */
22
+ export type IntentAction = {
23
+ /** The caller to approve */
24
+ caller: AztecAddress;
25
+ /** The action to approve */
26
+ action: ContractFunctionInteraction | FunctionCall;
27
+ };
28
+ /**
29
+ * Compute an authentication witness message hash from an intent and metadata
30
+ *
31
+ * If using the `IntentInnerHash`, the consumer is the address that can "consume" the authwit, for token approvals it is the token contract itself.
32
+ * The `innerHash` itself will be the message that a contract is allowed to execute.
33
+ * At the point of "approval checking", the validating contract (account for private and registry for public) will be computing the message hash
34
+ * (`H(consumer, chainid, version, inner_hash)`) where the all but the `inner_hash` is injected from the context (consumer = msg_sender),
35
+ * and use it for the authentication check.
36
+ * Therefore, any allowed `innerHash` will therefore also have information around where it can be spent (version, chainId) and who can spend it (consumer).
37
+ *
38
+ * If using the `IntentAction`, the caller is the address that is making the call, for a token approval from Alice to Bob, this would be Bob.
39
+ * The action is then used along with the `caller` to compute the `innerHash` and the consumer.
40
+ *
41
+ *
42
+ * @param intent - The intent to approve (consumer and innerHash or caller and action)
43
+ * The consumer is the address that can "consume" the authwit, for token approvals it is the token contract itself.
44
+ * The caller is the address that is making the call, for a token approval from Alice to Bob, this would be Bob.
45
+ * The caller becomes part of the `inner_hash` and is dealt with entirely in application logic.
46
+ * @param metadata - The metadata for the intent (chainId, version)
47
+ * @returns The message hash for the action
48
+ */
49
+ export declare const computeAuthWitMessageHash: (intent: IntentInnerHash | IntentAction, metadata: IntentMetadata) => Promise<Fr>;
50
+ export declare const computeInnerAuthWitHashFromAction: (caller: AztecAddress, action: FunctionCall) => Promise<Fr>;
51
+ /**
52
+ * Compute the inner hash for an authentication witness.
53
+ * This is the "intent" of the message, before siloed with the consumer.
54
+ * It is used as part of the `computeAuthWitMessageHash` but can also be used
55
+ * in case the message is not a "call" to a function, but arbitrary data.
56
+ * @param args - The arguments to hash
57
+ * @returns The inner hash for the witness
58
+ */
59
+ export declare const computeInnerAuthWitHash: (args: Fr[]) => Promise<Fr>;
60
+ //# sourceMappingURL=authwit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authwit.d.ts","sourceRoot":"","sources":["../../src/utils/authwit.ts"],"names":[],"mappings":";;AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE,OAAO,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAE3F,8BAA8B;AAC9B,MAAM,MAAM,cAAc,GAAG;IAC3B,8BAA8B;IAC9B,OAAO,EAAE,EAAE,CAAC;IACZ,8BAA8B;IAC9B,OAAO,EAAE,EAAE,CAAC;CACb,CAAC;AAEF,gCAAgC;AAChC,MAAM,MAAM,eAAe,GAAG;IAC5B,qBAAqB;IACrB,QAAQ,EAAE,YAAY,CAAC;IACvB,4BAA4B;IAC5B,SAAS,EAAE,MAAM,GAAG,EAAE,CAAC;CACxB,CAAC;AAEF,4BAA4B;AAC5B,MAAM,MAAM,YAAY,GAAG;IACzB,6BAA6B;IAC7B,MAAM,EAAE,YAAY,CAAC;IACrB,4BAA4B;IAC5B,MAAM,EAAE,2BAA2B,GAAG,YAAY,CAAC;CACpD,CAAC;AAGF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,yBAAyB,WAAkB,eAAe,GAAG,YAAY,YAAY,cAAc,gBAgB/G,CAAC;AAGF,eAAO,MAAM,iCAAiC,WAAkB,YAAY,UAAU,YAAY,gBAK9F,CAAC;AAEL;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,SAAU,EAAE,EAAE,gBAEjD,CAAC"}
@@ -0,0 +1,74 @@
1
+ import { GeneratorIndex } from '@aztec/constants';
2
+ import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto';
3
+ import { Fr } from '@aztec/foundation/fields';
4
+ import { HashedValues } from '@aztec/stdlib/tx';
5
+ import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
6
+ // docs:start:authwit_computeAuthWitMessageHash
7
+ /**
8
+ * Compute an authentication witness message hash from an intent and metadata
9
+ *
10
+ * If using the `IntentInnerHash`, the consumer is the address that can "consume" the authwit, for token approvals it is the token contract itself.
11
+ * The `innerHash` itself will be the message that a contract is allowed to execute.
12
+ * At the point of "approval checking", the validating contract (account for private and registry for public) will be computing the message hash
13
+ * (`H(consumer, chainid, version, inner_hash)`) where the all but the `inner_hash` is injected from the context (consumer = msg_sender),
14
+ * and use it for the authentication check.
15
+ * Therefore, any allowed `innerHash` will therefore also have information around where it can be spent (version, chainId) and who can spend it (consumer).
16
+ *
17
+ * If using the `IntentAction`, the caller is the address that is making the call, for a token approval from Alice to Bob, this would be Bob.
18
+ * The action is then used along with the `caller` to compute the `innerHash` and the consumer.
19
+ *
20
+ *
21
+ * @param intent - The intent to approve (consumer and innerHash or caller and action)
22
+ * The consumer is the address that can "consume" the authwit, for token approvals it is the token contract itself.
23
+ * The caller is the address that is making the call, for a token approval from Alice to Bob, this would be Bob.
24
+ * The caller becomes part of the `inner_hash` and is dealt with entirely in application logic.
25
+ * @param metadata - The metadata for the intent (chainId, version)
26
+ * @returns The message hash for the action
27
+ */ export const computeAuthWitMessageHash = async (intent, metadata)=>{
28
+ const chainId = metadata.chainId;
29
+ const version = metadata.version;
30
+ if ('caller' in intent) {
31
+ const action = intent.action instanceof ContractFunctionInteraction ? await intent.action.request() : intent.action;
32
+ return computeOuterAuthWitHash(action.to, chainId, version, await computeInnerAuthWitHashFromAction(intent.caller, action));
33
+ } else {
34
+ const inner = Buffer.isBuffer(intent.innerHash) ? Fr.fromBuffer(intent.innerHash) : intent.innerHash;
35
+ return computeOuterAuthWitHash(intent.consumer, chainId, version, inner);
36
+ }
37
+ };
38
+ // docs:end:authwit_computeAuthWitMessageHash
39
+ export const computeInnerAuthWitHashFromAction = async (caller, action)=>computeInnerAuthWitHash([
40
+ caller.toField(),
41
+ action.selector.toField(),
42
+ (await HashedValues.fromValues(action.args)).hash
43
+ ]);
44
+ /**
45
+ * Compute the inner hash for an authentication witness.
46
+ * This is the "intent" of the message, before siloed with the consumer.
47
+ * It is used as part of the `computeAuthWitMessageHash` but can also be used
48
+ * in case the message is not a "call" to a function, but arbitrary data.
49
+ * @param args - The arguments to hash
50
+ * @returns The inner hash for the witness
51
+ */ export const computeInnerAuthWitHash = (args)=>{
52
+ return poseidon2HashWithSeparator(args, GeneratorIndex.AUTHWIT_INNER);
53
+ };
54
+ /**
55
+ * Compute the outer hash for an authentication witness.
56
+ * This is the value siloed with its "consumer" and what the `on_behalf_of`
57
+ * should be signing.
58
+ * The consumer is who will be consuming the message, for token approvals it
59
+ * is the token contract itself (because the token makes the call to check the approval).
60
+ * It is used as part of the `computeAuthWitMessageHash` but can also be used
61
+ * in case the message is not a "call" to a function, but arbitrary data.
62
+ * @param consumer - The address that can "consume" the authwit
63
+ * @param chainId - The chain id that can "consume" the authwit
64
+ * @param version - The version that can "consume" the authwit
65
+ * @param innerHash - The inner hash for the witness
66
+ * @returns The outer hash for the witness
67
+ */ const computeOuterAuthWitHash = (consumer, chainId, version, innerHash)=>{
68
+ return poseidon2HashWithSeparator([
69
+ consumer.toField(),
70
+ chainId,
71
+ version,
72
+ innerHash
73
+ ], GeneratorIndex.AUTHWIT_OUTER);
74
+ };
@@ -0,0 +1,59 @@
1
+ import { Fr } from '@aztec/foundation/fields';
2
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
+ import type { PXE } from '@aztec/stdlib/interfaces/client';
4
+ import type { Note } from '@aztec/stdlib/note';
5
+ /**
6
+ * A class that provides utility functions for interacting with the aztec chain.
7
+ */
8
+ export declare class AztecCheatCodes {
9
+ /**
10
+ * The PXE Service to use for interacting with the chain
11
+ */
12
+ pxe: PXE;
13
+ /**
14
+ * The logger to use for the aztec cheatcodes
15
+ */
16
+ logger: import("@aztec/foundation/log").Logger;
17
+ constructor(
18
+ /**
19
+ * The PXE Service to use for interacting with the chain
20
+ */
21
+ pxe: PXE,
22
+ /**
23
+ * The logger to use for the aztec cheatcodes
24
+ */
25
+ logger?: import("@aztec/foundation/log").Logger);
26
+ /**
27
+ * Computes the slot value for a given map and key.
28
+ * @param mapSlot - The slot of the map (specified in Aztec.nr contract)
29
+ * @param key - The key to lookup in the map
30
+ * @returns The storage slot of the value in the map
31
+ */
32
+ computeSlotInMap(mapSlot: Fr | bigint, key: Fr | bigint | AztecAddress): Promise<Fr>;
33
+ /**
34
+ * Get the current blocknumber
35
+ * @returns The current block number
36
+ */
37
+ blockNumber(): Promise<number>;
38
+ /**
39
+ * Get the current timestamp
40
+ * @returns The current timestamp
41
+ */
42
+ timestamp(): Promise<number>;
43
+ /**
44
+ * Loads the value stored at the given slot in the public storage of the given contract.
45
+ * @param who - The address of the contract
46
+ * @param slot - The storage slot to lookup
47
+ * @returns The value stored at the given slot
48
+ */
49
+ loadPublic(who: AztecAddress, slot: Fr | bigint): Promise<Fr>;
50
+ /**
51
+ * Loads the value stored at the given slot in the private storage of the given contract.
52
+ * @param contract - The address of the contract
53
+ * @param owner - The owner for whom the notes are encrypted
54
+ * @param slot - The storage slot to lookup
55
+ * @returns The notes stored at the given slot
56
+ */
57
+ loadPrivate(owner: AztecAddress, contract: AztecAddress, slot: Fr | bigint): Promise<Note[]>;
58
+ }
59
+ //# sourceMappingURL=aztec_cheatcodes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aztec_cheatcodes.d.ts","sourceRoot":"","sources":["../../src/utils/aztec_cheatcodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE/C;;GAEG;AACH,qBAAa,eAAe;IAExB;;OAEG;IACI,GAAG,EAAE,GAAG;IACf;;OAEG;IACI,MAAM;;IAPb;;OAEG;IACI,GAAG,EAAE,GAAG;IACf;;OAEG;IACI,MAAM,yCAAsC;IAGrD;;;;;OAKG;IACI,gBAAgB,CAAC,OAAO,EAAE,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,EAAE,GAAG,MAAM,GAAG,YAAY,GAAG,OAAO,CAAC,EAAE,CAAC;IAK3F;;;OAGG;IACU,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAI3C;;;OAGG;IACU,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IAKzC;;;;;OAKG;IACU,UAAU,CAAC,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC;IAK1E;;;;;;OAMG;IACU,WAAW,CAAC,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;CAQ1G"}
@@ -0,0 +1,62 @@
1
+ import { Fr } from '@aztec/foundation/fields';
2
+ import { createLogger } from '@aztec/foundation/log';
3
+ import { deriveStorageSlotInMap } from '@aztec/stdlib/hash';
4
+ /**
5
+ * A class that provides utility functions for interacting with the aztec chain.
6
+ */ export class AztecCheatCodes {
7
+ pxe;
8
+ logger;
9
+ constructor(/**
10
+ * The PXE Service to use for interacting with the chain
11
+ */ pxe, /**
12
+ * The logger to use for the aztec cheatcodes
13
+ */ logger = createLogger('aztecjs:cheat_codes')){
14
+ this.pxe = pxe;
15
+ this.logger = logger;
16
+ }
17
+ /**
18
+ * Computes the slot value for a given map and key.
19
+ * @param mapSlot - The slot of the map (specified in Aztec.nr contract)
20
+ * @param key - The key to lookup in the map
21
+ * @returns The storage slot of the value in the map
22
+ */ computeSlotInMap(mapSlot, key) {
23
+ const keyFr = typeof key === 'bigint' ? new Fr(key) : key.toField();
24
+ return deriveStorageSlotInMap(mapSlot, keyFr);
25
+ }
26
+ /**
27
+ * Get the current blocknumber
28
+ * @returns The current block number
29
+ */ async blockNumber() {
30
+ return await this.pxe.getBlockNumber();
31
+ }
32
+ /**
33
+ * Get the current timestamp
34
+ * @returns The current timestamp
35
+ */ async timestamp() {
36
+ const res = await this.pxe.getBlock(await this.blockNumber());
37
+ return res?.header.globalVariables.timestamp.toNumber() ?? 0;
38
+ }
39
+ /**
40
+ * Loads the value stored at the given slot in the public storage of the given contract.
41
+ * @param who - The address of the contract
42
+ * @param slot - The storage slot to lookup
43
+ * @returns The value stored at the given slot
44
+ */ async loadPublic(who, slot) {
45
+ const storageValue = await this.pxe.getPublicStorageAt(who, new Fr(slot));
46
+ return storageValue;
47
+ }
48
+ /**
49
+ * Loads the value stored at the given slot in the private storage of the given contract.
50
+ * @param contract - The address of the contract
51
+ * @param owner - The owner for whom the notes are encrypted
52
+ * @param slot - The storage slot to lookup
53
+ * @returns The notes stored at the given slot
54
+ */ async loadPrivate(owner, contract, slot) {
55
+ const extendedNotes = await this.pxe.getNotes({
56
+ owner,
57
+ contractAddress: contract,
58
+ storageSlot: new Fr(slot)
59
+ });
60
+ return extendedNotes.map((extendedNote)=>extendedNote.note);
61
+ }
62
+ }
@@ -0,0 +1,7 @@
1
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
2
+ import type { PXE } from '../api/interfaces/pxe.js';
3
+ /**
4
+ * Returns the owner's fee juice balance.
5
+ */
6
+ export declare function getFeeJuiceBalance(owner: AztecAddress, pxe: PXE): Promise<bigint>;
7
+ //# sourceMappingURL=fee_juice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fee_juice.d.ts","sourceRoot":"","sources":["../../src/utils/fee_juice.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAEpD;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAGvF"}
@@ -0,0 +1,9 @@
1
+ import { Fr } from '@aztec/foundation/fields';
2
+ import { ProtocolContractAddress } from '@aztec/protocol-contracts';
3
+ import { deriveStorageSlotInMap } from '@aztec/stdlib/hash';
4
+ /**
5
+ * Returns the owner's fee juice balance.
6
+ */ export async function getFeeJuiceBalance(owner, pxe) {
7
+ const slot = await deriveStorageSlotInMap(new Fr(1), owner);
8
+ return (await pxe.getPublicStorageAt(ProtocolContractAddress.FeeJuice, slot)).toBigInt();
9
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The representation of a FieldCompressedString in aztec.nr
3
+ */
4
+ interface NoirFieldCompressedString {
5
+ /**
6
+ * The field value of the string
7
+ */
8
+ value: bigint;
9
+ }
10
+ /**
11
+ * This turns
12
+ * @param field - The field that contains the string
13
+ * @returns - the string that is decoded from the field
14
+ */
15
+ export declare const readFieldCompressedString: (field: NoirFieldCompressedString) => string;
16
+ export {};
17
+ //# sourceMappingURL=field_compressed_string.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field_compressed_string.d.ts","sourceRoot":"","sources":["../../src/utils/field_compressed_string.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,UAAU,yBAAyB;IACjC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AACD;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,UAAW,yBAAyB,KAAG,MAU5E,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { Fr } from '@aztec/foundation/fields';
2
+ /**
3
+ * This turns
4
+ * @param field - The field that contains the string
5
+ * @returns - the string that is decoded from the field
6
+ */ export const readFieldCompressedString = (field)=>{
7
+ const vals = Array.from(new Fr(field.value).toBuffer());
8
+ let str = '';
9
+ for(let i = 0; i < vals.length; i++){
10
+ if (vals[i] != 0) {
11
+ str += String.fromCharCode(Number(vals[i]));
12
+ }
13
+ }
14
+ return str;
15
+ };
@@ -0,0 +1,8 @@
1
+ export { generatePublicKey } from './pub_key.js';
2
+ export { type AztecAddressLike, type EthAddressLike, type EventSelectorLike, type FieldLike, type FunctionSelectorLike, type U128Like, type WrappedFieldLike, } from './abi_types.js';
3
+ export { computeAuthWitMessageHash, computeInnerAuthWitHash, computeInnerAuthWitHashFromAction, type IntentAction, type IntentInnerHash, } from './authwit.js';
4
+ export { waitForPXE } from './pxe.js';
5
+ export { waitForNode, createAztecNodeClient, type AztecNode } from './node.js';
6
+ export { getFeeJuiceBalance } from './fee_juice.js';
7
+ export { readFieldCompressedString } from './field_compressed_string.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,KAAK,oBAAoB,EACzB,KAAK,QAAQ,EACb,KAAK,gBAAgB,GACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,yBAAyB,EACzB,uBAAuB,EACvB,iCAAiC,EACjC,KAAK,YAAY,EACjB,KAAK,eAAe,GACrB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { generatePublicKey } from './pub_key.js';
2
+ export { computeAuthWitMessageHash, computeInnerAuthWitHash, computeInnerAuthWitHashFromAction } from './authwit.js';
3
+ export { waitForPXE } from './pxe.js';
4
+ export { waitForNode, createAztecNodeClient } from './node.js';
5
+ export { getFeeJuiceBalance } from './fee_juice.js';
6
+ export { readFieldCompressedString } from './field_compressed_string.js';
@@ -0,0 +1,5 @@
1
+ import type { Logger } from '@aztec/foundation/log';
2
+ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
3
+ export declare const waitForNode: (node: AztecNode, logger?: Logger) => Promise<void>;
4
+ export { createAztecNodeClient, type AztecNode } from '@aztec/stdlib/interfaces/client';
5
+ //# sourceMappingURL=node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/utils/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAEjE,eAAO,MAAM,WAAW,SAAgB,SAAS,WAAW,MAAM,kBAYjE,CAAC;AAEF,OAAO,EAAE,qBAAqB,EAAE,KAAK,SAAS,EAAE,MAAM,iCAAiC,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { retryUntil } from '@aztec/foundation/retry';
2
+ export const waitForNode = async (node, logger)=>{
3
+ await retryUntil(async ()=>{
4
+ try {
5
+ logger?.verbose('Attempting to contact Aztec node...');
6
+ await node.getNodeInfo();
7
+ logger?.verbose('Contacted Aztec node');
8
+ return true;
9
+ } catch (error) {
10
+ logger?.verbose('Failed to contact Aztec Node');
11
+ }
12
+ return undefined;
13
+ }, 'RPC Get Node Info');
14
+ };
15
+ export { createAztecNodeClient } from '@aztec/stdlib/interfaces/client';
@@ -0,0 +1,9 @@
1
+ import type { GrumpkinScalar } from '@aztec/foundation/fields';
2
+ import type { PublicKey } from '@aztec/stdlib/keys';
3
+ /**
4
+ * Method for generating a public grumpkin key from a private key.
5
+ * @param privateKey - The private key.
6
+ * @returns The generated public key.
7
+ */
8
+ export declare function generatePublicKey(privateKey: GrumpkinScalar): Promise<PublicKey>;
9
+ //# sourceMappingURL=pub_key.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pub_key.d.ts","sourceRoot":"","sources":["../../src/utils/pub_key.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,cAAc,GAAG,OAAO,CAAC,SAAS,CAAC,CAGhF"}
@@ -0,0 +1,9 @@
1
+ import { Grumpkin } from '@aztec/foundation/crypto';
2
+ /**
3
+ * Method for generating a public grumpkin key from a private key.
4
+ * @param privateKey - The private key.
5
+ * @returns The generated public key.
6
+ */ export function generatePublicKey(privateKey) {
7
+ const grumpkin = new Grumpkin();
8
+ return grumpkin.mul(grumpkin.generator(), privateKey);
9
+ }
@@ -0,0 +1,4 @@
1
+ import type { Logger } from '@aztec/foundation/log';
2
+ import type { PXE } from '@aztec/stdlib/interfaces/client';
3
+ export declare const waitForPXE: (pxe: PXE, logger?: Logger) => Promise<void>;
4
+ //# sourceMappingURL=pxe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pxe.d.ts","sourceRoot":"","sources":["../../src/utils/pxe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAE3D,eAAO,MAAM,UAAU,QAAe,GAAG,WAAW,MAAM,kBAYzD,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { retryUntil } from '@aztec/foundation/retry';
2
+ export const waitForPXE = async (pxe, logger)=>{
3
+ await retryUntil(async ()=>{
4
+ try {
5
+ logger?.verbose('Attempting to contact PXE...');
6
+ await pxe.getNodeInfo();
7
+ logger?.verbose('Contacted PXE');
8
+ return true;
9
+ } catch (error) {
10
+ logger?.verbose('Failed to contact PXE');
11
+ }
12
+ return undefined;
13
+ }, 'RPC Get Node Info');
14
+ };
@@ -0,0 +1,76 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ /// <reference types="node" resolution-mode="require"/>
3
+ import { Fr } from '@aztec/foundation/fields';
4
+ import type { AuthWitness } from '@aztec/stdlib/auth-witness';
5
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
6
+ import type { PXE } from '@aztec/stdlib/interfaces/client';
7
+ import type { TxExecutionRequest } from '@aztec/stdlib/tx';
8
+ import type { AccountInterface } from '../account/interface.js';
9
+ import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
10
+ import type { ExecutionRequestInit } from '../entrypoint/entrypoint.js';
11
+ import { type IntentAction, type IntentInnerHash } from '../utils/authwit.js';
12
+ import { BaseWallet } from './base_wallet.js';
13
+ /**
14
+ * A wallet implementation that forwards authentication requests to a provided account.
15
+ */
16
+ export declare class AccountWallet extends BaseWallet {
17
+ protected account: AccountInterface;
18
+ constructor(pxe: PXE, account: AccountInterface);
19
+ createTxExecutionRequest(exec: ExecutionRequestInit): Promise<TxExecutionRequest>;
20
+ getChainId(): Fr;
21
+ getVersion(): Fr;
22
+ isL1ToL2MessageSynced(l1ToL2Message: Fr): Promise<boolean>;
23
+ /**
24
+ * Computes an authentication witness from either a message hash or an intent.
25
+ *
26
+ * If a message hash is provided, it will create a witness for the hash directly.
27
+ * Otherwise, it will compute the message hash using the intent, along with the
28
+ * chain id and the version values provided by the wallet.
29
+ *
30
+ * @param messageHashOrIntent - The message hash of the intent to approve
31
+ * @returns The authentication witness
32
+ */
33
+ createAuthWit(messageHashOrIntent: Fr | Buffer | IntentAction | IntentInnerHash): Promise<AuthWitness>;
34
+ /**
35
+ * Returns a function interaction to set a message hash as authorized or revoked in this account.
36
+ *
37
+ * Public calls can then consume this authorization.
38
+ *
39
+ * @param messageHashOrIntent - The message hash or intent to authorize/revoke
40
+ * @param authorized - True to authorize, false to revoke authorization.
41
+ * @returns - A function interaction.
42
+ */
43
+ setPublicAuthWit(messageHashOrIntent: Fr | Buffer | IntentInnerHash | IntentAction, authorized: boolean): Promise<ContractFunctionInteraction>;
44
+ private getInnerHashAndConsumer;
45
+ /**
46
+ * Returns the message hash for the given intent
47
+ *
48
+ * @param intent - A tuple of (consumer and inner hash) or (caller and action)
49
+ * @returns The message hash
50
+ */
51
+ private getMessageHash;
52
+ /**
53
+ * Lookup the validity of an authwit in private and public contexts.
54
+ *
55
+ * Uses the chain id and version of the wallet.
56
+ *
57
+ * @param onBehalfOf - The address of the "approver"
58
+ * @param intent - The consumer and inner hash or the caller and action to lookup
59
+ *
60
+ * @returns - A struct containing the validity of the authwit in private and public contexts.
61
+ */
62
+ lookupValidity(onBehalfOf: AztecAddress, intent: IntentInnerHash | IntentAction): Promise<{
63
+ /** boolean flag indicating if the authwit is valid in private context */
64
+ isValidInPrivate: boolean;
65
+ /** boolean flag indicating if the authwit is valid in public context */
66
+ isValidInPublic: boolean;
67
+ }>;
68
+ /** Returns the complete address of the account that implements this wallet. */
69
+ getCompleteAddress(): import("@aztec/stdlib/contract").CompleteAddress;
70
+ /** Returns the address of the account that implements this wallet. */
71
+ getAddress(): AztecAddress;
72
+ private getSetAuthorizedAbi;
73
+ private getLookupValidityAbi;
74
+ private getIsConsumableAbi;
75
+ }
76
+ //# sourceMappingURL=account_wallet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account_wallet.d.ts","sourceRoot":"","sources":["../../src/wallet/account_wallet.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAG9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAC3F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,eAAe,EAGrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C;;GAEG;AACH,qBAAa,aAAc,SAAQ,UAAU;IACrB,SAAS,CAAC,OAAO,EAAE,gBAAgB;gBAA7C,GAAG,EAAE,GAAG,EAAY,OAAO,EAAE,gBAAgB;IAIzD,wBAAwB,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAIjF,UAAU,IAAI,EAAE;IAIhB,UAAU,IAAI,EAAE;IAIP,qBAAqB,CAAC,aAAa,EAAE,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAInE;;;;;;;;;OASG;IACG,aAAa,CAAC,mBAAmB,EAAE,EAAE,GAAG,MAAM,GAAG,YAAY,GAAG,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;IAe5G;;;;;;;;OAQG;IACU,gBAAgB,CAC3B,mBAAmB,EAAE,EAAE,GAAG,MAAM,GAAG,eAAe,GAAG,YAAY,EACjE,UAAU,EAAE,OAAO,GAClB,OAAO,CAAC,2BAA2B,CAAC;YAgBzB,uBAAuB;IAmBrC;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAMtB;;;;;;;;;OASG;IACG,cAAc,CAClB,UAAU,EAAE,YAAY,EACxB,MAAM,EAAE,eAAe,GAAG,YAAY,GACrC,OAAO,CAAC;QACT,yEAAyE;QACzE,gBAAgB,EAAE,OAAO,CAAC;QAC1B,wEAAwE;QACxE,eAAe,EAAE,OAAO,CAAC;KAC1B,CAAC;IA0BF,+EAA+E;IACxE,kBAAkB;IAIzB,sEAAsE;IACtD,UAAU;IAI1B,OAAO,CAAC,mBAAmB;IAwB3B,OAAO,CAAC,oBAAoB;IAa5B,OAAO,CAAC,kBAAkB;CAuB3B"}