@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
@@ -1,329 +0,0 @@
1
- /**
2
- * RPC handler for AEPP side
3
- *
4
- * @module @aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/aepp-rpc
5
- * @export AeppRpc
6
- * @example
7
- * import ContentScriptBridge
8
- * from '@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/aepp-rpc'
9
- */
10
- import { v4 as uuid } from 'uuid';
11
- import Ae from '../../../ae';
12
- import RpcClient from './rpc-client';
13
- import { getHandler, message, voidFn } from '../helpers';
14
- import { METHODS, RPC_STATUS, VERSION } from '../schema';
15
- const NOTIFICATIONS = {
16
- [METHODS.wallet.updateAddress]: instance => _ref => {
17
- let {
18
- params
19
- } = _ref;
20
- instance.rpcClient.accounts = params;
21
- instance.onAddressChange(params);
22
- },
23
- [METHODS.updateNetwork]: instance => msg => {
24
- instance.rpcClient.info.networkId = msg.params.networkId;
25
- instance.onNetworkChange(msg.params);
26
- },
27
- [METHODS.closeConnection]: instance => msg => {
28
- instance.disconnectWallet();
29
- instance.onDisconnect(msg.params);
30
- }
31
- };
32
- const RESPONSES = {
33
- [METHODS.aepp.address]: instance => msg => instance.rpcClient.processResponse(msg),
34
- [METHODS.aepp.connect]: instance => msg => {
35
- if (msg.result) instance.rpcClient.info.status = RPC_STATUS.CONNECTED;
36
- instance.rpcClient.processResponse(msg);
37
- },
38
- [METHODS.aepp.subscribeAddress]: instance => msg => {
39
- if (msg.result) {
40
- if (msg.result.address) {
41
- instance.rpcClient.accounts = msg.result.address;
42
- }
43
-
44
- if (msg.result.subscription) {
45
- instance.rpcClient.addressSubscription = msg.result.subscription;
46
- }
47
- }
48
-
49
- instance.rpcClient.processResponse(msg, _ref2 => {
50
- let {
51
- id,
52
- result
53
- } = _ref2;
54
- return [result];
55
- });
56
- },
57
- [METHODS.aepp.sign]: instance => msg => {
58
- instance.rpcClient.processResponse(msg, _ref3 => {
59
- let {
60
- id,
61
- result
62
- } = _ref3;
63
- return [result.signedTransaction || result.transactionHash];
64
- });
65
- },
66
- [METHODS.aepp.signMessage]: instance => msg => {
67
- instance.rpcClient.processResponse(msg, _ref4 => {
68
- let {
69
- id,
70
- result
71
- } = _ref4;
72
- return [result.signature];
73
- });
74
- }
75
- };
76
- const REQUESTS = {};
77
-
78
- const handleMessage = instance => async msg => {
79
- if (!msg.id) {
80
- return getHandler(NOTIFICATIONS, msg, {
81
- debug: instance.debug
82
- })(instance)(msg);
83
- } else if (Object.prototype.hasOwnProperty.call(instance.rpcClient.callbacks, msg.id)) {
84
- return getHandler(RESPONSES, msg, {
85
- debug: instance.debug
86
- })(instance)(msg);
87
- } else {
88
- return getHandler(REQUESTS, msg, {
89
- debug: instance.debug
90
- })(instance)(msg);
91
- }
92
- };
93
- /**
94
- * Contain functionality for wallet interaction and connect it to sdk
95
- * @alias module:@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/aepp-rpc
96
- * @function
97
- * @rtype Stamp
98
- * @param {Object} param Init params object
99
- * @param {String=} [param.name] Aepp name
100
- * @param {Function} onAddressChange Call-back function for update address event
101
- * @param {Function} onDisconnect Call-back function for disconnect event
102
- * @param {Function} onNetworkChange Call-back function for update network event
103
- * @param {Object} connection Wallet connection object
104
- * @return {Object}
105
- */
106
-
107
-
108
- export default Ae.compose({
109
- async init(_ref5) {
110
- let {
111
- name,
112
- onAddressChange = voidFn,
113
- onDisconnect = voidFn,
114
- onNetworkChange = voidFn,
115
- connection,
116
- forceValidation = false,
117
- debug = false
118
- } = _ref5;
119
- const eventsHandlers = ['onDisconnect', 'onAddressChange', 'onNetworkChange'];
120
- this.connection = connection;
121
- this.name = name;
122
- this.debug = debug;
123
-
124
- if (connection) {
125
- // Init RPCClient
126
- await this.connectToWallet(connection);
127
- } // Event callbacks
128
-
129
-
130
- this.onDisconnect = onDisconnect;
131
- this.onAddressChange = onAddressChange;
132
- this.onNetworkChange = onNetworkChange; // validation
133
-
134
- eventsHandlers.forEach(event => {
135
- if (!forceValidation && typeof this[event] !== 'function') throw new Error(`Call-back for ${event} must be an function!`);
136
- });
137
- },
138
-
139
- deepProps: {
140
- Ae: {
141
- defaults: {
142
- walletBroadcast: true
143
- }
144
- }
145
- },
146
- methods: {
147
- sign() {},
148
-
149
- addresses() {
150
- if (!this.rpcClient.currentAccount) throw new Error('You are not subscribed for an account.');
151
- return [this.rpcClient.currentAccount, ...Object.keys(this.rpcClient.accounts.connected)];
152
- },
153
-
154
- /**
155
- * Connect to wallet
156
- * @function connectToWallet
157
- * @instance
158
- * @rtype (connection: Object) => void
159
- * @param {Object} connection Wallet connection object
160
- * @return {void}
161
- */
162
- async connectToWallet(connection) {
163
- if (this.rpcClient && this.rpcClient.isConnected()) throw new Error('You are already connected to wallet ' + this.rpcClient);
164
- this.rpcClient = RpcClient({
165
- connection,
166
- networkId: this.getNetworkId({
167
- force: true
168
- }),
169
- ...connection.connectionInfo,
170
- id: uuid(),
171
- handlers: [handleMessage(this), this.onDisconnect]
172
- });
173
- return this.sendConnectRequest();
174
- },
175
-
176
- /**
177
- * Disconnect from wallet
178
- * @function disconnectWallet
179
- * @instance
180
- * @rtype (force: Boolean = false) => void
181
- * @param {Boolean} sendDisconnect=false Force sending close connection message
182
- * @return {void}
183
- */
184
- async disconnectWallet() {
185
- let sendDisconnect = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
186
- if (!this.rpcClient || !this.rpcClient.isConnected()) throw new Error('You are not connected to Wallet');
187
- sendDisconnect && this.rpcClient.sendMessage(message(METHODS.closeConnection, {
188
- reason: 'bye'
189
- }), true);
190
- this.rpcClient.disconnect();
191
- this.rpcClient = null;
192
- },
193
-
194
- async address() {
195
- let {
196
- onAccount
197
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
198
- if (!this.rpcClient || !this.rpcClient.isConnected()) throw new Error('You are not connected to Wallet');
199
- const current = this.rpcClient.currentAccount;
200
- if (!current) throw new Error('You are not subscribed for an account.');
201
- if (onAccount && !this.rpcClient.hasAccessToAccount(onAccount)) throw new Error(`You do not have access to account ${onAccount}`);
202
- return onAccount || current;
203
- },
204
-
205
- /**
206
- * Ask address from wallet
207
- * @function askAddresses
208
- * @instance
209
- * @rtype () => Promise
210
- * @return {Promise} Address from wallet
211
- */
212
- async askAddresses() {
213
- if (!this.rpcClient || !this.rpcClient.isConnected()) throw new Error('You are not connected to Wallet');
214
- if (!this.rpcClient.currentAccount) throw new Error('You are not subscribed for an account.');
215
- return this.rpcClient.request(METHODS.aepp.address);
216
- },
217
-
218
- /**
219
- * Subscribe for addresses from wallet
220
- * @function subscribeAddress
221
- * @instance
222
- * @rtype (type: String, value: String) => Promise
223
- * @param {String} type Should be one of 'current' (the selected account), 'connected' (all)
224
- * @param {String} value Subscription action('subscribe'|'unsubscribe')
225
- * @return {Promise} Address from wallet
226
- */
227
- async subscribeAddress(type, value) {
228
- if (!this.rpcClient || !this.rpcClient.isConnected()) throw new Error('You are not connected to Wallet');
229
- return this.rpcClient.request(METHODS.aepp.subscribeAddress, {
230
- type,
231
- value
232
- });
233
- },
234
-
235
- /**
236
- * Overwriting of `signTransaction` AE method
237
- * All sdk API which use it will be send notification to wallet and wait for callBack
238
- * @function signTransaction
239
- * @instance
240
- * @rtype (tx: String, options = {}) => Promise
241
- * @return {Promise<String>} Signed transaction
242
- */
243
- async signTransaction(tx) {
244
- let opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
245
- if (!this.rpcClient || !this.rpcClient.isConnected()) throw new Error('You are not connected to Wallet');
246
- if (!this.rpcClient.currentAccount) throw new Error('You are not subscribed for an account.');
247
- if (opt.onAccount && !this.rpcClient.hasAccessToAccount(opt.onAccount)) throw new Error(`You do not have access to account ${opt.onAccount}`);
248
- return this.rpcClient.request(METHODS.aepp.sign, { ...opt,
249
- tx,
250
- returnSigned: true,
251
- networkId: this.getNetworkId()
252
- });
253
- },
254
-
255
- /**
256
- * Overwriting of `signMessage` AE method
257
- * All sdk API which use it will be send notification to wallet and wait for callBack
258
- * @function signMessage
259
- * @instance
260
- * @rtype (msg: String, options = {}) => Promise
261
- * @return {Promise<String>} Signed transaction
262
- */
263
- async signMessage(msg) {
264
- let opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
265
- if (!this.rpcClient || !this.rpcClient.isConnected()) throw new Error('You are not connected to Wallet');
266
- if (!this.rpcClient.currentAccount) throw new Error('You are not subscribed for an account.');
267
- if (opt.onAccount && !this.rpcClient.hasAccessToAccount(opt.onAccount)) throw new Error(`You do not have access to account ${opt.onAccount}`);
268
- return this.rpcClient.request(METHODS.aepp.signMessage, { ...opt,
269
- message: msg
270
- });
271
- },
272
-
273
- /**
274
- * Send connection request to wallet
275
- * @function sendConnectRequest
276
- * @instance
277
- * @rtype () => Promise
278
- * @return {Promise} Connection response
279
- */
280
- async sendConnectRequest() {
281
- return this.rpcClient.request(METHODS.aepp.connect, {
282
- name: this.name,
283
- version: VERSION,
284
- networkId: this.getNetworkId({
285
- force: true
286
- })
287
- });
288
- },
289
-
290
- /**
291
- * Overwriting of `send` AE method
292
- * All sdk API which use it will be send notification to wallet and wait for callBack
293
- * This method will sign, broadcast and wait until transaction will be accepted using rpc
294
- * communication with wallet
295
- * @function send
296
- * @instance
297
- * @rtype (tx: String, options = {}) => Promise
298
- * @param {String} tx
299
- * @param {Object} [options={}]
300
- * @param {Object} [options.walletBroadcast=true]
301
- * @return {Promise<Object>} Transaction broadcast result
302
- */
303
- async send(tx) {
304
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
305
- if (!this.rpcClient || !this.rpcClient.isConnected()) throw new Error('You are not connected to Wallet');
306
- if (!this.rpcClient.currentAccount) throw new Error('You are not subscribed for an account.');
307
- if (options.onAccount && !this.rpcClient.hasAccessToAccount(options.onAccount)) throw new Error(`You do not have access to account ${options.onAccount}`);
308
- const opt = { ...this.Ae.defaults,
309
- ...options
310
- };
311
-
312
- if (!opt.walletBroadcast) {
313
- const signed = await this.signTransaction(tx, {
314
- onAccount: opt.onAccount
315
- });
316
- return this.sendTransaction(signed, opt);
317
- }
318
-
319
- return this.rpcClient.request(METHODS.aepp.sign, {
320
- onAccount: opt.onAccount,
321
- tx,
322
- returnSigned: false,
323
- networkId: this.getNetworkId()
324
- });
325
- }
326
-
327
- }
328
- });
329
- //# sourceMappingURL=aepp-rpc.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/utils/aepp-wallet-communication/rpc/aepp-rpc.js"],"names":["v4","uuid","Ae","RpcClient","getHandler","message","voidFn","METHODS","RPC_STATUS","VERSION","NOTIFICATIONS","wallet","updateAddress","instance","params","rpcClient","accounts","onAddressChange","updateNetwork","msg","info","networkId","onNetworkChange","closeConnection","disconnectWallet","onDisconnect","RESPONSES","aepp","address","processResponse","connect","result","status","CONNECTED","subscribeAddress","subscription","addressSubscription","id","sign","signedTransaction","transactionHash","signMessage","signature","REQUESTS","handleMessage","debug","Object","prototype","hasOwnProperty","call","callbacks","compose","init","name","connection","forceValidation","eventsHandlers","connectToWallet","forEach","event","Error","deepProps","defaults","walletBroadcast","methods","addresses","currentAccount","keys","connected","isConnected","getNetworkId","force","connectionInfo","handlers","sendConnectRequest","sendDisconnect","sendMessage","reason","disconnect","onAccount","current","hasAccessToAccount","askAddresses","request","type","value","signTransaction","tx","opt","returnSigned","version","send","options","signed","sendTransaction"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,EAAE,IAAIC,IAAf,QAA2B,MAA3B;AACA,OAAOC,EAAP,MAAe,aAAf;AACA,OAAOC,SAAP,MAAsB,cAAtB;AACA,SAASC,UAAT,EAAqBC,OAArB,EAA8BC,MAA9B,QAA4C,YAA5C;AACA,SAASC,OAAT,EAAkBC,UAAlB,EAA8BC,OAA9B,QAA6C,WAA7C;AAEA,MAAMC,aAAa,GAAG;AACpB,GAACH,OAAO,CAACI,MAAR,CAAeC,aAAhB,GAAiCC,QAAD,IAC9B,QAAgB;AAAA,QAAf;AAAEC,MAAAA;AAAF,KAAe;AACdD,IAAAA,QAAQ,CAACE,SAAT,CAAmBC,QAAnB,GAA8BF,MAA9B;AACAD,IAAAA,QAAQ,CAACI,eAAT,CAAyBH,MAAzB;AACD,GALiB;AAMpB,GAACP,OAAO,CAACW,aAAT,GAA0BL,QAAD,IACtBM,GAAD,IAAS;AACPN,IAAAA,QAAQ,CAACE,SAAT,CAAmBK,IAAnB,CAAwBC,SAAxB,GAAoCF,GAAG,CAACL,MAAJ,CAAWO,SAA/C;AACAR,IAAAA,QAAQ,CAACS,eAAT,CAAyBH,GAAG,CAACL,MAA7B;AACD,GAViB;AAWpB,GAACP,OAAO,CAACgB,e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O,CAACb,SAAR,IAAqB,CAAC,KAAKhE,SAAL,CAAekE,kBAAf,CAAkCW,OAAO,CAACb,SAA1C,CAA1B,EAAgF,MAAM,IAAInB,KAAJ,CAAW,qCAAoCgC,OAAO,CAACb,SAAU,EAAjE,CAAN;AAChF,YAAMS,GAAG,GAAG,EAAE,GAAG,KAAKtF,EAAL,CAAQ4D,QAAb;AAAuB,WAAG8B;AAA1B,OAAZ;;AACA,UAAI,CAACJ,GAAG,CAACzB,eAAT,EAA0B;AACxB,cAAM8B,MAAM,GAAG,MAAM,KAAKP,eAAL,CAAqBC,EAArB,EAAyB;AAAER,UAAAA,SAAS,EAAES,GAAG,CAACT;AAAjB,SAAzB,CAArB;AACA,eAAO,KAAKe,eAAL,CAAqBD,MAArB,EAA6BL,GAA7B,CAAP;AACD;;AACD,aAAO,KAAKzE,SAAL,CAAeoE,OAAf,CACL5E,OAAO,CAACoB,IAAR,CAAaW,IADR,EAEL;AAAEyC,QAAAA,SAAS,EAAES,GAAG,CAACT,SAAjB;AAA4BQ,QAAAA,EAA5B;AAAgCE,QAAAA,YAAY,EAAE,KAA9C;AAAqDpE,QAAAA,SAAS,EAAE,KAAKiD,YAAL;AAAhE,OAFK,CAAP;AAID;;AAjJM;AA7Be,CAAX,CAAf","sourcesContent":["/**\n * RPC handler for AEPP side\n *\n * @module @aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/aepp-rpc\n * @export AeppRpc\n * @example\n * import ContentScriptBridge\n * from '@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/aepp-rpc'\n */\nimport { v4 as uuid } from 'uuid'\nimport Ae from '../../../ae'\nimport RpcClient from './rpc-client'\nimport { getHandler, message, voidFn } from '../helpers'\nimport { METHODS, RPC_STATUS, VERSION } from '../schema'\n\nconst NOTIFICATIONS = {\n [METHODS.wallet.updateAddress]: (instance) =>\n ({ params }) => {\n instance.rpcClient.accounts = params\n instance.onAddressChange(params)\n },\n [METHODS.updateNetwork]: (instance) =>\n (msg) => {\n instance.rpcClient.info.networkId = msg.params.networkId\n instance.onNetworkChange(msg.params)\n },\n [METHODS.closeConnection]: (instance) =>\n (msg) => {\n instance.disconnectWallet()\n instance.onDisconnect(msg.params)\n }\n}\n\nconst RESPONSES = {\n [METHODS.aepp.address]: (instance) =>\n (msg) => instance.rpcClient.processResponse(msg),\n [METHODS.aepp.connect]: (instance) =>\n (msg) => {\n if (msg.result) instance.rpcClient.info.status = RPC_STATUS.CONNECTED\n instance.rpcClient.processResponse(msg)\n },\n [METHODS.aepp.subscribeAddress]: (instance) =>\n (msg) => {\n if (msg.result) {\n if (msg.result.address) {\n instance.rpcClient.accounts = msg.result.address\n }\n if (msg.result.subscription) {\n instance.rpcClient.addressSubscription = msg.result.subscription\n }\n }\n\n instance.rpcClient.processResponse(msg, ({ id, result }) => [result])\n },\n [METHODS.aepp.sign]: (instance) =>\n (msg) => {\n instance.rpcClient.processResponse(\n msg, ({ id, result }) => [result.signedTransaction || result.transactionHash]\n )\n },\n [METHODS.aepp.signMessage]: (instance) =>\n (msg) => {\n instance.rpcClient.processResponse(msg, ({ id, result }) => [result.signature])\n }\n}\n\nconst REQUESTS = {}\n\nconst handleMessage = (instance) => async (msg) => {\n if (!msg.id) {\n return getHandler(NOTIFICATIONS, msg, { debug: instance.debug })(instance)(msg)\n } else if (Object.prototype.hasOwnProperty.call(instance.rpcClient.callbacks, msg.id)) {\n return getHandler(RESPONSES, msg, { debug: instance.debug })(instance)(msg)\n } else {\n return getHandler(REQUESTS, msg, { debug: instance.debug })(instance)(msg)\n }\n}\n\n/**\n * Contain functionality for wallet interaction and connect it to sdk\n * @alias module:@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/aepp-rpc\n * @function\n * @rtype Stamp\n * @param {Object} param Init params object\n * @param {String=} [param.name] Aepp name\n * @param {Function} onAddressChange Call-back function for update address event\n * @param {Function} onDisconnect Call-back function for disconnect event\n * @param {Function} onNetworkChange Call-back function for update network event\n * @param {Object} connection Wallet connection object\n * @return {Object}\n */\nexport default Ae.compose({\n async init ({\n name,\n onAddressChange = voidFn,\n onDisconnect = voidFn,\n onNetworkChange = voidFn,\n connection,\n forceValidation = false,\n debug = false\n }) {\n const eventsHandlers = ['onDisconnect', 'onAddressChange', 'onNetworkChange']\n this.connection = connection\n this.name = name\n this.debug = debug\n\n if (connection) {\n // Init RPCClient\n await this.connectToWallet(connection)\n }\n // Event callbacks\n this.onDisconnect = onDisconnect\n this.onAddressChange = onAddressChange\n this.onNetworkChange = onNetworkChange\n // validation\n eventsHandlers.forEach(event => {\n if (!forceValidation && typeof this[event] !== 'function') throw new Error(`Call-back for ${event} must be an function!`)\n })\n },\n deepProps: { Ae: { defaults: { walletBroadcast: true } } },\n methods: {\n sign () {\n },\n addresses () {\n if (!this.rpcClient.currentAccount) throw new Error('You are not subscribed for an account.')\n return [this.rpcClient.currentAccount, ...Object.keys(this.rpcClient.accounts.connected)]\n },\n /**\n * Connect to wallet\n * @function connectToWallet\n * @instance\n * @rtype (connection: Object) => void\n * @param {Object} connection Wallet connection object\n * @return {void}\n */\n async connectToWallet (connection) {\n if (this.rpcClient && this.rpcClient.isConnected()) throw new Error('You are already connected to wallet ' + this.rpcClient)\n this.rpcClient = RpcClient({\n connection,\n networkId: this.getNetworkId({ force: true }),\n ...connection.connectionInfo,\n id: uuid(),\n handlers: [handleMessage(this), this.onDisconnect]\n })\n return this.sendConnectRequest()\n },\n /**\n * Disconnect from wallet\n * @function disconnectWallet\n * @instance\n * @rtype (force: Boolean = false) => void\n * @param {Boolean} sendDisconnect=false Force sending close connection message\n * @return {void}\n */\n async disconnectWallet (sendDisconnect = true) {\n if (!this.rpcClient || !this.rpcClient.isConnected()) throw new Error('You are not connected to Wallet')\n sendDisconnect && this.rpcClient.sendMessage(message(METHODS.closeConnection, { reason: 'bye' }), true)\n this.rpcClient.disconnect()\n this.rpcClient = null\n },\n async address ({ onAccount } = {}) {\n if (!this.rpcClient || !this.rpcClient.isConnected()) throw new Error('You are not connected to Wallet')\n const current = this.rpcClient.currentAccount\n if (!current) throw new Error('You are not subscribed for an account.')\n if (onAccount && !this.rpcClient.hasAccessToAccount(onAccount)) throw new Error(`You do not have access to account ${onAccount}`)\n return onAccount || current\n },\n /**\n * Ask address from wallet\n * @function askAddresses\n * @instance\n * @rtype () => Promise\n * @return {Promise} Address from wallet\n */\n async askAddresses () {\n if (!this.rpcClient || !this.rpcClient.isConnected()) throw new Error('You are not connected to Wallet')\n if (!this.rpcClient.currentAccount) throw new Error('You are not subscribed for an account.')\n return this.rpcClient.request(METHODS.aepp.address)\n },\n /**\n * Subscribe for addresses from wallet\n * @function subscribeAddress\n * @instance\n * @rtype (type: String, value: String) => Promise\n * @param {String} type Should be one of 'current' (the selected account), 'connected' (all)\n * @param {String} value Subscription action('subscribe'|'unsubscribe')\n * @return {Promise} Address from wallet\n */\n async subscribeAddress (type, value) {\n if (!this.rpcClient || !this.rpcClient.isConnected()) throw new Error('You are not connected to Wallet')\n return this.rpcClient.request(METHODS.aepp.subscribeAddress, { type, value })\n },\n /**\n * Overwriting of `signTransaction` AE method\n * All sdk API which use it will be send notification to wallet and wait for callBack\n * @function signTransaction\n * @instance\n * @rtype (tx: String, options = {}) => Promise\n * @return {Promise<String>} Signed transaction\n */\n async signTransaction (tx, opt = {}) {\n if (!this.rpcClient || !this.rpcClient.isConnected()) throw new Error('You are not connected to Wallet')\n if (!this.rpcClient.currentAccount) throw new Error('You are not subscribed for an account.')\n if (opt.onAccount && !this.rpcClient.hasAccessToAccount(opt.onAccount)) throw new Error(`You do not have access to account ${opt.onAccount}`)\n return this.rpcClient.request(\n METHODS.aepp.sign,\n { ...opt, tx, returnSigned: true, networkId: this.getNetworkId() }\n )\n },\n /**\n * Overwriting of `signMessage` AE method\n * All sdk API which use it will be send notification to wallet and wait for callBack\n * @function signMessage\n * @instance\n * @rtype (msg: String, options = {}) => Promise\n * @return {Promise<String>} Signed transaction\n */\n async signMessage (msg, opt = {}) {\n if (!this.rpcClient || !this.rpcClient.isConnected()) throw new Error('You are not connected to Wallet')\n if (!this.rpcClient.currentAccount) throw new Error('You are not subscribed for an account.')\n if (opt.onAccount && !this.rpcClient.hasAccessToAccount(opt.onAccount)) throw new Error(`You do not have access to account ${opt.onAccount}`)\n return this.rpcClient.request(METHODS.aepp.signMessage, { ...opt, message: msg })\n },\n /**\n * Send connection request to wallet\n * @function sendConnectRequest\n * @instance\n * @rtype () => Promise\n * @return {Promise} Connection response\n */\n async sendConnectRequest () {\n return this.rpcClient.request(\n METHODS.aepp.connect, {\n name: this.name,\n version: VERSION,\n networkId: this.getNetworkId({ force: true })\n }\n )\n },\n /**\n * Overwriting of `send` AE method\n * All sdk API which use it will be send notification to wallet and wait for callBack\n * This method will sign, broadcast and wait until transaction will be accepted using rpc\n * communication with wallet\n * @function send\n * @instance\n * @rtype (tx: String, options = {}) => Promise\n * @param {String} tx\n * @param {Object} [options={}]\n * @param {Object} [options.walletBroadcast=true]\n * @return {Promise<Object>} Transaction broadcast result\n */\n async send (tx, options = {}) {\n if (!this.rpcClient || !this.rpcClient.isConnected()) throw new Error('You are not connected to Wallet')\n if (!this.rpcClient.currentAccount) throw new Error('You are not subscribed for an account.')\n if (options.onAccount && !this.rpcClient.hasAccessToAccount(options.onAccount)) throw new Error(`You do not have access to account ${options.onAccount}`)\n const opt = { ...this.Ae.defaults, ...options }\n if (!opt.walletBroadcast) {\n const signed = await this.signTransaction(tx, { onAccount: opt.onAccount })\n return this.sendTransaction(signed, opt)\n }\n return this.rpcClient.request(\n METHODS.aepp.sign,\n { onAccount: opt.onAccount, tx, returnSigned: false, networkId: this.getNetworkId() }\n )\n }\n }\n})\n"],"file":"aepp-rpc.js"}
@@ -1,270 +0,0 @@
1
- /**
2
- * RpcClient module
3
- *
4
- * @module @aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/rpc-client
5
- * @export { RpcClient, RpcClients }
6
- * @example
7
- * import RpcClient from '@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/rpc-client'
8
- */
9
- import stampit from '@stamp/it';
10
- import { METHODS, RPC_STATUS, SUBSCRIPTION_TYPES } from '../schema';
11
- import { sendMessage, message, isValidAccounts } from '../helpers';
12
- /**
13
- * Contain functionality for using RPC conection
14
- * @alias module:@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/rpc-client
15
- * @function
16
- * @rtype Stamp
17
- * @param {Object} param Init params object
18
- * @param {String} param.name Client name
19
- * @param {Object} param.connection Connection object
20
- * @param {Function[]} param.handlers Array with two function for message handling
21
- * @param {Function} param.handlers[0] Message handler
22
- * @param {Function} param.handlers[1] Disconnect callback
23
- * @return {Object}
24
- */
25
-
26
- export default stampit({
27
- init(_ref) {
28
- let {
29
- id,
30
- name,
31
- networkId,
32
- icons,
33
- connection,
34
- handlers: [onMessage, onDisconnect]
35
- } = _ref;
36
- this.id = id;
37
- this.connection = connection;
38
- this.info = {
39
- name,
40
- networkId,
41
- icons
42
- }; // {
43
- // [msg.id]: { resolve, reject }
44
- // }
45
-
46
- this.callbacks = {}; // ['connected', 'current']
47
-
48
- this.addressSubscription = []; // {
49
- // connected: { [pub]: {...meta} },
50
- // current: { [pub]: {...meta} }
51
- // }
52
-
53
- this.accounts = {};
54
- this.sendMessage = sendMessage(this.connection);
55
-
56
- const handleMessage = (msg, origin) => {
57
- if (!msg || !msg.jsonrpc || msg.jsonrpc !== '2.0' || !msg.method) {
58
- throw new Error(`Received invalid message: ${msg}`);
59
- }
60
-
61
- onMessage(msg, origin);
62
- };
63
-
64
- const disconnect = (aepp, connection) => {
65
- this.disconnect(true);
66
- typeof onDisconnect === 'function' && onDisconnect(connection, this);
67
- };
68
-
69
- connection.connect(handleMessage, disconnect);
70
- },
71
-
72
- propertyDescriptors: {
73
- currentAccount: {
74
- enumerable: true,
75
- configurable: false,
76
-
77
- get() {
78
- return this.isHasAccounts() ? Object.keys(this.accounts.current)[0] : undefined;
79
- }
80
-
81
- },
82
- addresses: {
83
- enumerable: true,
84
- configurable: false,
85
-
86
- get() {
87
- return this.isHasAccounts() ? [...Object.keys(this.accounts.current), ...Object.keys(this.accounts.connected)] : [];
88
- }
89
-
90
- },
91
- origin: {
92
- enumerable: true,
93
- configurable: false,
94
-
95
- get() {
96
- return this.connection;
97
- }
98
-
99
- }
100
- },
101
- methods: {
102
- /**
103
- * Update info
104
- * @function updateInfo
105
- * @instance
106
- * @rtype (info: Object) => void
107
- * @param {Object} info Info to update (will be merged with current info object)
108
- * @return {void}
109
- */
110
- updateInfo(info) {
111
- Object.assign(this.info, info);
112
- },
113
-
114
- isHasAccounts() {
115
- return typeof this.accounts === 'object' && typeof this.accounts.connected === 'object' && typeof this.accounts.current === 'object';
116
- },
117
-
118
- isSubscribed() {
119
- return this.addressSubscription.length && this.isHasAccounts();
120
- },
121
-
122
- /**
123
- * Check if aepp has access to account
124
- * @function hasAccessToAccount
125
- * @instance
126
- * @rtype (address: String) => Boolean
127
- * @param {String} address Account address
128
- * @return {Boolean} is connected
129
- */
130
- hasAccessToAccount(address) {
131
- return !!address && this.addresses.find(a => a === address);
132
- },
133
-
134
- /**
135
- * Check if is connected
136
- * @function isConnected
137
- * @instance
138
- * @rtype () => Boolean
139
- * @return {Boolean} is connected
140
- */
141
- isConnected() {
142
- return this.connection.isConnected() && this.info.status === RPC_STATUS.CONNECTED;
143
- },
144
-
145
- /**
146
- * Get selected account
147
- * @function getCurrentAccount
148
- * @instance
149
- * @rtype ({ onAccount } = {}) => String
150
- * @param {Object} options Options
151
- * @return {String}
152
- */
153
- getCurrentAccount() {
154
- let {
155
- onAccount
156
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
157
- return onAccount || Object.keys(this.accounts.current)[0];
158
- },
159
-
160
- /**
161
- * Disconnect
162
- * @function disconnect
163
- * @instance
164
- * @rtype () => void
165
- * @return {void}
166
- */
167
- disconnect() {
168
- let forceConnectionClose = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
169
- this.info.status = RPC_STATUS.DISCONNECTED;
170
- this.addressSubscription = [];
171
- this.accounts = {};
172
- forceConnectionClose || this.connection.disconnect();
173
- },
174
-
175
- /**
176
- * Update accounts and sent `update.address` notification to AEPP
177
- * @param {{ current: Object, connected: Object }} accounts Current and connected accounts
178
- * @param {Object} [options]
179
- * @param {Boolean} [options.forceNotification] Don't sent update notification to AEPP
180
- */
181
- setAccounts(accounts) {
182
- let {
183
- forceNotification
184
- } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
185
-
186
- if (!isValidAccounts(accounts)) {
187
- throw new Error('Invalid accounts object. Should be object like: `{ connected: {}, selected: {} }`');
188
- }
189
-
190
- this.accounts = accounts;
191
-
192
- if (!forceNotification) {
193
- // Sent notification about account updates
194
- this.sendMessage(message(METHODS.wallet.updateAddress, this.accounts), true);
195
- }
196
- },
197
-
198
- /**
199
- * Update subscription
200
- * @function updateSubscription
201
- * @instance
202
- * @rtype (type: String, value: String) => void
203
- * @param {String} type Subscription type
204
- * @param {String} value Subscription value
205
- * @return {String[]}
206
- */
207
- updateSubscription(type, value) {
208
- if (type === SUBSCRIPTION_TYPES.subscribe && !this.addressSubscription.includes(value)) {
209
- this.addressSubscription.push(value);
210
- }
211
-
212
- if (type === SUBSCRIPTION_TYPES.unsubscribe && this.addressSubscription.includes(value)) {
213
- this.addressSubscription = this.addressSubscription.filter(s => s !== value);
214
- }
215
-
216
- return this.addressSubscription;
217
- },
218
-
219
- /**
220
- * Make a request
221
- * @function request
222
- * @instance
223
- * @rtype (name: String, params: Object) => Promise
224
- * @param {String} name Method name
225
- * @param {Object} params Method params
226
- * @return {Promise} Promise which will be resolved after receiving response message
227
- */
228
- request(name, params) {
229
- const msgId = this.sendMessage(message(name, params));
230
- if (Object.prototype.hasOwnProperty.call(this.callbacks, msgId)) throw new Error('Callback Already exist');
231
- return new Promise((resolve, reject) => {
232
- this.callbacks[msgId] = {
233
- resolve,
234
- reject
235
- };
236
- });
237
- },
238
-
239
- /**
240
- * Process response message
241
- * @function processResponse
242
- * @instance
243
- * @rtype (msg: Object, transformResult: Function) => void
244
- * @param {Object} msg Message object
245
- * @param {Function=} transformResult Optional parser function for message
246
- * @return {void}
247
- */
248
- processResponse(_ref2, transformResult) {
249
- let {
250
- id,
251
- error,
252
- result
253
- } = _ref2;
254
- if (!this.callbacks[id]) throw new Error(`Can't find callback for this messageId ${id}`);
255
-
256
- if (result) {
257
- this.callbacks[id].resolve(...(typeof transformResult === 'function' ? transformResult({
258
- id,
259
- result
260
- }) : [result]));
261
- } else {
262
- this.callbacks[id].reject(error);
263
- }
264
-
265
- delete this.callbacks[id];
266
- }
267
-
268
- }
269
- });
270
- //# sourceMappingURL=rpc-client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/utils/aepp-wallet-communication/rpc/rpc-client.js"],"names":["stampit","METHODS","RPC_STATUS","SUBSCRIPTION_TYPES","sendMessage","message","isValidAccounts","init","id","name","networkId","icons","connection","handlers","onMessage","onDisconnect","info","callbacks","addressSubscription","accounts","handleMessage","msg","origin","jsonrpc","method","Error","disconnect","aepp","connect","propertyDescriptors","currentAccount","enumerable","configurable","get","isHasAccounts","Object","keys","current","undefined","addresses","connected","methods","updateInfo","assign","isSubscribed","length","hasAccessToAccount","address","find","a","isConnected","status","CONNECTED","getCurrentAccount","onAccount","forceConnectionClose","DISCONNECTED","setAccounts","forceNotification","wallet","updateAddress","updateSubscription","type","value","subscribe","includes","push","unsubscribe","filter","s","request","params","msgId","prototype","hasOwnProperty","call","Promise","resolve","reject","processResponse","transformResult","error","result"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,OAAP,MAAoB,WAApB;AAEA,SAASC,OAAT,EAAkBC,UAAlB,EAA8BC,kBAA9B,QAAwD,WAAxD;AACA,SAASC,WAAT,EAAsBC,OAAtB,EAA+BC,eAA/B,QAAsD,YAAtD;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAeN,OAAO,CAAC;AACrBO,EAAAA,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X,SAAxB;AACD,OAFM,CAAP;AAGD,KAlHM;;AAmHP;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACIC,IAAAA,eAAe,QAAyBC,eAAzB,EAA0C;AAAA,UAAxC;AAAExE,QAAAA,EAAF;AAAMyE,QAAAA,KAAN;AAAaC,QAAAA;AAAb,OAAwC;AACvD,UAAI,CAAC,KAAKjE,SAAL,CAAeT,EAAf,CAAL,EAAyB,MAAM,IAAIiB,KAAJ,CAAW,0CAAyCjB,EAAG,EAAvD,CAAN;;AACzB,UAAI0E,MAAJ,EAAY;AACV,aAAKjE,SAAL,CAAeT,EAAf,EAAmBqE,OAAnB,CAA2B,IAAG,OAAOG,eAAP,KAA2B,UAA3B,GAC1BA,eAAe,CAAC;AAAExE,UAAAA,EAAF;AAAM0E,UAAAA;AAAN,SAAD,CADW,GAE1B,CAACA,MAAD,CAFuB,CAA3B;AAGD,OAJD,MAIO;AACL,aAAKjE,SAAL,CAAeT,EAAf,EAAmBsE,MAAnB,CAA0BG,KAA1B;AACD;;AACD,aAAO,KAAKhE,SAAL,CAAeT,EAAf,CAAP;AACD;;AAtIM;AA5DY,CAAD,CAAtB","sourcesContent":["/**\n * RpcClient module\n *\n * @module @aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/rpc-client\n * @export { RpcClient, RpcClients }\n * @example\n * import RpcClient from '@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/rpc-client'\n */\nimport stampit from '@stamp/it'\n\nimport { METHODS, RPC_STATUS, SUBSCRIPTION_TYPES } from '../schema'\nimport { sendMessage, message, isValidAccounts } from '../helpers'\n\n/**\n * Contain functionality for using RPC conection\n * @alias module:@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/rpc-client\n * @function\n * @rtype Stamp\n * @param {Object} param Init params object\n * @param {String} param.name Client name\n * @param {Object} param.connection Connection object\n * @param {Function[]} param.handlers Array with two function for message handling\n * @param {Function} param.handlers[0] Message handler\n * @param {Function} param.handlers[1] Disconnect callback\n * @return {Object}\n */\nexport default stampit({\n init ({ id, name, networkId, icons, connection, handlers: [onMessage, onDisconnect] }) {\n this.id = id\n this.connection = connection\n this.info = { name, networkId, icons }\n // {\n // [msg.id]: { resolve, reject }\n // }\n this.callbacks = {}\n // ['connected', 'current']\n this.addressSubscription = []\n // {\n // connected: { [pub]: {...meta} },\n // current: { [pub]: {...meta} }\n // }\n this.accounts = {}\n\n this.sendMessage = sendMessage(this.connection)\n\n const handleMessage = (msg, origin) => {\n if (!msg || !msg.jsonrpc || msg.jsonrpc !== '2.0' || !msg.method) {\n throw new Error(`Received invalid message: ${msg}`)\n }\n onMessage(msg, origin)\n }\n\n const disconnect = (aepp, connection) => {\n this.disconnect(true)\n typeof onDisconnect === 'function' && onDisconnect(connection, this)\n }\n\n connection.connect(handleMessage, disconnect)\n },\n propertyDescriptors: {\n currentAccount: {\n enumerable: true,\n configurable: false,\n get () {\n return this.isHasAccounts()\n ? Object.keys(this.accounts.current)[0]\n : undefined\n }\n },\n addresses: {\n enumerable: true,\n configurable: false,\n get () {\n return this.isHasAccounts()\n ? [...Object.keys(this.accounts.current), ...Object.keys(this.accounts.connected)]\n : []\n }\n },\n origin: {\n enumerable: true,\n configurable: false,\n get () {\n return this.connection\n }\n }\n },\n methods: {\n /**\n * Update info\n * @function updateInfo\n * @instance\n * @rtype (info: Object) => void\n * @param {Object} info Info to update (will be merged with current info object)\n * @return {void}\n */\n updateInfo (info) {\n Object.assign(this.info, info)\n },\n isHasAccounts () {\n return typeof this.accounts === 'object' &&\n typeof this.accounts.connected === 'object' &&\n typeof this.accounts.current === 'object'\n },\n isSubscribed () {\n return this.addressSubscription.length && this.isHasAccounts()\n },\n /**\n * Check if aepp has access to account\n * @function hasAccessToAccount\n * @instance\n * @rtype (address: String) => Boolean\n * @param {String} address Account address\n * @return {Boolean} is connected\n */\n hasAccessToAccount (address) {\n return !!address && this.addresses.find(a => a === address)\n },\n /**\n * Check if is connected\n * @function isConnected\n * @instance\n * @rtype () => Boolean\n * @return {Boolean} is connected\n */\n isConnected () {\n return this.connection.isConnected() && this.info.status === RPC_STATUS.CONNECTED\n },\n /**\n * Get selected account\n * @function getCurrentAccount\n * @instance\n * @rtype ({ onAccount } = {}) => String\n * @param {Object} options Options\n * @return {String}\n */\n getCurrentAccount ({ onAccount } = {}) {\n return onAccount || Object.keys(this.accounts.current)[0]\n },\n /**\n * Disconnect\n * @function disconnect\n * @instance\n * @rtype () => void\n * @return {void}\n */\n disconnect (forceConnectionClose = false) {\n this.info.status = RPC_STATUS.DISCONNECTED\n this.addressSubscription = []\n this.accounts = {}\n forceConnectionClose || this.connection.disconnect()\n },\n /**\n * Update accounts and sent `update.address` notification to AEPP\n * @param {{ current: Object, connected: Object }} accounts Current and connected accounts\n * @param {Object} [options]\n * @param {Boolean} [options.forceNotification] Don't sent update notification to AEPP\n */\n setAccounts (accounts, { forceNotification } = {}) {\n if (!isValidAccounts(accounts)) {\n throw new Error('Invalid accounts object. Should be object like: `{ connected: {}, selected: {} }`')\n }\n this.accounts = accounts\n if (!forceNotification) {\n // Sent notification about account updates\n this.sendMessage(message(METHODS.wallet.updateAddress, this.accounts), true)\n }\n },\n /**\n * Update subscription\n * @function updateSubscription\n * @instance\n * @rtype (type: String, value: String) => void\n * @param {String} type Subscription type\n * @param {String} value Subscription value\n * @return {String[]}\n */\n updateSubscription (type, value) {\n if (type === SUBSCRIPTION_TYPES.subscribe && !this.addressSubscription.includes(value)) {\n this.addressSubscription.push(value)\n }\n if (type === SUBSCRIPTION_TYPES.unsubscribe && this.addressSubscription.includes(value)) {\n this.addressSubscription = this.addressSubscription.filter(s => s !== value)\n }\n return this.addressSubscription\n },\n /**\n * Make a request\n * @function request\n * @instance\n * @rtype (name: String, params: Object) => Promise\n * @param {String} name Method name\n * @param {Object} params Method params\n * @return {Promise} Promise which will be resolved after receiving response message\n */\n request (name, params) {\n const msgId = this.sendMessage(message(name, params))\n if (Object.prototype.hasOwnProperty.call(this.callbacks, msgId)) throw new Error('Callback Already exist')\n return new Promise((resolve, reject) => {\n this.callbacks[msgId] = { resolve, reject }\n })\n },\n /**\n * Process response message\n * @function processResponse\n * @instance\n * @rtype (msg: Object, transformResult: Function) => void\n * @param {Object} msg Message object\n * @param {Function=} transformResult Optional parser function for message\n * @return {void}\n */\n processResponse ({ id, error, result }, transformResult) {\n if (!this.callbacks[id]) throw new Error(`Can't find callback for this messageId ${id}`)\n if (result) {\n this.callbacks[id].resolve(...typeof transformResult === 'function'\n ? transformResult({ id, result })\n : [result])\n } else {\n this.callbacks[id].reject(error)\n }\n delete this.callbacks[id]\n }\n }\n})\n"],"file":"rpc-client.js"}