@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,980 +0,0 @@
1
- /*
2
- * ISC License (ISC)
3
- * Copyright (c) 2018 aeternity developers
4
- *
5
- * Permission to use, copy, modify, and/or distribute this software for any
6
- * purpose with or without fee is hereby granted, provided that the above
7
- * copyright notice and this permission notice appear in all copies.
8
- *
9
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
- * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
- * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
- * PERFORMANCE OF THIS SOFTWARE.
16
- */
17
-
18
- /**
19
- * Channel module
20
- * @module @aeternity/aepp-sdk/es/channel/index
21
- * @export Channel
22
- * @example import { Channel } from '@aeternity/aepp-sdk'
23
- */
24
- import AsyncInit from '../utils/async-init';
25
- import { snakeToPascal } from '../utils/string';
26
- import { buildTx, unpackTx } from '../tx/builder';
27
- import { TX_TYPE } from '../tx/builder/schema';
28
- import * as handlers from './handlers';
29
- import { eventEmitters, status as channelStatus, state as channelState, initialize, enqueueAction, send, channelId, call, disconnect as channelDisconnect, fsmId as channelFsmId } from './internal';
30
-
31
- function snakeToPascalObjKeys(obj) {
32
- return Object.entries(obj).reduce((result, _ref) => {
33
- let [key, val] = _ref;
34
- return { ...result,
35
- [snakeToPascal(key)]: val
36
- };
37
- }, {});
38
- }
39
- /**
40
- * Register event listener function
41
- *
42
- * Possible events:
43
- *
44
- * - "error"
45
- * - "onChainTx"
46
- * - "ownWithdrawLocked"
47
- * - "withdrawLocked"
48
- * - "ownDepositLocked"
49
- * - "depositLocked"
50
- *
51
- * @param {String} event - Event name
52
- * @param {Function} callback - Callback function
53
- */
54
-
55
-
56
- function on(event, callback) {
57
- eventEmitters.get(this).on(event, callback);
58
- }
59
- /**
60
- * Remove event listener function
61
- *
62
- * @param {String} event - Event name
63
- * @param {Function} callback - Callback function
64
- */
65
-
66
-
67
- function off(event, callback) {
68
- eventEmitters.get(this).removeListener(event, callback);
69
- }
70
- /**
71
- * Close the connection
72
- */
73
-
74
-
75
- function disconnect() {
76
- return channelDisconnect(this);
77
- }
78
- /**
79
- * Get current status
80
- *
81
- * @return {String}
82
- */
83
-
84
-
85
- function status() {
86
- return channelStatus.get(this);
87
- }
88
- /**
89
- * Get current state
90
- *
91
- * @return {Promise<Object>}
92
- */
93
-
94
-
95
- async function state() {
96
- return snakeToPascalObjKeys(await call(this, 'channels.get.offchain_state', {}));
97
- }
98
- /**
99
- * Get current round
100
- *
101
- * If round cannot be determined (for example when channel has not been opened)
102
- * it will return `null`.
103
- *
104
- * @return {Number}
105
- */
106
-
107
-
108
- function round() {
109
- const state = channelState.get(this);
110
-
111
- if (!state) {
112
- return null;
113
- }
114
-
115
- const {
116
- txType,
117
- tx
118
- } = unpackTx(channelState.get(this)).tx.encodedTx;
119
-
120
- switch (txType) {
121
- case TX_TYPE.channelCreate:
122
- return 1;
123
-
124
- case TX_TYPE.channelOffChain:
125
- case TX_TYPE.channelWithdraw:
126
- case TX_TYPE.channelDeposit:
127
- return parseInt(tx.round, 10);
128
-
129
- default:
130
- return null;
131
- }
132
- }
133
- /**
134
- * Get channel id
135
- *
136
- * @return {String}
137
- */
138
-
139
-
140
- function id() {
141
- return channelId.get(this);
142
- }
143
- /**
144
- * Get channel's fsm id
145
- *
146
- * @return {String}
147
- */
148
-
149
-
150
- function fsmId() {
151
- return channelFsmId.get(this);
152
- }
153
- /**
154
- * Trigger a transfer update
155
- *
156
- * The transfer update is moving tokens from one channel account to another.
157
- * The update is a change to be applied on top of the latest state.
158
- *
159
- * Sender and receiver are the channel parties. Both the initiator and responder
160
- * can take those roles. Any public key outside of the channel is considered invalid.
161
- *
162
- * @param {String} from - Sender's public address
163
- * @param {String} to - Receiver's public address
164
- * @param {Number} amount - Transaction amount
165
- * @param {Function} sign - Function which verifies and signs offchain transaction
166
- * @param {Array<String>} metadata
167
- * @return {Promise<Object>}
168
- * @example channel.update(
169
- * 'ak_Y1NRjHuoc3CGMYMvCmdHSBpJsMDR6Ra2t5zjhRcbtMeXXLpLH',
170
- * 'ak_V6an1xhec1xVaAhLuak7QoEbi6t7w5hEtYWp9bMKaJ19i6A9E',
171
- * 10,
172
- * async (tx) => await account.signTransaction(tx)
173
- * ).then(({ accepted, signedTx }) =>
174
- * if (accepted) {
175
- * console.log('Update has been accepted')
176
- * }
177
- * )
178
- */
179
-
180
-
181
- function update(from, to, amount, sign, metadata) {
182
- return new Promise((resolve, reject) => {
183
- enqueueAction(this, (channel, state) => state.handler === handlers.channelOpen, (channel, state) => {
184
- send(channel, {
185
- jsonrpc: '2.0',
186
- method: 'channels.update.new',
187
- params: {
188
- from,
189
- to,
190
- amount,
191
- meta: metadata
192
- }
193
- });
194
- return {
195
- handler: handlers.awaitingOffChainTx,
196
- state: {
197
- resolve,
198
- reject,
199
- sign
200
- }
201
- };
202
- });
203
- });
204
- }
205
- /**
206
- * Get proof of inclusion
207
- *
208
- * If a certain address of an account or a contract is not found
209
- * in the state tree - the response is an error.
210
- *
211
- * @param {Object} addresses
212
- * @param {Array<String>} [addresses.accounts] - List of account addresses to include in poi
213
- * @param {Array<String>} [addresses.contracts] - List of contract addresses to include in poi
214
- * @return {Promise<String>}
215
- * @example channel.poi({
216
- * accounts: [
217
- * 'ak_Y1NRjHuoc3CGMYMvCmdHSBpJsMDR6Ra2t5zjhRcbtMeXXLpLH',
218
- * 'ak_V6an1xhec1xVaAhLuak7QoEbi6t7w5hEtYWp9bMKaJ19i6A9E'
219
- * ],
220
- * contracts: ['ct_2dCUAWYZdrWfACz3a2faJeKVTVrfDYxCQHCqAt5zM15f3u2UfA']
221
- * }).then(poi => console.log(poi))
222
- */
223
-
224
-
225
- async function poi(_ref2) {
226
- let {
227
- accounts,
228
- contracts
229
- } = _ref2;
230
- return (await call(this, 'channels.get.poi', {
231
- accounts,
232
- contracts
233
- })).poi;
234
- }
235
- /**
236
- * Get balances
237
- *
238
- * The accounts paramcontains a list of addresses to fetch balances of.
239
- * Those can be either account balances or a contract ones, encoded as an account addresses.
240
- *
241
- * If a certain account address had not being found in the state tree - it is simply
242
- * skipped in the response.
243
- *
244
- * @param {Array<String>} accounts - List of addresses to fetch balances from
245
- * @return {Promise<Object>}
246
- * @example channel.balances([
247
- * 'ak_Y1NRjHuoc3CGMYMvCmdHSBpJsMDR6Ra2t5zjhRcbtMeXXLpLH',
248
- * 'ak_V6an1xhec1xVaAhLuak7QoEbi6t7w5hEtYWp9bMKaJ19i6A9E'
249
- * 'ct_2dCUAWYZdrWfACz3a2faJeKVTVrfDYxCQHCqAt5zM15f3u2UfA'
250
- * ]).then(balances =>
251
- * console.log(balances['ak_Y1NRjHuoc3CGMYMvCmdHSBpJsMDR6Ra2t5zjhRcbtMeXXLpLH'])
252
- * )
253
- */
254
-
255
-
256
- async function balances(accounts) {
257
- return Object.fromEntries((await call(this, 'channels.get.balances', {
258
- accounts
259
- })).map(item => [item.account, item.balance]));
260
- }
261
- /**
262
- * Leave channel
263
- *
264
- * It is possible to leave a channel and then later reestablish the channel
265
- * off-chain state and continue operation. When a leave method is called,
266
- * the channel fsm passes it on to the peer fsm, reports the current mutually
267
- * signed state and then terminates.
268
- *
269
- * The channel can be reestablished by instantiating another Channel instance
270
- * with two extra params: existingChannelId and offchainTx (returned from leave
271
- * method as channelId and signedTx respectively).
272
- *
273
- * @return {Promise<Object>}
274
- * @example channel.leave().then(({ channelId, signedTx }) => {
275
- * console.log(channelId)
276
- * console.log(signedTx)
277
- * })
278
- */
279
-
280
-
281
- function leave() {
282
- return new Promise((resolve, reject) => {
283
- enqueueAction(this, (channel, state) => state.handler === handlers.channelOpen, (channel, state) => {
284
- send(channel, {
285
- jsonrpc: '2.0',
286
- method: 'channels.leave',
287
- params: {}
288
- });
289
- return {
290
- handler: handlers.awaitingLeave,
291
- state: {
292
- resolve,
293
- reject
294
- }
295
- };
296
- });
297
- });
298
- }
299
- /**
300
- * Trigger mutual close
301
- *
302
- * At any moment after the channel is opened, a closing procedure can be triggered.
303
- * This can be done by either of the parties. The process is similar to the off-chain updates.
304
- *
305
- * @param {Function} sign - Function which verifies and signs mutual close transaction
306
- * @return {Promise<String>}
307
- * @example channel.shutdown(
308
- * async (tx) => await account.signTransaction(tx)
309
- * ).then(tx => console.log('on_chain_tx', tx))
310
- */
311
-
312
-
313
- function shutdown(sign) {
314
- return new Promise((resolve, reject) => {
315
- enqueueAction(this, (channel, state) => state.handler === handlers.channelOpen, (channel, state) => {
316
- send(channel, {
317
- jsonrpc: '2.0',
318
- method: 'channels.shutdown',
319
- params: {}
320
- });
321
- return {
322
- handler: handlers.awaitingShutdownTx,
323
- state: {
324
- sign,
325
- resolve,
326
- reject
327
- }
328
- };
329
- });
330
- });
331
- }
332
- /**
333
- * Withdraw tokens from the channel
334
- *
335
- * After the channel had been opened any of the participants can initiate a withdrawal.
336
- * The process closely resembles the update. The most notable difference is that the
337
- * transaction has been co-signed: it is channel_withdraw_tx and after the procedure
338
- * is finished - it is being posted on-chain.
339
- *
340
- * Any of the participants can initiate a withdrawal. The only requirements are:
341
- *
342
- * - Channel is already opened
343
- * - No off-chain update/deposit/withdrawal is currently being performed
344
- * - Channel is not being closed or in a solo closing state
345
- * - The withdrawal amount must be equal to or greater than zero, and cannot exceed
346
- * the available balance on the channel (minus the channel_reserve)
347
- *
348
- * After the other party had signed the withdraw transaction, the transaction is posted
349
- * on-chain and onOnChainTx callback is called with on-chain transaction as first argument.
350
- * After computing transaction hash it can be tracked on the chain: entering the mempool,
351
- * block inclusion and a number of confirmations.
352
- *
353
- * After the minimum_depth block confirmations onOwnWithdrawLocked callback is called
354
- * (without any arguments).
355
- *
356
- * When the other party had confirmed that the block height needed is reached
357
- * onWithdrawLocked callback is called (without any arguments).
358
- *
359
- * @param {Number} amount - Amount of tokens to withdraw
360
- * @param {Function} sign - Function which verifies and signs withdraw transaction
361
- * @param {Object} [callbacks]
362
- * @param {Function} [callbacks.onOnChainTx] - Called when withdraw transaction has been posted
363
- * on chain
364
- * @param {Function} [callbacks.onOwnWithdrawLocked]
365
- * @param {Function} [callbacks.onWithdrawLocked]
366
- * @return {Promise<Object>}
367
- * @example channel.withdraw(
368
- * 100,
369
- * async (tx) => await account.signTransaction(tx),
370
- * { onOnChainTx: (tx) => console.log('on_chain_tx', tx) }
371
- * ).then(({ accepted, signedTx }) => {
372
- * if (accepted) {
373
- * console.log('Withdrawal has been accepted')
374
- * } else {
375
- * console.log('Withdrawal has been rejected')
376
- * }
377
- * })
378
- */
379
-
380
-
381
- function withdraw(amount, sign) {
382
- let {
383
- onOnChainTx,
384
- onOwnWithdrawLocked,
385
- onWithdrawLocked
386
- } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
387
- return new Promise((resolve, reject) => {
388
- enqueueAction(this, (channel, state) => state.handler === handlers.channelOpen, (channel, state) => {
389
- send(channel, {
390
- jsonrpc: '2.0',
391
- method: 'channels.withdraw',
392
- params: {
393
- amount
394
- }
395
- });
396
- return {
397
- handler: handlers.awaitingWithdrawTx,
398
- state: {
399
- sign,
400
- resolve,
401
- reject,
402
- onOnChainTx,
403
- onOwnWithdrawLocked,
404
- onWithdrawLocked
405
- }
406
- };
407
- });
408
- });
409
- }
410
- /**
411
- * Deposit tokens into the channel
412
- *
413
- * After the channel had been opened any of the participants can initiate a deposit.
414
- * The process closely resembles the update. The most notable difference is that the
415
- * transaction has been co-signed: it is channel_deposit_tx and after the procedure
416
- * is finished - it is being posted on-chain.
417
- *
418
- * Any of the participants can initiate a deposit. The only requirements are:
419
- *
420
- * - Channel is already opened
421
- * - No off-chain update/deposit/withdrawal is currently being performed
422
- * - Channel is not being closed or in a solo closing state
423
- * - The deposit amount must be equal to or greater than zero, and cannot exceed
424
- * the available balance on the channel (minus the channel_reserve)
425
- *
426
- * After the other party had signed the deposit transaction, the transaction is posted
427
- * on-chain and onOnChainTx callback is called with on-chain transaction as first argument.
428
- * After computing transaction hash it can be tracked on the chain: entering the mempool,
429
- * block inclusion and a number of confirmations.
430
- *
431
- * After the minimum_depth block confirmations onOwnDepositLocked callback is called
432
- * (without any arguments).
433
- *
434
- * When the other party had confirmed that the block height needed is reached
435
- * onDepositLocked callback is called (without any arguments).
436
- *
437
- * @param {Number} amount - Amount of tokens to deposit
438
- * @param {Function} sign - Function which verifies and signs deposit transaction
439
- * @param {Object} [callbacks]
440
- * @param {Function} [callbacks.onOnChainTx] - Called when deposit transaction has been posted
441
- * on chain
442
- * @param {Function} [callbacks.onOwnDepositLocked]
443
- * @param {Function} [callbacks.onDepositLocked]
444
- * @return {Promise<Object>}
445
- * @example channel.deposit(
446
- * 100,
447
- * async (tx) => await account.signTransaction(tx),
448
- * { onOnChainTx: (tx) => console.log('on_chain_tx', tx) }
449
- * ).then(({ accepted, state }) => {
450
- * if (accepted) {
451
- * console.log('Deposit has been accepted')
452
- * console.log('The new state is:', state)
453
- * } else {
454
- * console.log('Deposit has been rejected')
455
- * }
456
- * })
457
- */
458
-
459
-
460
- function deposit(amount, sign) {
461
- let {
462
- onOnChainTx,
463
- onOwnDepositLocked,
464
- onDepositLocked
465
- } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
466
- return new Promise((resolve, reject) => {
467
- enqueueAction(this, (channel, state) => state.handler === handlers.channelOpen, (channel, state) => {
468
- send(channel, {
469
- jsonrpc: '2.0',
470
- method: 'channels.deposit',
471
- params: {
472
- amount
473
- }
474
- });
475
- return {
476
- handler: handlers.awaitingDepositTx,
477
- state: {
478
- sign,
479
- resolve,
480
- reject,
481
- onOnChainTx,
482
- onOwnDepositLocked,
483
- onDepositLocked
484
- }
485
- };
486
- });
487
- });
488
- }
489
- /**
490
- * Trigger create contract update
491
- *
492
- * The create contract update is creating a contract inside the channel's internal state tree.
493
- * The update is a change to be applied on top of the latest state.
494
- *
495
- * That would create a contract with the poster being the owner of it. Poster commits initially
496
- * a deposit amount of tokens to the new contract.
497
- *
498
- * @param {Object} options
499
- * @param {String} options.code - Api encoded compiled AEVM byte code
500
- * @param {String} options.callData - Api encoded compiled AEVM call data for the code
501
- * @param {Number} options.deposit - Initial amount the owner of the contract commits to it
502
- * @param {Number} options.vmVersion - Version of the Virtual Machine
503
- * @param {Number} options.abiVersion - Version of the Application Binary Interface
504
- * @param {Function} sign - Function which verifies and signs create contract transaction
505
- * @return {Promise<Object>}
506
- * @example channel.createContract({
507
- * code: 'cb_HKtpipK4aCgYb17wZ...',
508
- * callData: 'cb_1111111111111111...',
509
- * deposit: 10,
510
- * vmVersion: 3,
511
- * abiVersion: 1
512
- * }).then(({ accepted, signedTx, address }) => {
513
- * if (accepted) {
514
- * console.log('New contract has been created')
515
- * console.log('Contract address:', address)
516
- * } else {
517
- * console.log('New contract has been rejected')
518
- * }
519
- * })
520
- */
521
-
522
-
523
- function createContract(_ref3, sign) {
524
- let {
525
- code,
526
- callData,
527
- deposit,
528
- vmVersion,
529
- abiVersion
530
- } = _ref3;
531
- return new Promise((resolve, reject) => {
532
- enqueueAction(this, (channel, state) => state.handler === handlers.channelOpen, (channel, state) => {
533
- send(channel, {
534
- jsonrpc: '2.0',
535
- method: 'channels.update.new_contract',
536
- params: {
537
- code,
538
- call_data: callData,
539
- deposit,
540
- vm_version: vmVersion,
541
- abi_version: abiVersion
542
- }
543
- });
544
- return {
545
- handler: handlers.awaitingNewContractTx,
546
- state: {
547
- sign,
548
- resolve,
549
- reject
550
- }
551
- };
552
- });
553
- });
554
- }
555
- /**
556
- * Trigger call a contract update
557
- *
558
- * The call contract update is calling a preexisting contract inside the channel's
559
- * internal state tree. The update is a change to be applied on top of the latest state.
560
- *
561
- * That would call a contract with the poster being the caller of it. Poster commits
562
- * an amount of tokens to the contract.
563
- *
564
- * The call would also create a call object inside the channel state tree. It contains
565
- * the result of the contract call.
566
- *
567
- * It is worth mentioning that the gas is not consumed, because this is an off-chain
568
- * contract call. It would be consumed if it were a on-chain one. This could happen
569
- * if a call with a similar computation amount is to be forced on-chain.
570
- *
571
- * @param {Object} options
572
- * @param {String} [options.amount] - Amount the caller of the contract commits to it
573
- * @param {String} [options.callData] - ABI encoded compiled AEVM call data for the code
574
- * @param {Number} [options.contract] - Address of the contract to call
575
- * @param {Number} [options.abiVersion] - Version of the ABI
576
- * @param {Function} sign - Function which verifies and signs contract call transaction
577
- * @return {Promise<Object>}
578
- * @example channel.callContract({
579
- * contract: 'ct_9sRA9AVE4BYTAkh5RNfJYmwQe1NZ4MErasQLXZkFWG43TPBqa',
580
- * callData: 'cb_1111111111111111...',
581
- * amount: 0,
582
- * abiVersion: 1
583
- * }).then(({ accepted, signedTx }) => {
584
- * if (accepted) {
585
- * console.log('Contract called succesfully')
586
- * } else {
587
- * console.log('Contract call has been rejected')
588
- * }
589
- * })
590
- */
591
-
592
-
593
- function callContract(_ref4, sign) {
594
- let {
595
- amount,
596
- callData,
597
- contract,
598
- abiVersion
599
- } = _ref4;
600
- return new Promise((resolve, reject) => {
601
- enqueueAction(this, (channel, state) => state.handler === handlers.channelOpen, (channel, state) => {
602
- send(channel, {
603
- jsonrpc: '2.0',
604
- method: 'channels.update.call_contract',
605
- params: {
606
- amount,
607
- call_data: callData,
608
- contract_id: contract,
609
- abi_version: abiVersion
610
- }
611
- });
612
- return {
613
- handler: handlers.awaitingCallContractUpdateTx,
614
- state: {
615
- resolve,
616
- reject,
617
- sign
618
- }
619
- };
620
- });
621
- });
622
- }
623
- /**
624
- * Trigger a force progress contract call
625
- * This call is going on-chain
626
- * @param {Object} options
627
- * @param {String} [options.amount] - Amount the caller of the contract commits to it
628
- * @param {String} [options.callData] - ABI encoded compiled AEVM call data for the code
629
- * @param {Number} [options.contract] - Address of the contract to call
630
- * @param {Number} [options.abiVersion] - Version of the ABI
631
- * @param {Number} [options.gasPrice=1000000000] - Gas price
632
- * @param {Number} [options.gas=1000000] - Gas limit
633
- * @param {Function} sign - Function which verifies and signs contract force progress transaction
634
- * @param {{ onOnChainTxL: Function }} callbacks
635
- * @return {Promise<Object>}
636
- * @example channel.forceProgress({
637
- * contract: 'ct_9sRA9AVE4BYTAkh5RNfJYmwQe1NZ4MErasQLXZkFWG43TPBqa',
638
- * callData: 'cb_1111111111111111...',
639
- * amount: 0,
640
- * abiVersion: 1,
641
- * gasPrice: 1000005554
642
- * }).then(({ accepted, signedTx }) => {
643
- * if (accepted) {
644
- * console.log('Contract force progress call successful')
645
- * } else {
646
- * console.log('Contract force progress call has been rejected')
647
- * }
648
- * })
649
- */
650
-
651
-
652
- function forceProgress(_ref5, sign) {
653
- let {
654
- amount,
655
- callData,
656
- contract,
657
- abiVersion,
658
- gas = 1000000,
659
- gasPrice = 1000000000,
660
- nonce
661
- } = _ref5;
662
- let {
663
- onOnChainTx
664
- } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
665
- return new Promise((resolve, reject) => {
666
- enqueueAction(this, (channel, state) => state.handler === handlers.channelOpen, (channel, state) => {
667
- send(channel, {
668
- jsonrpc: '2.0',
669
- method: 'channels.force_progress',
670
- params: {
671
- amount,
672
- call_data: callData,
673
- contract_id: contract,
674
- abi_version: abiVersion,
675
- gas_price: gasPrice,
676
- gas
677
- }
678
- });
679
- return {
680
- handler: handlers.awaitingCallContractForceProgressUpdate,
681
- state: {
682
- resolve,
683
- reject,
684
- sign,
685
- onOnChainTx
686
- }
687
- };
688
- });
689
- });
690
- }
691
- /**
692
- * Call contract using dry-run
693
- *
694
- * In order to get the result of a potential contract call, one might need to
695
- * dry-run a contract call. It takes the exact same arguments as a call would
696
- * and returns the call object.
697
- *
698
- * The call is executed in the channel's state but it does not impact the state
699
- * whatsoever. It uses as an environment the latest channel's state and the current
700
- * top of the blockchain as seen by the node.
701
- *
702
- * @param {Object} options
703
- * @param {String} [options.amount] - Amount the caller of the contract commits to it
704
- * @param {String} [options.callData] - ABI encoded compiled AEVM call data for the code
705
- * @param {Number} [options.contract] - Address of the contract to call
706
- * @param {Number} [options.abiVersion] - Version of the ABI
707
- * @return {Promise<Object>}
708
- * @example channel.callContractStatic({
709
- * contract: 'ct_9sRA9AVE4BYTAkh5RNfJYmwQe1NZ4MErasQLXZkFWG43TPBqa',
710
- * callData: 'cb_1111111111111111...',
711
- * amount: 0,
712
- * abiVersion: 1
713
- * }).then(({ returnValue, gasUsed }) => {
714
- * console.log('Returned value:', returnValue)
715
- * console.log('Gas used:', gasUsed)
716
- * })
717
- */
718
-
719
-
720
- async function callContractStatic(_ref6) {
721
- let {
722
- amount,
723
- callData,
724
- contract,
725
- abiVersion
726
- } = _ref6;
727
- return snakeToPascalObjKeys(await call(this, 'channels.dry_run.call_contract', {
728
- amount,
729
- call_data: callData,
730
- contract_id: contract,
731
- abi_version: abiVersion
732
- }));
733
- }
734
- /**
735
- * Get contract call result
736
- *
737
- * The combination of a caller, contract and a round of execution determines the
738
- * contract call. Providing an incorrect set of those results in an error response.
739
- *
740
- * @param {Object} options
741
- * @param {String} [options.caller] - Address of contract caller
742
- * @param {String} [options.contract] - Address of the contract
743
- * @param {Number} [options.round] - Round when contract was called
744
- * @return {Promise<Object>}
745
- * @example channel.getContractCall({
746
- * caller: 'ak_Y1NRjHuoc3CGMYMvCmdHSBpJsMDR6Ra2t5zjhRcbtMeXXLpLH',
747
- * contract: 'ct_9sRA9AVE4BYTAkh5RNfJYmwQe1NZ4MErasQLXZkFWG43TPBqa',
748
- * round: 3
749
- * }).then(({ returnType, returnValue }) => {
750
- * if (returnType === 'ok') console.log(returnValue)
751
- * })
752
- */
753
-
754
-
755
- async function getContractCall(_ref7) {
756
- let {
757
- caller,
758
- contract,
759
- round
760
- } = _ref7;
761
- return snakeToPascalObjKeys(await call(this, 'channels.get.contract_call', {
762
- caller_id: caller,
763
- contract_id: contract,
764
- round
765
- }));
766
- }
767
- /**
768
- * Get contract latest state
769
- *
770
- * @param {String} contract - Address of the contract
771
- * @return {Promise<Object>}
772
- * @example channel.getContractState(
773
- * 'ct_9sRA9AVE4BYTAkh5RNfJYmwQe1NZ4MErasQLXZkFWG43TPBqa'
774
- * ).then(({ contract }) => {
775
- * console.log('deposit:', contract.deposit)
776
- * })
777
- */
778
-
779
-
780
- async function getContractState(contract) {
781
- const result = await call(this, 'channels.get.contract', {
782
- pubkey: contract
783
- });
784
- return snakeToPascalObjKeys({ ...result,
785
- contract: snakeToPascalObjKeys(result.contract)
786
- });
787
- }
788
- /**
789
- * Clean up all locally stored contract calls
790
- *
791
- * Contract calls are kept locally in order for the participant to be able to look them up.
792
- * They consume memory and in order for the participant to free it - one can prune all messages.
793
- * This cleans up all locally stored contract calls and those will no longer be available for
794
- * fetching and inspection.
795
- *
796
- * @return {Promise}
797
- */
798
-
799
-
800
- function cleanContractCalls() {
801
- return new Promise((resolve, reject) => {
802
- enqueueAction(this, (channel, state) => state.handler === handlers.channelOpen, (channel, state) => {
803
- send(channel, {
804
- jsonrpc: '2.0',
805
- method: 'channels.clean_contract_calls',
806
- params: {}
807
- });
808
- return {
809
- handler: handlers.awaitingCallsPruned,
810
- state: {
811
- resolve,
812
- reject
813
- }
814
- };
815
- });
816
- });
817
- }
818
- /**
819
- * Send generic message
820
- *
821
- * If message is an object it will be serialized into JSON string
822
- * before sending.
823
- *
824
- * If there is ongoing update that has not yet been finished the message
825
- * will be sent after that update is finalized.
826
- *
827
- * @param {String|Object} message
828
- * @param {String} recipient - Address of the recipient
829
- * @example channel.sendMessage(
830
- * 'hello world',
831
- * 'ak_Y1NRjHuoc3CGMYMvCmdHSBpJsMDR6Ra2t5zjhRcbtMeXXLpLH'
832
- * )
833
- */
834
-
835
-
836
- function sendMessage(message, recipient) {
837
- let info = message;
838
-
839
- if (typeof message === 'object') {
840
- info = JSON.stringify(message);
841
- }
842
-
843
- const doSend = channel => send(channel, {
844
- jsonrpc: '2.0',
845
- method: 'channels.message',
846
- params: {
847
- info,
848
- to: recipient
849
- }
850
- });
851
-
852
- if (this.status() === 'connecting') {
853
- const onStatusChanged = status => {
854
- if (status !== 'connecting') {
855
- // For some reason we can't immediately send a message when connection is
856
- // established. Thus we wait 500ms which seems to work.
857
- setTimeout(() => doSend(this), 500);
858
- this.off('statusChanged', onStatusChanged);
859
- }
860
- };
861
-
862
- this.on('statusChanged', onStatusChanged);
863
- } else {
864
- doSend(this);
865
- }
866
- }
867
-
868
- async function reconnect(options, txParams) {
869
- const {
870
- sign
871
- } = options;
872
- return Channel({ ...options,
873
- reconnectTx: await sign('reconnect', buildTx(txParams, TX_TYPE.channelReconnect).tx)
874
- });
875
- }
876
- /**
877
- * Channel
878
- *
879
- * @function
880
- * @alias module:@aeternity/aepp-sdk/es/channel/index
881
- * @rtype Channel
882
- * @param {Object} options - Channel params
883
- * @param {String} options.url - Channel url (for example: "ws://localhost:3001")
884
- * @param {String} options.role - Participant role ("initiator" or "responder")
885
- * @param {String} options.initiatorId - Initiator's public key
886
- * @param {String} options.responderId - Responder's public key
887
- * @param {Number} options.pushAmount - Initial deposit in favour of the responder by the initiator
888
- * @param {Number} options.initiatorAmount - Amount of tokens the initiator has committed to
889
- * the channel
890
- * @param {Number} options.responderAmount - Amount of tokens the responder has committed to
891
- * the channel
892
- * @param {Number} options.channelReserve - The minimum amount both peers need to maintain
893
- * @param {Number} [options.ttl] - Minimum block height to include the channel_create_tx
894
- * @param {String} options.host - Host of the responder's node
895
- * @param {Number} options.port - The port of the responders node
896
- * @param {Number} options.lockPeriod - Amount of blocks for disputing a solo close
897
- * @param {Number} [options.existingChannelId] - Existing channel id (required if reestablishing a
898
- * channel)
899
- * @param {Number} [options.offchainTx] - Offchain transaction (required if reestablishing
900
- * a channel)
901
- * @param {Number} [options.timeoutIdle] - The time waiting for a new event to be initiated
902
- * (default: 600000)
903
- * @param {Number} [options.timeoutFundingCreate] - The time waiting for the initiator to produce
904
- * the create channel transaction after the noise session had been established (default: 120000)
905
- * @param {Number} [options.timeoutFundingSign] - The time frame the other client has to sign an
906
- * off-chain update after our client had initiated and signed it. This applies only for double
907
- * signed on-chain intended updates: channel create transaction, deposit, withdrawal and etc.
908
- * (default: 120000)
909
- * @param {Number} [options.timeoutFundingLock] - The time frame the other client has to confirm an
910
- * on-chain transaction reaching maturity (passing minimum depth) after the local node has detected
911
- * this. This applies only for double signed on-chain intended updates: channel create transaction,
912
- * deposit, withdrawal and etc. (default: 360000)
913
- * @param {Number} [options.timeoutSign] - The time frame the client has to return a signed
914
- * off-chain update or to decline it. This applies for all off-chain updates (default: 500000)
915
- * @param {Number} [options.timeoutAccept] - The time frame the other client has to react to an
916
- * event. This applies for all off-chain updates that are not meant to land on-chain, as well as
917
- * some special cases: opening a noise connection, mutual closing acknowledgement and
918
- * reestablishing an existing channel (default: 120000)
919
- * @param {Number} [options.timeoutInitialized] - the time frame the responder has to accept an
920
- * incoming noise session. Applicable only for initiator (default: timeout_accept's value)
921
- * @param {Number} [options.timeoutAwaitingOpen] - The time frame the initiator has to start an
922
- * outgoing noise session to the responder's node. Applicable only for responder (default:
923
- * timeout_idle's value)
924
- * @param {Number} [options.debug=false] - Log websocket communication
925
- * @param {Function} options.sign - Function which verifies and signs transactions
926
- * @return {Promise<Object>} Channel instance
927
- * @example Channel({
928
- * url: 'ws://localhost:3001',
929
- * role: 'initiator'
930
- * initiatorId: 'ak_Y1NRjHuoc3CGMYMvCmdHSBpJsMDR6Ra2t5zjhRcbtMeXXLpLH',
931
- * responderId: 'ak_V6an1xhec1xVaAhLuak7QoEbi6t7w5hEtYWp9bMKaJ19i6A9E',
932
- * initiatorAmount: 1e18,
933
- * responderAmount: 1e18,
934
- * pushAmount: 0,
935
- * channelReserve: 0,
936
- * ttl: 1000,
937
- * host: 'localhost',
938
- * port: 3002,
939
- * lockPeriod: 10,
940
- * async sign (tag, tx) => await account.signTransaction(tx)
941
- * })
942
- */
943
-
944
-
945
- const Channel = AsyncInit.compose({
946
- async init(options) {
947
- initialize(this, options);
948
- },
949
-
950
- methods: {
951
- on,
952
- off,
953
- status,
954
- state,
955
- round,
956
- id,
957
- fsmId,
958
- update,
959
- poi,
960
- balances,
961
- leave,
962
- shutdown,
963
- sendMessage,
964
- withdraw,
965
- deposit,
966
- createContract,
967
- callContract,
968
- callContractStatic,
969
- getContractCall,
970
- getContractState,
971
- disconnect,
972
- cleanContractCalls,
973
- forceProgress
974
- },
975
- statics: {
976
- reconnect
977
- }
978
- });
979
- export default Channel;
980
- //# sourceMappingURL=index.js.map