@aeternity/aepp-sdk 11.0.1 → 12.0.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 (376) 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 +12 -19
  4. package/dist/aepp-sdk.browser-script.js.map +1 -1
  5. package/dist/aepp-sdk.browser.js +1 -1
  6. package/dist/aepp-sdk.browser.js.map +1 -1
  7. package/dist/aepp-sdk.js +1 -1
  8. package/dist/aepp-sdk.js.map +1 -1
  9. package/es/AeSdk.d.ts +37 -0
  10. package/es/AeSdk.mjs +81 -0
  11. package/es/AeSdk.mjs.map +1 -0
  12. package/es/AeSdkAepp.d.ts +69 -0
  13. package/es/AeSdkAepp.mjs +175 -0
  14. package/es/AeSdkAepp.mjs.map +1 -0
  15. package/es/AeSdkBase.d.ts +212 -0
  16. package/es/AeSdkBase.mjs +310 -0
  17. package/es/AeSdkBase.mjs.map +1 -0
  18. package/es/AeSdkWallet.d.ts +103 -0
  19. package/es/AeSdkWallet.mjs +322 -0
  20. package/es/AeSdkWallet.mjs.map +1 -0
  21. package/es/Node.d.ts +44 -0
  22. package/es/Node.mjs +141 -0
  23. package/es/Node.mjs.map +1 -0
  24. package/es/account/Base.d.ts +65 -0
  25. package/es/account/Base.mjs +123 -0
  26. package/es/account/Base.mjs.map +1 -0
  27. package/es/account/Memory.d.ts +25 -0
  28. package/es/account/Memory.mjs +81 -0
  29. package/es/account/Memory.mjs.map +1 -0
  30. package/es/account/Rpc.d.ts +27 -0
  31. package/es/account/Rpc.mjs +79 -0
  32. package/es/account/Rpc.mjs.map +1 -0
  33. package/es/aens.d.ts +209 -0
  34. package/es/aens.mjs +332 -0
  35. package/es/aens.mjs.map +1 -0
  36. package/es/aepp-wallet-communication/connection/Browser.d.ts +32 -0
  37. package/es/aepp-wallet-communication/connection/Browser.mjs +70 -0
  38. package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -0
  39. package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +17 -0
  40. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +57 -0
  41. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -0
  42. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +35 -0
  43. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +142 -0
  44. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -0
  45. package/es/aepp-wallet-communication/connection-proxy.d.ts +10 -0
  46. package/{src/utils/crypto-ts.ts → es/aepp-wallet-communication/connection-proxy.mjs} +15 -11
  47. package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -0
  48. package/es/aepp-wallet-communication/rpc/RpcClient.d.ts +33 -0
  49. package/es/aepp-wallet-communication/rpc/RpcClient.mjs +169 -0
  50. package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -0
  51. package/es/aepp-wallet-communication/rpc/types.d.ts +77 -0
  52. package/es/aepp-wallet-communication/rpc/types.mjs +3 -0
  53. package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -0
  54. package/es/aepp-wallet-communication/schema.d.ts +90 -46
  55. package/es/aepp-wallet-communication/schema.mjs +214 -0
  56. package/es/aepp-wallet-communication/schema.mjs.map +1 -0
  57. package/es/aepp-wallet-communication/wallet-detector.d.ts +24 -0
  58. package/es/aepp-wallet-communication/wallet-detector.mjs +63 -0
  59. package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -0
  60. package/es/apis/compiler/compiler.d.ts +92 -0
  61. package/es/apis/compiler/compiler.mjs +576 -0
  62. package/es/apis/compiler/compiler.mjs.map +1 -0
  63. package/es/apis/compiler/index.d.ts +2 -0
  64. package/es/apis/compiler/index.mjs +3 -0
  65. package/es/apis/compiler/index.mjs.map +1 -0
  66. package/es/apis/compiler/models/index.d.ts +248 -0
  67. package/es/apis/compiler/models/index.mjs +48 -0
  68. package/es/apis/compiler/models/index.mjs.map +1 -0
  69. package/es/apis/compiler/models/mappers.d.ts +23 -0
  70. package/es/apis/compiler/models/mappers.mjs +585 -0
  71. package/es/apis/compiler/models/mappers.mjs.map +1 -0
  72. package/es/apis/compiler/models/parameters.d.ts +13 -0
  73. package/es/apis/compiler/models/parameters.mjs +71 -0
  74. package/es/apis/compiler/models/parameters.mjs.map +1 -0
  75. package/es/apis/node/index.d.ts +2 -0
  76. package/es/apis/node/index.mjs +3 -0
  77. package/es/apis/node/index.mjs.map +1 -0
  78. package/es/apis/node/models/index.d.ts +1061 -0
  79. package/es/apis/node/models/index.mjs +2 -0
  80. package/es/apis/node/models/index.mjs.map +1 -0
  81. package/es/apis/node/models/mappers.d.ts +95 -0
  82. package/es/apis/node/models/mappers.mjs +4164 -0
  83. package/es/apis/node/models/mappers.mjs.map +1 -0
  84. package/es/apis/node/models/parameters.d.ts +17 -0
  85. package/es/apis/node/models/parameters.mjs +165 -0
  86. package/es/apis/node/models/parameters.mjs.map +1 -0
  87. package/es/apis/node/node.d.ts +215 -0
  88. package/es/apis/node/node.mjs +1165 -0
  89. package/es/apis/node/node.mjs.map +1 -0
  90. package/es/chain.d.ts +220 -0
  91. package/es/chain.mjs +524 -0
  92. package/es/chain.mjs.map +1 -0
  93. package/es/channel/handlers.d.ts +34 -0
  94. package/es/channel/handlers.mjs +147 -112
  95. package/es/channel/handlers.mjs.map +1 -1
  96. package/es/channel/index.d.ts +634 -0
  97. package/es/channel/index.mjs +898 -900
  98. package/es/channel/index.mjs.map +1 -1
  99. package/es/channel/internal.d.ts +100 -0
  100. package/es/channel/internal.mjs +97 -51
  101. package/es/channel/internal.mjs.map +1 -1
  102. package/es/contract/Compiler.d.ts +17 -0
  103. package/es/contract/Compiler.mjs +67 -0
  104. package/es/contract/Compiler.mjs.map +1 -0
  105. package/es/contract/aci.d.ts +125 -0
  106. package/es/contract/aci.mjs +199 -180
  107. package/es/contract/aci.mjs.map +1 -1
  108. package/es/contract/ga.d.ts +68 -0
  109. package/es/contract/ga.mjs +190 -0
  110. package/es/contract/ga.mjs.map +1 -0
  111. package/es/contract/methods.d.ts +68 -0
  112. package/es/contract/methods.mjs +101 -0
  113. package/es/contract/methods.mjs.map +1 -0
  114. package/es/index.d.ts +32 -0
  115. package/es/index.mjs +32 -40
  116. package/es/index.mjs.map +1 -1
  117. package/es/oracle.d.ts +154 -0
  118. package/es/oracle.mjs +288 -0
  119. package/es/oracle.mjs.map +1 -0
  120. package/es/spend.d.ts +61 -0
  121. package/es/spend.mjs +122 -0
  122. package/es/spend.mjs.map +1 -0
  123. package/es/tx/builder/constants.d.ts +41 -0
  124. package/es/tx/builder/constants.mjs +11 -19
  125. package/es/tx/builder/constants.mjs.map +1 -1
  126. package/es/tx/builder/field-types.d.ts +62 -0
  127. package/es/tx/builder/field-types.mjs +62 -10
  128. package/es/tx/builder/field-types.mjs.map +1 -1
  129. package/es/tx/builder/helpers.d.ts +131 -0
  130. package/es/tx/builder/helpers.mjs +71 -169
  131. package/es/tx/builder/helpers.mjs.map +1 -1
  132. package/es/tx/builder/index.d.ts +75 -0
  133. package/es/tx/builder/index.mjs +141 -323
  134. package/es/tx/builder/index.mjs.map +1 -1
  135. package/es/tx/builder/schema.d.ts +350 -0
  136. package/es/tx/builder/schema.mjs +173 -510
  137. package/es/tx/builder/schema.mjs.map +1 -1
  138. package/es/tx/index.d.ts +63 -0
  139. package/es/tx/index.mjs +171 -265
  140. package/es/tx/index.mjs.map +1 -1
  141. package/es/tx/min-fee.d.ts +20 -0
  142. package/es/tx/min-fee.mjs +148 -0
  143. package/es/tx/min-fee.mjs.map +1 -0
  144. package/es/tx/validator.d.ts +19 -0
  145. package/es/tx/validator.mjs +64 -71
  146. package/es/tx/validator.mjs.map +1 -1
  147. package/es/typings/@aeternity__argon2-browser/index.d.mjs +2 -0
  148. package/es/typings/@aeternity__argon2-browser/index.d.mjs.map +1 -0
  149. package/es/typings/@aeternity__uuid/index.d.mjs +2 -0
  150. package/es/typings/@aeternity__uuid/index.d.mjs.map +1 -0
  151. package/es/typings/bip32-path/index.d.mjs +2 -0
  152. package/es/typings/bip32-path/index.d.mjs.map +1 -0
  153. package/es/typings/blakejs/index.d.mjs.map +1 -1
  154. package/es/typings/tweetnacl-auth/index.d.mjs +2 -0
  155. package/es/typings/tweetnacl-auth/index.d.mjs.map +1 -0
  156. package/es/utils/amount-formatter.d.ts +42 -0
  157. package/es/utils/amount-formatter.mjs +28 -41
  158. package/es/utils/amount-formatter.mjs.map +1 -1
  159. package/es/utils/autorest.d.ts +6 -0
  160. package/es/utils/autorest.mjs +97 -0
  161. package/es/utils/autorest.mjs.map +1 -0
  162. package/es/utils/bignumber.d.ts +13 -0
  163. package/es/utils/bignumber.mjs +10 -8
  164. package/es/utils/bignumber.mjs.map +1 -1
  165. package/es/{bytes.d.ts → utils/bytes.d.ts} +10 -13
  166. package/es/utils/bytes.mjs +10 -14
  167. package/es/utils/bytes.mjs.map +1 -1
  168. package/es/utils/crypto.d.ts +103 -0
  169. package/es/utils/crypto.mjs +60 -68
  170. package/es/utils/crypto.mjs.map +1 -1
  171. package/es/utils/encoder.d.ts +26 -0
  172. package/es/utils/encoder.mjs +47 -51
  173. package/es/utils/encoder.mjs.map +1 -1
  174. package/es/{errors.d.ts → utils/errors.d.ts} +254 -57
  175. package/es/utils/errors.mjs +318 -125
  176. package/es/utils/errors.mjs.map +1 -1
  177. package/es/utils/hd-wallet.d.ts +34 -0
  178. package/es/utils/hd-wallet.mjs +27 -16
  179. package/es/utils/hd-wallet.mjs.map +1 -1
  180. package/es/utils/json-big.d.ts +5 -0
  181. package/es/utils/json-big.mjs +10 -14
  182. package/es/utils/json-big.mjs.map +1 -1
  183. package/es/utils/keystore.d.ts +51 -0
  184. package/es/utils/keystore.mjs +98 -193
  185. package/es/utils/keystore.mjs.map +1 -1
  186. package/es/{mptree.d.ts → utils/mptree.d.ts} +5 -8
  187. package/es/utils/mptree.mjs +13 -14
  188. package/es/utils/mptree.mjs.map +1 -1
  189. package/es/utils/other.d.ts +14 -0
  190. package/es/utils/other.mjs +21 -36
  191. package/es/utils/other.mjs.map +1 -1
  192. package/es/{semver-satisfies.d.ts → utils/semver-satisfies.d.ts} +0 -0
  193. package/es/utils/semver-satisfies.mjs.map +1 -1
  194. package/es/utils/string.d.ts +24 -0
  195. package/es/utils/string.mjs +8 -10
  196. package/es/utils/string.mjs.map +1 -1
  197. package/package.json +49 -39
  198. package/src/AeSdk.ts +65 -0
  199. package/src/AeSdkAepp.ts +167 -0
  200. package/src/AeSdkBase.ts +320 -0
  201. package/src/AeSdkWallet.ts +332 -0
  202. package/src/Node.ts +167 -0
  203. package/src/account/Base.ts +114 -0
  204. package/src/account/Memory.ts +83 -0
  205. package/src/account/Rpc.ts +67 -0
  206. package/src/aens.ts +391 -0
  207. package/src/aepp-wallet-communication/connection/Browser.ts +68 -0
  208. package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +58 -0
  209. package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +111 -0
  210. package/{es/utils/crypto-ts.mjs → src/aepp-wallet-communication/connection-proxy.ts} +16 -17
  211. package/src/aepp-wallet-communication/rpc/RpcClient.ts +137 -0
  212. package/src/aepp-wallet-communication/rpc/types.ts +66 -0
  213. package/src/aepp-wallet-communication/schema.ts +181 -0
  214. package/src/aepp-wallet-communication/wallet-detector.ts +71 -0
  215. package/src/apis/compiler/code-model-v4.yaml +2649 -0
  216. package/src/apis/compiler/compiler.ts +585 -0
  217. package/src/apis/compiler/index.ts +2 -0
  218. package/src/apis/compiler/models/index.ts +301 -0
  219. package/src/apis/compiler/models/mappers.ts +583 -0
  220. package/src/apis/compiler/models/parameters.ts +93 -0
  221. package/src/apis/node/code-model-v4.yaml +10046 -0
  222. package/src/apis/node/index.ts +2 -0
  223. package/src/apis/node/models/index.ts +1253 -0
  224. package/src/apis/node/models/mappers.ts +4278 -0
  225. package/src/apis/node/models/parameters.ts +188 -0
  226. package/src/apis/node/node.ts +1299 -0
  227. package/src/chain.ts +444 -0
  228. package/src/channel/{handlers.js → handlers.ts} +220 -128
  229. package/src/channel/index.ts +991 -0
  230. package/src/channel/internal.ts +345 -0
  231. package/src/contract/Compiler.ts +66 -0
  232. package/src/contract/aci.ts +529 -0
  233. package/src/contract/ga.ts +178 -0
  234. package/src/contract/methods.ts +118 -0
  235. package/src/index.ts +51 -0
  236. package/src/oracle.ts +342 -0
  237. package/src/spend.ts +152 -0
  238. package/src/tx/builder/{constants.js → constants.ts} +12 -16
  239. package/src/tx/builder/field-types.ts +111 -0
  240. package/src/tx/builder/helpers.ts +253 -0
  241. package/src/tx/builder/index.ts +394 -0
  242. package/src/tx/builder/schema.ts +771 -0
  243. package/src/tx/index.ts +199 -0
  244. package/src/tx/min-fee.ts +136 -0
  245. package/src/tx/validator.ts +226 -0
  246. package/src/typings/@aeternity__argon2-browser/index.d.ts +3 -0
  247. package/src/typings/@aeternity__uuid/index.d.ts +3 -0
  248. package/src/typings/bip32-path/index.d.ts +33 -0
  249. package/src/typings/tweetnacl-auth/index.d.ts +14 -0
  250. package/src/utils/amount-formatter.ts +29 -42
  251. package/src/utils/autorest.ts +90 -0
  252. package/src/utils/bignumber.ts +9 -11
  253. package/src/utils/bytes.ts +12 -14
  254. package/src/utils/crypto.ts +217 -0
  255. package/src/utils/encoder.ts +52 -55
  256. package/src/utils/errors.ts +268 -134
  257. package/src/utils/hd-wallet.ts +134 -0
  258. package/src/utils/json-big.ts +26 -0
  259. package/src/utils/keystore.ts +179 -0
  260. package/src/utils/mptree.ts +14 -14
  261. package/src/utils/other.ts +28 -43
  262. package/src/utils/string.ts +8 -10
  263. package/es/account/base.mjs +0 -179
  264. package/es/account/base.mjs.map +0 -1
  265. package/es/account/memory.mjs +0 -99
  266. package/es/account/memory.mjs.map +0 -1
  267. package/es/account/multiple.mjs +0 -179
  268. package/es/account/multiple.mjs.map +0 -1
  269. package/es/ae/aens.mjs +0 -404
  270. package/es/ae/aens.mjs.map +0 -1
  271. package/es/ae/aepp.mjs +0 -45
  272. package/es/ae/aepp.mjs.map +0 -1
  273. package/es/ae/contract.mjs +0 -159
  274. package/es/ae/contract.mjs.map +0 -1
  275. package/es/ae/index.mjs +0 -207
  276. package/es/ae/index.mjs.map +0 -1
  277. package/es/ae/oracle.mjs +0 -339
  278. package/es/ae/oracle.mjs.map +0 -1
  279. package/es/ae/universal.mjs +0 -45
  280. package/es/ae/universal.mjs.map +0 -1
  281. package/es/ae/wallet.mjs +0 -50
  282. package/es/ae/wallet.mjs.map +0 -1
  283. package/es/amount-formatter.d.ts +0 -58
  284. package/es/bignumber.d.ts +0 -18
  285. package/es/chain/index.mjs +0 -272
  286. package/es/chain/index.mjs.map +0 -1
  287. package/es/chain/node.mjs +0 -442
  288. package/es/chain/node.mjs.map +0 -1
  289. package/es/contract/compiler.mjs +0 -115
  290. package/es/contract/compiler.mjs.map +0 -1
  291. package/es/contract/ga/helpers.mjs +0 -30
  292. package/es/contract/ga/helpers.mjs.map +0 -1
  293. package/es/contract/ga/index.mjs +0 -178
  294. package/es/contract/ga/index.mjs.map +0 -1
  295. package/es/crypto-ts.d.ts +0 -9
  296. package/es/encoder.d.ts +0 -26
  297. package/es/node-pool/index.mjs +0 -188
  298. package/es/node-pool/index.mjs.map +0 -1
  299. package/es/node.mjs +0 -133
  300. package/es/node.mjs.map +0 -1
  301. package/es/other.d.ts +0 -31
  302. package/es/string.d.ts +0 -26
  303. package/es/tx/tx-object.mjs +0 -283
  304. package/es/tx/tx-object.mjs.map +0 -1
  305. package/es/tx/tx.mjs +0 -938
  306. package/es/tx/tx.mjs.map +0 -1
  307. package/es/utils/aepp-wallet-communication/connection/browser-runtime.mjs +0 -132
  308. package/es/utils/aepp-wallet-communication/connection/browser-runtime.mjs.map +0 -1
  309. package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs +0 -183
  310. package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs.map +0 -1
  311. package/es/utils/aepp-wallet-communication/connection/index.mjs +0 -87
  312. package/es/utils/aepp-wallet-communication/connection/index.mjs.map +0 -1
  313. package/es/utils/aepp-wallet-communication/content-script-bridge.mjs +0 -98
  314. package/es/utils/aepp-wallet-communication/content-script-bridge.mjs.map +0 -1
  315. package/es/utils/aepp-wallet-communication/helpers.mjs +0 -92
  316. package/es/utils/aepp-wallet-communication/helpers.mjs.map +0 -1
  317. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs +0 -375
  318. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs.map +0 -1
  319. package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs +0 -275
  320. package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs.map +0 -1
  321. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs +0 -541
  322. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs.map +0 -1
  323. package/es/utils/aepp-wallet-communication/schema.mjs +0 -102
  324. package/es/utils/aepp-wallet-communication/schema.mjs.map +0 -1
  325. package/es/utils/aepp-wallet-communication/wallet-detector.mjs +0 -110
  326. package/es/utils/aepp-wallet-communication/wallet-detector.mjs.map +0 -1
  327. package/es/utils/async-init.mjs +0 -64
  328. package/es/utils/async-init.mjs.map +0 -1
  329. package/es/utils/crypto-ts.mjs.map +0 -1
  330. package/es/utils/swagger.mjs +0 -164
  331. package/es/utils/swagger.mjs.map +0 -1
  332. package/src/account/base.js +0 -153
  333. package/src/account/memory.js +0 -83
  334. package/src/account/multiple.js +0 -162
  335. package/src/ae/aens.js +0 -361
  336. package/src/ae/aepp.js +0 -45
  337. package/src/ae/contract.js +0 -148
  338. package/src/ae/index.js +0 -168
  339. package/src/ae/oracle.js +0 -311
  340. package/src/ae/universal.js +0 -47
  341. package/src/ae/wallet.js +0 -50
  342. package/src/chain/index.js +0 -269
  343. package/src/chain/node.js +0 -320
  344. package/src/channel/index.js +0 -903
  345. package/src/channel/internal.js +0 -236
  346. package/src/contract/aci.js +0 -376
  347. package/src/contract/compiler.js +0 -100
  348. package/src/contract/ga/helpers.js +0 -19
  349. package/src/contract/ga/index.js +0 -150
  350. package/src/index.js +0 -89
  351. package/src/node-pool/index.js +0 -172
  352. package/src/node.js +0 -116
  353. package/src/tx/builder/field-types.js +0 -61
  354. package/src/tx/builder/helpers.js +0 -334
  355. package/src/tx/builder/index.js +0 -465
  356. package/src/tx/builder/schema.js +0 -1100
  357. package/src/tx/index.js +0 -301
  358. package/src/tx/tx-object.js +0 -187
  359. package/src/tx/tx.js +0 -631
  360. package/src/tx/validator.js +0 -181
  361. package/src/utils/aepp-wallet-communication/connection/browser-runtime.js +0 -119
  362. package/src/utils/aepp-wallet-communication/connection/browser-window-message.js +0 -165
  363. package/src/utils/aepp-wallet-communication/connection/index.js +0 -85
  364. package/src/utils/aepp-wallet-communication/content-script-bridge.js +0 -86
  365. package/src/utils/aepp-wallet-communication/helpers.js +0 -60
  366. package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +0 -294
  367. package/src/utils/aepp-wallet-communication/rpc/rpc-client.js +0 -232
  368. package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +0 -401
  369. package/src/utils/aepp-wallet-communication/schema.ts +0 -80
  370. package/src/utils/aepp-wallet-communication/wallet-detector.js +0 -92
  371. package/src/utils/async-init.js +0 -45
  372. package/src/utils/crypto.js +0 -219
  373. package/src/utils/hd-wallet.js +0 -100
  374. package/src/utils/json-big.js +0 -26
  375. package/src/utils/keystore.js +0 -219
  376. package/src/utils/swagger.js +0 -156
package/es/AeSdk.d.ts ADDED
@@ -0,0 +1,37 @@
1
+ import AeSdkBase, { Account } from './AeSdkBase';
2
+ import AccountBase from './account/Base';
3
+ import { EncodedData } from './utils/encoder';
4
+ export default class AeSdk extends AeSdkBase {
5
+ accounts: {
6
+ [key: EncodedData<'ak'>]: AccountBase;
7
+ };
8
+ selectedAddress?: EncodedData<'ak'>;
9
+ _resolveAccount(account?: Account | EncodedData<'ak'>): AccountBase;
10
+ /**
11
+ * Get accounts addresses
12
+ * @example addresses()
13
+ */
14
+ addresses(): Array<EncodedData<'ak'>>;
15
+ /**
16
+ * Add specific account
17
+ * @param account - Account instance
18
+ * @param options - Options
19
+ * @param options.select - Select account
20
+ * @example addAccount(account)
21
+ */
22
+ addAccount(account: AccountBase, { select }?: {
23
+ select?: boolean;
24
+ }): Promise<void>;
25
+ /**
26
+ * Remove specific account
27
+ * @param address - Address of account to remove
28
+ * @example removeAccount(address)
29
+ */
30
+ removeAccount(address: EncodedData<'ak'>): void;
31
+ /**
32
+ * Select specific account
33
+ * @param address - Address of account to select
34
+ * @example selectAccount('ak_xxxxxxxx')
35
+ */
36
+ selectAccount(address: EncodedData<'ak'>): void;
37
+ }
package/es/AeSdk.mjs ADDED
@@ -0,0 +1,81 @@
1
+ import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
2
+ import AeSdkBase from "./AeSdkBase.mjs";
3
+ import { decode } from "./utils/encoder.mjs";
4
+ import { UnavailableAccountError } from "./utils/errors.mjs";
5
+ export default class AeSdk extends AeSdkBase {
6
+ constructor() {
7
+ super(...arguments);
8
+
9
+ _defineProperty(this, "accounts", {});
10
+ }
11
+
12
+ _resolveAccount() {
13
+ let account = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.selectedAddress;
14
+
15
+ if (typeof account === 'string') {
16
+ const address = account;
17
+ decode(address);
18
+ if (this.accounts[address] == null) throw new UnavailableAccountError(account);
19
+ account = this.accounts[address];
20
+ }
21
+
22
+ return super._resolveAccount(account);
23
+ }
24
+ /**
25
+ * Get accounts addresses
26
+ * @example addresses()
27
+ */
28
+
29
+
30
+ addresses() {
31
+ return Object.keys(this.accounts);
32
+ }
33
+ /**
34
+ * Add specific account
35
+ * @param account - Account instance
36
+ * @param options - Options
37
+ * @param options.select - Select account
38
+ * @example addAccount(account)
39
+ */
40
+
41
+
42
+ async addAccount(account) {
43
+ let {
44
+ select
45
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
46
+ const address = await account.address();
47
+ this.accounts[address] = account;
48
+ if (select === true) this.selectAccount(address);
49
+ }
50
+ /**
51
+ * Remove specific account
52
+ * @param address - Address of account to remove
53
+ * @example removeAccount(address)
54
+ */
55
+
56
+
57
+ removeAccount(address) {
58
+ if (this.accounts[address] == null) {
59
+ console.warn(`removeAccount: Account for ${address} not available`);
60
+ return;
61
+ }
62
+
63
+ delete this.accounts[address]; // eslint-disable-line @typescript-eslint/no-dynamic-delete
64
+
65
+ if (this.selectedAddress === address) delete this.selectedAddress;
66
+ }
67
+ /**
68
+ * Select specific account
69
+ * @param address - Address of account to select
70
+ * @example selectAccount('ak_xxxxxxxx')
71
+ */
72
+
73
+
74
+ selectAccount(address) {
75
+ decode(address);
76
+ if (this.accounts[address] == null) throw new UnavailableAccountError(address);
77
+ this.selectedAddress = address;
78
+ }
79
+
80
+ }
81
+ //# sourceMappingURL=AeSdk.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AeSdk.mjs","names":["AeSdkBase","decode","UnavailableAccountError","AeSdk","_resolveAccount","account","selectedAddress","address","accounts","addresses","Object","keys","addAccount","select","selectAccount","removeAccount","console","warn"],"sources":["../src/AeSdk.ts"],"sourcesContent":["import AeSdkBase, { Account } from './AeSdkBase'\nimport AccountBase from './account/Base'\nimport { decode, EncodedData } from './utils/encoder'\nimport { UnavailableAccountError } from './utils/errors'\n\nexport default class AeSdk extends AeSdkBase {\n accounts: { [key: EncodedData<'ak'>]: AccountBase } = {}\n selectedAddress?: EncodedData<'ak'>\n\n _resolveAccount (account: Account | EncodedData<'ak'> = this.selectedAddress): AccountBase {\n if (typeof account === 'string') {\n const address = account as EncodedData<'ak'>\n decode(address)\n if (this.accounts[address] == null) throw new UnavailableAccountError(account)\n account = this.accounts[address]\n }\n return super._resolveAccount(account)\n }\n\n /**\n * Get accounts addresses\n * @example addresses()\n */\n addresses (): Array<EncodedData<'ak'>> {\n return Object.keys(this.accounts) as Array<EncodedData<'ak'>>\n }\n\n /**\n * Add specific account\n * @param account - Account instance\n * @param options - Options\n * @param options.select - Select account\n * @example addAccount(account)\n */\n async addAccount (account: AccountBase, { select }: { select?: boolean } = {}): Promise<void> {\n const address = await account.address()\n this.accounts[address] = account\n if (select === true) this.selectAccount(address)\n }\n\n /**\n * Remove specific account\n * @param address - Address of account to remove\n * @example removeAccount(address)\n */\n removeAccount (address: EncodedData<'ak'>): void {\n if (this.accounts[address] == null) {\n console.warn(`removeAccount: Account for ${address} not available`)\n return\n }\n delete this.accounts[address] // eslint-disable-line @typescript-eslint/no-dynamic-delete\n if (this.selectedAddress === address) delete this.selectedAddress\n }\n\n /**\n * Select specific account\n * @param address - Address of account to select\n * @example selectAccount('ak_xxxxxxxx')\n */\n selectAccount (address: EncodedData<'ak'>): void {\n decode(address)\n if (this.accounts[address] == null) throw new UnavailableAccountError(address)\n this.selectedAddress = address\n }\n}\n"],"mappings":";OAAOA,S;SAEEC,M;SACAC,uB;AAET,eAAe,MAAMC,KAAN,SAAoBH,SAApB,CAA8B;EAAA;IAAA;;IAAA,kCACW,EADX;EAAA;;EAI3CI,eAAe,GAA4E;IAAA,IAA1EC,OAA0E,uEAAnC,KAAKC,eAA8B;;IACzF,IAAI,OAAOD,OAAP,KAAmB,QAAvB,EAAiC;MAC/B,MAAME,OAAO,GAAGF,OAAhB;MACAJ,MAAM,CAACM,OAAD,CAAN;MACA,IAAI,KAAKC,QAAL,CAAcD,OAAd,KAA0B,IAA9B,EAAoC,MAAM,IAAIL,uBAAJ,CAA4BG,OAA5B,CAAN;MACpCA,OAAO,GAAG,KAAKG,QAAL,CAAcD,OAAd,CAAV;IACD;;IACD,OAAO,MAAMH,eAAN,CAAsBC,OAAtB,CAAP;EACD;EAED;AACF;AACA;AACA;;;EACEI,SAAS,GAA8B;IACrC,OAAOC,MAAM,CAACC,IAAP,CAAY,KAAKH,QAAjB,CAAP;EACD;EAED;AACF;AACA;AACA;AACA;AACA;AACA;;;EACkB,MAAVI,UAAU,CAAEP,OAAF,EAA8E;IAAA,IAAtD;MAAEQ;IAAF,CAAsD,uEAAnB,EAAmB;IAC5F,MAAMN,OAAO,GAAG,MAAMF,OAAO,CAACE,OAAR,EAAtB;IACA,KAAKC,QAAL,CAAcD,OAAd,IAAyBF,OAAzB;IACA,IAAIQ,MAAM,KAAK,IAAf,EAAqB,KAAKC,aAAL,CAAmBP,OAAnB;EACtB;EAED;AACF;AACA;AACA;AACA;;;EACEQ,aAAa,CAAER,OAAF,EAAoC;IAC/C,IAAI,KAAKC,QAAL,CAAcD,OAAd,KAA0B,IAA9B,EAAoC;MAClCS,OAAO,CAACC,IAAR,CAAc,8BAA6BV,OAAQ,gBAAnD;MACA;IACD;;IACD,OAAO,KAAKC,QAAL,CAAcD,OAAd,CAAP,CAL+C,CAKjB;;IAC9B,IAAI,KAAKD,eAAL,KAAyBC,OAA7B,EAAsC,OAAO,KAAKD,eAAZ;EACvC;EAED;AACF;AACA;AACA;AACA;;;EACEQ,aAAa,CAAEP,OAAF,EAAoC;IAC/CN,MAAM,CAACM,OAAD,CAAN;IACA,IAAI,KAAKC,QAAL,CAAcD,OAAd,KAA0B,IAA9B,EAAoC,MAAM,IAAIL,uBAAJ,CAA4BK,OAA5B,CAAN;IACpC,KAAKD,eAAL,GAAuBC,OAAvB;EACD;;AA1D0C"}
@@ -0,0 +1,69 @@
1
+ import AeSdkBase, { Account } from './AeSdkBase';
2
+ import AccountBase from './account/Base';
3
+ import { EncodedData } from './utils/encoder';
4
+ import { Accounts, WalletInfo, Network, WalletApi, AeppApi } from './aepp-wallet-communication/rpc/types';
5
+ import RpcClient from './aepp-wallet-communication/rpc/RpcClient';
6
+ import { METHODS, SUBSCRIPTION_TYPES } from './aepp-wallet-communication/schema';
7
+ import BrowserConnection from './aepp-wallet-communication/connection/Browser';
8
+ /**
9
+ * RPC handler for AEPP side
10
+ * Contain functionality for wallet interaction and connect it to sdk
11
+ */
12
+ export default class AeSdkAepp extends AeSdkBase {
13
+ name: string;
14
+ onAddressChange: (a: Accounts) => void;
15
+ onDisconnect: (p: any) => void;
16
+ onNetworkChange: (a: Network) => void;
17
+ rpcClient?: RpcClient<WalletApi, AeppApi>;
18
+ _accounts?: Accounts;
19
+ /**
20
+ * @param options - Options
21
+ * @param options.name - Aepp name
22
+ * @param options.onAddressChange - Call-back function for update address event
23
+ * @param options.onDisconnect - Call-back function for disconnect event
24
+ * @param options.onNetworkChange - Call-back function for update network event
25
+ */
26
+ constructor({ name, onAddressChange, onDisconnect, onNetworkChange, ...other }: {
27
+ name: string;
28
+ onAddressChange: (a: Accounts) => void;
29
+ onDisconnect: (p: any) => void;
30
+ onNetworkChange: (a: Network) => void;
31
+ } & ConstructorParameters<typeof AeSdkBase>[0]);
32
+ _resolveAccount(account?: Account): AccountBase;
33
+ addresses(): Array<EncodedData<'ak'>>;
34
+ /**
35
+ * Connect to wallet
36
+ * @param connection - Wallet connection object
37
+ * @param options - Options
38
+ * @param options.connectNode - Request wallet to bind node
39
+ * @param options.name - Node name
40
+ * @param options.select - Select this node as current
41
+ */
42
+ connectToWallet(connection: BrowserConnection, { connectNode, name, select }?: {
43
+ connectNode?: boolean;
44
+ name?: string;
45
+ select?: boolean;
46
+ }): Promise<WalletInfo>;
47
+ /**
48
+ * Disconnect from wallet
49
+ */
50
+ disconnectWallet(): void;
51
+ /**
52
+ * Ask addresses from wallet
53
+ * @returns Addresses from wallet
54
+ */
55
+ askAddresses(): Promise<Array<EncodedData<'ak'>>>;
56
+ /**
57
+ * Subscribe for addresses from wallet
58
+ * @param type - Subscription type
59
+ * @param value - Should be one of 'current' (the selected account), 'connected' (all)
60
+ * @returns Accounts from wallet
61
+ */
62
+ subscribeAddress(type: SUBSCRIPTION_TYPES, value: 'current' | 'connected'): Promise<ReturnType<WalletApi[METHODS.subscribeAddress]>>;
63
+ _ensureConnected(): asserts this is AeSdkAepp & {
64
+ rpcClient: NonNullable<AeSdkAepp['rpcClient']>;
65
+ };
66
+ _ensureAccountAccess(): asserts this is AeSdkAepp & {
67
+ rpcClient: NonNullable<AeSdkAepp['rpcClient']>;
68
+ };
69
+ }
@@ -0,0 +1,175 @@
1
+ import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
2
+ import AeSdkBase from "./AeSdkBase.mjs";
3
+ import AccountRpc from "./account/Rpc.mjs";
4
+ import { decode } from "./utils/encoder.mjs";
5
+ import { RPC_VERSION } from "./aepp-wallet-communication/rpc/types.mjs";
6
+ import RpcClient from "./aepp-wallet-communication/rpc/RpcClient.mjs";
7
+ import { METHODS } from "./aepp-wallet-communication/schema.mjs";
8
+ import { AlreadyConnectedError, NoWalletConnectedError, UnsubscribedAccountError, UnAuthorizedAccountError, RpcConnectionError } from "./utils/errors.mjs";
9
+ import Node from "./Node.mjs";
10
+
11
+ /**
12
+ * RPC handler for AEPP side
13
+ * Contain functionality for wallet interaction and connect it to sdk
14
+ */
15
+ export default class AeSdkAepp extends AeSdkBase {
16
+ /**
17
+ * @param options - Options
18
+ * @param options.name - Aepp name
19
+ * @param options.onAddressChange - Call-back function for update address event
20
+ * @param options.onDisconnect - Call-back function for disconnect event
21
+ * @param options.onNetworkChange - Call-back function for update network event
22
+ */
23
+ constructor(_ref) {
24
+ let {
25
+ name,
26
+ onAddressChange = () => {},
27
+ onDisconnect = () => {},
28
+ onNetworkChange = () => {},
29
+ ...other
30
+ } = _ref;
31
+ super(other);
32
+ this.onAddressChange = onAddressChange;
33
+ this.onDisconnect = onDisconnect;
34
+ this.onNetworkChange = onNetworkChange;
35
+ this.name = name;
36
+ }
37
+
38
+ _resolveAccount() {
39
+ let account = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.addresses()[0];
40
+
41
+ if (typeof account === 'string') {
42
+ var _context;
43
+
44
+ const address = account;
45
+ decode(address);
46
+ if (!_includesInstanceProperty(_context = this.addresses()).call(_context, address)) throw new UnAuthorizedAccountError(address);
47
+ account = new AccountRpc({
48
+ rpcClient: this.rpcClient,
49
+ address
50
+ });
51
+ }
52
+
53
+ if (account == null) this._ensureAccountAccess();
54
+ return super._resolveAccount(account);
55
+ }
56
+
57
+ addresses() {
58
+ if (this._accounts == null) return [];
59
+ const current = Object.keys(this._accounts.current)[0];
60
+ return [...(current != null ? [current] : []), ...Object.keys(this._accounts.connected)];
61
+ }
62
+ /**
63
+ * Connect to wallet
64
+ * @param connection - Wallet connection object
65
+ * @param options - Options
66
+ * @param options.connectNode - Request wallet to bind node
67
+ * @param options.name - Node name
68
+ * @param options.select - Select this node as current
69
+ */
70
+
71
+
72
+ async connectToWallet(connection) {
73
+ let {
74
+ connectNode = false,
75
+ name = 'wallet-node',
76
+ select = false
77
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
78
+ if (this.rpcClient != null) throw new AlreadyConnectedError('You are already connected to wallet');
79
+ let disconnectParams;
80
+ const client = new RpcClient(connection, () => {
81
+ delete this.rpcClient;
82
+ delete this._accounts;
83
+ this.onDisconnect(disconnectParams);
84
+ }, {
85
+ [METHODS.updateAddress]: params => {
86
+ this._accounts = params;
87
+ this.onAddressChange(params);
88
+ },
89
+ [METHODS.updateNetwork]: params => {
90
+ const {
91
+ node
92
+ } = params;
93
+ if (node != null) this.addNode(node.name, new Node(node.url), true);
94
+ this.onNetworkChange(params);
95
+ },
96
+ [METHODS.closeConnection]: params => {
97
+ disconnectParams = params;
98
+ client.connection.disconnect();
99
+ },
100
+ [METHODS.readyToConnect]: () => {}
101
+ });
102
+ const {
103
+ node,
104
+ ...walletInfo
105
+ } = await client.request(METHODS.connect, {
106
+ name: this.name,
107
+ version: RPC_VERSION,
108
+ connectNode
109
+ });
110
+
111
+ if (connectNode) {
112
+ if (node == null) throw new RpcConnectionError('Missing URLs of the Node');
113
+ this.addNode(name, new Node(node.url), select);
114
+ }
115
+
116
+ this.rpcClient = client;
117
+ return walletInfo;
118
+ }
119
+ /**
120
+ * Disconnect from wallet
121
+ */
122
+
123
+
124
+ disconnectWallet() {
125
+ this._ensureConnected();
126
+
127
+ this.rpcClient.notify(METHODS.closeConnection, {
128
+ reason: 'bye'
129
+ });
130
+ this.rpcClient.connection.disconnect();
131
+ }
132
+ /**
133
+ * Ask addresses from wallet
134
+ * @returns Addresses from wallet
135
+ */
136
+
137
+
138
+ async askAddresses() {
139
+ this._ensureAccountAccess();
140
+
141
+ return await this.rpcClient.request(METHODS.address, undefined);
142
+ }
143
+ /**
144
+ * Subscribe for addresses from wallet
145
+ * @param type - Subscription type
146
+ * @param value - Should be one of 'current' (the selected account), 'connected' (all)
147
+ * @returns Accounts from wallet
148
+ */
149
+
150
+
151
+ async subscribeAddress(type, value) {
152
+ this._ensureConnected();
153
+
154
+ const result = await this.rpcClient.request(METHODS.subscribeAddress, {
155
+ type,
156
+ value
157
+ });
158
+ this._accounts = result.address;
159
+ return result;
160
+ }
161
+
162
+ _ensureConnected() {
163
+ if (this.rpcClient != null) return;
164
+ throw new NoWalletConnectedError('You are not connected to Wallet');
165
+ }
166
+
167
+ _ensureAccountAccess() {
168
+ this._ensureConnected();
169
+
170
+ if (this.addresses().length !== 0) return;
171
+ throw new UnsubscribedAccountError();
172
+ }
173
+
174
+ }
175
+ //# sourceMappingURL=AeSdkAepp.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AeSdkAepp.mjs","names":["AeSdkBase","AccountRpc","decode","RPC_VERSION","RpcClient","METHODS","AlreadyConnectedError","NoWalletConnectedError","UnsubscribedAccountError","UnAuthorizedAccountError","RpcConnectionError","Node","AeSdkAepp","constructor","name","onAddressChange","onDisconnect","onNetworkChange","other","_resolveAccount","account","addresses","address","rpcClient","_ensureAccountAccess","_accounts","current","Object","keys","connected","connectToWallet","connection","connectNode","select","disconnectParams","client","updateAddress","params","updateNetwork","node","addNode","url","closeConnection","disconnect","readyToConnect","walletInfo","request","connect","version","disconnectWallet","_ensureConnected","notify","reason","askAddresses","undefined","subscribeAddress","type","value","result","length"],"sources":["../src/AeSdkAepp.ts"],"sourcesContent":["import AeSdkBase, { Account } from './AeSdkBase'\nimport AccountBase from './account/Base'\nimport AccountRpc from './account/Rpc'\nimport { decode, EncodedData } from './utils/encoder'\nimport { Accounts, RPC_VERSION, WalletInfo, Network, WalletApi, AeppApi } from './aepp-wallet-communication/rpc/types'\nimport RpcClient from './aepp-wallet-communication/rpc/RpcClient'\nimport { METHODS, SUBSCRIPTION_TYPES } from './aepp-wallet-communication/schema'\nimport {\n AlreadyConnectedError,\n NoWalletConnectedError,\n UnsubscribedAccountError,\n UnAuthorizedAccountError,\n RpcConnectionError\n} from './utils/errors'\nimport Node from './Node'\nimport BrowserConnection from './aepp-wallet-communication/connection/Browser'\n\n/**\n * RPC handler for AEPP side\n * Contain functionality for wallet interaction and connect it to sdk\n */\nexport default class AeSdkAepp extends AeSdkBase {\n name: string\n onAddressChange: (a: Accounts) => void\n onDisconnect: (p: any) => void\n onNetworkChange: (a: Network) => void\n rpcClient?: RpcClient<WalletApi, AeppApi>\n _accounts?: Accounts\n\n /**\n * @param options - Options\n * @param options.name - Aepp name\n * @param options.onAddressChange - Call-back function for update address event\n * @param options.onDisconnect - Call-back function for disconnect event\n * @param options.onNetworkChange - Call-back function for update network event\n */\n constructor ({\n name,\n onAddressChange = () => {},\n onDisconnect = () => {},\n onNetworkChange = () => {},\n ...other\n }: {\n name: string\n onAddressChange: (a: Accounts) => void\n onDisconnect: (p: any) => void\n onNetworkChange: (a: Network) => void\n } & ConstructorParameters<typeof AeSdkBase>[0]) {\n super(other)\n this.onAddressChange = onAddressChange\n this.onDisconnect = onDisconnect\n this.onNetworkChange = onNetworkChange\n this.name = name\n }\n\n _resolveAccount (account: Account = this.addresses()[0]): AccountBase {\n if (typeof account === 'string') {\n const address = account as EncodedData<'ak'>\n decode(address)\n if (!this.addresses().includes(address)) throw new UnAuthorizedAccountError(address)\n account = new AccountRpc({ rpcClient: this.rpcClient, address })\n }\n if (account == null) this._ensureAccountAccess()\n return super._resolveAccount(account)\n }\n\n addresses (): Array<EncodedData<'ak'>> {\n if (this._accounts == null) return []\n const current = Object.keys(this._accounts.current)[0]\n return [\n ...current != null ? [current] : [], ...Object.keys(this._accounts.connected)\n ] as Array<EncodedData<'ak'>>\n }\n\n /**\n * Connect to wallet\n * @param connection - Wallet connection object\n * @param options - Options\n * @param options.connectNode - Request wallet to bind node\n * @param options.name - Node name\n * @param options.select - Select this node as current\n */\n async connectToWallet (\n connection: BrowserConnection,\n { connectNode = false, name = 'wallet-node', select = false }:\n { connectNode?: boolean, name?: string, select?: boolean } = {}\n ): Promise<WalletInfo> {\n if (this.rpcClient != null) throw new AlreadyConnectedError('You are already connected to wallet')\n let disconnectParams: any\n const client = new RpcClient<WalletApi, AeppApi>(\n connection,\n () => {\n delete this.rpcClient\n delete this._accounts\n this.onDisconnect(disconnectParams)\n }, {\n [METHODS.updateAddress]: (params) => {\n this._accounts = params\n this.onAddressChange(params)\n },\n [METHODS.updateNetwork]: (params) => {\n const { node } = params\n if (node != null) this.addNode(node.name, new Node(node.url), true)\n this.onNetworkChange(params)\n },\n [METHODS.closeConnection]: (params) => {\n disconnectParams = params\n client.connection.disconnect()\n },\n [METHODS.readyToConnect]: () => {}\n }\n )\n const { node, ...walletInfo } = await client.request(\n METHODS.connect, { name: this.name, version: RPC_VERSION, connectNode }\n )\n if (connectNode) {\n if (node == null) throw new RpcConnectionError('Missing URLs of the Node')\n this.addNode(name, new Node(node.url), select)\n }\n this.rpcClient = client\n return walletInfo\n }\n\n /**\n * Disconnect from wallet\n */\n disconnectWallet (): void {\n this._ensureConnected()\n this.rpcClient.notify(METHODS.closeConnection, { reason: 'bye' })\n this.rpcClient.connection.disconnect()\n }\n\n /**\n * Ask addresses from wallet\n * @returns Addresses from wallet\n */\n async askAddresses (): Promise<Array<EncodedData<'ak'>>> {\n this._ensureAccountAccess()\n return await this.rpcClient.request(METHODS.address, undefined)\n }\n\n /**\n * Subscribe for addresses from wallet\n * @param type - Subscription type\n * @param value - Should be one of 'current' (the selected account), 'connected' (all)\n * @returns Accounts from wallet\n */\n async subscribeAddress (\n type: SUBSCRIPTION_TYPES, value: 'current' | 'connected'\n ): Promise<ReturnType<WalletApi[METHODS.subscribeAddress]>> {\n this._ensureConnected()\n const result = await this.rpcClient.request(METHODS.subscribeAddress, { type, value })\n this._accounts = result.address\n return result\n }\n\n _ensureConnected (): asserts this is AeSdkAepp & { rpcClient: NonNullable<AeSdkAepp['rpcClient']> } {\n if (this.rpcClient != null) return\n throw new NoWalletConnectedError('You are not connected to Wallet')\n }\n\n _ensureAccountAccess (): asserts this is AeSdkAepp & { rpcClient: NonNullable<AeSdkAepp['rpcClient']> } {\n this._ensureConnected()\n if (this.addresses().length !== 0) return\n throw new UnsubscribedAccountError()\n }\n}\n"],"mappings":"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"}
@@ -0,0 +1,212 @@
1
+ import * as chainMethods from './chain';
2
+ import * as txMethods from './tx';
3
+ import * as aensMethods from './aens';
4
+ import * as spendMethods from './spend';
5
+ import * as oracleMethods from './oracle';
6
+ import * as contractMethods from './contract/methods';
7
+ import * as contractGaMethods from './contract/ga';
8
+ import { _buildTx } from './tx';
9
+ import Node, { getNetworkId } from './Node';
10
+ import { AE_AMOUNT_FORMATS } from './utils/amount-formatter';
11
+ import { TX_TYPE } from './tx/builder/schema';
12
+ import { Keypair } from './account/Memory';
13
+ import AccountBase from './account/Base';
14
+ import { EncodedData } from './utils/encoder';
15
+ import Compiler from './contract/Compiler';
16
+ export declare type Account = Keypair | AccountBase | any;
17
+ declare type NodeInfo = Awaited<ReturnType<Node['getNodeInfo']>> & {
18
+ name: string;
19
+ };
20
+ /**
21
+ * Basic AeSdk class
22
+ *
23
+ * AeSdkBase objects are the composition of:
24
+ * - chain methods
25
+ * - tx methods
26
+ * - aens methods
27
+ * - spend methods
28
+ * - oracle methods
29
+ * - contract methods
30
+ * - contract ga methods
31
+ * Only by providing the joint functionality of them, most more advanced
32
+ * operations, i.e. the ones with actual use value on the chain, become
33
+ * available.
34
+ */
35
+ declare class AeSdkBase {
36
+ _options: {
37
+ denomination: AE_AMOUNT_FORMATS;
38
+ amount: number;
39
+ [key: string]: any;
40
+ };
41
+ pool: Map<string, Node>;
42
+ selectedNodeName?: string;
43
+ compilerApi: Compiler;
44
+ /**
45
+ * @param options - Options
46
+ * @param options.nodes - Array of nodes
47
+ * @param options.compilerUrl - Url for compiler API
48
+ * @param options.ignoreVersion - Don't check node or compiler version
49
+ */
50
+ constructor({ nodes, compilerUrl, ignoreVersion, ...options }?: {
51
+ nodes?: Array<{
52
+ name: string;
53
+ instance: Node;
54
+ }>;
55
+ compilerUrl?: string;
56
+ ignoreVersion?: boolean;
57
+ [key: string]: any;
58
+ });
59
+ setCompilerUrl(compilerUrl: string, { ignoreVersion }?: {
60
+ ignoreVersion?: boolean;
61
+ }): void;
62
+ get api(): Node;
63
+ /**
64
+ * Add Node
65
+ * @param name - Node name
66
+ * @param node - Node instance
67
+ * @param select - Select this node as current
68
+ * @example
69
+ * ```js
70
+ * // add and select new node with name 'testNode'
71
+ * aeSdkBase.addNode('testNode', new Node({ url }), true)
72
+ * ```
73
+ */
74
+ addNode(name: string, node: Node, select?: boolean): void;
75
+ /**
76
+ * Select Node
77
+ * @param name - Node name
78
+ * @example
79
+ * nodePool.selectNode('testNode')
80
+ */
81
+ selectNode(name: string): void;
82
+ /**
83
+ * Get NetworkId of current Node
84
+ * @example
85
+ * nodePool.getNetworkId()
86
+ */
87
+ readonly getNetworkId: typeof getNetworkId;
88
+ /**
89
+ * Check if you have selected node
90
+ * @example
91
+ * nodePool.isNodeConnected()
92
+ */
93
+ isNodeConnected(): this is AeSdkBase & {
94
+ selectedNodeName: string;
95
+ };
96
+ protected ensureNodeConnected(): asserts this is AeSdkBase & {
97
+ selectedNodeName: string;
98
+ };
99
+ /**
100
+ * Get information about node
101
+ * @example
102
+ * ```js
103
+ * nodePool.getNodeInfo() // { name, version, networkId, protocol, ... }
104
+ * ```
105
+ */
106
+ getNodeInfo(): Promise<NodeInfo>;
107
+ /**
108
+ * Get array of available nodes
109
+ * @example
110
+ * nodePool.getNodesInPool()
111
+ */
112
+ getNodesInPool(): Promise<NodeInfo[]>;
113
+ addresses(): Array<EncodedData<'ak'>>;
114
+ address({ onAccount }?: {
115
+ onAccount?: Account;
116
+ }): Promise<EncodedData<'ak'>>;
117
+ sign(data: string | Uint8Array, { onAccount, ...options }?: {
118
+ onAccount?: Account;
119
+ }): Promise<Uint8Array>;
120
+ signTransaction(tx: EncodedData<'tx'>, { onAccount, ...options }?: {
121
+ onAccount?: Account;
122
+ } & Parameters<AccountBase['signTransaction']>[1]): Promise<EncodedData<'tx'>>;
123
+ signMessage(message: string, { onAccount, ...options }?: {
124
+ onAccount?: Account;
125
+ } & Parameters<AccountBase['signMessage']>[1]): Promise<string | Uint8Array>;
126
+ verifyMessage(message: string, signature: string | Uint8Array, { onAccount, ...options }?: {
127
+ onAccount?: Account;
128
+ } & Parameters<AccountBase['verifyMessage']>[2]): Promise<boolean>;
129
+ /**
130
+ * Resolves an account
131
+ * @param account - ak-address, instance of AccountBase, or keypair
132
+ */
133
+ _resolveAccount(account?: Account): AccountBase;
134
+ _getOptions(): Promise<{
135
+ onNode: Node;
136
+ onAccount: AccountBase;
137
+ onCompiler: Compiler;
138
+ networkId: string;
139
+ }>;
140
+ buildTx<TxType extends TX_TYPE>(txType: TxType, options: Omit<Parameters<typeof _buildTx<TxType>>[1], 'onNode'> & {
141
+ onNode?: Node;
142
+ }): Promise<EncodedData<'tx'>>;
143
+ }
144
+ declare const methods: {
145
+ readonly isGA: typeof contractGaMethods.isGA;
146
+ readonly createGeneralizedAccount: typeof contractGaMethods.createGeneralizedAccount;
147
+ readonly createMetaTx: typeof contractGaMethods.createMetaTx;
148
+ readonly buildAuthTxHash: typeof contractGaMethods.buildAuthTxHash;
149
+ readonly createAensDelegationSignature: typeof contractMethods.createAensDelegationSignature;
150
+ readonly createOracleDelegationSignature: typeof contractMethods.createOracleDelegationSignature;
151
+ readonly getContractInstance: typeof contractMethods.getContractInstance;
152
+ readonly getOracleObject: typeof oracleMethods.getOracleObject;
153
+ readonly pollForQueries: typeof oracleMethods.pollForQueries;
154
+ readonly getQueryObject: typeof oracleMethods.getQueryObject;
155
+ readonly pollForQueryResponse: typeof oracleMethods.pollForQueryResponse;
156
+ readonly registerOracle: typeof oracleMethods.registerOracle;
157
+ readonly postQueryToOracle: typeof oracleMethods.postQueryToOracle;
158
+ readonly extendOracleTtl: typeof oracleMethods.extendOracleTtl;
159
+ readonly respondToQuery: typeof oracleMethods.respondToQuery;
160
+ readonly send: typeof spendMethods.send;
161
+ readonly signUsingGA: typeof spendMethods.signUsingGA;
162
+ readonly spend: typeof spendMethods.spend;
163
+ readonly transferFunds: typeof spendMethods.transferFunds;
164
+ readonly payForTransaction: typeof spendMethods.payForTransaction;
165
+ readonly aensRevoke: typeof aensMethods.aensRevoke;
166
+ readonly aensUpdate: typeof aensMethods.aensUpdate;
167
+ readonly aensTransfer: typeof aensMethods.aensTransfer;
168
+ readonly aensQuery: typeof aensMethods.aensQuery;
169
+ readonly aensClaim: typeof aensMethods.aensClaim;
170
+ readonly aensPreclaim: typeof aensMethods.aensPreclaim;
171
+ readonly aensBid: typeof aensMethods.aensBid;
172
+ readonly getVmVersion: typeof txMethods.getVmVersion;
173
+ readonly prepareTxParams: typeof txMethods.prepareTxParams;
174
+ readonly _getPollInterval: typeof chainMethods._getPollInterval;
175
+ readonly sendTransaction: typeof chainMethods.sendTransaction;
176
+ readonly waitForTxConfirm: typeof chainMethods.waitForTxConfirm;
177
+ readonly getAccount: typeof chainMethods.getAccount;
178
+ readonly getBalance: typeof chainMethods.getBalance;
179
+ readonly height: typeof chainMethods.height;
180
+ readonly awaitHeight: typeof chainMethods.awaitHeight;
181
+ readonly poll: typeof chainMethods.poll;
182
+ readonly getCurrentGeneration: typeof chainMethods.getCurrentGeneration;
183
+ readonly getGeneration: typeof chainMethods.getGeneration;
184
+ readonly getMicroBlockTransactions: typeof chainMethods.getMicroBlockTransactions;
185
+ readonly getKeyBlock: typeof chainMethods.getKeyBlock;
186
+ readonly getMicroBlockHeader: typeof chainMethods.getMicroBlockHeader;
187
+ readonly txDryRun: typeof chainMethods.txDryRun;
188
+ readonly getContractByteCode: typeof chainMethods.getContractByteCode;
189
+ readonly getContract: typeof chainMethods.getContract;
190
+ readonly getName: typeof chainMethods.getName;
191
+ readonly resolveName: typeof chainMethods.resolveName;
192
+ };
193
+ declare type RequiredKeys<T> = {
194
+ [K in keyof T]-?: {} extends Pick<T, K> ? never : K;
195
+ }[keyof T];
196
+ declare type OptionalIfNotRequired<T extends [any]> = RequiredKeys<T[0]> extends never ? T | [] : T;
197
+ declare type MakeOptional<Args extends any[]> = Args extends [infer Head, ...infer Tail] ? Tail extends [] ? Head extends object ? OptionalIfNotRequired<[
198
+ Omit<Head, 'onNode' | 'onCompiler' | 'onAccount'> & {
199
+ onNode?: Node;
200
+ onCompiler?: Compiler;
201
+ onAccount?: AccountBase | EncodedData<'ak'> | Keypair;
202
+ }
203
+ ]> : [Head] : [Head, ...MakeOptional<Tail>] : never;
204
+ declare type TransformMethods<Methods extends {
205
+ [key: string]: Function;
206
+ }> = {
207
+ [Name in keyof Methods]: Methods[Name] extends (...args: infer Args) => infer Ret ? (...args: MakeOptional<Args>) => Ret : never;
208
+ };
209
+ interface AeSdkBaseMethods extends TransformMethods<typeof methods> {
210
+ }
211
+ declare const _default: new (options: ConstructorParameters<typeof AeSdkBase>[0]) => AeSdkBase & AeSdkBaseMethods;
212
+ export default _default;