@aeternity/aepp-sdk 10.0.0 → 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 (424) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +15 -14
  3. package/dist/aepp-sdk.browser-script.js +1 -1
  4. package/dist/aepp-sdk.browser-script.js.LICENSE.txt +13 -40
  5. package/dist/aepp-sdk.browser-script.js.map +1 -1
  6. package/dist/aepp-sdk.browser.js +1 -1
  7. package/dist/aepp-sdk.browser.js.map +1 -1
  8. package/dist/aepp-sdk.js +1 -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 +69 -0
  14. package/es/AeSdkAepp.mjs +175 -0
  15. package/es/AeSdkAepp.mjs.map +1 -0
  16. package/es/AeSdkBase.d.ts +212 -0
  17. package/es/AeSdkBase.mjs +310 -0
  18. package/es/AeSdkBase.mjs.map +1 -0
  19. package/es/AeSdkWallet.d.ts +103 -0
  20. package/es/AeSdkWallet.mjs +322 -0
  21. package/es/AeSdkWallet.mjs.map +1 -0
  22. package/es/Node.d.ts +44 -0
  23. package/es/Node.mjs +141 -0
  24. package/es/Node.mjs.map +1 -0
  25. package/es/account/Base.d.ts +65 -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 +25 -0
  29. package/es/account/Memory.mjs +81 -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 +79 -0
  33. package/es/account/Rpc.mjs.map +1 -0
  34. package/es/aens.d.ts +209 -0
  35. package/es/aens.mjs +332 -0
  36. package/es/aens.mjs.map +1 -0
  37. package/es/aepp-wallet-communication/connection/Browser.d.ts +32 -0
  38. package/es/aepp-wallet-communication/connection/Browser.mjs +70 -0
  39. package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -0
  40. package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +17 -0
  41. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +57 -0
  42. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -0
  43. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +35 -0
  44. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +142 -0
  45. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -0
  46. package/es/aepp-wallet-communication/connection-proxy.d.ts +10 -0
  47. package/{src/utils/crypto-ts.ts → es/aepp-wallet-communication/connection-proxy.mjs} +15 -11
  48. package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -0
  49. package/es/aepp-wallet-communication/rpc/RpcClient.d.ts +33 -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 +118 -0
  56. package/es/aepp-wallet-communication/schema.mjs +214 -0
  57. package/es/aepp-wallet-communication/schema.mjs.map +1 -0
  58. package/es/aepp-wallet-communication/wallet-detector.d.ts +24 -0
  59. package/es/aepp-wallet-communication/wallet-detector.mjs +63 -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 +1061 -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 +4164 -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 +220 -0
  92. package/es/chain.mjs +524 -0
  93. package/es/chain.mjs.map +1 -0
  94. package/es/channel/handlers.d.ts +34 -0
  95. package/es/channel/{handlers.js → handlers.mjs} +163 -130
  96. package/es/channel/handlers.mjs.map +1 -0
  97. package/es/channel/index.d.ts +634 -0
  98. package/es/channel/index.mjs +978 -0
  99. package/es/channel/index.mjs.map +1 -0
  100. package/es/channel/internal.d.ts +100 -0
  101. package/es/channel/internal.mjs +328 -0
  102. package/es/channel/internal.mjs.map +1 -0
  103. package/es/contract/Compiler.d.ts +17 -0
  104. package/es/contract/Compiler.mjs +67 -0
  105. package/es/contract/Compiler.mjs.map +1 -0
  106. package/es/contract/aci.d.ts +125 -0
  107. package/es/contract/aci.mjs +496 -0
  108. package/es/contract/aci.mjs.map +1 -0
  109. package/es/contract/ga.d.ts +68 -0
  110. package/es/contract/ga.mjs +190 -0
  111. package/es/contract/ga.mjs.map +1 -0
  112. package/es/contract/methods.d.ts +68 -0
  113. package/es/contract/methods.mjs +101 -0
  114. package/es/contract/methods.mjs.map +1 -0
  115. package/es/index.d.ts +32 -0
  116. package/es/index.mjs +49 -0
  117. package/es/index.mjs.map +1 -0
  118. package/es/oracle.d.ts +154 -0
  119. package/es/oracle.mjs +288 -0
  120. package/es/oracle.mjs.map +1 -0
  121. package/es/spend.d.ts +61 -0
  122. package/es/spend.mjs +122 -0
  123. package/es/spend.mjs.map +1 -0
  124. package/es/tx/builder/constants.d.ts +41 -0
  125. package/es/tx/builder/constants.mjs +100 -0
  126. package/es/tx/builder/constants.mjs.map +1 -0
  127. package/es/tx/builder/field-types.d.ts +62 -0
  128. package/es/tx/builder/field-types.mjs +126 -0
  129. package/es/tx/builder/field-types.mjs.map +1 -0
  130. package/es/tx/builder/helpers.d.ts +131 -0
  131. package/es/tx/builder/helpers.mjs +223 -0
  132. package/es/tx/builder/helpers.mjs.map +1 -0
  133. package/es/tx/builder/index.d.ts +75 -0
  134. package/es/tx/builder/index.mjs +424 -0
  135. package/es/tx/builder/index.mjs.map +1 -0
  136. package/es/tx/builder/schema.d.ts +350 -0
  137. package/es/tx/builder/schema.mjs +320 -0
  138. package/es/tx/builder/schema.mjs.map +1 -0
  139. package/es/tx/index.d.ts +63 -0
  140. package/es/tx/index.mjs +209 -0
  141. package/es/tx/index.mjs.map +1 -0
  142. package/es/tx/min-fee.d.ts +20 -0
  143. package/es/tx/min-fee.mjs +148 -0
  144. package/es/tx/min-fee.mjs.map +1 -0
  145. package/es/tx/validator.d.ts +19 -0
  146. package/es/tx/validator.mjs +240 -0
  147. package/es/tx/validator.mjs.map +1 -0
  148. package/es/typings/@aeternity__argon2-browser/index.d.mjs +2 -0
  149. package/es/typings/@aeternity__argon2-browser/index.d.mjs.map +1 -0
  150. package/es/typings/@aeternity__uuid/index.d.mjs +2 -0
  151. package/es/typings/@aeternity__uuid/index.d.mjs.map +1 -0
  152. package/es/typings/bip32-path/index.d.mjs +2 -0
  153. package/es/typings/bip32-path/index.d.mjs.map +1 -0
  154. package/es/typings/blakejs/index.d.mjs +2 -0
  155. package/es/typings/blakejs/index.d.mjs.map +1 -0
  156. package/es/typings/tweetnacl-auth/index.d.mjs +2 -0
  157. package/es/typings/tweetnacl-auth/index.d.mjs.map +1 -0
  158. package/es/utils/amount-formatter.d.ts +42 -0
  159. package/es/utils/{amount-formatter.js → amount-formatter.mjs} +38 -44
  160. package/es/utils/amount-formatter.mjs.map +1 -0
  161. package/es/utils/autorest.d.ts +6 -0
  162. package/es/utils/autorest.mjs +97 -0
  163. package/es/utils/autorest.mjs.map +1 -0
  164. package/es/utils/bignumber.d.ts +13 -0
  165. package/es/utils/bignumber.mjs +23 -0
  166. package/es/utils/bignumber.mjs.map +1 -0
  167. package/es/{bytes.d.ts → utils/bytes.d.ts} +10 -13
  168. package/es/utils/{bytes.js → bytes.mjs} +26 -22
  169. package/es/utils/bytes.mjs.map +1 -0
  170. package/es/utils/crypto.d.ts +103 -0
  171. package/es/utils/crypto.mjs +221 -0
  172. package/es/utils/crypto.mjs.map +1 -0
  173. package/es/utils/encoder.d.ts +26 -0
  174. package/es/utils/encoder.mjs +102 -0
  175. package/es/utils/encoder.mjs.map +1 -0
  176. package/es/utils/errors.d.ts +481 -0
  177. package/es/utils/errors.mjs +882 -0
  178. package/es/utils/errors.mjs.map +1 -0
  179. package/es/utils/hd-wallet.d.ts +34 -0
  180. package/es/utils/hd-wallet.mjs +122 -0
  181. package/es/utils/hd-wallet.mjs.map +1 -0
  182. package/es/utils/json-big.d.ts +5 -0
  183. package/es/utils/json-big.mjs +41 -0
  184. package/es/utils/json-big.mjs.map +1 -0
  185. package/es/utils/keystore.d.ts +51 -0
  186. package/es/utils/keystore.mjs +145 -0
  187. package/es/utils/keystore.mjs.map +1 -0
  188. package/es/{mptree.d.ts → utils/mptree.d.ts} +5 -8
  189. package/es/utils/{mptree.js → mptree.mjs} +33 -25
  190. package/es/utils/mptree.mjs.map +1 -0
  191. package/es/utils/other.d.ts +14 -0
  192. package/es/utils/other.mjs +28 -0
  193. package/es/utils/other.mjs.map +1 -0
  194. package/es/{semver-satisfies.d.ts → utils/semver-satisfies.d.ts} +0 -0
  195. package/es/utils/{semver-satisfies.js → semver-satisfies.mjs} +1 -1
  196. package/es/utils/semver-satisfies.mjs.map +1 -0
  197. package/es/utils/string.d.ts +24 -0
  198. package/es/utils/{string.js → string.mjs} +9 -11
  199. package/es/utils/string.mjs.map +1 -0
  200. package/package.json +67 -64
  201. package/src/AeSdk.ts +65 -0
  202. package/src/AeSdkAepp.ts +167 -0
  203. package/src/AeSdkBase.ts +320 -0
  204. package/src/AeSdkWallet.ts +332 -0
  205. package/src/Node.ts +167 -0
  206. package/src/account/Base.ts +114 -0
  207. package/src/account/Memory.ts +83 -0
  208. package/src/account/Rpc.ts +67 -0
  209. package/src/aens.ts +391 -0
  210. package/src/aepp-wallet-communication/connection/Browser.ts +68 -0
  211. package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +58 -0
  212. package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +111 -0
  213. package/{es/utils/crypto-ts.js → src/aepp-wallet-communication/connection-proxy.ts} +16 -9
  214. package/src/aepp-wallet-communication/rpc/RpcClient.ts +137 -0
  215. package/src/aepp-wallet-communication/rpc/types.ts +66 -0
  216. package/src/aepp-wallet-communication/schema.ts +181 -0
  217. package/src/aepp-wallet-communication/wallet-detector.ts +71 -0
  218. package/src/apis/compiler/code-model-v4.yaml +2649 -0
  219. package/src/apis/compiler/compiler.ts +585 -0
  220. package/src/apis/compiler/index.ts +2 -0
  221. package/src/apis/compiler/models/index.ts +301 -0
  222. package/src/apis/compiler/models/mappers.ts +583 -0
  223. package/src/apis/compiler/models/parameters.ts +93 -0
  224. package/src/apis/node/code-model-v4.yaml +10046 -0
  225. package/src/apis/node/index.ts +2 -0
  226. package/src/apis/node/models/index.ts +1253 -0
  227. package/src/apis/node/models/mappers.ts +4278 -0
  228. package/src/apis/node/models/parameters.ts +188 -0
  229. package/src/apis/node/node.ts +1299 -0
  230. package/src/chain.ts +444 -0
  231. package/src/channel/{handlers.js → handlers.ts} +238 -143
  232. package/src/channel/index.ts +991 -0
  233. package/src/channel/internal.ts +345 -0
  234. package/src/contract/Compiler.ts +66 -0
  235. package/src/contract/aci.ts +529 -0
  236. package/src/contract/ga.ts +178 -0
  237. package/src/contract/methods.ts +118 -0
  238. package/src/index.ts +51 -0
  239. package/src/oracle.ts +342 -0
  240. package/src/spend.ts +152 -0
  241. package/src/tx/builder/constants.ts +96 -0
  242. package/src/tx/builder/field-types.ts +111 -0
  243. package/src/tx/builder/helpers.ts +253 -0
  244. package/src/tx/builder/index.ts +394 -0
  245. package/src/tx/builder/schema.ts +771 -0
  246. package/src/tx/index.ts +199 -0
  247. package/src/tx/min-fee.ts +136 -0
  248. package/src/tx/validator.ts +226 -0
  249. package/src/typings/@aeternity__argon2-browser/index.d.ts +3 -0
  250. package/src/typings/@aeternity__uuid/index.d.ts +3 -0
  251. package/src/typings/bip32-path/index.d.ts +33 -0
  252. package/src/typings/tweetnacl-auth/index.d.ts +14 -0
  253. package/src/utils/amount-formatter.ts +29 -41
  254. package/src/utils/autorest.ts +90 -0
  255. package/src/utils/bignumber.ts +9 -19
  256. package/src/utils/bytes.ts +15 -16
  257. package/src/utils/crypto.ts +217 -0
  258. package/src/utils/encoder.ts +98 -0
  259. package/src/utils/errors.ts +817 -0
  260. package/src/utils/hd-wallet.ts +134 -0
  261. package/src/utils/json-big.ts +26 -0
  262. package/src/utils/keystore.ts +179 -0
  263. package/src/utils/mptree.ts +26 -20
  264. package/src/utils/other.ts +28 -43
  265. package/src/utils/string.ts +8 -10
  266. package/CHANGELOG.md +0 -1603
  267. package/es/account/base.js +0 -169
  268. package/es/account/base.js.map +0 -1
  269. package/es/account/memory.js +0 -84
  270. package/es/account/memory.js.map +0 -1
  271. package/es/account/multiple.js +0 -178
  272. package/es/account/multiple.js.map +0 -1
  273. package/es/ae/aens.js +0 -408
  274. package/es/ae/aens.js.map +0 -1
  275. package/es/ae/aepp.js +0 -45
  276. package/es/ae/aepp.js.map +0 -1
  277. package/es/ae/contract.js +0 -312
  278. package/es/ae/contract.js.map +0 -1
  279. package/es/ae/index.js +0 -206
  280. package/es/ae/index.js.map +0 -1
  281. package/es/ae/oracle.js +0 -322
  282. package/es/ae/oracle.js.map +0 -1
  283. package/es/ae/universal.js +0 -45
  284. package/es/ae/universal.js.map +0 -1
  285. package/es/ae/wallet.js +0 -50
  286. package/es/ae/wallet.js.map +0 -1
  287. package/es/amount-formatter.d.ts +0 -58
  288. package/es/bignumber.d.ts +0 -24
  289. package/es/chain/index.js +0 -256
  290. package/es/chain/index.js.map +0 -1
  291. package/es/chain/node.js +0 -394
  292. package/es/chain/node.js.map +0 -1
  293. package/es/channel/handlers.js.map +0 -1
  294. package/es/channel/index.js +0 -980
  295. package/es/channel/index.js.map +0 -1
  296. package/es/channel/internal.js +0 -266
  297. package/es/channel/internal.js.map +0 -1
  298. package/es/contract/aci/helpers.js +0 -298
  299. package/es/contract/aci/helpers.js.map +0 -1
  300. package/es/contract/aci/index.js +0 -361
  301. package/es/contract/aci/index.js.map +0 -1
  302. package/es/contract/aci/transformation.js +0 -66
  303. package/es/contract/aci/transformation.js.map +0 -1
  304. package/es/contract/compiler.js +0 -244
  305. package/es/contract/compiler.js.map +0 -1
  306. package/es/contract/ga/helpers.js +0 -22
  307. package/es/contract/ga/helpers.js.map +0 -1
  308. package/es/contract/ga/index.js +0 -170
  309. package/es/contract/ga/index.js.map +0 -1
  310. package/es/contract/index.js +0 -162
  311. package/es/contract/index.js.map +0 -1
  312. package/es/crypto-ts.d.ts +0 -9
  313. package/es/index.js +0 -57
  314. package/es/index.js.map +0 -1
  315. package/es/node-pool/index.js +0 -187
  316. package/es/node-pool/index.js.map +0 -1
  317. package/es/node.js +0 -132
  318. package/es/node.js.map +0 -1
  319. package/es/other.d.ts +0 -31
  320. package/es/string.d.ts +0 -26
  321. package/es/tx/builder/helpers.js +0 -305
  322. package/es/tx/builder/helpers.js.map +0 -1
  323. package/es/tx/builder/index.js +0 -595
  324. package/es/tx/builder/index.js.map +0 -1
  325. package/es/tx/builder/schema.js +0 -814
  326. package/es/tx/builder/schema.js.map +0 -1
  327. package/es/tx/index.js +0 -300
  328. package/es/tx/index.js.map +0 -1
  329. package/es/tx/tx-object.js +0 -276
  330. package/es/tx/tx-object.js.map +0 -1
  331. package/es/tx/tx.js +0 -937
  332. package/es/tx/tx.js.map +0 -1
  333. package/es/tx/validator.js +0 -208
  334. package/es/tx/validator.js.map +0 -1
  335. package/es/typings/blakejs/index.d.js +0 -2
  336. package/es/typings/blakejs/index.d.js.map +0 -1
  337. package/es/utils/aepp-wallet-communication/connection/browser-runtime.js +0 -131
  338. package/es/utils/aepp-wallet-communication/connection/browser-runtime.js.map +0 -1
  339. package/es/utils/aepp-wallet-communication/connection/browser-window-message.js +0 -184
  340. package/es/utils/aepp-wallet-communication/connection/browser-window-message.js.map +0 -1
  341. package/es/utils/aepp-wallet-communication/connection/index.js +0 -84
  342. package/es/utils/aepp-wallet-communication/connection/index.js.map +0 -1
  343. package/es/utils/aepp-wallet-communication/content-script-bridge.js +0 -97
  344. package/es/utils/aepp-wallet-communication/content-script-bridge.js.map +0 -1
  345. package/es/utils/aepp-wallet-communication/helpers.js +0 -103
  346. package/es/utils/aepp-wallet-communication/helpers.js.map +0 -1
  347. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js +0 -329
  348. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js.map +0 -1
  349. package/es/utils/aepp-wallet-communication/rpc/rpc-client.js +0 -270
  350. package/es/utils/aepp-wallet-communication/rpc/rpc-client.js.map +0 -1
  351. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js +0 -533
  352. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js.map +0 -1
  353. package/es/utils/aepp-wallet-communication/schema.js +0 -107
  354. package/es/utils/aepp-wallet-communication/schema.js.map +0 -1
  355. package/es/utils/aepp-wallet-communication/wallet-detector.js +0 -109
  356. package/es/utils/aepp-wallet-communication/wallet-detector.js.map +0 -1
  357. package/es/utils/amount-formatter.js.map +0 -1
  358. package/es/utils/async-init.js +0 -67
  359. package/es/utils/async-init.js.map +0 -1
  360. package/es/utils/bignumber.js +0 -28
  361. package/es/utils/bignumber.js.map +0 -1
  362. package/es/utils/bytes.js.map +0 -1
  363. package/es/utils/crypto-ts.js.map +0 -1
  364. package/es/utils/crypto.js +0 -304
  365. package/es/utils/crypto.js.map +0 -1
  366. package/es/utils/hd-wallet.js +0 -112
  367. package/es/utils/hd-wallet.js.map +0 -1
  368. package/es/utils/json-big.js +0 -45
  369. package/es/utils/json-big.js.map +0 -1
  370. package/es/utils/keystore.js +0 -228
  371. package/es/utils/keystore.js.map +0 -1
  372. package/es/utils/mptree.js.map +0 -1
  373. package/es/utils/other.js +0 -43
  374. package/es/utils/other.js.map +0 -1
  375. package/es/utils/semver-satisfies.js.map +0 -1
  376. package/es/utils/string.js.map +0 -1
  377. package/es/utils/swagger.js +0 -132
  378. package/es/utils/swagger.js.map +0 -1
  379. package/src/account/base.js +0 -153
  380. package/src/account/memory.js +0 -78
  381. package/src/account/multiple.js +0 -154
  382. package/src/ae/aens.js +0 -366
  383. package/src/ae/aepp.js +0 -45
  384. package/src/ae/contract.js +0 -285
  385. package/src/ae/index.js +0 -167
  386. package/src/ae/oracle.js +0 -296
  387. package/src/ae/universal.js +0 -47
  388. package/src/ae/wallet.js +0 -50
  389. package/src/chain/index.js +0 -250
  390. package/src/chain/node.js +0 -293
  391. package/src/channel/index.js +0 -898
  392. package/src/channel/internal.js +0 -231
  393. package/src/contract/aci/index.js +0 -317
  394. package/src/contract/aci/transformation.js +0 -72
  395. package/src/contract/compiler.js +0 -195
  396. package/src/contract/ga/helpers.js +0 -17
  397. package/src/contract/ga/index.js +0 -147
  398. package/src/contract/index.js +0 -163
  399. package/src/index.js +0 -90
  400. package/src/node-pool/index.js +0 -171
  401. package/src/node.js +0 -118
  402. package/src/tx/builder/helpers.js +0 -325
  403. package/src/tx/builder/index.js +0 -460
  404. package/src/tx/builder/schema.js +0 -1211
  405. package/src/tx/index.js +0 -301
  406. package/src/tx/tx-object.js +0 -186
  407. package/src/tx/tx.js +0 -622
  408. package/src/tx/validator.js +0 -161
  409. package/src/utils/aepp-wallet-communication/connection/browser-runtime.js +0 -114
  410. package/src/utils/aepp-wallet-communication/connection/browser-window-message.js +0 -161
  411. package/src/utils/aepp-wallet-communication/connection/index.js +0 -85
  412. package/src/utils/aepp-wallet-communication/content-script-bridge.js +0 -85
  413. package/src/utils/aepp-wallet-communication/helpers.js +0 -70
  414. package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +0 -268
  415. package/src/utils/aepp-wallet-communication/rpc/rpc-client.js +0 -223
  416. package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +0 -390
  417. package/src/utils/aepp-wallet-communication/schema.js +0 -108
  418. package/src/utils/aepp-wallet-communication/wallet-detector.js +0 -91
  419. package/src/utils/async-init.js +0 -41
  420. package/src/utils/crypto.js +0 -312
  421. package/src/utils/hd-wallet.js +0 -115
  422. package/src/utils/json-big.js +0 -26
  423. package/src/utils/keystore.js +0 -223
  424. package/src/utils/swagger.js +0 -133
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;