@aeternity/aepp-sdk 11.0.1 → 12.1.1

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 (444) hide show
  1. package/LICENSE +1 -1
  2. package/dist/aepp-sdk.browser-script.js +1 -1
  3. package/dist/aepp-sdk.browser-script.js.LICENSE.txt +0 -22
  4. package/dist/aepp-sdk.browser-script.js.map +1 -1
  5. package/dist/aepp-sdk.browser.js +2 -1
  6. package/dist/aepp-sdk.browser.js.LICENSE.txt +1 -0
  7. package/dist/aepp-sdk.browser.js.map +1 -1
  8. package/dist/aepp-sdk.js +20765 -1
  9. package/dist/aepp-sdk.js.map +1 -1
  10. package/es/AeSdk.d.ts +37 -0
  11. package/es/AeSdk.mjs +81 -0
  12. package/es/AeSdk.mjs.map +1 -0
  13. package/es/AeSdkAepp.d.ts +70 -0
  14. package/es/AeSdkAepp.mjs +176 -0
  15. package/es/AeSdkAepp.mjs.map +1 -0
  16. package/es/AeSdkBase.d.ts +213 -0
  17. package/es/AeSdkBase.mjs +314 -0
  18. package/es/AeSdkBase.mjs.map +1 -0
  19. package/es/AeSdkWallet.d.ts +104 -0
  20. package/es/AeSdkWallet.mjs +326 -0
  21. package/es/AeSdkWallet.mjs.map +1 -0
  22. package/es/Node.d.ts +41 -0
  23. package/es/Node.mjs +147 -0
  24. package/es/Node.mjs.map +1 -0
  25. package/es/account/Base.d.ts +68 -0
  26. package/es/account/Base.mjs +123 -0
  27. package/es/account/Base.mjs.map +1 -0
  28. package/es/account/Memory.d.ts +26 -0
  29. package/es/account/Memory.mjs +103 -0
  30. package/es/account/Memory.mjs.map +1 -0
  31. package/es/account/Rpc.d.ts +27 -0
  32. package/es/account/Rpc.mjs +80 -0
  33. package/es/account/Rpc.mjs.map +1 -0
  34. package/es/aens.d.ts +222 -0
  35. package/es/aens.mjs +338 -0
  36. package/es/aens.mjs.map +1 -0
  37. package/es/aepp-wallet-communication/connection/Browser.d.ts +33 -0
  38. package/es/aepp-wallet-communication/connection/Browser.mjs +73 -0
  39. package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -0
  40. package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +18 -0
  41. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +58 -0
  42. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -0
  43. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +36 -0
  44. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +146 -0
  45. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -0
  46. package/es/aepp-wallet-communication/connection-proxy.d.ts +11 -0
  47. package/{src/utils/crypto-ts.ts → es/aepp-wallet-communication/connection-proxy.mjs} +16 -11
  48. package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -0
  49. package/es/aepp-wallet-communication/rpc/RpcClient.d.ts +34 -0
  50. package/es/aepp-wallet-communication/rpc/RpcClient.mjs +169 -0
  51. package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -0
  52. package/es/aepp-wallet-communication/rpc/types.d.ts +77 -0
  53. package/es/aepp-wallet-communication/rpc/types.mjs +3 -0
  54. package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -0
  55. package/es/aepp-wallet-communication/schema.d.ts +105 -46
  56. package/es/aepp-wallet-communication/schema.mjs +251 -0
  57. package/es/aepp-wallet-communication/schema.mjs.map +1 -0
  58. package/es/aepp-wallet-communication/wallet-detector.d.ts +25 -0
  59. package/es/aepp-wallet-communication/wallet-detector.mjs +62 -0
  60. package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -0
  61. package/es/apis/compiler/compiler.d.ts +92 -0
  62. package/es/apis/compiler/compiler.mjs +576 -0
  63. package/es/apis/compiler/compiler.mjs.map +1 -0
  64. package/es/apis/compiler/index.d.ts +2 -0
  65. package/es/apis/compiler/index.mjs +3 -0
  66. package/es/apis/compiler/index.mjs.map +1 -0
  67. package/es/apis/compiler/models/index.d.ts +248 -0
  68. package/es/apis/compiler/models/index.mjs +48 -0
  69. package/es/apis/compiler/models/index.mjs.map +1 -0
  70. package/es/apis/compiler/models/mappers.d.ts +23 -0
  71. package/es/apis/compiler/models/mappers.mjs +585 -0
  72. package/es/apis/compiler/models/mappers.mjs.map +1 -0
  73. package/es/apis/compiler/models/parameters.d.ts +13 -0
  74. package/es/apis/compiler/models/parameters.mjs +71 -0
  75. package/es/apis/compiler/models/parameters.mjs.map +1 -0
  76. package/es/apis/node/index.d.ts +2 -0
  77. package/es/apis/node/index.mjs +3 -0
  78. package/es/apis/node/index.mjs.map +1 -0
  79. package/es/apis/node/models/index.d.ts +1065 -0
  80. package/es/apis/node/models/index.mjs +2 -0
  81. package/es/apis/node/models/index.mjs.map +1 -0
  82. package/es/apis/node/models/mappers.d.ts +95 -0
  83. package/es/apis/node/models/mappers.mjs +4166 -0
  84. package/es/apis/node/models/mappers.mjs.map +1 -0
  85. package/es/apis/node/models/parameters.d.ts +17 -0
  86. package/es/apis/node/models/parameters.mjs +165 -0
  87. package/es/apis/node/models/parameters.mjs.map +1 -0
  88. package/es/apis/node/node.d.ts +215 -0
  89. package/es/apis/node/node.mjs +1165 -0
  90. package/es/apis/node/node.mjs.map +1 -0
  91. package/es/chain.d.ts +248 -0
  92. package/es/chain.mjs +560 -0
  93. package/es/chain.mjs.map +1 -0
  94. package/es/channel/handlers.d.ts +34 -0
  95. package/es/channel/handlers.mjs +164 -131
  96. package/es/channel/handlers.mjs.map +1 -1
  97. package/es/channel/index.d.ts +625 -0
  98. package/es/channel/index.mjs +897 -902
  99. package/es/channel/index.mjs.map +1 -1
  100. package/es/channel/internal.d.ts +101 -0
  101. package/es/channel/internal.mjs +136 -85
  102. package/es/channel/internal.mjs.map +1 -1
  103. package/es/contract/Compiler.d.ts +18 -0
  104. package/es/contract/Compiler.mjs +68 -0
  105. package/es/contract/Compiler.mjs.map +1 -0
  106. package/es/contract/aci.d.ts +127 -0
  107. package/es/contract/aci.mjs +225 -193
  108. package/es/contract/aci.mjs.map +1 -1
  109. package/es/contract/ga.d.ts +69 -0
  110. package/es/contract/ga.mjs +195 -0
  111. package/es/contract/ga.mjs.map +1 -0
  112. package/es/contract/methods.d.ts +71 -0
  113. package/es/contract/methods.mjs +104 -0
  114. package/es/contract/methods.mjs.map +1 -0
  115. package/es/deprecated/index.d.ts +143 -0
  116. package/es/deprecated/index.mjs +162 -0
  117. package/es/deprecated/index.mjs.map +1 -0
  118. package/es/deprecated/methods.d.ts +18 -0
  119. package/es/deprecated/methods.mjs +26 -0
  120. package/es/deprecated/methods.mjs.map +1 -0
  121. package/es/index.d.ts +35 -0
  122. package/es/index.mjs +35 -40
  123. package/es/index.mjs.map +1 -1
  124. package/es/oracle.d.ts +161 -0
  125. package/es/oracle.mjs +306 -0
  126. package/es/oracle.mjs.map +1 -0
  127. package/es/spend.d.ts +62 -0
  128. package/es/spend.mjs +111 -0
  129. package/es/spend.mjs.map +1 -0
  130. package/es/tx/builder/address.d.ts +25 -0
  131. package/es/tx/builder/address.mjs +45 -0
  132. package/es/tx/builder/address.mjs.map +1 -0
  133. package/es/tx/builder/constants.d.ts +70 -0
  134. package/es/tx/builder/constants.mjs +61 -47
  135. package/es/tx/builder/constants.mjs.map +1 -1
  136. package/es/tx/builder/field-types/coin-amount.d.ts +13 -0
  137. package/es/tx/builder/field-types/coin-amount.mjs +26 -0
  138. package/es/tx/builder/field-types/coin-amount.mjs.map +1 -0
  139. package/es/tx/builder/field-types/deposit.d.ts +15 -0
  140. package/es/tx/builder/field-types/deposit.mjs +19 -0
  141. package/es/tx/builder/field-types/deposit.mjs.map +1 -0
  142. package/es/tx/builder/field-types/fee.d.ts +25 -0
  143. package/es/tx/builder/field-types/fee.mjs +150 -0
  144. package/es/tx/builder/field-types/fee.mjs.map +1 -0
  145. package/es/tx/builder/field-types/field.d.ts +6 -0
  146. package/es/tx/builder/field-types/field.mjs +15 -0
  147. package/es/tx/builder/field-types/field.mjs.map +1 -0
  148. package/es/tx/builder/field-types/gas-limit.d.ts +12 -0
  149. package/es/tx/builder/field-types/gas-limit.mjs +33 -0
  150. package/es/tx/builder/field-types/gas-limit.mjs.map +1 -0
  151. package/es/tx/builder/field-types/gas-price.d.ts +8 -0
  152. package/es/tx/builder/field-types/gas-price.mjs +18 -0
  153. package/es/tx/builder/field-types/gas-price.mjs.map +1 -0
  154. package/es/tx/builder/field-types/index.d.ts +70 -0
  155. package/es/tx/builder/field-types/index.mjs +25 -0
  156. package/es/tx/builder/field-types/index.mjs.map +1 -0
  157. package/es/tx/builder/field-types/name-fee.d.ts +20 -0
  158. package/es/tx/builder/field-types/name-fee.mjs +24 -0
  159. package/es/tx/builder/field-types/name-fee.mjs.map +1 -0
  160. package/es/tx/builder/field-types/name-id.d.ts +14 -0
  161. package/es/tx/builder/field-types/name-id.mjs +19 -0
  162. package/es/tx/builder/field-types/name-id.mjs.map +1 -0
  163. package/es/tx/builder/field-types/name.d.ts +13 -0
  164. package/es/tx/builder/field-types/name.mjs +18 -0
  165. package/es/tx/builder/field-types/name.mjs.map +1 -0
  166. package/es/tx/builder/field-types/short-u-int.d.ts +6 -0
  167. package/es/tx/builder/field-types/short-u-int.mjs +12 -0
  168. package/es/tx/builder/field-types/short-u-int.mjs.map +1 -0
  169. package/es/tx/builder/field-types/u-int.d.ts +8 -0
  170. package/es/tx/builder/field-types/u-int.mjs +14 -0
  171. package/es/tx/builder/field-types/u-int.mjs.map +1 -0
  172. package/es/tx/builder/helpers.d.ts +125 -0
  173. package/es/tx/builder/helpers.mjs +94 -198
  174. package/es/tx/builder/helpers.mjs.map +1 -1
  175. package/es/tx/builder/index.d.ts +88 -0
  176. package/es/tx/builder/index.mjs +167 -358
  177. package/es/tx/builder/index.mjs.map +1 -1
  178. package/es/tx/builder/schema.d.ts +1201 -0
  179. package/es/tx/builder/schema.mjs +175 -561
  180. package/es/tx/builder/schema.mjs.map +1 -1
  181. package/es/tx/index.d.ts +64 -0
  182. package/es/tx/index.mjs +151 -265
  183. package/es/tx/index.mjs.map +1 -1
  184. package/es/tx/validator.d.ts +20 -0
  185. package/es/tx/validator.mjs +104 -124
  186. package/es/tx/validator.mjs.map +1 -1
  187. package/es/typings/@aeternity__argon2-browser/index.d.mjs +2 -0
  188. package/es/typings/@aeternity__argon2-browser/index.d.mjs.map +1 -0
  189. package/es/typings/@aeternity__uuid/index.d.mjs +2 -0
  190. package/es/typings/@aeternity__uuid/index.d.mjs.map +1 -0
  191. package/es/typings/bip32-path/index.d.mjs +2 -0
  192. package/es/typings/bip32-path/index.d.mjs.map +1 -0
  193. package/es/typings/blakejs/index.d.mjs.map +1 -1
  194. package/es/typings/sha-js/index.d.mjs +2 -0
  195. package/es/typings/sha-js/index.d.mjs.map +1 -0
  196. package/es/typings/tweetnacl-auth/index.d.mjs +2 -0
  197. package/es/typings/tweetnacl-auth/index.d.mjs.map +1 -0
  198. package/es/utils/amount-formatter.d.ts +42 -0
  199. package/es/utils/amount-formatter.mjs +36 -49
  200. package/es/utils/amount-formatter.mjs.map +1 -1
  201. package/es/utils/autorest.d.ts +6 -0
  202. package/es/utils/autorest.mjs +97 -0
  203. package/es/utils/autorest.mjs.map +1 -0
  204. package/es/utils/bignumber.d.ts +13 -0
  205. package/es/utils/bignumber.mjs +11 -8
  206. package/es/utils/bignumber.mjs.map +1 -1
  207. package/es/{bytes.d.ts → utils/bytes.d.ts} +10 -13
  208. package/es/utils/bytes.mjs +11 -15
  209. package/es/utils/bytes.mjs.map +1 -1
  210. package/es/utils/crypto.d.ts +88 -0
  211. package/es/utils/crypto.mjs +64 -98
  212. package/es/utils/crypto.mjs.map +1 -1
  213. package/es/utils/encoder-types.d.ts +61 -0
  214. package/es/utils/encoder-types.mjs +36 -0
  215. package/es/utils/encoder-types.mjs.map +1 -0
  216. package/es/utils/encoder.d.ts +25 -0
  217. package/es/utils/encoder.mjs +71 -59
  218. package/es/utils/encoder.mjs.map +1 -1
  219. package/es/{errors.d.ts → utils/errors.d.ts} +246 -59
  220. package/es/utils/errors.mjs +313 -136
  221. package/es/utils/errors.mjs.map +1 -1
  222. package/es/utils/hd-wallet.d.ts +50 -0
  223. package/es/utils/hd-wallet.mjs +86 -45
  224. package/es/utils/hd-wallet.mjs.map +1 -1
  225. package/es/utils/json-big.d.ts +5 -0
  226. package/es/utils/json-big.mjs +12 -16
  227. package/es/utils/json-big.mjs.map +1 -1
  228. package/es/utils/keystore.d.ts +51 -0
  229. package/es/utils/keystore.mjs +101 -194
  230. package/es/utils/keystore.mjs.map +1 -1
  231. package/es/{mptree.d.ts → utils/mptree.d.ts} +6 -9
  232. package/es/utils/mptree.mjs +22 -18
  233. package/es/utils/mptree.mjs.map +1 -1
  234. package/es/utils/other.d.ts +20 -0
  235. package/es/utils/other.mjs +32 -35
  236. package/es/utils/other.mjs.map +1 -1
  237. package/es/utils/semver-satisfies.d.ts +1 -0
  238. package/es/utils/semver-satisfies.mjs +2 -2
  239. package/es/utils/semver-satisfies.mjs.map +1 -1
  240. package/es/utils/string.d.ts +24 -0
  241. package/es/utils/string.mjs +8 -10
  242. package/es/utils/string.mjs.map +1 -1
  243. package/package.json +55 -43
  244. package/src/AeSdk.ts +68 -0
  245. package/src/AeSdkAepp.ts +176 -0
  246. package/src/AeSdkBase.ts +338 -0
  247. package/src/AeSdkWallet.ts +348 -0
  248. package/src/Node.ts +173 -0
  249. package/src/account/Base.ts +124 -0
  250. package/src/account/Memory.ts +98 -0
  251. package/src/account/Rpc.ts +69 -0
  252. package/src/aens.ts +407 -0
  253. package/src/aepp-wallet-communication/connection/Browser.ts +71 -0
  254. package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +59 -0
  255. package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +122 -0
  256. package/{es/utils/crypto-ts.mjs → src/aepp-wallet-communication/connection-proxy.ts} +18 -18
  257. package/src/aepp-wallet-communication/rpc/RpcClient.ts +143 -0
  258. package/src/aepp-wallet-communication/rpc/types.ts +66 -0
  259. package/src/aepp-wallet-communication/schema.ts +224 -0
  260. package/src/aepp-wallet-communication/wallet-detector.ts +72 -0
  261. package/src/apis/compiler/code-model-v4.yaml +2649 -0
  262. package/src/apis/compiler/compiler.ts +585 -0
  263. package/src/apis/compiler/index.ts +2 -0
  264. package/src/apis/compiler/models/index.ts +301 -0
  265. package/src/apis/compiler/models/mappers.ts +583 -0
  266. package/src/apis/compiler/models/parameters.ts +93 -0
  267. package/src/apis/node/code-model-v4.yaml +10080 -0
  268. package/src/apis/node/index.ts +2 -0
  269. package/src/apis/node/models/index.ts +1257 -0
  270. package/src/apis/node/models/mappers.ts +4280 -0
  271. package/src/apis/node/models/parameters.ts +188 -0
  272. package/src/apis/node/node.ts +1299 -0
  273. package/src/chain.ts +502 -0
  274. package/src/channel/handlers.ts +817 -0
  275. package/src/channel/index.ts +1025 -0
  276. package/src/channel/internal.ts +361 -0
  277. package/src/contract/Compiler.ts +67 -0
  278. package/src/contract/aci.ts +538 -0
  279. package/src/contract/ga.ts +199 -0
  280. package/src/contract/methods.ts +123 -0
  281. package/src/deprecated/index.ts +172 -0
  282. package/src/deprecated/methods.ts +25 -0
  283. package/src/index.ts +56 -0
  284. package/src/oracle.ts +364 -0
  285. package/src/spend.ts +164 -0
  286. package/src/tx/builder/address.ts +50 -0
  287. package/src/tx/builder/constants.ts +126 -0
  288. package/src/tx/builder/field-types/coin-amount.ts +27 -0
  289. package/src/tx/builder/field-types/deposit.ts +21 -0
  290. package/src/tx/builder/field-types/fee.ts +143 -0
  291. package/src/tx/builder/field-types/field.ts +9 -0
  292. package/src/tx/builder/field-types/gas-limit.ts +41 -0
  293. package/src/tx/builder/field-types/gas-price.ts +16 -0
  294. package/src/tx/builder/field-types/index.ts +45 -0
  295. package/src/tx/builder/field-types/name-fee.ts +32 -0
  296. package/src/tx/builder/field-types/name-id.ts +20 -0
  297. package/src/tx/builder/field-types/name.ts +18 -0
  298. package/src/tx/builder/field-types/short-u-int.ts +11 -0
  299. package/src/tx/builder/field-types/u-int.ts +16 -0
  300. package/src/tx/builder/helpers.ts +248 -0
  301. package/src/tx/builder/index.ts +400 -0
  302. package/src/tx/builder/schema.ts +727 -0
  303. package/src/tx/index.ts +192 -0
  304. package/src/tx/validator.ts +230 -0
  305. package/src/typings/@aeternity__argon2-browser/index.d.ts +3 -0
  306. package/src/typings/@aeternity__uuid/index.d.ts +5 -0
  307. package/src/typings/bip32-path/index.d.ts +33 -0
  308. package/src/typings/blakejs/index.d.ts +4 -32
  309. package/src/typings/sha-js/index.d.ts +5 -0
  310. package/src/typings/tweetnacl-auth/index.d.ts +14 -0
  311. package/src/utils/amount-formatter.ts +56 -69
  312. package/src/utils/autorest.ts +93 -0
  313. package/src/utils/bignumber.ts +11 -12
  314. package/src/utils/bytes.ts +29 -31
  315. package/src/utils/crypto.ts +205 -0
  316. package/src/utils/encoder-types.ts +63 -0
  317. package/src/utils/encoder.ts +116 -71
  318. package/src/utils/errors.ts +482 -366
  319. package/src/utils/hd-wallet.ts +166 -0
  320. package/src/utils/json-big.ts +27 -0
  321. package/src/utils/keystore.ts +182 -0
  322. package/src/utils/mptree.ts +64 -61
  323. package/src/utils/other.ts +34 -41
  324. package/src/utils/semver-satisfies.ts +15 -11
  325. package/src/utils/string.ts +18 -20
  326. package/es/account/base.mjs +0 -179
  327. package/es/account/base.mjs.map +0 -1
  328. package/es/account/memory.mjs +0 -99
  329. package/es/account/memory.mjs.map +0 -1
  330. package/es/account/multiple.mjs +0 -179
  331. package/es/account/multiple.mjs.map +0 -1
  332. package/es/ae/aens.mjs +0 -404
  333. package/es/ae/aens.mjs.map +0 -1
  334. package/es/ae/aepp.mjs +0 -45
  335. package/es/ae/aepp.mjs.map +0 -1
  336. package/es/ae/contract.mjs +0 -159
  337. package/es/ae/contract.mjs.map +0 -1
  338. package/es/ae/index.mjs +0 -207
  339. package/es/ae/index.mjs.map +0 -1
  340. package/es/ae/oracle.mjs +0 -339
  341. package/es/ae/oracle.mjs.map +0 -1
  342. package/es/ae/universal.mjs +0 -45
  343. package/es/ae/universal.mjs.map +0 -1
  344. package/es/ae/wallet.mjs +0 -50
  345. package/es/ae/wallet.mjs.map +0 -1
  346. package/es/amount-formatter.d.ts +0 -58
  347. package/es/bignumber.d.ts +0 -18
  348. package/es/chain/index.mjs +0 -272
  349. package/es/chain/index.mjs.map +0 -1
  350. package/es/chain/node.mjs +0 -442
  351. package/es/chain/node.mjs.map +0 -1
  352. package/es/contract/compiler.mjs +0 -115
  353. package/es/contract/compiler.mjs.map +0 -1
  354. package/es/contract/ga/helpers.mjs +0 -30
  355. package/es/contract/ga/helpers.mjs.map +0 -1
  356. package/es/contract/ga/index.mjs +0 -178
  357. package/es/contract/ga/index.mjs.map +0 -1
  358. package/es/crypto-ts.d.ts +0 -9
  359. package/es/encoder.d.ts +0 -26
  360. package/es/node-pool/index.mjs +0 -188
  361. package/es/node-pool/index.mjs.map +0 -1
  362. package/es/node.mjs +0 -133
  363. package/es/node.mjs.map +0 -1
  364. package/es/other.d.ts +0 -31
  365. package/es/semver-satisfies.d.ts +0 -1
  366. package/es/string.d.ts +0 -26
  367. package/es/tx/builder/field-types.mjs +0 -74
  368. package/es/tx/builder/field-types.mjs.map +0 -1
  369. package/es/tx/tx-object.mjs +0 -283
  370. package/es/tx/tx-object.mjs.map +0 -1
  371. package/es/tx/tx.mjs +0 -938
  372. package/es/tx/tx.mjs.map +0 -1
  373. package/es/utils/aepp-wallet-communication/connection/browser-runtime.mjs +0 -132
  374. package/es/utils/aepp-wallet-communication/connection/browser-runtime.mjs.map +0 -1
  375. package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs +0 -183
  376. package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs.map +0 -1
  377. package/es/utils/aepp-wallet-communication/connection/index.mjs +0 -87
  378. package/es/utils/aepp-wallet-communication/connection/index.mjs.map +0 -1
  379. package/es/utils/aepp-wallet-communication/content-script-bridge.mjs +0 -98
  380. package/es/utils/aepp-wallet-communication/content-script-bridge.mjs.map +0 -1
  381. package/es/utils/aepp-wallet-communication/helpers.mjs +0 -92
  382. package/es/utils/aepp-wallet-communication/helpers.mjs.map +0 -1
  383. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs +0 -375
  384. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs.map +0 -1
  385. package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs +0 -275
  386. package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs.map +0 -1
  387. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs +0 -541
  388. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs.map +0 -1
  389. package/es/utils/aepp-wallet-communication/schema.mjs +0 -102
  390. package/es/utils/aepp-wallet-communication/schema.mjs.map +0 -1
  391. package/es/utils/aepp-wallet-communication/wallet-detector.mjs +0 -110
  392. package/es/utils/aepp-wallet-communication/wallet-detector.mjs.map +0 -1
  393. package/es/utils/async-init.mjs +0 -64
  394. package/es/utils/async-init.mjs.map +0 -1
  395. package/es/utils/crypto-ts.mjs.map +0 -1
  396. package/es/utils/swagger.mjs +0 -164
  397. package/es/utils/swagger.mjs.map +0 -1
  398. package/src/account/base.js +0 -153
  399. package/src/account/memory.js +0 -83
  400. package/src/account/multiple.js +0 -162
  401. package/src/ae/aens.js +0 -361
  402. package/src/ae/aepp.js +0 -45
  403. package/src/ae/contract.js +0 -148
  404. package/src/ae/index.js +0 -168
  405. package/src/ae/oracle.js +0 -311
  406. package/src/ae/universal.js +0 -47
  407. package/src/ae/wallet.js +0 -50
  408. package/src/chain/index.js +0 -269
  409. package/src/chain/node.js +0 -320
  410. package/src/channel/handlers.js +0 -673
  411. package/src/channel/index.js +0 -903
  412. package/src/channel/internal.js +0 -236
  413. package/src/contract/aci.js +0 -376
  414. package/src/contract/compiler.js +0 -100
  415. package/src/contract/ga/helpers.js +0 -19
  416. package/src/contract/ga/index.js +0 -150
  417. package/src/index.js +0 -89
  418. package/src/node-pool/index.js +0 -172
  419. package/src/node.js +0 -116
  420. package/src/tx/builder/constants.js +0 -100
  421. package/src/tx/builder/field-types.js +0 -61
  422. package/src/tx/builder/helpers.js +0 -334
  423. package/src/tx/builder/index.js +0 -465
  424. package/src/tx/builder/schema.js +0 -1100
  425. package/src/tx/index.js +0 -301
  426. package/src/tx/tx-object.js +0 -187
  427. package/src/tx/tx.js +0 -631
  428. package/src/tx/validator.js +0 -181
  429. package/src/utils/aepp-wallet-communication/connection/browser-runtime.js +0 -119
  430. package/src/utils/aepp-wallet-communication/connection/browser-window-message.js +0 -165
  431. package/src/utils/aepp-wallet-communication/connection/index.js +0 -85
  432. package/src/utils/aepp-wallet-communication/content-script-bridge.js +0 -86
  433. package/src/utils/aepp-wallet-communication/helpers.js +0 -60
  434. package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +0 -294
  435. package/src/utils/aepp-wallet-communication/rpc/rpc-client.js +0 -232
  436. package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +0 -401
  437. package/src/utils/aepp-wallet-communication/schema.ts +0 -80
  438. package/src/utils/aepp-wallet-communication/wallet-detector.js +0 -92
  439. package/src/utils/async-init.js +0 -45
  440. package/src/utils/crypto.js +0 -219
  441. package/src/utils/hd-wallet.js +0 -100
  442. package/src/utils/json-big.js +0 -26
  443. package/src/utils/keystore.js +0 -219
  444. package/src/utils/swagger.js +0 -156
@@ -1,43 +1,40 @@
1
- import { snakeToPascal, pascalToSnake } from "./string.mjs";
2
- export const pause = async duration => await new Promise(resolve => setTimeout(resolve, duration));
3
- export const mapObject = (object, fn) => Object.fromEntries(Object.entries(object).map(fn));
4
- export const filterObject = (object, fn) => Object.fromEntries(Object.entries(object).filter(fn));
5
- /**
6
- * Key traversal metafunction
7
- * @static
8
- * @function
9
- * @rtype (fn: (s: String) => String) => (o: Object) => Object
10
- * @param {Function} fn - Key transformation function
11
- * @param {Object} object - Object to traverse
12
- * @return {Object} Transformed object
13
- */
1
+ import _buffer from "buffer";
2
+ import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
3
+ const {
4
+ Buffer: _Buffer
5
+ } = _buffer;
6
+ export const pause = async duration => new Promise(resolve => {
7
+ setTimeout(resolve, duration);
8
+ });
9
+ export const mapObject = (object, fn) => Object.fromEntries(Object.entries(object).map(fn)); // remove after dropping webpack4 support
10
+
11
+ const isWebpack4Buffer = (() => {
12
+ try {
13
+ _Buffer.concat([Uint8Array.from([])]);
14
+
15
+ return false;
16
+ } catch (error) {
17
+ return true;
18
+ }
19
+ })();
14
20
 
15
- export const traverseKeys = (fn, object) => {
16
- if (typeof object !== 'object' || object === null) return object;
17
- if (Array.isArray(object)) return object.map(i => traverseKeys(fn, i));
18
- return mapObject(object, _ref => {
19
- let [key, value] = _ref;
20
- return [fn(key), traverseKeys(fn, value)];
21
- });
22
- };
21
+ export const concatBuffers = isWebpack4Buffer ? (list, totalLength) => _Buffer.concat(list.map(el => _Buffer.from(el)), totalLength) : _Buffer.concat;
23
22
  /**
24
- * snake_case key traversal
25
- * @static
26
- * @rtype (o: Object) => Object
27
- * @param {Object} object - Object to traverse
28
- * @return {Object} Transformed object
29
- * @see pascalToSnake
23
+ * Object key type guard
24
+ * @param key - Maybe object key
25
+ * @param object - Object
30
26
  */
31
27
 
32
- export const snakizeKeys = traverseKeys.bind(null, pascalToSnake);
28
+ export function isKeyOfObject(key, object) {
29
+ return key in object;
30
+ }
33
31
  /**
34
- * PascalCase key traversal
35
- * @static
36
- * @rtype (o: Object) => Object
37
- * @param {Object} object - Object to traverse
38
- * @return {Object} Transformed object
39
- * @see snakeToPascal
32
+ * Array item type guard
33
+ * @param item - Maybe array item
34
+ * @param array - Array
40
35
  */
41
36
 
42
- export const pascalizeKeys = traverseKeys.bind(null, snakeToPascal);
37
+ export function isItemOfArray(item, array) {
38
+ return _includesInstanceProperty(array).call(array, item);
39
+ }
43
40
  //# sourceMappingURL=other.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/other.ts"],"names":["snakeToPascal","pascalToSnake","pause","duration","Promise","resolve","setTimeout","mapObject","object","fn","Object","fromEntries","entries","map","filterObject","filter","traverseKeys","Array","isArray","i","key","value","snakizeKeys","bind","pascalizeKeys"],"mappings":"SAASA,a,EAAeC,a;AAExB,OAAO,MAAMC,KAAK,GAAG,MAAOC,QAAP,IACnB,MAAM,IAAIC,OAAJ,CAAYC,OAAO,IAAIC,UAAU,CAACD,OAAD,EAAUF,QAAV,CAAjC,CADD;AAGP,OAAO,MAAMI,SAAS,GAAG,CACvBC,MADuB,EAEvBC,EAFuB,KAGZC,MAAM,CAACC,WAAP,CAAmBD,MAAM,CAACE,OAAP,CAAeJ,MAAf,EAAuBK,GAAvB,CAA2BJ,EAA3B,CAAnB,CAHN;AAKP,OAAO,MAAMK,YAAY,GAAG,CAC1BN,MAD0B,EAE1BC,EAF0B,KAGfC,MAAM,CAACC,WAAP,CAAmBD,MAAM,CAACE,OAAP,CAAeJ,MAAf,EAAuBO,MAAvB,CAA8BN,EAA9B,CAAnB,CAHN;AAKP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMO,YAAY,GAAG,CAACP,EAAD,EAAeD,MAAf,KAAoC;AAC9D,MAAI,OAAOA,MAAP,KAAkB,QAAlB,IAA8BA,MAAM,KAAK,IAA7C,EAAmD,OAAOA,MAAP;AACnD,MAAIS,KAAK,CAACC,OAAN,CAAcV,MAAd,CAAJ,EAA2B,OAAOA,MAAM,CAACK,GAAP,CAAWM,CAAC,IAAIH,YAAY,CAACP,EAAD,EAAKU,CAAL,CAA5B,CAAP;AAC3B,SAAOZ,SAAS,CAACC,MAAD,EAAS;AAAA,QAAC,CAACY,GAAD,EAAMC,KAAN,CAAD;AAAA,WAAiC,CACxDZ,EAAE,CAACW,GAAD,CADsD,EAC/CJ,YAAY,CAACP,EAAD,EAAKY,KAAL,CADmC,CAAjC;AAAA,GAAT,CAAhB;AAGD,CANM;AAQP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,WAAW,GAAGN,YAAY,CAACO,IAAb,CAAkB,IAAlB,EAAwBtB,aAAxB,CAApB;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMuB,aAAa,GAAGR,YAAY,CAACO,IAAb,CAAkB,IAAlB,EAAwBvB,aAAxB,CAAtB","sourcesContent":["import { snakeToPascal, pascalToSnake } from './string'\n\nexport const pause = async (duration: number): Promise<void> =>\n await new Promise(resolve => setTimeout(resolve, duration))\n\nexport const mapObject = (\n object: object,\n fn: (value: [string, any], index: number, array: Array<[string, any]>) => Array<[string, any]>\n): object => Object.fromEntries(Object.entries(object).map(fn))\n\nexport const filterObject = (\n object: object,\n fn: (value: [string, any], index: number, array: Array<[string, any]>) => boolean\n): object => Object.fromEntries(Object.entries(object).filter(fn))\n\n/**\n * Key traversal metafunction\n * @static\n * @function\n * @rtype (fn: (s: String) => String) => (o: Object) => Object\n * @param {Function} fn - Key transformation function\n * @param {Object} object - Object to traverse\n * @return {Object} Transformed object\n */\nexport const traverseKeys = (fn: Function, object: any): any => {\n if (typeof object !== 'object' || object === null) return object\n if (Array.isArray(object)) return object.map(i => traverseKeys(fn, i))\n return mapObject(object, ([key, value]: [string, any]) => [\n fn(key), traverseKeys(fn, value)\n ])\n}\n\n/**\n * snake_case key traversal\n * @static\n * @rtype (o: Object) => Object\n * @param {Object} object - Object to traverse\n * @return {Object} Transformed object\n * @see pascalToSnake\n */\nexport const snakizeKeys = traverseKeys.bind(null, pascalToSnake)\n\n/**\n * PascalCase key traversal\n * @static\n * @rtype (o: Object) => Object\n * @param {Object} object - Object to traverse\n * @return {Object} Transformed object\n * @see snakeToPascal\n */\nexport const pascalizeKeys = traverseKeys.bind(null, snakeToPascal)\n"],"file":"other.mjs"}
1
+ {"version":3,"file":"other.mjs","names":["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"],"sources":["../../src/utils/other.ts"],"sourcesContent":["export 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>(key: string | number | symbol, object: T): 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"],"mappings":";;;;;AAAA,OAAO,MAAMA,KAAK,GAAG,MAAOC,QAAP,IAA2C,IAAIC,OAAJ,CAAaC,OAAD,IAAa;EACvFC,UAAU,CAACD,OAAD,EAAUF,QAAV,CAAV;AACD,CAF+D,CAAzD;AAIP,OAAO,MAAMI,SAAS,GAAG,CACvBC,MADuB,EAEvBC,EAFuB,KAKMC,MAAM,CAACC,WAAP,CAAmBD,MAAM,CAACE,OAAP,CAAeJ,MAAf,EAAuBK,GAAvB,CAA2BJ,EAA3B,CAAnB,CALxB,C,CAOP;;AACA,MAAMK,gBAAgB,GAAG,CAAC,MAAM;EAC9B,IAAI;IACF,QAAOC,MAAP,CAAc,CAACC,UAAU,CAACC,IAAX,CAAgB,EAAhB,CAAD,CAAd;;IACA,OAAO,KAAP;EACD,CAHD,CAGE,OAAOC,KAAP,EAAc;IACd,OAAO,IAAP;EACD;AACF,CAPwB,GAAzB;;AASA,OAAO,MAAMC,aAAa,GAAGL,gBAAgB,GACzC,CAACM,IAAD,EAA8BC,WAA9B,KACA,QAAON,MAAP,CAAcK,IAAI,CAACP,GAAL,CAAUS,EAAD,IAAQ,QAAOL,IAAP,CAAYK,EAAZ,CAAjB,CAAd,EAAiDD,WAAjD,CAFyC,GAIzC,QAAON,MAJJ;AAMP;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASQ,aAAT,CAA0BC,GAA1B,EAAyDhB,MAAzD,EAAoF;EACzF,OAAOgB,GAAG,IAAIhB,MAAd;AACD;AAED;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASiB,aAAT,CAA0BC,IAA1B,EAAqCC,KAArC,EAAqE;EAC1E,OAAO,0BAAAA,KAAK,MAAL,CAAAA,KAAK,EAAUD,IAAV,CAAZ;AACD"}
@@ -0,0 +1 @@
1
+ export default function semverSatisfies(version: string, geVersion: string, ltVersion: string): boolean;
@@ -1,4 +1,4 @@
1
- export default function (version, geVersion, ltVersion) {
1
+ export default function semverSatisfies(version, geVersion, ltVersion) {
2
2
  const getComponents = v => v.split(/[-+]/)[0].split('.').map(i => +i);
3
3
 
4
4
  const versionComponents = getComponents(version);
@@ -6,7 +6,7 @@ export default function (version, geVersion, ltVersion) {
6
6
  const ltComponents = getComponents(ltVersion);
7
7
  const base = Math.max(...versionComponents, ...geComponents, ...ltComponents) + 1;
8
8
 
9
- const componentsToNumber = components => components.reverse().reduce((acc, n, idx) => acc + n * Math.pow(base, idx), 0);
9
+ const componentsToNumber = components => components.reverse().reduce((acc, n, idx) => acc + n * base ** idx, 0);
10
10
 
11
11
  const vNumber = componentsToNumber(versionComponents);
12
12
  const geNumber = componentsToNumber(geComponents);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/semver-satisfies.ts"],"names":["version","geVersion","ltVersion","getComponents","v","split","map","i","versionComponents","geComponents","ltComponents","base","Math","max","componentsToNumber","components","reverse","reduce","acc","n","idx","pow","vNumber","geNumber","ltNumber"],"mappings":"AAAA,eAAe,UAAUA,OAAV,EAA2BC,SAA3B,EAA8CC,SAA9C,EAA0E;AACvF,QAAMC,aAAa,GAAIC,CAAD,IAAyBA,CAAC,CAC7CC,KAD4C,CACtC,MADsC,EAC9B,CAD8B,EAC3BA,KAD2B,CACrB,GADqB,EAChBC,GADgB,CACZC,CAAC,IAAI,CAACA,CADM,CAA/C;;AAGA,QAAMC,iBAAiB,GAAGL,aAAa,CAACH,OAAD,CAAvC;AACA,QAAMS,YAAY,GAAGN,aAAa,CAACF,SAAD,CAAlC;AACA,QAAMS,YAAY,GAAGP,aAAa,CAACD,SAAD,CAAlC;AAEA,QAAMS,IAAI,GAAGC,IAAI,CAACC,GAAL,CAAS,GAAGL,iBAAZ,EAA+B,GAAGC,YAAlC,EAAgD,GAAGC,YAAnD,IAAmE,CAAhF;;AACA,QAAMI,kBAAkB,GAAIC,UAAD,IAAkCA,UAAU,CAACC,OAAX,GAC1DC,MAD0D,CACnD,CAACC,GAAD,EAAMC,CAAN,EAASC,GAAT,KAAiBF,GAAG,GAAGC,CAAC,GAAGP,IAAI,CAACS,GAAL,CAASV,IAAT,EAAeS,GAAf,CADwB,EACH,CADG,CAA7D;;AAGA,QAAME,OAAO,GAAGR,kBAAkB,CAACN,iBAAD,CAAlC;AACA,QAAMe,QAAQ,GAAGT,kBAAkB,CAACL,YAAD,CAAnC;AACA,QAAMe,QAAQ,GAAGV,kBAAkB,CAACJ,YAAD,CAAnC;AACA,SAAOY,OAAO,IAAIC,QAAX,IAAuBD,OAAO,GAAGE,QAAxC;AACD","sourcesContent":["export default function (version: string, geVersion: string, ltVersion: string): 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 * Math.pow(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"],"file":"semver-satisfies.mjs"}
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,eAAT,CACbC,OADa,EAEbC,SAFa,EAGbC,SAHa,EAIJ;EACT,MAAMC,aAAa,GAAIC,CAAD,IAAyBA,CAAC,CAC7CC,KAD4C,CACtC,MADsC,EAC9B,CAD8B,EAC3BA,KAD2B,CACrB,GADqB,EAChBC,GADgB,CACXC,CAAD,IAAO,CAACA,CADI,CAA/C;;EAGA,MAAMC,iBAAiB,GAAGL,aAAa,CAACH,OAAD,CAAvC;EACA,MAAMS,YAAY,GAAGN,aAAa,CAACF,SAAD,CAAlC;EACA,MAAMS,YAAY,GAAGP,aAAa,CAACD,SAAD,CAAlC;EAEA,MAAMS,IAAI,GAAGC,IAAI,CAACC,GAAL,CAAS,GAAGL,iBAAZ,EAA+B,GAAGC,YAAlC,EAAgD,GAAGC,YAAnD,IAAmE,CAAhF;;EACA,MAAMI,kBAAkB,GAAIC,UAAD,IAAkCA,UAAU,CAACC,OAAX,GAC1DC,MAD0D,CACnD,CAACC,GAAD,EAAMC,CAAN,EAASC,GAAT,KAAiBF,GAAG,GAAGC,CAAC,GAAGR,IAAI,IAAIS,GADgB,EACX,CADW,CAA7D;;EAGA,MAAMC,OAAO,GAAGP,kBAAkB,CAACN,iBAAD,CAAlC;EACA,MAAMc,QAAQ,GAAGR,kBAAkB,CAACL,YAAD,CAAnC;EACA,MAAMc,QAAQ,GAAGT,kBAAkB,CAACJ,YAAD,CAAnC;EACA,OAAOW,OAAO,IAAIC,QAAX,IAAuBD,OAAO,GAAGE,QAAxC;AACD"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Convert string from snake_case to PascalCase
3
+ * @param s - String to convert
4
+ * @returns Converted string
5
+ */
6
+ export declare function snakeToPascal(s: string): string;
7
+ /**
8
+ * Convert string from PascalCase to snake_case
9
+ * @param s - String to convert
10
+ * @returns Converted string
11
+ */
12
+ export declare function pascalToSnake(s: string): string;
13
+ /**
14
+ * Check whether a string is valid hex.
15
+ * @param str - String to validate.
16
+ * @returns True if the string is valid hex, false otherwise.
17
+ */
18
+ export declare function isHex(str: string): boolean;
19
+ /**
20
+ * Check whether a string is valid base-64.
21
+ * @param str - String to validate.
22
+ * @returns True if the string is valid base-64, false otherwise.
23
+ */
24
+ export declare function isBase64(str: string): boolean;
@@ -17,18 +17,16 @@
17
17
 
18
18
  /**
19
19
  * Convert string from snake_case to PascalCase
20
- * @rtype (s: String) => String
21
- * @param {String} s - String to convert
22
- * @return {String} Converted string
20
+ * @param s - String to convert
21
+ * @returns Converted string
23
22
  */
24
23
  export function snakeToPascal(s) {
25
24
  return s.replace(/_./g, match => match[1].toUpperCase());
26
25
  }
27
26
  /**
28
27
  * Convert string from PascalCase to snake_case
29
- * @rtype (s: String) => String
30
- * @param {String} s - String to convert
31
- * @return {String} Converted string
28
+ * @param s - String to convert
29
+ * @returns Converted string
32
30
  */
33
31
 
34
32
  export function pascalToSnake(s) {
@@ -36,8 +34,8 @@ export function pascalToSnake(s) {
36
34
  }
37
35
  /**
38
36
  * Check whether a string is valid hex.
39
- * @param {string} str String to validate.
40
- * @return {boolean} True if the string is valid hex, false otherwise.
37
+ * @param str - String to validate.
38
+ * @returns True if the string is valid hex, false otherwise.
41
39
  */
42
40
 
43
41
  export function isHex(str) {
@@ -45,8 +43,8 @@ export function isHex(str) {
45
43
  }
46
44
  /**
47
45
  * Check whether a string is valid base-64.
48
- * @param {string} str String to validate.
49
- * @return {boolean} True if the string is valid base-64, false otherwise.
46
+ * @param str - String to validate.
47
+ * @returns True if the string is valid base-64, false otherwise.
50
48
  */
51
49
 
52
50
  export function isBase64(str) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/string.ts"],"names":["snakeToPascal","s","replace","match","toUpperCase","pascalToSnake","toLowerCase","isHex","str","length","test","isBase64","index","indexOf","slice"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,aAAT,CAAwBC,CAAxB,EAA2C;AAChD,SAAOA,CAAC,CAACC,OAAF,CAAU,KAAV,EAAiBC,KAAK,IAAIA,KAAK,CAAC,CAAD,CAAL,CAASC,WAAT,EAA1B,CAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,aAAT,CAAwBJ,CAAxB,EAA2C;AAChD,SAAOA,CAAC,CAACC,OAAF,CAAU,QAAV,EAAoBC,KAAK,IAAK,IAAGA,KAAK,CAACG,WAAN,EAAoB,EAArD,CAAP;AACD;AAED;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,KAAT,CAAgBC,GAAhB,EAAsC;AAC3C,SAAOA,GAAG,CAACC,MAAJ,GAAa,CAAb,KAAmB,CAAnB,IAAwB,eAAeC,IAAf,CAAoBF,GAApB,CAA/B;AACD;AAED;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASG,QAAT,CAAmBH,GAAnB,EAAyC;AAC9C,MAAIA,GAAG,CAACC,MAAJ,GAAa,CAAb,GAAiB,CAAjB,IAAsB,gBAAgBC,IAAhB,CAAqBF,GAArB,CAA1B,EAAqD,OAAO,KAAP;AACrD,QAAMI,KAAK,GAAGJ,GAAG,CAACK,OAAJ,CAAY,GAAZ,CAAd;AACA,SAAOD,KAAK,KAAK,CAAC,CAAX,IAAgB,SAASF,IAAT,CAAcF,GAAG,CAACM,KAAJ,CAAUF,KAAV,CAAd,CAAvB;AACD","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 * @rtype (s: String) => String\n * @param {String} s - String to convert\n * @return {String} 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 * @rtype (s: String) => String\n * @param {String} s - String to convert\n * @return {String} Converted string\n */\nexport function pascalToSnake (s: string): string {\n return s.replace(/[A-Z]/g, match => `_${match.toLowerCase()}`)\n}\n\n/**\n * Check whether a string is valid hex.\n * @param {string} str String to validate.\n * @return {boolean} True if the string is valid hex, false otherwise.\n */\nexport function isHex (str: string): boolean {\n return str.length % 2 === 0 && /^[0-9a-f]+$/i.test(str)\n}\n\n/**\n * Check whether a string is valid base-64.\n * @param {string} str String to validate.\n * @return {boolean} True if the string is valid base-64, false otherwise.\n */\nexport function isBase64 (str: string): boolean {\n if (str.length % 4 > 0 || /[^0-9a-z+/=]/i.test(str)) return false\n const index = str.indexOf('=')\n return index === -1 || /={1,2}/.test(str.slice(index))\n}\n"],"file":"string.mjs"}
1
+ {"version":3,"file":"string.mjs","names":["snakeToPascal","s","replace","match","toUpperCase","pascalToSnake","toLowerCase","isHex","str","length","test","isBase64","index","indexOf","slice"],"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\n/**\n * Check whether a string is valid hex.\n * @param str - String to validate.\n * @returns True if the string is valid hex, false otherwise.\n */\nexport function isHex(str: string): boolean {\n return str.length % 2 === 0 && /^[0-9a-f]+$/i.test(str);\n}\n\n/**\n * Check whether a string is valid base-64.\n * @param str - String to validate.\n * @returns True if the string is valid base-64, false otherwise.\n */\nexport function isBase64(str: string): boolean {\n if (str.length % 4 > 0 || /[^0-9a-z+/=]/i.test(str)) return false;\n const index = str.indexOf('=');\n return index === -1 || /={1,2}/.test(str.slice(index));\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,aAAT,CAAuBC,CAAvB,EAA0C;EAC/C,OAAOA,CAAC,CAACC,OAAF,CAAU,KAAV,EAAkBC,KAAD,IAAWA,KAAK,CAAC,CAAD,CAAL,CAASC,WAAT,EAA5B,CAAP;AACD;AAED;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,aAAT,CAAuBJ,CAAvB,EAA0C;EAC/C,OAAOA,CAAC,CAACC,OAAF,CAAU,QAAV,EAAqBC,KAAD,IAAY,IAAGA,KAAK,CAACG,WAAN,EAAoB,EAAvD,CAAP;AACD;AAED;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,KAAT,CAAeC,GAAf,EAAqC;EAC1C,OAAOA,GAAG,CAACC,MAAJ,GAAa,CAAb,KAAmB,CAAnB,IAAwB,eAAeC,IAAf,CAAoBF,GAApB,CAA/B;AACD;AAED;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASG,QAAT,CAAkBH,GAAlB,EAAwC;EAC7C,IAAIA,GAAG,CAACC,MAAJ,GAAa,CAAb,GAAiB,CAAjB,IAAsB,gBAAgBC,IAAhB,CAAqBF,GAArB,CAA1B,EAAqD,OAAO,KAAP;EACrD,MAAMI,KAAK,GAAGJ,GAAG,CAACK,OAAJ,CAAY,GAAZ,CAAd;EACA,OAAOD,KAAK,KAAK,CAAC,CAAX,IAAgB,SAASF,IAAT,CAAcF,GAAG,CAACM,KAAJ,CAAUF,KAAV,CAAd,CAAvB;AACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeternity/aepp-sdk",
3
- "version": "11.0.1",
3
+ "version": "12.1.1",
4
4
  "description": "SDK for the æternity blockchain",
5
5
  "main": "dist/aepp-sdk.js",
6
6
  "types": "es/index.d.ts",
@@ -11,17 +11,20 @@
11
11
  "sideEffects": false,
12
12
  "scripts": {
13
13
  "build:es": "tsc && babel src --config-file ./babel.esm.config.js --out-dir es --extensions .js,.ts --out-file-extension .mjs --source-maps true",
14
- "build": "webpack --mode=production && npm run build:es",
14
+ "build:api": "npx autorest tooling/autorest/compiler.yaml --output-artifact:code-model-v4 && npx autorest tooling/autorest/node.yaml --output-artifact:code-model-v4",
15
+ "build": "npm run build:api && webpack --mode=production && npm run build:es",
15
16
  "build:dev": "webpack --mode=development && npm run build:es",
16
17
  "docs:examples": "node tooling/docs/examples-to-md.js examples/node/*.js",
17
- "docs:api": "node apidoc.js",
18
- "lint": "eslint .",
18
+ "docs:api": "typedoc",
19
+ "commitlint": "commitlint --from develop",
20
+ "lint": "eslint . --ext .ts,.js,.mjs",
21
+ "report-coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
19
22
  "test": "nyc mocha './test/unit/' './test/integration/'",
20
23
  "test:integration": "nyc mocha './test/integration/'",
21
24
  "test:unit": "nyc mocha './test/unit/'",
22
25
  "test:watch": "mocha './test/unit/' './test/integration/' --watch",
23
26
  "prepare": "npm run build",
24
- "prepublishOnly": "npm run docs:examples",
27
+ "prepublishOnly": "test/examples.sh && npm run docs:examples && npm run docs:api",
25
28
  "release": "standard-version --skip.tag --infile docs/CHANGELOG.md"
26
29
  },
27
30
  "license": "ISC",
@@ -32,27 +35,33 @@
32
35
  "SDK"
33
36
  ],
34
37
  "dependencies": {
35
- "@aeternity/aepp-calldata": "^1.1.1",
38
+ "@aeternity/aepp-calldata": "^1.2.0",
36
39
  "@aeternity/argon2-browser": "^0.1.2",
37
- "@aeternity/blakejs": "^1.1.2",
38
- "@aeternity/json-bigint": "^0.3.1",
39
40
  "@aeternity/uuid": "^0.0.1",
40
- "@babel/runtime-corejs3": "^7.17.2",
41
- "@stamp/it": "^1.1.0",
42
- "@stamp/required": "^1.0.1",
41
+ "@azure/core-client": "^1.6.0",
42
+ "@azure/core-rest-pipeline": "^1.9.0",
43
+ "@babel/runtime-corejs3": "^7.18.9",
44
+ "@types/aes-js": "^3.1.1",
45
+ "@types/argon2-browser": "^1.18.1",
46
+ "@types/json-bigint": "^1.0.1",
47
+ "@types/sha.js": "^2.4.0",
48
+ "@types/uuid": "^8.3.4",
49
+ "@types/webextension-polyfill": "^0.9.0",
50
+ "@types/websocket": "^1.0.5",
43
51
  "aes-js": "^3.1.2",
44
52
  "bignumber.js": "^9.0.2",
45
53
  "bip32-path": "^0.4.2",
46
- "bs58": "^4.0.1",
54
+ "blakejs": "^1.2.1",
55
+ "bs58": "^5.0.0",
47
56
  "buffer": "^6.0.3",
48
- "cross-fetch": "^3.1.5",
49
57
  "events": "^3.3.0",
58
+ "json-bigint": "^1.0.0",
50
59
  "process": "^0.11.10",
51
60
  "rlp": "^3.0.0",
52
61
  "sha.js": "^2.4.11",
53
- "swagger-client": "^3.18.4",
54
62
  "tweetnacl": "^1.0.3",
55
63
  "tweetnacl-auth": "^1.0.1",
64
+ "varuint-bitcoin": "^1.1.2",
56
65
  "websocket": "^1.0.34"
57
66
  },
58
67
  "repository": {
@@ -60,42 +69,45 @@
60
69
  "url": "https://github.com/aeternity/aepp-sdk-js"
61
70
  },
62
71
  "devDependencies": {
63
- "@babel/cli": "^7.17.0",
64
- "@babel/core": "^7.17.2",
65
- "@babel/node": "^7.16.8",
66
- "@babel/plugin-transform-runtime": "^7.17.0",
67
- "@babel/preset-env": "^7.16.11",
68
- "@babel/preset-typescript": "^7.16.7",
69
- "@babel/register": "^7.17.0",
70
- "@commitlint/cli": "^16.1.0",
71
- "@commitlint/config-conventional": "^16.0.0",
72
- "@types/bn.js": "^5.1.0",
73
- "@types/bs58": "^4.0.1",
74
- "@types/chai": "^4.3.0",
75
- "@types/mocha": "^9.1.0",
76
- "@types/node": "^17.0.17",
77
- "@types/sha.js": "^2.4.0",
78
- "@typescript-eslint/eslint-plugin": "^5.11.0",
79
- "@typescript-eslint/parser": "^5.11.0",
80
- "babel-loader": "^8.2.3",
72
+ "@babel/cli": "^7.18.9",
73
+ "@babel/core": "^7.18.9",
74
+ "@babel/node": "^7.18.9",
75
+ "@babel/plugin-transform-runtime": "^7.18.9",
76
+ "@babel/preset-env": "^7.18.9",
77
+ "@babel/preset-typescript": "^7.18.6",
78
+ "@babel/register": "^7.18.9",
79
+ "@commitlint/cli": "^17.0.3",
80
+ "@commitlint/config-conventional": "^17.0.3",
81
+ "@types/chai": "^4.3.1",
82
+ "@types/chai-as-promised": "^7.1.5",
83
+ "@types/mocha": "^9.1.1",
84
+ "@types/sinon": "^10.0.13",
85
+ "@typescript-eslint/eslint-plugin": "^5.31.0",
86
+ "@typescript-eslint/parser": "^5.31.0",
87
+ "babel-loader": "^8.2.5",
81
88
  "babel-plugin-add-import-extension": "^1.6.0",
82
89
  "babel-plugin-import-globals": "^2.0.0",
83
90
  "babel-plugin-transform-default-named-imports": "^1.2.2",
84
91
  "chai": "^4.3.6",
85
92
  "chai-as-promised": "^7.1.1",
86
- "eslint": "^8.8.0",
87
- "eslint-config-standard": "^17.0.0-1",
88
- "jsdoc-to-markdown": "^7.1.1",
89
- "mocha": "^9.2.0",
93
+ "codecov": "^3.8.3",
94
+ "eslint": "^8.20.0",
95
+ "eslint-config-airbnb-base": "^15.0.0",
96
+ "eslint-config-airbnb-typescript": "^17.0.0",
97
+ "eslint-plugin-rulesdir": "^0.2.1",
98
+ "eslint-plugin-tsdoc": "^0.2.16",
99
+ "mocha": "^10.0.0",
90
100
  "nyc": "^15.1.0",
91
- "sinon": "^13.0.1",
92
- "source-map": "^0.7.3",
93
- "standard-version": "^9.3.2",
94
- "ts-node": "^10.5.0",
95
- "typescript": "^4.5.5",
96
- "webpack": "^5.68.0",
101
+ "sinon": "^14.0.0",
102
+ "source-map": "^0.7.4",
103
+ "standard-version": "^9.5.0",
104
+ "ts-node": "^10.9.1",
105
+ "typedoc": "^0.23.9",
106
+ "typedoc-plugin-missing-exports": "^0.23.0",
107
+ "typescript": "^4.7.4",
108
+ "webpack": "^5.74.0",
97
109
  "webpack-bundle-analyzer": "^4.5.0",
98
- "webpack-cli": "^4.9.2"
110
+ "webpack-cli": "^4.10.0"
99
111
  },
100
112
  "files": [
101
113
  "dist",
package/src/AeSdk.ts ADDED
@@ -0,0 +1,68 @@
1
+ import AeSdkBase, { Account } from './AeSdkBase';
2
+ import AccountBase from './account/Base';
3
+ import { decode, Encoded } from './utils/encoder';
4
+ import { UnavailableAccountError } from './utils/errors';
5
+
6
+ export default class AeSdk extends AeSdkBase {
7
+ accounts: { [key: Encoded.AccountAddress]: AccountBase } = {};
8
+
9
+ selectedAddress?: Encoded.AccountAddress;
10
+
11
+ _resolveAccount(
12
+ account: Account | Encoded.AccountAddress = this.selectedAddress,
13
+ ): AccountBase {
14
+ if (typeof account === 'string') {
15
+ const address = account as Encoded.AccountAddress;
16
+ decode(address);
17
+ if (this.accounts[address] == null) throw new UnavailableAccountError(account);
18
+ account = this.accounts[address];
19
+ }
20
+ return super._resolveAccount(account);
21
+ }
22
+
23
+ /**
24
+ * Get accounts addresses
25
+ * @example addresses()
26
+ */
27
+ addresses(): Encoded.AccountAddress[] {
28
+ return Object.keys(this.accounts) as Encoded.AccountAddress[];
29
+ }
30
+
31
+ /**
32
+ * Add specific account
33
+ * @param account - Account instance
34
+ * @param options - Options
35
+ * @param options.select - Select account
36
+ * @example addAccount(account)
37
+ */
38
+ async addAccount(account: AccountBase, { select }: { select?: boolean } = {}): Promise<void> {
39
+ const address = await account.address();
40
+ this.accounts[address] = account;
41
+ if (select === true) this.selectAccount(address);
42
+ }
43
+
44
+ /**
45
+ * Remove specific account
46
+ * @param address - Address of account to remove
47
+ * @example removeAccount(address)
48
+ */
49
+ removeAccount(address: Encoded.AccountAddress): void {
50
+ if (this.accounts[address] == null) {
51
+ console.warn(`removeAccount: Account for ${address} not available`);
52
+ return;
53
+ }
54
+ delete this.accounts[address]; // eslint-disable-line @typescript-eslint/no-dynamic-delete
55
+ if (this.selectedAddress === address) delete this.selectedAddress;
56
+ }
57
+
58
+ /**
59
+ * Select specific account
60
+ * @param address - Address of account to select
61
+ * @example selectAccount('ak_xxxxxxxx')
62
+ */
63
+ selectAccount(address: Encoded.AccountAddress): void {
64
+ decode(address);
65
+ if (this.accounts[address] == null) throw new UnavailableAccountError(address);
66
+ this.selectedAddress = address;
67
+ }
68
+ }
@@ -0,0 +1,176 @@
1
+ import AeSdkBase, { Account } from './AeSdkBase';
2
+ import AccountBase from './account/Base';
3
+ import AccountRpc from './account/Rpc';
4
+ import { decode, Encoded } from './utils/encoder';
5
+ import {
6
+ Accounts, RPC_VERSION, WalletInfo, Network, WalletApi, AeppApi,
7
+ } from './aepp-wallet-communication/rpc/types';
8
+ import RpcClient from './aepp-wallet-communication/rpc/RpcClient';
9
+ import { METHODS, SUBSCRIPTION_TYPES } from './aepp-wallet-communication/schema';
10
+ import {
11
+ AlreadyConnectedError,
12
+ NoWalletConnectedError,
13
+ UnsubscribedAccountError,
14
+ UnAuthorizedAccountError,
15
+ RpcConnectionError,
16
+ } from './utils/errors';
17
+ import Node from './Node';
18
+ import BrowserConnection from './aepp-wallet-communication/connection/Browser';
19
+
20
+ /**
21
+ * RPC handler for AEPP side
22
+ * Contain functionality for wallet interaction and connect it to sdk
23
+ * @category aepp wallet communication
24
+ */
25
+ export default class AeSdkAepp extends AeSdkBase {
26
+ name: string;
27
+
28
+ onAddressChange: (a: Accounts) => void;
29
+
30
+ onDisconnect: (p: any) => void;
31
+
32
+ onNetworkChange: (a: Network) => void;
33
+
34
+ rpcClient?: RpcClient<WalletApi, AeppApi>;
35
+
36
+ _accounts?: Accounts;
37
+
38
+ /**
39
+ * @param options - Options
40
+ * @param options.name - Aepp name
41
+ * @param options.onAddressChange - Call-back function for update address event
42
+ * @param options.onDisconnect - Call-back function for disconnect event
43
+ * @param options.onNetworkChange - Call-back function for update network event
44
+ */
45
+ constructor({
46
+ name,
47
+ onAddressChange = () => {},
48
+ onDisconnect = () => {},
49
+ onNetworkChange = () => {},
50
+ ...other
51
+ }: {
52
+ name: string;
53
+ onAddressChange: (a: Accounts) => void;
54
+ onDisconnect: (p: any) => void;
55
+ onNetworkChange: (a: Network) => void;
56
+ } & ConstructorParameters<typeof AeSdkBase>[0]) {
57
+ super(other);
58
+ this.onAddressChange = onAddressChange;
59
+ this.onDisconnect = onDisconnect;
60
+ this.onNetworkChange = onNetworkChange;
61
+ this.name = name;
62
+ }
63
+
64
+ _resolveAccount(account: Account = this.addresses()[0]): AccountBase {
65
+ if (typeof account === 'string') {
66
+ const address = account as Encoded.AccountAddress;
67
+ decode(address);
68
+ if (!this.addresses().includes(address)) throw new UnAuthorizedAccountError(address);
69
+ account = new AccountRpc({ rpcClient: this.rpcClient, address });
70
+ }
71
+ if (account == null) this._ensureAccountAccess();
72
+ return super._resolveAccount(account);
73
+ }
74
+
75
+ addresses(): Encoded.AccountAddress[] {
76
+ if (this._accounts == null) return [];
77
+ const current = Object.keys(this._accounts.current)[0];
78
+ return [
79
+ ...current != null ? [current] : [], ...Object.keys(this._accounts.connected),
80
+ ] as Encoded.AccountAddress[];
81
+ }
82
+
83
+ /**
84
+ * Connect to wallet
85
+ * @param connection - Wallet connection object
86
+ * @param options - Options
87
+ * @param options.connectNode - Request wallet to bind node
88
+ * @param options.name - Node name
89
+ * @param options.select - Select this node as current
90
+ */
91
+ async connectToWallet(
92
+ connection: BrowserConnection,
93
+ { connectNode = false, name = 'wallet-node', select = false }:
94
+ { connectNode?: boolean; name?: string; select?: boolean } = {},
95
+ ): Promise<WalletInfo> {
96
+ if (this.rpcClient != null) throw new AlreadyConnectedError('You are already connected to wallet');
97
+ let disconnectParams: any;
98
+ const client = new RpcClient<WalletApi, AeppApi>(
99
+ connection,
100
+ () => {
101
+ delete this.rpcClient;
102
+ delete this._accounts;
103
+ this.onDisconnect(disconnectParams);
104
+ },
105
+ {
106
+ [METHODS.updateAddress]: (params) => {
107
+ this._accounts = params;
108
+ this.onAddressChange(params);
109
+ },
110
+ [METHODS.updateNetwork]: (params) => {
111
+ const { node } = params;
112
+ if (node != null) this.addNode(node.name, new Node(node.url), true);
113
+ this.onNetworkChange(params);
114
+ },
115
+ [METHODS.closeConnection]: (params) => {
116
+ disconnectParams = params;
117
+ client.connection.disconnect();
118
+ },
119
+ [METHODS.readyToConnect]: () => {},
120
+ },
121
+ );
122
+ const { node, ...walletInfo } = await client
123
+ .request(METHODS.connect, { name: this.name, version: RPC_VERSION, connectNode });
124
+ if (connectNode) {
125
+ if (node == null) throw new RpcConnectionError('Missing URLs of the Node');
126
+ this.addNode(name, new Node(node.url), select);
127
+ }
128
+ this.rpcClient = client;
129
+ return walletInfo;
130
+ }
131
+
132
+ /**
133
+ * Disconnect from wallet
134
+ */
135
+ disconnectWallet(): void {
136
+ this._ensureConnected();
137
+ this.rpcClient.notify(METHODS.closeConnection, { reason: 'bye' });
138
+ this.rpcClient.connection.disconnect();
139
+ }
140
+
141
+ /**
142
+ * Ask addresses from wallet
143
+ * @returns Addresses from wallet
144
+ */
145
+ async askAddresses(): Promise<Encoded.AccountAddress[]> {
146
+ this._ensureAccountAccess();
147
+ return this.rpcClient.request(METHODS.address, undefined);
148
+ }
149
+
150
+ /**
151
+ * Subscribe for addresses from wallet
152
+ * @param type - Subscription type
153
+ * @param value - Should be one of 'current' (the selected account), 'connected' (all)
154
+ * @returns Accounts from wallet
155
+ */
156
+ async subscribeAddress(
157
+ type: SUBSCRIPTION_TYPES,
158
+ value: 'current' | 'connected',
159
+ ): Promise<ReturnType<WalletApi[METHODS.subscribeAddress]>> {
160
+ this._ensureConnected();
161
+ const result = await this.rpcClient.request(METHODS.subscribeAddress, { type, value });
162
+ this._accounts = result.address;
163
+ return result;
164
+ }
165
+
166
+ _ensureConnected(): asserts this is AeSdkAepp & { rpcClient: NonNullable<AeSdkAepp['rpcClient']> } {
167
+ if (this.rpcClient != null) return;
168
+ throw new NoWalletConnectedError('You are not connected to Wallet');
169
+ }
170
+
171
+ _ensureAccountAccess(): asserts this is AeSdkAepp & { rpcClient: NonNullable<AeSdkAepp['rpcClient']> } {
172
+ this._ensureConnected();
173
+ if (this.addresses().length !== 0) return;
174
+ throw new UnsubscribedAccountError();
175
+ }
176
+ }