@aeternity/aepp-sdk 13.2.1 → 13.3.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 (509) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -1
  3. package/bin/aesophia_cli +0 -0
  4. package/bin/aesophia_cli_8 +0 -0
  5. package/dist/aepp-sdk.browser-script.js +1 -1
  6. package/dist/aepp-sdk.browser-script.js.map +1 -1
  7. package/dist/aepp-sdk.browser.js +1 -1
  8. package/dist/aepp-sdk.browser.js.map +1 -1
  9. package/dist/aepp-sdk.js +7288 -9464
  10. package/dist/aepp-sdk.js.map +1 -1
  11. package/es/AeSdk.d.ts +3 -0
  12. package/es/AeSdk.mjs +12 -12
  13. package/es/AeSdk.mjs.map +1 -1
  14. package/es/AeSdkAepp.d.ts +0 -1
  15. package/es/AeSdkAepp.mjs +12 -16
  16. package/es/AeSdkAepp.mjs.map +1 -1
  17. package/es/AeSdkBase.d.ts +61 -6
  18. package/es/AeSdkBase.mjs +150 -69
  19. package/es/AeSdkBase.mjs.map +1 -1
  20. package/es/AeSdkMethods.d.ts +19 -7
  21. package/es/AeSdkMethods.mjs +39 -38
  22. package/es/AeSdkMethods.mjs.map +1 -1
  23. package/es/AeSdkWallet.mjs +86 -55
  24. package/es/AeSdkWallet.mjs.map +1 -1
  25. package/es/Middleware.d.ts +1 -1
  26. package/es/Middleware.mjs +32 -28
  27. package/es/Middleware.mjs.map +1 -1
  28. package/es/MiddlewareSubscriber.mjs +5 -14
  29. package/es/MiddlewareSubscriber.mjs.map +1 -1
  30. package/es/Node.d.ts +11 -3
  31. package/es/Node.mjs +65 -57
  32. package/es/Node.mjs.map +1 -1
  33. package/es/account/Base.d.ts +39 -3
  34. package/es/account/Base.mjs +35 -1
  35. package/es/account/Base.mjs.map +1 -1
  36. package/es/account/Generalized.d.ts +2 -0
  37. package/es/account/Generalized.mjs +15 -6
  38. package/es/account/Generalized.mjs.map +1 -1
  39. package/es/account/Ledger.d.ts +2 -0
  40. package/es/account/Ledger.mjs +14 -5
  41. package/es/account/Ledger.mjs.map +1 -1
  42. package/es/account/LedgerFactory.mjs +4 -6
  43. package/es/account/LedgerFactory.mjs.map +1 -1
  44. package/es/account/Memory.d.ts +15 -4
  45. package/es/account/Memory.mjs +96 -31
  46. package/es/account/Memory.mjs.map +1 -1
  47. package/es/account/Rpc.d.ts +16 -5
  48. package/es/account/Rpc.mjs +94 -21
  49. package/es/account/Rpc.mjs.map +1 -1
  50. package/es/aens.d.ts +17 -44
  51. package/es/aens.mjs +32 -71
  52. package/es/aens.mjs.map +1 -1
  53. package/es/aepp-wallet-communication/connection/Browser.mjs +3 -4
  54. package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -1
  55. package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +3 -0
  56. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +7 -5
  57. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
  58. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +8 -9
  59. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -1
  60. package/es/aepp-wallet-communication/rpc/RpcClient.mjs +7 -7
  61. package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
  62. package/es/aepp-wallet-communication/rpc/types.d.ts +14 -0
  63. package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
  64. package/es/aepp-wallet-communication/schema.d.ts +2 -0
  65. package/es/aepp-wallet-communication/schema.mjs +2 -0
  66. package/es/aepp-wallet-communication/schema.mjs.map +1 -1
  67. package/es/aepp-wallet-communication/wallet-detector.d.ts +2 -5
  68. package/es/aepp-wallet-communication/wallet-detector.mjs +13 -9
  69. package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
  70. package/es/apis/compiler/compiler.mjs.map +1 -1
  71. package/es/apis/compiler/models/index.d.ts +1 -0
  72. package/es/apis/compiler/models/index.mjs.map +1 -1
  73. package/es/apis/compiler/models/mappers.mjs +13 -0
  74. package/es/apis/compiler/models/mappers.mjs.map +1 -1
  75. package/es/apis/compiler/models/parameters.mjs.map +1 -1
  76. package/es/apis/middleware/middleware.d.ts +23 -5
  77. package/es/apis/middleware/middleware.mjs +114 -18
  78. package/es/apis/middleware/middleware.mjs.map +1 -1
  79. package/es/apis/middleware/models/index.d.ts +164 -15
  80. package/es/apis/middleware/models/index.mjs +53 -3
  81. package/es/apis/middleware/models/index.mjs.map +1 -1
  82. package/es/apis/middleware/models/mappers.d.ts +8 -1
  83. package/es/apis/middleware/models/mappers.mjs +376 -3
  84. package/es/apis/middleware/models/mappers.mjs.map +1 -1
  85. package/es/apis/middleware/models/parameters.d.ts +6 -3
  86. package/es/apis/middleware/models/parameters.mjs +38 -11
  87. package/es/apis/middleware/models/parameters.mjs.map +1 -1
  88. package/es/apis/node/models/index.d.ts +66 -2
  89. package/es/apis/node/models/index.mjs.map +1 -1
  90. package/es/apis/node/models/mappers.d.ts +5 -1
  91. package/es/apis/node/models/mappers.mjs +229 -7
  92. package/es/apis/node/models/mappers.mjs.map +1 -1
  93. package/es/apis/node/models/parameters.d.ts +2 -2
  94. package/es/apis/node/models/parameters.mjs +2 -2
  95. package/es/apis/node/models/parameters.mjs.map +1 -1
  96. package/es/apis/node/node.d.ts +24 -3
  97. package/es/apis/node/node.mjs +135 -3
  98. package/es/apis/node/node.mjs.map +1 -1
  99. package/es/chain.d.ts +14 -44
  100. package/es/chain.mjs +125 -219
  101. package/es/chain.mjs.map +1 -1
  102. package/es/channel/Base.d.ts +3 -47
  103. package/es/channel/Base.mjs +21 -54
  104. package/es/channel/Base.mjs.map +1 -1
  105. package/es/channel/Contract.d.ts +16 -25
  106. package/es/channel/Contract.mjs +39 -63
  107. package/es/channel/Contract.mjs.map +1 -1
  108. package/es/channel/Spend.d.ts +0 -8
  109. package/es/channel/Spend.mjs +17 -29
  110. package/es/channel/Spend.mjs.map +1 -1
  111. package/es/channel/handlers.mjs +1 -1
  112. package/es/channel/handlers.mjs.map +1 -1
  113. package/es/channel/internal.d.ts +104 -5
  114. package/es/channel/internal.mjs +26 -34
  115. package/es/channel/internal.mjs.map +1 -1
  116. package/es/contract/Contract.d.ts +10 -2
  117. package/es/contract/Contract.mjs +83 -79
  118. package/es/contract/Contract.mjs.map +1 -1
  119. package/es/contract/compiler/Base.d.ts +14 -8
  120. package/es/contract/compiler/Base.mjs.map +1 -1
  121. package/es/contract/compiler/Cli.d.ts +12 -11
  122. package/es/contract/compiler/Cli.mjs +52 -25
  123. package/es/contract/compiler/Cli.mjs.map +1 -1
  124. package/es/contract/compiler/Cli8.d.ts +13 -0
  125. package/es/contract/compiler/Cli8.mjs +22 -0
  126. package/es/contract/compiler/Cli8.mjs.map +1 -0
  127. package/es/contract/compiler/Http.d.ts +3 -9
  128. package/es/contract/compiler/Http.mjs +28 -16
  129. package/es/contract/compiler/Http.mjs.map +1 -1
  130. package/es/contract/compiler/HttpNode.d.ts +2 -5
  131. package/es/contract/compiler/HttpNode.mjs.map +1 -1
  132. package/es/contract/delegation-signature.d.ts +2 -1
  133. package/es/contract/delegation-signature.mjs +18 -14
  134. package/es/contract/delegation-signature.mjs.map +1 -1
  135. package/es/contract/ga.d.ts +1 -2
  136. package/es/contract/ga.mjs +23 -25
  137. package/es/contract/ga.mjs.map +1 -1
  138. package/es/deprecated.d.ts +48 -0
  139. package/es/deprecated.mjs +66 -1
  140. package/es/deprecated.mjs.map +1 -1
  141. package/es/index-browser.d.ts +11 -6
  142. package/es/index-browser.mjs +10 -6
  143. package/es/index-browser.mjs.map +1 -1
  144. package/es/index.d.ts +1 -0
  145. package/es/index.mjs +1 -0
  146. package/es/index.mjs.map +1 -1
  147. package/es/oracle.d.ts +6 -37
  148. package/es/oracle.mjs +32 -66
  149. package/es/oracle.mjs.map +1 -1
  150. package/es/send-transaction.d.ts +53 -0
  151. package/es/send-transaction.mjs +109 -0
  152. package/es/send-transaction.mjs.map +1 -0
  153. package/es/spend.d.ts +4 -3
  154. package/es/spend.mjs +6 -1
  155. package/es/spend.mjs.map +1 -1
  156. package/es/tx/builder/common.d.ts +29 -0
  157. package/es/tx/builder/common.mjs +42 -0
  158. package/es/tx/builder/common.mjs.map +1 -0
  159. package/es/tx/builder/constants.d.ts +6 -5
  160. package/es/tx/builder/constants.mjs +7 -15
  161. package/es/tx/builder/constants.mjs.map +1 -1
  162. package/es/tx/builder/delegation/index.d.ts +20 -0
  163. package/es/tx/builder/delegation/index.mjs +24 -0
  164. package/es/tx/builder/delegation/index.mjs.map +1 -0
  165. package/es/tx/builder/delegation/schema.d.ts +130 -0
  166. package/es/tx/builder/delegation/schema.generated.d.ts +141 -0
  167. package/es/tx/builder/delegation/schema.generated.mjs +2 -0
  168. package/es/tx/builder/delegation/schema.generated.mjs.map +1 -0
  169. package/es/tx/builder/delegation/schema.mjs +54 -0
  170. package/es/tx/builder/delegation/schema.mjs.map +1 -0
  171. package/es/tx/builder/field-types/abi-version.mjs +8 -11
  172. package/es/tx/builder/field-types/abi-version.mjs.map +1 -1
  173. package/es/tx/builder/field-types/address.mjs +1 -4
  174. package/es/tx/builder/field-types/address.mjs.map +1 -1
  175. package/es/tx/builder/field-types/coin-amount.d.ts +2 -2
  176. package/es/tx/builder/field-types/coin-amount.mjs +6 -6
  177. package/es/tx/builder/field-types/coin-amount.mjs.map +1 -1
  178. package/es/tx/builder/field-types/ct-version.d.ts +1 -1
  179. package/es/tx/builder/field-types/ct-version.mjs +4 -5
  180. package/es/tx/builder/field-types/ct-version.mjs.map +1 -1
  181. package/es/tx/builder/field-types/entry.mjs +7 -13
  182. package/es/tx/builder/field-types/entry.mjs.map +1 -1
  183. package/es/tx/builder/field-types/fee.d.ts +19 -11
  184. package/es/tx/builder/field-types/fee.mjs +57 -39
  185. package/es/tx/builder/field-types/fee.mjs.map +1 -1
  186. package/es/tx/builder/field-types/gas-limit.mjs +13 -15
  187. package/es/tx/builder/field-types/gas-limit.mjs.map +1 -1
  188. package/es/tx/builder/field-types/gas-price.d.ts +10 -2
  189. package/es/tx/builder/field-types/gas-price.mjs +53 -4
  190. package/es/tx/builder/field-types/gas-price.mjs.map +1 -1
  191. package/es/tx/builder/field-types/index.d.ts +31 -29
  192. package/es/tx/builder/field-types/index.mjs +31 -29
  193. package/es/tx/builder/field-types/index.mjs.map +1 -1
  194. package/es/tx/builder/field-types/map.mjs +20 -31
  195. package/es/tx/builder/field-types/map.mjs.map +1 -1
  196. package/es/tx/builder/field-types/mptree.mjs +14 -29
  197. package/es/tx/builder/field-types/mptree.mjs.map +1 -1
  198. package/es/tx/builder/field-types/name-fee.d.ts +1 -1
  199. package/es/tx/builder/field-types/name-fee.mjs +1 -1
  200. package/es/tx/builder/field-types/name-fee.mjs.map +1 -1
  201. package/es/tx/builder/field-types/nonce.d.ts +1 -0
  202. package/es/tx/builder/field-types/nonce.mjs +2 -0
  203. package/es/tx/builder/field-types/nonce.mjs.map +1 -1
  204. package/es/tx/builder/field-types/pointers.mjs +4 -7
  205. package/es/tx/builder/field-types/pointers.mjs.map +1 -1
  206. package/es/tx/builder/field-types/pointers2.d.ts +23 -0
  207. package/es/tx/builder/field-types/pointers2.mjs +65 -0
  208. package/es/tx/builder/field-types/pointers2.mjs.map +1 -0
  209. package/es/tx/builder/field-types/query-fee.d.ts +19 -0
  210. package/es/tx/builder/field-types/query-fee.mjs +20 -0
  211. package/es/tx/builder/field-types/query-fee.mjs.map +1 -0
  212. package/es/tx/builder/field-types/ttl.d.ts +9 -1
  213. package/es/tx/builder/field-types/ttl.mjs +19 -8
  214. package/es/tx/builder/field-types/ttl.mjs.map +1 -1
  215. package/es/tx/builder/field-types/with-default.d.ts +7 -0
  216. package/es/tx/builder/field-types/with-default.mjs +9 -0
  217. package/es/tx/builder/field-types/with-default.mjs.map +1 -0
  218. package/es/tx/builder/field-types/with-formatting.d.ts +7 -0
  219. package/es/tx/builder/field-types/with-formatting.mjs +9 -0
  220. package/es/tx/builder/field-types/with-formatting.mjs.map +1 -0
  221. package/es/tx/builder/field-types/wrapped.mjs +6 -8
  222. package/es/tx/builder/field-types/wrapped.mjs.map +1 -1
  223. package/es/tx/builder/helpers.d.ts +2 -2
  224. package/es/tx/builder/helpers.mjs +12 -21
  225. package/es/tx/builder/helpers.mjs.map +1 -1
  226. package/es/tx/builder/index.d.ts +17 -10
  227. package/es/tx/builder/index.mjs +39 -65
  228. package/es/tx/builder/index.mjs.map +1 -1
  229. package/es/tx/builder/schema.d.ts +478 -257
  230. package/es/tx/builder/schema.generated.d.ts +39 -3
  231. package/es/tx/builder/schema.generated.mjs.map +1 -1
  232. package/es/tx/builder/schema.mjs +48 -36
  233. package/es/tx/builder/schema.mjs.map +1 -1
  234. package/es/tx/execution-cost.d.ts +6 -5
  235. package/es/tx/execution-cost.mjs +16 -17
  236. package/es/tx/execution-cost.mjs.map +1 -1
  237. package/es/tx/transaction-signer.mjs +1 -4
  238. package/es/tx/transaction-signer.mjs.map +1 -1
  239. package/es/tx/validator.mjs +61 -42
  240. package/es/tx/validator.mjs.map +1 -1
  241. package/es/utils/amount-formatter.mjs +15 -22
  242. package/es/utils/amount-formatter.mjs.map +1 -1
  243. package/es/utils/autorest.d.ts +2 -3
  244. package/es/utils/autorest.mjs +41 -25
  245. package/es/utils/autorest.mjs.map +1 -1
  246. package/es/utils/bytes.mjs +1 -2
  247. package/es/utils/bytes.mjs.map +1 -1
  248. package/es/utils/crypto.d.ts +9 -5
  249. package/es/utils/crypto.mjs +18 -14
  250. package/es/utils/crypto.mjs.map +1 -1
  251. package/es/utils/errors.d.ts +6 -0
  252. package/es/utils/errors.mjs +12 -6
  253. package/es/utils/errors.mjs.map +1 -1
  254. package/es/utils/hd-wallet.d.ts +2 -0
  255. package/es/utils/hd-wallet.mjs +6 -5
  256. package/es/utils/hd-wallet.mjs.map +1 -1
  257. package/es/utils/json-big.mjs +2 -10
  258. package/es/utils/json-big.mjs.map +1 -1
  259. package/es/utils/jwt.d.ts +53 -0
  260. package/es/utils/jwt.mjs +120 -0
  261. package/es/utils/jwt.mjs.map +1 -0
  262. package/es/utils/keystore.d.ts +6 -2
  263. package/es/utils/keystore.mjs +8 -16
  264. package/es/utils/keystore.mjs.map +1 -1
  265. package/es/utils/typed-data.d.ts +0 -2
  266. package/es/utils/typed-data.mjs +8 -23
  267. package/es/utils/typed-data.mjs.map +1 -1
  268. package/es/utils/wrap-proxy.d.ts +2 -0
  269. package/es/utils/wrap-proxy.mjs +15 -0
  270. package/es/utils/wrap-proxy.mjs.map +1 -0
  271. package/package.json +57 -51
  272. package/src/AeSdk.ts +3 -0
  273. package/src/AeSdkAepp.ts +0 -1
  274. package/src/AeSdkBase.ts +97 -10
  275. package/src/AeSdkMethods.ts +37 -33
  276. package/src/AeSdkWallet.ts +22 -3
  277. package/src/Middleware.ts +17 -9
  278. package/src/MiddlewareSubscriber.ts +1 -1
  279. package/src/Node.ts +51 -21
  280. package/src/account/Base.ts +62 -3
  281. package/src/account/Generalized.ts +10 -0
  282. package/src/account/Ledger.ts +10 -0
  283. package/src/account/Memory.ts +83 -9
  284. package/src/account/Rpc.ts +69 -6
  285. package/src/aens.ts +35 -56
  286. package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +3 -0
  287. package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +2 -2
  288. package/src/aepp-wallet-communication/rpc/RpcClient.ts +4 -2
  289. package/src/aepp-wallet-communication/rpc/types.ts +14 -1
  290. package/src/aepp-wallet-communication/schema.ts +2 -0
  291. package/src/aepp-wallet-communication/wallet-detector.ts +10 -10
  292. package/src/apis/compiler/compiler.ts +93 -93
  293. package/src/apis/compiler/models/index.ts +1 -0
  294. package/src/apis/compiler/models/mappers.ts +178 -165
  295. package/src/apis/compiler/models/parameters.ts +18 -18
  296. package/src/apis/middleware/middleware.ts +462 -341
  297. package/src/apis/middleware/models/index.ts +258 -56
  298. package/src/apis/middleware/models/mappers.ts +2357 -1919
  299. package/src/apis/middleware/models/parameters.ts +172 -142
  300. package/src/apis/node/models/index.ts +79 -2
  301. package/src/apis/node/models/mappers.ts +1529 -1302
  302. package/src/apis/node/models/parameters.ts +51 -51
  303. package/src/apis/node/node.ts +420 -275
  304. package/src/chain.ts +42 -128
  305. package/src/channel/Base.ts +14 -47
  306. package/src/channel/Contract.ts +18 -26
  307. package/src/channel/Spend.ts +0 -8
  308. package/src/channel/internal.ts +115 -13
  309. package/src/contract/Contract.ts +36 -12
  310. package/src/contract/compiler/Base.ts +15 -8
  311. package/src/contract/compiler/Cli.ts +44 -23
  312. package/src/contract/compiler/Cli8.ts +17 -0
  313. package/src/contract/compiler/Http.ts +24 -14
  314. package/src/contract/compiler/HttpNode.ts +2 -2
  315. package/src/contract/delegation-signature.ts +11 -5
  316. package/src/contract/ga.ts +4 -3
  317. package/src/deprecated.ts +55 -1
  318. package/src/index-browser.ts +18 -11
  319. package/src/index.ts +1 -0
  320. package/src/oracle.ts +11 -54
  321. package/src/send-transaction.ts +136 -0
  322. package/src/spend.ts +25 -11
  323. package/src/tx/builder/common.ts +74 -0
  324. package/src/tx/builder/constants.ts +7 -9
  325. package/src/tx/builder/delegation/index.ts +28 -0
  326. package/src/tx/builder/delegation/schema.generated.ts +143 -0
  327. package/src/tx/builder/delegation/schema.ts +61 -0
  328. package/src/tx/builder/field-types/coin-amount.ts +3 -2
  329. package/src/tx/builder/field-types/ct-version.ts +1 -1
  330. package/src/tx/builder/field-types/entry.ts +1 -4
  331. package/src/tx/builder/field-types/fee.ts +72 -44
  332. package/src/tx/builder/field-types/gas-limit.ts +4 -4
  333. package/src/tx/builder/field-types/gas-price.ts +59 -3
  334. package/src/tx/builder/field-types/index.ts +31 -59
  335. package/src/tx/builder/field-types/name-fee.ts +1 -1
  336. package/src/tx/builder/field-types/nonce.ts +7 -1
  337. package/src/tx/builder/field-types/pointers2.ts +62 -0
  338. package/src/tx/builder/field-types/query-fee.ts +25 -0
  339. package/src/tx/builder/field-types/ttl.ts +13 -3
  340. package/src/tx/builder/field-types/with-default.ts +18 -0
  341. package/src/tx/builder/field-types/with-formatting.ts +18 -0
  342. package/src/tx/builder/helpers.ts +2 -2
  343. package/src/tx/builder/index.ts +42 -59
  344. package/src/tx/builder/schema.generated.ts +39 -3
  345. package/src/tx/builder/schema.ts +55 -29
  346. package/src/tx/execution-cost.ts +6 -5
  347. package/src/tx/validator.ts +31 -5
  348. package/src/utils/autorest.ts +37 -28
  349. package/src/utils/crypto.ts +24 -14
  350. package/src/utils/errors.ts +10 -0
  351. package/src/utils/hd-wallet.ts +2 -0
  352. package/src/utils/jwt.ts +126 -0
  353. package/src/utils/keystore.ts +6 -2
  354. package/src/utils/typed-data.ts +4 -30
  355. package/src/utils/wrap-proxy.ts +24 -0
  356. package/types-legacy/ts4.2/AeSdk.d.ts +3 -0
  357. package/types-legacy/ts4.2/AeSdkAepp.d.ts +0 -1
  358. package/types-legacy/ts4.2/AeSdkBase.d.ts +61 -6
  359. package/types-legacy/ts4.2/AeSdkMethods.d.ts +19 -7
  360. package/types-legacy/ts4.2/Middleware.d.ts +1 -1
  361. package/types-legacy/ts4.2/Node.d.ts +15 -2
  362. package/types-legacy/ts4.2/account/Base.d.ts +39 -3
  363. package/types-legacy/ts4.2/account/Generalized.d.ts +2 -0
  364. package/types-legacy/ts4.2/account/Ledger.d.ts +2 -0
  365. package/types-legacy/ts4.2/account/Memory.d.ts +15 -4
  366. package/types-legacy/ts4.2/account/Rpc.d.ts +16 -5
  367. package/types-legacy/ts4.2/aens.d.ts +17 -44
  368. package/types-legacy/ts4.2/aepp-wallet-communication/connection/BrowserRuntime.d.ts +3 -0
  369. package/types-legacy/ts4.2/aepp-wallet-communication/rpc/types.d.ts +14 -0
  370. package/types-legacy/ts4.2/aepp-wallet-communication/schema.d.ts +2 -0
  371. package/types-legacy/ts4.2/aepp-wallet-communication/wallet-detector.d.ts +2 -5
  372. package/types-legacy/ts4.2/apis/compiler/models/index.d.ts +1 -0
  373. package/types-legacy/ts4.2/apis/middleware/middleware.d.ts +23 -5
  374. package/types-legacy/ts4.2/apis/middleware/models/index.d.ts +164 -15
  375. package/types-legacy/ts4.2/apis/middleware/models/mappers.d.ts +8 -1
  376. package/types-legacy/ts4.2/apis/middleware/models/parameters.d.ts +6 -3
  377. package/types-legacy/ts4.2/apis/node/models/index.d.ts +66 -2
  378. package/types-legacy/ts4.2/apis/node/models/mappers.d.ts +5 -1
  379. package/types-legacy/ts4.2/apis/node/models/parameters.d.ts +2 -2
  380. package/types-legacy/ts4.2/apis/node/node.d.ts +24 -3
  381. package/types-legacy/ts4.2/chain.d.ts +14 -44
  382. package/types-legacy/ts4.2/channel/Base.d.ts +3 -47
  383. package/types-legacy/ts4.2/channel/Contract.d.ts +16 -25
  384. package/types-legacy/ts4.2/channel/Spend.d.ts +0 -8
  385. package/types-legacy/ts4.2/channel/internal.d.ts +104 -5
  386. package/types-legacy/ts4.2/contract/Contract.d.ts +10 -2
  387. package/types-legacy/ts4.2/contract/compiler/Base.d.ts +14 -8
  388. package/types-legacy/ts4.2/contract/compiler/Cli.d.ts +12 -11
  389. package/types-legacy/ts4.2/contract/compiler/Cli8.d.ts +13 -0
  390. package/types-legacy/ts4.2/contract/compiler/Http.d.ts +3 -9
  391. package/types-legacy/ts4.2/contract/compiler/HttpNode.d.ts +2 -5
  392. package/types-legacy/ts4.2/contract/delegation-signature.d.ts +2 -1
  393. package/types-legacy/ts4.2/contract/ga.d.ts +1 -2
  394. package/types-legacy/ts4.2/deprecated.d.ts +48 -0
  395. package/types-legacy/ts4.2/index-browser.d.ts +11 -6
  396. package/types-legacy/ts4.2/index.d.ts +1 -0
  397. package/types-legacy/ts4.2/oracle.d.ts +6 -37
  398. package/types-legacy/ts4.2/send-transaction.d.ts +53 -0
  399. package/types-legacy/ts4.2/spend.d.ts +4 -3
  400. package/types-legacy/ts4.2/tx/builder/common.d.ts +32 -0
  401. package/types-legacy/ts4.2/tx/builder/constants.d.ts +6 -5
  402. package/types-legacy/ts4.2/tx/builder/delegation/index.d.ts +20 -0
  403. package/types-legacy/ts4.2/tx/builder/delegation/schema.d.ts +136 -0
  404. package/types-legacy/ts4.2/tx/builder/delegation/schema.generated.d.ts +141 -0
  405. package/types-legacy/ts4.2/tx/builder/field-types/coin-amount.d.ts +2 -2
  406. package/types-legacy/ts4.2/tx/builder/field-types/ct-version.d.ts +1 -1
  407. package/types-legacy/ts4.2/tx/builder/field-types/fee.d.ts +19 -11
  408. package/types-legacy/ts4.2/tx/builder/field-types/gas-price.d.ts +10 -2
  409. package/types-legacy/ts4.2/tx/builder/field-types/index.d.ts +31 -29
  410. package/types-legacy/ts4.2/tx/builder/field-types/name-fee.d.ts +1 -1
  411. package/types-legacy/ts4.2/tx/builder/field-types/nonce.d.ts +1 -0
  412. package/types-legacy/ts4.2/tx/builder/field-types/pointers2.d.ts +26 -0
  413. package/types-legacy/ts4.2/tx/builder/field-types/query-fee.d.ts +19 -0
  414. package/types-legacy/ts4.2/tx/builder/field-types/ttl.d.ts +9 -1
  415. package/types-legacy/ts4.2/tx/builder/field-types/with-default.d.ts +7 -0
  416. package/types-legacy/ts4.2/tx/builder/field-types/with-formatting.d.ts +7 -0
  417. package/types-legacy/ts4.2/tx/builder/helpers.d.ts +2 -2
  418. package/types-legacy/ts4.2/tx/builder/index.d.ts +17 -10
  419. package/types-legacy/ts4.2/tx/builder/schema.d.ts +482 -257
  420. package/types-legacy/ts4.2/tx/builder/schema.generated.d.ts +39 -3
  421. package/types-legacy/ts4.2/tx/execution-cost.d.ts +6 -5
  422. package/types-legacy/ts4.2/utils/autorest.d.ts +2 -3
  423. package/types-legacy/ts4.2/utils/crypto.d.ts +9 -5
  424. package/types-legacy/ts4.2/utils/errors.d.ts +6 -0
  425. package/types-legacy/ts4.2/utils/hd-wallet.d.ts +2 -0
  426. package/types-legacy/ts4.2/utils/jwt.d.ts +53 -0
  427. package/types-legacy/ts4.2/utils/keystore.d.ts +6 -2
  428. package/types-legacy/ts4.2/utils/typed-data.d.ts +0 -2
  429. package/types-legacy/ts4.2/utils/wrap-proxy.d.ts +2 -0
  430. package/types-legacy/ts4.5/AeSdk.d.ts +3 -0
  431. package/types-legacy/ts4.5/AeSdkAepp.d.ts +0 -1
  432. package/types-legacy/ts4.5/AeSdkBase.d.ts +61 -6
  433. package/types-legacy/ts4.5/AeSdkMethods.d.ts +19 -7
  434. package/types-legacy/ts4.5/Middleware.d.ts +1 -1
  435. package/types-legacy/ts4.5/Node.d.ts +15 -2
  436. package/types-legacy/ts4.5/account/Base.d.ts +39 -3
  437. package/types-legacy/ts4.5/account/Generalized.d.ts +2 -0
  438. package/types-legacy/ts4.5/account/Ledger.d.ts +2 -0
  439. package/types-legacy/ts4.5/account/Memory.d.ts +15 -4
  440. package/types-legacy/ts4.5/account/Rpc.d.ts +16 -5
  441. package/types-legacy/ts4.5/aens.d.ts +17 -44
  442. package/types-legacy/ts4.5/aepp-wallet-communication/connection/BrowserRuntime.d.ts +3 -0
  443. package/types-legacy/ts4.5/aepp-wallet-communication/rpc/types.d.ts +14 -0
  444. package/types-legacy/ts4.5/aepp-wallet-communication/schema.d.ts +2 -0
  445. package/types-legacy/ts4.5/aepp-wallet-communication/wallet-detector.d.ts +2 -5
  446. package/types-legacy/ts4.5/apis/compiler/models/index.d.ts +1 -0
  447. package/types-legacy/ts4.5/apis/middleware/middleware.d.ts +23 -5
  448. package/types-legacy/ts4.5/apis/middleware/models/index.d.ts +164 -15
  449. package/types-legacy/ts4.5/apis/middleware/models/mappers.d.ts +8 -1
  450. package/types-legacy/ts4.5/apis/middleware/models/parameters.d.ts +6 -3
  451. package/types-legacy/ts4.5/apis/node/models/index.d.ts +66 -2
  452. package/types-legacy/ts4.5/apis/node/models/mappers.d.ts +5 -1
  453. package/types-legacy/ts4.5/apis/node/models/parameters.d.ts +2 -2
  454. package/types-legacy/ts4.5/apis/node/node.d.ts +24 -3
  455. package/types-legacy/ts4.5/chain.d.ts +14 -44
  456. package/types-legacy/ts4.5/channel/Base.d.ts +3 -47
  457. package/types-legacy/ts4.5/channel/Contract.d.ts +16 -25
  458. package/types-legacy/ts4.5/channel/Spend.d.ts +0 -8
  459. package/types-legacy/ts4.5/channel/internal.d.ts +104 -5
  460. package/types-legacy/ts4.5/contract/Contract.d.ts +10 -2
  461. package/types-legacy/ts4.5/contract/compiler/Base.d.ts +14 -8
  462. package/types-legacy/ts4.5/contract/compiler/Cli.d.ts +12 -11
  463. package/types-legacy/ts4.5/contract/compiler/Cli8.d.ts +13 -0
  464. package/types-legacy/ts4.5/contract/compiler/Http.d.ts +3 -9
  465. package/types-legacy/ts4.5/contract/compiler/HttpNode.d.ts +2 -5
  466. package/types-legacy/ts4.5/contract/delegation-signature.d.ts +2 -1
  467. package/types-legacy/ts4.5/contract/ga.d.ts +1 -2
  468. package/types-legacy/ts4.5/deprecated.d.ts +48 -0
  469. package/types-legacy/ts4.5/index-browser.d.ts +11 -6
  470. package/types-legacy/ts4.5/index.d.ts +1 -0
  471. package/types-legacy/ts4.5/oracle.d.ts +6 -37
  472. package/types-legacy/ts4.5/send-transaction.d.ts +53 -0
  473. package/types-legacy/ts4.5/spend.d.ts +4 -3
  474. package/types-legacy/ts4.5/tx/builder/common.d.ts +32 -0
  475. package/types-legacy/ts4.5/tx/builder/constants.d.ts +6 -5
  476. package/types-legacy/ts4.5/tx/builder/delegation/index.d.ts +20 -0
  477. package/types-legacy/ts4.5/tx/builder/delegation/schema.d.ts +136 -0
  478. package/types-legacy/ts4.5/tx/builder/delegation/schema.generated.d.ts +141 -0
  479. package/types-legacy/ts4.5/tx/builder/field-types/coin-amount.d.ts +2 -2
  480. package/types-legacy/ts4.5/tx/builder/field-types/ct-version.d.ts +1 -1
  481. package/types-legacy/ts4.5/tx/builder/field-types/fee.d.ts +19 -11
  482. package/types-legacy/ts4.5/tx/builder/field-types/gas-price.d.ts +10 -2
  483. package/types-legacy/ts4.5/tx/builder/field-types/index.d.ts +31 -29
  484. package/types-legacy/ts4.5/tx/builder/field-types/name-fee.d.ts +1 -1
  485. package/types-legacy/ts4.5/tx/builder/field-types/nonce.d.ts +1 -0
  486. package/types-legacy/ts4.5/tx/builder/field-types/pointers2.d.ts +26 -0
  487. package/types-legacy/ts4.5/tx/builder/field-types/query-fee.d.ts +19 -0
  488. package/types-legacy/ts4.5/tx/builder/field-types/ttl.d.ts +9 -1
  489. package/types-legacy/ts4.5/tx/builder/field-types/with-default.d.ts +7 -0
  490. package/types-legacy/ts4.5/tx/builder/field-types/with-formatting.d.ts +7 -0
  491. package/types-legacy/ts4.5/tx/builder/helpers.d.ts +2 -2
  492. package/types-legacy/ts4.5/tx/builder/index.d.ts +17 -10
  493. package/types-legacy/ts4.5/tx/builder/schema.d.ts +482 -257
  494. package/types-legacy/ts4.5/tx/builder/schema.generated.d.ts +39 -3
  495. package/types-legacy/ts4.5/tx/execution-cost.d.ts +6 -5
  496. package/types-legacy/ts4.5/utils/autorest.d.ts +2 -3
  497. package/types-legacy/ts4.5/utils/crypto.d.ts +9 -5
  498. package/types-legacy/ts4.5/utils/errors.d.ts +6 -0
  499. package/types-legacy/ts4.5/utils/hd-wallet.d.ts +2 -0
  500. package/types-legacy/ts4.5/utils/jwt.d.ts +53 -0
  501. package/types-legacy/ts4.5/utils/keystore.d.ts +6 -2
  502. package/types-legacy/ts4.5/utils/typed-data.d.ts +0 -2
  503. package/types-legacy/ts4.5/utils/wrap-proxy.d.ts +2 -0
  504. package/es/tx/builder/field-types/deposit.d.ts +0 -15
  505. package/es/tx/builder/field-types/deposit.mjs +0 -18
  506. package/es/tx/builder/field-types/deposit.mjs.map +0 -1
  507. package/src/tx/builder/field-types/deposit.ts +0 -23
  508. package/types-legacy/ts4.2/tx/builder/field-types/deposit.d.ts +0 -15
  509. package/types-legacy/ts4.5/tx/builder/field-types/deposit.d.ts +0 -15
@@ -1 +1 @@
1
- {"version":3,"file":"keystore.mjs","names":["nacl","v4","uuid","_aeternityArgon","hash","argon2id","getAddressFromPriv","InvalidPasswordError","DERIVED_KEY_FUNCTIONS","pass","salt","params","memlimit_kib","memoryCost","opslimit","timeCost","hashLength","type","CRYPTO_FUNCTIONS","encrypt","secretbox","decrypt","res","open","arguments","CRYPTO_DEFAULTS","secret_type","symmetric_alg","kdf","kdf_params","parallelism","plaintext","key","nonce","algo","length","undefined","ciphertext","deriveKey","password","kdfParams","recover","_ref","crypto","_Buffer","from","cipher_params","toString","dump","name","privateKey","randomBytes","options","opt","derivedKey","payload","version","public_key","id"],"sources":["../../src/utils/keystore.ts"],"sourcesContent":["import nacl from 'tweetnacl';\nimport { v4 as uuid } from '@aeternity/uuid';\nimport { hash, argon2id } from '@aeternity/argon2';\nimport { getAddressFromPriv } from './crypto';\nimport { InvalidPasswordError } from './errors';\n\nconst DERIVED_KEY_FUNCTIONS = {\n async argon2id(\n pass: string | Uint8Array,\n salt: string | Uint8Array,\n params: Partial<Keystore['crypto']['kdf_params']>,\n ): Promise<Uint8Array> {\n const { memlimit_kib: memoryCost, opslimit: timeCost } = params;\n\n return hash(pass, {\n hashLength: 32,\n salt,\n timeCost,\n memoryCost,\n type: argon2id,\n });\n },\n};\n\nconst CRYPTO_FUNCTIONS = {\n 'xsalsa20-poly1305': {\n encrypt: nacl.secretbox,\n decrypt(...args: Parameters<typeof nacl.secretbox.open>): Uint8Array {\n const res = nacl.secretbox.open(...args);\n if (res == null) throw new InvalidPasswordError();\n return res;\n },\n },\n};\n\nexport interface Keystore {\n name: string;\n version: 1;\n public_key: string;\n id: string;\n crypto: {\n secret_type: 'ed25519';\n symmetric_alg: keyof typeof CRYPTO_FUNCTIONS;\n ciphertext: string;\n cipher_params: {\n nonce: string;\n };\n kdf: keyof typeof DERIVED_KEY_FUNCTIONS;\n kdf_params: {\n memlimit_kib: number;\n opslimit: number;\n parallelism: number;\n salt: string;\n };\n };\n}\n\nconst CRYPTO_DEFAULTS = {\n secret_type: 'ed25519',\n symmetric_alg: 'xsalsa20-poly1305',\n kdf: 'argon2id',\n kdf_params: {\n memlimit_kib: 65536,\n opslimit: 3,\n parallelism: 1,\n },\n} as const;\n\n/**\n * Symmetric private key encryption using secret (derived) key.\n * @category keystore\n * @param plaintext - Data to be encrypted.\n * @param key - Secret key.\n * @param nonce - Randomly generated nonce.\n * @param algo - Encryption algorithm.\n * @returns Encrypted data.\n */\nfunction encrypt(\n plaintext: Uint8Array,\n key: Uint8Array,\n nonce: Uint8Array,\n algo: keyof typeof CRYPTO_FUNCTIONS = CRYPTO_DEFAULTS.symmetric_alg,\n): Uint8Array {\n return CRYPTO_FUNCTIONS[algo].encrypt(plaintext, nonce, key);\n}\n\n/**\n * Symmetric private key decryption using secret (derived) key.\n * @category keystore\n * @param ciphertext - Data to be decrypted.\n * @param key - Secret key.\n * @param nonce - Nonce from key-object.\n * @param algo - Encryption algorithm.\n * @returns Decrypted data.\n */\nfunction decrypt(\n ciphertext: Uint8Array,\n key: Uint8Array,\n nonce: Uint8Array,\n algo: keyof typeof CRYPTO_FUNCTIONS = CRYPTO_DEFAULTS.symmetric_alg,\n): Uint8Array {\n return CRYPTO_FUNCTIONS[algo].decrypt(ciphertext, nonce, key);\n}\n\n/**\n * Derive secret key from password with key derivation function.\n * @category keystore\n * @param password - User-supplied password.\n * @param nonce - Randomly generated nonce.\n * @param kdf - Key derivation function.\n * @param kdfParams - KDF parameters.\n * @returns Secret key derived from password.\n */\nasync function deriveKey(\n password: string | Uint8Array,\n nonce: string | Uint8Array,\n kdf: Keystore['crypto']['kdf'],\n kdfParams: Omit<Keystore['crypto']['kdf_params'], 'salt'>,\n): Promise<Uint8Array> {\n return DERIVED_KEY_FUNCTIONS[kdf](password, nonce, kdfParams);\n}\n\n/**\n * Recover plaintext private key from secret-storage key object.\n * @category keystore\n * @param password - Keystore object password.\n * @param keystore - Keystore object.\n * @returns Plaintext private key.\n */\nexport async function recover(\n password: string | Uint8Array,\n { crypto }: Keystore,\n): Promise<string> {\n const salt = Buffer.from(crypto.kdf_params.salt, 'hex');\n return Buffer.from(decrypt(\n Buffer.from(crypto.ciphertext, 'hex'),\n await deriveKey(password, salt, crypto.kdf, crypto.kdf_params),\n Buffer.from(crypto.cipher_params.nonce, 'hex'),\n crypto.symmetric_alg,\n )).toString('hex');\n}\n\n/**\n * Export private key to keystore secret-storage format.\n * @category keystore\n * @param name - Key name.\n * @param password - User-supplied password.\n * @param privateKey - Private key as hex-string or a Buffer.\n * @param nonce - Randomly generated 24byte nonce.\n * @param salt - Randomly generated 16byte salt.\n * @param options - Encryption parameters.\n * @param options.kdf - Key derivation function.\n * @param options.kdf_params - KDF parameters.\n */\nexport async function dump(\n name: string,\n password: string | Uint8Array,\n privateKey: string | Uint8Array,\n nonce: Uint8Array = nacl.randomBytes(24),\n salt: Uint8Array = nacl.randomBytes(16),\n options?: Partial<Keystore['crypto']>,\n): Promise<Keystore> {\n const opt = { ...CRYPTO_DEFAULTS, ...options };\n const derivedKey = await deriveKey(password, salt, opt.kdf, opt.kdf_params);\n const payload = typeof privateKey === 'string' ? Buffer.from(privateKey, 'hex') : privateKey;\n return {\n name,\n version: 1,\n public_key: getAddressFromPriv(payload),\n id: uuid(),\n crypto: {\n secret_type: opt.secret_type,\n symmetric_alg: opt.symmetric_alg,\n ciphertext: Buffer.from(\n encrypt(payload, derivedKey, nonce, opt.symmetric_alg),\n ).toString('hex'),\n cipher_params: { nonce: Buffer.from(nonce).toString('hex') },\n kdf: opt.kdf,\n kdf_params: {\n ...opt.kdf_params,\n salt: Buffer.from(salt).toString('hex'),\n },\n },\n };\n}\n"],"mappings":";;;;AAAA,OAAOA,IAAI,MAAM,WAAW;AAC5B,SAASC,EAAE,IAAIC,IAAI,QAAQ,iBAAiB;AAC5C,OAAAC,eAAA,MAA+B,mBAAmB;AAAC;EAAAC,IAAA;EAAAC;AAAA,IAAAF,eAAA;AAAA,SAC1CG,kBAAkB;AAAA,SAClBC,oBAAoB;AAE7B,MAAMC,qBAAqB,GAAG;EAC5B,MAAMH,QAAQA,CACZI,IAAyB,EACzBC,IAAyB,EACzBC,MAAiD,EAC5B;IACrB,MAAM;MAAEC,YAAY,EAAEC,UAAU;MAAEC,QAAQ,EAAEC;IAAS,CAAC,GAAGJ,MAAM;IAE/D,O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F;EACF,CAAC;AACH"}
1
+ {"version":3,"file":"keystore.mjs","names":["nacl","v4","uuid","_aeternityArgon","hash","argon2id","getAddressFromPriv","InvalidPasswordError","DERIVED_KEY_FUNCTIONS","pass","salt","params","memlimit_kib","memoryCost","opslimit","timeCost","hashLength","type","CRYPTO_FUNCTIONS","encrypt","secretbox","decrypt","args","res","open","CRYPTO_DEFAULTS","secret_type","symmetric_alg","kdf","kdf_params","parallelism","plaintext","key","nonce","algo","ciphertext","deriveKey","password","kdfParams","recover","crypto","_Buffer","from","cipher_params","toString","dump","name","privateKey","randomBytes","options","opt","derivedKey","payload","version","public_key","id"],"sources":["../../src/utils/keystore.ts"],"sourcesContent":["import nacl from 'tweetnacl';\nimport { v4 as uuid } from '@aeternity/uuid';\nimport { hash, argon2id } from '@aeternity/argon2';\nimport { getAddressFromPriv } from './crypto';\nimport { InvalidPasswordError } from './errors';\n\nconst DERIVED_KEY_FUNCTIONS = {\n async argon2id(\n pass: string | Uint8Array,\n salt: string | Uint8Array,\n params: Partial<Keystore['crypto']['kdf_params']>,\n ): Promise<Uint8Array> {\n const { memlimit_kib: memoryCost, opslimit: timeCost } = params;\n\n return hash(pass, {\n hashLength: 32,\n salt,\n timeCost,\n memoryCost,\n type: argon2id,\n });\n },\n};\n\nconst CRYPTO_FUNCTIONS = {\n 'xsalsa20-poly1305': {\n encrypt: nacl.secretbox,\n decrypt(...args: Parameters<typeof nacl.secretbox.open>): Uint8Array {\n const res = nacl.secretbox.open(...args);\n if (res == null) throw new InvalidPasswordError();\n return res;\n },\n },\n};\n\nexport interface Keystore {\n name: string;\n version: 1;\n public_key: string;\n id: string;\n crypto: {\n secret_type: 'ed25519';\n symmetric_alg: keyof typeof CRYPTO_FUNCTIONS;\n ciphertext: string;\n cipher_params: {\n nonce: string;\n };\n /**\n * Key derivation function name.\n */\n kdf: keyof typeof DERIVED_KEY_FUNCTIONS;\n /**\n * Key derivation function parameters.\n */\n kdf_params: {\n memlimit_kib: number;\n opslimit: number;\n parallelism: number;\n salt: string;\n };\n };\n}\n\nconst CRYPTO_DEFAULTS = {\n secret_type: 'ed25519',\n symmetric_alg: 'xsalsa20-poly1305',\n kdf: 'argon2id',\n kdf_params: {\n memlimit_kib: 65536,\n opslimit: 3,\n parallelism: 1,\n },\n} as const;\n\n/**\n * Symmetric private key encryption using secret (derived) key.\n * @category keystore\n * @param plaintext - Data to be encrypted.\n * @param key - Secret key.\n * @param nonce - Randomly generated nonce.\n * @param algo - Encryption algorithm.\n * @returns Encrypted data.\n */\nfunction encrypt(\n plaintext: Uint8Array,\n key: Uint8Array,\n nonce: Uint8Array,\n algo: keyof typeof CRYPTO_FUNCTIONS = CRYPTO_DEFAULTS.symmetric_alg,\n): Uint8Array {\n return CRYPTO_FUNCTIONS[algo].encrypt(plaintext, nonce, key);\n}\n\n/**\n * Symmetric private key decryption using secret (derived) key.\n * @category keystore\n * @param ciphertext - Data to be decrypted.\n * @param key - Secret key.\n * @param nonce - Nonce from key-object.\n * @param algo - Encryption algorithm.\n * @returns Decrypted data.\n */\nfunction decrypt(\n ciphertext: Uint8Array,\n key: Uint8Array,\n nonce: Uint8Array,\n algo: keyof typeof CRYPTO_FUNCTIONS = CRYPTO_DEFAULTS.symmetric_alg,\n): Uint8Array {\n return CRYPTO_FUNCTIONS[algo].decrypt(ciphertext, nonce, key);\n}\n\n/**\n * Derive secret key from password with key derivation function.\n * @category keystore\n * @param password - User-supplied password.\n * @param nonce - Randomly generated nonce.\n * @param kdf - Key derivation function.\n * @param kdfParams - KDF parameters.\n * @returns Secret key derived from password.\n */\nasync function deriveKey(\n password: string | Uint8Array,\n nonce: string | Uint8Array,\n kdf: Keystore['crypto']['kdf'],\n kdfParams: Omit<Keystore['crypto']['kdf_params'], 'salt'>,\n): Promise<Uint8Array> {\n return DERIVED_KEY_FUNCTIONS[kdf](password, nonce, kdfParams);\n}\n\n/**\n * Recover plaintext private key from secret-storage key object.\n * @category keystore\n * @param password - Keystore object password.\n * @param keystore - Keystore object.\n * @returns Plaintext private key.\n */\nexport async function recover(\n password: string | Uint8Array,\n { crypto }: Keystore,\n): Promise<string> {\n const salt = Buffer.from(crypto.kdf_params.salt, 'hex');\n return Buffer.from(decrypt(\n Buffer.from(crypto.ciphertext, 'hex'),\n await deriveKey(password, salt, crypto.kdf, crypto.kdf_params),\n Buffer.from(crypto.cipher_params.nonce, 'hex'),\n crypto.symmetric_alg,\n )).toString('hex');\n}\n\n/**\n * Export private key to keystore secret-storage format.\n * @category keystore\n * @param name - Key name.\n * @param password - User-supplied password.\n * @param privateKey - Private key as hex-string or a Buffer.\n * @param nonce - Randomly generated 24byte nonce.\n * @param salt - Randomly generated 16byte salt.\n * @param options - Encryption parameters.\n */\nexport async function dump(\n name: string,\n password: string | Uint8Array,\n privateKey: string | Uint8Array,\n nonce: Uint8Array = nacl.randomBytes(24),\n salt: Uint8Array = nacl.randomBytes(16),\n options?: Partial<Keystore['crypto']>,\n): Promise<Keystore> {\n const opt = { ...CRYPTO_DEFAULTS, ...options };\n const derivedKey = await deriveKey(password, salt, opt.kdf, opt.kdf_params);\n const payload = typeof privateKey === 'string' ? Buffer.from(privateKey, 'hex') : privateKey;\n return {\n name,\n version: 1,\n public_key: getAddressFromPriv(payload),\n id: uuid(),\n crypto: {\n secret_type: opt.secret_type,\n symmetric_alg: opt.symmetric_alg,\n ciphertext: Buffer.from(\n encrypt(payload, derivedKey, nonce, opt.symmetric_alg),\n ).toString('hex'),\n cipher_params: { nonce: Buffer.from(nonce).toString('hex') },\n kdf: opt.kdf,\n kdf_params: {\n ...opt.kdf_params,\n salt: Buffer.from(salt).toString('hex'),\n },\n },\n };\n}\n"],"mappings":";;;;AAAA,OAAOA,IAAI,MAAM,WAAW;AAC5B,SAASC,EAAE,IAAIC,IAAI,QAAQ,iBAAiB;AAC5C,OAAAC,eAAA,MAA+B,mBAAmB;AAAC;EAAAC,IAAA;EAAAC;AAAA,IAAAF,eAAA;AAAA,SAC1CG,kBAAkB;AAAA,SAClBC,oBAAoB;AA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ACnB,MAAMC,GAAG,GAAG;IAAE,GAAGzB,eAAe;IAAE,GAAGwB;EAAQ,CAAC;EAC9C,MAAME,UAAU,GAAG,MAAMf,SAAS,CAACC,QAAQ,EAAE3B,IAAI,EAAEwC,GAAG,CAACtB,GAAG,EAAEsB,GAAG,CAACrB,UAAU,CAAC;EAC3E,MAAMuB,OAAO,GAAG,OAAOL,UAAU,KAAK,QAAQ,GAAGN,OAAA,CAAOC,IAAI,CAACK,UAAU,EAAE,KAAK,CAAC,GAAGA,UAAU;EAC5F,OAAO;IACLD,IAAI;IACJO,OAAO,EAAE,CAAC;IACVC,UAAU,EAAEhD,kBAAkB,CAAC8C,OAAO,CAAC;IACvCG,EAAE,EAAErD,IAAI,CAAC,CAAC;IACVsC,MAAM,EAAE;MACNd,WAAW,EAAEwB,GAAG,CAACxB,WAAW;MAC5BC,aAAa,EAAEuB,GAAG,CAACvB,aAAa;MAChCQ,UAAU,EAAEM,OAAA,CAAOC,IAAI,CACrBvB,OAAO,CAACiC,OAAO,EAAED,UAAU,EAAElB,KAAK,EAAEiB,GAAG,CAACvB,aAAa,CACvD,CAAC,CAACiB,QAAQ,CAAC,KAAK,CAAC;MACjBD,aAAa,EAAE;QAAEV,KAAK,EAAEQ,OAAA,CAAOC,IAAI,CAACT,KAAK,CAAC,CAACW,QAAQ,CAAC,KAAK;MAAE,CAAC;MAC5DhB,GAAG,EAAEsB,GAAG,CAACtB,GAAG;MACZC,UAAU,EAAE;QACV,GAAGqB,GAAG,CAACrB,UAAU;QACjBnB,IAAI,EAAE+B,OAAA,CAAOC,IAAI,CAAChC,IAAI,CAAC,CAACkC,QAAQ,CAAC,KAAK;MACxC;IACF;EACF,CAAC;AACH"}
@@ -36,8 +36,6 @@ export interface Domain {
36
36
  networkId?: string;
37
37
  contractAddress?: Encoded.ContractAddress;
38
38
  }
39
- export declare function encodeFateValue(value: unknown, aci: AciValue): Encoded.ContractBytearray;
40
- export declare function decodeFateValue(value: Encoded.ContractBytearray, aci: AciValue): Encoded.ContractBytearray;
41
39
  /**
42
40
  * Hashes domain object, can be used to inline domain hash to contract source code
43
41
  */
@@ -1,10 +1,8 @@
1
- // js extension is required for mjs build
2
- // @ts-expect-error see https://github.com/aeternity/aepp-calldata-js/issues/216
3
- // eslint-disable-next-line import/extensions
4
- import ContractByteArrayEncoder from '@aeternity/aepp-calldata/src/ContractByteArrayEncoder.js';
5
- // @ts-expect-error see https://github.com/aeternity/aepp-calldata-js/issues/216
6
- // eslint-disable-next-line import/extensions
7
- import AciTypeResolver from '@aeternity/aepp-calldata/src/AciTypeResolver.js';
1
+ import _aeternityAeppCalldata from '@aeternity/aepp-calldata';
2
+ const {
3
+ TypeResolver,
4
+ ContractByteArrayEncoder
5
+ } = _aeternityAeppCalldata;
8
6
  import canonicalize from 'canonicalize';
9
7
  import { decode } from "./encoder.mjs";
10
8
  import { hash, messagePrefixLength } from "./crypto.mjs";
@@ -19,21 +17,6 @@ export function hashJson(data) {
19
17
 
20
18
  // TODO: move this type to calldata library https://github.com/aeternity/aepp-calldata-js/issues/215
21
19
  // based on https://github.com/aeternity/aepp-calldata-js/blob/82b5a98f9b308482627da8d7484d213e9cf87151/src/AciTypeResolver.js#L129
22
- // TODO: replace with api on calldata side https://github.com/aeternity/aepp-calldata-js/issues/216
23
- export function encodeFateValue(value, aci) {
24
- const contractByteArrayEncoder = new ContractByteArrayEncoder();
25
- const aciTypeResolver = new AciTypeResolver([]);
26
- aciTypeResolver.isCustomType = () => false;
27
- return contractByteArrayEncoder.encode(aciTypeResolver.resolveType(aci), value);
28
- }
29
-
30
- // TODO: replace with api on calldata side https://github.com/aeternity/aepp-calldata-js/issues/216
31
- export function decodeFateValue(value, aci) {
32
- const contractByteArrayEncoder = new ContractByteArrayEncoder();
33
- const aciTypeResolver = new AciTypeResolver([]);
34
- aciTypeResolver.isCustomType = () => false;
35
- return contractByteArrayEncoder.decodeWithType(value, aciTypeResolver.resolveType(aci));
36
- }
37
20
 
38
21
  /**
39
22
  * Hashes domain object, can be used to inline domain hash to contract source code
@@ -62,7 +45,9 @@ export function hashDomain(domain) {
62
45
  }
63
46
  }]
64
47
  };
65
- return hash(decode(encodeFateValue(domain, domainAci)));
48
+ const domainType = new TypeResolver().resolveType(domainAci, {});
49
+ const fateValue = new ContractByteArrayEncoder().encodeWithType(domain, domainType);
50
+ return hash(decode(fateValue));
66
51
  }
67
52
  export function hashTypedData(data, aci, domain) {
68
53
  return hash(concatBuffers([messagePrefixLength, new Uint8Array([0]), hashDomain(domain), hashJson(aci), hash(decode(data))]));
@@ -1 +1 @@
1
- {"version":3,"file":"typed-data.mjs","names":["ContractByteArrayEncoder","AciTypeResolver","canonicalize","decode","hash","messagePrefixLength","concatBuffers","hashJson","data","_canonicalize","encodeFateValue","value","aci","contractByteArrayEncoder","aciTypeResolver","isCustomType","encode","resolveType","decodeFateValue","decodeWithType","hashDomain","domain","domainAci","record","name","type","option","hashTypedData","Uint8Array"],"sources":["../../src/utils/typed-data.ts"],"sourcesContent":["// js extension is required for mjs build\n// @ts-expect-error see https://github.com/aeternity/aepp-calldata-js/issues/216\n// eslint-disable-next-line import/extensions\nimport ContractByteArrayEncoder from '@aeternity/aepp-calldata/src/ContractByteArrayEncoder.js';\n// @ts-expect-error see https://github.com/aeternity/aepp-calldata-js/issues/216\n// eslint-disable-next-line import/extensions\nimport AciTypeResolver from '@aeternity/aepp-calldata/src/AciTypeResolver.js';\nimport canonicalize from 'canonicalize';\nimport { Encoded, decode } from './encoder';\nimport { hash, messagePrefixLength } from './crypto';\nimport { concatBuffers } from './other';\n\n/**\n * Hashes arbitrary object, can be used to inline the aci hash to contract source code\n */\nexport function hashJson(data: unknown): Buffer {\n return hash(canonicalize(data) ?? '');\n}\n\n// TODO: move this type to calldata library https://github.com/aeternity/aepp-calldata-js/issues/215\n// based on https://github.com/aeternity/aepp-calldata-js/blob/82b5a98f9b308482627da8d7484d213e9cf87151/src/AciTypeResolver.js#L129\nexport type AciValue = 'void' | 'unit' | 'int' | 'bool' | 'string' | 'bits' | 'hash' | 'signature'\n| 'address' | 'contract_pubkey' | 'Chain.ttl' | 'Chain.ga_meta_tx' | 'Chain.paying_for_tx'\n| 'Chain.base_tx' | 'AENS.pointee' | 'AENS.name' | 'MCL_BLS12_381.fr' | 'MCL_BLS12_381.fp'\n| { 'Set.set': readonly [AciValue] }\n| { bytes: number }\n| { list: readonly [AciValue] }\n| { map: readonly [AciValue, AciValue] }\n| { tuple: readonly AciValue[] }\n| { record: ReadonlyArray<{ name: string; type: AciValue }> }\n| { variant: ReadonlyArray<{ [key: string]: readonly AciValue[] }> }\n| { option: readonly [AciValue] }\n| { oracle: readonly [AciValue, AciValue] }\n| { oracle_query: readonly [AciValue, AciValue] };\n\nexport interface Domain {\n name?: string;\n version?: number;\n networkId?: string;\n contractAddress?: Encoded.ContractAddress;\n}\n\n// TODO: replace with api on calldata side https://github.com/aeternity/aepp-calldata-js/issues/216\nexport function encodeFateValue(\n value: unknown,\n aci: AciValue,\n): Encoded.ContractBytearray {\n const contractByteArrayEncoder = new ContractByteArrayEncoder();\n const aciTypeResolver = new AciTypeResolver([]);\n aciTypeResolver.isCustomType = () => false;\n return contractByteArrayEncoder.encode(aciTypeResolver.resolveType(aci), value);\n}\n\n// TODO: replace with api on calldata side https://github.com/aeternity/aepp-calldata-js/issues/216\nexport function decodeFateValue(\n value: Encoded.ContractBytearray,\n aci: AciValue,\n): Encoded.ContractBytearray {\n const contractByteArrayEncoder = new ContractByteArrayEncoder();\n const aciTypeResolver = new AciTypeResolver([]);\n aciTypeResolver.isCustomType = () => false;\n return contractByteArrayEncoder.decodeWithType(value, aciTypeResolver.resolveType(aci));\n}\n\n/**\n * Hashes domain object, can be used to inline domain hash to contract source code\n */\nexport function hashDomain(domain: Domain): Buffer {\n const domainAci = {\n record: [{\n name: 'name',\n type: { option: ['string'] },\n }, {\n name: 'version',\n type: { option: ['int'] },\n }, {\n name: 'networkId',\n type: { option: ['string'] },\n }, {\n name: 'contractAddress',\n type: { option: ['contract_pubkey'] },\n }],\n } as const;\n return hash(decode(encodeFateValue(domain, domainAci)));\n}\n\nexport function hashTypedData(\n data: Encoded.ContractBytearray,\n aci: AciValue,\n domain: Domain,\n): Buffer {\n return hash(concatBuffers([\n messagePrefixLength, new Uint8Array([0]), hashDomain(domain), hashJson(aci), hash(decode(data)),\n ]));\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,wBAAwB,MAAM,0DAA0D;AAC/F;AACA;AACA,OAAOC,eAAe,MAAM,iDAAiD;AAC7E,OAAOC,YAAY,MAAM,cAAc;AAAC,SACtBC,MAAM;AAAA,SACfC,IAAI,EAAEC,mBAAmB;AAAA,SACzBC,aAAa;AAEtB;AACA;AACA;AACA,OAAO,SAASC,QAAQA,CAACC,IAAa,EAAU;EAAA,IAAAC,aAAA;EAC9C,OAAOL,IAAI,EAAAK,aAAA,GAACP,YAAY,CAACM,IAAI,CAAC,cAAAC,aAAA,cAAAA,aAAA,GAAI,EAAE,CAAC;AACvC;;AAEA;AACA;AAsBA;AACA,OAAO,SAASC,eAAeA,CAC7BC,KAAc,EACdC,GAAa,EACc;EAC3B,MAAMC,wBAAwB,GAAG,IAAIb,wBAAwB,CAAC,CAAC;EAC/D,MAAMc,eAAe,GAAG,IAAIb,eAAe,CAAC,EAAE,CAAC;EAC/Ca,eAAe,CAACC,YAAY,GAAG,MAAM,KAAK;EAC1C,OAAOF,wBAAwB,CAACG,MAAM,CAACF,eAAe,CAACG,WAAW,CAACL,GAAG,CAAC,EAAED,KAAK,CAAC;AACjF;;AAEA;AACA,OAAO,SAASO,eAAeA,CAC7BP,KAAgC,EAChCC,GAAa,EACc;EAC3B,MAAMC,wBAAwB,GAAG,IAAIb,wBAAwB,CAAC,CAAC;EAC/D,MAAMc,eAAe,GAAG,IAAIb,eAAe,CAAC,EAAE,CAAC;EAC/Ca,eAAe,CAACC,YAAY,GAAG,MAAM,KAAK;EAC1C,OAAOF,wBAAwB,CAACM,cAAc,CAACR,KAAK,EAAEG,eAAe,CAACG,WAAW,CAACL,GAAG,CAAC,CAAC;AACzF;;AAEA;AACA;AACA;AACA,OAAO,SAASQ,UAAUA,CAACC,MAAc,EAAU;EACjD,MAAMC,SAAS,GAAG;IAChBC,MAAM,EAAE,CAAC;MACPC,IAAI,EAAE,MAAM;MACZC,IAAI,EAAE;QAAEC,MAAM,EAAE,CAAC,QAAQ;MAAE;IAC7B,CAAC,EAAE;MACDF,IAAI,EAAE,SAAS;MACfC,IAAI,EAAE;QAAEC,MAAM,EAAE,CAAC,KAAK;MAAE;IAC1B,CAAC,EAAE;MACDF,IAAI,EAAE,WAAW;MACjBC,IAAI,EAAE;QAAEC,MAAM,EAAE,CAAC,QAAQ;MAAE;IAC7B,CAAC,EAAE;MACDF,IAAI,EAAE,iBAAiB;MACvBC,IAAI,EAAE;QAAEC,MAAM,EAAE,CAAC,iBAAiB;MAAE;IACtC,CAAC;EACH,CAAU;EACV,OAAOtB,IAAI,CAACD,MAAM,CAACO,eAAe,CAACW,MAAM,EAAEC,SAAS,CAAC,CAAC,CAAC;AACzD;AAEA,OAAO,SAASK,aAAaA,CAC3BnB,IAA+B,EAC/BI,GAAa,EACbS,MAAc,EACN;EACR,OAAOjB,IAAI,CAACE,aAAa,CAAC,CACxBD,mBAAmB,EAAE,IAAIuB,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,EAAER,UAAU,CAACC,MAAM,CAAC,EAAEd,QAAQ,CAACK,GAAG,CAAC,EAAER,IAAI,CAACD,MAAM,CAACK,IAAI,CAAC,CAAC,CAChG,CAAC,CAAC;AACL"}
1
+ {"version":3,"file":"typed-data.mjs","names":["_aeternityAeppCalldata","TypeResolver","ContractByteArrayEncoder","canonicalize","decode","hash","messagePrefixLength","concatBuffers","hashJson","data","_canonicalize","hashDomain","domain","domainAci","record","name","type","option","domainType","resolveType","fateValue","encodeWithType","hashTypedData","aci","Uint8Array"],"sources":["../../src/utils/typed-data.ts"],"sourcesContent":["import { TypeResolver, ContractByteArrayEncoder } from '@aeternity/aepp-calldata';\nimport canonicalize from 'canonicalize';\nimport { Encoded, decode } from './encoder';\nimport { hash, messagePrefixLength } from './crypto';\nimport { concatBuffers } from './other';\n\n/**\n * Hashes arbitrary object, can be used to inline the aci hash to contract source code\n */\nexport function hashJson(data: unknown): Buffer {\n return hash(canonicalize(data) ?? '');\n}\n\n// TODO: move this type to calldata library https://github.com/aeternity/aepp-calldata-js/issues/215\n// based on https://github.com/aeternity/aepp-calldata-js/blob/82b5a98f9b308482627da8d7484d213e9cf87151/src/AciTypeResolver.js#L129\nexport type AciValue = 'void' | 'unit' | 'int' | 'bool' | 'string' | 'bits' | 'hash' | 'signature'\n| 'address' | 'contract_pubkey' | 'Chain.ttl' | 'Chain.ga_meta_tx' | 'Chain.paying_for_tx'\n| 'Chain.base_tx' | 'AENS.pointee' | 'AENS.name' | 'MCL_BLS12_381.fr' | 'MCL_BLS12_381.fp'\n| { 'Set.set': readonly [AciValue] }\n| { bytes: number }\n| { list: readonly [AciValue] }\n| { map: readonly [AciValue, AciValue] }\n| { tuple: readonly AciValue[] }\n| { record: ReadonlyArray<{ name: string; type: AciValue }> }\n| { variant: ReadonlyArray<{ [key: string]: readonly AciValue[] }> }\n| { option: readonly [AciValue] }\n| { oracle: readonly [AciValue, AciValue] }\n| { oracle_query: readonly [AciValue, AciValue] };\n\nexport interface Domain {\n name?: string;\n version?: number;\n networkId?: string;\n contractAddress?: Encoded.ContractAddress;\n}\n\n/**\n * Hashes domain object, can be used to inline domain hash to contract source code\n */\nexport function hashDomain(domain: Domain): Buffer {\n const domainAci = {\n record: [{\n name: 'name',\n type: { option: ['string'] },\n }, {\n name: 'version',\n type: { option: ['int'] },\n }, {\n name: 'networkId',\n type: { option: ['string'] },\n }, {\n name: 'contractAddress',\n type: { option: ['contract_pubkey'] },\n }],\n } as const;\n const domainType = new TypeResolver().resolveType(domainAci, {});\n const fateValue = new ContractByteArrayEncoder().encodeWithType(domain, domainType);\n return hash(decode(fateValue));\n}\n\nexport function hashTypedData(\n data: Encoded.ContractBytearray,\n aci: AciValue,\n domain: Domain,\n): Buffer {\n return hash(concatBuffers([\n messagePrefixLength, new Uint8Array([0]), hashDomain(domain), hashJson(aci), hash(decode(data)),\n ]));\n}\n"],"mappings":"AAAA,OAAAA,sBAAA,MAAuD,0BAA0B;AAAC;EAAAC,YAAA;EAAAC;AAAA,IAAAF,sBAAA;AAClF,OAAOG,YAAY,MAAM,cAAc;AAAC,SACtBC,MAAM;AAAA,SACfC,IAAI,EAAEC,mBAAmB;AAAA,SACzBC,aAAa;AAEtB;AACA;AACA;AACA,OAAO,SAASC,QAAQA,CAACC,IAAa,EAAU;EAAA,IAAAC,aAAA;EAC9C,OAAOL,IAAI,EAAAK,aAAA,GAACP,YAAY,CAACM,IAAI,CAAC,cAAAC,aAAA,cAAAA,aAAA,GAAI,EAAE,CAAC;AACvC;;AAEA;AACA;;AAsBA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CAACC,MAAc,EAAU;EACjD,MAAMC,SAAS,GAAG;IAChBC,MAAM,EAAE,CAAC;MACPC,IAAI,EAAE,MAAM;MACZC,IAAI,EAAE;QAAEC,MAAM,EAAE,CAAC,QAAQ;MAAE;IAC7B,CAAC,EAAE;MACDF,IAAI,EAAE,SAAS;MACfC,IAAI,EAAE;QAAEC,MAAM,EAAE,CAAC,KAAK;MAAE;IAC1B,CAAC,EAAE;MACDF,IAAI,EAAE,WAAW;MACjBC,IAAI,EAAE;QAAEC,MAAM,EAAE,CAAC,QAAQ;MAAE;IAC7B,CAAC,EAAE;MACDF,IAAI,EAAE,iBAAiB;MACvBC,IAAI,EAAE;QAAEC,MAAM,EAAE,CAAC,iBAAiB;MAAE;IACtC,CAAC;EACH,CAAU;EACV,MAAMC,UAAU,GAAG,IAAIjB,YAAY,CAAC,CAAC,CAACkB,WAAW,CAACN,SAAS,EAAE,CAAC,CAAC,CAAC;EAChE,MAAMO,SAAS,GAAG,IAAIlB,wBAAwB,CAAC,CAAC,CAACmB,cAAc,CAACT,MAAM,EAAEM,UAAU,CAAC;EACnF,OAAOb,IAAI,CAACD,MAAM,CAACgB,SAAS,CAAC,CAAC;AAChC;AAEA,OAAO,SAASE,aAAaA,CAC3Bb,IAA+B,EAC/Bc,GAAa,EACbX,MAAc,EACN;EACR,OAAOP,IAAI,CAACE,aAAa,CAAC,CACxBD,mBAAmB,EAAE,IAAIkB,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,EAAEb,UAAU,CAACC,MAAM,CAAC,EAAEJ,QAAQ,CAACe,GAAG,CAAC,EAAElB,IAAI,CAACD,MAAM,CAACK,IAAI,CAAC,CAAC,CAChG,CAAC,CAAC;AACL"}
@@ -0,0 +1,2 @@
1
+ export declare function wrapWithProxy<Value extends object | undefined>(valueCb: () => Value): NonNullable<Value>;
2
+ export declare function unwrapProxy<Value extends object>(value: Value): Value;
@@ -0,0 +1,15 @@
1
+ import { ArgumentError } from "./errors.mjs";
2
+ export function wrapWithProxy(valueCb) {
3
+ return new Proxy({}, Object.fromEntries(['apply', 'construct', 'defineProperty', 'deleteProperty', 'getOwnPropertyDescriptor', 'getPrototypeOf', 'isExtensible', 'ownKeys', 'preventExtensions', 'set', 'setPrototypeOf', 'get', 'has'].map(name => [name, (t, ...args) => {
4
+ const target = valueCb();
5
+ if (target == null) throw new ArgumentError('wrapped value', 'defined', target);
6
+ if (name === 'get' && args[0] === '_wrappedValue') return target;
7
+ const res = Reflect[name](target, ...args);
8
+ return typeof res === 'function' && name === 'get' ? res.bind(target) : res;
9
+ }])));
10
+ }
11
+ export function unwrapProxy(value) {
12
+ var _wrappedValue;
13
+ return (_wrappedValue = value._wrappedValue) !== null && _wrappedValue !== void 0 ? _wrappedValue : value;
14
+ }
15
+ //# sourceMappingURL=wrap-proxy.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrap-proxy.mjs","names":["ArgumentError","wrapWithProxy","valueCb","Proxy","Object","fromEntries","map","name","t","args","target","res","Reflect","bind","unwrapProxy","value","_wrappedValue"],"sources":["../../src/utils/wrap-proxy.ts"],"sourcesContent":["import { ArgumentError } from './errors';\n\nexport function wrapWithProxy<Value extends object | undefined>(\n valueCb: () => Value,\n): NonNullable<Value> {\n return new Proxy(\n {},\n Object.fromEntries(([\n 'apply', 'construct', 'defineProperty', 'deleteProperty', 'getOwnPropertyDescriptor',\n 'getPrototypeOf', 'isExtensible', 'ownKeys', 'preventExtensions', 'set', 'setPrototypeOf',\n 'get', 'has',\n ] as const).map((name) => [name, (t: {}, ...args: unknown[]) => {\n const target = valueCb();\n if (target == null) throw new ArgumentError('wrapped value', 'defined', target);\n if (name === 'get' && args[0] === '_wrappedValue') return target;\n const res = (Reflect[name] as any)(target, ...args);\n return typeof res === 'function' && name === 'get' ? res.bind(target) : res;\n }])),\n ) as NonNullable<Value>;\n}\n\nexport function unwrapProxy<Value extends object>(value: Value): Value {\n return (value as { _wrappedValue?: Value })._wrappedValue ?? value;\n}\n"],"mappings":"SAASA,aAAa;AAEtB,OAAO,SAASC,aAAaA,CAC3BC,OAAoB,EACA;EACpB,OAAO,IAAIC,KAAK,CACd,CAAC,CAAC,EACFC,MAAM,CAACC,WAAW,CAAE,CAClB,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,0BAA0B,EACpF,gBAAgB,EAAE,cAAc,EAAE,SAAS,EAAE,mBAAmB,EAAE,KAAK,EAAE,gBAAgB,EACzF,KAAK,EAAE,KAAK,CACb,CAAWC,GAAG,CAAEC,IAAI,IAAK,CAACA,IAAI,EAAE,CAACC,CAAK,EAAE,GAAGC,IAAe,KAAK;IAC9D,MAAMC,MAAM,GAAGR,OAAO,CAAC,CAAC;IACxB,IAAIQ,MAAM,IAAI,IAAI,EAAE,MAAM,IAAIV,aAAa,CAAC,eAAe,EAAE,SAAS,EAAEU,MAAM,CAAC;IAC/E,IAAIH,IAAI,KAAK,KAAK,IAAIE,IAAI,CAAC,CAAC,CAAC,KAAK,eAAe,EAAE,OAAOC,MAAM;IAChE,MAAMC,GAAG,GAAIC,OAAO,CAACL,IAAI,CAAC,CAASG,MAAM,EAAE,GAAGD,IAAI,CAAC;IACnD,OAAO,OAAOE,GAAG,KAAK,UAAU,IAAIJ,IAAI,KAAK,KAAK,GAAGI,GAAG,CAACE,IAAI,CAACH,MAAM,CAAC,GAAGC,GAAG;EAC7E,CAAC,CAAC,CAAC,CACL,CAAC;AACH;AAEA,OAAO,SAASG,WAAWA,CAAuBC,KAAY,EAAS;EAAA,IAAAC,aAAA;EACrE,QAAAA,aAAA,GAAQD,KAAK,CAA+BC,aAAa,cAAAA,aAAA,cAAAA,aAAA,GAAID,KAAK;AACpE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeternity/aepp-sdk",
3
- "version": "13.2.1",
3
+ "version": "13.3.0",
4
4
  "description": "SDK for the æternity blockchain",
5
5
  "main": "dist/aepp-sdk.js",
6
6
  "types": "es/index.d.ts",
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "sideEffects": false,
45
45
  "scripts": {
46
- "build:assets": "node tooling/fetch-aesophia-cli.mjs",
46
+ "build:assets": "node tooling/fetch-aesophia-cli.mjs && node tooling/fetch-aesophia-cli-8.mjs",
47
47
  "build:types": "tsc && node tooling/downlevel/run.mjs",
48
48
  "build:es": "babel src --config-file ./babel.esm.config.js --out-dir es --extensions .js,.ts --out-file-extension .mjs --source-maps true",
49
49
  "build:api:node": "autorest tooling/autorest/node.yaml",
@@ -75,23 +75,23 @@
75
75
  "SDK"
76
76
  ],
77
77
  "dependencies": {
78
- "@aeternity/aepp-calldata": "^1.4.0",
78
+ "@aeternity/aepp-calldata": "^1.7.0",
79
79
  "@aeternity/argon2": "^0.0.1",
80
80
  "@aeternity/uuid": "^0.0.1",
81
- "@azure/core-client": "1.6.0",
82
- "@azure/core-rest-pipeline": "^1.11.0",
83
- "@babel/runtime-corejs3": "^7.22.6",
84
- "@ledgerhq/hw-transport": "^6.28.6",
85
- "@types/aes-js": "^3.1.1",
86
- "@types/json-bigint": "^1.0.1",
87
- "@types/node": "~18.11.9",
88
- "@types/sha.js": "^2.4.1",
89
- "@types/uuid": "^9.0.2",
90
- "@types/webextension-polyfill": "^0.10.1",
91
- "@types/websocket": "^1.0.5",
92
- "@types/ws": "^8.5.5",
81
+ "@azure/core-client": "^1.8.0",
82
+ "@azure/core-rest-pipeline": "^1.14.0",
83
+ "@babel/runtime-corejs3": "^7.24.0",
84
+ "@ledgerhq/hw-transport": "^6.30.4",
85
+ "@types/aes-js": "^3.1.4",
86
+ "@types/json-bigint": "^1.0.4",
87
+ "@types/node": "~18.13",
88
+ "@types/sha.js": "^2.4.4",
89
+ "@types/uuid": "^9.0.8",
90
+ "@types/webextension-polyfill": "^0.10.7",
91
+ "@types/websocket": "^1.0.10",
92
+ "@types/ws": "^8.5.10",
93
93
  "aes-js": "^3.1.2",
94
- "bignumber.js": "^9.1.1",
94
+ "bignumber.js": "^9.1.2",
95
95
  "bip32-path": "^0.4.2",
96
96
  "blakejs": "^1.2.1",
97
97
  "bs58": "^5.0.0",
@@ -107,58 +107,58 @@
107
107
  "tweetnacl-auth": "^1.0.1",
108
108
  "varuint-bitcoin": "^1.1.2",
109
109
  "websocket": "^1.0.34",
110
- "ws": "^8.13.0"
110
+ "ws": "^8.16.0"
111
111
  },
112
112
  "repository": {
113
113
  "type": "git",
114
114
  "url": "https://github.com/aeternity/aepp-sdk-js"
115
115
  },
116
116
  "devDependencies": {
117
- "@babel/cli": "^7.22.9",
118
- "@babel/core": "^7.22.9",
119
- "@babel/node": "^7.22.6",
120
- "@babel/plugin-transform-runtime": "^7.22.9",
121
- "@babel/preset-env": "^7.22.9",
122
- "@babel/preset-typescript": "^7.22.5",
123
- "@babel/register": "^7.22.5",
124
- "@commitlint/cli": "^17.6.7",
125
- "@commitlint/config-conventional": "^17.6.7",
126
- "@ledgerhq/hw-transport-mocker": "^6.27.17",
127
- "@ledgerhq/hw-transport-node-hid-singleton": "^6.28.16",
128
- "@ledgerhq/hw-transport-webusb": "^6.27.17",
129
- "@types/chai": "^4.3.5",
130
- "@types/chai-as-promised": "^7.1.5",
131
- "@types/mocha": "^10.0.1",
132
- "@types/node-hid": "^1.3.1",
133
- "@types/sinon": "^10.0.15",
134
- "@typescript-eslint/eslint-plugin": "^6.2.0",
135
- "@typescript-eslint/parser": "^6.2.0",
136
- "autorest": "^3.6.3",
117
+ "@babel/cli": "^7.23.9",
118
+ "@babel/core": "^7.24.0",
119
+ "@babel/node": "^7.23.9",
120
+ "@babel/plugin-transform-runtime": "^7.24.0",
121
+ "@babel/preset-env": "^7.24.0",
122
+ "@babel/preset-typescript": "^7.23.3",
123
+ "@babel/register": "^7.23.7",
124
+ "@commitlint/cli": "^19.0.3",
125
+ "@commitlint/config-conventional": "^19.0.3",
126
+ "@ledgerhq/hw-transport-mocker": "^6.28.4",
127
+ "@ledgerhq/hw-transport-node-hid-singleton": "^6.30.4",
128
+ "@ledgerhq/hw-transport-webusb": "^6.28.4",
129
+ "@types/chai": "^4.3.12",
130
+ "@types/chai-as-promised": "^7.1.8",
131
+ "@types/mocha": "^10.0.6",
132
+ "@types/node-hid": "^1.3.4",
133
+ "@types/sinon": "^17.0.3",
134
+ "@typescript-eslint/eslint-plugin": "^7.1.1",
135
+ "@typescript-eslint/parser": "^7.1.1",
136
+ "autorest": "^3.7.1",
137
137
  "babel-loader": "^9.1.3",
138
138
  "babel-plugin-add-import-extension": "^1.6.0",
139
139
  "babel-plugin-import-globals": "^2.0.0",
140
140
  "babel-plugin-transform-default-named-imports": "^1.2.2",
141
- "babel-plugin-transform-import-meta": "^2.2.0",
142
- "chai": "^4.3.7",
141
+ "babel-plugin-transform-import-meta": "^2.2.1",
142
+ "chai": "^4.4.1",
143
143
  "chai-as-promised": "^7.1.1",
144
144
  "downlevel-dts": "github:aeternity/downlevel-dts",
145
- "eslint": "^8.45.0",
145
+ "eslint": "^8.57.0",
146
146
  "eslint-config-airbnb-base": "^15.0.0",
147
- "eslint-config-airbnb-typescript": "^17.1.0",
147
+ "eslint-config-airbnb-typescript": "^18.0.0",
148
148
  "eslint-plugin-rulesdir": "^0.2.2",
149
149
  "eslint-plugin-tsdoc": "^0.2.17",
150
- "html-webpack-plugin": "^5.5.3",
151
- "mocha": "^10.2.0",
150
+ "html-webpack-plugin": "^5.6.0",
151
+ "mocha": "^10.3.0",
152
152
  "nyc": "^15.1.0",
153
- "sinon": "^15.2.0",
153
+ "sinon": "^17.0.1",
154
154
  "source-map": "^0.7.4",
155
155
  "standard-version": "^9.5.0",
156
- "ts-node": "^10.9.1",
157
- "typedoc": "^0.24.8",
158
- "typedoc-plugin-missing-exports": "^2.0.0",
159
- "typescript": "^5.1.6",
160
- "webpack": "^5.88.2",
161
- "webpack-bundle-analyzer": "^4.9.0",
156
+ "ts-node": "^10.9.2",
157
+ "typedoc": "^0.25.11",
158
+ "typedoc-plugin-missing-exports": "^2.2.0",
159
+ "typescript": "^5.3.3",
160
+ "webpack": "^5.90.3",
161
+ "webpack-bundle-analyzer": "^4.10.1",
162
162
  "webpack-cli": "^5.1.4"
163
163
  },
164
164
  "files": [
@@ -189,5 +189,11 @@
189
189
  "engines": {
190
190
  "node": ">=14.19.0"
191
191
  },
192
- "packageManager": "npm@8.19.3"
192
+ "packageManager": "npm@8.19.3",
193
+ "contributors": [
194
+ "Till Kolter <till.kolter@gmail.com>",
195
+ "Alexander Kahl <ak@sodosopa.io>",
196
+ "Nazar Duchak <omelko39@gmail.com>",
197
+ "Denis Davidyuk <denis_davidyuk@hotmail.com>"
198
+ ]
193
199
  }
package/src/AeSdk.ts CHANGED
@@ -9,6 +9,9 @@ export default class AeSdk extends AeSdkBase {
9
9
 
10
10
  selectedAddress?: Encoded.AccountAddress;
11
11
 
12
+ /**
13
+ * @param options - Options
14
+ */
12
15
  constructor(
13
16
  { accounts, ...options }: { accounts?: AccountBase[] }
14
17
  & ConstructorParameters<typeof AeSdkBase>[0] = {},
package/src/AeSdkAepp.ts CHANGED
@@ -88,7 +88,6 @@ export default class AeSdkAepp extends AeSdkBase {
88
88
  * @param options - Options
89
89
  * @param options.connectNode - Request wallet to bind node
90
90
  * @param options.name - Node name
91
- * @param options.select - Select this node as current
92
91
  */
93
92
  async connectToWallet(
94
93
  connection: BrowserConnection,
package/src/AeSdkBase.ts CHANGED
@@ -4,8 +4,9 @@ import {
4
4
  CompilerError, DuplicateNodeError, NodeNotFoundError, NotImplementedError, TypeError,
5
5
  } from './utils/errors';
6
6
  import { Encoded } from './utils/encoder';
7
+ import { wrapWithProxy } from './utils/wrap-proxy';
7
8
  import CompilerBase from './contract/compiler/Base';
8
- import AeSdkMethods, { OnAccount, getValueOrErrorProxy, AeSdkMethodsOptions } from './AeSdkMethods';
9
+ import AeSdkMethods, { OnAccount, AeSdkMethodsOptions, WrappedOptions } from './AeSdkMethods';
9
10
  import { AensName } from './tx/builder/constants';
10
11
 
11
12
  type NodeInfo = Awaited<ReturnType<Node['getNodeInfo']>> & { name: string };
@@ -21,6 +22,8 @@ export default class AeSdkBase extends AeSdkMethods {
21
22
 
22
23
  selectedNodeName?: string;
23
24
 
25
+ readonly #wrappedOptions: WrappedOptions;
26
+
24
27
  /**
25
28
  * @param options - Options
26
29
  * @param options.nodes - Array of nodes
@@ -33,6 +36,12 @@ export default class AeSdkBase extends AeSdkMethods {
33
36
  super(options);
34
37
 
35
38
  nodes.forEach(({ name, instance }, i) => this.addNode(name, instance, i === 0));
39
+
40
+ this.#wrappedOptions = {
41
+ onNode: wrapWithProxy(() => this.api),
42
+ onCompiler: wrapWithProxy(() => this.compilerApi),
43
+ onAccount: wrapWithProxy(() => this._resolveAccount()),
44
+ };
36
45
  }
37
46
 
38
47
  // TODO: consider dropping this getter, because:
@@ -147,6 +156,11 @@ export default class AeSdkBase extends AeSdkMethods {
147
156
  return this._resolveAccount().address;
148
157
  }
149
158
 
159
+ /**
160
+ * Sign data blob
161
+ * @param data - Data to sign
162
+ * @param options - Options
163
+ */
150
164
  async sign(
151
165
  data: string | Uint8Array,
152
166
  { onAccount, ...options }: { onAccount?: OnAccount } = {},
@@ -154,6 +168,11 @@ export default class AeSdkBase extends AeSdkMethods {
154
168
  return this._resolveAccount(onAccount).sign(data, options);
155
169
  }
156
170
 
171
+ /**
172
+ * Sign encoded transaction
173
+ * @param tx - Transaction to sign
174
+ * @param options - Options
175
+ */
157
176
  async signTransaction(
158
177
  tx: Encoded.Transaction,
159
178
  { onAccount, ...options }: { onAccount?: OnAccount } & Parameters<AccountBase['signTransaction']>[1] = {},
@@ -162,6 +181,11 @@ export default class AeSdkBase extends AeSdkMethods {
162
181
  return this._resolveAccount(onAccount).signTransaction(tx, { networkId, ...options });
163
182
  }
164
183
 
184
+ /**
185
+ * Sign message
186
+ * @param message - Message to sign
187
+ * @param options - Options
188
+ */
165
189
  async signMessage(
166
190
  message: string,
167
191
  { onAccount, ...options }: { onAccount?: OnAccount } & Parameters<AccountBase['signMessage']>[1] = {},
@@ -169,6 +193,12 @@ export default class AeSdkBase extends AeSdkMethods {
169
193
  return this._resolveAccount(onAccount).signMessage(message, options);
170
194
  }
171
195
 
196
+ /**
197
+ * Sign typed data
198
+ * @param data - Encoded data to sign
199
+ * @param aci - Type of data to sign
200
+ * @param options - Options
201
+ */
172
202
  async signTypedData(
173
203
  data: Encoded.ContractBytearray,
174
204
  aci: Parameters<AccountBase['signTypedData']>[1],
@@ -177,6 +207,11 @@ export default class AeSdkBase extends AeSdkMethods {
177
207
  return this._resolveAccount(onAccount).signTypedData(data, aci, options);
178
208
  }
179
209
 
210
+ /**
211
+ * @deprecated use AeSdkBase:signDelegation in Ceres
212
+ * @param contractAddress - Contract address
213
+ * @param options - Options
214
+ */
180
215
  async signDelegationToContract(
181
216
  contractAddress: Encoded.ContractAddress,
182
217
  { onAccount, ...options }: { onAccount?: OnAccount }
@@ -184,10 +219,18 @@ export default class AeSdkBase extends AeSdkMethods {
184
219
  ): Promise<Encoded.Signature> {
185
220
  options.networkId ??= this.selectedNodeName !== null
186
221
  ? await this.api.getNetworkId() : undefined;
222
+ options.consensusProtocolVersion ??= this.selectedNodeName !== null
223
+ ? (await this.api.getNodeInfo()).consensusProtocolVersion : undefined;
187
224
  return this._resolveAccount(onAccount)
188
225
  .signDelegationToContract(contractAddress, options);
189
226
  }
190
227
 
228
+ /**
229
+ * @deprecated use AeSdkBase:signDelegation in Ceres
230
+ * @param contractAddress - Contract address
231
+ * @param name - AENS name
232
+ * @param options - Options
233
+ */
191
234
  async signNameDelegationToContract(
192
235
  contractAddress: Encoded.ContractAddress,
193
236
  name: AensName,
@@ -196,10 +239,36 @@ export default class AeSdkBase extends AeSdkMethods {
196
239
  ): Promise<Encoded.Signature> {
197
240
  options.networkId ??= this.selectedNodeName !== null
198
241
  ? await this.api.getNetworkId() : undefined;
242
+ options.consensusProtocolVersion ??= this.selectedNodeName !== null
243
+ ? (await this.api.getNodeInfo()).consensusProtocolVersion : undefined;
199
244
  return this._resolveAccount(onAccount)
200
245
  .signNameDelegationToContract(contractAddress, name, options);
201
246
  }
202
247
 
248
+ /**
249
+ * @deprecated use AeSdkBase:signDelegation in Ceres
250
+ * @param contractAddress - Contract address
251
+ * @param options - Options
252
+ */
253
+ async signAllNamesDelegationToContract(
254
+ contractAddress: Encoded.ContractAddress,
255
+ { onAccount, ...options }: { onAccount?: OnAccount }
256
+ & Parameters<AccountBase['signAllNamesDelegationToContract']>[1] = {},
257
+ ): Promise<Encoded.Signature> {
258
+ options.networkId ??= this.selectedNodeName !== null
259
+ ? await this.api.getNetworkId() : undefined;
260
+ options.consensusProtocolVersion ??= this.selectedNodeName !== null
261
+ ? (await this.api.getNodeInfo()).consensusProtocolVersion : undefined;
262
+ return this._resolveAccount(onAccount)
263
+ .signAllNamesDelegationToContract(contractAddress, options);
264
+ }
265
+
266
+ /**
267
+ * @deprecated use AeSdkBase:signDelegation in Ceres
268
+ * @param contractAddress - Contract address
269
+ * @param oracleQueryId - Oracle query id
270
+ * @param options - Options
271
+ */
203
272
  async signOracleQueryDelegationToContract(
204
273
  contractAddress: Encoded.ContractAddress,
205
274
  oracleQueryId: Encoded.OracleQueryId,
@@ -208,21 +277,39 @@ export default class AeSdkBase extends AeSdkMethods {
208
277
  ): Promise<Encoded.Signature> {
209
278
  options.networkId ??= this.selectedNodeName !== null
210
279
  ? await this.api.getNetworkId() : undefined;
280
+ options.consensusProtocolVersion ??= this.selectedNodeName !== null
281
+ ? (await this.api.getNodeInfo()).consensusProtocolVersion : undefined;
211
282
  return this._resolveAccount(onAccount)
212
283
  .signOracleQueryDelegationToContract(contractAddress, oracleQueryId, options);
213
284
  }
214
285
 
215
- override _getOptions(callOptions: AeSdkMethodsOptions = {}): {
216
- onNode: Node;
217
- onAccount: AccountBase;
218
- onCompiler: CompilerBase;
219
- } {
286
+ /**
287
+ * Sign delegation, works only in Ceres
288
+ * @param delegation - Delegation to sign
289
+ * @param options - Options
290
+ */
291
+ async signDelegation(
292
+ delegation: Encoded.Bytearray,
293
+ { onAccount, ...options }: { onAccount?: OnAccount }
294
+ & Parameters<AccountBase['signDelegation']>[1] = {},
295
+ ): Promise<Encoded.Signature> {
296
+ options.networkId ??= this.selectedNodeName !== null
297
+ ? await this.api.getNetworkId() : undefined;
298
+ return this._resolveAccount(onAccount).signDelegation(delegation, options);
299
+ }
300
+
301
+ /**
302
+ * The same as AeSdkMethods:getContext, but it would resolve ak_-prefixed address in
303
+ * `mergeWith.onAccount` to AccountBase.
304
+ */
305
+ override getContext(mergeWith: AeSdkMethodsOptions = {}): AeSdkMethodsOptions & WrappedOptions {
220
306
  return {
221
307
  ...this._options,
222
- onNode: getValueOrErrorProxy(() => this.api),
223
- onCompiler: getValueOrErrorProxy(() => this.compilerApi),
224
- ...callOptions,
225
- onAccount: getValueOrErrorProxy(() => this._resolveAccount(callOptions.onAccount)),
308
+ ...this.#wrappedOptions,
309
+ ...mergeWith,
310
+ ...mergeWith.onAccount != null && {
311
+ onAccount: this._resolveAccount(mergeWith.onAccount),
312
+ },
226
313
  };
227
314
  }
228
315
  }