@aeternity/aepp-sdk 13.0.0-alpha.0 → 13.0.0-beta.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 (481) hide show
  1. package/bin/aesophia_cli +0 -0
  2. package/dist/aepp-sdk.browser-script.js +1 -1
  3. package/dist/aepp-sdk.browser-script.js.map +1 -1
  4. package/dist/aepp-sdk.browser.js +1 -1
  5. package/dist/aepp-sdk.browser.js.map +1 -1
  6. package/dist/aepp-sdk.js +5595 -2249
  7. package/dist/aepp-sdk.js.map +1 -1
  8. package/es/AeSdk.mjs.map +1 -1
  9. package/es/AeSdkAepp.mjs.map +1 -1
  10. package/es/AeSdkBase.d.ts +3 -3
  11. package/es/AeSdkBase.mjs +4 -0
  12. package/es/AeSdkBase.mjs.map +1 -1
  13. package/es/AeSdkMethods.d.ts +12 -14
  14. package/es/AeSdkMethods.mjs +6 -8
  15. package/es/AeSdkMethods.mjs.map +1 -1
  16. package/es/AeSdkWallet.mjs +1 -1
  17. package/es/AeSdkWallet.mjs.map +1 -1
  18. package/es/Node.d.ts +9 -4
  19. package/es/Node.mjs +12 -6
  20. package/es/Node.mjs.map +1 -1
  21. package/es/account/Base.d.ts +13 -8
  22. package/es/account/Base.mjs +0 -17
  23. package/es/account/Base.mjs.map +1 -1
  24. package/es/account/Generalized.mjs +14 -25
  25. package/es/account/Generalized.mjs.map +1 -1
  26. package/es/account/Ledger.mjs +2 -1
  27. package/es/account/Ledger.mjs.map +1 -1
  28. package/es/account/LedgerFactory.mjs.map +1 -1
  29. package/es/account/Memory.d.ts +2 -1
  30. package/es/account/Memory.mjs +11 -22
  31. package/es/account/Memory.mjs.map +1 -1
  32. package/es/account/Rpc.mjs.map +1 -1
  33. package/es/aens.d.ts +12 -14
  34. package/es/aens.mjs +22 -32
  35. package/es/aens.mjs.map +1 -1
  36. package/es/aepp-wallet-communication/connection/Browser.mjs +0 -16
  37. package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -1
  38. package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +1 -0
  39. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +19 -20
  40. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
  41. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +0 -16
  42. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -1
  43. package/es/aepp-wallet-communication/connection-proxy.mjs +0 -17
  44. package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -1
  45. package/es/aepp-wallet-communication/rpc/RpcClient.mjs +5 -6
  46. package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
  47. package/es/aepp-wallet-communication/rpc/types.d.ts +6 -2
  48. package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
  49. package/es/aepp-wallet-communication/schema.mjs.map +1 -1
  50. package/es/aepp-wallet-communication/wallet-detector.mjs +0 -16
  51. package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
  52. package/es/apis/compiler/compiler.d.ts +1 -1
  53. package/es/apis/compiler/compiler.mjs +4 -20
  54. package/es/apis/compiler/compiler.mjs.map +1 -1
  55. package/es/apis/compiler/models/index.d.ts +3 -2
  56. package/es/apis/compiler/models/index.mjs.map +1 -1
  57. package/es/apis/compiler/models/mappers.d.ts +1 -1
  58. package/es/apis/compiler/models/mappers.mjs +19 -2
  59. package/es/apis/compiler/models/mappers.mjs.map +1 -1
  60. package/es/apis/node/models/index.d.ts +15 -15
  61. package/es/apis/node/models/index.mjs.map +1 -1
  62. package/es/apis/node/models/mappers.d.ts +1 -1
  63. package/es/apis/node/models/mappers.mjs +2 -1
  64. package/es/apis/node/models/mappers.mjs.map +1 -1
  65. package/es/apis/node/models/parameters.d.ts +2 -2
  66. package/es/apis/node/models/parameters.mjs +2 -2
  67. package/es/apis/node/models/parameters.mjs.map +1 -1
  68. package/es/apis/node/node.mjs +3 -19
  69. package/es/apis/node/node.mjs.map +1 -1
  70. package/es/chain.d.ts +17 -9
  71. package/es/chain.mjs +23 -23
  72. package/es/chain.mjs.map +1 -1
  73. package/es/channel/Base.d.ts +27 -9
  74. package/es/channel/Base.mjs +27 -27
  75. package/es/channel/Base.mjs.map +1 -1
  76. package/es/channel/Contract.d.ts +8 -7
  77. package/es/channel/Contract.mjs +8 -21
  78. package/es/channel/Contract.mjs.map +1 -1
  79. package/es/channel/Spend.d.ts +5 -1
  80. package/es/channel/Spend.mjs +4 -18
  81. package/es/channel/Spend.mjs.map +1 -1
  82. package/es/channel/handlers.mjs +16 -26
  83. package/es/channel/handlers.mjs.map +1 -1
  84. package/es/channel/internal.d.ts +19 -2
  85. package/es/channel/internal.mjs +22 -20
  86. package/es/channel/internal.mjs.map +1 -1
  87. package/es/contract/Contract.d.ts +43 -123
  88. package/es/contract/Contract.mjs +230 -250
  89. package/es/contract/Contract.mjs.map +1 -1
  90. package/es/contract/compiler/Base.d.ts +74 -0
  91. package/es/contract/compiler/Base.mjs +5 -0
  92. package/es/contract/compiler/Base.mjs.map +1 -0
  93. package/es/contract/compiler/Cli.d.ts +23 -0
  94. package/es/contract/compiler/Cli.mjs +149 -0
  95. package/es/contract/compiler/Cli.mjs.map +1 -0
  96. package/es/contract/compiler/Http.d.ts +32 -0
  97. package/es/contract/compiler/Http.mjs +94 -0
  98. package/es/contract/compiler/Http.mjs.map +1 -0
  99. package/es/contract/compiler/HttpNode.d.ts +17 -0
  100. package/es/contract/compiler/HttpNode.mjs +26 -0
  101. package/es/contract/compiler/HttpNode.mjs.map +1 -0
  102. package/es/contract/compiler/getFileSystem.d.ts +6 -0
  103. package/es/contract/compiler/getFileSystem.mjs +40 -0
  104. package/es/contract/compiler/getFileSystem.mjs.map +1 -0
  105. package/es/contract/delegation-signature.d.ts +43 -0
  106. package/es/contract/delegation-signature.mjs +45 -0
  107. package/es/contract/delegation-signature.mjs.map +1 -0
  108. package/es/contract/ga.d.ts +27 -10
  109. package/es/contract/ga.mjs +63 -29
  110. package/es/contract/ga.mjs.map +1 -1
  111. package/es/index-browser.d.ts +40 -0
  112. package/es/index-browser.mjs +41 -0
  113. package/es/index-browser.mjs.map +1 -0
  114. package/es/index.d.ts +4 -38
  115. package/es/index.mjs +4 -53
  116. package/es/index.mjs.map +1 -1
  117. package/es/oracle.d.ts +12 -17
  118. package/es/oracle.mjs +29 -49
  119. package/es/oracle.mjs.map +1 -1
  120. package/es/spend.d.ts +19 -27
  121. package/es/spend.mjs +21 -46
  122. package/es/spend.mjs.map +1 -1
  123. package/es/tx/builder/SchemaTypes.d.ts +37 -0
  124. package/es/tx/builder/SchemaTypes.mjs +2 -0
  125. package/es/tx/builder/SchemaTypes.mjs.map +1 -0
  126. package/es/tx/builder/constants.d.ts +31 -2
  127. package/es/tx/builder/constants.mjs +34 -3
  128. package/es/tx/builder/constants.mjs.map +1 -1
  129. package/es/tx/builder/field-types/abi-version.d.ts +19 -0
  130. package/es/tx/builder/field-types/abi-version.mjs +40 -0
  131. package/es/tx/builder/field-types/abi-version.mjs.map +1 -0
  132. package/es/tx/builder/field-types/address.d.ts +5 -6
  133. package/es/tx/builder/field-types/address.mjs +17 -8
  134. package/es/tx/builder/field-types/address.mjs.map +1 -1
  135. package/es/tx/builder/field-types/array.d.ts +7 -0
  136. package/es/tx/builder/field-types/array.mjs +11 -0
  137. package/es/tx/builder/field-types/array.mjs.map +1 -0
  138. package/es/tx/builder/field-types/boolean.d.ts +6 -0
  139. package/es/tx/builder/field-types/boolean.mjs +13 -0
  140. package/es/tx/builder/field-types/boolean.mjs.map +1 -0
  141. package/es/tx/builder/field-types/coin-amount.d.ts +4 -5
  142. package/es/tx/builder/field-types/coin-amount.mjs +4 -5
  143. package/es/tx/builder/field-types/coin-amount.mjs.map +1 -1
  144. package/es/tx/builder/field-types/ct-version.d.ts +49 -0
  145. package/es/tx/builder/field-types/ct-version.mjs +76 -0
  146. package/es/tx/builder/field-types/ct-version.mjs.map +1 -0
  147. package/es/tx/builder/field-types/deposit.d.ts +3 -2
  148. package/es/tx/builder/field-types/deposit.mjs +3 -2
  149. package/es/tx/builder/field-types/deposit.mjs.map +1 -1
  150. package/es/tx/builder/field-types/encoded.d.ts +6 -0
  151. package/es/tx/builder/field-types/encoded.mjs +21 -0
  152. package/es/tx/builder/field-types/encoded.mjs.map +1 -0
  153. package/es/tx/builder/field-types/entry.d.ts +11 -0
  154. package/es/tx/builder/field-types/entry.mjs +34 -0
  155. package/es/tx/builder/field-types/entry.mjs.map +1 -0
  156. package/es/tx/builder/field-types/enumeration.d.ts +5 -3
  157. package/es/tx/builder/field-types/enumeration.mjs +11 -2
  158. package/es/tx/builder/field-types/enumeration.mjs.map +1 -1
  159. package/es/tx/builder/field-types/fee.d.ts +12 -7
  160. package/es/tx/builder/field-types/fee.mjs +28 -20
  161. package/es/tx/builder/field-types/fee.mjs.map +1 -1
  162. package/es/tx/builder/field-types/field.mjs.map +1 -1
  163. package/es/tx/builder/field-types/gas-limit.d.ts +7 -3
  164. package/es/tx/builder/field-types/gas-limit.mjs +13 -8
  165. package/es/tx/builder/field-types/gas-limit.mjs.map +1 -1
  166. package/es/tx/builder/field-types/gas-price.d.ts +3 -1
  167. package/es/tx/builder/field-types/gas-price.mjs.map +1 -1
  168. package/es/tx/builder/field-types/index.d.ts +107 -30
  169. package/es/tx/builder/field-types/index.mjs +38 -12
  170. package/es/tx/builder/field-types/index.mjs.map +1 -1
  171. package/es/tx/builder/field-types/map.d.ts +13 -0
  172. package/es/tx/builder/field-types/map.mjs +49 -0
  173. package/es/tx/builder/field-types/map.mjs.map +1 -0
  174. package/es/tx/builder/field-types/mptree.d.ts +42 -0
  175. package/es/tx/builder/field-types/mptree.mjs +266 -0
  176. package/es/tx/builder/field-types/mptree.mjs.map +1 -0
  177. package/es/tx/builder/field-types/name-fee.d.ts +2 -3
  178. package/es/tx/builder/field-types/name-fee.mjs +2 -2
  179. package/es/tx/builder/field-types/name-fee.mjs.map +1 -1
  180. package/es/tx/builder/field-types/name-id.mjs +2 -1
  181. package/es/tx/builder/field-types/name-id.mjs.map +1 -1
  182. package/es/tx/builder/field-types/name.mjs.map +1 -1
  183. package/es/tx/builder/field-types/nonce.d.ts +14 -0
  184. package/es/tx/builder/field-types/nonce.mjs +29 -0
  185. package/es/tx/builder/field-types/nonce.mjs.map +1 -0
  186. package/es/tx/builder/field-types/pointers.mjs +2 -2
  187. package/es/tx/builder/field-types/pointers.mjs.map +1 -1
  188. package/es/tx/builder/field-types/raw.d.ts +6 -0
  189. package/es/tx/builder/field-types/raw.mjs +13 -0
  190. package/es/tx/builder/field-types/raw.mjs.map +1 -0
  191. package/es/tx/builder/field-types/short-u-int-const.d.ts +7 -0
  192. package/es/tx/builder/field-types/short-u-int-const.mjs +20 -0
  193. package/es/tx/builder/field-types/short-u-int-const.mjs.map +1 -0
  194. package/es/tx/builder/field-types/short-u-int.mjs.map +1 -1
  195. package/es/tx/builder/field-types/string.d.ts +6 -0
  196. package/es/tx/builder/field-types/string.mjs +10 -0
  197. package/es/tx/builder/field-types/string.mjs.map +1 -0
  198. package/es/tx/builder/field-types/ttl.d.ts +11 -0
  199. package/es/tx/builder/field-types/ttl.mjs +21 -0
  200. package/es/tx/builder/field-types/ttl.mjs.map +1 -0
  201. package/es/tx/builder/field-types/u-int.d.ts +1 -2
  202. package/es/tx/builder/field-types/u-int.mjs.map +1 -1
  203. package/es/tx/builder/field-types/wrapped.d.ts +14 -0
  204. package/es/tx/builder/field-types/wrapped.mjs +22 -0
  205. package/es/tx/builder/field-types/wrapped.mjs.map +1 -0
  206. package/es/tx/builder/helpers.mjs.map +1 -1
  207. package/es/tx/builder/index.d.ts +18 -36
  208. package/es/tx/builder/index.mjs +65 -236
  209. package/es/tx/builder/index.mjs.map +1 -1
  210. package/es/tx/builder/schema.d.ts +2734 -1324
  211. package/es/tx/builder/schema.generated.d.ts +2011 -0
  212. package/es/tx/builder/schema.generated.mjs +2 -0
  213. package/es/tx/builder/schema.generated.mjs.map +1 -0
  214. package/es/tx/builder/schema.mjs +459 -223
  215. package/es/tx/builder/schema.mjs.map +1 -1
  216. package/es/tx/execution-cost.d.ts +35 -0
  217. package/es/tx/execution-cost.mjs +123 -0
  218. package/es/tx/execution-cost.mjs.map +1 -0
  219. package/es/tx/transaction-signer.d.ts +6 -0
  220. package/es/tx/transaction-signer.mjs +27 -0
  221. package/es/tx/transaction-signer.mjs.map +1 -0
  222. package/es/tx/validator.d.ts +3 -5
  223. package/es/tx/validator.mjs +91 -153
  224. package/es/tx/validator.mjs.map +1 -1
  225. package/es/utils/amount-formatter.mjs +0 -16
  226. package/es/utils/amount-formatter.mjs.map +1 -1
  227. package/es/utils/autorest.d.ts +3 -2
  228. package/es/utils/autorest.mjs +43 -11
  229. package/es/utils/autorest.mjs.map +1 -1
  230. package/es/utils/bytes.mjs +1 -17
  231. package/es/utils/bytes.mjs.map +1 -1
  232. package/es/utils/crypto.mjs +0 -16
  233. package/es/utils/crypto.mjs.map +1 -1
  234. package/es/utils/encoder.mjs.map +1 -1
  235. package/es/utils/errors.d.ts +16 -38
  236. package/es/utils/errors.mjs +3 -43
  237. package/es/utils/errors.mjs.map +1 -1
  238. package/es/utils/hd-wallet.mjs.map +1 -1
  239. package/es/utils/json-big.mjs.map +1 -1
  240. package/es/utils/keystore.mjs.map +1 -1
  241. package/es/utils/other.mjs.map +1 -1
  242. package/es/utils/semver-satisfies.mjs.map +1 -1
  243. package/es/utils/string.mjs +0 -17
  244. package/es/utils/string.mjs.map +1 -1
  245. package/package.json +52 -40
  246. package/src/AeSdkBase.ts +6 -3
  247. package/src/AeSdkMethods.ts +12 -18
  248. package/src/AeSdkWallet.ts +1 -1
  249. package/src/Node.ts +23 -9
  250. package/src/account/Base.ts +13 -24
  251. package/src/account/Generalized.ts +9 -24
  252. package/src/account/Ledger.ts +1 -1
  253. package/src/account/Memory.ts +15 -22
  254. package/src/aens.ts +34 -49
  255. package/src/aepp-wallet-communication/connection/Browser.ts +0 -17
  256. package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +18 -24
  257. package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +0 -17
  258. package/src/aepp-wallet-communication/connection-proxy.ts +0 -17
  259. package/src/aepp-wallet-communication/rpc/RpcClient.ts +2 -2
  260. package/src/aepp-wallet-communication/rpc/types.ts +6 -2
  261. package/src/aepp-wallet-communication/wallet-detector.ts +0 -17
  262. package/src/apis/compiler/compiler.ts +3 -27
  263. package/src/apis/compiler/models/index.ts +3 -2
  264. package/src/apis/compiler/models/mappers.ts +15 -2
  265. package/src/apis/node/models/index.ts +16 -15
  266. package/src/apis/node/models/mappers.ts +2 -1
  267. package/src/apis/node/models/parameters.ts +2 -2
  268. package/src/apis/node/node.ts +3 -27
  269. package/src/chain.ts +33 -30
  270. package/src/channel/Base.ts +39 -31
  271. package/src/channel/Contract.ts +18 -32
  272. package/src/channel/Spend.ts +8 -18
  273. package/src/channel/handlers.ts +14 -26
  274. package/src/channel/internal.ts +41 -23
  275. package/src/contract/Contract.ts +188 -228
  276. package/src/contract/compiler/Base.ts +87 -0
  277. package/src/contract/compiler/Cli.ts +128 -0
  278. package/src/contract/compiler/Http.ts +105 -0
  279. package/src/contract/compiler/HttpNode.ts +26 -0
  280. package/src/contract/compiler/getFileSystem.ts +42 -0
  281. package/src/contract/delegation-signature.ts +56 -0
  282. package/src/contract/ga.ts +61 -37
  283. package/src/index-browser.ts +50 -0
  284. package/src/index.ts +4 -56
  285. package/src/oracle.ts +47 -57
  286. package/src/spend.ts +34 -68
  287. package/src/tx/builder/SchemaTypes.ts +79 -0
  288. package/src/tx/builder/constants.ts +34 -3
  289. package/src/tx/builder/field-types/abi-version.ts +44 -0
  290. package/src/tx/builder/field-types/address.ts +23 -13
  291. package/src/tx/builder/field-types/array.ts +19 -0
  292. package/src/tx/builder/field-types/boolean.ts +9 -0
  293. package/src/tx/builder/field-types/coin-amount.ts +8 -5
  294. package/src/tx/builder/field-types/ct-version.ts +83 -0
  295. package/src/tx/builder/field-types/deposit.ts +4 -2
  296. package/src/tx/builder/field-types/encoded.ts +27 -0
  297. package/src/tx/builder/field-types/entry.ts +36 -0
  298. package/src/tx/builder/field-types/enumeration.ts +15 -4
  299. package/src/tx/builder/field-types/fee.ts +41 -19
  300. package/src/tx/builder/field-types/gas-limit.ts +13 -8
  301. package/src/tx/builder/field-types/index.ts +60 -17
  302. package/src/tx/builder/field-types/map.ts +45 -0
  303. package/src/tx/builder/field-types/mptree.ts +243 -0
  304. package/src/tx/builder/field-types/name-fee.ts +3 -3
  305. package/src/tx/builder/field-types/name-id.ts +1 -1
  306. package/src/tx/builder/field-types/nonce.ts +40 -0
  307. package/src/tx/builder/field-types/pointers.ts +2 -2
  308. package/src/tx/builder/field-types/raw.ts +9 -0
  309. package/src/tx/builder/field-types/short-u-int-const.ts +30 -0
  310. package/src/tx/builder/field-types/string.ts +11 -0
  311. package/src/tx/builder/field-types/ttl.ts +24 -0
  312. package/src/tx/builder/field-types/u-int.ts +1 -3
  313. package/src/tx/builder/field-types/wrapped.ts +32 -0
  314. package/src/tx/builder/index.ts +82 -280
  315. package/src/tx/builder/schema.generated.ts +2013 -0
  316. package/src/tx/builder/schema.ts +536 -666
  317. package/src/tx/execution-cost.ts +146 -0
  318. package/src/tx/transaction-signer.ts +27 -0
  319. package/src/tx/validator.ts +100 -154
  320. package/src/utils/amount-formatter.ts +0 -16
  321. package/src/utils/autorest.ts +52 -11
  322. package/src/utils/bytes.ts +1 -17
  323. package/src/utils/crypto.ts +0 -16
  324. package/src/utils/errors.ts +18 -56
  325. package/src/utils/string.ts +0 -17
  326. package/types-legacy/ts4.2/AeSdkBase.d.ts +3 -3
  327. package/types-legacy/ts4.2/AeSdkMethods.d.ts +12 -14
  328. package/types-legacy/ts4.2/Node.d.ts +8 -4
  329. package/types-legacy/ts4.2/account/Base.d.ts +13 -8
  330. package/types-legacy/ts4.2/account/Memory.d.ts +2 -1
  331. package/types-legacy/ts4.2/aens.d.ts +12 -14
  332. package/types-legacy/ts4.2/aepp-wallet-communication/connection/BrowserRuntime.d.ts +1 -0
  333. package/types-legacy/ts4.2/aepp-wallet-communication/rpc/types.d.ts +6 -2
  334. package/types-legacy/ts4.2/apis/compiler/compiler.d.ts +1 -1
  335. package/types-legacy/ts4.2/apis/compiler/models/index.d.ts +3 -2
  336. package/types-legacy/ts4.2/apis/compiler/models/mappers.d.ts +1 -1
  337. package/types-legacy/ts4.2/apis/node/models/index.d.ts +15 -15
  338. package/types-legacy/ts4.2/apis/node/models/mappers.d.ts +1 -1
  339. package/types-legacy/ts4.2/apis/node/models/parameters.d.ts +2 -2
  340. package/types-legacy/ts4.2/chain.d.ts +17 -9
  341. package/types-legacy/ts4.2/channel/Base.d.ts +27 -9
  342. package/types-legacy/ts4.2/channel/Contract.d.ts +8 -7
  343. package/types-legacy/ts4.2/channel/Spend.d.ts +5 -1
  344. package/types-legacy/ts4.2/channel/internal.d.ts +22 -2
  345. package/types-legacy/ts4.2/contract/Contract.d.ts +42 -122
  346. package/types-legacy/ts4.2/contract/compiler/Base.d.ts +74 -0
  347. package/types-legacy/ts4.2/contract/compiler/Cli.d.ts +23 -0
  348. package/types-legacy/ts4.2/contract/compiler/Http.d.ts +32 -0
  349. package/types-legacy/ts4.2/contract/compiler/HttpNode.d.ts +17 -0
  350. package/types-legacy/ts4.2/contract/compiler/getFileSystem.d.ts +6 -0
  351. package/types-legacy/ts4.2/contract/delegation-signature.d.ts +43 -0
  352. package/types-legacy/ts4.2/contract/ga.d.ts +27 -10
  353. package/types-legacy/ts4.2/index-browser.d.ts +40 -0
  354. package/types-legacy/ts4.2/index.d.ts +4 -38
  355. package/types-legacy/ts4.2/oracle.d.ts +12 -17
  356. package/types-legacy/ts4.2/spend.d.ts +19 -27
  357. package/types-legacy/ts4.2/tx/builder/SchemaTypes.d.ts +37 -0
  358. package/types-legacy/ts4.2/tx/builder/constants.d.ts +31 -2
  359. package/types-legacy/ts4.2/tx/builder/field-types/abi-version.d.ts +19 -0
  360. package/types-legacy/ts4.2/tx/builder/field-types/address.d.ts +11 -12
  361. package/types-legacy/ts4.2/tx/builder/field-types/array.d.ts +7 -0
  362. package/types-legacy/ts4.2/tx/builder/field-types/boolean.d.ts +6 -0
  363. package/types-legacy/ts4.2/tx/builder/field-types/coin-amount.d.ts +4 -5
  364. package/types-legacy/ts4.2/tx/builder/field-types/ct-version.d.ts +72 -0
  365. package/types-legacy/ts4.2/tx/builder/field-types/deposit.d.ts +3 -2
  366. package/types-legacy/ts4.2/tx/builder/field-types/encoded.d.ts +6 -0
  367. package/types-legacy/ts4.2/tx/builder/field-types/entry.d.ts +11 -0
  368. package/types-legacy/ts4.2/tx/builder/field-types/enumeration.d.ts +5 -3
  369. package/types-legacy/ts4.2/tx/builder/field-types/fee.d.ts +12 -7
  370. package/types-legacy/ts4.2/tx/builder/field-types/gas-limit.d.ts +7 -3
  371. package/types-legacy/ts4.2/tx/builder/field-types/gas-price.d.ts +3 -1
  372. package/types-legacy/ts4.2/tx/builder/field-types/index.d.ts +113 -30
  373. package/types-legacy/ts4.2/tx/builder/field-types/map.d.ts +13 -0
  374. package/types-legacy/ts4.2/tx/builder/field-types/mptree.d.ts +48 -0
  375. package/types-legacy/ts4.2/tx/builder/field-types/name-fee.d.ts +2 -3
  376. package/types-legacy/ts4.2/tx/builder/field-types/nonce.d.ts +14 -0
  377. package/types-legacy/ts4.2/tx/builder/field-types/raw.d.ts +6 -0
  378. package/types-legacy/ts4.2/tx/builder/field-types/short-u-int-const.d.ts +7 -0
  379. package/types-legacy/ts4.2/tx/builder/field-types/string.d.ts +6 -0
  380. package/types-legacy/ts4.2/tx/builder/field-types/ttl.d.ts +11 -0
  381. package/types-legacy/ts4.2/tx/builder/field-types/u-int.d.ts +1 -2
  382. package/types-legacy/ts4.2/tx/builder/field-types/wrapped.d.ts +14 -0
  383. package/types-legacy/ts4.2/tx/builder/index.d.ts +21 -36
  384. package/types-legacy/ts4.2/tx/builder/schema.d.ts +2971 -2926
  385. package/types-legacy/ts4.2/tx/builder/schema.generated.d.ts +2011 -0
  386. package/types-legacy/ts4.2/tx/execution-cost.d.ts +35 -0
  387. package/types-legacy/ts4.2/tx/transaction-signer.d.ts +6 -0
  388. package/types-legacy/ts4.2/tx/validator.d.ts +3 -5
  389. package/types-legacy/ts4.2/utils/autorest.d.ts +3 -2
  390. package/types-legacy/ts4.2/utils/errors.d.ts +16 -38
  391. package/types-legacy/ts4.5/AeSdkBase.d.ts +3 -3
  392. package/types-legacy/ts4.5/AeSdkMethods.d.ts +12 -14
  393. package/types-legacy/ts4.5/Node.d.ts +8 -4
  394. package/types-legacy/ts4.5/account/Base.d.ts +13 -8
  395. package/types-legacy/ts4.5/account/Memory.d.ts +2 -1
  396. package/types-legacy/ts4.5/aens.d.ts +12 -14
  397. package/types-legacy/ts4.5/aepp-wallet-communication/connection/BrowserRuntime.d.ts +1 -0
  398. package/types-legacy/ts4.5/aepp-wallet-communication/rpc/types.d.ts +6 -2
  399. package/types-legacy/ts4.5/apis/compiler/compiler.d.ts +1 -1
  400. package/types-legacy/ts4.5/apis/compiler/models/index.d.ts +3 -2
  401. package/types-legacy/ts4.5/apis/compiler/models/mappers.d.ts +1 -1
  402. package/types-legacy/ts4.5/apis/node/models/index.d.ts +15 -15
  403. package/types-legacy/ts4.5/apis/node/models/mappers.d.ts +1 -1
  404. package/types-legacy/ts4.5/apis/node/models/parameters.d.ts +2 -2
  405. package/types-legacy/ts4.5/chain.d.ts +17 -9
  406. package/types-legacy/ts4.5/channel/Base.d.ts +27 -9
  407. package/types-legacy/ts4.5/channel/Contract.d.ts +8 -7
  408. package/types-legacy/ts4.5/channel/Spend.d.ts +5 -1
  409. package/types-legacy/ts4.5/channel/internal.d.ts +22 -2
  410. package/types-legacy/ts4.5/contract/Contract.d.ts +42 -122
  411. package/types-legacy/ts4.5/contract/compiler/Base.d.ts +74 -0
  412. package/types-legacy/ts4.5/contract/compiler/Cli.d.ts +23 -0
  413. package/types-legacy/ts4.5/contract/compiler/Http.d.ts +32 -0
  414. package/types-legacy/ts4.5/contract/compiler/HttpNode.d.ts +17 -0
  415. package/types-legacy/ts4.5/contract/compiler/getFileSystem.d.ts +6 -0
  416. package/types-legacy/ts4.5/contract/delegation-signature.d.ts +43 -0
  417. package/types-legacy/ts4.5/contract/ga.d.ts +27 -10
  418. package/types-legacy/ts4.5/index-browser.d.ts +40 -0
  419. package/types-legacy/ts4.5/index.d.ts +4 -38
  420. package/types-legacy/ts4.5/oracle.d.ts +12 -17
  421. package/types-legacy/ts4.5/spend.d.ts +19 -27
  422. package/types-legacy/ts4.5/tx/builder/SchemaTypes.d.ts +37 -0
  423. package/types-legacy/ts4.5/tx/builder/constants.d.ts +31 -2
  424. package/types-legacy/ts4.5/tx/builder/field-types/abi-version.d.ts +19 -0
  425. package/types-legacy/ts4.5/tx/builder/field-types/address.d.ts +11 -12
  426. package/types-legacy/ts4.5/tx/builder/field-types/array.d.ts +7 -0
  427. package/types-legacy/ts4.5/tx/builder/field-types/boolean.d.ts +6 -0
  428. package/types-legacy/ts4.5/tx/builder/field-types/coin-amount.d.ts +4 -5
  429. package/types-legacy/ts4.5/tx/builder/field-types/ct-version.d.ts +72 -0
  430. package/types-legacy/ts4.5/tx/builder/field-types/deposit.d.ts +3 -2
  431. package/types-legacy/ts4.5/tx/builder/field-types/encoded.d.ts +6 -0
  432. package/types-legacy/ts4.5/tx/builder/field-types/entry.d.ts +11 -0
  433. package/types-legacy/ts4.5/tx/builder/field-types/enumeration.d.ts +5 -3
  434. package/types-legacy/ts4.5/tx/builder/field-types/fee.d.ts +12 -7
  435. package/types-legacy/ts4.5/tx/builder/field-types/gas-limit.d.ts +7 -3
  436. package/types-legacy/ts4.5/tx/builder/field-types/gas-price.d.ts +3 -1
  437. package/types-legacy/ts4.5/tx/builder/field-types/index.d.ts +113 -30
  438. package/types-legacy/ts4.5/tx/builder/field-types/map.d.ts +13 -0
  439. package/types-legacy/ts4.5/tx/builder/field-types/mptree.d.ts +48 -0
  440. package/types-legacy/ts4.5/tx/builder/field-types/name-fee.d.ts +2 -3
  441. package/types-legacy/ts4.5/tx/builder/field-types/nonce.d.ts +14 -0
  442. package/types-legacy/ts4.5/tx/builder/field-types/raw.d.ts +6 -0
  443. package/types-legacy/ts4.5/tx/builder/field-types/short-u-int-const.d.ts +7 -0
  444. package/types-legacy/ts4.5/tx/builder/field-types/string.d.ts +6 -0
  445. package/types-legacy/ts4.5/tx/builder/field-types/ttl.d.ts +11 -0
  446. package/types-legacy/ts4.5/tx/builder/field-types/u-int.d.ts +1 -2
  447. package/types-legacy/ts4.5/tx/builder/field-types/wrapped.d.ts +14 -0
  448. package/types-legacy/ts4.5/tx/builder/index.d.ts +21 -36
  449. package/types-legacy/ts4.5/tx/builder/schema.d.ts +2971 -2926
  450. package/types-legacy/ts4.5/tx/builder/schema.generated.d.ts +2011 -0
  451. package/types-legacy/ts4.5/tx/execution-cost.d.ts +35 -0
  452. package/types-legacy/ts4.5/tx/transaction-signer.d.ts +6 -0
  453. package/types-legacy/ts4.5/tx/validator.d.ts +3 -5
  454. package/types-legacy/ts4.5/utils/autorest.d.ts +3 -2
  455. package/types-legacy/ts4.5/utils/errors.d.ts +16 -38
  456. package/es/contract/CompilerHttp.d.ts +0 -18
  457. package/es/contract/CompilerHttp.mjs +0 -63
  458. package/es/contract/CompilerHttp.mjs.map +0 -1
  459. package/es/tx/builder/field-types/addresses.d.ts +0 -6
  460. package/es/tx/builder/field-types/addresses.mjs +0 -13
  461. package/es/tx/builder/field-types/addresses.mjs.map +0 -1
  462. package/es/tx/index.d.ts +0 -34
  463. package/es/tx/index.mjs +0 -172
  464. package/es/tx/index.mjs.map +0 -1
  465. package/es/utils/mptree.d.ts +0 -26
  466. package/es/utils/mptree.mjs +0 -143
  467. package/es/utils/mptree.mjs.map +0 -1
  468. package/src/apis/compiler/code-model-v4.yaml +0 -2442
  469. package/src/apis/node/code-model-v4.yaml +0 -10080
  470. package/src/contract/CompilerHttp.ts +0 -67
  471. package/src/tx/builder/field-types/addresses.ts +0 -18
  472. package/src/tx/index.ts +0 -196
  473. package/src/utils/mptree.ts +0 -145
  474. package/types-legacy/ts4.2/contract/CompilerHttp.d.ts +0 -18
  475. package/types-legacy/ts4.2/tx/builder/field-types/addresses.d.ts +0 -6
  476. package/types-legacy/ts4.2/tx/index.d.ts +0 -34
  477. package/types-legacy/ts4.2/utils/mptree.d.ts +0 -32
  478. package/types-legacy/ts4.5/contract/CompilerHttp.d.ts +0 -18
  479. package/types-legacy/ts4.5/tx/builder/field-types/addresses.d.ts +0 -6
  480. package/types-legacy/ts4.5/tx/index.d.ts +0 -34
  481. package/types-legacy/ts4.5/utils/mptree.d.ts +0 -32
@@ -1 +1 @@
1
- {"version":3,"file":"hd-wallet.mjs","names":["nacl","aesjs","sha256hash","encode","Encoding","CryptographyError","concatBuffers","Ecb","ModeOfOperation","ecb","encryptKey","password","binaryData","hashedPasswordBytes","aesEcb","encrypt","decryptKey","encrypted","encryptedBytes","from","decrypt","DerivationError","constructor","message","name","ED25519_CURVE","HARDENED_OFFSET","deriveChild","index","secretKey","chainCode","indexBuffer","allocUnsafe","writeUInt32BE","data","alloc","I","hmac","IL","slice","IR","derivePathFromKey","path","key","segments","fromString","toPathArray","forEach","segment","i","reduce","parentKey","getMasterKeyFromSeed","seed","derivePathFromSeed","includes","masterKey","formatAccount","keys","publicKey","toString","AccountAddress","getKeyPair","sign","keyPair","fromSeed","generateSaveHDWalletFromSeed","walletKey","getSaveHDWalletAccounts","saveHDWallet","accountCount","Array","fill","undefined","map","_","idx","getHdWalletAccountFromSeed","accountIdx","derived"],"sources":["../../src/utils/hd-wallet.ts"],"sourcesContent":["import nacl from 'tweetnacl';\nimport { full as hmac } from 'tweetnacl-auth';\nimport { fromString } from 'bip32-path';\nimport aesjs from 'aes-js';\nimport { sha256hash, encode, Encoding } from './encoder';\nimport { CryptographyError } from './errors';\nimport { concatBuffers } from './other';\n\nconst Ecb = aesjs.ModeOfOperation.ecb;\n\n// TODO: use mnemonic encryption instead of AES\n/**\n * Encrypt given data using `password`\n * @param password - Password to encrypt with\n * @param binaryData - Data to encrypt\n * @returns Encrypted data\n */\nfunction encryptKey(password: string, binaryData: Uint8Array): Uint8Array {\n const hashedPasswordBytes = sha256hash(password);\n const aesEcb = new Ecb(hashedPasswordBytes);\n return aesEcb.encrypt(binaryData);\n}\n\n/**\n * Decrypt given data using `password`\n * @param password - Password to decrypt with\n * @param encrypted - Data to decrypt\n * @returns Decrypted data\n */\nfunction decryptKey(password: string, encrypted: Uint8Array): Uint8Array {\n const encryptedBytes = Buffer.from(encrypted);\n const hashedPasswordBytes = sha256hash(password);\n const aesEcb = new Ecb(hashedPasswordBytes);\n return aesEcb.decrypt(encryptedBytes);\n}\n\n/**\n * @category exception\n */\nexport class DerivationError extends CryptographyError {\n constructor(message: string) {\n super(message);\n this.name = 'DerivationError';\n }\n}\n\nconst ED25519_CURVE = Buffer.from('ed25519 seed');\nconst HARDENED_OFFSET = 0x80000000;\n\ninterface KeyTreeNode {\n secretKey: Uint8Array;\n chainCode: Uint8Array;\n}\n\ninterface HDWallet {\n secretKey: string;\n chainCode: string;\n}\n\ninterface Account {\n secretKey: string;\n publicKey: string;\n}\n\ntype Dec<N extends number> = [-1, 0, 1, 2, 3, 4][N];\ntype Bip32PathT<MaxLen extends number, H extends 'H' | 'h' | '\\''> = MaxLen extends -1\n ? `${number}${H}`\n : Bip32PathT<Dec<MaxLen>, H> | `${Bip32PathT<Dec<MaxLen>, H>}/${number}${H}`;\ntype Bip32Path<MaxLen extends number> =\n '' | Bip32PathT<MaxLen, 'H'> | Bip32PathT<MaxLen, 'h'> | Bip32PathT<MaxLen, '\\''>;\n\n/**\n * @category hd-wallet\n */\nexport function deriveChild({ secretKey, chainCode }: KeyTreeNode, index: number): KeyTreeNode {\n if (index < HARDENED_OFFSET) {\n throw new DerivationError(`Segment ${index} is not hardened`);\n }\n const indexBuffer = Buffer.allocUnsafe(4);\n indexBuffer.writeUInt32BE(index, 0);\n\n const data = concatBuffers([Buffer.alloc(1, 0), secretKey, indexBuffer]);\n\n const I = hmac(data, chainCode);\n const IL = I.slice(0, 32);\n const IR = I.slice(32);\n return {\n secretKey: IL,\n chainCode: IR,\n };\n}\n\n/**\n * @category hd-wallet\n */\nexport function derivePathFromKey(path: Bip32Path<5>, key: KeyTreeNode): KeyTreeNode {\n const segments = path === '' ? [] : fromString(path).toPathArray();\n segments.forEach((segment, i) => {\n if (segment < HARDENED_OFFSET) {\n throw new DerivationError(`Segment #${i + 1} is not hardened`);\n }\n });\n\n return segments.reduce((parentKey, segment) => deriveChild(parentKey, segment), key);\n}\n\n/**\n * @category hd-wallet\n */\nexport function getMasterKeyFromSeed(seed: Uint8Array): KeyTreeNode {\n const I = hmac(seed, ED25519_CURVE);\n const IL = I.slice(0, 32);\n const IR = I.slice(32);\n return {\n secretKey: IL,\n chainCode: IR,\n };\n}\n\n/**\n * @category hd-wallet\n */\nexport function derivePathFromSeed(path: 'm' | `m/${Bip32Path<5>}`, seed: Uint8Array): KeyTreeNode {\n if (!['m', 'm/'].includes(path.slice(0, 2))) {\n throw new DerivationError('Root element is required');\n }\n const masterKey = getMasterKeyFromSeed(seed);\n return derivePathFromKey(path.slice(2) as Bip32Path<5>, masterKey);\n}\n\nfunction formatAccount(keys: nacl.SignKeyPair): Account {\n const { secretKey, publicKey } = keys;\n return {\n secretKey: Buffer.from(secretKey).toString('hex'),\n publicKey: encode(publicKey, Encoding.AccountAddress),\n };\n}\n\n/**\n * @category hd-wallet\n */\nexport function getKeyPair(secretKey: Uint8Array): nacl.SignKeyPair {\n return nacl.sign.keyPair.fromSeed(secretKey);\n}\n\n/**\n * @category hd-wallet\n */\nexport function generateSaveHDWalletFromSeed(seed: Uint8Array, password: string): HDWallet {\n const walletKey = derivePathFromSeed('m/44h/457h', seed);\n return {\n secretKey: Buffer.from(encryptKey(password, walletKey.secretKey)).toString('hex'),\n chainCode: Buffer.from(encryptKey(password, walletKey.chainCode)).toString('hex'),\n };\n}\n\n/**\n * @category hd-wallet\n */\nexport function getSaveHDWalletAccounts(\n saveHDWallet: HDWallet,\n password: string,\n accountCount: number,\n): Account[] {\n const walletKey = {\n secretKey: decryptKey(password, Buffer.from(saveHDWallet.secretKey, 'hex')),\n chainCode: decryptKey(password, Buffer.from(saveHDWallet.chainCode, 'hex')),\n };\n return (new Array(accountCount)).fill(undefined)\n .map((_, idx) => formatAccount(getKeyPair(derivePathFromKey(`${idx}h/0h/0h`, walletKey).secretKey)));\n}\n\n/**\n * @category hd-wallet\n */\nexport const getHdWalletAccountFromSeed = (\n seed: Uint8Array,\n accountIdx: number,\n): Account & { idx: number } => {\n const walletKey = derivePathFromSeed('m/44h/457h', seed);\n const derived = derivePathFromKey(`${accountIdx}h/0h/0h`, walletKey);\n const keyPair = getKeyPair(derived.secretKey);\n return {\n ...formatAccount(keyPair),\n idx: accountIdx,\n };\n};\n"],"mappings":";;;;AAAA,OAAOA,IAAI,MAAM,WAAW;AAC5B,2BAA6B,gBAAgB;AAAC;EAAA;AAAA;AAC9C,uBAA2B,YAAY;AAAC;EAAA;AAAA;AACxC,OAAOC,KAAK,MAAM,QAAQ;AAAC,SAClBC,UAAU,EAAEC,MAAM,EAAEC,QAAQ;AAAA,SAC5BC,iBAAiB;AAAA,SACjBC,aAAa;AAEtB,MAAMC,GAAG,GAAGN,KAAK,CAACO,eAAe,CAACC,GAAG;;AAErC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,UAAU,CAACC,QAAgB,EAAEC,UAAsB,EAAc;EACxE,MAAMC,mBAAmB,GAAGX,UAAU,CAACS,QAAQ,CAAC;EAChD,MAAMG,MAAM,GAAG,IAAIP,GAAG,CAACM,mBAAmB,CAAC;EAC3C,OAAOC,MAAM,CAACC,OAAO,CAACH,UAAU,CAAC;AACnC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASI,UAAU,CAACL,QAAgB,EAAEM,SAAqB,EAAc;EACvE,MAAMC,cAAc,GAAG,QAAOC,IAAI,CAACF,SAAS,CAAC;EAC7C,MAAMJ,mBAAmB,GAAGX,UAAU,CAACS,QAAQ,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AAEC,GAAG,KAAKnB,aAAa,CAACK,UAAU,CAACrB,iBAAiB,CAAE,GAAEmC,GAAI,SAAQ,EAAET,SAAS,CAAC,CAACtC,SAAS,CAAC,CAAC,CAAC;AACxG;;AAEA;AACA;AACA;AACA,OAAO,MAAMgD,0BAA0B,GAAG,CACxCxB,IAAgB,EAChByB,UAAkB,KACY;EAC9B,MAAMX,SAAS,GAAGb,kBAAkB,CAAC,YAAY,EAAED,IAAI,CAAC;EACxD,MAAM0B,OAAO,GAAGtC,iBAAiB,CAAE,GAAEqC,UAAW,SAAQ,EAAEX,SAAS,CAAC;EACpE,MAAMH,OAAO,GAAGF,UAAU,CAACiB,OAAO,CAAClD,SAAS,CAAC;EAC7C,OAAO;IACL,GAAG4B,aAAa,CAACO,OAAO,CAAC;IACzBY,GAAG,EAAEE;EACP,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"hd-wallet.mjs","names":["nacl","_tweetnaclAuth","full","hmac","_bip32Path","fromString","aesjs","sha256hash","encode","Encoding","CryptographyError","concatBuffers","Ecb","ModeOfOperation","ecb","encryptKey","password","binaryData","hashedPasswordBytes","aesEcb","encrypt","decryptKey","encrypted","encryptedBytes","_Buffer","from","decrypt","DerivationError","constructor","message","name","ED25519_CURVE","HARDENED_OFFSET","deriveChild","_ref","index","secretKey","chainCode","indexBuffer","allocUnsafe","writeUInt32BE","data","alloc","I","IL","slice","IR","derivePathFromKey","path","key","segments","toPathArray","forEach","segment","i","reduce","parentKey","getMasterKeyFromSeed","seed","derivePathFromSeed","includes","masterKey","formatAccount","keys","publicKey","toString","AccountAddress","getKeyPair","sign","keyPair","fromSeed","generateSaveHDWalletFromSeed","walletKey","getSaveHDWalletAccounts","saveHDWallet","accountCount","Array","fill","undefined","map","_","idx","getHdWalletAccountFromSeed","accountIdx","derived"],"sources":["../../src/utils/hd-wallet.ts"],"sourcesContent":["import nacl from 'tweetnacl';\nimport { full as hmac } from 'tweetnacl-auth';\nimport { fromString } from 'bip32-path';\nimport aesjs from 'aes-js';\nimport { sha256hash, encode, Encoding } from './encoder';\nimport { CryptographyError } from './errors';\nimport { concatBuffers } from './other';\n\nconst Ecb = aesjs.ModeOfOperation.ecb;\n\n// TODO: use mnemonic encryption instead of AES\n/**\n * Encrypt given data using `password`\n * @param password - Password to encrypt with\n * @param binaryData - Data to encrypt\n * @returns Encrypted data\n */\nfunction encryptKey(password: string, binaryData: Uint8Array): Uint8Array {\n const hashedPasswordBytes = sha256hash(password);\n const aesEcb = new Ecb(hashedPasswordBytes);\n return aesEcb.encrypt(binaryData);\n}\n\n/**\n * Decrypt given data using `password`\n * @param password - Password to decrypt with\n * @param encrypted - Data to decrypt\n * @returns Decrypted data\n */\nfunction decryptKey(password: string, encrypted: Uint8Array): Uint8Array {\n const encryptedBytes = Buffer.from(encrypted);\n const hashedPasswordBytes = sha256hash(password);\n const aesEcb = new Ecb(hashedPasswordBytes);\n return aesEcb.decrypt(encryptedBytes);\n}\n\n/**\n * @category exception\n */\nexport class DerivationError extends CryptographyError {\n constructor(message: string) {\n super(message);\n this.name = 'DerivationError';\n }\n}\n\nconst ED25519_CURVE = Buffer.from('ed25519 seed');\nconst HARDENED_OFFSET = 0x80000000;\n\ninterface KeyTreeNode {\n secretKey: Uint8Array;\n chainCode: Uint8Array;\n}\n\ninterface HDWallet {\n secretKey: string;\n chainCode: string;\n}\n\ninterface Account {\n secretKey: string;\n publicKey: string;\n}\n\ntype Dec<N extends number> = [-1, 0, 1, 2, 3, 4][N];\ntype Bip32PathT<MaxLen extends number, H extends 'H' | 'h' | '\\''> = MaxLen extends -1\n ? `${number}${H}`\n : Bip32PathT<Dec<MaxLen>, H> | `${Bip32PathT<Dec<MaxLen>, H>}/${number}${H}`;\ntype Bip32Path<MaxLen extends number> =\n '' | Bip32PathT<MaxLen, 'H'> | Bip32PathT<MaxLen, 'h'> | Bip32PathT<MaxLen, '\\''>;\n\n/**\n * @category hd-wallet\n */\nexport function deriveChild({ secretKey, chainCode }: KeyTreeNode, index: number): KeyTreeNode {\n if (index < HARDENED_OFFSET) {\n throw new DerivationError(`Segment ${index} is not hardened`);\n }\n const indexBuffer = Buffer.allocUnsafe(4);\n indexBuffer.writeUInt32BE(index, 0);\n\n const data = concatBuffers([Buffer.alloc(1, 0), secretKey, indexBuffer]);\n\n const I = hmac(data, chainCode);\n const IL = I.slice(0, 32);\n const IR = I.slice(32);\n return {\n secretKey: IL,\n chainCode: IR,\n };\n}\n\n/**\n * @category hd-wallet\n */\nexport function derivePathFromKey(path: Bip32Path<5>, key: KeyTreeNode): KeyTreeNode {\n const segments = path === '' ? [] : fromString(path).toPathArray();\n segments.forEach((segment, i) => {\n if (segment < HARDENED_OFFSET) {\n throw new DerivationError(`Segment #${i + 1} is not hardened`);\n }\n });\n\n return segments.reduce((parentKey, segment) => deriveChild(parentKey, segment), key);\n}\n\n/**\n * @category hd-wallet\n */\nexport function getMasterKeyFromSeed(seed: Uint8Array): KeyTreeNode {\n const I = hmac(seed, ED25519_CURVE);\n const IL = I.slice(0, 32);\n const IR = I.slice(32);\n return {\n secretKey: IL,\n chainCode: IR,\n };\n}\n\n/**\n * @category hd-wallet\n */\nexport function derivePathFromSeed(path: 'm' | `m/${Bip32Path<5>}`, seed: Uint8Array): KeyTreeNode {\n if (!['m', 'm/'].includes(path.slice(0, 2))) {\n throw new DerivationError('Root element is required');\n }\n const masterKey = getMasterKeyFromSeed(seed);\n return derivePathFromKey(path.slice(2) as Bip32Path<5>, masterKey);\n}\n\nfunction formatAccount(keys: nacl.SignKeyPair): Account {\n const { secretKey, publicKey } = keys;\n return {\n secretKey: Buffer.from(secretKey).toString('hex'),\n publicKey: encode(publicKey, Encoding.AccountAddress),\n };\n}\n\n/**\n * @category hd-wallet\n */\nexport function getKeyPair(secretKey: Uint8Array): nacl.SignKeyPair {\n return nacl.sign.keyPair.fromSeed(secretKey);\n}\n\n/**\n * @category hd-wallet\n */\nexport function generateSaveHDWalletFromSeed(seed: Uint8Array, password: string): HDWallet {\n const walletKey = derivePathFromSeed('m/44h/457h', seed);\n return {\n secretKey: Buffer.from(encryptKey(password, walletKey.secretKey)).toString('hex'),\n chainCode: Buffer.from(encryptKey(password, walletKey.chainCode)).toString('hex'),\n };\n}\n\n/**\n * @category hd-wallet\n */\nexport function getSaveHDWalletAccounts(\n saveHDWallet: HDWallet,\n password: string,\n accountCount: number,\n): Account[] {\n const walletKey = {\n secretKey: decryptKey(password, Buffer.from(saveHDWallet.secretKey, 'hex')),\n chainCode: decryptKey(password, Buffer.from(saveHDWallet.chainCode, 'hex')),\n };\n return (new Array(accountCount)).fill(undefined)\n .map((_, idx) => formatAccount(getKeyPair(derivePathFromKey(`${idx}h/0h/0h`, walletKey).secretKey)));\n}\n\n/**\n * @category hd-wallet\n */\nexport const getHdWalletAccountFromSeed = (\n seed: Uint8Array,\n accountIdx: number,\n): Account & { idx: number } => {\n const walletKey = derivePathFromSeed('m/44h/457h', seed);\n const derived = derivePathFromKey(`${accountIdx}h/0h/0h`, walletKey);\n const keyPair = getKeyPair(derived.secretKey);\n return {\n ...formatAccount(keyPair),\n idx: accountIdx,\n };\n};\n"],"mappings":";;;;AAAA,OAAOA,IAAI,MAAM,WAAW;AAC5B,OAAAC,cAAA,MAA6B,gBAAgB;AAAC;EAAAC,IAAA,EAAAC;AAAA,IAAAF,cAAA;AAC9C,OAAAG,UAAA,MAA2B,YAAY;AAAC;EAAAC;AAAA,IAAAD,UAAA;AACxC,OAAOE,KAAK,MAAM,QAAQ;AAAC,SAClBC,UAAU,EAAEC,MAAM,EAAEC,QAAQ;AAAA,SAC5BC,iBAAiB;AAAA,SACjBC,aAAa;AAEtB,MAAMC,GAAG,GAAGN,KAAK,CAACO,eAAe,CAACC,GAAG;;AAErC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,UAAUA,CAACC,QAAgB,EAAEC,UAAsB,EAAc;EACxE,MAAMC,mBAAmB,GAAGX,UAAU,CAACS,QAAQ,CAAC;EAChD,MAAMG,MAAM,GAAG,IAAIP,GAAG,CAACM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MAAMH,SAAS,GAAG;IAChBpC,SAAS,EAAEf,UAAU,CAACL,QAAQ,EAAEQ,OAAA,CAAOC,IAAI,CAACiD,YAAY,CAACtC,SAAS,EAAE,KAAK,CAAC,CAAC;IAC3EC,SAAS,EAAEhB,UAAU,CAACL,QAAQ,EAAEQ,OAAA,CAAOC,IAAI,CAACiD,YAAY,CAACrC,SAAS,EAAE,KAAK,CAAC;EAC5E,CAAC;EACD,OAAQ,IAAIuC,KAAK,CAACD,YAAY,CAAC,CAAEE,IAAI,CAACC,SAAS,CAAC,CAC7CC,GAAG,CAAC,CAACC,CAAC,EAAEC,GAAG,KAAKnB,aAAa,CAACK,UAAU,CAACpB,iBAAiB,CAAE,GAAEkC,GAAI,SAAQ,EAAET,SAAS,CAAC,CAACpC,SAAS,CAAC,CAAC,CAAC;AACxG;;AAEA;AACA;AACA;AACA,OAAO,MAAM8C,0BAA0B,GAAGA,CACxCxB,IAAgB,EAChByB,UAAkB,KACY;EAC9B,MAAMX,SAAS,GAAGb,kBAAkB,CAAC,YAAY,EAAED,IAAI,CAAC;EACxD,MAAM0B,OAAO,GAAGrC,iBAAiB,CAAE,GAAEoC,UAAW,SAAQ,EAAEX,SAAS,CAAC;EACpE,MAAMH,OAAO,GAAGF,UAAU,CAACiB,OAAO,CAAChD,SAAS,CAAC;EAC7C,OAAO;IACL,GAAG0B,aAAa,CAACO,OAAO,CAAC;IACzBY,GAAG,EAAEE;EACP,CAAC;AACH,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"json-big.mjs","names":["JsonBig","BigNumber","mapObject","jsonBig","storeAsString","convertValuesToBigNumbers","value","constructor","Object","k","v","Array","isArray","map","item","toString","bn","toJSON","stringify","args","slice","parse"],"sources":["../../src/utils/json-big.ts"],"sourcesContent":["import JsonBig from 'json-bigint';\nimport BigNumber from 'bignumber.js';\nimport { mapObject } from './other';\n\nconst jsonBig = JsonBig({ storeAsString: true });\n\nconst convertValuesToBigNumbers = (value: any): any => {\n if (typeof value === 'object' && value !== null && value.constructor === Object) {\n return mapObject(value, ([k, v]) => [k, convertValuesToBigNumbers(v)]);\n }\n if (Array.isArray(value)) {\n return value.map((item) => convertValuesToBigNumbers(item));\n }\n if (typeof value === 'string' && new BigNumber(value).toString(10) === value) {\n const bn = new BigNumber(value);\n bn.toJSON = () => bn.toString(10);\n return bn;\n }\n return value;\n};\n\nexport default {\n stringify: (...args: Parameters<typeof JsonBig['stringify']>): string => (\n jsonBig.stringify(convertValuesToBigNumbers(args[0]), ...args.slice(1))\n ),\n parse: jsonBig.parse,\n};\n"],"mappings":"AAAA,OAAOA,OAAO,MAAM,aAAa;AACjC,OAAOC,SAAS,MAAM,cAAc;AAAC,SAC5BC,SAAS;AAElB,MAAMC,OAAO,GAAGH,OAAO,CAAC;EAAEI,aAAa,EAAE;AAAK,CAAC,CAAC;AAEhD,MAAMC,yBAAyB,GAAIC,KAAU,IAAU;EACrD,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,KAAK,IAAI,IAAIA,KAAK,CAACC,WAAW,KAAKC,MAAM,EAAE;IAC/E,OAAON,SAAS,CAACI,KAAK,EAAE;MAAA,IAAC,CAACG,CAAC,EAAEC,CAAC,CAAC;MAAA,OAAK,CAACD,CAAC,EAAEJ,yBAAyB,CAACK,CAAC,CAAC,CAAC;IAAA,EAAC;EACxE;EACA,IAAIC,KAAK,CAACC,OAAO,CAACN,KAAK,CAAC,EAAE;IACxB,OAAOA,KAAK,CAACO,GAAG,CAAEC,IAAI,IAAKT,yBAAyB,CAACS,IAAI,CAAC,CAAC;EAC7D;EACA,IAAI,OAAOR,KAAK,KAAK,QAAQ,IAAI,IAAIL,SAAS,CAACK,KAAK,CAAC,CAACS,QAAQ,CAAC,EAAE,CAAC,KAAKT,KAAK,EAAE;IAC5E,MAAMU,EAAE,GAAG,IAAIf,SAAS,CAACK,KAAK,CAAC;IAC/BU,EAAE,CAACC,MAAM,GAAG,MAAMD,EAAE,CAACD,QAAQ,CAAC,EAAE,CAAC;IACjC,OAAOC,EAAE;EACX;EACA,OAAOV,KAAK;AACd,CAAC;AAED,eAAe;EACbY,SAAS,EAAE;IAAA,kCAAIC,IAAI;MAAJA,IAAI;IAAA;IAAA,OACjBhB,OAAO,CAACe,SAAS,CAACb,yBAAyB,CAACc,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,GAAGA,IAAI,CAACC,KAAK,CAAC,CAAC,CAAC,CAAC;EAAA,CACxE;EACDC,KAAK,EAAElB,OAAO,CAACkB;AACjB,CAAC"}
1
+ {"version":3,"file":"json-big.mjs","names":["JsonBig","BigNumber","mapObject","jsonBig","storeAsString","convertValuesToBigNumbers","value","constructor","Object","_ref","k","v","Array","isArray","map","item","toString","bn","toJSON","stringify","_len","arguments","length","args","_key","slice","parse"],"sources":["../../src/utils/json-big.ts"],"sourcesContent":["import JsonBig from 'json-bigint';\nimport BigNumber from 'bignumber.js';\nimport { mapObject } from './other';\n\nconst jsonBig = JsonBig({ storeAsString: true });\n\nconst convertValuesToBigNumbers = (value: any): any => {\n if (typeof value === 'object' && value !== null && value.constructor === Object) {\n return mapObject(value, ([k, v]) => [k, convertValuesToBigNumbers(v)]);\n }\n if (Array.isArray(value)) {\n return value.map((item) => convertValuesToBigNumbers(item));\n }\n if (typeof value === 'string' && new BigNumber(value).toString(10) === value) {\n const bn = new BigNumber(value);\n bn.toJSON = () => bn.toString(10);\n return bn;\n }\n return value;\n};\n\nexport default {\n stringify: (...args: Parameters<typeof JsonBig['stringify']>): string => (\n jsonBig.stringify(convertValuesToBigNumbers(args[0]), ...args.slice(1))\n ),\n parse: jsonBig.parse,\n};\n"],"mappings":"AAAA,OAAOA,OAAO,MAAM,aAAa;AACjC,OAAOC,SAAS,MAAM,cAAc;AAAC,SAC5BC,SAAS;AAElB,MAAMC,OAAO,GAAGH,OAAO,CAAC;EAAEI,aAAa,EAAE;AAAK,CAAC,CAAC;AAEhD,MAAMC,yBAAyB,GAAIC,KAAU,IAAU;EACrD,IAAI,OAAOA,KAA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FromPriv","InvalidPasswordError","DERIVED_KEY_FUNCTIONS","argon2id","pass","salt","params","memlimit_kib","memoryCost","opslimit","timeCost","hash","hashLength","type","CRYPTO_FUNCTIONS","encrypt","secretbox","decrypt","res","open","CRYPTO_DEFAULTS","secret_type","symmetric_alg","kdf","kdf_params","parallelism","plaintext","key","nonce","algo","ciphertext","deriveKey","password","kdfParams","recover","crypto","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,4BAA+B,mBAAmB;AAAC;EAAA;EAAA;AAAA;AAAA,SAC1CC,kBAAkB;AAAA,SAClBC,oBAAoB;AAE7B,MAAMC,qBAAqB,GAAG;EAC5B,MAAMC,QAAQ,CACZC,IAAyB,EACzBC,IAAyB,EACzBC,MAAiD,EAC5B;IACrB,MAAM;MAAEC,YAAY,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EAAEuC,GAAG,CAACrB,GAAG,EAAEqB,GAAG,CAACpB,UAAU,CAAC;EAC3E,MAAMsB,OAAO,GAAG,OAAOL,UAAU,KAAK,QAAQ,GAAG,QAAOL,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,EAAElD,IAAI,EAAE;IACVoC,MAAM,EAAE;MACNd,WAAW,EAAEuB,GAAG,CAACvB,WAAW;MAC5BC,aAAa,EAAEsB,GAAG,CAACtB,aAAa;MAChCQ,UAAU,EAAE,QAAOM,IAAI,CACrBrB,OAAO,CAAC+B,OAAO,EAAED,UAAU,EAAEjB,KAAK,EAAEgB,GAAG,CAACtB,aAAa,CAAC,CACvD,CAACgB,QAAQ,CAAC,KAAK,CAAC;MACjBD,aAAa,EAAE;QAAET,KAAK,EAAE,QAAOQ,IAAI,CAACR,KAAK,CAAC,CAACU,QAAQ,CAAC,KAAK;MAAE,CAAC;MAC5Df,GAAG,EAAEqB,GAAG,CAACrB,GAAG;MACZC,UAAU,EAAE;QACV,GAAGoB,GAAG,CAACpB,UAAU;QACjBnB,IAAI,EAAE,QAAO+B,IAAI,CAAC/B,IAAI,CAAC,CAACiC,QAAQ,CAAC,KAAK;MACxC;IACF;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","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,OAAOP,IAAI,CAACK,IAAI,EAAE;MAChBO,UAAU,EAAE,EAAE;MACdN,IAAI;MACJK,QAAQ;MACRF,UAAU;MACVI,IAAI,EAAEZ;IACR,CAAC,CAAC;EACJ;AACF,CAAC;AAED,MAAMa,gBAA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AAX,SAAA,MAAAY,SAAA;EAErC,MAAMiB,GAAG,GAAG;IAAE,GAAG5B,eAAe;IAAE,GAAG2B;EAAQ,CAAC;EAC9C,MAAME,UAAU,GAAG,MAAMhB,SAAS,CAACC,QAAQ,EAAE7B,IAAI,EAAE2C,GAAG,CAACzB,GAAG,EAAEyB,GAAG,CAACxB,UAAU,CAAC;EAC3E,MAAM0B,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,EAAEnD,kBAAkB,CAACiD,OAAO,CAAC;IACvCG,EAAE,EAAExD,IAAI,EAAE;IACVyC,MAAM,EAAE;MACNjB,WAAW,EAAE2B,GAAG,CAAC3B,WAAW;MAC5BC,aAAa,EAAE0B,GAAG,CAAC1B,aAAa;MAChCU,UAAU,EAAEO,OAAA,CAAOC,IAAI,CACrB1B,OAAO,CAACoC,OAAO,EAAED,UAAU,EAAErB,KAAK,EAAEoB,GAAG,CAAC1B,aAAa,CAAC,CACvD,CAACoB,QAAQ,CAAC,KAAK,CAAC;MACjBD,aAAa,EAAE;QAAEb,KAAK,EAAEW,OAAA,CAAOC,IAAI,CAACZ,KAAK,CAAC,CAACc,QAAQ,CAAC,KAAK;MAAE,CAAC;MAC5DnB,GAAG,EAAEyB,GAAG,CAACzB,GAAG;MACZC,UAAU,EAAE;QACV,GAAGwB,GAAG,CAACxB,UAAU;QACjBnB,IAAI,EAAEkC,OAAA,CAAOC,IAAI,CAACnC,IAAI,CAAC,CAACqC,QAAQ,CAAC,KAAK;MACxC;IACF;EACF,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"other.mjs","names":["RestError","pause","duration","Promise","resolve","setTimeout","mapObject","object","fn","Object","fromEntries","entries","map","isWebpack4Buffer","concat","Uint8Array","from","error","concatBuffers","list","totalLength","el","isKeyOfObject","key","isItemOfArray","item","array","includes","isAccountNotFoundError","statusCode","message"],"sources":["../../src/utils/other.ts"],"sourcesContent":["import { RestError } from '@azure/core-rest-pipeline';\n\nexport const pause = async (duration: number): Promise<void> => new Promise((resolve) => {\n setTimeout(resolve, duration);\n});\n\nexport const mapObject = <InputV, OutputV>(\n object: { [k: string]: InputV },\n fn: (\n value: [string, InputV], index: number, array: Array<[string, InputV]>\n ) => [number | string, OutputV],\n): { [k: string]: OutputV } => Object.fromEntries(Object.entries(object).map(fn));\n\n// remove after dropping webpack4 support\nconst isWebpack4Buffer = (() => {\n try {\n Buffer.concat([Uint8Array.from([])]);\n return false;\n } catch (error) {\n return true;\n }\n})();\n\nexport const concatBuffers = isWebpack4Buffer\n ? (list: readonly Uint8Array[], totalLength?: number): Buffer => (\n Buffer.concat(list.map((el) => Buffer.from(el)), totalLength)\n )\n : Buffer.concat;\n\n/**\n * Object key type guard\n * @param key - Maybe object key\n * @param object - Object\n */\nexport function isKeyOfObject<T extends object>(\n key: string | number | symbol,\n object: T,\n): key is keyof T {\n return key in object;\n}\n\n/**\n * Array item type guard\n * @param item - Maybe array item\n * @param array - Array\n */\nexport function isItemOfArray<T>(item: any, array: readonly T[]): item is T {\n return array.includes(item);\n}\n\nexport function isAccountNotFoundError(error: Error): boolean {\n return error instanceof RestError && error.statusCode === 404\n && error.message.includes('Account not found');\n}\n\n// based on https://stackoverflow.com/a/50375286/6176994\nexport type UnionToIntersection<Union> =\n (Union extends any ? (k: Union) => void : never) extends ((k: infer Intersection) => void)\n ? Intersection : never;\n"],"mappings":";;;;AAAA,SAASA,SAAS,QAAQ,2BAA2B;AAErD,OAAO,MAAMC,KAAK,GAAG,MAAOC,QAAgB,IAAoB,IAAIC,OAAO,CAAEC,OAAO,IAAK;EACvFC,UAAU,CAACD,OAAO,EAAEF,QAAQ,CAAC;AAC/B,CAAC,CAAC;AAEF,OAAO,MAAMI,SAAS,GAAG,CACvBC,MAA+B,EAC/BC,EAE+B,KACFC,MAAM,CAACC,WAAW,CAACD,MAAM,CAACE,OAAO,CAACJ,MAAM,CAAC,CAACK,GAAG,CAACJ,EAAE,CAAC,CAAC;;AAEjF;AACA,MAAMK,gBAAgB,GAAG,CAAC,MAAM;EAC9B,IAAI;IACF,QAAOC,MAAM,CAAC,CAACC,UAAU,CAACC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IACpC,OAAO,KAAK;EACd,CAAC,CAAC,OAAOC,KAAK,EAAE;IACd,OAAO,IAAI;EACb;AACF,CAAC,GAAG;AAEJ,OAAO,MAAMC,aAAa,GAAGL,gBAAgB,GACzC,CAACM,IAA2B,EAAEC,WAAoB,KAClD,QAAON,MAAM,CAACK,IAAI,CAACP,GAAG,CAAES,EAAE,IAAK,QAAOL,IAAI,CAACK,EAAE,CAAC,CAAC,EAAED,WAAW,CAC7D,GACC,QAAON,MAAM;;AAEjB;AACA;AACA;AACA;AACA;AACA,OAAO,SAASQ,aAAa,CAC3BC,GAA6B,EAC7BhB,MAAS,EACO;EAChB,OAAOgB,GAAG,IAAIhB,MAAM;AACtB;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASiB,aAAa,CAAIC,IAAS,EAAEC,KAAmB,EAAa;EAC1E,OAAOA,KAAK,CAACC,QAAQ,CAACF,IAAI,CAAC;AAC7B;AAEA,OAAO,SAASG,sBAAsB,CAACX,KAAY,EAAW;EAC5D,OAAOA,KAAK,YAAYjB,SAAS,IAAIiB,KAAK,CAACY,UAAU,KAAK,GAAG,IACxDZ,KAAK,CAACa,OAAO,CAACH,QAAQ,CAAC,mBAAmB,CAAC;AAClD;;AAEA"}
1
+ {"version":3,"file":"other.mjs","names":["RestError","pause","duration","Promise","resolve","setTimeout","mapObject","object","fn","Object","fromEntries","entries","map","isWebpack4Buffer","_Buffer","concat","Uint8Array","from","error","concatBuffers","list","totalLength","el","isKeyOfObject","key","isItemOfArray","item","array","includes","isAccountNotFoundError","statusCode","message"],"sources":["../../src/utils/other.ts"],"sourcesContent":["import { RestError } from '@azure/core-rest-pipeline';\n\nexport const pause = async (duration: number): Promise<void> => new Promise((resolve) => {\n setTimeout(resolve, duration);\n});\n\nexport const mapObject = <InputV, OutputV>(\n object: { [k: string]: InputV },\n fn: (\n value: [string, InputV], index: number, array: Array<[string, InputV]>\n ) => [number | string, OutputV],\n): { [k: string]: OutputV } => Object.fromEntries(Object.entries(object).map(fn));\n\n// remove after dropping webpack4 support\nconst isWebpack4Buffer = (() => {\n try {\n Buffer.concat([Uint8Array.from([])]);\n return false;\n } catch (error) {\n return true;\n }\n})();\n\nexport const concatBuffers = isWebpack4Buffer\n ? (list: readonly Uint8Array[], totalLength?: number): Buffer => (\n Buffer.concat(list.map((el) => Buffer.from(el)), totalLength)\n )\n : Buffer.concat;\n\n/**\n * Object key type guard\n * @param key - Maybe object key\n * @param object - Object\n */\nexport function isKeyOfObject<T extends object>(\n key: string | number | symbol,\n object: T,\n): key is keyof T {\n return key in object;\n}\n\n/**\n * Array item type guard\n * @param item - Maybe array item\n * @param array - Array\n */\nexport function isItemOfArray<T>(item: any, array: readonly T[]): item is T {\n return array.includes(item);\n}\n\nexport function isAccountNotFoundError(error: Error): boolean {\n return error instanceof RestError && error.statusCode === 404\n && error.message.includes('Account not found');\n}\n\n// based on https://stackoverflow.com/a/50375286/6176994\nexport type UnionToIntersection<Union> =\n (Union extends any ? (k: Union) => void : never) extends ((k: infer Intersection) => void)\n ? Intersection : never;\n"],"mappings":";;;;AAAA,SAASA,SAAS,QAAQ,2BAA2B;AAErD,OAAO,MAAMC,KAAK,GAAG,MAAOC,QAAgB,IAAoB,IAAIC,OAAO,CAAEC,OAAO,IAAK;EACvFC,UAAU,CAACD,OAAO,EAAEF,QAAQ,CAAC;AAC/B,CAAC,CAAC;AAEF,OAAO,MAAMI,SAAS,GAAGA,CACvBC,MAA+B,EAC/BC,EAE+B,KACFC,MAAM,CAACC,WAAW,CAACD,MAAM,CAACE,OAAO,CAACJ,MAAM,CAAC,CAACK,GAAG,CAACJ,EAAE,CAAC,CAAC;;AAEjF;AACA,MAAMK,gBAAgB,GAAG,CAAC,MAAM;EAC9B,IAAI;IACFC,OAAA,CAAOC,MAAM,CAAC,CAACC,UAAU,CAACC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IACpC,OAAO,KAAK;EACd,CAAC,CAAC,OAAOC,KAAK,EAAE;IACd,OAAO,IAAI;EACb;AACF,CAAC,GAAG;AAEJ,OAAO,MAAMC,aAAa,GAAGN,gBAAgB,GACzC,CAACO,IAA2B,EAAEC,WAAoB,KAClDP,OAAA,CAAOC,MAAM,CAACK,IAAI,CAACR,GAAG,CAAEU,EAAE,IAAKR,OAAA,CAAOG,IAAI,CAACK,EAAE,CAAC,CAAC,EAAED,WAAW,CAC7D,GACCP,OAAA,CAAOC,MAAM;;AAEjB;AACA;AACA;AACA;AACA;AACA,OAAO,SAASQ,aAAaA,CAC3BC,GAA6B,EAC7BjB,MAAS,EACO;EAChB,OAAOiB,GAAG,IAAIjB,MAAM;AACtB;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASkB,aAAaA,CAAIC,IAAS,EAAEC,KAAmB,EAAa;EAC1E,OAAOA,KAAK,CAACC,QAAQ,CAACF,IAAI,CAAC;AAC7B;AAEA,OAAO,SAASG,sBAAsBA,CAACX,KAAY,EAAW;EAC5D,OAAOA,KAAK,YAAYlB,SAAS,IAAIkB,KAAK,CAACY,UAAU,KAAK,GAAG,IACxDZ,KAAK,CAACa,OAAO,CAACH,QAAQ,CAAC,mBAAmB,CAAC;AAClD;;AAEA"}
@@ -1 +1 @@
1
- {"version":3,"file":"semver-satisfies.mjs","names":["semverSatisfies","version","geVersion","ltVersion","getComponents","v","split","map","i","versionComponents","geComponents","ltComponents","base","Math","max","componentsToNumber","components","reverse","reduce","acc","n","idx","vNumber","geNumber","ltNumber"],"sources":["../../src/utils/semver-satisfies.ts"],"sourcesContent":["export default function semverSatisfies(\n version: string,\n geVersion: string,\n ltVersion: string,\n): boolean {\n const getComponents = (v: string): number[] => v\n .split(/[-+]/)[0].split('.').map((i) => +i);\n\n const versionComponents = getComponents(version);\n const geComponents = getComponents(geVersion);\n const ltComponents = getComponents(ltVersion);\n\n const base = Math.max(...versionComponents, ...geComponents, ...ltComponents) + 1;\n const componentsToNumber = (components: number[]): number => components.reverse()\n .reduce((acc, n, idx) => acc + n * base ** idx, 0);\n\n const vNumber = componentsToNumber(versionComponents);\n const geNumber = componentsToNumber(geComponents);\n const ltNumber = componentsToNumber(ltComponents);\n return vNumber >= geNumber && vNumber < ltNumber;\n}\n"],"mappings":"AAAA,eAAe,SAASA,eAAe,CACrCC,OAAe,EACfC,SAAiB,EACjBC,SAAiB,EACR;EACT,MAAMC,aAAa,GAAIC,CAAS,IAAeA,CAAC,CAC7CC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAACA,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,CAAEC,CAAC,IAAK,CAACA,CAAC,CAAC;EAE7C,MAAMC,iBAAiB,GAAGL,aAAa,CAACH,OAAO,CAAC;EAChD,MAAMS,YAAY,GAAGN,aAAa,CAACF,SAAS,CAAC;EAC7C,MAAMS,YAAY,GAAGP,aAAa,CAACD,SAAS,CAAC;EAE7C,MAAMS,IAAI,GAAGC,IAAI,CAACC,GAAG,CAAC,GAAGL,iBAAiB,EAAE,GAAGC,YAAY,EAAE,GAAGC,YAAY,CAAC,GAAG,CAAC;EACjF,MAAMI,kBAAkB,GAAIC,UAAoB,IAAaA,UAAU,CAACC,OAAO,EAAE,CAC9EC,MAAM,CAAC,CAACC,GAAG,EAAEC,CAAC,EAAEC,GAAG,KAAKF,GAAG,GAAGC,CAAC,GAAGR,IAAI,IAAIS,GAAG,EAAE,CAAC,CAAC;EAEpD,MAAMC,OAAO,GAAGP,kBAAkB,CAACN,iBAAiB,CAAC;EACrD,MAAMc,QAAQ,GAAGR,kBAAkB,CAACL,YAAY,CAAC;EACjD,MAAMc,QAAQ,GAAGT,kBAAkB,CAACJ,YAAY,CAAC;EACjD,OAAOW,OAAO,IAAIC,QAAQ,IAAID,OAAO,GAAGE,QAAQ;AAClD"}
1
+ {"version":3,"file":"semver-satisfies.mjs","names":["semverSatisfies","version","geVersion","ltVersion","getComponents","v","split","map","i","versionComponents","geComponents","ltComponents","base","Math","max","componentsToNumber","components","reverse","reduce","acc","n","idx","vNumber","geNumber","ltNumber"],"sources":["../../src/utils/semver-satisfies.ts"],"sourcesContent":["export default function semverSatisfies(\n version: string,\n geVersion: string,\n ltVersion: string,\n): boolean {\n const getComponents = (v: string): number[] => v\n .split(/[-+]/)[0].split('.').map((i) => +i);\n\n const versionComponents = getComponents(version);\n const geComponents = getComponents(geVersion);\n const ltComponents = getComponents(ltVersion);\n\n const base = Math.max(...versionComponents, ...geComponents, ...ltComponents) + 1;\n const componentsToNumber = (components: number[]): number => components.reverse()\n .reduce((acc, n, idx) => acc + n * base ** idx, 0);\n\n const vNumber = componentsToNumber(versionComponents);\n const geNumber = componentsToNumber(geComponents);\n const ltNumber = componentsToNumber(ltComponents);\n return vNumber >= geNumber && vNumber < ltNumber;\n}\n"],"mappings":"AAAA,eAAe,SAASA,eAAeA,CACrCC,OAAe,EACfC,SAAiB,EACjBC,SAAiB,EACR;EACT,MAAMC,aAAa,GAAIC,CAAS,IAAeA,CAAC,CAC7CC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAACA,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,CAAEC,CAAC,IAAK,CAACA,CAAC,CAAC;EAE7C,MAAMC,iBAAiB,GAAGL,aAAa,CAACH,OAAO,CAAC;EAChD,MAAMS,YAAY,GAAGN,aAAa,CAACF,SAAS,CAAC;EAC7C,MAAMS,YAAY,GAAGP,aAAa,CAACD,SAAS,CAAC;EAE7C,MAAMS,IAAI,GAAGC,IAAI,CAACC,GAAG,CAAC,GAAGL,iBAAiB,EAAE,GAAGC,YAAY,EAAE,GAAGC,YAAY,CAAC,GAAG,CAAC;EACjF,MAAMI,kBAAkB,GAAIC,UAAoB,IAAaA,UAAU,CAACC,OAAO,EAAE,CAC9EC,MAAM,CAAC,CAACC,GAAG,EAAEC,CAAC,EAAEC,GAAG,KAAKF,GAAG,GAAGC,CAAC,GAAGR,IAAI,IAAIS,GAAG,EAAE,CAAC,CAAC;EAEpD,MAAMC,OAAO,GAAGP,kBAAkB,CAACN,iBAAiB,CAAC;EACrD,MAAMc,QAAQ,GAAGR,kBAAkB,CAACL,YAAY,CAAC;EACjD,MAAMc,QAAQ,GAAGT,kBAAkB,CAACJ,YAAY,CAAC;EACjD,OAAOW,OAAO,IAAIC,QAAQ,IAAID,OAAO,GAAGE,QAAQ;AAClD"}
@@ -1,20 +1,3 @@
1
- /*
2
- * ISC License (ISC)
3
- * Copyright 2018 aeternity developers
4
- *
5
- * Permission to use, copy, modify, and/or distribute this software for any
6
- * purpose with or without fee is hereby granted, provided that the above
7
- * copyright notice and this permission notice appear in all copies.
8
- *
9
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
- * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
- * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
- * PERFORMANCE OF THIS SOFTWARE.
16
- */
17
-
18
1
  /**
19
2
  * Convert string from snake_case to PascalCase
20
3
  * @param s - String to convert
@@ -1 +1 @@
1
- {"version":3,"file":"string.mjs","names":["snakeToPascal","s","replace","match","toUpperCase","pascalToSnake","toLowerCase"],"sources":["../../src/utils/string.ts"],"sourcesContent":["/*\n * ISC License (ISC)\n * Copyright 2018 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\n\n/**\n * Convert string from snake_case to PascalCase\n * @param s - String to convert\n * @returns Converted string\n */\nexport function snakeToPascal(s: string): string {\n return s.replace(/_./g, (match) => match[1].toUpperCase());\n}\n\n/**\n * Convert string from PascalCase to snake_case\n * @param s - String to convert\n * @returns Converted string\n */\nexport function pascalToSnake(s: string): string {\n return s.replace(/[A-Z]/g, (match) => `_${match.toLowerCase()}`);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,aAAa,CAACC,CAAS,EAAU;EAC/C,OAAOA,CAAC,CAACC,OAAO,CAAC,KAAK,EAAGC,KAAK,IAAKA,KAAK,CAAC,CAAC,CAAC,CAACC,WAAW,EAAE,CAAC;AAC5D;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAa,CAACJ,CAAS,EAAU;EAC/C,OAAOA,CAAC,CAACC,OAAO,CAAC,QAAQ,EAAGC,KAAK,IAAM,IAAGA,KAAK,CAACG,WAAW,EAAG,EAAC,CAAC;AAClE"}
1
+ {"version":3,"file":"string.mjs","names":["snakeToPascal","s","replace","match","toUpperCase","pascalToSnake","toLowerCase"],"sources":["../../src/utils/string.ts"],"sourcesContent":["/**\n * Convert string from snake_case to PascalCase\n * @param s - String to convert\n * @returns Converted string\n */\nexport function snakeToPascal(s: string): string {\n return s.replace(/_./g, (match) => match[1].toUpperCase());\n}\n\n/**\n * Convert string from PascalCase to snake_case\n * @param s - String to convert\n * @returns Converted string\n */\nexport function pascalToSnake(s: string): string {\n return s.replace(/[A-Z]/g, (match) => `_${match.toLowerCase()}`);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,aAAaA,CAACC,CAAS,EAAU;EAC/C,OAAOA,CAAC,CAACC,OAAO,CAAC,KAAK,EAAGC,KAAK,IAAKA,KAAK,CAAC,CAAC,CAAC,CAACC,WAAW,EAAE,CAAC;AAC5D;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAACJ,CAAS,EAAU;EAC/C,OAAOA,CAAC,CAACC,OAAO,CAAC,QAAQ,EAAGC,KAAK,IAAM,IAAGA,KAAK,CAACG,WAAW,EAAG,EAAC,CAAC;AAClE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeternity/aepp-sdk",
3
- "version": "13.0.0-alpha.0",
3
+ "version": "13.0.0-beta.0",
4
4
  "description": "SDK for the æternity blockchain",
5
5
  "main": "dist/aepp-sdk.js",
6
6
  "types": "es/index.d.ts",
@@ -18,23 +18,30 @@
18
18
  },
19
19
  "module": "es/index.mjs",
20
20
  "browser": {
21
+ "es/index.mjs": "./es/index-browser.mjs",
21
22
  "dist/aepp-sdk.js": "./dist/aepp-sdk.browser.js"
22
23
  },
23
24
  "exports": {
24
- "import": "./es/index.mjs",
25
- "node": "./dist/aepp-sdk.js",
25
+ "node": {
26
+ "import": "./es/index.mjs",
27
+ "default": "./dist/aepp-sdk.js"
28
+ },
29
+ "import": "./es/index-browser.mjs",
26
30
  "default": "./dist/aepp-sdk.browser.js"
27
31
  },
28
32
  "sideEffects": false,
29
33
  "scripts": {
34
+ "build:assets": "node tooling/fetch-aesophia-cli.mjs",
30
35
  "build:types": "tsc && node tooling/downlevel/run.mjs",
31
36
  "build:es": "babel src --config-file ./babel.esm.config.js --out-dir es --extensions .js,.ts --out-file-extension .mjs --source-maps true",
32
- "build:api": "node tooling/autorest/compiler-prepare.mjs && autorest tooling/autorest/compiler.yaml --output-artifact:code-model-v4 && autorest tooling/autorest/node.yaml --output-artifact:code-model-v4",
33
- "build": "npm run build:api && webpack && npm run build:types && npm run build:es",
37
+ "build:api": "node tooling/autorest/compiler-prepare.mjs && autorest tooling/autorest/compiler.yaml && autorest tooling/autorest/node.yaml",
38
+ "build:generate": "tooling/generate-schema.ts",
39
+ "build": "npm run build:api && npm run build:generate && webpack && npm run build:types && npm run build:es && npm run build:assets",
34
40
  "docs:examples": "node tooling/docs/examples-to-md.js examples/node/*.mjs",
35
41
  "docs:api": "typedoc",
36
42
  "commitlint": "commitlint --from develop",
37
- "lint": "eslint . --ext .ts,.js,.mjs",
43
+ "lint": "npm run lint:types && eslint . --ext .ts,.js,.mjs",
44
+ "lint:types": "tsc -p tsconfig.tests.json",
38
45
  "test": "mocha './test/unit/' './test/integration/'",
39
46
  "test:integration": "mocha './test/integration/'",
40
47
  "test:unit": "mocha './test/unit/'",
@@ -42,7 +49,8 @@
42
49
  "prepare": "npm run build",
43
50
  "prepublishOnly": "test/examples.sh && npm run docs:examples && npm run docs:api",
44
51
  "release": "standard-version --skip.tag --infile docs/CHANGELOG.md",
45
- "release-alpha": "npm run release -- --prerelease alpha"
52
+ "release-alpha": "npm run release -- --prerelease alpha",
53
+ "release-beta": "npm run release -- --prerelease beta"
46
54
  },
47
55
  "license": "ISC",
48
56
  "keywords": [
@@ -52,21 +60,22 @@
52
60
  "SDK"
53
61
  ],
54
62
  "dependencies": {
55
- "@aeternity/aepp-calldata": "^1.3.0",
63
+ "@aeternity/aepp-calldata": "github:aeternity/aepp-calldata-js#3320455210221e59bff1198389ccfd5851598513",
56
64
  "@aeternity/argon2": "^0.0.1",
57
65
  "@aeternity/uuid": "^0.0.1",
58
66
  "@azure/core-client": "1.6.0",
59
- "@azure/core-rest-pipeline": "^1.10.0",
60
- "@babel/runtime-corejs3": "^7.20.1",
61
- "@ledgerhq/hw-transport": "^6.27.7",
67
+ "@azure/core-rest-pipeline": "^1.10.1",
68
+ "@babel/runtime-corejs3": "^7.21.0",
69
+ "@ledgerhq/hw-transport": "^6.28.1",
62
70
  "@types/aes-js": "^3.1.1",
63
71
  "@types/json-bigint": "^1.0.1",
72
+ "@types/node": "~18.11.9",
64
73
  "@types/sha.js": "^2.4.0",
65
- "@types/uuid": "^8.3.4",
66
- "@types/webextension-polyfill": "^0.9.1",
74
+ "@types/uuid": "^9.0.1",
75
+ "@types/webextension-polyfill": "^0.10.0",
67
76
  "@types/websocket": "^1.0.5",
68
77
  "aes-js": "^3.1.2",
69
- "bignumber.js": "^9.1.0",
78
+ "bignumber.js": "^9.1.1",
70
79
  "bip32-path": "^0.4.2",
71
80
  "blakejs": "^1.2.1",
72
81
  "bs58": "^5.0.0",
@@ -86,54 +95,56 @@
86
95
  "url": "https://github.com/aeternity/aepp-sdk-js"
87
96
  },
88
97
  "devDependencies": {
89
- "@babel/cli": "^7.19.3",
90
- "@babel/core": "^7.20.2",
91
- "@babel/node": "^7.20.2",
92
- "@babel/plugin-transform-runtime": "^7.19.6",
98
+ "@babel/cli": "^7.21.0",
99
+ "@babel/core": "^7.21.0",
100
+ "@babel/node": "^7.20.7",
101
+ "@babel/plugin-transform-runtime": "^7.21.0",
93
102
  "@babel/preset-env": "^7.20.2",
94
- "@babel/preset-typescript": "^7.18.6",
95
- "@babel/register": "^7.18.9",
96
- "@commitlint/cli": "^17.3.0",
97
- "@commitlint/config-conventional": "^17.3.0",
98
- "@ledgerhq/hw-transport-mocker": "^6.27.7",
99
- "@ledgerhq/hw-transport-node-hid-singleton": "^6.28.4",
100
- "@ledgerhq/hw-transport-webusb": "^6.27.7",
103
+ "@babel/preset-typescript": "^7.21.0",
104
+ "@babel/register": "^7.21.0",
105
+ "@commitlint/cli": "^17.4.4",
106
+ "@commitlint/config-conventional": "^17.4.4",
107
+ "@ledgerhq/hw-transport-mocker": "^6.27.12",
108
+ "@ledgerhq/hw-transport-node-hid-singleton": "^6.28.9",
109
+ "@ledgerhq/hw-transport-webusb": "^6.27.12",
101
110
  "@types/chai": "^4.3.4",
102
111
  "@types/chai-as-promised": "^7.1.5",
103
- "@types/mocha": "^10.0.0",
112
+ "@types/mocha": "^10.0.1",
113
+ "@types/node-hid": "^1.3.1",
104
114
  "@types/sinon": "^10.0.13",
105
- "@typescript-eslint/eslint-plugin": "^5.44.0",
106
- "@typescript-eslint/parser": "^5.44.0",
107
- "autorest": "^3.6.2",
108
- "babel-loader": "^9.1.0",
115
+ "@typescript-eslint/eslint-plugin": "^5.54.0",
116
+ "@typescript-eslint/parser": "^5.54.0",
117
+ "autorest": "^3.6.3",
118
+ "babel-loader": "^9.1.2",
109
119
  "babel-plugin-add-import-extension": "^1.6.0",
110
120
  "babel-plugin-import-globals": "^2.0.0",
111
121
  "babel-plugin-transform-default-named-imports": "^1.2.2",
122
+ "babel-plugin-transform-import-meta": "^2.2.0",
112
123
  "chai": "^4.3.7",
113
124
  "chai-as-promised": "^7.1.1",
114
- "cross-fetch": "^3.1.5",
115
125
  "downlevel-dts": "github:aeternity/downlevel-dts",
116
- "eslint": "^8.28.0",
126
+ "eslint": "^8.35.0",
117
127
  "eslint-config-airbnb-base": "^15.0.0",
118
128
  "eslint-config-airbnb-typescript": "^17.0.0",
119
- "eslint-plugin-rulesdir": "^0.2.1",
129
+ "eslint-plugin-rulesdir": "^0.2.2",
120
130
  "eslint-plugin-tsdoc": "^0.2.17",
121
131
  "html-webpack-plugin": "^5.5.0",
122
- "mocha": "^10.1.0",
132
+ "mocha": "^10.2.0",
123
133
  "nyc": "^15.1.0",
124
- "sinon": "^14.0.2",
134
+ "sinon": "^15.0.1",
125
135
  "source-map": "^0.7.4",
126
136
  "standard-version": "^9.5.0",
127
137
  "ts-node": "^10.9.1",
128
- "typedoc": "^0.23.21",
138
+ "typedoc": "^0.23.26",
129
139
  "typedoc-plugin-missing-exports": "^1.0.0",
130
- "typescript": "^4.9.3",
140
+ "typescript": "^4.9.5",
131
141
  "webpack": "^5.75.0",
132
- "webpack-bundle-analyzer": "^4.7.0",
133
- "webpack-cli": "^5.0.0"
142
+ "webpack-bundle-analyzer": "^4.8.0",
143
+ "webpack-cli": "^5.0.1"
134
144
  },
135
145
  "files": [
136
146
  "dist",
147
+ "bin",
137
148
  "types-legacy",
138
149
  "src",
139
150
  "es"
@@ -158,5 +169,6 @@
158
169
  },
159
170
  "engines": {
160
171
  "node": ">=14.19.0"
161
- }
172
+ },
173
+ "packageManager": "npm@8.19.3"
162
174
  }
package/src/AeSdkBase.ts CHANGED
@@ -2,7 +2,7 @@ import Node from './Node';
2
2
  import AccountBase from './account/Base';
3
3
  import { CompilerError, DuplicateNodeError, NodeNotFoundError } from './utils/errors';
4
4
  import { Encoded } from './utils/encoder';
5
- import CompilerHttp from './contract/CompilerHttp';
5
+ import CompilerBase from './contract/compiler/Base';
6
6
  import AeSdkMethods, { OnAccount, getValueOrErrorProxy } from './AeSdkMethods';
7
7
 
8
8
  type NodeInfo = Awaited<ReturnType<Node['getNodeInfo']>> & { name: string };
@@ -32,7 +32,10 @@ export default class AeSdkBase extends AeSdkMethods {
32
32
  nodes.forEach(({ name, instance }, i) => this.addNode(name, instance, i === 0));
33
33
  }
34
34
 
35
- get compilerApi(): CompilerHttp {
35
+ // TODO: consider dropping this getter, because:
36
+ // compiler is not intended to be used separately any more (functionality limited to sdk needs)
37
+ // and user creates its instance by himself
38
+ get compilerApi(): CompilerBase {
36
39
  if (this._options.onCompiler == null) {
37
40
  throw new CompilerError('You can\'t use Compiler API. Compiler is not ready!');
38
41
  }
@@ -153,7 +156,7 @@ export default class AeSdkBase extends AeSdkMethods {
153
156
  override _getOptions(): {
154
157
  onNode: Node;
155
158
  onAccount: AccountBase;
156
- onCompiler: CompilerHttp;
159
+ onCompiler: CompilerBase;
157
160
  } {
158
161
  return {
159
162
  ...super._getOptions(),
@@ -3,15 +3,14 @@ import * as aensMethods from './aens';
3
3
  import * as spendMethods from './spend';
4
4
  import * as oracleMethods from './oracle';
5
5
  import Contract, { ContractMethodsBase } from './contract/Contract';
6
+ import createDelegationSignature from './contract/delegation-signature';
6
7
  import * as contractGaMethods from './contract/ga';
7
- import { _buildTx } from './tx';
8
+ import { buildTxAsync } from './tx/builder';
8
9
  import { mapObject, UnionToIntersection } from './utils/other';
9
10
  import Node from './Node';
10
- import { AE_AMOUNT_FORMATS } from './utils/amount-formatter';
11
- import { Tag } from './tx/builder/constants';
11
+ import { TxParamsAsync } from './tx/builder/schema.generated';
12
12
  import AccountBase from './account/Base';
13
13
  import { Encoded } from './utils/encoder';
14
- import CompilerHttp from './contract/CompilerHttp';
15
14
  import { ArgumentError, NotImplementedError, TypeError } from './utils/errors';
16
15
 
17
16
  export type OnAccount = Encoded.AccountAddress | AccountBase | undefined;
@@ -40,6 +39,7 @@ const methods = {
40
39
  ...aensMethods,
41
40
  ...spendMethods,
42
41
  ...oracleMethods,
42
+ createDelegationSignature,
43
43
  ...contractGaMethods,
44
44
  } as const;
45
45
 
@@ -70,7 +70,7 @@ interface AeSdkMethodsOptions
70
70
  * their context (current account, network, and compiler to use).
71
71
  */
72
72
  class AeSdkMethods {
73
- _options: AeSdkMethodsOptions = { denomination: AE_AMOUNT_FORMATS.AETTOS };
73
+ _options: AeSdkMethodsOptions = {};
74
74
 
75
75
  /**
76
76
  * @param options - Options
@@ -100,20 +100,12 @@ class AeSdkMethods {
100
100
  };
101
101
  }
102
102
 
103
- async buildTx<TxType extends Tag>(
104
- txType: TxType,
105
- options: Omit<Parameters<typeof _buildTx<TxType>>[1], 'onNode'> & { onNode?: Node },
106
- ): Promise<Encoded.Transaction> {
107
- // @ts-expect-error TODO: need to figure out what's wrong here
108
- return _buildTx<TxType>(txType, {
109
- ...this._getOptions(),
110
- ...options,
111
- });
103
+ async buildTx(options: TxParamsAsync): Promise<Encoded.Transaction> {
104
+ return buildTxAsync({ ...this._getOptions(), ...options });
112
105
  }
113
106
 
114
107
  async initializeContract<Methods extends ContractMethodsBase>(
115
- options?: Omit<Parameters<typeof Contract.initialize>[0], 'onNode' | 'onCompiler'> &
116
- { onNode?: Node; onCompiler?: CompilerHttp },
108
+ options?: Omit<Parameters<typeof Contract.initialize>[0], 'onNode'> & { onNode?: Node },
117
109
  ): Promise<Contract<Methods>> {
118
110
  const { onNode, onCompiler, ...otherOptions } = this._getOptions();
119
111
  if (onCompiler == null || onNode == null) {
@@ -134,9 +126,11 @@ type RequiredKeys<T> = {
134
126
 
135
127
  type OptionalIfNotRequired<T extends [any]> = RequiredKeys<T[0]> extends never ? T | [] : T;
136
128
 
129
+ type ReplaceOnAccount<Options> = Options extends { onAccount: any }
130
+ ? Omit<Options, 'onAccount'> & { onAccount: OnAccount } : Options;
131
+
137
132
  type MakeOptional<Options> = OptionalIfNotRequired<[
138
- Omit<Options, 'onNode' | 'onCompiler' | 'onAccount'>
139
- & { onNode?: Node; onCompiler?: CompilerHttp; onAccount?: OnAccount },
133
+ Omit<Options, 'onNode' | 'onCompiler' | 'onAccount'> & Partial<ReplaceOnAccount<Options>>,
140
134
  ]>;
141
135
 
142
136
  type TransformMethods <Methods extends { [key: string]: Function }> =
@@ -254,7 +254,7 @@ export default class AeSdkWallet extends AeSdk {
254
254
  }
255
255
  try {
256
256
  return jsonBig.parse(jsonBig.stringify({
257
- transactionHash: await this.send(tx, { ...parameters, verify: false }),
257
+ transactionHash: await this.sendTransaction(tx, { ...parameters, verify: false }),
258
258
  }));
259
259
  } catch (error) {
260
260
  const validation = await verifyTransaction(tx, this.api);
package/src/Node.ts CHANGED
@@ -3,11 +3,12 @@ import BigNumber from 'bignumber.js';
3
3
  import { OperationArguments, OperationSpec } from '@azure/core-client';
4
4
  import {
5
5
  genRequestQueuesPolicy, genCombineGetRequestsPolicy, genErrorFormatterPolicy,
6
- genVersionCheckPolicy,
6
+ genVersionCheckPolicy, genRetryOnFailurePolicy,
7
7
  } from './utils/autorest';
8
8
  import { Node as NodeApi, NodeOptionalParams, ErrorModel } from './apis/node';
9
9
  import { mapObject } from './utils/other';
10
10
  import { Encoded } from './utils/encoder';
11
+ import { ConsensusProtocolVersion } from './tx/builder/constants';
11
12
 
12
13
  const bigIntPropertyNames = [
13
14
  'balance', 'queryFee', 'fee', 'amount', 'nameFee', 'channelAmount',
@@ -17,7 +18,7 @@ const bigIntPropertyNames = [
17
18
 
18
19
  const numberPropertyNames = [
19
20
  'time', 'gas', 'gasUsed', 'nameSalt',
20
- 'nonce', 'nextNonce', 'height', 'blockHeight', 'top', 'topBlockHeight',
21
+ 'nonce', 'nextNonce', 'height', 'blockHeight', 'topBlockHeight',
21
22
  'ttl', 'nameTtl', 'clientTtl',
22
23
  'inbound', 'outbound', 'peerCount', 'pendingTransactionsCount', 'effectiveAtHeight',
23
24
  'version', 'solutions', 'round',
@@ -91,7 +92,9 @@ export type TransformNodeType<Type> =
91
92
  ? PreserveOptional<number, Type[Property]>
92
93
  : Property extends 'txHash'
93
94
  ? PreserveOptional<Encoded.TxHash, Type[Property]>
94
- : TransformNodeType<Type[Property]>
95
+ : Property extends 'bytecode'
96
+ ? PreserveOptional<Encoded.ContractBytearray, Type[Property]>
97
+ : TransformNodeType<Type[Property]>
95
98
  }
96
99
  : Type;
97
100
  type NodeTransformedApi = new (...args: ConstructorParameters<typeof NodeApi>) => {
@@ -104,20 +107,28 @@ export interface NodeInfo {
104
107
  url: string;
105
108
  nodeNetworkId: string;
106
109
  version: string;
107
- consensusProtocolVersion: number;
110
+ consensusProtocolVersion: ConsensusProtocolVersion;
108
111
  }
109
112
 
110
113
  export default class Node extends (NodeTransformed as unknown as NodeTransformedApi) {
111
- #networkIdPromise?: Promise<string>;
114
+ #networkIdPromise?: Promise<string | Error>;
112
115
 
113
116
  /**
114
117
  * @param url - Url for node API
115
118
  * @param options - Options
116
119
  * @param options.ignoreVersion - Don't check node version
120
+ * @param options.retryCount - Amount of extra requests to do in case of failure
121
+ * @param options.retryOverallDelay - Time in ms to wait between all retries
117
122
  */
118
123
  constructor(
119
124
  url: string,
120
- { ignoreVersion = false, ...options }: NodeOptionalParams & { ignoreVersion?: boolean } = {},
125
+ {
126
+ ignoreVersion = false, retryCount = 3, retryOverallDelay = 800, ...options
127
+ }: NodeOptionalParams & {
128
+ ignoreVersion?: boolean;
129
+ retryCount?: number;
130
+ retryOverallDelay?: number;
131
+ } = {},
121
132
  ) {
122
133
  // eslint-disable-next-line constructor-super
123
134
  super(url, {
@@ -125,14 +136,15 @@ export default class Node extends (NodeTransformed as unknown as NodeTransformed
125
136
  additionalPolicies: [
126
137
  genRequestQueuesPolicy(),
127
138
  genCombineGetRequestsPolicy(),
139
+ genRetryOnFailurePolicy(retryCount, retryOverallDelay),
128
140
  genErrorFormatterPolicy((body: ErrorModel) => ` ${body.reason}`),
129
141
  ],
130
142
  ...options,
131
143
  });
132
144
  if (!ignoreVersion) {
133
145
  const statusPromise = this.getStatus();
134
- const versionPromise = statusPromise.then(({ nodeVersion }) => nodeVersion);
135
- this.#networkIdPromise = statusPromise.then(({ networkId }) => networkId);
146
+ const versionPromise = statusPromise.then(({ nodeVersion }) => nodeVersion, (error) => error);
147
+ this.#networkIdPromise = statusPromise.then(({ networkId }) => networkId, (error) => error);
136
148
  this.pipeline.addPolicy(
137
149
  genVersionCheckPolicy('node', '/v3/status', versionPromise, '6.2.0', '7.0.0'),
138
150
  );
@@ -142,7 +154,9 @@ export default class Node extends (NodeTransformed as unknown as NodeTransformed
142
154
 
143
155
  async getNetworkId(): Promise<string> {
144
156
  this.#networkIdPromise ??= this.getStatus().then(({ networkId }) => networkId);
145
- return this.#networkIdPromise;
157
+ const networkId = await this.#networkIdPromise;
158
+ if (networkId instanceof Error) throw networkId;
159
+ return networkId;
146
160
  }
147
161
 
148
162
  async getNodeInfo(): Promise<NodeInfo> {