@aeternity/aepp-sdk 11.0.0 → 12.1.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 (442) hide show
  1. package/LICENSE +1 -1
  2. package/dist/aepp-sdk.browser-script.js +1 -1
  3. package/dist/aepp-sdk.browser-script.js.LICENSE.txt +0 -22
  4. package/dist/aepp-sdk.browser-script.js.map +1 -1
  5. package/dist/aepp-sdk.browser.js +2 -1
  6. package/dist/aepp-sdk.browser.js.LICENSE.txt +1 -0
  7. package/dist/aepp-sdk.browser.js.map +1 -1
  8. package/dist/aepp-sdk.js +20764 -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 +70 -0
  14. package/es/AeSdkAepp.mjs +176 -0
  15. package/es/AeSdkAepp.mjs.map +1 -0
  16. package/es/AeSdkBase.d.ts +213 -0
  17. package/es/AeSdkBase.mjs +314 -0
  18. package/es/AeSdkBase.mjs.map +1 -0
  19. package/es/AeSdkWallet.d.ts +104 -0
  20. package/es/AeSdkWallet.mjs +326 -0
  21. package/es/AeSdkWallet.mjs.map +1 -0
  22. package/es/Node.d.ts +41 -0
  23. package/es/Node.mjs +147 -0
  24. package/es/Node.mjs.map +1 -0
  25. package/es/account/Base.d.ts +68 -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 +26 -0
  29. package/es/account/Memory.mjs +103 -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 +80 -0
  33. package/es/account/Rpc.mjs.map +1 -0
  34. package/es/aens.d.ts +222 -0
  35. package/es/aens.mjs +338 -0
  36. package/es/aens.mjs.map +1 -0
  37. package/es/aepp-wallet-communication/connection/Browser.d.ts +33 -0
  38. package/es/aepp-wallet-communication/connection/Browser.mjs +73 -0
  39. package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -0
  40. package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +18 -0
  41. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +58 -0
  42. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -0
  43. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +36 -0
  44. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +146 -0
  45. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -0
  46. package/es/aepp-wallet-communication/connection-proxy.d.ts +11 -0
  47. package/{src/utils/crypto-ts.ts → es/aepp-wallet-communication/connection-proxy.mjs} +16 -11
  48. package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -0
  49. package/es/aepp-wallet-communication/rpc/RpcClient.d.ts +34 -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 +105 -46
  56. package/es/aepp-wallet-communication/schema.mjs +251 -0
  57. package/es/aepp-wallet-communication/schema.mjs.map +1 -0
  58. package/es/aepp-wallet-communication/wallet-detector.d.ts +25 -0
  59. package/es/aepp-wallet-communication/wallet-detector.mjs +62 -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 +1065 -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 +4166 -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 +248 -0
  92. package/es/chain.mjs +560 -0
  93. package/es/chain.mjs.map +1 -0
  94. package/es/channel/handlers.d.ts +34 -0
  95. package/es/channel/handlers.mjs +164 -131
  96. package/es/channel/handlers.mjs.map +1 -1
  97. package/es/channel/index.d.ts +625 -0
  98. package/es/channel/index.mjs +897 -902
  99. package/es/channel/index.mjs.map +1 -1
  100. package/es/channel/internal.d.ts +101 -0
  101. package/es/channel/internal.mjs +138 -88
  102. package/es/channel/internal.mjs.map +1 -1
  103. package/es/contract/Compiler.d.ts +18 -0
  104. package/es/contract/Compiler.mjs +68 -0
  105. package/es/contract/Compiler.mjs.map +1 -0
  106. package/es/contract/aci.d.ts +127 -0
  107. package/es/contract/aci.mjs +225 -193
  108. package/es/contract/aci.mjs.map +1 -1
  109. package/es/contract/ga.d.ts +69 -0
  110. package/es/contract/ga.mjs +195 -0
  111. package/es/contract/ga.mjs.map +1 -0
  112. package/es/contract/methods.d.ts +71 -0
  113. package/es/contract/methods.mjs +104 -0
  114. package/es/contract/methods.mjs.map +1 -0
  115. package/es/deprecated/index.d.ts +143 -0
  116. package/es/deprecated/index.mjs +162 -0
  117. package/es/deprecated/index.mjs.map +1 -0
  118. package/es/deprecated/methods.d.ts +18 -0
  119. package/es/deprecated/methods.mjs +26 -0
  120. package/es/deprecated/methods.mjs.map +1 -0
  121. package/es/index.d.ts +35 -0
  122. package/es/index.mjs +35 -40
  123. package/es/index.mjs.map +1 -1
  124. package/es/oracle.d.ts +161 -0
  125. package/es/oracle.mjs +306 -0
  126. package/es/oracle.mjs.map +1 -0
  127. package/es/spend.d.ts +62 -0
  128. package/es/spend.mjs +111 -0
  129. package/es/spend.mjs.map +1 -0
  130. package/es/tx/builder/address.d.ts +25 -0
  131. package/es/tx/builder/address.mjs +45 -0
  132. package/es/tx/builder/address.mjs.map +1 -0
  133. package/es/tx/builder/constants.d.ts +70 -0
  134. package/es/tx/builder/constants.mjs +122 -0
  135. package/es/tx/builder/constants.mjs.map +1 -0
  136. package/es/tx/builder/field-types/coin-amount.d.ts +13 -0
  137. package/es/tx/builder/field-types/coin-amount.mjs +26 -0
  138. package/es/tx/builder/field-types/coin-amount.mjs.map +1 -0
  139. package/es/tx/builder/field-types/deposit.d.ts +15 -0
  140. package/es/tx/builder/field-types/deposit.mjs +19 -0
  141. package/es/tx/builder/field-types/deposit.mjs.map +1 -0
  142. package/es/tx/builder/field-types/fee.d.ts +25 -0
  143. package/es/tx/builder/field-types/fee.mjs +150 -0
  144. package/es/tx/builder/field-types/fee.mjs.map +1 -0
  145. package/es/tx/builder/field-types/field.d.ts +6 -0
  146. package/es/tx/builder/field-types/field.mjs +15 -0
  147. package/es/tx/builder/field-types/field.mjs.map +1 -0
  148. package/es/tx/builder/field-types/gas-limit.d.ts +12 -0
  149. package/es/tx/builder/field-types/gas-limit.mjs +33 -0
  150. package/es/tx/builder/field-types/gas-limit.mjs.map +1 -0
  151. package/es/tx/builder/field-types/gas-price.d.ts +8 -0
  152. package/es/tx/builder/field-types/gas-price.mjs +18 -0
  153. package/es/tx/builder/field-types/gas-price.mjs.map +1 -0
  154. package/es/tx/builder/field-types/index.d.ts +70 -0
  155. package/es/tx/builder/field-types/index.mjs +25 -0
  156. package/es/tx/builder/field-types/index.mjs.map +1 -0
  157. package/es/tx/builder/field-types/name-fee.d.ts +20 -0
  158. package/es/tx/builder/field-types/name-fee.mjs +24 -0
  159. package/es/tx/builder/field-types/name-fee.mjs.map +1 -0
  160. package/es/tx/builder/field-types/name-id.d.ts +14 -0
  161. package/es/tx/builder/field-types/name-id.mjs +19 -0
  162. package/es/tx/builder/field-types/name-id.mjs.map +1 -0
  163. package/es/tx/builder/field-types/name.d.ts +13 -0
  164. package/es/tx/builder/field-types/name.mjs +18 -0
  165. package/es/tx/builder/field-types/name.mjs.map +1 -0
  166. package/es/tx/builder/field-types/short-u-int.d.ts +6 -0
  167. package/es/tx/builder/field-types/short-u-int.mjs +12 -0
  168. package/es/tx/builder/field-types/short-u-int.mjs.map +1 -0
  169. package/es/tx/builder/field-types/u-int.d.ts +8 -0
  170. package/es/tx/builder/field-types/u-int.mjs +14 -0
  171. package/es/tx/builder/field-types/u-int.mjs.map +1 -0
  172. package/es/tx/builder/helpers.d.ts +125 -0
  173. package/es/tx/builder/helpers.mjs +94 -240
  174. package/es/tx/builder/helpers.mjs.map +1 -1
  175. package/es/tx/builder/index.d.ts +88 -0
  176. package/es/tx/builder/index.mjs +167 -358
  177. package/es/tx/builder/index.mjs.map +1 -1
  178. package/es/tx/builder/schema.d.ts +1201 -0
  179. package/es/tx/builder/schema.mjs +175 -664
  180. package/es/tx/builder/schema.mjs.map +1 -1
  181. package/es/tx/index.d.ts +64 -0
  182. package/es/tx/index.mjs +151 -265
  183. package/es/tx/index.mjs.map +1 -1
  184. package/es/tx/validator.d.ts +20 -0
  185. package/es/tx/validator.mjs +104 -124
  186. package/es/tx/validator.mjs.map +1 -1
  187. package/es/typings/@aeternity__argon2-browser/index.d.mjs +2 -0
  188. package/es/typings/@aeternity__argon2-browser/index.d.mjs.map +1 -0
  189. package/es/typings/@aeternity__uuid/index.d.mjs +2 -0
  190. package/es/typings/@aeternity__uuid/index.d.mjs.map +1 -0
  191. package/es/typings/bip32-path/index.d.mjs +2 -0
  192. package/es/typings/bip32-path/index.d.mjs.map +1 -0
  193. package/es/typings/blakejs/index.d.mjs.map +1 -1
  194. package/es/typings/sha-js/index.d.mjs +2 -0
  195. package/es/typings/sha-js/index.d.mjs.map +1 -0
  196. package/es/typings/tweetnacl-auth/index.d.mjs +2 -0
  197. package/es/typings/tweetnacl-auth/index.d.mjs.map +1 -0
  198. package/es/utils/amount-formatter.d.ts +42 -0
  199. package/es/utils/amount-formatter.mjs +36 -49
  200. package/es/utils/amount-formatter.mjs.map +1 -1
  201. package/es/utils/autorest.d.ts +6 -0
  202. package/es/utils/autorest.mjs +97 -0
  203. package/es/utils/autorest.mjs.map +1 -0
  204. package/es/utils/bignumber.d.ts +13 -0
  205. package/es/utils/bignumber.mjs +11 -8
  206. package/es/utils/bignumber.mjs.map +1 -1
  207. package/es/{bytes.d.ts → utils/bytes.d.ts} +10 -13
  208. package/es/utils/bytes.mjs +11 -15
  209. package/es/utils/bytes.mjs.map +1 -1
  210. package/es/utils/crypto.d.ts +88 -0
  211. package/es/utils/crypto.mjs +64 -108
  212. package/es/utils/crypto.mjs.map +1 -1
  213. package/es/utils/encoder-types.d.ts +61 -0
  214. package/es/utils/encoder-types.mjs +36 -0
  215. package/es/utils/encoder-types.mjs.map +1 -0
  216. package/es/utils/encoder.d.ts +25 -0
  217. package/es/utils/encoder.mjs +118 -0
  218. package/es/utils/encoder.mjs.map +1 -0
  219. package/es/{errors.d.ts → utils/errors.d.ts} +246 -59
  220. package/es/utils/errors.mjs +313 -136
  221. package/es/utils/errors.mjs.map +1 -1
  222. package/es/utils/hd-wallet.d.ts +50 -0
  223. package/es/utils/hd-wallet.mjs +86 -45
  224. package/es/utils/hd-wallet.mjs.map +1 -1
  225. package/es/utils/json-big.d.ts +5 -0
  226. package/es/utils/json-big.mjs +12 -16
  227. package/es/utils/json-big.mjs.map +1 -1
  228. package/es/utils/keystore.d.ts +51 -0
  229. package/es/utils/keystore.mjs +101 -194
  230. package/es/utils/keystore.mjs.map +1 -1
  231. package/es/{mptree.d.ts → utils/mptree.d.ts} +6 -9
  232. package/es/utils/mptree.mjs +22 -18
  233. package/es/utils/mptree.mjs.map +1 -1
  234. package/es/utils/other.d.ts +20 -0
  235. package/es/utils/other.mjs +32 -35
  236. package/es/utils/other.mjs.map +1 -1
  237. package/es/utils/semver-satisfies.d.ts +1 -0
  238. package/es/utils/semver-satisfies.mjs +2 -2
  239. package/es/utils/semver-satisfies.mjs.map +1 -1
  240. package/es/utils/string.d.ts +24 -0
  241. package/es/utils/string.mjs +8 -10
  242. package/es/utils/string.mjs.map +1 -1
  243. package/package.json +56 -42
  244. package/src/AeSdk.ts +68 -0
  245. package/src/AeSdkAepp.ts +176 -0
  246. package/src/AeSdkBase.ts +338 -0
  247. package/src/AeSdkWallet.ts +348 -0
  248. package/src/Node.ts +173 -0
  249. package/src/account/Base.ts +124 -0
  250. package/src/account/Memory.ts +98 -0
  251. package/src/account/Rpc.ts +69 -0
  252. package/src/aens.ts +407 -0
  253. package/src/aepp-wallet-communication/connection/Browser.ts +71 -0
  254. package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +59 -0
  255. package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +122 -0
  256. package/{es/utils/crypto-ts.mjs → src/aepp-wallet-communication/connection-proxy.ts} +18 -18
  257. package/src/aepp-wallet-communication/rpc/RpcClient.ts +143 -0
  258. package/src/aepp-wallet-communication/rpc/types.ts +66 -0
  259. package/src/aepp-wallet-communication/schema.ts +224 -0
  260. package/src/aepp-wallet-communication/wallet-detector.ts +72 -0
  261. package/src/apis/compiler/code-model-v4.yaml +2649 -0
  262. package/src/apis/compiler/compiler.ts +585 -0
  263. package/src/apis/compiler/index.ts +2 -0
  264. package/src/apis/compiler/models/index.ts +301 -0
  265. package/src/apis/compiler/models/mappers.ts +583 -0
  266. package/src/apis/compiler/models/parameters.ts +93 -0
  267. package/src/apis/node/code-model-v4.yaml +10080 -0
  268. package/src/apis/node/index.ts +2 -0
  269. package/src/apis/node/models/index.ts +1257 -0
  270. package/src/apis/node/models/mappers.ts +4280 -0
  271. package/src/apis/node/models/parameters.ts +188 -0
  272. package/src/apis/node/node.ts +1299 -0
  273. package/src/chain.ts +502 -0
  274. package/src/channel/handlers.ts +817 -0
  275. package/src/channel/index.ts +1025 -0
  276. package/src/channel/internal.ts +361 -0
  277. package/src/contract/Compiler.ts +67 -0
  278. package/src/contract/aci.ts +538 -0
  279. package/src/contract/ga.ts +199 -0
  280. package/src/contract/methods.ts +123 -0
  281. package/src/deprecated/index.ts +170 -0
  282. package/src/deprecated/methods.ts +25 -0
  283. package/src/index.ts +56 -0
  284. package/src/oracle.ts +364 -0
  285. package/src/spend.ts +164 -0
  286. package/src/tx/builder/address.ts +50 -0
  287. package/src/tx/builder/constants.ts +126 -0
  288. package/src/tx/builder/field-types/coin-amount.ts +27 -0
  289. package/src/tx/builder/field-types/deposit.ts +21 -0
  290. package/src/tx/builder/field-types/fee.ts +143 -0
  291. package/src/tx/builder/field-types/field.ts +9 -0
  292. package/src/tx/builder/field-types/gas-limit.ts +41 -0
  293. package/src/tx/builder/field-types/gas-price.ts +16 -0
  294. package/src/tx/builder/field-types/index.ts +45 -0
  295. package/src/tx/builder/field-types/name-fee.ts +32 -0
  296. package/src/tx/builder/field-types/name-id.ts +20 -0
  297. package/src/tx/builder/field-types/name.ts +18 -0
  298. package/src/tx/builder/field-types/short-u-int.ts +11 -0
  299. package/src/tx/builder/field-types/u-int.ts +16 -0
  300. package/src/tx/builder/helpers.ts +248 -0
  301. package/src/tx/builder/index.ts +400 -0
  302. package/src/tx/builder/schema.ts +727 -0
  303. package/src/tx/index.ts +192 -0
  304. package/src/tx/validator.ts +230 -0
  305. package/src/typings/@aeternity__argon2-browser/index.d.ts +3 -0
  306. package/src/typings/@aeternity__uuid/index.d.ts +5 -0
  307. package/src/typings/bip32-path/index.d.ts +33 -0
  308. package/src/typings/blakejs/index.d.ts +4 -32
  309. package/src/typings/sha-js/index.d.ts +5 -0
  310. package/src/typings/tweetnacl-auth/index.d.ts +14 -0
  311. package/src/utils/amount-formatter.ts +56 -69
  312. package/src/utils/autorest.ts +93 -0
  313. package/src/utils/bignumber.ts +11 -12
  314. package/src/utils/bytes.ts +29 -31
  315. package/src/utils/crypto.ts +205 -0
  316. package/src/utils/encoder-types.ts +63 -0
  317. package/src/utils/encoder.ts +146 -0
  318. package/src/utils/errors.ts +482 -366
  319. package/src/utils/hd-wallet.ts +166 -0
  320. package/src/utils/json-big.ts +27 -0
  321. package/src/utils/keystore.ts +182 -0
  322. package/src/utils/mptree.ts +64 -61
  323. package/src/utils/other.ts +34 -41
  324. package/src/utils/semver-satisfies.ts +15 -11
  325. package/src/utils/string.ts +18 -20
  326. package/es/account/base.mjs +0 -179
  327. package/es/account/base.mjs.map +0 -1
  328. package/es/account/memory.mjs +0 -99
  329. package/es/account/memory.mjs.map +0 -1
  330. package/es/account/multiple.mjs +0 -179
  331. package/es/account/multiple.mjs.map +0 -1
  332. package/es/ae/aens.mjs +0 -404
  333. package/es/ae/aens.mjs.map +0 -1
  334. package/es/ae/aepp.mjs +0 -45
  335. package/es/ae/aepp.mjs.map +0 -1
  336. package/es/ae/contract.mjs +0 -159
  337. package/es/ae/contract.mjs.map +0 -1
  338. package/es/ae/index.mjs +0 -207
  339. package/es/ae/index.mjs.map +0 -1
  340. package/es/ae/oracle.mjs +0 -339
  341. package/es/ae/oracle.mjs.map +0 -1
  342. package/es/ae/universal.mjs +0 -45
  343. package/es/ae/universal.mjs.map +0 -1
  344. package/es/ae/wallet.mjs +0 -50
  345. package/es/ae/wallet.mjs.map +0 -1
  346. package/es/amount-formatter.d.ts +0 -58
  347. package/es/bignumber.d.ts +0 -18
  348. package/es/chain/index.mjs +0 -272
  349. package/es/chain/index.mjs.map +0 -1
  350. package/es/chain/node.mjs +0 -442
  351. package/es/chain/node.mjs.map +0 -1
  352. package/es/contract/compiler.mjs +0 -115
  353. package/es/contract/compiler.mjs.map +0 -1
  354. package/es/contract/ga/helpers.mjs +0 -30
  355. package/es/contract/ga/helpers.mjs.map +0 -1
  356. package/es/contract/ga/index.mjs +0 -178
  357. package/es/contract/ga/index.mjs.map +0 -1
  358. package/es/crypto-ts.d.ts +0 -9
  359. package/es/node-pool/index.mjs +0 -188
  360. package/es/node-pool/index.mjs.map +0 -1
  361. package/es/node.mjs +0 -133
  362. package/es/node.mjs.map +0 -1
  363. package/es/other.d.ts +0 -31
  364. package/es/semver-satisfies.d.ts +0 -1
  365. package/es/string.d.ts +0 -26
  366. package/es/tx/builder/field-types.mjs +0 -74
  367. package/es/tx/builder/field-types.mjs.map +0 -1
  368. package/es/tx/tx-object.mjs +0 -283
  369. package/es/tx/tx-object.mjs.map +0 -1
  370. package/es/tx/tx.mjs +0 -938
  371. package/es/tx/tx.mjs.map +0 -1
  372. package/es/utils/aepp-wallet-communication/connection/browser-runtime.mjs +0 -132
  373. package/es/utils/aepp-wallet-communication/connection/browser-runtime.mjs.map +0 -1
  374. package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs +0 -183
  375. package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs.map +0 -1
  376. package/es/utils/aepp-wallet-communication/connection/index.mjs +0 -87
  377. package/es/utils/aepp-wallet-communication/connection/index.mjs.map +0 -1
  378. package/es/utils/aepp-wallet-communication/content-script-bridge.mjs +0 -98
  379. package/es/utils/aepp-wallet-communication/content-script-bridge.mjs.map +0 -1
  380. package/es/utils/aepp-wallet-communication/helpers.mjs +0 -92
  381. package/es/utils/aepp-wallet-communication/helpers.mjs.map +0 -1
  382. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs +0 -375
  383. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs.map +0 -1
  384. package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs +0 -275
  385. package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs.map +0 -1
  386. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs +0 -541
  387. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs.map +0 -1
  388. package/es/utils/aepp-wallet-communication/schema.mjs +0 -102
  389. package/es/utils/aepp-wallet-communication/schema.mjs.map +0 -1
  390. package/es/utils/aepp-wallet-communication/wallet-detector.mjs +0 -110
  391. package/es/utils/aepp-wallet-communication/wallet-detector.mjs.map +0 -1
  392. package/es/utils/async-init.mjs +0 -64
  393. package/es/utils/async-init.mjs.map +0 -1
  394. package/es/utils/crypto-ts.mjs.map +0 -1
  395. package/es/utils/swagger.mjs +0 -164
  396. package/es/utils/swagger.mjs.map +0 -1
  397. package/src/account/base.js +0 -153
  398. package/src/account/memory.js +0 -83
  399. package/src/account/multiple.js +0 -162
  400. package/src/ae/aens.js +0 -361
  401. package/src/ae/aepp.js +0 -45
  402. package/src/ae/contract.js +0 -148
  403. package/src/ae/index.js +0 -168
  404. package/src/ae/oracle.js +0 -311
  405. package/src/ae/universal.js +0 -47
  406. package/src/ae/wallet.js +0 -50
  407. package/src/chain/index.js +0 -269
  408. package/src/chain/node.js +0 -320
  409. package/src/channel/handlers.js +0 -673
  410. package/src/channel/index.js +0 -898
  411. package/src/channel/internal.js +0 -237
  412. package/src/contract/aci.js +0 -376
  413. package/src/contract/compiler.js +0 -100
  414. package/src/contract/ga/helpers.js +0 -19
  415. package/src/contract/ga/index.js +0 -150
  416. package/src/index.js +0 -89
  417. package/src/node-pool/index.js +0 -172
  418. package/src/node.js +0 -116
  419. package/src/tx/builder/field-types.js +0 -61
  420. package/src/tx/builder/helpers.js +0 -380
  421. package/src/tx/builder/index.js +0 -465
  422. package/src/tx/builder/schema.js +0 -1197
  423. package/src/tx/index.js +0 -301
  424. package/src/tx/tx-object.js +0 -187
  425. package/src/tx/tx.js +0 -631
  426. package/src/tx/validator.js +0 -181
  427. package/src/utils/aepp-wallet-communication/connection/browser-runtime.js +0 -119
  428. package/src/utils/aepp-wallet-communication/connection/browser-window-message.js +0 -165
  429. package/src/utils/aepp-wallet-communication/connection/index.js +0 -85
  430. package/src/utils/aepp-wallet-communication/content-script-bridge.js +0 -86
  431. package/src/utils/aepp-wallet-communication/helpers.js +0 -60
  432. package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +0 -294
  433. package/src/utils/aepp-wallet-communication/rpc/rpc-client.js +0 -232
  434. package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +0 -401
  435. package/src/utils/aepp-wallet-communication/schema.ts +0 -80
  436. package/src/utils/aepp-wallet-communication/wallet-detector.js +0 -92
  437. package/src/utils/async-init.js +0 -45
  438. package/src/utils/crypto.js +0 -229
  439. package/src/utils/hd-wallet.js +0 -100
  440. package/src/utils/json-big.js +0 -26
  441. package/src/utils/keystore.js +0 -219
  442. package/src/utils/swagger.js +0 -156
package/es/aens.mjs ADDED
@@ -0,0 +1,338 @@
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 { genSalt } from "./utils/crypto.mjs";
26
+ import { commitmentHash, isAuctionName } from "./tx/builder/helpers.mjs";
27
+ import { CLIENT_TTL, NAME_TTL, Tag } from "./tx/builder/constants.mjs";
28
+ import { ArgumentError } from "./utils/errors.mjs";
29
+ import { send } from "./spend.mjs";
30
+ import { getName, getHeight } from "./chain.mjs";
31
+ import { _buildTx } from "./tx/index.mjs";
32
+
33
+ /**
34
+ * Revoke a name
35
+ * @category AENS
36
+ * @param name - Name hash
37
+ * @param options - Options
38
+ * @param options.onAccount - Make operation on specific account from sdk (you pass
39
+ * publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)
40
+ * @param options.fee - fee
41
+ * @param options.ttl - ttl
42
+ * @param options.nonce - nonce
43
+ * @returns Transaction result
44
+ * @example
45
+ * ```js
46
+ * const name = 'test.chain'
47
+ * const nameObject = await sdkInstance.aensQuery(name)
48
+ *
49
+ * await sdkInstance.aensRevoke(name, { fee, ttl , nonce })
50
+ * // or
51
+ * await nameObject.revoke({ fee, ttl, nonce })
52
+ * ```
53
+ */
54
+ export async function aensRevoke(name, options) {
55
+ const nameRevokeTx = await _buildTx(Tag.NameRevokeTx, { ...options,
56
+ nameId: name,
57
+ accountId: await options.onAccount.address(options)
58
+ });
59
+ return send(nameRevokeTx, options);
60
+ }
61
+
62
+ /**
63
+ * Update a name
64
+ * @category AENS
65
+ * @param name - AENS name
66
+ * @param pointers - Map of pointer keys to corresponding addresses
67
+ * @param options - Options
68
+ * @param options.extendPointers - Get the pointers from the node and merge with provided
69
+ * ones. Pointers with the same type will be overwritten
70
+ * @param options.onAccount - Make operation on specific account from sdk (you
71
+ * pass publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)
72
+ * @param options.fee - fee
73
+ * @param options.ttl - ttl
74
+ * @param options.nonce - nonce
75
+ * @param options.nameTtl - Name ttl represented in number of
76
+ * blocks (Max value is 50000 blocks)
77
+ * @param options.clientTtl=84600 a suggestion as to how long any
78
+ * clients should cache this information
79
+ * @throws Invalid pointer array error
80
+ * @example
81
+ * ```js
82
+ * const name = 'test.chain'
83
+ * const pointersArray = ['ak_asd23dasdas...,' 'ct_asdf34fasdasd...']
84
+ * const nameObject = await sdkInstance.aensQuery(name)
85
+ *
86
+ * await sdkInstance.aensUpdate(name, pointersArray, { nameTtl, ttl, fee, nonce, clientTtl })
87
+ * // or
88
+ * await nameObject.update(pointers, { nameTtl, ttl, fee, nonce, clientTtl })
89
+ * ```
90
+ */
91
+ export async function aensUpdate(name, pointers, _ref) {
92
+ let {
93
+ extendPointers,
94
+ ...options
95
+ } = _ref;
96
+ const allPointers = { ...(extendPointers === true && Object.fromEntries((await getName(name, options)).pointers.map(_ref2 => {
97
+ let {
98
+ key,
99
+ id
100
+ } = _ref2;
101
+ return [key, id];
102
+ }))),
103
+ ...pointers
104
+ };
105
+ const nameUpdateTx = await _buildTx(Tag.NameUpdateTx, {
106
+ clientTtl: CLIENT_TTL,
107
+ nameTtl: NAME_TTL,
108
+ ...options,
109
+ nameId: name,
110
+ accountId: await options.onAccount.address(options),
111
+ pointers: Object.entries(allPointers).map(_ref3 => {
112
+ let [key, id] = _ref3;
113
+ return {
114
+ key,
115
+ id: id.toString()
116
+ };
117
+ })
118
+ });
119
+ return send(nameUpdateTx, options);
120
+ }
121
+
122
+ /**
123
+ * Transfer a domain to another account
124
+ * @category AENS
125
+ * @param name - AENS name
126
+ * @param account - Recipient account publick key
127
+ * @param options - Options
128
+ * @param options.onAccount - Make operation on specific account from sdk (you pass
129
+ * publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)
130
+ * @param options.fee - fee
131
+ * @param options.ttl - ttl
132
+ * @param options.nonce - nonce
133
+ * @returns Transaction result
134
+ * @example
135
+ * ```js
136
+ * const name = 'test.chain'
137
+ * const recipientPub = 'ak_asd23dasdas...'
138
+ * const nameObject = await sdkInstance.aensQuery(name)
139
+ *
140
+ * await sdkInstance.aensTransfer(name, recipientPub, { ttl, fee, nonce })
141
+ * // or
142
+ * await nameObject.transfer(recipientPub, { ttl, fee, nonce })
143
+ * ```
144
+ */
145
+ export async function aensTransfer(name, account, options) {
146
+ const nameTransferTx = await _buildTx(Tag.NameTransferTx, { ...options,
147
+ nameId: name,
148
+ accountId: await options.onAccount.address(options),
149
+ recipientId: account
150
+ });
151
+ return send(nameTransferTx, options);
152
+ }
153
+
154
+ /**
155
+ * Query the AENS name info from the node
156
+ * and return the object with info and predefined functions for manipulating name
157
+ * @category AENS
158
+ * @param name - AENS name
159
+ * @param opt - Options
160
+ * @returns
161
+ * @example
162
+ * ```js
163
+ * const nameObject = sdkInstance.aensQuery('test.chain')
164
+ * console.log(nameObject)
165
+ * {
166
+ * id, // name hash
167
+ * pointers, // array of pointers
168
+ * update, // Update name function
169
+ * extendTtl, // Extend Ttl name function
170
+ * transfer, // Transfer name function
171
+ * revoke // Revoke name function
172
+ * }
173
+ * ```
174
+ */
175
+ export async function aensQuery(name, opt) {
176
+ const nameEntry = await getName(name, opt);
177
+ return Object.freeze({ ...nameEntry,
178
+ id: nameEntry.id,
179
+ owner: nameEntry.owner,
180
+
181
+ async update(pointers, options) {
182
+ return { ...(await aensUpdate(name, pointers, { ...opt,
183
+ ...options
184
+ })),
185
+ ...(await aensQuery(name, { ...opt,
186
+ ...options
187
+ }))
188
+ };
189
+ },
190
+
191
+ async transfer(account, options) {
192
+ return { ...(await aensTransfer(name, account, { ...opt,
193
+ ...options
194
+ })),
195
+ ...(await aensQuery(name, { ...opt,
196
+ ...options
197
+ }))
198
+ };
199
+ },
200
+
201
+ async revoke(options) {
202
+ return aensRevoke(name, { ...opt,
203
+ ...options
204
+ });
205
+ },
206
+
207
+ async extendTtl() {
208
+ let nameTtl = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : NAME_TTL;
209
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
210
+
211
+ if (nameTtl > NAME_TTL || nameTtl <= 0) {
212
+ throw new ArgumentError('nameTtl', `a number between 1 and ${NAME_TTL} blocks`, nameTtl);
213
+ }
214
+
215
+ return { ...(await aensUpdate(name, {}, { ...opt,
216
+ ...options,
217
+ nameTtl,
218
+ extendPointers: true
219
+ })),
220
+ ...(await aensQuery(name, { ...opt,
221
+ ...options
222
+ }))
223
+ };
224
+ }
225
+
226
+ });
227
+ }
228
+ /**
229
+ * Claim a previously preclaimed registration. This can only be done after the
230
+ * preclaim step
231
+ * @category AENS
232
+ * @param name - AENS name
233
+ * @param salt - Salt from pre-claim, or 0 if it's a bid
234
+ * @param options - options
235
+ * @param options.onAccount - Make operation on specific account from sdk (you pass
236
+ * publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)
237
+ * @param options.fee - fee
238
+ * @param options.ttl - ttl
239
+ * @param options.nonce - nonce
240
+ * @param options.nameFee - Name Fee (By default calculated by sdk)
241
+ * @returns the result of the claim
242
+ * @example
243
+ * ```js
244
+ * const name = 'test.chain'
245
+ * const salt = preclaimResult.salt // salt from pre-claim transaction
246
+ *
247
+ * await sdkInstance.aensClaim(name, salt, { ttl, fee, nonce, nameFee })
248
+ * ```
249
+ */
250
+
251
+ export async function aensClaim(name, salt, options) {
252
+ const claimTx = await _buildTx(Tag.NameClaimTx, { ...options,
253
+ accountId: await options.onAccount.address(options),
254
+ nameSalt: salt,
255
+ name
256
+ });
257
+ const result = await send(claimTx, options);
258
+
259
+ if (!isAuctionName(name)) {
260
+ const nameInter = result.blockHeight != null && result.blockHeight > 0 ? await aensQuery(name, options) : {};
261
+ return Object.assign(result, nameInter);
262
+ }
263
+
264
+ return result;
265
+ }
266
+
267
+ /**
268
+ * Preclaim a name. Sends a hash of the name and a random salt to the node
269
+ * @category AENS
270
+ * @param name - AENS name
271
+ * @param options - Options
272
+ * @param options.onAccount - Make operation on specific account from sdk (you pass
273
+ * publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)
274
+ * @param options.fee - fee
275
+ * @param options.ttl - ttl
276
+ * @param options.nonce - nonce
277
+ * @example
278
+ * ```js
279
+ * const name = 'test.chain'
280
+ * const salt = preclaimResult.salt // salt from pre-claim transaction
281
+ *
282
+ * await sdkInstance.aensPreclaim(name, { ttl, fee, nonce })
283
+ * {
284
+ * ...transactionResult,
285
+ * claim, // Claim function (options={}) => claimTransactionResult
286
+ * salt,
287
+ * commitmentId
288
+ * }
289
+ * ```
290
+ */
291
+ export async function aensPreclaim(name, options) {
292
+ const salt = genSalt();
293
+ const height = await getHeight(options);
294
+ const commitmentId = commitmentHash(name, salt);
295
+ const preclaimTx = await _buildTx(Tag.NamePreclaimTx, { ...options,
296
+ accountId: await options.onAccount.address(options),
297
+ commitmentId
298
+ });
299
+ return Object.freeze({ ...(await send(preclaimTx, options)),
300
+ height,
301
+ salt,
302
+ commitmentId,
303
+
304
+ async claim(opts) {
305
+ return aensClaim(name, salt, { ...options,
306
+ ...opts
307
+ });
308
+ }
309
+
310
+ });
311
+ }
312
+
313
+ /**
314
+ * Bid to name auction
315
+ * @category AENS
316
+ * @param name - Domain name
317
+ * @param nameFee - Name fee (bid fee)
318
+ * @param options - Options
319
+ * @param options.onAccount - Make operation on specific account from sdk (you pass
320
+ * publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)
321
+ * @param options.fee - fee
322
+ * @param options.ttl - ttl
323
+ * @param options.nonce - nonce
324
+ * @returns Transaction result
325
+ * @example
326
+ * ```js
327
+ * const name = 'test.chain'
328
+ * const bidFee = computeBidFee(name, startFee, incrementPercentage)
329
+ *
330
+ * await sdkInstance.aensBid(name, 213109412839123, { ttl, fee, nonce })
331
+ * ```
332
+ */
333
+ export async function aensBid(name, nameFee, options) {
334
+ return aensClaim(name, 0, { ...options,
335
+ nameFee
336
+ });
337
+ }
338
+ //# sourceMappingURL=aens.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aens.mjs","names":["genSalt","commitmentHash","isAuctionName","CLIENT_TTL","NAME_TTL","Tag","ArgumentError","send","getName","getHeight","_buildTx","aensRevoke","name","options","nameRevokeTx","NameRevokeTx","nameId","accountId","onAccount","address","aensUpdate","pointers","extendPointers","allPointers","Object","fromEntries","map","key","id","nameUpdateTx","NameUpdateTx","clientTtl","nameTtl","entries","toString","aensTransfer","account","nameTransferTx","NameTransferTx","recipientId","aensQuery","opt","nameEntry","freeze","owner","update","transfer","revoke","extendTtl","aensClaim","salt","claimTx","NameClaimTx","nameSalt","result","nameInter","blockHeight","assign","aensPreclaim","height","commitmentId","preclaimTx","NamePreclaimTx","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 BigNumber from 'bignumber.js';\nimport { genSalt } from './utils/crypto';\nimport { commitmentHash, isAuctionName } from './tx/builder/helpers';\nimport {\n CLIENT_TTL, NAME_TTL, Tag, AensName,\n} from './tx/builder/constants';\nimport { ArgumentError } from './utils/errors';\nimport { Encoded } from './utils/encoder';\nimport { send, SendOptions } from './spend';\nimport { getName, getHeight } from './chain';\nimport { _buildTx, BuildTxOptions } from './tx';\nimport { TransformNodeType } from './Node';\nimport { NameEntry, NamePointer } from './apis/node';\nimport AccountBase from './account/Base';\n\ninterface KeyPointers {\n [key: string]: string | Buffer;\n}\n\n/**\n * Revoke a name\n * @category AENS\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,\n options: AensRevokeOptions,\n): ReturnType<typeof send> {\n const nameRevokeTx = await _buildTx(Tag.NameRevokeTx, {\n ...options,\n nameId: name,\n accountId: await options.onAccount.address(options),\n });\n return send(nameRevokeTx, options);\n}\n\ninterface AensRevokeOptions extends\n BuildTxOptions<Tag.NameRevokeTx, 'nameId' | 'accountId'>,\n SendOptions {}\n\n/**\n * Update a name\n * @category AENS\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,\n pointers: KeyPointers,\n { 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(Tag.NameUpdateTx, {\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 send(nameUpdateTx, options);\n}\n\ninterface AensUpdateOptions extends\n BuildTxOptions<Tag.NameUpdateTx, '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 * @category AENS\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,\n account: Encoded.AccountAddress,\n options: AensTransferOptions,\n): ReturnType<typeof send> {\n const nameTransferTx = await _buildTx(Tag.NameTransferTx, {\n ...options,\n nameId: name,\n accountId: await options.onAccount.address(options),\n recipientId: account,\n });\n\n return send(nameTransferTx, options);\n}\n\ninterface AensTransferOptions extends\n BuildTxOptions<Tag.NameTransferTx, '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 * @category AENS\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: Encoded.Name;\n owner: Encoded.AccountAddress;\n pointers: KeyPointers | NamePointer[];\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: Encoded.AccountAddress,\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 Encoded.Name,\n owner: nameEntry.owner as Encoded.AccountAddress,\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 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, {}, {\n ...opt, ...options, nameTtl, extendPointers: true,\n }),\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 * @category AENS\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,\n salt: number,\n options: AensClaimOptions,\n): Promise<AensClaimReturnType> {\n const claimTx = await _buildTx(Tag.NameClaimTx, {\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<Tag.NameClaimTx, '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 * @category AENS\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(name: AensName, options: AensPreclaimOptions): Promise<Readonly<\nAwaited<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 = genSalt();\n const height = await getHeight(options);\n const commitmentId = commitmentHash(name, salt);\n\n const preclaimTx = await _buildTx(Tag.NamePreclaimTx, {\n ...options,\n accountId: await options.onAccount.address(options),\n commitmentId,\n });\n\n return Object.freeze({\n ...await send(preclaimTx, options),\n height,\n salt,\n commitmentId,\n async claim(opts?: Parameters<typeof aensClaim>[2]) {\n return aensClaim(name, salt, { ...options, ...opts });\n },\n });\n}\n\ninterface AensPreclaimOptions extends\n BuildTxOptions<Tag.NamePreclaimTx, 'accountId' | 'commitmentId'>,\n SendOptions,\n AensClaimOptions {}\n\n/**\n * Bid to name auction\n * @category AENS\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 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;SAGSA,O;SACAC,c,EAAgBC,a;SAEvBC,U,EAAYC,Q,EAAUC,G;SAEfC,a;SAEAC,I;SACAC,O,EAASC,S;SACTC,Q;;AAST;AACA;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,EAELC,OAFK,EAGoB;EACzB,MAAMC,YAAY,GAAG,MAAMJ,QAAQ,CAACL,GAAG,CAACU,YAAL,EAAmB,EACpD,GAAGF,OADiD;IAEpDG,MAAM,EAAEJ,IAF4C;IAGpDK,SAAS,EAAE,MAAMJ,OAAO,CAACK,SAAR,CAAkBC,OAAlB,CAA0BN,OAA1B;EAHmC,CAAnB,CAAnC;EAKA,OAAON,IAAI,CAACO,YAAD,EAAeD,OAAf,CAAX;AACD;;AAMD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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mD;MAAjB,CAAb,CAAhB;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;AACA,OAAO,eAAeC,OAAf,CACLrD,IADK,EAELsD,OAFK,EAGLrD,OAHK,EAIyB;EAC9B,OAAOoC,SAAS,CAACrC,IAAD,EAAO,CAAP,EAAU,EAAE,GAAGC,OAAL;IAAcqD;EAAd,CAAV,CAAhB;AACD"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Browser connection base interface
3
+ * @category aepp wallet communication
4
+ */
5
+ export default abstract class BrowserConnection {
6
+ debug: boolean;
7
+ protected constructor({ debug }: {
8
+ debug?: boolean;
9
+ });
10
+ /**
11
+ * Connect
12
+ * @param onMessage - Message handler
13
+ * @param onDisconnect - trigger when runtime connection in closed
14
+ */
15
+ connect(onMessage: (message: any, origin: string, source: any) => void, onDisconnect: () => void): void;
16
+ /**
17
+ * Disconnect
18
+ */
19
+ disconnect(): void;
20
+ /**
21
+ * Receive message
22
+ */
23
+ protected receiveMessage(message: any): void;
24
+ /**
25
+ * Send message
26
+ */
27
+ sendMessage(message: any): void;
28
+ /**
29
+ * Check if connected
30
+ * @returns Is connected
31
+ */
32
+ abstract isConnected(): boolean;
33
+ }
@@ -0,0 +1,73 @@
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
+ * @category aepp wallet communication
21
+ */
22
+
23
+ export default class BrowserConnection {
24
+ constructor(_ref) {
25
+ let {
26
+ debug = false
27
+ } = _ref;
28
+ this.debug = debug;
29
+ }
30
+ /**
31
+ * Connect
32
+ * @param onMessage - Message handler
33
+ * @param onDisconnect - trigger when runtime connection in closed
34
+ */
35
+
36
+
37
+ connect( // eslint-disable-next-line @typescript-eslint/no-unused-vars
38
+ onMessage, // eslint-disable-next-line @typescript-eslint/no-unused-vars
39
+ onDisconnect) {
40
+ if (this.isConnected()) throw new AlreadyConnectedError('You already connected');
41
+ }
42
+ /**
43
+ * Disconnect
44
+ */
45
+
46
+
47
+ disconnect() {
48
+ if (!this.isConnected()) throw new NoWalletConnectedError('You dont have connection. Please connect before');
49
+ }
50
+ /**
51
+ * Receive message
52
+ */
53
+
54
+
55
+ receiveMessage(message) {
56
+ if (this.debug) console.log('Receive message:', message);
57
+ }
58
+ /**
59
+ * Send message
60
+ */
61
+
62
+
63
+ sendMessage(message) {
64
+ if (this.debug) console.log('Send message:', message);
65
+ }
66
+ /**
67
+ * Check if connected
68
+ * @returns Is connected
69
+ */
70
+
71
+
72
+ }
73
+ //# 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 * @category aepp wallet communication\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 // eslint-disable-next-line @typescript-eslint/no-unused-vars\n onMessage: (message: any, origin: string, source: any) => void,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\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 * Receive 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;;AACA,eAAe,MAAeC,iBAAf,CAAiC;EAGpCC,WAAW,OAAyC;IAAA,IAAxC;MAAEC,KAAK,GAAG;IAAV,CAAwC;IAC5D,KAAKA,KAAL,GAAaA,KAAb;EACD;EAED;AACF;AACA;AACA;AACA;;;EACEC,OAAO,EACL;EACAC,SAFK,EAGL;EACAC,YAJK,EAKC;IACN,IAAI,KAAKC,WAAL,EAAJ,EAAwB,MAAM,IAAIR,qBAAJ,CAA0B,uBAA1B,CAAN;EACzB;EAED;AACF;AACA;;;EACES,UAAU,GAAS;IACjB,IAAI,CAAC,KAAKD,WAAL,EAAL,EAAyB,MAAM,IAAIP,sBAAJ,CAA2B,iDAA3B,CAAN;EAC1B;EAED;AACF;AACA;;;EACYS,cAAc,CAACC,OAAD,EAAqB;IAC3C,IAAI,KAAKP,KAAT,EAAgBQ,OAAO,CAACC,GAAR,CAAY,kBAAZ,EAAgCF,OAAhC;EACjB;EAED;AACF;AACA;;;EACEG,WAAW,CAACH,OAAD,EAAqB;IAC9B,IAAI,KAAKP,KAAT,EAAgBQ,OAAO,CAACC,GAAR,CAAY,eAAZ,EAA6BF,OAA7B;EACjB;EAED;AACF;AACA;AACA;;;AA7CgD"}
@@ -0,0 +1,18 @@
1
+ import { Runtime } from 'webextension-polyfill';
2
+ import BrowserConnection from './Browser';
3
+ /**
4
+ * BrowserRuntimeConnection
5
+ * Handle browser runtime communication
6
+ * @category aepp wallet communication
7
+ */
8
+ export default class BrowserRuntimeConnection extends BrowserConnection {
9
+ port: Runtime.Port;
10
+ constructor({ port, ...options }: {
11
+ port: Runtime.Port;
12
+ debug: boolean;
13
+ });
14
+ disconnect(): void;
15
+ connect(onMessage: (message: any, origin: string, source: Runtime.Port) => void, onDisconnect: () => void): void;
16
+ sendMessage(message: any): void;
17
+ isConnected(): boolean;
18
+ }
@@ -0,0 +1,58 @@
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
+ * @category aepp wallet communication
22
+ */
23
+
24
+ export default class BrowserRuntimeConnection extends BrowserConnection {
25
+ constructor(_ref) {
26
+ let {
27
+ port,
28
+ ...options
29
+ } = _ref;
30
+ super(options);
31
+ this.port = port;
32
+ }
33
+
34
+ disconnect() {
35
+ super.disconnect();
36
+ this.port.disconnect();
37
+ }
38
+
39
+ connect(onMessage, onDisconnect) {
40
+ super.connect(onMessage, onDisconnect);
41
+ this.port.onMessage.addListener((message, port) => {
42
+ this.receiveMessage(message);
43
+ onMessage(message, port.name, port);
44
+ });
45
+ this.port.onDisconnect.addListener(onDisconnect);
46
+ }
47
+
48
+ sendMessage(message) {
49
+ super.sendMessage(message);
50
+ this.port.postMessage(message);
51
+ }
52
+
53
+ isConnected() {
54
+ return this.port.onMessage.hasListeners();
55
+ }
56
+
57
+ }
58
+ //# 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 * @category aepp wallet 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;;AACA,eAAe,MAAMC,wBAAN,SAAuCD,iBAAvC,CAAyD;EAGtEE,WAAW,OAA+D;IAAA,IAA9D;MAAEC,IAAF;MAAQ,GAAGC;IAAX,CAA8D;IACxE,MAAMA,OAAN;IACA,KAAKD,IAAL,GAAYA,IAAZ;EACD;;EAEDE,UAAU,GAAS;IACjB,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,CAACH,OAAD,EAAqB;IAC9B,MAAMG,WAAN,CAAkBH,OAAlB;IACA,KAAKP,IAAL,CAAUW,WAAV,CAAsBJ,OAAtB;EACD;;EAEDK,WAAW,GAAY;IACrB,OAAO,KAAKZ,IAAL,CAAUI,SAAV,CAAoBS,YAApB,EAAP;EACD;;AAhCqE"}
@@ -0,0 +1,36 @@
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
+ * @category aepp wallet communication
7
+ */
8
+ export default class BrowserWindowMessageConnection extends BrowserConnection {
9
+ #private;
10
+ origin?: string;
11
+ sendDirection?: MESSAGE_DIRECTION;
12
+ receiveDirection: MESSAGE_DIRECTION;
13
+ listener?: (this: Window, ev: MessageEvent<any>) => void;
14
+ /**
15
+ * @param options - Options
16
+ * @param options.target Target window for message
17
+ * @param options.self Host window for message
18
+ * @param options.origin Origin of receiver
19
+ * @param options.sendDirection Wrapping messages into additional struct
20
+ * `({ type: 'to_aepp' || 'to_waellet', data })`
21
+ * Used for handling messages between content script and page
22
+ * @param options.receiveDirection Unwrapping messages from additional struct
23
+ */
24
+ constructor({ target, self, origin, sendDirection, receiveDirection, ...options }?: {
25
+ target?: ImplPostMessage;
26
+ self?: ImplPostMessage;
27
+ origin?: string;
28
+ sendDirection?: MESSAGE_DIRECTION;
29
+ receiveDirection?: MESSAGE_DIRECTION;
30
+ debug?: boolean;
31
+ });
32
+ isConnected(): boolean;
33
+ connect(onMessage: (message: any, origin: string, source: MessageEventSource | null) => void, onDisconnect: () => void): void;
34
+ disconnect(): void;
35
+ sendMessage(msg: any): void;
36
+ }