@aeternity/aepp-sdk 10.0.0 → 12.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (424) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +15 -14
  3. package/dist/aepp-sdk.browser-script.js +1 -1
  4. package/dist/aepp-sdk.browser-script.js.LICENSE.txt +13 -40
  5. package/dist/aepp-sdk.browser-script.js.map +1 -1
  6. package/dist/aepp-sdk.browser.js +1 -1
  7. package/dist/aepp-sdk.browser.js.map +1 -1
  8. package/dist/aepp-sdk.js +1 -1
  9. package/dist/aepp-sdk.js.map +1 -1
  10. package/es/AeSdk.d.ts +37 -0
  11. package/es/AeSdk.mjs +81 -0
  12. package/es/AeSdk.mjs.map +1 -0
  13. package/es/AeSdkAepp.d.ts +69 -0
  14. package/es/AeSdkAepp.mjs +175 -0
  15. package/es/AeSdkAepp.mjs.map +1 -0
  16. package/es/AeSdkBase.d.ts +212 -0
  17. package/es/AeSdkBase.mjs +310 -0
  18. package/es/AeSdkBase.mjs.map +1 -0
  19. package/es/AeSdkWallet.d.ts +103 -0
  20. package/es/AeSdkWallet.mjs +322 -0
  21. package/es/AeSdkWallet.mjs.map +1 -0
  22. package/es/Node.d.ts +44 -0
  23. package/es/Node.mjs +141 -0
  24. package/es/Node.mjs.map +1 -0
  25. package/es/account/Base.d.ts +65 -0
  26. package/es/account/Base.mjs +123 -0
  27. package/es/account/Base.mjs.map +1 -0
  28. package/es/account/Memory.d.ts +25 -0
  29. package/es/account/Memory.mjs +81 -0
  30. package/es/account/Memory.mjs.map +1 -0
  31. package/es/account/Rpc.d.ts +27 -0
  32. package/es/account/Rpc.mjs +79 -0
  33. package/es/account/Rpc.mjs.map +1 -0
  34. package/es/aens.d.ts +209 -0
  35. package/es/aens.mjs +332 -0
  36. package/es/aens.mjs.map +1 -0
  37. package/es/aepp-wallet-communication/connection/Browser.d.ts +32 -0
  38. package/es/aepp-wallet-communication/connection/Browser.mjs +70 -0
  39. package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -0
  40. package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +17 -0
  41. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +57 -0
  42. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -0
  43. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +35 -0
  44. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +142 -0
  45. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -0
  46. package/es/aepp-wallet-communication/connection-proxy.d.ts +10 -0
  47. package/{src/utils/crypto-ts.ts → es/aepp-wallet-communication/connection-proxy.mjs} +15 -11
  48. package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -0
  49. package/es/aepp-wallet-communication/rpc/RpcClient.d.ts +33 -0
  50. package/es/aepp-wallet-communication/rpc/RpcClient.mjs +169 -0
  51. package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -0
  52. package/es/aepp-wallet-communication/rpc/types.d.ts +77 -0
  53. package/es/aepp-wallet-communication/rpc/types.mjs +3 -0
  54. package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -0
  55. package/es/aepp-wallet-communication/schema.d.ts +118 -0
  56. package/es/aepp-wallet-communication/schema.mjs +214 -0
  57. package/es/aepp-wallet-communication/schema.mjs.map +1 -0
  58. package/es/aepp-wallet-communication/wallet-detector.d.ts +24 -0
  59. package/es/aepp-wallet-communication/wallet-detector.mjs +63 -0
  60. package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -0
  61. package/es/apis/compiler/compiler.d.ts +92 -0
  62. package/es/apis/compiler/compiler.mjs +576 -0
  63. package/es/apis/compiler/compiler.mjs.map +1 -0
  64. package/es/apis/compiler/index.d.ts +2 -0
  65. package/es/apis/compiler/index.mjs +3 -0
  66. package/es/apis/compiler/index.mjs.map +1 -0
  67. package/es/apis/compiler/models/index.d.ts +248 -0
  68. package/es/apis/compiler/models/index.mjs +48 -0
  69. package/es/apis/compiler/models/index.mjs.map +1 -0
  70. package/es/apis/compiler/models/mappers.d.ts +23 -0
  71. package/es/apis/compiler/models/mappers.mjs +585 -0
  72. package/es/apis/compiler/models/mappers.mjs.map +1 -0
  73. package/es/apis/compiler/models/parameters.d.ts +13 -0
  74. package/es/apis/compiler/models/parameters.mjs +71 -0
  75. package/es/apis/compiler/models/parameters.mjs.map +1 -0
  76. package/es/apis/node/index.d.ts +2 -0
  77. package/es/apis/node/index.mjs +3 -0
  78. package/es/apis/node/index.mjs.map +1 -0
  79. package/es/apis/node/models/index.d.ts +1061 -0
  80. package/es/apis/node/models/index.mjs +2 -0
  81. package/es/apis/node/models/index.mjs.map +1 -0
  82. package/es/apis/node/models/mappers.d.ts +95 -0
  83. package/es/apis/node/models/mappers.mjs +4164 -0
  84. package/es/apis/node/models/mappers.mjs.map +1 -0
  85. package/es/apis/node/models/parameters.d.ts +17 -0
  86. package/es/apis/node/models/parameters.mjs +165 -0
  87. package/es/apis/node/models/parameters.mjs.map +1 -0
  88. package/es/apis/node/node.d.ts +215 -0
  89. package/es/apis/node/node.mjs +1165 -0
  90. package/es/apis/node/node.mjs.map +1 -0
  91. package/es/chain.d.ts +220 -0
  92. package/es/chain.mjs +524 -0
  93. package/es/chain.mjs.map +1 -0
  94. package/es/channel/handlers.d.ts +34 -0
  95. package/es/channel/{handlers.js → handlers.mjs} +163 -130
  96. package/es/channel/handlers.mjs.map +1 -0
  97. package/es/channel/index.d.ts +634 -0
  98. package/es/channel/index.mjs +978 -0
  99. package/es/channel/index.mjs.map +1 -0
  100. package/es/channel/internal.d.ts +100 -0
  101. package/es/channel/internal.mjs +328 -0
  102. package/es/channel/internal.mjs.map +1 -0
  103. package/es/contract/Compiler.d.ts +17 -0
  104. package/es/contract/Compiler.mjs +67 -0
  105. package/es/contract/Compiler.mjs.map +1 -0
  106. package/es/contract/aci.d.ts +125 -0
  107. package/es/contract/aci.mjs +496 -0
  108. package/es/contract/aci.mjs.map +1 -0
  109. package/es/contract/ga.d.ts +68 -0
  110. package/es/contract/ga.mjs +190 -0
  111. package/es/contract/ga.mjs.map +1 -0
  112. package/es/contract/methods.d.ts +68 -0
  113. package/es/contract/methods.mjs +101 -0
  114. package/es/contract/methods.mjs.map +1 -0
  115. package/es/index.d.ts +32 -0
  116. package/es/index.mjs +49 -0
  117. package/es/index.mjs.map +1 -0
  118. package/es/oracle.d.ts +154 -0
  119. package/es/oracle.mjs +288 -0
  120. package/es/oracle.mjs.map +1 -0
  121. package/es/spend.d.ts +61 -0
  122. package/es/spend.mjs +122 -0
  123. package/es/spend.mjs.map +1 -0
  124. package/es/tx/builder/constants.d.ts +41 -0
  125. package/es/tx/builder/constants.mjs +100 -0
  126. package/es/tx/builder/constants.mjs.map +1 -0
  127. package/es/tx/builder/field-types.d.ts +62 -0
  128. package/es/tx/builder/field-types.mjs +126 -0
  129. package/es/tx/builder/field-types.mjs.map +1 -0
  130. package/es/tx/builder/helpers.d.ts +131 -0
  131. package/es/tx/builder/helpers.mjs +223 -0
  132. package/es/tx/builder/helpers.mjs.map +1 -0
  133. package/es/tx/builder/index.d.ts +75 -0
  134. package/es/tx/builder/index.mjs +424 -0
  135. package/es/tx/builder/index.mjs.map +1 -0
  136. package/es/tx/builder/schema.d.ts +350 -0
  137. package/es/tx/builder/schema.mjs +320 -0
  138. package/es/tx/builder/schema.mjs.map +1 -0
  139. package/es/tx/index.d.ts +63 -0
  140. package/es/tx/index.mjs +209 -0
  141. package/es/tx/index.mjs.map +1 -0
  142. package/es/tx/min-fee.d.ts +20 -0
  143. package/es/tx/min-fee.mjs +148 -0
  144. package/es/tx/min-fee.mjs.map +1 -0
  145. package/es/tx/validator.d.ts +19 -0
  146. package/es/tx/validator.mjs +240 -0
  147. package/es/tx/validator.mjs.map +1 -0
  148. package/es/typings/@aeternity__argon2-browser/index.d.mjs +2 -0
  149. package/es/typings/@aeternity__argon2-browser/index.d.mjs.map +1 -0
  150. package/es/typings/@aeternity__uuid/index.d.mjs +2 -0
  151. package/es/typings/@aeternity__uuid/index.d.mjs.map +1 -0
  152. package/es/typings/bip32-path/index.d.mjs +2 -0
  153. package/es/typings/bip32-path/index.d.mjs.map +1 -0
  154. package/es/typings/blakejs/index.d.mjs +2 -0
  155. package/es/typings/blakejs/index.d.mjs.map +1 -0
  156. package/es/typings/tweetnacl-auth/index.d.mjs +2 -0
  157. package/es/typings/tweetnacl-auth/index.d.mjs.map +1 -0
  158. package/es/utils/amount-formatter.d.ts +42 -0
  159. package/es/utils/{amount-formatter.js → amount-formatter.mjs} +38 -44
  160. package/es/utils/amount-formatter.mjs.map +1 -0
  161. package/es/utils/autorest.d.ts +6 -0
  162. package/es/utils/autorest.mjs +97 -0
  163. package/es/utils/autorest.mjs.map +1 -0
  164. package/es/utils/bignumber.d.ts +13 -0
  165. package/es/utils/bignumber.mjs +23 -0
  166. package/es/utils/bignumber.mjs.map +1 -0
  167. package/es/{bytes.d.ts → utils/bytes.d.ts} +10 -13
  168. package/es/utils/{bytes.js → bytes.mjs} +26 -22
  169. package/es/utils/bytes.mjs.map +1 -0
  170. package/es/utils/crypto.d.ts +103 -0
  171. package/es/utils/crypto.mjs +221 -0
  172. package/es/utils/crypto.mjs.map +1 -0
  173. package/es/utils/encoder.d.ts +26 -0
  174. package/es/utils/encoder.mjs +102 -0
  175. package/es/utils/encoder.mjs.map +1 -0
  176. package/es/utils/errors.d.ts +481 -0
  177. package/es/utils/errors.mjs +882 -0
  178. package/es/utils/errors.mjs.map +1 -0
  179. package/es/utils/hd-wallet.d.ts +34 -0
  180. package/es/utils/hd-wallet.mjs +122 -0
  181. package/es/utils/hd-wallet.mjs.map +1 -0
  182. package/es/utils/json-big.d.ts +5 -0
  183. package/es/utils/json-big.mjs +41 -0
  184. package/es/utils/json-big.mjs.map +1 -0
  185. package/es/utils/keystore.d.ts +51 -0
  186. package/es/utils/keystore.mjs +145 -0
  187. package/es/utils/keystore.mjs.map +1 -0
  188. package/es/{mptree.d.ts → utils/mptree.d.ts} +5 -8
  189. package/es/utils/{mptree.js → mptree.mjs} +33 -25
  190. package/es/utils/mptree.mjs.map +1 -0
  191. package/es/utils/other.d.ts +14 -0
  192. package/es/utils/other.mjs +28 -0
  193. package/es/utils/other.mjs.map +1 -0
  194. package/es/{semver-satisfies.d.ts → utils/semver-satisfies.d.ts} +0 -0
  195. package/es/utils/{semver-satisfies.js → semver-satisfies.mjs} +1 -1
  196. package/es/utils/semver-satisfies.mjs.map +1 -0
  197. package/es/utils/string.d.ts +24 -0
  198. package/es/utils/{string.js → string.mjs} +9 -11
  199. package/es/utils/string.mjs.map +1 -0
  200. package/package.json +67 -64
  201. package/src/AeSdk.ts +65 -0
  202. package/src/AeSdkAepp.ts +167 -0
  203. package/src/AeSdkBase.ts +320 -0
  204. package/src/AeSdkWallet.ts +332 -0
  205. package/src/Node.ts +167 -0
  206. package/src/account/Base.ts +114 -0
  207. package/src/account/Memory.ts +83 -0
  208. package/src/account/Rpc.ts +67 -0
  209. package/src/aens.ts +391 -0
  210. package/src/aepp-wallet-communication/connection/Browser.ts +68 -0
  211. package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +58 -0
  212. package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +111 -0
  213. package/{es/utils/crypto-ts.js → src/aepp-wallet-communication/connection-proxy.ts} +16 -9
  214. package/src/aepp-wallet-communication/rpc/RpcClient.ts +137 -0
  215. package/src/aepp-wallet-communication/rpc/types.ts +66 -0
  216. package/src/aepp-wallet-communication/schema.ts +181 -0
  217. package/src/aepp-wallet-communication/wallet-detector.ts +71 -0
  218. package/src/apis/compiler/code-model-v4.yaml +2649 -0
  219. package/src/apis/compiler/compiler.ts +585 -0
  220. package/src/apis/compiler/index.ts +2 -0
  221. package/src/apis/compiler/models/index.ts +301 -0
  222. package/src/apis/compiler/models/mappers.ts +583 -0
  223. package/src/apis/compiler/models/parameters.ts +93 -0
  224. package/src/apis/node/code-model-v4.yaml +10046 -0
  225. package/src/apis/node/index.ts +2 -0
  226. package/src/apis/node/models/index.ts +1253 -0
  227. package/src/apis/node/models/mappers.ts +4278 -0
  228. package/src/apis/node/models/parameters.ts +188 -0
  229. package/src/apis/node/node.ts +1299 -0
  230. package/src/chain.ts +444 -0
  231. package/src/channel/{handlers.js → handlers.ts} +238 -143
  232. package/src/channel/index.ts +991 -0
  233. package/src/channel/internal.ts +345 -0
  234. package/src/contract/Compiler.ts +66 -0
  235. package/src/contract/aci.ts +529 -0
  236. package/src/contract/ga.ts +178 -0
  237. package/src/contract/methods.ts +118 -0
  238. package/src/index.ts +51 -0
  239. package/src/oracle.ts +342 -0
  240. package/src/spend.ts +152 -0
  241. package/src/tx/builder/constants.ts +96 -0
  242. package/src/tx/builder/field-types.ts +111 -0
  243. package/src/tx/builder/helpers.ts +253 -0
  244. package/src/tx/builder/index.ts +394 -0
  245. package/src/tx/builder/schema.ts +771 -0
  246. package/src/tx/index.ts +199 -0
  247. package/src/tx/min-fee.ts +136 -0
  248. package/src/tx/validator.ts +226 -0
  249. package/src/typings/@aeternity__argon2-browser/index.d.ts +3 -0
  250. package/src/typings/@aeternity__uuid/index.d.ts +3 -0
  251. package/src/typings/bip32-path/index.d.ts +33 -0
  252. package/src/typings/tweetnacl-auth/index.d.ts +14 -0
  253. package/src/utils/amount-formatter.ts +29 -41
  254. package/src/utils/autorest.ts +90 -0
  255. package/src/utils/bignumber.ts +9 -19
  256. package/src/utils/bytes.ts +15 -16
  257. package/src/utils/crypto.ts +217 -0
  258. package/src/utils/encoder.ts +98 -0
  259. package/src/utils/errors.ts +817 -0
  260. package/src/utils/hd-wallet.ts +134 -0
  261. package/src/utils/json-big.ts +26 -0
  262. package/src/utils/keystore.ts +179 -0
  263. package/src/utils/mptree.ts +26 -20
  264. package/src/utils/other.ts +28 -43
  265. package/src/utils/string.ts +8 -10
  266. package/CHANGELOG.md +0 -1603
  267. package/es/account/base.js +0 -169
  268. package/es/account/base.js.map +0 -1
  269. package/es/account/memory.js +0 -84
  270. package/es/account/memory.js.map +0 -1
  271. package/es/account/multiple.js +0 -178
  272. package/es/account/multiple.js.map +0 -1
  273. package/es/ae/aens.js +0 -408
  274. package/es/ae/aens.js.map +0 -1
  275. package/es/ae/aepp.js +0 -45
  276. package/es/ae/aepp.js.map +0 -1
  277. package/es/ae/contract.js +0 -312
  278. package/es/ae/contract.js.map +0 -1
  279. package/es/ae/index.js +0 -206
  280. package/es/ae/index.js.map +0 -1
  281. package/es/ae/oracle.js +0 -322
  282. package/es/ae/oracle.js.map +0 -1
  283. package/es/ae/universal.js +0 -45
  284. package/es/ae/universal.js.map +0 -1
  285. package/es/ae/wallet.js +0 -50
  286. package/es/ae/wallet.js.map +0 -1
  287. package/es/amount-formatter.d.ts +0 -58
  288. package/es/bignumber.d.ts +0 -24
  289. package/es/chain/index.js +0 -256
  290. package/es/chain/index.js.map +0 -1
  291. package/es/chain/node.js +0 -394
  292. package/es/chain/node.js.map +0 -1
  293. package/es/channel/handlers.js.map +0 -1
  294. package/es/channel/index.js +0 -980
  295. package/es/channel/index.js.map +0 -1
  296. package/es/channel/internal.js +0 -266
  297. package/es/channel/internal.js.map +0 -1
  298. package/es/contract/aci/helpers.js +0 -298
  299. package/es/contract/aci/helpers.js.map +0 -1
  300. package/es/contract/aci/index.js +0 -361
  301. package/es/contract/aci/index.js.map +0 -1
  302. package/es/contract/aci/transformation.js +0 -66
  303. package/es/contract/aci/transformation.js.map +0 -1
  304. package/es/contract/compiler.js +0 -244
  305. package/es/contract/compiler.js.map +0 -1
  306. package/es/contract/ga/helpers.js +0 -22
  307. package/es/contract/ga/helpers.js.map +0 -1
  308. package/es/contract/ga/index.js +0 -170
  309. package/es/contract/ga/index.js.map +0 -1
  310. package/es/contract/index.js +0 -162
  311. package/es/contract/index.js.map +0 -1
  312. package/es/crypto-ts.d.ts +0 -9
  313. package/es/index.js +0 -57
  314. package/es/index.js.map +0 -1
  315. package/es/node-pool/index.js +0 -187
  316. package/es/node-pool/index.js.map +0 -1
  317. package/es/node.js +0 -132
  318. package/es/node.js.map +0 -1
  319. package/es/other.d.ts +0 -31
  320. package/es/string.d.ts +0 -26
  321. package/es/tx/builder/helpers.js +0 -305
  322. package/es/tx/builder/helpers.js.map +0 -1
  323. package/es/tx/builder/index.js +0 -595
  324. package/es/tx/builder/index.js.map +0 -1
  325. package/es/tx/builder/schema.js +0 -814
  326. package/es/tx/builder/schema.js.map +0 -1
  327. package/es/tx/index.js +0 -300
  328. package/es/tx/index.js.map +0 -1
  329. package/es/tx/tx-object.js +0 -276
  330. package/es/tx/tx-object.js.map +0 -1
  331. package/es/tx/tx.js +0 -937
  332. package/es/tx/tx.js.map +0 -1
  333. package/es/tx/validator.js +0 -208
  334. package/es/tx/validator.js.map +0 -1
  335. package/es/typings/blakejs/index.d.js +0 -2
  336. package/es/typings/blakejs/index.d.js.map +0 -1
  337. package/es/utils/aepp-wallet-communication/connection/browser-runtime.js +0 -131
  338. package/es/utils/aepp-wallet-communication/connection/browser-runtime.js.map +0 -1
  339. package/es/utils/aepp-wallet-communication/connection/browser-window-message.js +0 -184
  340. package/es/utils/aepp-wallet-communication/connection/browser-window-message.js.map +0 -1
  341. package/es/utils/aepp-wallet-communication/connection/index.js +0 -84
  342. package/es/utils/aepp-wallet-communication/connection/index.js.map +0 -1
  343. package/es/utils/aepp-wallet-communication/content-script-bridge.js +0 -97
  344. package/es/utils/aepp-wallet-communication/content-script-bridge.js.map +0 -1
  345. package/es/utils/aepp-wallet-communication/helpers.js +0 -103
  346. package/es/utils/aepp-wallet-communication/helpers.js.map +0 -1
  347. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js +0 -329
  348. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js.map +0 -1
  349. package/es/utils/aepp-wallet-communication/rpc/rpc-client.js +0 -270
  350. package/es/utils/aepp-wallet-communication/rpc/rpc-client.js.map +0 -1
  351. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js +0 -533
  352. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js.map +0 -1
  353. package/es/utils/aepp-wallet-communication/schema.js +0 -107
  354. package/es/utils/aepp-wallet-communication/schema.js.map +0 -1
  355. package/es/utils/aepp-wallet-communication/wallet-detector.js +0 -109
  356. package/es/utils/aepp-wallet-communication/wallet-detector.js.map +0 -1
  357. package/es/utils/amount-formatter.js.map +0 -1
  358. package/es/utils/async-init.js +0 -67
  359. package/es/utils/async-init.js.map +0 -1
  360. package/es/utils/bignumber.js +0 -28
  361. package/es/utils/bignumber.js.map +0 -1
  362. package/es/utils/bytes.js.map +0 -1
  363. package/es/utils/crypto-ts.js.map +0 -1
  364. package/es/utils/crypto.js +0 -304
  365. package/es/utils/crypto.js.map +0 -1
  366. package/es/utils/hd-wallet.js +0 -112
  367. package/es/utils/hd-wallet.js.map +0 -1
  368. package/es/utils/json-big.js +0 -45
  369. package/es/utils/json-big.js.map +0 -1
  370. package/es/utils/keystore.js +0 -228
  371. package/es/utils/keystore.js.map +0 -1
  372. package/es/utils/mptree.js.map +0 -1
  373. package/es/utils/other.js +0 -43
  374. package/es/utils/other.js.map +0 -1
  375. package/es/utils/semver-satisfies.js.map +0 -1
  376. package/es/utils/string.js.map +0 -1
  377. package/es/utils/swagger.js +0 -132
  378. package/es/utils/swagger.js.map +0 -1
  379. package/src/account/base.js +0 -153
  380. package/src/account/memory.js +0 -78
  381. package/src/account/multiple.js +0 -154
  382. package/src/ae/aens.js +0 -366
  383. package/src/ae/aepp.js +0 -45
  384. package/src/ae/contract.js +0 -285
  385. package/src/ae/index.js +0 -167
  386. package/src/ae/oracle.js +0 -296
  387. package/src/ae/universal.js +0 -47
  388. package/src/ae/wallet.js +0 -50
  389. package/src/chain/index.js +0 -250
  390. package/src/chain/node.js +0 -293
  391. package/src/channel/index.js +0 -898
  392. package/src/channel/internal.js +0 -231
  393. package/src/contract/aci/index.js +0 -317
  394. package/src/contract/aci/transformation.js +0 -72
  395. package/src/contract/compiler.js +0 -195
  396. package/src/contract/ga/helpers.js +0 -17
  397. package/src/contract/ga/index.js +0 -147
  398. package/src/contract/index.js +0 -163
  399. package/src/index.js +0 -90
  400. package/src/node-pool/index.js +0 -171
  401. package/src/node.js +0 -118
  402. package/src/tx/builder/helpers.js +0 -325
  403. package/src/tx/builder/index.js +0 -460
  404. package/src/tx/builder/schema.js +0 -1211
  405. package/src/tx/index.js +0 -301
  406. package/src/tx/tx-object.js +0 -186
  407. package/src/tx/tx.js +0 -622
  408. package/src/tx/validator.js +0 -161
  409. package/src/utils/aepp-wallet-communication/connection/browser-runtime.js +0 -114
  410. package/src/utils/aepp-wallet-communication/connection/browser-window-message.js +0 -161
  411. package/src/utils/aepp-wallet-communication/connection/index.js +0 -85
  412. package/src/utils/aepp-wallet-communication/content-script-bridge.js +0 -85
  413. package/src/utils/aepp-wallet-communication/helpers.js +0 -70
  414. package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +0 -268
  415. package/src/utils/aepp-wallet-communication/rpc/rpc-client.js +0 -223
  416. package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +0 -390
  417. package/src/utils/aepp-wallet-communication/schema.js +0 -108
  418. package/src/utils/aepp-wallet-communication/wallet-detector.js +0 -91
  419. package/src/utils/async-init.js +0 -41
  420. package/src/utils/crypto.js +0 -312
  421. package/src/utils/hd-wallet.js +0 -115
  422. package/src/utils/json-big.js +0 -26
  423. package/src/utils/keystore.js +0 -223
  424. package/src/utils/swagger.js +0 -133
package/es/aens.mjs ADDED
@@ -0,0 +1,332 @@
1
+ /*
2
+ * ISC License (ISC)
3
+ * Copyright (c) 2022 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
+ * Aens methods - routines to interact with the æternity naming system
20
+ *
21
+ * The high-level description of the naming system is
22
+ * https://github.com/aeternity/protocol/blob/master/AENS.md in the protocol
23
+ * repository.
24
+ */
25
+ import { salt } from "./utils/crypto.mjs";
26
+ import { commitmentHash, isAuctionName } from "./tx/builder/helpers.mjs";
27
+ import { CLIENT_TTL, NAME_TTL, TX_TYPE } from "./tx/builder/schema.mjs";
28
+ import { ArgumentError } from "./utils/errors.mjs";
29
+ import { send } from "./spend.mjs";
30
+ import { getName, height } from "./chain.mjs";
31
+ import { _buildTx } from "./tx/index.mjs";
32
+
33
+ /**
34
+ * Revoke a name
35
+ * @param name - Name hash
36
+ * @param options - Options
37
+ * @param options.onAccount - Make operation on specific account from sdk (you pass
38
+ * publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)
39
+ * @param options.fee - fee
40
+ * @param options.ttl - ttl
41
+ * @param options.nonce - nonce
42
+ * @returns Transaction result
43
+ * @example
44
+ * ```js
45
+ * const name = 'test.chain'
46
+ * const nameObject = await sdkInstance.aensQuery(name)
47
+ *
48
+ * await sdkInstance.aensRevoke(name, { fee, ttl , nonce })
49
+ * // or
50
+ * await nameObject.revoke({ fee, ttl, nonce })
51
+ * ```
52
+ */
53
+ export async function aensRevoke(name, options) {
54
+ const nameRevokeTx = await _buildTx(TX_TYPE.nameRevoke, { ...options,
55
+ nameId: name,
56
+ accountId: await options.onAccount.address(options)
57
+ });
58
+ return await send(nameRevokeTx, options);
59
+ }
60
+
61
+ /**
62
+ * Update a name
63
+ * @param name - AENS name
64
+ * @param pointers - Map of pointer keys to corresponding addresses
65
+ * @param options - Options
66
+ * @param options.extendPointers - Get the pointers from the node and merge with provided
67
+ * ones. Pointers with the same type will be overwritten
68
+ * @param options.onAccount - Make operation on specific account from sdk (you
69
+ * pass publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)
70
+ * @param options.fee - fee
71
+ * @param options.ttl - ttl
72
+ * @param options.nonce - nonce
73
+ * @param options.nameTtl - Name ttl represented in number of
74
+ * blocks (Max value is 50000 blocks)
75
+ * @param options.clientTtl=84600 a suggestion as to how long any
76
+ * clients should cache this information
77
+ * @throws Invalid pointer array error
78
+ * @example
79
+ * ```js
80
+ * const name = 'test.chain'
81
+ * const pointersArray = ['ak_asd23dasdas...,' 'ct_asdf34fasdasd...']
82
+ * const nameObject = await sdkInstance.aensQuery(name)
83
+ *
84
+ * await sdkInstance.aensUpdate(name, pointersArray, { nameTtl, ttl, fee, nonce, clientTtl })
85
+ * // or
86
+ * await nameObject.update(pointers, { nameTtl, ttl, fee, nonce, clientTtl })
87
+ * ```
88
+ */
89
+ export async function aensUpdate(name, pointers, _ref) {
90
+ let {
91
+ extendPointers,
92
+ ...options
93
+ } = _ref;
94
+ const allPointers = { ...(extendPointers === true && Object.fromEntries((await getName(name, options)).pointers.map(_ref2 => {
95
+ let {
96
+ key,
97
+ id
98
+ } = _ref2;
99
+ return [key, id];
100
+ }))),
101
+ ...pointers
102
+ };
103
+ const nameUpdateTx = await _buildTx(TX_TYPE.nameUpdate, {
104
+ clientTtl: CLIENT_TTL,
105
+ nameTtl: NAME_TTL,
106
+ ...options,
107
+ nameId: name,
108
+ accountId: await options.onAccount.address(options),
109
+ pointers: Object.entries(allPointers).map(_ref3 => {
110
+ let [key, id] = _ref3;
111
+ return {
112
+ key,
113
+ id: id.toString()
114
+ };
115
+ })
116
+ });
117
+ return await send(nameUpdateTx, options);
118
+ }
119
+
120
+ /**
121
+ * Transfer a domain to another account
122
+ * @param name - AENS name
123
+ * @param account - Recipient account publick key
124
+ * @param options - Options
125
+ * @param options.onAccount - Make operation on specific account from sdk (you pass
126
+ * publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)
127
+ * @param options.fee - fee
128
+ * @param options.ttl - ttl
129
+ * @param options.nonce - nonce
130
+ * @returns Transaction result
131
+ * @example
132
+ * ```js
133
+ * const name = 'test.chain'
134
+ * const recipientPub = 'ak_asd23dasdas...'
135
+ * const nameObject = await sdkInstance.aensQuery(name)
136
+ *
137
+ * await sdkInstance.aensTransfer(name, recipientPub, { ttl, fee, nonce })
138
+ * // or
139
+ * await nameObject.transfer(recipientPub, { ttl, fee, nonce })
140
+ * ```
141
+ */
142
+ export async function aensTransfer(name, account, options) {
143
+ const nameTransferTx = await _buildTx(TX_TYPE.nameTransfer, { ...options,
144
+ nameId: name,
145
+ accountId: await options.onAccount.address(options),
146
+ recipientId: account
147
+ });
148
+ return await send(nameTransferTx, options);
149
+ }
150
+
151
+ /**
152
+ * Query the AENS name info from the node
153
+ * and return the object with info and predefined functions for manipulating name
154
+ * @param name - AENS name
155
+ * @param opt - Options
156
+ * @returns
157
+ * @example
158
+ * ```js
159
+ * const nameObject = sdkInstance.aensQuery('test.chain')
160
+ * console.log(nameObject)
161
+ * {
162
+ * id, // name hash
163
+ * pointers, // array of pointers
164
+ * update, // Update name function
165
+ * extendTtl, // Extend Ttl name function
166
+ * transfer, // Transfer name function
167
+ * revoke // Revoke name function
168
+ * }
169
+ * ```
170
+ */
171
+ export async function aensQuery(name, opt) {
172
+ const nameEntry = await getName(name, opt);
173
+ return Object.freeze({ ...nameEntry,
174
+ id: nameEntry.id,
175
+ owner: nameEntry.owner,
176
+
177
+ async update(pointers, options) {
178
+ return { ...(await aensUpdate(name, pointers, { ...opt,
179
+ ...options
180
+ })),
181
+ ...(await aensQuery(name, { ...opt,
182
+ ...options
183
+ }))
184
+ };
185
+ },
186
+
187
+ async transfer(account, options) {
188
+ return { ...(await aensTransfer(name, account, { ...opt,
189
+ ...options
190
+ })),
191
+ ...(await aensQuery(name, { ...opt,
192
+ ...options
193
+ }))
194
+ };
195
+ },
196
+
197
+ async revoke(options) {
198
+ return await aensRevoke(name, { ...opt,
199
+ ...options
200
+ });
201
+ },
202
+
203
+ async extendTtl() {
204
+ let nameTtl = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : NAME_TTL;
205
+ let options = arguments.length > 1 ? arguments[1] : undefined;
206
+
207
+ if (nameTtl > NAME_TTL || nameTtl <= 0) {
208
+ throw new ArgumentError('nameTtl', `a number between 1 and ${NAME_TTL} blocks`, nameTtl);
209
+ }
210
+
211
+ return { ...(await aensUpdate(name, {}, { ...opt,
212
+ ...options,
213
+ nameTtl,
214
+ extendPointers: true
215
+ })),
216
+ ...(await aensQuery(name, { ...opt,
217
+ ...options
218
+ }))
219
+ };
220
+ }
221
+
222
+ });
223
+ }
224
+ /**
225
+ * Claim a previously preclaimed registration. This can only be done after the
226
+ * preclaim step
227
+ * @param name - AENS name
228
+ * @param salt - Salt from pre-claim, or 0 if it's a bid
229
+ * @param options - options
230
+ * @param options.onAccount - Make operation on specific account from sdk (you pass
231
+ * publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)
232
+ * @param options.fee - fee
233
+ * @param options.ttl - ttl
234
+ * @param options.nonce - nonce
235
+ * @param options.nameFee - Name Fee (By default calculated by sdk)
236
+ * @returns the result of the claim
237
+ * @example
238
+ * ```js
239
+ * const name = 'test.chain'
240
+ * const salt = preclaimResult.salt // salt from pre-claim transaction
241
+ *
242
+ * await sdkInstance.aensClaim(name, salt, { ttl, fee, nonce, nameFee })
243
+ * ```
244
+ */
245
+
246
+ export async function aensClaim(name, salt, options) {
247
+ const claimTx = await _buildTx(TX_TYPE.nameClaim, { ...options,
248
+ accountId: await options.onAccount.address(options),
249
+ nameSalt: salt,
250
+ name
251
+ });
252
+ const result = await send(claimTx, options);
253
+
254
+ if (!isAuctionName(name)) {
255
+ const nameInter = result.blockHeight != null && result.blockHeight > 0 ? await aensQuery(name, options) : {};
256
+ return Object.assign(result, nameInter);
257
+ }
258
+
259
+ return result;
260
+ }
261
+
262
+ /**
263
+ * Preclaim a name. Sends a hash of the name and a random salt to the node
264
+ * @param name - AENS name
265
+ * @param options - Options
266
+ * @param options.onAccount - Make operation on specific account from sdk (you pass
267
+ * publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)
268
+ * @param options.fee - fee
269
+ * @param options.ttl - ttl
270
+ * @param options.nonce - nonce
271
+ * @example
272
+ * ```js
273
+ * const name = 'test.chain'
274
+ * const salt = preclaimResult.salt // salt from pre-claim transaction
275
+ *
276
+ * await sdkInstance.aensPreclaim(name, { ttl, fee, nonce })
277
+ * {
278
+ * ...transactionResult,
279
+ * claim, // Claim function (options={}) => claimTransactionResult
280
+ * salt,
281
+ * commitmentId
282
+ * }
283
+ * ```
284
+ */
285
+ export async function aensPreclaim(name, options) {
286
+ const _salt = salt();
287
+
288
+ const currentHeight = await height(options);
289
+ const commitmentId = commitmentHash(name, _salt);
290
+ const preclaimTx = await _buildTx(TX_TYPE.namePreClaim, { ...options,
291
+ accountId: await options.onAccount.address(options),
292
+ commitmentId
293
+ });
294
+ return Object.freeze({ ...(await send(preclaimTx, options)),
295
+ height: currentHeight,
296
+ salt: _salt,
297
+ commitmentId,
298
+
299
+ async claim(opts) {
300
+ return await aensClaim(name, _salt, { ...options,
301
+ ...opts
302
+ });
303
+ }
304
+
305
+ });
306
+ }
307
+
308
+ /**
309
+ * Bid to name auction
310
+ * @param name - Domain name
311
+ * @param nameFee - Name fee (bid fee)
312
+ * @param options - Options
313
+ * @param options.onAccount - Make operation on specific account from sdk (you pass
314
+ * publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)
315
+ * @param options.fee - fee
316
+ * @param options.ttl - ttl
317
+ * @param options.nonce - nonce
318
+ * @returns Transaction result
319
+ * @example
320
+ * ```js
321
+ * const name = 'test.chain'
322
+ * const bidFee = computeBidFee(name, startFee, incrementPercentage)
323
+ *
324
+ * await sdkInstance.aensBid(name, 213109412839123, { ttl, fee, nonce })
325
+ * ```
326
+ */
327
+ export async function aensBid(name, nameFee, options) {
328
+ return await aensClaim(name, 0, { ...options,
329
+ nameFee
330
+ });
331
+ }
332
+ //# sourceMappingURL=aens.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aens.mjs","names":["salt","commitmentHash","isAuctionName","CLIENT_TTL","NAME_TTL","TX_TYPE","ArgumentError","send","getName","height","_buildTx","aensRevoke","name","options","nameRevokeTx","nameRevoke","nameId","accountId","onAccount","address","aensUpdate","pointers","extendPointers","allPointers","Object","fromEntries","map","key","id","nameUpdateTx","nameUpdate","clientTtl","nameTtl","entries","toString","aensTransfer","account","nameTransferTx","nameTransfer","recipientId","aensQuery","opt","nameEntry","freeze","owner","update","transfer","revoke","extendTtl","aensClaim","claimTx","nameClaim","nameSalt","result","nameInter","blockHeight","assign","aensPreclaim","_salt","currentHeight","commitmentId","preclaimTx","namePreClaim","claim","opts","aensBid","nameFee"],"sources":["../src/aens.ts"],"sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2022 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\n\n/**\n * Aens methods - routines to interact with the æternity naming system\n *\n * The high-level description of the naming system is\n * https://github.com/aeternity/protocol/blob/master/AENS.md in the protocol\n * repository.\n */\n\nimport { salt } from './utils/crypto'\nimport { commitmentHash, isAuctionName, Pointer } from './tx/builder/helpers'\nimport { CLIENT_TTL, NAME_TTL, TX_TYPE, AensName } from './tx/builder/schema'\nimport { ArgumentError } from './utils/errors'\nimport { EncodedData } from './utils/encoder'\nimport BigNumber from 'bignumber.js'\nimport { send, SendOptions } from './spend'\nimport { getName, height } from './chain'\nimport { _buildTx, BuildTxOptions } from './tx'\nimport { TransformNodeType } from './Node'\nimport { NameEntry } from './apis/node'\nimport AccountBase from './account/Base'\n\ninterface KeyPointers {\n [key: string]: string | Buffer\n}\n\n/**\n * Revoke a name\n * @param name - Name hash\n * @param options - Options\n * @param options.onAccount - Make operation on specific account from sdk (you pass\n * publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)\n * @param options.fee - fee\n * @param options.ttl - ttl\n * @param options.nonce - nonce\n * @returns Transaction result\n * @example\n * ```js\n * const name = 'test.chain'\n * const nameObject = await sdkInstance.aensQuery(name)\n *\n * await sdkInstance.aensRevoke(name, { fee, ttl , nonce })\n * // or\n * await nameObject.revoke({ fee, ttl, nonce })\n * ```\n */\nexport async function aensRevoke (\n name: AensName, options: AensRevokeOptions\n): ReturnType<typeof send> {\n const nameRevokeTx = await _buildTx(TX_TYPE.nameRevoke, {\n ...options,\n nameId: name,\n accountId: await options.onAccount.address(options)\n })\n return await send(nameRevokeTx, options)\n}\n\ninterface AensRevokeOptions extends\n BuildTxOptions<TX_TYPE.nameRevoke, 'nameId' | 'accountId'>,\n SendOptions {}\n\n/**\n * Update a name\n * @param name - AENS name\n * @param pointers - Map of pointer keys to corresponding addresses\n * @param options - Options\n * @param options.extendPointers - Get the pointers from the node and merge with provided\n * ones. Pointers with the same type will be overwritten\n * @param options.onAccount - Make operation on specific account from sdk (you\n * pass publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)\n * @param options.fee - fee\n * @param options.ttl - ttl\n * @param options.nonce - nonce\n * @param options.nameTtl - Name ttl represented in number of\n * blocks (Max value is 50000 blocks)\n * @param options.clientTtl=84600 a suggestion as to how long any\n * clients should cache this information\n * @throws Invalid pointer array error\n * @example\n * ```js\n * const name = 'test.chain'\n * const pointersArray = ['ak_asd23dasdas...,' 'ct_asdf34fasdasd...']\n * const nameObject = await sdkInstance.aensQuery(name)\n *\n * await sdkInstance.aensUpdate(name, pointersArray, { nameTtl, ttl, fee, nonce, clientTtl })\n * // or\n * await nameObject.update(pointers, { nameTtl, ttl, fee, nonce, clientTtl })\n * ```\n */\nexport async function aensUpdate (\n name: AensName, pointers: KeyPointers, { extendPointers, ...options }: AensUpdateOptions\n): ReturnType<typeof send> {\n const allPointers = {\n ...extendPointers === true && Object.fromEntries(\n (await getName(name, options)).pointers\n .map(({ key, id }: { key: string, id: string }) => [key, id])\n ),\n ...pointers\n }\n\n const nameUpdateTx = await _buildTx(TX_TYPE.nameUpdate, {\n clientTtl: CLIENT_TTL,\n nameTtl: NAME_TTL,\n ...options,\n nameId: name,\n accountId: await options.onAccount.address(options),\n pointers: Object.entries(allPointers).map(([key, id]) => ({ key, id: id.toString() }))\n })\n\n return await send(nameUpdateTx, options)\n}\n\ninterface AensUpdateOptions extends\n BuildTxOptions<TX_TYPE.nameUpdate, 'nameId' | 'accountId' | 'pointers' | 'clientTtl' | 'nameTtl'>,\n SendOptions {\n extendPointers?: boolean\n clientTtl?: number\n nameTtl?: number\n}\n\n/**\n * Transfer a domain to another account\n * @param name - AENS name\n * @param account - Recipient account publick key\n * @param options - Options\n * @param options.onAccount - Make operation on specific account from sdk (you pass\n * publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)\n * @param options.fee - fee\n * @param options.ttl - ttl\n * @param options.nonce - nonce\n * @returns Transaction result\n * @example\n * ```js\n * const name = 'test.chain'\n * const recipientPub = 'ak_asd23dasdas...'\n * const nameObject = await sdkInstance.aensQuery(name)\n *\n * await sdkInstance.aensTransfer(name, recipientPub, { ttl, fee, nonce })\n * // or\n * await nameObject.transfer(recipientPub, { ttl, fee, nonce })\n * ```\n */\nexport async function aensTransfer (\n name: AensName, account: EncodedData<'ak'>, options: AensTransferOptions\n): ReturnType<typeof send> {\n const nameTransferTx = await _buildTx(TX_TYPE.nameTransfer, {\n ...options,\n nameId: name,\n accountId: await options.onAccount.address(options),\n recipientId: account\n })\n\n return await send(nameTransferTx, options)\n}\n\ninterface AensTransferOptions extends\n BuildTxOptions<TX_TYPE.nameTransfer, 'nameId' | 'accountId' | 'recipientId'>,\n SendOptions {}\n\n/**\n * Query the AENS name info from the node\n * and return the object with info and predefined functions for manipulating name\n * @param name - AENS name\n * @param opt - Options\n * @returns\n * @example\n * ```js\n * const nameObject = sdkInstance.aensQuery('test.chain')\n * console.log(nameObject)\n * {\n * id, // name hash\n * pointers, // array of pointers\n * update, // Update name function\n * extendTtl, // Extend Ttl name function\n * transfer, // Transfer name function\n * revoke // Revoke name function\n * }\n * ```\n */\nexport async function aensQuery (\n name: AensName,\n opt: Parameters<typeof getName>[1] & Parameters<typeof aensUpdate>[2]\n & Parameters<typeof aensTransfer>[2]\n): Promise<Readonly<\n TransformNodeType<NameEntry> & {\n id: EncodedData<'nm'>\n owner: EncodedData<'ak'>\n pointers: KeyPointers | Pointer[]\n ttl: number\n update: (\n pointers: KeyPointers,\n options?: Omit<Parameters<typeof aensQuery>[1], 'onNode' | 'onCompiler' | 'onAccount'> & {\n onAccount?: AccountBase\n }\n ) => ReturnType<typeof aensUpdate> & ReturnType<typeof aensQuery>\n transfer: (\n account: EncodedData<'ak'>,\n options?: Parameters<typeof aensQuery>[1]\n ) => ReturnType<typeof aensUpdate> & ReturnType<typeof aensQuery>\n revoke: (options?: Omit<Parameters<typeof aensRevoke>[1], 'onNode' | 'onCompiler' | 'onAccount'> & {\n onAccount?: AccountBase\n }\n ) => ReturnType<typeof aensRevoke>\n extendTtl: (\n nameTtl: number,\n options?: Omit<Parameters<typeof aensQuery>[1], 'onNode' | 'onCompiler' | 'onAccount'>\n ) => ReturnType<typeof aensUpdate> & ReturnType<typeof aensQuery>\n }\n >> {\n const nameEntry = await getName(name, opt)\n return Object.freeze({\n ...nameEntry,\n id: nameEntry.id as EncodedData<'nm'>,\n owner: nameEntry.owner as EncodedData<'ak'>,\n async update (pointers, options) {\n return {\n ...await aensUpdate(name, pointers, { ...opt, ...options }),\n ...await aensQuery(name, { ...opt, ...options })\n }\n },\n async transfer (account, options) {\n return {\n ...await aensTransfer(name, account, { ...opt, ...options }),\n ...await aensQuery(name, { ...opt, ...options })\n }\n },\n async revoke (options) {\n return await aensRevoke(name, { ...opt, ...options })\n },\n async extendTtl (nameTtl = NAME_TTL, options) {\n if (nameTtl > NAME_TTL || nameTtl <= 0) {\n throw new ArgumentError('nameTtl', `a number between 1 and ${NAME_TTL} blocks`, nameTtl)\n }\n\n return {\n ...await aensUpdate(name, {}, { ...opt, ...options, nameTtl, extendPointers: true }),\n ...await aensQuery(name, { ...opt, ...options })\n }\n }\n })\n}\n\n/**\n * Claim a previously preclaimed registration. This can only be done after the\n * preclaim step\n * @param name - AENS name\n * @param salt - Salt from pre-claim, or 0 if it's a bid\n * @param options - options\n * @param options.onAccount - Make operation on specific account from sdk (you pass\n * publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)\n * @param options.fee - fee\n * @param options.ttl - ttl\n * @param options.nonce - nonce\n * @param options.nameFee - Name Fee (By default calculated by sdk)\n * @returns the result of the claim\n * @example\n * ```js\n * const name = 'test.chain'\n * const salt = preclaimResult.salt // salt from pre-claim transaction\n *\n * await sdkInstance.aensClaim(name, salt, { ttl, fee, nonce, nameFee })\n * ```\n */\nexport async function aensClaim (\n name: AensName, salt: number, options: AensClaimOptions\n): Promise<AensClaimReturnType> {\n const claimTx = await _buildTx(TX_TYPE.nameClaim, {\n ...options,\n accountId: await options.onAccount.address(options),\n nameSalt: salt,\n name\n })\n\n const result = await send(claimTx, options)\n if (!isAuctionName(name)) {\n const nameInter = result.blockHeight != null && result.blockHeight > 0\n ? await aensQuery(name, options)\n : {}\n return Object.assign(result, nameInter)\n }\n return result\n}\n\ntype AensClaimOptionsType = BuildTxOptions<TX_TYPE.nameClaim, 'accountId' | 'nameSalt' | 'name'>\n& SendOptions & Parameters<typeof aensQuery>[1]\ninterface AensClaimOptions extends AensClaimOptionsType {}\ninterface AensClaimReturnType extends\n Awaited<ReturnType<typeof send>>,\n Partial<Awaited<ReturnType<typeof aensQuery>>> {}\n\n/**\n * Preclaim a name. Sends a hash of the name and a random salt to the node\n * @param name - AENS name\n * @param options - Options\n * @param options.onAccount - Make operation on specific account from sdk (you pass\n * publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)\n * @param options.fee - fee\n * @param options.ttl - ttl\n * @param options.nonce - nonce\n * @example\n * ```js\n * const name = 'test.chain'\n * const salt = preclaimResult.salt // salt from pre-claim transaction\n *\n * await sdkInstance.aensPreclaim(name, { ttl, fee, nonce })\n * {\n * ...transactionResult,\n * claim, // Claim function (options={}) => claimTransactionResult\n * salt,\n * commitmentId\n * }\n * ```\n */\nexport async function aensPreclaim (\n name: AensName, options: AensPreclaimOptions\n): Promise<Readonly<\n Awaited<ReturnType<typeof send>> & {\n height: number\n salt: number\n commitmentId: string\n claim: (opts?: Parameters<typeof aensClaim>[2]) => ReturnType<typeof aensClaim>\n }\n >> {\n const _salt = salt()\n const currentHeight = await height(options)\n const commitmentId = commitmentHash(name, _salt)\n\n const preclaimTx = await _buildTx(TX_TYPE.namePreClaim, {\n ...options,\n accountId: await options.onAccount.address(options),\n commitmentId\n })\n\n return Object.freeze({\n ...await send(preclaimTx, options),\n height: currentHeight,\n salt: _salt,\n commitmentId,\n async claim (opts?: Parameters<typeof aensClaim>[2]) {\n return await aensClaim(name, _salt, { ...options, ...opts })\n }\n })\n}\n\ninterface AensPreclaimOptions extends\n BuildTxOptions<TX_TYPE.namePreClaim, 'accountId' | 'commitmentId'>,\n SendOptions,\n AensClaimOptions {}\n\n/**\n * Bid to name auction\n * @param name - Domain name\n * @param nameFee - Name fee (bid fee)\n * @param options - Options\n * @param options.onAccount - Make operation on specific account from sdk (you pass\n * publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)\n * @param options.fee - fee\n * @param options.ttl - ttl\n * @param options.nonce - nonce\n * @returns Transaction result\n * @example\n * ```js\n * const name = 'test.chain'\n * const bidFee = computeBidFee(name, startFee, incrementPercentage)\n *\n * await sdkInstance.aensBid(name, 213109412839123, { ttl, fee, nonce })\n * ```\n */\nexport async function aensBid (\n name: AensName,\n nameFee: number | string | BigNumber,\n options: Omit<Parameters<typeof aensClaim>[2], 'nameFee'>\n): ReturnType<typeof aensClaim> {\n return await aensClaim(name, 0, { ...options, nameFee })\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;SAESA,I;SACAC,c,EAAgBC,a;SAChBC,U,EAAYC,Q,EAAUC,O;SACtBC,a;SAGAC,I;SACAC,O,EAASC,M;SACTC,Q;;AAST;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,UAAf,CACLC,IADK,EACWC,OADX,EAEoB;EACzB,MAAMC,YAAY,GAAG,MAAMJ,QAAQ,CAACL,OAAO,CAACU,UAAT,EAAqB,EACtD,GAAGF,OADmD;IAEtDG,MAAM,EAAEJ,IAF8C;IAGtDK,SAAS,EAAE,MAAMJ,OAAO,CAACK,SAAR,CAAkBC,OAAlB,CAA0BN,OAA1B;EAHqC,CAArB,CAAnC;EAKA,OAAO,MAAMN,IAAI,CAACO,YAAD,EAAeD,OAAf,CAAjB;AACD;;AAMD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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IACD;;EAPkB,CAAd,CAAP;AASD;;AAOD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,OAAf,CACLrD,IADK,EAELsD,OAFK,EAGLrD,OAHK,EAIyB;EAC9B,OAAO,MAAMoC,SAAS,CAACrC,IAAD,EAAO,CAAP,EAAU,EAAE,GAAGC,OAAL;IAAcqD;EAAd,CAAV,CAAtB;AACD"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Browser connection base interface
3
+ */
4
+ export default abstract class BrowserConnection {
5
+ debug: boolean;
6
+ protected constructor({ debug }: {
7
+ debug?: boolean;
8
+ });
9
+ /**
10
+ * Connect
11
+ * @param onMessage - Message handler
12
+ * @param onDisconnect - trigger when runtime connection in closed
13
+ */
14
+ connect(onMessage: (message: any, origin: string, source: any) => void, onDisconnect: () => void): void;
15
+ /**
16
+ * Disconnect
17
+ */
18
+ disconnect(): void;
19
+ /**
20
+ * Send message
21
+ */
22
+ protected receiveMessage(message: any): void;
23
+ /**
24
+ * Send message
25
+ */
26
+ sendMessage(message: any): void;
27
+ /**
28
+ * Check if connected
29
+ * @returns Is connected
30
+ */
31
+ abstract isConnected(): boolean;
32
+ }
@@ -0,0 +1,70 @@
1
+ /*
2
+ * ISC License (ISC)
3
+ * Copyright (c) 2022 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
+ import { AlreadyConnectedError, NoWalletConnectedError } from "../../utils/errors.mjs";
18
+ /**
19
+ * Browser connection base interface
20
+ */
21
+
22
+ export default class BrowserConnection {
23
+ constructor(_ref) {
24
+ let {
25
+ debug = false
26
+ } = _ref;
27
+ this.debug = debug;
28
+ }
29
+ /**
30
+ * Connect
31
+ * @param onMessage - Message handler
32
+ * @param onDisconnect - trigger when runtime connection in closed
33
+ */
34
+
35
+
36
+ connect(onMessage, onDisconnect) {
37
+ if (this.isConnected()) throw new AlreadyConnectedError('You already connected');
38
+ }
39
+ /**
40
+ * Disconnect
41
+ */
42
+
43
+
44
+ disconnect() {
45
+ if (!this.isConnected()) throw new NoWalletConnectedError('You dont have connection. Please connect before');
46
+ }
47
+ /**
48
+ * Send message
49
+ */
50
+
51
+
52
+ receiveMessage(message) {
53
+ if (this.debug) console.log('Receive message:', message);
54
+ }
55
+ /**
56
+ * Send message
57
+ */
58
+
59
+
60
+ sendMessage(message) {
61
+ if (this.debug) console.log('Send message:', message);
62
+ }
63
+ /**
64
+ * Check if connected
65
+ * @returns Is connected
66
+ */
67
+
68
+
69
+ }
70
+ //# sourceMappingURL=Browser.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Browser.mjs","names":["AlreadyConnectedError","NoWalletConnectedError","BrowserConnection","constructor","debug","connect","onMessage","onDisconnect","isConnected","disconnect","receiveMessage","message","console","log","sendMessage"],"sources":["../../../src/aepp-wallet-communication/connection/Browser.ts"],"sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2022 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\n\nimport { AlreadyConnectedError, NoWalletConnectedError } from '../../utils/errors'\n\n/**\n * Browser connection base interface\n */\nexport default abstract class BrowserConnection {\n debug: boolean\n\n protected constructor ({ debug = false }: { debug?: boolean }) {\n this.debug = debug\n }\n\n /**\n * Connect\n * @param onMessage - Message handler\n * @param onDisconnect - trigger when runtime connection in closed\n */\n connect (\n onMessage: (message: any, origin: string, source: any) => void,\n onDisconnect: () => void\n ): void {\n if (this.isConnected()) throw new AlreadyConnectedError('You already connected')\n }\n\n /**\n * Disconnect\n */\n disconnect (): void {\n if (!this.isConnected()) throw new NoWalletConnectedError('You dont have connection. Please connect before')\n }\n\n /**\n * Send message\n */\n protected receiveMessage (message: any): void {\n if (this.debug) console.log('Receive message:', message)\n }\n\n /**\n * Send message\n */\n sendMessage (message: any): void {\n if (this.debug) console.log('Send message:', message)\n }\n\n /**\n * Check if connected\n * @returns Is connected\n */\n abstract isConnected (): boolean\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;SAESA,qB,EAAuBC,sB;AAEhC;AACA;AACA;;AACA,eAAe,MAAeC,iBAAf,CAAiC;EAGpCC,WAAW,OAA0C;IAAA,IAAxC;MAAEC,KAAK,GAAG;IAAV,CAAwC;IAC7D,KAAKA,KAAL,GAAaA,KAAb;EACD;EAED;AACF;AACA;AACA;AACA;;;EACEC,OAAO,CACLC,SADK,EAELC,YAFK,EAGC;IACN,IAAI,KAAKC,WAAL,EAAJ,EAAwB,MAAM,IAAIR,qBAAJ,CAA0B,uBAA1B,CAAN;EACzB;EAED;AACF;AACA;;;EACES,UAAU,GAAU;IAClB,IAAI,CAAC,KAAKD,WAAL,EAAL,EAAyB,MAAM,IAAIP,sBAAJ,CAA2B,iDAA3B,CAAN;EAC1B;EAED;AACF;AACA;;;EACYS,cAAc,CAAEC,OAAF,EAAsB;IAC5C,IAAI,KAAKP,KAAT,EAAgBQ,OAAO,CAACC,GAAR,CAAY,kBAAZ,EAAgCF,OAAhC;EACjB;EAED;AACF;AACA;;;EACEG,WAAW,CAAEH,OAAF,EAAsB;IAC/B,IAAI,KAAKP,KAAT,EAAgBQ,OAAO,CAACC,GAAR,CAAY,eAAZ,EAA6BF,OAA7B;EACjB;EAED;AACF;AACA;AACA;;;AA3CgD"}
@@ -0,0 +1,17 @@
1
+ import { Runtime } from 'webextension-polyfill';
2
+ import BrowserConnection from './Browser';
3
+ /**
4
+ * BrowserRuntimeConnection
5
+ * Handle browser runtime communication
6
+ */
7
+ export default class BrowserRuntimeConnection extends BrowserConnection {
8
+ port: Runtime.Port;
9
+ constructor({ port, ...options }: {
10
+ port: Runtime.Port;
11
+ debug: boolean;
12
+ });
13
+ disconnect(): void;
14
+ connect(onMessage: (message: any, origin: string, source: Runtime.Port) => void, onDisconnect: () => void): void;
15
+ sendMessage(message: any): void;
16
+ isConnected(): boolean;
17
+ }
@@ -0,0 +1,57 @@
1
+ /*
2
+ * ISC License (ISC)
3
+ * Copyright (c) 2022 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
+ import BrowserConnection from "./Browser.mjs";
18
+ /**
19
+ * BrowserRuntimeConnection
20
+ * Handle browser runtime communication
21
+ */
22
+
23
+ export default class BrowserRuntimeConnection extends BrowserConnection {
24
+ constructor(_ref) {
25
+ let {
26
+ port,
27
+ ...options
28
+ } = _ref;
29
+ super(options);
30
+ this.port = port;
31
+ }
32
+
33
+ disconnect() {
34
+ super.disconnect();
35
+ this.port.disconnect();
36
+ }
37
+
38
+ connect(onMessage, onDisconnect) {
39
+ super.connect(onMessage, onDisconnect);
40
+ this.port.onMessage.addListener((message, port) => {
41
+ this.receiveMessage(message);
42
+ onMessage(message, port.name, port);
43
+ });
44
+ this.port.onDisconnect.addListener(onDisconnect);
45
+ }
46
+
47
+ sendMessage(message) {
48
+ super.sendMessage(message);
49
+ this.port.postMessage(message);
50
+ }
51
+
52
+ isConnected() {
53
+ return this.port.onMessage.hasListeners();
54
+ }
55
+
56
+ }
57
+ //# sourceMappingURL=BrowserRuntime.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BrowserRuntime.mjs","names":["BrowserConnection","BrowserRuntimeConnection","constructor","port","options","disconnect","connect","onMessage","onDisconnect","addListener","message","receiveMessage","name","sendMessage","postMessage","isConnected","hasListeners"],"sources":["../../../src/aepp-wallet-communication/connection/BrowserRuntime.ts"],"sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2022 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\n\nimport { Runtime } from 'webextension-polyfill'\nimport BrowserConnection from './Browser'\n\n/**\n * BrowserRuntimeConnection\n * Handle browser runtime communication\n */\nexport default class BrowserRuntimeConnection extends BrowserConnection {\n port: Runtime.Port\n\n constructor ({ port, ...options }: { port: Runtime.Port, debug: boolean }) {\n super(options)\n this.port = port\n }\n\n disconnect (): void {\n super.disconnect()\n this.port.disconnect()\n }\n\n connect (\n onMessage: (message: any, origin: string, source: Runtime.Port) => void,\n onDisconnect: () => void\n ): void {\n super.connect(onMessage, onDisconnect)\n this.port.onMessage.addListener((message, port) => {\n this.receiveMessage(message)\n onMessage(message, port.name, port)\n })\n this.port.onDisconnect.addListener(onDisconnect)\n }\n\n sendMessage (message: any): void {\n super.sendMessage(message)\n this.port.postMessage(message)\n }\n\n isConnected (): boolean {\n return this.port.onMessage.hasListeners()\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;OAGOA,iB;AAEP;AACA;AACA;AACA;;AACA,eAAe,MAAMC,wBAAN,SAAuCD,iBAAvC,CAAyD;EAGtEE,WAAW,OAAgE;IAAA,IAA9D;MAAEC,IAAF;MAAQ,GAAGC;IAAX,CAA8D;IACzE,MAAMA,OAAN;IACA,KAAKD,IAAL,GAAYA,IAAZ;EACD;;EAEDE,UAAU,GAAU;IAClB,MAAMA,UAAN;IACA,KAAKF,IAAL,CAAUE,UAAV;EACD;;EAEDC,OAAO,CACLC,SADK,EAELC,YAFK,EAGC;IACN,MAAMF,OAAN,CAAcC,SAAd,EAAyBC,YAAzB;IACA,KAAKL,IAAL,CAAUI,SAAV,CAAoBE,WAApB,CAAgC,CAACC,OAAD,EAAUP,IAAV,KAAmB;MACjD,KAAKQ,cAAL,CAAoBD,OAApB;MACAH,SAAS,CAACG,OAAD,EAAUP,IAAI,CAACS,IAAf,EAAqBT,IAArB,CAAT;IACD,CAHD;IAIA,KAAKA,IAAL,CAAUK,YAAV,CAAuBC,WAAvB,CAAmCD,YAAnC;EACD;;EAEDK,WAAW,CAAEH,OAAF,EAAsB;IAC/B,MAAMG,WAAN,CAAkBH,OAAlB;IACA,KAAKP,IAAL,CAAUW,WAAV,CAAsBJ,OAAtB;EACD;;EAEDK,WAAW,GAAa;IACtB,OAAO,KAAKZ,IAAL,CAAUI,SAAV,CAAoBS,YAApB,EAAP;EACD;;AAhCqE"}
@@ -0,0 +1,35 @@
1
+ import BrowserConnection from './Browser';
2
+ import { MESSAGE_DIRECTION } from '../schema';
3
+ export declare type ImplPostMessage = Pick<Window, 'addEventListener' | 'removeEventListener' | 'postMessage'>;
4
+ /**
5
+ * Browser window Post Message connector module
6
+ */
7
+ export default class BrowserWindowMessageConnection extends BrowserConnection {
8
+ #private;
9
+ origin?: string;
10
+ sendDirection?: MESSAGE_DIRECTION;
11
+ receiveDirection: MESSAGE_DIRECTION;
12
+ listener?: (this: Window, ev: MessageEvent<any>) => void;
13
+ /**
14
+ * @param options - Options
15
+ * @param options.target Target window for message
16
+ * @param options.self Host window for message
17
+ * @param options.origin Origin of receiver
18
+ * @param options.sendDirection Wrapping messages into additional struct
19
+ * `({ type: 'to_aepp' || 'to_waellet', data })`
20
+ * Used for handling messages between content script and page
21
+ * @param options.receiveDirection Unwrapping messages from additional struct
22
+ */
23
+ constructor({ target, self, origin, sendDirection, receiveDirection, ...options }?: {
24
+ target?: ImplPostMessage;
25
+ self?: ImplPostMessage;
26
+ origin?: string;
27
+ sendDirection?: MESSAGE_DIRECTION;
28
+ receiveDirection?: MESSAGE_DIRECTION;
29
+ debug?: boolean;
30
+ });
31
+ isConnected(): boolean;
32
+ connect(onMessage: (message: any, origin: string, source: MessageEventSource | null) => void, onDisconnect: () => void): void;
33
+ disconnect(): void;
34
+ sendMessage(msg: any): void;
35
+ }