@aztec/foundation 0.6.7 → 0.7.2

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 (351) hide show
  1. package/Dockerfile +15 -0
  2. package/package.json +1 -1
  3. package/src/abi/abi.ts +1 -1
  4. package/src/abi/decoder.test.ts +77 -0
  5. package/src/abi/decoder.ts +33 -10
  6. package/.tsbuildinfo +0 -1
  7. package/dest/abi/abi.d.ts +0 -232
  8. package/dest/abi/abi.d.ts.map +0 -1
  9. package/dest/abi/abi.js +0 -37
  10. package/dest/abi/abi_coder.d.ts +0 -8
  11. package/dest/abi/abi_coder.d.ts.map +0 -1
  12. package/dest/abi/abi_coder.js +0 -24
  13. package/dest/abi/decoder.d.ts +0 -42
  14. package/dest/abi/decoder.d.ts.map +0 -1
  15. package/dest/abi/decoder.js +0 -129
  16. package/dest/abi/encoder.d.ts +0 -10
  17. package/dest/abi/encoder.d.ts.map +0 -1
  18. package/dest/abi/encoder.js +0 -89
  19. package/dest/abi/encoder.test.d.ts +0 -2
  20. package/dest/abi/encoder.test.d.ts.map +0 -1
  21. package/dest/abi/encoder.test.js +0 -74
  22. package/dest/abi/function_selector.d.ts +0 -73
  23. package/dest/abi/function_selector.d.ts.map +0 -1
  24. package/dest/abi/function_selector.js +0 -104
  25. package/dest/abi/index.d.ts +0 -6
  26. package/dest/abi/index.d.ts.map +0 -1
  27. package/dest/abi/index.js +0 -6
  28. package/dest/async-map/async_map.test.d.ts +0 -2
  29. package/dest/async-map/async_map.test.d.ts.map +0 -1
  30. package/dest/async-map/async_map.test.js +0 -9
  31. package/dest/async-map/index.d.ts +0 -13
  32. package/dest/async-map/index.d.ts.map +0 -1
  33. package/dest/async-map/index.js +0 -19
  34. package/dest/aztec-address/index.d.ts +0 -114
  35. package/dest/aztec-address/index.d.ts.map +0 -1
  36. package/dest/aztec-address/index.js +0 -148
  37. package/dest/bigint-buffer/bigint-buffer.test.d.ts +0 -2
  38. package/dest/bigint-buffer/bigint-buffer.test.d.ts.map +0 -1
  39. package/dest/bigint-buffer/bigint-buffer.test.js +0 -18
  40. package/dest/bigint-buffer/index.d.ts +0 -35
  41. package/dest/bigint-buffer/index.d.ts.map +0 -1
  42. package/dest/bigint-buffer/index.js +0 -68
  43. package/dest/collection/array.d.ts +0 -30
  44. package/dest/collection/array.d.ts.map +0 -1
  45. package/dest/collection/array.js +0 -47
  46. package/dest/collection/index.d.ts +0 -2
  47. package/dest/collection/index.d.ts.map +0 -1
  48. package/dest/collection/index.js +0 -2
  49. package/dest/committable/committable.d.ts +0 -28
  50. package/dest/committable/committable.d.ts.map +0 -1
  51. package/dest/committable/committable.js +0 -41
  52. package/dest/committable/committable.test.d.ts +0 -2
  53. package/dest/committable/committable.test.d.ts.map +0 -1
  54. package/dest/committable/committable.test.js +0 -26
  55. package/dest/committable/index.d.ts +0 -2
  56. package/dest/committable/index.d.ts.map +0 -1
  57. package/dest/committable/index.js +0 -2
  58. package/dest/crypto/index.d.ts +0 -4
  59. package/dest/crypto/index.d.ts.map +0 -1
  60. package/dest/crypto/index.js +0 -4
  61. package/dest/crypto/keccak/index.d.ts +0 -20
  62. package/dest/crypto/keccak/index.d.ts.map +0 -1
  63. package/dest/crypto/keccak/index.js +0 -31
  64. package/dest/crypto/random/index.d.ts +0 -3
  65. package/dest/crypto/random/index.d.ts.map +0 -1
  66. package/dest/crypto/random/index.js +0 -36
  67. package/dest/crypto/random/index.test.d.ts +0 -2
  68. package/dest/crypto/random/index.test.d.ts.map +0 -1
  69. package/dest/crypto/random/index.test.js +0 -13
  70. package/dest/crypto/sha256/index.d.ts +0 -11
  71. package/dest/crypto/sha256/index.d.ts.map +0 -1
  72. package/dest/crypto/sha256/index.js +0 -14
  73. package/dest/crypto/sha256/index.test.d.ts +0 -2
  74. package/dest/crypto/sha256/index.test.d.ts.map +0 -1
  75. package/dest/crypto/sha256/index.test.js +0 -11
  76. package/dest/errors/index.d.ts +0 -8
  77. package/dest/errors/index.d.ts.map +0 -1
  78. package/dest/errors/index.js +0 -8
  79. package/dest/eth-address/eth_address.test.d.ts +0 -2
  80. package/dest/eth-address/eth_address.test.d.ts.map +0 -1
  81. package/dest/eth-address/eth_address.test.js +0 -95
  82. package/dest/eth-address/index.d.ts +0 -144
  83. package/dest/eth-address/index.d.ts.map +0 -1
  84. package/dest/eth-address/index.js +0 -228
  85. package/dest/fields/coordinate.d.ts +0 -67
  86. package/dest/fields/coordinate.d.ts.map +0 -1
  87. package/dest/fields/coordinate.js +0 -95
  88. package/dest/fields/coordinate.test.d.ts +0 -2
  89. package/dest/fields/coordinate.test.d.ts.map +0 -1
  90. package/dest/fields/coordinate.test.js +0 -22
  91. package/dest/fields/fields.d.ts +0 -177
  92. package/dest/fields/fields.d.ts.map +0 -1
  93. package/dest/fields/fields.js +0 -219
  94. package/dest/fields/grumpkin_scalar.d.ts +0 -96
  95. package/dest/fields/grumpkin_scalar.d.ts.map +0 -1
  96. package/dest/fields/grumpkin_scalar.js +0 -125
  97. package/dest/fields/grumpkin_scalar.test.d.ts +0 -2
  98. package/dest/fields/grumpkin_scalar.test.d.ts.map +0 -1
  99. package/dest/fields/grumpkin_scalar.test.js +0 -45
  100. package/dest/fields/index.d.ts +0 -5
  101. package/dest/fields/index.d.ts.map +0 -1
  102. package/dest/fields/index.js +0 -5
  103. package/dest/fields/point.d.ts +0 -105
  104. package/dest/fields/point.d.ts.map +0 -1
  105. package/dest/fields/point.js +0 -125
  106. package/dest/fifo/bounded_serial_queue.d.ts +0 -56
  107. package/dest/fifo/bounded_serial_queue.d.ts.map +0 -1
  108. package/dest/fifo/bounded_serial_queue.js +0 -94
  109. package/dest/fifo/index.d.ts +0 -5
  110. package/dest/fifo/index.d.ts.map +0 -1
  111. package/dest/fifo/index.js +0 -5
  112. package/dest/fifo/memory_fifo.d.ts +0 -55
  113. package/dest/fifo/memory_fifo.d.ts.map +0 -1
  114. package/dest/fifo/memory_fifo.js +0 -109
  115. package/dest/fifo/semaphore.d.ts +0 -23
  116. package/dest/fifo/semaphore.d.ts.map +0 -1
  117. package/dest/fifo/semaphore.js +0 -30
  118. package/dest/fifo/serial_queue.d.ts +0 -48
  119. package/dest/fifo/serial_queue.d.ts.map +0 -1
  120. package/dest/fifo/serial_queue.js +0 -74
  121. package/dest/json-rpc/class_converter.d.ts +0 -144
  122. package/dest/json-rpc/class_converter.d.ts.map +0 -1
  123. package/dest/json-rpc/class_converter.js +0 -100
  124. package/dest/json-rpc/client/index.d.ts +0 -2
  125. package/dest/json-rpc/client/index.d.ts.map +0 -1
  126. package/dest/json-rpc/client/index.js +0 -2
  127. package/dest/json-rpc/client/json_rpc_client.d.ts +0 -29
  128. package/dest/json-rpc/client/json_rpc_client.d.ts.map +0 -1
  129. package/dest/json-rpc/client/json_rpc_client.js +0 -104
  130. package/dest/json-rpc/client/json_rpc_client.test.d.ts +0 -2
  131. package/dest/json-rpc/client/json_rpc_client.test.d.ts.map +0 -1
  132. package/dest/json-rpc/client/json_rpc_client.test.js +0 -20
  133. package/dest/json-rpc/convert.d.ts +0 -28
  134. package/dest/json-rpc/convert.d.ts.map +0 -1
  135. package/dest/json-rpc/convert.js +0 -139
  136. package/dest/json-rpc/convert.test.d.ts +0 -2
  137. package/dest/json-rpc/convert.test.d.ts.map +0 -1
  138. package/dest/json-rpc/convert.test.js +0 -68
  139. package/dest/json-rpc/fixtures/class_a.d.ts +0 -11
  140. package/dest/json-rpc/fixtures/class_a.d.ts.map +0 -1
  141. package/dest/json-rpc/fixtures/class_a.js +0 -17
  142. package/dest/json-rpc/fixtures/class_b.d.ts +0 -11
  143. package/dest/json-rpc/fixtures/class_b.d.ts.map +0 -1
  144. package/dest/json-rpc/fixtures/class_b.js +0 -17
  145. package/dest/json-rpc/fixtures/test_state.d.ts +0 -47
  146. package/dest/json-rpc/fixtures/test_state.d.ts.map +0 -1
  147. package/dest/json-rpc/fixtures/test_state.js +0 -62
  148. package/dest/json-rpc/index.d.ts +0 -3
  149. package/dest/json-rpc/index.d.ts.map +0 -1
  150. package/dest/json-rpc/index.js +0 -3
  151. package/dest/json-rpc/js_utils.d.ts +0 -13
  152. package/dest/json-rpc/js_utils.d.ts.map +0 -1
  153. package/dest/json-rpc/js_utils.js +0 -18
  154. package/dest/json-rpc/server/index.d.ts +0 -3
  155. package/dest/json-rpc/server/index.d.ts.map +0 -1
  156. package/dest/json-rpc/server/index.js +0 -3
  157. package/dest/json-rpc/server/json_proxy.d.ts +0 -18
  158. package/dest/json-rpc/server/json_proxy.d.ts.map +0 -1
  159. package/dest/json-rpc/server/json_proxy.js +0 -36
  160. package/dest/json-rpc/server/json_rpc_server.d.ts +0 -34
  161. package/dest/json-rpc/server/json_rpc_server.d.ts.map +0 -1
  162. package/dest/json-rpc/server/json_rpc_server.js +0 -133
  163. package/dest/json-rpc/server/json_rpc_server.test.d.ts +0 -2
  164. package/dest/json-rpc/server/json_rpc_server.test.d.ts.map +0 -1
  165. package/dest/json-rpc/server/json_rpc_server.test.js +0 -22
  166. package/dest/log/console.d.ts +0 -11
  167. package/dest/log/console.d.ts.map +0 -1
  168. package/dest/log/console.js +0 -38
  169. package/dest/log/debug.d.ts +0 -43
  170. package/dest/log/debug.d.ts.map +0 -1
  171. package/dest/log/debug.js +0 -75
  172. package/dest/log/index.d.ts +0 -9
  173. package/dest/log/index.d.ts.map +0 -1
  174. package/dest/log/index.js +0 -5
  175. package/dest/log/log_history.d.ts +0 -31
  176. package/dest/log/log_history.d.ts.map +0 -1
  177. package/dest/log/log_history.js +0 -42
  178. package/dest/log/log_history.test.d.ts +0 -2
  179. package/dest/log/log_history.test.d.ts.map +0 -1
  180. package/dest/log/log_history.test.js +0 -78
  181. package/dest/log/logger.d.ts +0 -34
  182. package/dest/log/logger.d.ts.map +0 -1
  183. package/dest/log/logger.js +0 -78
  184. package/dest/mutex/index.d.ts +0 -53
  185. package/dest/mutex/index.d.ts.map +0 -1
  186. package/dest/mutex/index.js +0 -74
  187. package/dest/mutex/mutex.test.d.ts +0 -9
  188. package/dest/mutex/mutex.test.d.ts.map +0 -1
  189. package/dest/mutex/mutex.test.js +0 -58
  190. package/dest/mutex/mutex_database.d.ts +0 -10
  191. package/dest/mutex/mutex_database.d.ts.map +0 -1
  192. package/dest/mutex/mutex_database.js +0 -2
  193. package/dest/retry/index.d.ts +0 -44
  194. package/dest/retry/index.d.ts.map +0 -1
  195. package/dest/retry/index.js +0 -89
  196. package/dest/running-promise/index.d.ts +0 -35
  197. package/dest/running-promise/index.d.ts.map +0 -1
  198. package/dest/running-promise/index.js +0 -59
  199. package/dest/serialize/buffer_reader.d.ts +0 -188
  200. package/dest/serialize/buffer_reader.d.ts.map +0 -1
  201. package/dest/serialize/buffer_reader.js +0 -229
  202. package/dest/serialize/buffer_reader.test.d.ts +0 -2
  203. package/dest/serialize/buffer_reader.test.d.ts.map +0 -1
  204. package/dest/serialize/buffer_reader.test.js +0 -156
  205. package/dest/serialize/deserializer.d.ts +0 -134
  206. package/dest/serialize/deserializer.d.ts.map +0 -1
  207. package/dest/serialize/deserializer.js +0 -145
  208. package/dest/serialize/free_funcs.d.ts +0 -203
  209. package/dest/serialize/free_funcs.d.ts.map +0 -1
  210. package/dest/serialize/free_funcs.js +0 -250
  211. package/dest/serialize/index.d.ts +0 -6
  212. package/dest/serialize/index.d.ts.map +0 -1
  213. package/dest/serialize/index.js +0 -6
  214. package/dest/serialize/serialize.test.d.ts +0 -2
  215. package/dest/serialize/serialize.test.d.ts.map +0 -1
  216. package/dest/serialize/serialize.test.js +0 -68
  217. package/dest/serialize/serializer.d.ts +0 -89
  218. package/dest/serialize/serializer.d.ts.map +0 -1
  219. package/dest/serialize/serializer.js +0 -111
  220. package/dest/serialize/types.d.ts +0 -33
  221. package/dest/serialize/types.d.ts.map +0 -1
  222. package/dest/serialize/types.js +0 -22
  223. package/dest/sleep/index.d.ts +0 -52
  224. package/dest/sleep/index.d.ts.map +0 -1
  225. package/dest/sleep/index.js +0 -70
  226. package/dest/timer/index.d.ts +0 -3
  227. package/dest/timer/index.d.ts.map +0 -1
  228. package/dest/timer/index.js +0 -3
  229. package/dest/timer/timeout.d.ts +0 -41
  230. package/dest/timer/timeout.d.ts.map +0 -1
  231. package/dest/timer/timeout.js +0 -62
  232. package/dest/timer/timer.d.ts +0 -33
  233. package/dest/timer/timer.d.ts.map +0 -1
  234. package/dest/timer/timer.js +0 -38
  235. package/dest/transport/browser/index.d.ts +0 -5
  236. package/dest/transport/browser/index.d.ts.map +0 -1
  237. package/dest/transport/browser/index.js +0 -5
  238. package/dest/transport/browser/message_port_socket.d.ts +0 -37
  239. package/dest/transport/browser/message_port_socket.d.ts.map +0 -1
  240. package/dest/transport/browser/message_port_socket.js +0 -46
  241. package/dest/transport/browser/shared_worker_connector.d.ts +0 -19
  242. package/dest/transport/browser/shared_worker_connector.d.ts.map +0 -1
  243. package/dest/transport/browser/shared_worker_connector.js +0 -21
  244. package/dest/transport/browser/shared_worker_listener.d.ts +0 -38
  245. package/dest/transport/browser/shared_worker_listener.d.ts.map +0 -1
  246. package/dest/transport/browser/shared_worker_listener.js +0 -37
  247. package/dest/transport/browser/worker_connector.d.ts +0 -26
  248. package/dest/transport/browser/worker_connector.d.ts.map +0 -1
  249. package/dest/transport/browser/worker_connector.js +0 -30
  250. package/dest/transport/browser/worker_listener.d.ts +0 -39
  251. package/dest/transport/browser/worker_listener.d.ts.map +0 -1
  252. package/dest/transport/browser/worker_listener.js +0 -39
  253. package/dest/transport/dispatch/create_dispatch_fn.d.ts +0 -25
  254. package/dest/transport/dispatch/create_dispatch_fn.d.ts.map +0 -1
  255. package/dest/transport/dispatch/create_dispatch_fn.js +0 -18
  256. package/dest/transport/dispatch/create_dispatch_proxy.d.ts +0 -102
  257. package/dest/transport/dispatch/create_dispatch_proxy.d.ts.map +0 -1
  258. package/dest/transport/dispatch/create_dispatch_proxy.js +0 -56
  259. package/dest/transport/dispatch/messages.d.ts +0 -52
  260. package/dest/transport/dispatch/messages.d.ts.map +0 -1
  261. package/dest/transport/dispatch/messages.js +0 -12
  262. package/dest/transport/index.d.ts +0 -12
  263. package/dest/transport/index.d.ts.map +0 -1
  264. package/dest/transport/index.js +0 -12
  265. package/dest/transport/interface/connector.d.ts +0 -8
  266. package/dest/transport/interface/connector.d.ts.map +0 -1
  267. package/dest/transport/interface/connector.js +0 -2
  268. package/dest/transport/interface/listener.d.ts +0 -13
  269. package/dest/transport/interface/listener.d.ts.map +0 -1
  270. package/dest/transport/interface/listener.js +0 -2
  271. package/dest/transport/interface/socket.d.ts +0 -13
  272. package/dest/transport/interface/socket.d.ts.map +0 -1
  273. package/dest/transport/interface/socket.js +0 -2
  274. package/dest/transport/interface/transferable.d.ts +0 -68
  275. package/dest/transport/interface/transferable.d.ts.map +0 -1
  276. package/dest/transport/interface/transferable.js +0 -63
  277. package/dest/transport/node/index.d.ts +0 -3
  278. package/dest/transport/node/index.d.ts.map +0 -1
  279. package/dest/transport/node/index.js +0 -3
  280. package/dest/transport/node/node_connector.d.ts +0 -28
  281. package/dest/transport/node/node_connector.d.ts.map +0 -1
  282. package/dest/transport/node/node_connector.js +0 -28
  283. package/dest/transport/node/node_connector_socket.d.ts +0 -42
  284. package/dest/transport/node/node_connector_socket.d.ts.map +0 -1
  285. package/dest/transport/node/node_connector_socket.js +0 -48
  286. package/dest/transport/node/node_listener.d.ts +0 -26
  287. package/dest/transport/node/node_listener.d.ts.map +0 -1
  288. package/dest/transport/node/node_listener.js +0 -30
  289. package/dest/transport/node/node_listener_socket.d.ts +0 -37
  290. package/dest/transport/node/node_listener_socket.d.ts.map +0 -1
  291. package/dest/transport/node/node_listener_socket.js +0 -44
  292. package/dest/transport/transport_client.d.ts +0 -61
  293. package/dest/transport/transport_client.d.ts.map +0 -1
  294. package/dest/transport/transport_client.js +0 -94
  295. package/dest/transport/transport_server.d.ts +0 -56
  296. package/dest/transport/transport_server.d.ts.map +0 -1
  297. package/dest/transport/transport_server.js +0 -101
  298. package/dest/types/index.d.ts +0 -7
  299. package/dest/types/index.d.ts.map +0 -1
  300. package/dest/types/index.js +0 -2
  301. package/dest/url/index.d.ts +0 -9
  302. package/dest/url/index.d.ts.map +0 -1
  303. package/dest/url/index.js +0 -66
  304. package/dest/wasm/empty_wasi_sdk.d.ts +0 -130
  305. package/dest/wasm/empty_wasi_sdk.d.ts.map +0 -1
  306. package/dest/wasm/empty_wasi_sdk.js +0 -166
  307. package/dest/wasm/index.d.ts +0 -2
  308. package/dest/wasm/index.d.ts.map +0 -1
  309. package/dest/wasm/index.js +0 -2
  310. package/dest/wasm/wasm_module.d.ts +0 -135
  311. package/dest/wasm/wasm_module.d.ts.map +0 -1
  312. package/dest/wasm/wasm_module.js +0 -205
  313. package/dest/wasm/wasm_module.test.d.ts +0 -2
  314. package/dest/wasm/wasm_module.test.d.ts.map +0 -1
  315. package/dest/wasm/wasm_module.test.js +0 -24
  316. package/dest/worker/browser/index.d.ts +0 -3
  317. package/dest/worker/browser/index.d.ts.map +0 -1
  318. package/dest/worker/browser/index.js +0 -3
  319. package/dest/worker/browser/start_web_module.d.ts +0 -7
  320. package/dest/worker/browser/start_web_module.d.ts.map +0 -1
  321. package/dest/worker/browser/start_web_module.js +0 -22
  322. package/dest/worker/browser/web_data_store.d.ts +0 -23
  323. package/dest/worker/browser/web_data_store.d.ts.map +0 -1
  324. package/dest/worker/browser/web_data_store.js +0 -32
  325. package/dest/worker/browser/web_worker.d.ts +0 -10
  326. package/dest/worker/browser/web_worker.d.ts.map +0 -1
  327. package/dest/worker/browser/web_worker.js +0 -23
  328. package/dest/worker/data_store.d.ts +0 -20
  329. package/dest/worker/data_store.d.ts.map +0 -1
  330. package/dest/worker/data_store.js +0 -2
  331. package/dest/worker/index.d.ts +0 -3
  332. package/dest/worker/index.d.ts.map +0 -1
  333. package/dest/worker/index.js +0 -2
  334. package/dest/worker/node/index.d.ts +0 -3
  335. package/dest/worker/node/index.d.ts.map +0 -1
  336. package/dest/worker/node/index.js +0 -3
  337. package/dest/worker/node/node_data_store.d.ts +0 -12
  338. package/dest/worker/node/node_data_store.d.ts.map +0 -1
  339. package/dest/worker/node/node_data_store.js +0 -21
  340. package/dest/worker/node/node_worker.d.ts +0 -6
  341. package/dest/worker/node/node_worker.d.ts.map +0 -1
  342. package/dest/worker/node/node_worker.js +0 -20
  343. package/dest/worker/node/start_node_module.d.ts +0 -7
  344. package/dest/worker/node/start_node_module.d.ts.map +0 -1
  345. package/dest/worker/node/start_node_module.js +0 -26
  346. package/dest/worker/wasm_worker.d.ts +0 -9
  347. package/dest/worker/wasm_worker.d.ts.map +0 -1
  348. package/dest/worker/wasm_worker.js +0 -2
  349. package/dest/worker/worker_pool.d.ts +0 -40
  350. package/dest/worker/worker_pool.d.ts.map +0 -1
  351. package/dest/worker/worker_pool.js +0 -62
package/dest/abi/abi.d.ts DELETED
@@ -1,232 +0,0 @@
1
- /**
2
- * A named type.
3
- */
4
- export interface ABIVariable {
5
- /**
6
- * The name of the variable.
7
- */
8
- name: string;
9
- /**
10
- * The type of the variable.
11
- */
12
- type: ABIType;
13
- }
14
- /**
15
- * Indicates whether a parameter is public or secret/private.
16
- */
17
- export declare enum ABIParameterVisibility {
18
- PUBLIC = "public",
19
- SECRET = "secret"
20
- }
21
- /**
22
- * A function parameter.
23
- */
24
- export interface ABIParameter extends ABIVariable {
25
- /**
26
- * Indicates whether a parameter is public or secret/private.
27
- */
28
- visibility: ABIParameterVisibility;
29
- }
30
- /**
31
- * A basic type.
32
- */
33
- export interface BasicType<T extends string> {
34
- /**
35
- * The kind of the type.
36
- */
37
- kind: T;
38
- }
39
- /**
40
- * A variable type.
41
- */
42
- export type ABIType = BasicType<'field'> | BasicType<'boolean'> | IntegerType | ArrayType | StringType | StructType;
43
- /**
44
- * An integer type.
45
- */
46
- export interface IntegerType extends BasicType<'integer'> {
47
- /**
48
- * The sign of the integer.
49
- */
50
- sign: string;
51
- /**
52
- * The width of the integer in bits.
53
- */
54
- width: number;
55
- }
56
- /**
57
- * An array type.
58
- */
59
- export interface ArrayType extends BasicType<'array'> {
60
- /**
61
- * The length of the array.
62
- */
63
- length: number;
64
- /**
65
- * The type of the array elements.
66
- */
67
- type: ABIType;
68
- }
69
- /**
70
- * A string type.
71
- */
72
- export interface StringType extends BasicType<'string'> {
73
- /**
74
- * The length of the string.
75
- */
76
- length: number;
77
- }
78
- /**
79
- * A struct type.
80
- */
81
- export interface StructType extends BasicType<'struct'> {
82
- /**
83
- * The fields of the struct.
84
- */
85
- fields: ABIVariable[];
86
- }
87
- /**
88
- * Noir function types.
89
- */
90
- export declare enum FunctionType {
91
- SECRET = "secret",
92
- OPEN = "open",
93
- UNCONSTRAINED = "unconstrained"
94
- }
95
- /**
96
- * The ABI entry of a function.
97
- */
98
- export interface FunctionAbi {
99
- /**
100
- * The name of the function.
101
- */
102
- name: string;
103
- /**
104
- * Whether the function is secret.
105
- */
106
- functionType: FunctionType;
107
- /**
108
- * Whether the function is internal.
109
- */
110
- isInternal: boolean;
111
- /**
112
- * Function parameters.
113
- */
114
- parameters: ABIParameter[];
115
- /**
116
- * The types of the return values.
117
- */
118
- returnTypes: ABIType[];
119
- /**
120
- * The ACIR bytecode of the function.
121
- */
122
- bytecode: string;
123
- /**
124
- * The verification key of the function.
125
- */
126
- verificationKey?: string;
127
- }
128
- /**
129
- * A file ID. It's assigned during compilation.
130
- */
131
- export type FileId = number;
132
- /**
133
- * A pointer to a specific section of the source code.
134
- */
135
- export interface SourceCodeLocation {
136
- /**
137
- * The section of the source code.
138
- */
139
- span: {
140
- /**
141
- * The byte where the section starts.
142
- */
143
- start: number;
144
- /**
145
- * The byte where the section ends.
146
- */
147
- end: number;
148
- };
149
- /**
150
- * The source code file pointed to.
151
- */
152
- file: FileId;
153
- }
154
- /**
155
- * The location of an opcode in the bytecode.
156
- * It's a string of the form `{acirIndex}` or `{acirIndex}:{brilligIndex}`.
157
- */
158
- export type OpcodeLocation = string;
159
- /**
160
- * The debug information for a given function.
161
- */
162
- export interface DebugInfo {
163
- /**
164
- * A map of the opcode location to the source code location.
165
- */
166
- locations: Record<OpcodeLocation, SourceCodeLocation[]>;
167
- }
168
- /**
169
- * Maps a file ID to its metadata for debugging purposes.
170
- */
171
- export type DebugFileMap = Record<FileId, {
172
- /**
173
- * The source code of the file.
174
- */
175
- source: string;
176
- /**
177
- * The path of the file.
178
- */
179
- path: string;
180
- }>;
181
- /**
182
- * The debug metadata of an ABI.
183
- */
184
- export interface DebugMetadata {
185
- /**
186
- * The DebugInfo object, deflated as JSON, compressed using gzip and serialized with base64.
187
- */
188
- debugSymbols: string[];
189
- /**
190
- * The map of file ID to the source code and path of the file.
191
- */
192
- fileMap: DebugFileMap;
193
- }
194
- /**
195
- * Defines ABI of a contract.
196
- */
197
- export interface ContractAbi {
198
- /**
199
- * The name of the contract.
200
- */
201
- name: string;
202
- /**
203
- * The functions of the contract.
204
- */
205
- functions: FunctionAbi[];
206
- /**
207
- * The debug metadata of the contract.
208
- * It's used to include the relevant source code section when a constraint is not met during simulation.
209
- */
210
- debug?: DebugMetadata;
211
- }
212
- /**
213
- * Debug metadata for a function.
214
- */
215
- export interface FunctionDebugMetadata {
216
- /**
217
- * Maps opcodes to source code pointers
218
- */
219
- debugSymbols: DebugInfo;
220
- /**
221
- * Maps the file IDs to the file contents to resolve pointers
222
- */
223
- files: DebugFileMap;
224
- }
225
- /**
226
- * Gets the debug metadata of a given function from the contract abi
227
- * @param abi - The contract abi
228
- * @param functionName - The name of the function
229
- * @returns The debug metadata of the function
230
- */
231
- export declare function getFunctionDebugMetadata(abi: ContractAbi, functionName: string): FunctionDebugMetadata | undefined;
232
- //# sourceMappingURL=abi.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"abi.d.ts","sourceRoot":"","sources":["../../src/abi/abi.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC;CACf;AAED;;GAEG;AACH,oBAAY,sBAAsB;IAChC,MAAM,WAAW;IACjB,MAAM,WAAW;CA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AAE,YAAY,EAAE,MAAM,GAAG,qBAAqB,GAAG,SAAS,CAalH"}
package/dest/abi/abi.js DELETED
@@ -1,37 +0,0 @@
1
- import { inflate } from 'pako';
2
- /**
3
- * Indicates whether a parameter is public or secret/private.
4
- */
5
- export var ABIParameterVisibility;
6
- (function (ABIParameterVisibility) {
7
- ABIParameterVisibility["PUBLIC"] = "public";
8
- ABIParameterVisibility["SECRET"] = "secret";
9
- })(ABIParameterVisibility || (ABIParameterVisibility = {}));
10
- /**
11
- * Noir function types.
12
- */
13
- export var FunctionType;
14
- (function (FunctionType) {
15
- FunctionType["SECRET"] = "secret";
16
- FunctionType["OPEN"] = "open";
17
- FunctionType["UNCONSTRAINED"] = "unconstrained";
18
- })(FunctionType || (FunctionType = {}));
19
- /**
20
- * Gets the debug metadata of a given function from the contract abi
21
- * @param abi - The contract abi
22
- * @param functionName - The name of the function
23
- * @returns The debug metadata of the function
24
- */
25
- export function getFunctionDebugMetadata(abi, functionName) {
26
- const functionIndex = abi.functions.findIndex(f => f.name === functionName);
27
- if (abi.debug && functionIndex !== -1) {
28
- const debugSymbols = JSON.parse(inflate(Buffer.from(abi.debug.debugSymbols[functionIndex], 'base64'), { to: 'string' }));
29
- const files = abi.debug.fileMap;
30
- return {
31
- debugSymbols,
32
- files,
33
- };
34
- }
35
- return undefined;
36
- }
37
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWJpLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2FiaS9hYmkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLE9BQU8sRUFBRSxNQUFNLE1BQU0sQ0FBQztBQWdCL0I7O0dBRUc7QUFDSCxNQUFNLENBQU4sSUFBWSxzQkFHWDtBQUhELFdBQVksc0JBQXNCO0lBQ2hDLDJDQUFpQixDQUFBO0lBQ2pCLDJDQUFpQixDQUFBO0FBQ25CLENBQUMsRUFIVyxzQkFBc0IsS0FBdEIsc0JBQXNCLFFBR2pDO0FBMkVEOztHQUVHO0FBQ0gsTUFBTSxDQUFOLElBQVksWUFJWDtBQUpELFdBQVksWUFBWTtJQUN0QixpQ0FBaUIsQ0FBQTtJQUNqQiw2QkFBYSxDQUFBO0lBQ2IsK0NBQStCLENBQUE7QUFDakMsQ0FBQyxFQUpXLFlBQVksS0FBWixZQUFZLFFBSXZCO0FBaUpEOzs7OztHQUtHO0FBQ0gsTUFBTSxVQUFVLHdCQUF3QixDQUFDLEdBQWdCLEVBQUUsWUFBb0I7SUFDN0UsTUFBTSxhQUFhLEdBQUcsR0FBRyxDQUFDLFNBQVMsQ0FBQyxTQUFTLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxDQUFDLENBQUMsSUFBSSxLQUFLLFlBQVksQ0FBQyxDQUFDO0lBQzVFLElBQUksR0FBRyxDQUFDLEtBQUssSUFBSSxhQUFhLEtBQUssQ0FBQyxDQUFDLEVBQUU7UUFDckMsTUFBTSxZQUFZLEdBQUcsSUFBSSxDQUFDLEtBQUssQ0FDN0IsT0FBTyxDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsR0FBRyxDQUFDLEtBQUssQ0FBQyxZQUFZLENBQUMsYUFBYSxDQUFDLEVBQUUsUUFBUSxDQUFDLEVBQUUsRUFBRSxFQUFFLEVBQUUsUUFBUSxFQUFFLENBQUMsQ0FDeEYsQ0FBQztRQUNGLE1BQU0sS0FBSyxHQUFHLEdBQUcsQ0FBQyxLQUFLLENBQUMsT0FBTyxDQUFDO1FBQ2hDLE9BQU87WUFDTCxZQUFZO1lBQ1osS0FBSztTQUNOLENBQUM7S0FDSDtJQUNELE9BQU8sU0FBUyxDQUFDO0FBQ25CLENBQUMifQ==
@@ -1,8 +0,0 @@
1
- import { ABIType } from '@aztec/foundation/abi';
2
- /**
3
- * Get the size of an ABI type in field elements.
4
- * @param type - The ABI type.
5
- * @returns The size of the type in field elements.
6
- */
7
- export declare function sizeOfType(type: ABIType): number;
8
- //# sourceMappingURL=abi_coder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"abi_coder.d.ts","sourceRoot":"","sources":["../../src/abi/abi_coder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAiBhD"}
@@ -1,24 +0,0 @@
1
- /**
2
- * Get the size of an ABI type in field elements.
3
- * @param type - The ABI type.
4
- * @returns The size of the type in field elements.
5
- */
6
- export function sizeOfType(type) {
7
- switch (type.kind) {
8
- case 'field':
9
- case 'boolean':
10
- case 'integer':
11
- return 1;
12
- case 'string':
13
- return type.length;
14
- case 'array':
15
- return type.length * sizeOfType(type.type);
16
- case 'struct':
17
- return type.fields.reduce((sum, field) => sum + sizeOfType(field.type), 0);
18
- default: {
19
- const exhaustiveCheck = type;
20
- throw new Error(`Unhandled abi type: ${exhaustiveCheck}`);
21
- }
22
- }
23
- }
24
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWJpX2NvZGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2FiaS9hYmlfY29kZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUE7Ozs7R0FJRztBQUNILE1BQU0sVUFBVSxVQUFVLENBQUMsSUFBYTtJQUN0QyxRQUFRLElBQUksQ0FBQyxJQUFJLEVBQUU7UUFDakIsS0FBSyxPQUFPLENBQUM7UUFDYixLQUFLLFNBQVMsQ0FBQztRQUNmLEtBQUssU0FBUztZQUNaLE9BQU8sQ0FBQyxDQUFDO1FBQ1gsS0FBSyxRQUFRO1lBQ1gsT0FBTyxJQUFJLENBQUMsTUFBTSxDQUFDO1FBQ3JCLEtBQUssT0FBTztZQUNWLE9BQU8sSUFBSSxDQUFDLE1BQU0sR0FBRyxVQUFVLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFDO1FBQzdDLEtBQUssUUFBUTtZQUNYLE9BQU8sSUFBSSxDQUFDLE1BQU0sQ0FBQyxNQUFNLENBQUMsQ0FBQyxHQUFHLEVBQUUsS0FBSyxFQUFFLEVBQUUsQ0FBQyxHQUFHLEdBQUcsVUFBVSxDQUFDLEtBQUssQ0FBQyxJQUFJLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQztRQUM3RSxPQUFPLENBQUMsQ0FBQztZQUNQLE1BQU0sZUFBZSxHQUFVLElBQUksQ0FBQztZQUNwQyxNQUFNLElBQUksS0FBSyxDQUFDLHVCQUF1QixlQUFlLEVBQUUsQ0FBQyxDQUFDO1NBQzNEO0tBQ0Y7QUFDSCxDQUFDIn0=
@@ -1,42 +0,0 @@
1
- import { ABIParameter, FunctionAbi } from '@aztec/foundation/abi';
2
- import { Fr } from '@aztec/foundation/fields';
3
- /**
4
- * The type of our decoded ABI.
5
- */
6
- export type DecodedReturn = bigint | boolean | DecodedReturn[] | {
7
- [key: string]: DecodedReturn;
8
- };
9
- /**
10
- * Decodes return values from a function call.
11
- * @param abi - The ABI entry of the function.
12
- * @param returnValues - The decoded return values.
13
- * @returns
14
- */
15
- export declare function decodeReturnValues(abi: FunctionAbi, returnValues: Fr[]): DecodedReturn;
16
- /**
17
- * Decodes the signature of a function from the name and parameters.
18
- */
19
- export declare class FunctionSignatureDecoder {
20
- private name;
21
- private parameters;
22
- constructor(name: string, parameters: ABIParameter[]);
23
- /**
24
- * Decodes a single function parameter for the function signature.
25
- * @param param - The parameter to decode.
26
- * @returns A string representing the parameter type.
27
- */
28
- private decodeParameter;
29
- /**
30
- * Decodes all the parameters and build the function signature
31
- * @returns The function signature.
32
- */
33
- decode(): string;
34
- }
35
- /**
36
- * Decodes a function signature from the name and parameters.
37
- * @param name - The name of the function-
38
- * @param parameters - The parameters of the function.
39
- * @returns - The function signature.
40
- */
41
- export declare function decodeFunctionSignature(name: string, parameters: ABIParameter[]): string;
42
- //# sourceMappingURL=decoder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"decoder.d.ts","sourceRoot":"","sources":["../../src/abi/decoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAW,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,GAAG,aAAa,EAAE,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAAA;CAAE,CAAC;AAyElG;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,WAAW,EAAE,YAAY,EAAE,EAAE,EAAE,iBAEtE;AAED;;GAEG;AACH,qBAAa,wBAAwB;IACvB,OAAO,CAAC,IAAI;IAAU,OAAO,CAAC,UAAU;gBAAhC,IAAI,EAAE,MAAM,EAAU,UAAU,EAAE,YAAY,EAAE;IAEpE;;;;OAIG;IACH,OAAO,CAAC,eAAe;IAoBvB;;;OAGG;IACI,MAAM,IAAI,MAAM;CAGxB;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,UAE/E"}
@@ -1,129 +0,0 @@
1
- /**
2
- * Decodes return values from a function call.
3
- * Missing support for integer and string.
4
- */
5
- class ReturnValuesDecoder {
6
- constructor(abi, flattened) {
7
- this.abi = abi;
8
- this.flattened = flattened;
9
- }
10
- /**
11
- * Decodes a single return value from field to the given type.
12
- * @param abiType - The type of the return value.
13
- * @returns The decoded return value.
14
- */
15
- decodeReturn(abiType) {
16
- switch (abiType.kind) {
17
- case 'field':
18
- return this.getNextField().value;
19
- case 'integer':
20
- if (abiType.sign === 'signed') {
21
- throw new Error('Unsupported type: signed integer');
22
- }
23
- return this.getNextField().value;
24
- case 'boolean':
25
- return !this.getNextField().isZero();
26
- case 'array': {
27
- const array = [];
28
- for (let i = 0; i < abiType.length; i += 1) {
29
- array.push(this.decodeReturn(abiType.type));
30
- }
31
- return array;
32
- }
33
- case 'struct': {
34
- const struct = {};
35
- for (const field of abiType.fields) {
36
- struct[field.name] = this.decodeReturn(field.type);
37
- }
38
- return struct;
39
- }
40
- default:
41
- throw new Error(`Unsupported type: ${abiType.kind}`);
42
- }
43
- }
44
- /**
45
- * Gets the next field in the flattened return values.
46
- * @returns The next field in the flattened return values.
47
- */
48
- getNextField() {
49
- const field = this.flattened.shift();
50
- if (!field) {
51
- throw new Error('Not enough return values');
52
- }
53
- return field;
54
- }
55
- /**
56
- * Decodes all the return values for the given function ABI.
57
- * Noir support only single return value
58
- * The return value can however be simple types, structs or arrays
59
- * @returns The decoded return values.
60
- */
61
- decode() {
62
- if (this.abi.returnTypes.length > 1) {
63
- throw new Error('Multiple return values not supported');
64
- }
65
- if (this.abi.returnTypes.length === 0) {
66
- return [];
67
- }
68
- return this.decodeReturn(this.abi.returnTypes[0]);
69
- }
70
- }
71
- /**
72
- * Decodes return values from a function call.
73
- * @param abi - The ABI entry of the function.
74
- * @param returnValues - The decoded return values.
75
- * @returns
76
- */
77
- export function decodeReturnValues(abi, returnValues) {
78
- return new ReturnValuesDecoder(abi, returnValues.slice()).decode();
79
- }
80
- /**
81
- * Decodes the signature of a function from the name and parameters.
82
- */
83
- export class FunctionSignatureDecoder {
84
- constructor(name, parameters) {
85
- this.name = name;
86
- this.parameters = parameters;
87
- }
88
- /**
89
- * Decodes a single function parameter for the function signature.
90
- * @param param - The parameter to decode.
91
- * @returns A string representing the parameter type.
92
- */
93
- decodeParameter(param) {
94
- switch (param.kind) {
95
- case 'field':
96
- return 'Field';
97
- case 'integer':
98
- if (param.sign === 'signed') {
99
- throw new Error('Unsupported type: signed integer');
100
- }
101
- return `u${param.width}`;
102
- case 'boolean':
103
- return 'bool';
104
- case 'array':
105
- return `[${this.decodeParameter(param.type)};${param.length}]`;
106
- case 'struct':
107
- return `(${param.fields.map(field => `${this.decodeParameter(field.type)}`).join(',')})`;
108
- default:
109
- throw new Error(`Unsupported type: ${param.kind}`);
110
- }
111
- }
112
- /**
113
- * Decodes all the parameters and build the function signature
114
- * @returns The function signature.
115
- */
116
- decode() {
117
- return `${this.name}(${this.parameters.map(param => this.decodeParameter(param.type)).join(',')})`;
118
- }
119
- }
120
- /**
121
- * Decodes a function signature from the name and parameters.
122
- * @param name - The name of the function-
123
- * @param parameters - The parameters of the function.
124
- * @returns - The function signature.
125
- */
126
- export function decodeFunctionSignature(name, parameters) {
127
- return new FunctionSignatureDecoder(name, parameters).decode();
128
- }
129
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVjb2Rlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9hYmkvZGVjb2Rlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFRQTs7O0dBR0c7QUFDSCxNQUFNLG1CQUFtQjtJQUN2QixZQUFvQixHQUFnQixFQUFVLFNBQWU7UUFBekMsUUFBRyxHQUFILEdBQUcsQ0FBYTtRQUFVLGNBQVMsR0FBVCxTQUFTLENBQU07SUFBRyxDQUFDO0lBRWpFOzs7O09BSUc7SUFDSyxZQUFZLENBQUMsT0FBZ0I7UUFDbkMsUUFBUSxPQUFPLENBQUMsSUFBSSxFQUFFO1lBQ3BCLEtBQUssT0FBTztnQkFDVixPQUFPLElBQUksQ0FBQyxZQUFZLEVBQUUsQ0FBQyxLQUFLLENBQUM7WUFDbkMsS0FBSyxTQUFTO2dCQUNaLElBQUksT0FBTyxDQUFDLElBQUksS0FBSyxRQUFRLEVBQUU7b0JBQzdCLE1BQU0sSUFBSSxLQUFLLENBQUMsa0NBQWtDLENBQUMsQ0FBQztpQkFDckQ7Z0JBQ0QsT0FBTyxJQUFJLENBQUMsWUFBWSxFQUFFLENBQUMsS0FBSyx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0FBQyxJQUFJLEVBQUUsVUFBVSxDQUFDLENBQUMsTUFBTSxFQUFFLENBQUM7QUFDakUsQ0FBQyJ9
@@ -1,10 +0,0 @@
1
- import { FunctionAbi } from '@aztec/foundation/abi';
2
- import { Fr } from '@aztec/foundation/fields';
3
- /**
4
- * Encodes all the arguments for a function call.
5
- * @param abi - The function ABI entry.
6
- * @param args - The arguments to encode.
7
- * @returns The encoded arguments.
8
- */
9
- export declare function encodeArguments(abi: FunctionAbi, args: any[]): Fr[];
10
- //# sourceMappingURL=encoder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"encoder.d.ts","sourceRoot":"","sources":["../../src/abi/encoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AA2E9C;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,EAAE,QAE5D"}
@@ -1,89 +0,0 @@
1
- import { Fr } from '@aztec/foundation/fields';
2
- /**
3
- * Encodes arguments for a function call.
4
- * Missing support for integer and string.
5
- */
6
- class ArgumentEncoder {
7
- constructor(abi, args) {
8
- this.abi = abi;
9
- this.args = args;
10
- this.flattened = [];
11
- }
12
- /**
13
- * Encodes a single argument from the given type to field.
14
- * @param abiType - The abi type of the argument.
15
- * @param arg - The value to encode.
16
- * @param name - Name.
17
- */
18
- encodeArgument(abiType, arg, name) {
19
- if (arg === undefined || arg == null) {
20
- throw new Error(`Undefined argument ${name ?? 'unnamed'} of type ${abiType.kind}`);
21
- }
22
- switch (abiType.kind) {
23
- case 'field':
24
- if (typeof arg === 'number') {
25
- this.flattened.push(new Fr(BigInt(arg)));
26
- }
27
- else if (typeof arg === 'bigint') {
28
- this.flattened.push(new Fr(arg));
29
- }
30
- else if (typeof arg === 'object') {
31
- if (Buffer.isBuffer(arg)) {
32
- this.flattened.push(Fr.fromBuffer(arg));
33
- }
34
- else if (typeof arg.toField === 'function') {
35
- this.flattened.push(arg.toField());
36
- }
37
- else if (arg instanceof Fr) {
38
- this.flattened.push(arg);
39
- }
40
- else {
41
- throw new Error(`Argument for ${name} cannot be serialised to a field`);
42
- }
43
- }
44
- else {
45
- throw new Error(`Invalid argument "${arg}" of type ${abiType.kind}`);
46
- }
47
- break;
48
- case 'boolean':
49
- this.flattened.push(new Fr(arg ? 1n : 0n));
50
- break;
51
- case 'array':
52
- for (let i = 0; i < abiType.length; i += 1) {
53
- this.encodeArgument(abiType.type, arg[i], `${name}[${i}]`);
54
- }
55
- break;
56
- case 'struct':
57
- for (const field of abiType.fields) {
58
- this.encodeArgument(field.type, arg[field.name], `${name}.${field.name}`);
59
- }
60
- break;
61
- case 'integer':
62
- this.flattened.push(new Fr(arg));
63
- break;
64
- default:
65
- throw new Error(`Unsupported type: ${abiType.kind}`);
66
- }
67
- }
68
- /**
69
- * Encodes all the arguments for the given function ABI.
70
- * @returns The encoded arguments.
71
- */
72
- encode() {
73
- for (let i = 0; i < this.abi.parameters.length; i += 1) {
74
- const parameterAbi = this.abi.parameters[i];
75
- this.encodeArgument(parameterAbi.type, this.args[i], parameterAbi.name);
76
- }
77
- return this.flattened;
78
- }
79
- }
80
- /**
81
- * Encodes all the arguments for a function call.
82
- * @param abi - The function ABI entry.
83
- * @param args - The arguments to encode.
84
- * @returns The encoded arguments.
85
- */
86
- export function encodeArguments(abi, args) {
87
- return new ArgumentEncoder(abi, args).encode();
88
- }
89
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZW5jb2Rlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9hYmkvZW5jb2Rlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sMEJBQTBCLENBQUM7QUFFOUM7OztHQUdHO0FB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