@aeternity/aepp-sdk 12.1.2 → 13.0.0-alpha.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 (475) hide show
  1. package/dist/aepp-sdk.browser-script.js +1 -1
  2. package/dist/aepp-sdk.browser-script.js.map +1 -1
  3. package/dist/aepp-sdk.browser.js +1 -1
  4. package/dist/aepp-sdk.browser.js.map +1 -1
  5. package/dist/aepp-sdk.js +6580 -8860
  6. package/dist/aepp-sdk.js.map +1 -1
  7. package/es/AeSdk.d.ts +7 -3
  8. package/es/AeSdk.mjs +17 -22
  9. package/es/AeSdk.mjs.map +1 -1
  10. package/es/AeSdkAepp.d.ts +6 -5
  11. package/es/AeSdkAepp.mjs +7 -30
  12. package/es/AeSdkAepp.mjs.map +1 -1
  13. package/es/AeSdkBase.d.ts +18 -140
  14. package/es/AeSdkBase.mjs +27 -185
  15. package/es/AeSdkBase.mjs.map +1 -1
  16. package/es/AeSdkMethods.d.ts +124 -0
  17. package/es/AeSdkMethods.mjs +122 -0
  18. package/es/AeSdkMethods.mjs.map +1 -0
  19. package/es/AeSdkWallet.d.ts +7 -21
  20. package/es/AeSdkWallet.mjs +38 -86
  21. package/es/AeSdkWallet.mjs.map +1 -1
  22. package/es/Node.d.ts +7 -12
  23. package/es/Node.mjs +34 -47
  24. package/es/Node.mjs.map +1 -1
  25. package/es/account/Base.d.ts +24 -40
  26. package/es/account/Base.mjs +1 -101
  27. package/es/account/Base.mjs.map +1 -1
  28. package/es/account/Generalized.d.ts +16 -0
  29. package/es/account/Generalized.mjs +111 -0
  30. package/es/account/Generalized.mjs.map +1 -0
  31. package/es/account/Ledger.d.ts +28 -0
  32. package/es/account/Ledger.mjs +101 -0
  33. package/es/account/Ledger.mjs.map +1 -0
  34. package/es/account/LedgerFactory.d.ts +39 -0
  35. package/es/account/LedgerFactory.mjs +81 -0
  36. package/es/account/LedgerFactory.mjs.map +1 -0
  37. package/es/account/Memory.d.ts +13 -17
  38. package/es/account/Memory.mjs +43 -65
  39. package/es/account/Memory.mjs.map +1 -1
  40. package/es/account/Rpc.d.ts +6 -8
  41. package/es/account/Rpc.mjs +14 -32
  42. package/es/account/Rpc.mjs.map +1 -1
  43. package/es/aens.d.ts +3 -3
  44. package/es/aens.mjs +42 -41
  45. package/es/aens.mjs.map +1 -1
  46. package/es/aepp-wallet-communication/connection/Browser.mjs +9 -13
  47. package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -1
  48. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +3 -7
  49. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
  50. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +1 -1
  51. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +0 -31
  52. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -1
  53. package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -1
  54. package/es/aepp-wallet-communication/rpc/RpcClient.d.ts +3 -3
  55. package/es/aepp-wallet-communication/rpc/RpcClient.mjs +4 -41
  56. package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
  57. package/es/aepp-wallet-communication/rpc/types.d.ts +7 -1
  58. package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
  59. package/es/aepp-wallet-communication/schema.mjs +14 -68
  60. package/es/aepp-wallet-communication/schema.mjs.map +1 -1
  61. package/es/aepp-wallet-communication/wallet-detector.mjs +0 -3
  62. package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
  63. package/es/apis/compiler/compiler.d.ts +23 -29
  64. package/es/apis/compiler/compiler.mjs +128 -189
  65. package/es/apis/compiler/compiler.mjs.map +1 -1
  66. package/es/apis/compiler/index.mjs.map +1 -1
  67. package/es/apis/compiler/models/index.d.ts +82 -135
  68. package/es/apis/compiler/models/index.mjs +1 -47
  69. package/es/apis/compiler/models/index.mjs.map +1 -1
  70. package/es/apis/compiler/models/mappers.d.ts +8 -8
  71. package/es/apis/compiler/models/mappers.mjs +165 -183
  72. package/es/apis/compiler/models/mappers.mjs.map +1 -1
  73. package/es/apis/compiler/models/parameters.d.ts +0 -1
  74. package/es/apis/compiler/models/parameters.mjs +5 -9
  75. package/es/apis/compiler/models/parameters.mjs.map +1 -1
  76. package/es/apis/node/index.mjs.map +1 -1
  77. package/es/apis/node/models/index.d.ts +48 -48
  78. package/es/apis/node/models/mappers.mjs +12 -6
  79. package/es/apis/node/models/mappers.mjs.map +1 -1
  80. package/es/apis/node/models/parameters.mjs.map +1 -1
  81. package/es/apis/node/node.mjs +43 -84
  82. package/es/apis/node/node.mjs.map +1 -1
  83. package/es/chain.d.ts +1 -1
  84. package/es/chain.mjs +33 -58
  85. package/es/chain.mjs.map +1 -1
  86. package/es/channel/Base.d.ts +195 -0
  87. package/es/channel/Base.mjs +290 -0
  88. package/es/channel/Base.mjs.map +1 -0
  89. package/es/channel/Contract.d.ts +247 -0
  90. package/es/channel/Contract.mjs +420 -0
  91. package/es/channel/Contract.mjs.map +1 -0
  92. package/es/channel/Spend.d.ts +217 -0
  93. package/es/channel/Spend.mjs +383 -0
  94. package/es/channel/Spend.mjs.map +1 -0
  95. package/es/channel/handlers.d.ts +8 -21
  96. package/es/channel/handlers.mjs +141 -891
  97. package/es/channel/handlers.mjs.map +1 -1
  98. package/es/channel/internal.d.ts +27 -21
  99. package/es/channel/internal.mjs +98 -190
  100. package/es/channel/internal.mjs.map +1 -1
  101. package/es/contract/{Compiler.d.ts → CompilerHttp.d.ts} +3 -3
  102. package/es/contract/{Compiler.mjs → CompilerHttp.mjs} +8 -13
  103. package/es/contract/CompilerHttp.mjs.map +1 -0
  104. package/es/contract/Contract.d.ts +235 -0
  105. package/es/contract/Contract.mjs +534 -0
  106. package/es/contract/Contract.mjs.map +1 -0
  107. package/es/contract/ga.d.ts +7 -33
  108. package/es/contract/ga.mjs +20 -112
  109. package/es/contract/ga.mjs.map +1 -1
  110. package/es/index.d.ts +9 -6
  111. package/es/index.mjs +8 -6
  112. package/es/index.mjs.map +1 -1
  113. package/es/oracle.d.ts +5 -5
  114. package/es/oracle.mjs +33 -39
  115. package/es/oracle.mjs.map +1 -1
  116. package/es/spend.d.ts +3 -3
  117. package/es/spend.mjs +17 -20
  118. package/es/spend.mjs.map +1 -1
  119. package/es/tx/builder/constants.d.ts +2 -1
  120. package/es/tx/builder/constants.mjs +12 -12
  121. package/es/tx/builder/constants.mjs.map +1 -1
  122. package/es/tx/builder/field-types/address.d.ts +15 -0
  123. package/es/tx/builder/field-types/address.mjs +42 -0
  124. package/es/tx/builder/field-types/address.mjs.map +1 -0
  125. package/es/tx/builder/field-types/addresses.d.ts +6 -0
  126. package/es/tx/builder/field-types/addresses.mjs +13 -0
  127. package/es/tx/builder/field-types/addresses.mjs.map +1 -0
  128. package/es/tx/builder/field-types/coin-amount.d.ts +1 -2
  129. package/es/tx/builder/field-types/coin-amount.mjs +4 -12
  130. package/es/tx/builder/field-types/coin-amount.mjs.map +1 -1
  131. package/es/tx/builder/field-types/deposit.d.ts +0 -1
  132. package/es/tx/builder/field-types/deposit.mjs +2 -4
  133. package/es/tx/builder/field-types/deposit.mjs.map +1 -1
  134. package/es/tx/builder/field-types/enumeration.d.ts +5 -0
  135. package/es/tx/builder/field-types/enumeration.mjs +21 -0
  136. package/es/tx/builder/field-types/enumeration.mjs.map +1 -0
  137. package/es/tx/builder/field-types/fee.d.ts +1 -9
  138. package/es/tx/builder/field-types/fee.mjs +9 -25
  139. package/es/tx/builder/field-types/fee.mjs.map +1 -1
  140. package/es/tx/builder/field-types/field.mjs +0 -2
  141. package/es/tx/builder/field-types/field.mjs.map +1 -1
  142. package/es/tx/builder/field-types/gas-limit.mjs +4 -9
  143. package/es/tx/builder/field-types/gas-limit.mjs.map +1 -1
  144. package/es/tx/builder/field-types/gas-price.d.ts +1 -2
  145. package/es/tx/builder/field-types/gas-price.mjs +3 -7
  146. package/es/tx/builder/field-types/gas-price.mjs.map +1 -1
  147. package/es/tx/builder/field-types/index.d.ts +23 -11
  148. package/es/tx/builder/field-types/index.mjs +10 -3
  149. package/es/tx/builder/field-types/index.mjs.map +1 -1
  150. package/es/tx/builder/field-types/name-fee.d.ts +0 -1
  151. package/es/tx/builder/field-types/name-fee.mjs +3 -5
  152. package/es/tx/builder/field-types/name-fee.mjs.map +1 -1
  153. package/es/tx/builder/field-types/name-id.d.ts +1 -4
  154. package/es/tx/builder/field-types/name-id.mjs +4 -10
  155. package/es/tx/builder/field-types/name-id.mjs.map +1 -1
  156. package/es/tx/builder/field-types/name.mjs +0 -2
  157. package/es/tx/builder/field-types/name.mjs.map +1 -1
  158. package/es/tx/builder/field-types/pointers.d.ts +23 -0
  159. package/es/tx/builder/field-types/pointers.mjs +36 -0
  160. package/es/tx/builder/field-types/pointers.mjs.map +1 -0
  161. package/es/tx/builder/field-types/short-u-int.mjs +0 -2
  162. package/es/tx/builder/field-types/short-u-int.mjs.map +1 -1
  163. package/es/tx/builder/field-types/u-int.d.ts +1 -1
  164. package/es/tx/builder/field-types/u-int.mjs +3 -4
  165. package/es/tx/builder/field-types/u-int.mjs.map +1 -1
  166. package/es/tx/builder/helpers.d.ts +2 -32
  167. package/es/tx/builder/helpers.mjs +19 -71
  168. package/es/tx/builder/helpers.mjs.map +1 -1
  169. package/es/tx/builder/index.d.ts +1 -21
  170. package/es/tx/builder/index.mjs +29 -148
  171. package/es/tx/builder/index.mjs.map +1 -1
  172. package/es/tx/builder/schema.d.ts +336 -176
  173. package/es/tx/builder/schema.mjs +71 -78
  174. package/es/tx/builder/schema.mjs.map +1 -1
  175. package/es/tx/index.d.ts +3 -33
  176. package/es/tx/index.mjs +26 -43
  177. package/es/tx/index.mjs.map +1 -1
  178. package/es/tx/validator.d.ts +2 -2
  179. package/es/tx/validator.mjs +86 -59
  180. package/es/tx/validator.mjs.map +1 -1
  181. package/es/typings/{@aeternity__argon2-browser → @aeternity__aepp-calldata}/index.d.mjs +0 -0
  182. package/es/typings/@aeternity__aepp-calldata/index.d.mjs.map +1 -0
  183. package/es/utils/amount-formatter.mjs +4 -10
  184. package/es/utils/amount-formatter.mjs.map +1 -1
  185. package/es/utils/autorest.d.ts +1 -0
  186. package/es/utils/autorest.mjs +17 -19
  187. package/es/utils/autorest.mjs.map +1 -1
  188. package/es/utils/bignumber.mjs +4 -7
  189. package/es/utils/bignumber.mjs.map +1 -1
  190. package/es/utils/bytes.d.ts +0 -17
  191. package/es/utils/bytes.mjs +6 -35
  192. package/es/utils/bytes.mjs.map +1 -1
  193. package/es/utils/crypto.d.ts +15 -8
  194. package/es/utils/crypto.mjs +40 -40
  195. package/es/utils/crypto.mjs.map +1 -1
  196. package/es/utils/encoder-types.d.ts +28 -28
  197. package/es/utils/encoder-types.mjs +0 -1
  198. package/es/utils/encoder-types.mjs.map +1 -1
  199. package/es/utils/encoder.d.ts +0 -1
  200. package/es/utils/encoder.mjs +7 -15
  201. package/es/utils/encoder.mjs.map +1 -1
  202. package/es/utils/errors.d.ts +12 -6
  203. package/es/utils/errors.mjs +87 -163
  204. package/es/utils/errors.mjs.map +1 -1
  205. package/es/utils/hd-wallet.d.ts +27 -19
  206. package/es/utils/hd-wallet.mjs +42 -26
  207. package/es/utils/hd-wallet.mjs.map +1 -1
  208. package/es/utils/json-big.mjs +0 -8
  209. package/es/utils/json-big.mjs.map +1 -1
  210. package/es/utils/keystore.d.ts +2 -0
  211. package/es/utils/keystore.mjs +37 -36
  212. package/es/utils/keystore.mjs.map +1 -1
  213. package/es/utils/mptree.d.ts +1 -1
  214. package/es/utils/mptree.mjs +4 -26
  215. package/es/utils/mptree.mjs.map +1 -1
  216. package/es/utils/other.d.ts +3 -1
  217. package/es/utils/other.mjs +11 -7
  218. package/es/utils/other.mjs.map +1 -1
  219. package/es/utils/semver-satisfies.mjs +0 -3
  220. package/es/utils/semver-satisfies.mjs.map +1 -1
  221. package/es/utils/string.d.ts +0 -12
  222. package/es/utils/string.mjs +1 -21
  223. package/es/utils/string.mjs.map +1 -1
  224. package/package.json +87 -48
  225. package/src/AeSdk.ts +15 -11
  226. package/src/AeSdkAepp.ts +9 -7
  227. package/src/AeSdkBase.ts +28 -202
  228. package/src/AeSdkMethods.ts +170 -0
  229. package/src/AeSdkWallet.ts +16 -47
  230. package/src/Node.ts +11 -15
  231. package/src/account/Base.ts +29 -75
  232. package/src/account/Generalized.ts +98 -0
  233. package/src/account/Ledger.ts +131 -0
  234. package/src/account/LedgerFactory.ts +86 -0
  235. package/src/account/Memory.ts +46 -60
  236. package/src/account/Rpc.ts +17 -26
  237. package/src/aens.ts +10 -9
  238. package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +5 -4
  239. package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +3 -3
  240. package/src/aepp-wallet-communication/rpc/RpcClient.ts +2 -2
  241. package/src/aepp-wallet-communication/rpc/types.ts +11 -1
  242. package/src/aepp-wallet-communication/schema.ts +18 -18
  243. package/src/apis/compiler/code-model-v4.yaml +681 -888
  244. package/src/apis/compiler/compiler.ts +113 -154
  245. package/src/apis/compiler/models/index.ts +80 -140
  246. package/src/apis/compiler/models/mappers.ts +165 -183
  247. package/src/apis/compiler/models/parameters.ts +6 -12
  248. package/src/chain.ts +6 -3
  249. package/src/channel/Base.ts +327 -0
  250. package/src/channel/Contract.ts +487 -0
  251. package/src/channel/Spend.ts +403 -0
  252. package/src/channel/handlers.ts +154 -573
  253. package/src/channel/internal.ts +113 -142
  254. package/src/contract/{Compiler.ts → CompilerHttp.ts} +5 -5
  255. package/src/contract/Contract.ts +620 -0
  256. package/src/contract/ga.ts +18 -104
  257. package/src/index.ts +9 -8
  258. package/src/oracle.ts +7 -7
  259. package/src/spend.ts +5 -13
  260. package/src/tx/builder/constants.ts +1 -0
  261. package/src/tx/builder/field-types/address.ts +52 -0
  262. package/src/tx/builder/field-types/addresses.ts +18 -0
  263. package/src/tx/builder/field-types/coin-amount.ts +2 -8
  264. package/src/tx/builder/field-types/enumeration.ts +21 -0
  265. package/src/tx/builder/field-types/fee.ts +1 -3
  266. package/src/tx/builder/field-types/gas-limit.ts +2 -2
  267. package/src/tx/builder/field-types/gas-price.ts +0 -2
  268. package/src/tx/builder/field-types/index.ts +16 -6
  269. package/src/tx/builder/field-types/name-fee.ts +1 -1
  270. package/src/tx/builder/field-types/name-id.ts +7 -10
  271. package/src/tx/builder/field-types/pointers.ts +41 -0
  272. package/src/tx/builder/field-types/u-int.ts +3 -2
  273. package/src/tx/builder/helpers.ts +10 -60
  274. package/src/tx/builder/index.ts +6 -65
  275. package/src/tx/builder/schema.ts +89 -100
  276. package/src/tx/index.ts +19 -15
  277. package/src/tx/validator.ts +36 -18
  278. package/src/typings/@aeternity__aepp-calldata/index.d.ts +20 -0
  279. package/src/utils/autorest.ts +16 -1
  280. package/src/utils/bytes.ts +5 -33
  281. package/src/utils/crypto.ts +23 -16
  282. package/src/utils/encoder.ts +0 -1
  283. package/src/utils/errors.ts +18 -12
  284. package/src/utils/hd-wallet.ts +30 -9
  285. package/src/utils/keystore.ts +24 -21
  286. package/src/utils/other.ts +16 -1
  287. package/src/utils/string.ts +0 -20
  288. package/types-legacy/ts4.2/AeSdk.d.ts +41 -0
  289. package/types-legacy/ts4.2/AeSdkAepp.d.ts +71 -0
  290. package/types-legacy/ts4.2/AeSdkBase.d.ts +91 -0
  291. package/types-legacy/ts4.2/AeSdkMethods.d.ts +141 -0
  292. package/types-legacy/ts4.2/AeSdkWallet.d.ts +90 -0
  293. package/types-legacy/ts4.2/Node.d.ts +78 -0
  294. package/types-legacy/ts4.2/account/Base.d.ts +52 -0
  295. package/types-legacy/ts4.2/account/Generalized.d.ts +16 -0
  296. package/types-legacy/ts4.2/account/Ledger.d.ts +28 -0
  297. package/types-legacy/ts4.2/account/LedgerFactory.d.ts +39 -0
  298. package/types-legacy/ts4.2/account/Memory.d.ts +22 -0
  299. package/types-legacy/ts4.2/account/Rpc.d.ts +25 -0
  300. package/types-legacy/ts4.2/aens.d.ts +222 -0
  301. package/types-legacy/ts4.2/aepp-wallet-communication/connection/Browser.d.ts +33 -0
  302. package/types-legacy/ts4.2/aepp-wallet-communication/connection/BrowserRuntime.d.ts +18 -0
  303. package/types-legacy/ts4.2/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +36 -0
  304. package/types-legacy/ts4.2/aepp-wallet-communication/connection-proxy.d.ts +11 -0
  305. package/types-legacy/ts4.2/aepp-wallet-communication/rpc/RpcClient.d.ts +34 -0
  306. package/types-legacy/ts4.2/aepp-wallet-communication/rpc/types.d.ts +83 -0
  307. package/types-legacy/ts4.2/aepp-wallet-communication/schema.d.ts +133 -0
  308. package/types-legacy/ts4.2/aepp-wallet-communication/wallet-detector.d.ts +25 -0
  309. package/types-legacy/ts4.2/apis/compiler/compiler.d.ts +86 -0
  310. package/types-legacy/ts4.2/apis/compiler/index.d.ts +2 -0
  311. package/types-legacy/ts4.2/apis/compiler/models/index.d.ts +195 -0
  312. package/types-legacy/ts4.2/apis/compiler/models/mappers.d.ts +23 -0
  313. package/types-legacy/ts4.2/apis/compiler/models/parameters.d.ts +12 -0
  314. package/types-legacy/ts4.2/apis/node/index.d.ts +2 -0
  315. package/types-legacy/ts4.2/apis/node/models/index.d.ts +1065 -0
  316. package/types-legacy/ts4.2/apis/node/models/mappers.d.ts +95 -0
  317. package/types-legacy/ts4.2/apis/node/models/parameters.d.ts +17 -0
  318. package/types-legacy/ts4.2/apis/node/node.d.ts +215 -0
  319. package/types-legacy/ts4.2/chain.d.ts +248 -0
  320. package/types-legacy/ts4.2/channel/Base.d.ts +194 -0
  321. package/types-legacy/ts4.2/channel/Contract.d.ts +247 -0
  322. package/types-legacy/ts4.2/channel/Spend.d.ts +217 -0
  323. package/types-legacy/ts4.2/channel/handlers.d.ts +21 -0
  324. package/types-legacy/ts4.2/channel/internal.d.ts +107 -0
  325. package/types-legacy/ts4.2/contract/CompilerHttp.d.ts +18 -0
  326. package/types-legacy/ts4.2/contract/Contract.d.ts +237 -0
  327. package/types-legacy/ts4.2/contract/ga.d.ts +43 -0
  328. package/types-legacy/ts4.2/globals.d.ts +16 -0
  329. package/types-legacy/ts4.2/index.d.ts +39 -0
  330. package/types-legacy/ts4.2/oracle.d.ts +161 -0
  331. package/types-legacy/ts4.2/spend.d.ts +62 -0
  332. package/types-legacy/ts4.2/tx/builder/constants.d.ts +71 -0
  333. package/types-legacy/ts4.2/tx/builder/field-types/address.d.ts +22 -0
  334. package/types-legacy/ts4.2/tx/builder/field-types/addresses.d.ts +6 -0
  335. package/types-legacy/ts4.2/tx/builder/field-types/coin-amount.d.ts +12 -0
  336. package/types-legacy/ts4.2/tx/builder/field-types/deposit.d.ts +14 -0
  337. package/types-legacy/ts4.2/tx/builder/field-types/enumeration.d.ts +5 -0
  338. package/types-legacy/ts4.2/tx/builder/field-types/fee.d.ts +17 -0
  339. package/types-legacy/ts4.2/tx/builder/field-types/field.d.ts +6 -0
  340. package/types-legacy/ts4.2/tx/builder/field-types/gas-limit.d.ts +12 -0
  341. package/types-legacy/ts4.2/tx/builder/field-types/gas-price.d.ts +7 -0
  342. package/types-legacy/ts4.2/tx/builder/field-types/index.d.ts +85 -0
  343. package/types-legacy/ts4.2/tx/builder/field-types/name-fee.d.ts +19 -0
  344. package/types-legacy/ts4.2/tx/builder/field-types/name-id.d.ts +11 -0
  345. package/types-legacy/ts4.2/tx/builder/field-types/name.d.ts +13 -0
  346. package/types-legacy/ts4.2/tx/builder/field-types/pointers.d.ts +26 -0
  347. package/types-legacy/ts4.2/tx/builder/field-types/short-u-int.d.ts +6 -0
  348. package/types-legacy/ts4.2/tx/builder/field-types/u-int.d.ts +8 -0
  349. package/types-legacy/ts4.2/tx/builder/helpers.d.ts +112 -0
  350. package/types-legacy/ts4.2/tx/builder/index.d.ts +68 -0
  351. package/types-legacy/ts4.2/tx/builder/schema.d.ts +2963 -0
  352. package/types-legacy/ts4.2/tx/index.d.ts +34 -0
  353. package/types-legacy/ts4.2/tx/validator.d.ts +20 -0
  354. package/types-legacy/ts4.2/utils/amount-formatter.d.ts +42 -0
  355. package/types-legacy/ts4.2/utils/autorest.d.ts +7 -0
  356. package/types-legacy/ts4.2/utils/bignumber.d.ts +13 -0
  357. package/types-legacy/ts4.2/utils/bytes.d.ts +9 -0
  358. package/types-legacy/ts4.2/utils/crypto.d.ts +95 -0
  359. package/types-legacy/ts4.2/utils/encoder-types.d.ts +61 -0
  360. package/types-legacy/ts4.2/utils/encoder.d.ts +24 -0
  361. package/types-legacy/ts4.2/utils/errors.d.ts +480 -0
  362. package/types-legacy/ts4.2/utils/hd-wallet.d.ts +65 -0
  363. package/types-legacy/ts4.2/utils/json-big.d.ts +5 -0
  364. package/types-legacy/ts4.2/utils/keystore.d.ts +53 -0
  365. package/types-legacy/ts4.2/utils/mptree.d.ts +32 -0
  366. package/types-legacy/ts4.2/utils/other.d.ts +31 -0
  367. package/types-legacy/ts4.2/utils/semver-satisfies.d.ts +1 -0
  368. package/types-legacy/ts4.2/utils/string.d.ts +12 -0
  369. package/types-legacy/ts4.5/AeSdk.d.ts +41 -0
  370. package/types-legacy/ts4.5/AeSdkAepp.d.ts +71 -0
  371. package/types-legacy/ts4.5/AeSdkBase.d.ts +91 -0
  372. package/types-legacy/ts4.5/AeSdkMethods.d.ts +141 -0
  373. package/types-legacy/ts4.5/AeSdkWallet.d.ts +90 -0
  374. package/types-legacy/ts4.5/Node.d.ts +78 -0
  375. package/types-legacy/ts4.5/account/Base.d.ts +52 -0
  376. package/types-legacy/ts4.5/account/Generalized.d.ts +16 -0
  377. package/types-legacy/ts4.5/account/Ledger.d.ts +28 -0
  378. package/types-legacy/ts4.5/account/LedgerFactory.d.ts +39 -0
  379. package/types-legacy/ts4.5/account/Memory.d.ts +22 -0
  380. package/types-legacy/ts4.5/account/Rpc.d.ts +25 -0
  381. package/types-legacy/ts4.5/aens.d.ts +222 -0
  382. package/types-legacy/ts4.5/aepp-wallet-communication/connection/Browser.d.ts +33 -0
  383. package/types-legacy/ts4.5/aepp-wallet-communication/connection/BrowserRuntime.d.ts +18 -0
  384. package/types-legacy/ts4.5/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +36 -0
  385. package/types-legacy/ts4.5/aepp-wallet-communication/connection-proxy.d.ts +11 -0
  386. package/types-legacy/ts4.5/aepp-wallet-communication/rpc/RpcClient.d.ts +34 -0
  387. package/types-legacy/ts4.5/aepp-wallet-communication/rpc/types.d.ts +83 -0
  388. package/types-legacy/ts4.5/aepp-wallet-communication/schema.d.ts +133 -0
  389. package/types-legacy/ts4.5/aepp-wallet-communication/wallet-detector.d.ts +25 -0
  390. package/types-legacy/ts4.5/apis/compiler/compiler.d.ts +86 -0
  391. package/types-legacy/ts4.5/apis/compiler/index.d.ts +2 -0
  392. package/types-legacy/ts4.5/apis/compiler/models/index.d.ts +195 -0
  393. package/types-legacy/ts4.5/apis/compiler/models/mappers.d.ts +23 -0
  394. package/types-legacy/ts4.5/apis/compiler/models/parameters.d.ts +12 -0
  395. package/types-legacy/ts4.5/apis/node/index.d.ts +2 -0
  396. package/types-legacy/ts4.5/apis/node/models/index.d.ts +1065 -0
  397. package/types-legacy/ts4.5/apis/node/models/mappers.d.ts +95 -0
  398. package/types-legacy/ts4.5/apis/node/models/parameters.d.ts +17 -0
  399. package/types-legacy/ts4.5/apis/node/node.d.ts +215 -0
  400. package/types-legacy/ts4.5/chain.d.ts +248 -0
  401. package/types-legacy/ts4.5/channel/Base.d.ts +194 -0
  402. package/types-legacy/ts4.5/channel/Contract.d.ts +247 -0
  403. package/types-legacy/ts4.5/channel/Spend.d.ts +217 -0
  404. package/types-legacy/ts4.5/channel/handlers.d.ts +21 -0
  405. package/types-legacy/ts4.5/channel/internal.d.ts +107 -0
  406. package/types-legacy/ts4.5/contract/CompilerHttp.d.ts +18 -0
  407. package/types-legacy/ts4.5/contract/Contract.d.ts +237 -0
  408. package/types-legacy/ts4.5/contract/ga.d.ts +43 -0
  409. package/types-legacy/ts4.5/index.d.ts +38 -0
  410. package/types-legacy/ts4.5/oracle.d.ts +161 -0
  411. package/types-legacy/ts4.5/spend.d.ts +62 -0
  412. package/types-legacy/ts4.5/tx/builder/constants.d.ts +71 -0
  413. package/types-legacy/ts4.5/tx/builder/field-types/address.d.ts +22 -0
  414. package/types-legacy/ts4.5/tx/builder/field-types/addresses.d.ts +6 -0
  415. package/types-legacy/ts4.5/tx/builder/field-types/coin-amount.d.ts +12 -0
  416. package/types-legacy/ts4.5/tx/builder/field-types/deposit.d.ts +14 -0
  417. package/types-legacy/ts4.5/tx/builder/field-types/enumeration.d.ts +5 -0
  418. package/types-legacy/ts4.5/tx/builder/field-types/fee.d.ts +17 -0
  419. package/types-legacy/ts4.5/tx/builder/field-types/field.d.ts +6 -0
  420. package/types-legacy/ts4.5/tx/builder/field-types/gas-limit.d.ts +12 -0
  421. package/types-legacy/ts4.5/tx/builder/field-types/gas-price.d.ts +7 -0
  422. package/types-legacy/ts4.5/tx/builder/field-types/index.d.ts +85 -0
  423. package/types-legacy/ts4.5/tx/builder/field-types/name-fee.d.ts +19 -0
  424. package/types-legacy/ts4.5/tx/builder/field-types/name-id.d.ts +11 -0
  425. package/types-legacy/ts4.5/tx/builder/field-types/name.d.ts +13 -0
  426. package/types-legacy/ts4.5/tx/builder/field-types/pointers.d.ts +26 -0
  427. package/types-legacy/ts4.5/tx/builder/field-types/short-u-int.d.ts +6 -0
  428. package/types-legacy/ts4.5/tx/builder/field-types/u-int.d.ts +8 -0
  429. package/types-legacy/ts4.5/tx/builder/helpers.d.ts +112 -0
  430. package/types-legacy/ts4.5/tx/builder/index.d.ts +68 -0
  431. package/types-legacy/ts4.5/tx/builder/schema.d.ts +2963 -0
  432. package/types-legacy/ts4.5/tx/index.d.ts +34 -0
  433. package/types-legacy/ts4.5/tx/validator.d.ts +20 -0
  434. package/types-legacy/ts4.5/utils/amount-formatter.d.ts +42 -0
  435. package/types-legacy/ts4.5/utils/autorest.d.ts +7 -0
  436. package/types-legacy/ts4.5/utils/bignumber.d.ts +13 -0
  437. package/types-legacy/ts4.5/utils/bytes.d.ts +9 -0
  438. package/types-legacy/ts4.5/utils/crypto.d.ts +95 -0
  439. package/types-legacy/ts4.5/utils/encoder-types.d.ts +61 -0
  440. package/types-legacy/ts4.5/utils/encoder.d.ts +24 -0
  441. package/types-legacy/ts4.5/utils/errors.d.ts +480 -0
  442. package/types-legacy/ts4.5/utils/hd-wallet.d.ts +65 -0
  443. package/types-legacy/ts4.5/utils/json-big.d.ts +5 -0
  444. package/types-legacy/ts4.5/utils/keystore.d.ts +53 -0
  445. package/types-legacy/ts4.5/utils/mptree.d.ts +32 -0
  446. package/types-legacy/ts4.5/utils/other.d.ts +31 -0
  447. package/types-legacy/ts4.5/utils/semver-satisfies.d.ts +1 -0
  448. package/types-legacy/ts4.5/utils/string.d.ts +12 -0
  449. package/es/channel/index.d.ts +0 -625
  450. package/es/channel/index.mjs +0 -975
  451. package/es/channel/index.mjs.map +0 -1
  452. package/es/contract/Compiler.mjs.map +0 -1
  453. package/es/contract/aci.d.ts +0 -127
  454. package/es/contract/aci.mjs +0 -509
  455. package/es/contract/aci.mjs.map +0 -1
  456. package/es/contract/methods.d.ts +0 -71
  457. package/es/contract/methods.mjs +0 -104
  458. package/es/contract/methods.mjs.map +0 -1
  459. package/es/deprecated/index.d.ts +0 -143
  460. package/es/deprecated/index.mjs +0 -162
  461. package/es/deprecated/index.mjs.map +0 -1
  462. package/es/deprecated/methods.d.ts +0 -18
  463. package/es/deprecated/methods.mjs +0 -26
  464. package/es/deprecated/methods.mjs.map +0 -1
  465. package/es/tx/builder/address.d.ts +0 -25
  466. package/es/tx/builder/address.mjs +0 -45
  467. package/es/tx/builder/address.mjs.map +0 -1
  468. package/es/typings/@aeternity__argon2-browser/index.d.mjs.map +0 -1
  469. package/src/channel/index.ts +0 -1025
  470. package/src/contract/aci.ts +0 -538
  471. package/src/contract/methods.ts +0 -123
  472. package/src/deprecated/index.ts +0 -172
  473. package/src/deprecated/methods.ts +0 -25
  474. package/src/tx/builder/address.ts +0 -50
  475. package/src/typings/@aeternity__argon2-browser/index.d.ts +0 -3
@@ -1,23 +1,15 @@
1
1
  import AeSdk from './AeSdk';
2
- import { Account } from './AeSdkBase';
3
2
  import RpcClient from './aepp-wallet-communication/rpc/RpcClient';
4
3
  import { METHODS, RPC_STATUS, WALLET_TYPE } from './aepp-wallet-communication/schema';
5
4
  import AccountBase from './account/Base';
6
5
  import BrowserConnection from './aepp-wallet-communication/connection/Browser';
7
6
  import { Accounts, AeppApi, Network, WalletApi, WalletInfo } from './aepp-wallet-communication/rpc/types';
8
7
  import { Encoded } from './utils/encoder';
9
- declare type RpcClientWallet = RpcClient<AeppApi, WalletApi>;
10
- declare type OnConnection = (clientId: string, params: Omit<Parameters<WalletApi[METHODS.connect]>[0], 'version'>, origin: string) => void;
11
- declare type OnSubscription = (clientId: string, params: Parameters<WalletApi[METHODS.subscribeAddress]>[0], origin: string) => void;
12
- declare type OnSign = (clientId: string, params: Parameters<WalletApi[METHODS.sign]>[0], origin: string) => Promise<{
13
- tx?: Encoded.Transaction;
14
- onAccount?: Account;
15
- } | undefined> | Promise<void>;
16
- declare type OnDisconnect = (clientId: string, params: Parameters<WalletApi[METHODS.closeConnection]>[0]) => void;
17
- declare type OnAskAccounts = (clientId: string, params: undefined, origin: string) => void;
18
- declare type OnMessageSign = (clientId: string, params: Parameters<WalletApi[METHODS.signMessage]>[0], origin: string) => Promise<{
19
- onAccount?: Account;
20
- } | undefined> | Promise<void>;
8
+ type RpcClientWallet = RpcClient<AeppApi, WalletApi>;
9
+ type OnConnection = (clientId: string, params: Omit<Parameters<WalletApi[METHODS.connect]>[0], 'version'>, origin: string) => void;
10
+ type OnSubscription = (clientId: string, params: Parameters<WalletApi[METHODS.subscribeAddress]>[0], origin: string) => void;
11
+ type OnDisconnect = (clientId: string, params: Parameters<WalletApi[METHODS.closeConnection]>[0]) => void;
12
+ type OnAskAccounts = (clientId: string, params: undefined, origin: string) => void;
21
13
  interface RpcClientsInfo {
22
14
  id: string;
23
15
  status: RPC_STATUS;
@@ -36,10 +28,8 @@ export default class AeSdkWallet extends AeSdk {
36
28
  _clients: Map<string, RpcClientsInfo>;
37
29
  onConnection: OnConnection;
38
30
  onSubscription: OnSubscription;
39
- onSign: OnSign;
40
31
  onDisconnect: OnDisconnect;
41
32
  onAskAccounts: OnAskAccounts;
42
- onMessageSign: OnMessageSign;
43
33
  /**
44
34
  * @param options - Options
45
35
  * @param options.name - Wallet name
@@ -47,25 +37,21 @@ export default class AeSdkWallet extends AeSdk {
47
37
  * @param options.type - Wallet type
48
38
  * @param options.onConnection - Call-back function for incoming AEPP connection
49
39
  * @param options.onSubscription - Call-back function for incoming AEPP account subscription
50
- * @param options.onSign - Call-back function for incoming AEPP sign request
51
40
  * @param options.onAskAccounts - Call-back function for incoming AEPP get address request
52
- * @param options.onMessageSign - Call-back function for incoming AEPP sign message request
53
41
  * @param options.onDisconnect - Call-back function for disconnect event
54
42
  */
55
- constructor({ name, id, type, onConnection, onSubscription, onSign, onDisconnect, onAskAccounts, onMessageSign, ...options }: {
43
+ constructor({ name, id, type, onConnection, onSubscription, onDisconnect, onAskAccounts, ...options }: {
56
44
  id: string;
57
45
  type: WALLET_TYPE;
58
46
  name: string;
59
47
  onConnection: OnConnection;
60
48
  onSubscription: OnSubscription;
61
- onSign: OnSign;
62
49
  onDisconnect: OnDisconnect;
63
50
  onAskAccounts: OnAskAccounts;
64
- onMessageSign: OnMessageSign;
65
51
  } & ConstructorParameters<typeof AeSdk>[0]);
66
52
  _pushAccountsToApps(): void;
67
53
  selectAccount(address: Encoded.AccountAddress): void;
68
- addAccount(account: AccountBase, options?: Parameters<AeSdk['addAccount']>[1]): Promise<void>;
54
+ addAccount(account: AccountBase, options?: Parameters<AeSdk['addAccount']>[1]): void;
69
55
  _getNode(): {
70
56
  node: Network['node'];
71
57
  };
@@ -1,4 +1,8 @@
1
- import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
1
+ import _buffer from "buffer";
2
+ const {
3
+ Buffer: _Buffer
4
+ } = _buffer;
5
+ import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
2
6
  import { v4 as uuid } from '@aeternity/uuid';
3
7
  import AeSdk from "./AeSdk.mjs";
4
8
  import verifyTransaction from "./tx/validator.mjs";
@@ -7,7 +11,6 @@ import { METHODS, RPC_STATUS, SUBSCRIPTION_TYPES, RpcBroadcastError, RpcInvalidT
7
11
  import { InternalError, UnknownRpcClientError } from "./utils/errors.mjs";
8
12
  import { RPC_VERSION } from "./aepp-wallet-communication/rpc/types.mjs";
9
13
  import jsonBig from "./utils/json-big.mjs";
10
-
11
14
  /**
12
15
  * Contain functionality for aepp interaction and managing multiple aepps
13
16
  * @category aepp wallet communication
@@ -20,9 +23,7 @@ export default class AeSdkWallet extends AeSdk {
20
23
  * @param options.type - Wallet type
21
24
  * @param options.onConnection - Call-back function for incoming AEPP connection
22
25
  * @param options.onSubscription - Call-back function for incoming AEPP account subscription
23
- * @param options.onSign - Call-back function for incoming AEPP sign request
24
26
  * @param options.onAskAccounts - Call-back function for incoming AEPP get address request
25
- * @param options.onMessageSign - Call-back function for incoming AEPP sign message request
26
27
  * @param options.onDisconnect - Call-back function for disconnect event
27
28
  */
28
29
  constructor(_ref) {
@@ -32,54 +33,44 @@ export default class AeSdkWallet extends AeSdk {
32
33
  type,
33
34
  onConnection,
34
35
  onSubscription,
35
- onSign,
36
36
  onDisconnect,
37
37
  onAskAccounts,
38
- onMessageSign,
39
38
  ...options
40
39
  } = _ref;
41
40
  super(options);
41
+ _defineProperty(this, "_clients", new Map());
42
42
  this.onConnection = onConnection;
43
43
  this.onSubscription = onSubscription;
44
- this.onSign = onSign;
45
44
  this.onDisconnect = onDisconnect;
46
45
  this.onAskAccounts = onAskAccounts;
47
- this.onMessageSign = onMessageSign;
48
- this._clients = new Map();
49
46
  this.name = name;
50
47
  this.id = id;
51
48
  this._type = type;
52
49
  }
53
-
54
50
  _pushAccountsToApps() {
51
+ if (this._clients == null) return;
55
52
  Array.from(this._clients.keys()).filter(clientId => this._isRpcClientSubscribed(clientId)).map(clientId => this._getClient(clientId).rpc).forEach(client => client.notify(METHODS.updateAddress, this.getAccounts()));
56
53
  }
57
-
58
54
  selectAccount(address) {
59
55
  super.selectAccount(address);
60
-
61
56
  this._pushAccountsToApps();
62
57
  }
63
-
64
- async addAccount(account, options) {
65
- await super.addAccount(account, options);
66
-
58
+ addAccount(account, options) {
59
+ super.addAccount(account, options);
67
60
  this._pushAccountsToApps();
68
61
  }
69
-
70
62
  _getNode() {
71
63
  this.ensureNodeConnected();
72
64
  return {
73
65
  node: {
74
- url: this.api.url,
66
+ url: this.api.$host,
75
67
  name: this.selectedNodeName
76
68
  }
77
69
  };
78
70
  }
79
-
80
71
  async selectNode(name) {
81
72
  super.selectNode(name);
82
- const networkId = await this.getNetworkId();
73
+ const networkId = await this.api.getNetworkId();
83
74
  Array.from(this._clients.keys()).filter(clientId => this._isRpcClientConnected(clientId)).map(clientId => this._getClient(clientId)).forEach(client => {
84
75
  client.rpc.notify(METHODS.updateNetwork, {
85
76
  networkId,
@@ -87,47 +78,38 @@ export default class AeSdkWallet extends AeSdk {
87
78
  });
88
79
  });
89
80
  }
90
-
91
81
  _getClient(clientId) {
92
82
  const client = this._clients.get(clientId);
93
-
94
83
  if (client == null) throw new UnknownRpcClientError(clientId);
95
84
  return client;
96
85
  }
97
-
98
86
  _isRpcClientSubscribed(clientId) {
99
87
  return this._isRpcClientConnected(clientId) && this._getClient(clientId).addressSubscription.size !== 0;
100
88
  }
101
-
102
89
  _isRpcClientConnected(clientId) {
103
90
  return RPC_STATUS.CONNECTED === this._getClient(clientId).status && this._getClient(clientId).rpc.connection.isConnected();
104
91
  }
105
-
106
92
  _disconnectRpcClient(clientId) {
107
93
  const client = this._getClient(clientId);
108
-
109
94
  client.rpc.connection.disconnect();
110
95
  client.status = RPC_STATUS.DISCONNECTED;
111
96
  client.addressSubscription = new Set();
112
97
  }
98
+
113
99
  /**
114
100
  * Remove specific RpcClient by ID
115
101
  * @param id - Client ID
116
102
  */
117
-
118
-
119
103
  removeRpcClient(id) {
120
104
  this._disconnectRpcClient(id);
121
-
122
105
  this._clients.delete(id);
123
106
  }
107
+
124
108
  /**
125
109
  * Add new client by AEPP connection
126
110
  * @param clientConnection - AEPP connection object
127
111
  * @returns Client ID
128
112
  */
129
-
130
-
131
113
  addRpcClient(clientConnection) {
132
114
  // @TODO detect if aepp has some history based on origin????
133
115
  // if yes use this instance for connection
@@ -140,12 +122,10 @@ export default class AeSdkWallet extends AeSdk {
140
122
  connectNode: false,
141
123
  rpc: new RpcClient(clientConnection, () => {
142
124
  this._clients.delete(id);
143
-
144
125
  this.onDisconnect(id, disconnectParams); // also related info
145
126
  }, {
146
127
  [METHODS.closeConnection]: params => {
147
128
  disconnectParams = params;
148
-
149
129
  this._disconnectRpcClient(id);
150
130
  },
151
131
  // Store client info and prepare two fn for each client `connect` and `denyConnection`
@@ -165,7 +145,8 @@ export default class AeSdkWallet extends AeSdk {
165
145
  }, origin);
166
146
  client.status = RPC_STATUS.CONNECTED;
167
147
  client.connectNode = connectNode;
168
- return { ...(await this.getWalletInfo()),
148
+ return {
149
+ ...(await this.getWalletInfo()),
169
150
  ...(connectNode && this._getNode())
170
151
  };
171
152
  },
@@ -179,20 +160,16 @@ export default class AeSdkWallet extends AeSdk {
179
160
  type,
180
161
  value
181
162
  }, origin);
182
-
183
163
  switch (type) {
184
164
  case SUBSCRIPTION_TYPES.subscribe:
185
165
  client.addressSubscription.add(value);
186
166
  break;
187
-
188
167
  case SUBSCRIPTION_TYPES.unsubscribe:
189
168
  client.addressSubscription.delete(value);
190
169
  break;
191
-
192
170
  default:
193
171
  throw new InternalError(`Unknown subscription type: ${type}`);
194
172
  }
195
-
196
173
  return {
197
174
  subscription: Array.from(client.addressSubscription),
198
175
  address: this.getAccounts()
@@ -204,40 +181,29 @@ export default class AeSdkWallet extends AeSdk {
204
181
  return this.addresses();
205
182
  },
206
183
  [METHODS.sign]: async (_ref4, origin) => {
207
- var _onAccount, _context, _overrides$onAccount, _overrides$tx;
208
-
209
184
  let {
210
185
  tx,
211
- onAccount,
186
+ onAccount = this.address,
212
187
  returnSigned
213
188
  } = _ref4;
214
189
  if (!this._isRpcClientConnected(id)) throw new RpcNotAuthorizeError();
215
- (_onAccount = onAccount) !== null && _onAccount !== void 0 ? _onAccount : onAccount = await this.address();
216
-
217
- if (!_includesInstanceProperty(_context = this.addresses()).call(_context, onAccount)) {
190
+ if (!this.addresses().includes(onAccount)) {
218
191
  throw new RpcPermissionDenyError(onAccount);
219
192
  }
220
-
221
- const overrides = await this.onSign(id, {
222
- tx,
223
- returnSigned,
224
- onAccount
225
- }, origin);
226
- onAccount = (_overrides$onAccount = overrides === null || overrides === void 0 ? void 0 : overrides.onAccount) !== null && _overrides$onAccount !== void 0 ? _overrides$onAccount : onAccount;
227
- tx = (_overrides$tx = overrides === null || overrides === void 0 ? void 0 : overrides.tx) !== null && _overrides$tx !== void 0 ? _overrides$tx : tx;
228
-
193
+ const parameters = {
194
+ onAccount,
195
+ aeppOrigin: origin,
196
+ aeppRpcClientId: id
197
+ };
229
198
  if (returnSigned) {
230
199
  return {
231
- signedTransaction: await this.signTransaction(tx, {
232
- onAccount
233
- })
200
+ signedTransaction: await this.signTransaction(tx, parameters)
234
201
  };
235
202
  }
236
-
237
203
  try {
238
204
  return jsonBig.parse(jsonBig.stringify({
239
205
  transactionHash: await this.send(tx, {
240
- onAccount,
206
+ ...parameters,
241
207
  verify: false
242
208
  })
243
209
  }));
@@ -248,79 +214,65 @@ export default class AeSdkWallet extends AeSdk {
248
214
  }
249
215
  },
250
216
  [METHODS.signMessage]: async (_ref5, origin) => {
251
- var _onAccount2, _context2, _overrides$onAccount2;
252
-
253
217
  let {
254
218
  message,
255
- onAccount
219
+ onAccount = this.address
256
220
  } = _ref5;
257
221
  if (!this._isRpcClientConnected(id)) throw new RpcNotAuthorizeError();
258
- (_onAccount2 = onAccount) !== null && _onAccount2 !== void 0 ? _onAccount2 : onAccount = await this.address();
259
-
260
- if (!_includesInstanceProperty(_context2 = this.addresses()).call(_context2, onAccount)) {
222
+ if (!this.addresses().includes(onAccount)) {
261
223
  throw new RpcPermissionDenyError(onAccount);
262
224
  }
263
-
264
- const overrides = await this.onMessageSign(id, {
265
- message,
266
- onAccount
267
- }, origin);
268
- onAccount = (_overrides$onAccount2 = overrides === null || overrides === void 0 ? void 0 : overrides.onAccount) !== null && _overrides$onAccount2 !== void 0 ? _overrides$onAccount2 : onAccount;
225
+ const parameters = {
226
+ onAccount,
227
+ aeppOrigin: origin,
228
+ aeppRpcClientId: id
229
+ };
269
230
  return {
270
- // TODO: fix signMessage return type
271
- signature: await this.signMessage(message, {
272
- onAccount,
273
- returnHex: true
274
- })
231
+ signature: _Buffer.from(await this.signMessage(message, parameters)).toString('hex')
275
232
  };
276
233
  }
277
234
  })
278
235
  };
279
-
280
236
  this._clients.set(id, client);
281
-
282
237
  return id;
283
238
  }
239
+
284
240
  /**
285
241
  * Send shareWalletInfo message to notify AEPP about wallet
286
242
  * @param clientId - ID of RPC client send message to
287
243
  */
288
-
289
-
290
244
  async shareWalletInfo(clientId) {
291
245
  this._getClient(clientId).rpc.notify(METHODS.readyToConnect, await this.getWalletInfo());
292
246
  }
247
+
293
248
  /**
294
249
  * Get Wallet info object
295
250
  * @returns Object with wallet information
296
251
  */
297
-
298
-
299
252
  async getWalletInfo() {
300
253
  return {
301
254
  id: this.id,
302
255
  name: this.name,
303
- networkId: await this.getNetworkId(),
256
+ networkId: await this.api.getNetworkId(),
304
257
  origin: window.location.origin,
305
258
  type: this._type
306
259
  };
307
260
  }
261
+
308
262
  /**
309
263
  * Get Wallet accounts
310
264
  * @returns Object with accounts information (\{ connected: Object, current: Object \})
311
265
  */
312
-
313
-
314
266
  getAccounts() {
315
267
  return {
316
268
  current: this.selectedAddress != null ? {
317
269
  [this.selectedAddress]: {}
318
270
  } : {},
319
- connected: this.addresses().filter(a => a !== this.selectedAddress).reduce((acc, a) => ({ ...acc,
271
+ connected: this.addresses().filter(a => a !== this.selectedAddress).reduce((acc, a) => ({
272
+ ...acc,
320
273
  [a]: {}
321
274
  }), {})
322
275
  };
323
276
  }
324
-
325
277
  }
326
278
  //# sourceMappingURL=AeSdkWallet.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"AeSdkWallet.mjs","names":["v4","uuid","AeSdk","verifyTransaction","RpcClient","METHODS","RPC_STATUS","SUBSCRIPTION_TYPES","RpcBroadcastError","RpcInvalidTransactionError","RpcNotAuthorizeError","RpcPermissionDenyError","RpcUnsupportedProtocolError","InternalError","UnknownRpcClientError","RPC_VERSION","jsonBig","AeSdkWallet","constructor","name","id","type","onConnection","onSubscription","onSign","onDisconnect","onAskAccounts","onMessageSign","options","_clients","Map","_type","_pushAccountsToApps","Array","from","keys","filter","clientId","_isRpcClientSubscribed","map","_getClient","rpc","forEach","client","notify","updateAddress","getAccounts","selectAccount","address","addAccount","account","_getNode","ensureNodeConnected","node","url","api","selectedNodeName","selectNode","networkId","getNetworkId","_isRpcClientConnected","updateNetwork","connectNode","get","addressSubscription","size","CONNECTED","status","connection","isConnected","_disconnectRpcClient","disconnect","DISCONNECTED","Set","removeRpcClient","delete","addRpcClient","clientConnection","disconnectParams","WAITING_FOR_CONNECTION_REQUEST","closeConnection","params","connect","origin","version","icons","getWalletInfo","subscribeAddress","value","subscribe","add","unsubscribe","subscription","addresses","sign","tx","onAccount","returnSigned","overrides","signedTransaction","signTransaction","parse","stringify","transactionHash","send","verify","error","validation","length","message","signMessage","signature","returnHex","set","shareWalletInfo","readyToConnect","window","location","current","selectedAddress","connected","a","reduce","acc"],"sources":["../src/AeSdkWallet.ts"],"sourcesContent":["import { v4 as uuid } from '@aeternity/uuid';\nimport AeSdk from './AeSdk';\nimport { Account } from './AeSdkBase';\nimport verifyTransaction from './tx/validator';\nimport RpcClient from './aepp-wallet-communication/rpc/RpcClient';\nimport {\n METHODS, RPC_STATUS, SUBSCRIPTION_TYPES, WALLET_TYPE,\n RpcBroadcastError, RpcInvalidTransactionError,\n RpcNotAuthorizeError, RpcPermissionDenyError, RpcUnsupportedProtocolError,\n} from './aepp-wallet-communication/schema';\nimport { InternalError, UnknownRpcClientError } from './utils/errors';\nimport AccountBase from './account/Base';\nimport BrowserConnection from './aepp-wallet-communication/connection/Browser';\nimport {\n Accounts,\n AeppApi,\n Network,\n RPC_VERSION,\n WalletApi,\n WalletInfo,\n} from './aepp-wallet-communication/rpc/types';\nimport { Encoded } from './utils/encoder';\nimport jsonBig from './utils/json-big';\n\ntype RpcClientWallet = RpcClient<AeppApi, WalletApi>;\n\ntype OnConnection = (\n clientId: string, params: Omit<Parameters<WalletApi[METHODS.connect]>[0], 'version'>, origin: string\n) => void;\n\ntype OnSubscription = (\n clientId: string, params: Parameters<WalletApi[METHODS.subscribeAddress]>[0], origin: string\n) => void;\n\ntype OnSign = (\n clientId: string, params: Parameters<WalletApi[METHODS.sign]>[0], origin: string\n) => Promise<{ tx?: Encoded.Transaction; onAccount?: Account } | undefined> | Promise<void>;\n\ntype OnDisconnect = (\n clientId: string, params: Parameters<WalletApi[METHODS.closeConnection]>[0]\n) => void;\n\ntype OnAskAccounts = (\n clientId: string, params: undefined, origin: string\n) => void;\n\ntype OnMessageSign = (\n clientId: string, params: Parameters<WalletApi[METHODS.signMessage]>[0], origin: string\n) => Promise<{ onAccount?: Account } | undefined> | Promise<void>;\n\ninterface RpcClientsInfo {\n id: string;\n status: RPC_STATUS;\n connectNode: boolean;\n addressSubscription: Set<'connected' | 'current'>;\n rpc: RpcClientWallet;\n}\n\n/**\n * Contain functionality for aepp interaction and managing multiple aepps\n * @category aepp wallet communication\n */\nexport default class AeSdkWallet extends AeSdk {\n id: string;\n\n _type: WALLET_TYPE;\n\n name: string;\n\n _clients: Map<string, RpcClientsInfo>;\n\n onConnection: OnConnection;\n\n onSubscription: OnSubscription;\n\n onSign: OnSign;\n\n onDisconnect: OnDisconnect;\n\n onAskAccounts: OnAskAccounts;\n\n onMessageSign: OnMessageSign;\n\n /**\n * @param options - Options\n * @param options.name - Wallet name\n * @param options.id - Wallet id\n * @param options.type - Wallet type\n * @param options.onConnection - Call-back function for incoming AEPP connection\n * @param options.onSubscription - Call-back function for incoming AEPP account subscription\n * @param options.onSign - Call-back function for incoming AEPP sign request\n * @param options.onAskAccounts - Call-back function for incoming AEPP get address request\n * @param options.onMessageSign - Call-back function for incoming AEPP sign message request\n * @param options.onDisconnect - Call-back function for disconnect event\n */\n constructor({\n name,\n id,\n type,\n onConnection,\n onSubscription,\n onSign,\n onDisconnect,\n onAskAccounts,\n onMessageSign,\n ...options\n }: {\n id: string;\n type: WALLET_TYPE;\n name: string;\n onConnection: OnConnection;\n onSubscription: OnSubscription;\n onSign: OnSign;\n onDisconnect: OnDisconnect;\n onAskAccounts: OnAskAccounts;\n onMessageSign: OnMessageSign;\n } & ConstructorParameters<typeof AeSdk>[0]) {\n super(options);\n this.onConnection = onConnection;\n this.onSubscription = onSubscription;\n this.onSign = onSign;\n this.onDisconnect = onDisconnect;\n this.onAskAccounts = onAskAccounts;\n this.onMessageSign = onMessageSign;\n this._clients = new Map();\n this.name = name;\n this.id = id;\n this._type = type;\n }\n\n _pushAccountsToApps(): void {\n Array.from(this._clients.keys())\n .filter((clientId) => this._isRpcClientSubscribed(clientId))\n .map((clientId) => this._getClient(clientId).rpc)\n .forEach((client) => client.notify(METHODS.updateAddress, this.getAccounts()));\n }\n\n selectAccount(address: Encoded.AccountAddress): void {\n super.selectAccount(address);\n this._pushAccountsToApps();\n }\n\n async addAccount(\n account: AccountBase,\n options?: Parameters<AeSdk['addAccount']>[1],\n ): Promise<void> {\n await super.addAccount(account, options);\n this._pushAccountsToApps();\n }\n\n _getNode(): { node: Network['node'] } {\n this.ensureNodeConnected();\n return { node: { url: this.api.url, name: this.selectedNodeName } };\n }\n\n async selectNode(name: string): Promise<void> {\n super.selectNode(name);\n const networkId = await this.getNetworkId();\n Array.from(this._clients.keys())\n .filter((clientId) => this._isRpcClientConnected(clientId))\n .map((clientId) => this._getClient(clientId))\n .forEach((client) => {\n client.rpc.notify(METHODS.updateNetwork, {\n networkId,\n ...client.connectNode && this._getNode(),\n });\n });\n }\n\n _getClient(clientId: string): RpcClientsInfo {\n const client = this._clients.get(clientId);\n if (client == null) throw new UnknownRpcClientError(clientId);\n return client;\n }\n\n _isRpcClientSubscribed(clientId: string): boolean {\n return this._isRpcClientConnected(clientId)\n && this._getClient(clientId).addressSubscription.size !== 0;\n }\n\n _isRpcClientConnected(clientId: string): boolean {\n return RPC_STATUS.CONNECTED === this._getClient(clientId).status\n && this._getClient(clientId).rpc.connection.isConnected();\n }\n\n _disconnectRpcClient(clientId: string): void {\n const client = this._getClient(clientId);\n client.rpc.connection.disconnect();\n client.status = RPC_STATUS.DISCONNECTED;\n client.addressSubscription = new Set();\n }\n\n /**\n * Remove specific RpcClient by ID\n * @param id - Client ID\n */\n removeRpcClient(id: string): void {\n this._disconnectRpcClient(id);\n this._clients.delete(id);\n }\n\n /**\n * Add new client by AEPP connection\n * @param clientConnection - AEPP connection object\n * @returns Client ID\n */\n addRpcClient(clientConnection: BrowserConnection): string {\n // @TODO detect if aepp has some history based on origin????\n // if yes use this instance for connection\n const id = uuid();\n let disconnectParams: any;\n const client: RpcClientsInfo = {\n id,\n status: RPC_STATUS.WAITING_FOR_CONNECTION_REQUEST,\n addressSubscription: new Set(),\n connectNode: false,\n rpc: new RpcClient<AeppApi, WalletApi>(\n clientConnection,\n () => {\n this._clients.delete(id);\n this.onDisconnect(id, disconnectParams); // also related info\n },\n {\n [METHODS.closeConnection]: (params) => {\n disconnectParams = params;\n this._disconnectRpcClient(id);\n },\n // Store client info and prepare two fn for each client `connect` and `denyConnection`\n // which automatically prepare and send response for that client\n [METHODS.connect]: async ({\n name, version, icons, connectNode,\n }, origin) => {\n if (version !== RPC_VERSION) throw new RpcUnsupportedProtocolError();\n\n await this.onConnection(id, { name, icons, connectNode }, origin);\n client.status = RPC_STATUS.CONNECTED;\n client.connectNode = connectNode;\n return {\n ...await this.getWalletInfo(),\n ...connectNode && this._getNode(),\n };\n },\n [METHODS.subscribeAddress]: async ({ type, value }, origin) => {\n if (!this._isRpcClientConnected(id)) throw new RpcNotAuthorizeError();\n\n await this.onSubscription(id, { type, value }, origin);\n\n switch (type) {\n case SUBSCRIPTION_TYPES.subscribe:\n client.addressSubscription.add(value);\n break;\n case SUBSCRIPTION_TYPES.unsubscribe:\n client.addressSubscription.delete(value);\n break;\n default:\n throw new InternalError(`Unknown subscription type: ${type}`);\n }\n\n return {\n subscription: Array.from(client.addressSubscription),\n address: this.getAccounts(),\n };\n },\n [METHODS.address]: async (params, origin) => {\n if (!this._isRpcClientSubscribed(id)) throw new RpcNotAuthorizeError();\n await this.onAskAccounts(id, params, origin);\n return this.addresses();\n },\n [METHODS.sign]: async ({ tx, onAccount, returnSigned }, origin) => {\n if (!this._isRpcClientConnected(id)) throw new RpcNotAuthorizeError();\n onAccount ??= await this.address();\n if (!this.addresses().includes(onAccount)) {\n throw new RpcPermissionDenyError(onAccount);\n }\n\n const overrides = await this.onSign(id, { tx, returnSigned, onAccount }, origin);\n onAccount = overrides?.onAccount ?? onAccount;\n tx = overrides?.tx ?? tx;\n if (returnSigned) {\n return { signedTransaction: await this.signTransaction(tx, { onAccount }) };\n }\n try {\n return jsonBig.parse(jsonBig.stringify({\n transactionHash: await this.send(tx, { onAccount, verify: false }),\n }));\n } catch (error) {\n const validation = await verifyTransaction(tx, this.api);\n if (validation.length > 0) throw new RpcInvalidTransactionError(validation);\n throw new RpcBroadcastError(error.message);\n }\n },\n [METHODS.signMessage]: async ({ message, onAccount }, origin) => {\n if (!this._isRpcClientConnected(id)) throw new RpcNotAuthorizeError();\n onAccount ??= await this.address();\n if (!this.addresses().includes(onAccount)) {\n throw new RpcPermissionDenyError(onAccount);\n }\n\n const overrides = await this.onMessageSign(id, { message, onAccount }, origin);\n onAccount = overrides?.onAccount ?? onAccount;\n return {\n // TODO: fix signMessage return type\n signature: await this.signMessage(message, { onAccount, returnHex: true }) as\n unknown as string,\n };\n },\n },\n ),\n };\n this._clients.set(id, client);\n return id;\n }\n\n /**\n * Send shareWalletInfo message to notify AEPP about wallet\n * @param clientId - ID of RPC client send message to\n */\n async shareWalletInfo(clientId: string): Promise<void> {\n this._getClient(clientId).rpc.notify(METHODS.readyToConnect, await this.getWalletInfo());\n }\n\n /**\n * Get Wallet info object\n * @returns Object with wallet information\n */\n async getWalletInfo(): Promise<WalletInfo> {\n return {\n id: this.id,\n name: this.name,\n networkId: await this.getNetworkId(),\n origin: window.location.origin,\n type: this._type,\n };\n }\n\n /**\n * Get Wallet accounts\n * @returns Object with accounts information (\\{ connected: Object, current: Object \\})\n */\n getAccounts(): Accounts {\n return {\n current: this.selectedAddress != null ? { [this.selectedAddress]: {} } : {},\n connected: this.addresses()\n .filter((a) => a !== this.selectedAddress)\n .reduce((acc, a) => ({ ...acc, [a]: {} }), {}),\n };\n }\n}\n"],"mappings":";AAAA,SAASA,EAAE,IAAIC,IAAf,QAA2B,iBAA3B;OACOC,K;OAEAC,iB;OACAC,S;SAELC,O,EAASC,U,EAAYC,kB,EACrBC,iB,EAAmBC,0B,EACnBC,oB,EAAsBC,sB,EAAwBC,2B;SAEvCC,a,EAAeC,qB;SAOtBC,W;OAKKC,O;;AAoCP;AACA;AACA;AACA;AACA,eAAe,MAAMC,WAAN,SAA0Bf,KAA1B,CAAgC;EAqB7C;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEgB,WAAW,OAqBiC;IAAA,IArBhC;MACVC,IADU;MAEVC,EAFU;MAGVC,IAHU;MAIVC,YAJU;MAKVC,cALU;MAMVC,MANU;MAOVC,YAPU;MAQVC,aARU;MASVC,aATU;MAUV,GAAGC;IAVO,CAqBgC;IAC1C,MAAMA,OAAN;IACA,KAAKN,YAAL,GAAoBA,YAApB;IACA,KAAKC,cAAL,GAAsBA,cAAtB;IACA,KAAKC,MAAL,GAAcA,MAAd;IACA,KAAKC,YAAL,GAAoBA,YAApB;IACA,KAAKC,aAAL,GAAqBA,aAArB;IACA,KAAKC,aAAL,GAAqBA,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I,EAAE,KAAKU;IALN,CAAP;EAOD;EAED;AACF;AACA;AACA;;;EACEe,WAAW,GAAa;IACtB,OAAO;MACLwE,OAAO,EAAE,KAAKC,eAAL,IAAwB,IAAxB,GAA+B;QAAE,CAAC,KAAKA,eAAN,GAAwB;MAA1B,CAA/B,GAAgE,EADpE;MAELC,SAAS,EAAE,KAAK3B,SAAL,GACRzD,MADQ,CACAqF,CAAD,IAAOA,CAAC,KAAK,KAAKF,eADjB,EAERG,MAFQ,CAED,CAACC,GAAD,EAAMF,CAAN,MAAa,EAAE,GAAGE,GAAL;QAAU,CAACF,CAAD,GAAK;MAAf,CAAb,CAFC,EAEkC,EAFlC;IAFN,CAAP;EAMD;;AA5R4C"}
1
+ {"version":3,"file":"AeSdkWallet.mjs","names":["v4","uuid","AeSdk","verifyTransaction","RpcClient","METHODS","RPC_STATUS","SUBSCRIPTION_TYPES","RpcBroadcastError","RpcInvalidTransactionError","RpcNotAuthorizeError","RpcPermissionDenyError","RpcUnsupportedProtocolError","InternalError","UnknownRpcClientError","RPC_VERSION","jsonBig","AeSdkWallet","constructor","name","id","type","onConnection","onSubscription","onDisconnect","onAskAccounts","options","Map","_type","_pushAccountsToApps","_clients","Array","from","keys","filter","clientId","_isRpcClientSubscribed","map","_getClient","rpc","forEach","client","notify","updateAddress","getAccounts","selectAccount","address","addAccount","account","_getNode","ensureNodeConnected","node","url","api","$host","selectedNodeName","selectNode","networkId","getNetworkId","_isRpcClientConnected","updateNetwork","connectNode","get","addressSubscription","size","CONNECTED","status","connection","isConnected","_disconnectRpcClient","disconnect","DISCONNECTED","Set","removeRpcClient","delete","addRpcClient","clientConnection","disconnectParams","WAITING_FOR_CONNECTION_REQUEST","closeConnection","params","connect","origin","version","icons","getWalletInfo","subscribeAddress","value","subscribe","add","unsubscribe","subscription","addresses","sign","tx","onAccount","returnSigned","includes","parameters","aeppOrigin","aeppRpcClientId","signedTransaction","signTransaction","parse","stringify","transactionHash","send","verify","error","validation","length","message","signMessage","signature","toString","set","shareWalletInfo","readyToConnect","window","location","current","selectedAddress","connected","a","reduce","acc"],"sources":["../src/AeSdkWallet.ts"],"sourcesContent":["import { v4 as uuid } from '@aeternity/uuid';\nimport AeSdk from './AeSdk';\nimport verifyTransaction from './tx/validator';\nimport RpcClient from './aepp-wallet-communication/rpc/RpcClient';\nimport {\n METHODS, RPC_STATUS, SUBSCRIPTION_TYPES, WALLET_TYPE,\n RpcBroadcastError, RpcInvalidTransactionError,\n RpcNotAuthorizeError, RpcPermissionDenyError, RpcUnsupportedProtocolError,\n} from './aepp-wallet-communication/schema';\nimport { InternalError, UnknownRpcClientError } from './utils/errors';\nimport AccountBase from './account/Base';\nimport BrowserConnection from './aepp-wallet-communication/connection/Browser';\nimport {\n Accounts,\n AeppApi,\n Network,\n RPC_VERSION,\n WalletApi,\n WalletInfo,\n} from './aepp-wallet-communication/rpc/types';\nimport { Encoded } from './utils/encoder';\nimport jsonBig from './utils/json-big';\n\ntype RpcClientWallet = RpcClient<AeppApi, WalletApi>;\n\ntype OnConnection = (\n clientId: string, params: Omit<Parameters<WalletApi[METHODS.connect]>[0], 'version'>, origin: string\n) => void;\n\ntype OnSubscription = (\n clientId: string, params: Parameters<WalletApi[METHODS.subscribeAddress]>[0], origin: string\n) => void;\n\ntype OnDisconnect = (\n clientId: string, params: Parameters<WalletApi[METHODS.closeConnection]>[0]\n) => void;\n\ntype OnAskAccounts = (\n clientId: string, params: undefined, origin: string\n) => void;\n\ninterface RpcClientsInfo {\n id: string;\n status: RPC_STATUS;\n connectNode: boolean;\n addressSubscription: Set<'connected' | 'current'>;\n rpc: RpcClientWallet;\n}\n\n/**\n * Contain functionality for aepp interaction and managing multiple aepps\n * @category aepp wallet communication\n */\nexport default class AeSdkWallet extends AeSdk {\n id: string;\n\n _type: WALLET_TYPE;\n\n name: string;\n\n _clients = new Map<string, RpcClientsInfo>();\n\n onConnection: OnConnection;\n\n onSubscription: OnSubscription;\n\n onDisconnect: OnDisconnect;\n\n onAskAccounts: OnAskAccounts;\n\n /**\n * @param options - Options\n * @param options.name - Wallet name\n * @param options.id - Wallet id\n * @param options.type - Wallet type\n * @param options.onConnection - Call-back function for incoming AEPP connection\n * @param options.onSubscription - Call-back function for incoming AEPP account subscription\n * @param options.onAskAccounts - Call-back function for incoming AEPP get address request\n * @param options.onDisconnect - Call-back function for disconnect event\n */\n constructor({\n name,\n id,\n type,\n onConnection,\n onSubscription,\n onDisconnect,\n onAskAccounts,\n ...options\n }: {\n id: string;\n type: WALLET_TYPE;\n name: string;\n onConnection: OnConnection;\n onSubscription: OnSubscription;\n onDisconnect: OnDisconnect;\n onAskAccounts: OnAskAccounts;\n } & ConstructorParameters<typeof AeSdk>[0]) {\n super(options);\n this.onConnection = onConnection;\n this.onSubscription = onSubscription;\n this.onDisconnect = onDisconnect;\n this.onAskAccounts = onAskAccounts;\n this.name = name;\n this.id = id;\n this._type = type;\n }\n\n _pushAccountsToApps(): void {\n if (this._clients == null) return;\n Array.from(this._clients.keys())\n .filter((clientId) => this._isRpcClientSubscribed(clientId))\n .map((clientId) => this._getClient(clientId).rpc)\n .forEach((client) => client.notify(METHODS.updateAddress, this.getAccounts()));\n }\n\n override selectAccount(address: Encoded.AccountAddress): void {\n super.selectAccount(address);\n this._pushAccountsToApps();\n }\n\n override addAccount(account: AccountBase, options?: Parameters<AeSdk['addAccount']>[1]): void {\n super.addAccount(account, options);\n this._pushAccountsToApps();\n }\n\n _getNode(): { node: Network['node'] } {\n this.ensureNodeConnected();\n return { node: { url: this.api.$host, name: this.selectedNodeName } };\n }\n\n override async selectNode(name: string): Promise<void> {\n super.selectNode(name);\n const networkId = await this.api.getNetworkId();\n Array.from(this._clients.keys())\n .filter((clientId) => this._isRpcClientConnected(clientId))\n .map((clientId) => this._getClient(clientId))\n .forEach((client) => {\n client.rpc.notify(METHODS.updateNetwork, {\n networkId,\n ...client.connectNode && this._getNode(),\n });\n });\n }\n\n _getClient(clientId: string): RpcClientsInfo {\n const client = this._clients.get(clientId);\n if (client == null) throw new UnknownRpcClientError(clientId);\n return client;\n }\n\n _isRpcClientSubscribed(clientId: string): boolean {\n return this._isRpcClientConnected(clientId)\n && this._getClient(clientId).addressSubscription.size !== 0;\n }\n\n _isRpcClientConnected(clientId: string): boolean {\n return RPC_STATUS.CONNECTED === this._getClient(clientId).status\n && this._getClient(clientId).rpc.connection.isConnected();\n }\n\n _disconnectRpcClient(clientId: string): void {\n const client = this._getClient(clientId);\n client.rpc.connection.disconnect();\n client.status = RPC_STATUS.DISCONNECTED;\n client.addressSubscription = new Set();\n }\n\n /**\n * Remove specific RpcClient by ID\n * @param id - Client ID\n */\n removeRpcClient(id: string): void {\n this._disconnectRpcClient(id);\n this._clients.delete(id);\n }\n\n /**\n * Add new client by AEPP connection\n * @param clientConnection - AEPP connection object\n * @returns Client ID\n */\n addRpcClient(clientConnection: BrowserConnection): string {\n // @TODO detect if aepp has some history based on origin????\n // if yes use this instance for connection\n const id = uuid();\n let disconnectParams: any;\n const client: RpcClientsInfo = {\n id,\n status: RPC_STATUS.WAITING_FOR_CONNECTION_REQUEST,\n addressSubscription: new Set(),\n connectNode: false,\n rpc: new RpcClient<AeppApi, WalletApi>(\n clientConnection,\n () => {\n this._clients.delete(id);\n this.onDisconnect(id, disconnectParams); // also related info\n },\n {\n [METHODS.closeConnection]: (params) => {\n disconnectParams = params;\n this._disconnectRpcClient(id);\n },\n // Store client info and prepare two fn for each client `connect` and `denyConnection`\n // which automatically prepare and send response for that client\n [METHODS.connect]: async ({\n name, version, icons, connectNode,\n }, origin) => {\n if (version !== RPC_VERSION) throw new RpcUnsupportedProtocolError();\n\n await this.onConnection(id, { name, icons, connectNode }, origin);\n client.status = RPC_STATUS.CONNECTED;\n client.connectNode = connectNode;\n return {\n ...await this.getWalletInfo(),\n ...connectNode && this._getNode(),\n };\n },\n [METHODS.subscribeAddress]: async ({ type, value }, origin) => {\n if (!this._isRpcClientConnected(id)) throw new RpcNotAuthorizeError();\n\n await this.onSubscription(id, { type, value }, origin);\n\n switch (type) {\n case SUBSCRIPTION_TYPES.subscribe:\n client.addressSubscription.add(value);\n break;\n case SUBSCRIPTION_TYPES.unsubscribe:\n client.addressSubscription.delete(value);\n break;\n default:\n throw new InternalError(`Unknown subscription type: ${type}`);\n }\n\n return {\n subscription: Array.from(client.addressSubscription),\n address: this.getAccounts(),\n };\n },\n [METHODS.address]: async (params, origin) => {\n if (!this._isRpcClientSubscribed(id)) throw new RpcNotAuthorizeError();\n await this.onAskAccounts(id, params, origin);\n return this.addresses();\n },\n [METHODS.sign]: async ({ tx, onAccount = this.address, returnSigned }, origin) => {\n if (!this._isRpcClientConnected(id)) throw new RpcNotAuthorizeError();\n if (!this.addresses().includes(onAccount)) {\n throw new RpcPermissionDenyError(onAccount);\n }\n\n const parameters = { onAccount, aeppOrigin: origin, aeppRpcClientId: id };\n if (returnSigned) {\n return { signedTransaction: await this.signTransaction(tx, parameters) };\n }\n try {\n return jsonBig.parse(jsonBig.stringify({\n transactionHash: await this.send(tx, { ...parameters, verify: false }),\n }));\n } catch (error) {\n const validation = await verifyTransaction(tx, this.api);\n if (validation.length > 0) throw new RpcInvalidTransactionError(validation);\n throw new RpcBroadcastError(error.message);\n }\n },\n [METHODS.signMessage]: async ({ message, onAccount = this.address }, origin) => {\n if (!this._isRpcClientConnected(id)) throw new RpcNotAuthorizeError();\n if (!this.addresses().includes(onAccount)) {\n throw new RpcPermissionDenyError(onAccount);\n }\n\n const parameters = { onAccount, aeppOrigin: origin, aeppRpcClientId: id };\n return {\n signature: Buffer.from(await this.signMessage(message, parameters)).toString('hex'),\n };\n },\n },\n ),\n };\n this._clients.set(id, client);\n return id;\n }\n\n /**\n * Send shareWalletInfo message to notify AEPP about wallet\n * @param clientId - ID of RPC client send message to\n */\n async shareWalletInfo(clientId: string): Promise<void> {\n this._getClient(clientId).rpc.notify(METHODS.readyToConnect, await this.getWalletInfo());\n }\n\n /**\n * Get Wallet info object\n * @returns Object with wallet information\n */\n async getWalletInfo(): Promise<WalletInfo> {\n return {\n id: this.id,\n name: this.name,\n networkId: await this.api.getNetworkId(),\n origin: window.location.origin,\n type: this._type,\n };\n }\n\n /**\n * Get Wallet accounts\n * @returns Object with accounts information (\\{ connected: Object, current: Object \\})\n */\n getAccounts(): Accounts {\n return {\n current: this.selectedAddress != null ? { [this.selectedAddress]: {} } : {},\n connected: this.addresses()\n .filter((a) => a !== this.selectedAddress)\n .reduce((acc, a) => ({ ...acc, [a]: {} }), {}),\n };\n }\n}\n"],"mappings":";;;;;AAAA,SAASA,EAAE,IAAIC,IAAI,QAAQ,iBAAiB;AAAC,OACtCC,KAAK;AAAA,OACLC,iBAAiB;AAAA,OACjBC,SAAS;AAAA,SAEdC,OAAO,EAAEC,UAAU,EAAEC,kBAAkB,EACvCC,iBAAiB,EAAEC,0BAA0B,EAC7CC,oBAAoB,EAAEC,sBAAsB,EAAEC,2BAA2B;AAAA,SAElEC,aAAa,EAAEC,qBAAqB;AAAA,SAO3CC,WAAW;AAAA,OAKNC,OAAO;AA4Bd;AACA;AACA;AACA;AACA,eAAe,MAAMC,WAAW,SAASf,KAAK,CAAC;EAiB7C;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEgB,WAAW,OAiBiC;IAAA,IAjBhC;MACVC,IAAI;MACJC,EAAE;MACFC,IAAI;MACJC,YAAY;MACZC,cAAc;MACdC,YAAY;MACZC,aAAa;MACb,GAAGC;IASoC,CAAC;IACxC,KAAK,CAACA,OAAO,CAAC;IAAC,kCAtCN,IAAIC,GAAG,EAA0B;IAuC1C,IAAI,CAACL,YAAY,GAAGA,YAAY;IAChC,IAAI,CAACC,cAAc,GAAGA,cAAc;IACpC,IAAI,CAACC,YAAY,GAAGA,YAAY;IAChC,IAAI,CAACC,aAAa,GAAGA,aAAa;IAClC,IAAI,CAACN,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACC,EAAE,GAAGA,EAAE;IACZ,IAAI,CAACQ,KAAK,GAAGP,IAAI;EACnB;EAEAQ,mBAAmB,GAAS;I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B,SAAS,EAAE,CACxB1D,MAAM,CAAEyF,CAAC,IAAKA,CAAC,KAAK,IAAI,CAACF,eAAe,CAAC,CACzCG,MAAM,CAAC,CAACC,GAAG,EAAEF,CAAC,MAAM;QAAE,GAAGE,GAAG;QAAE,CAACF,CAAC,GAAG,CAAC;MAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IACjD,CAAC;EACH;AACF"}
package/es/Node.d.ts CHANGED
@@ -1,22 +1,16 @@
1
1
  import { Node as NodeApi, NodeOptionalParams } from './apis/node';
2
2
  import { Encoded } from './utils/encoder';
3
- /**
4
- * Obtain networkId from account or node
5
- */
6
- export declare function getNetworkId({ networkId }?: {
7
- networkId?: string;
8
- }): Promise<string>;
9
3
  declare const bigIntPropertyNames: readonly ["balance", "queryFee", "fee", "amount", "nameFee", "channelAmount", "initiatorAmount", "responderAmount", "channelReserve", "initiatorAmountFinal", "responderAmountFinal", "gasPrice", "deposit"];
10
4
  declare const numberPropertyNames: readonly ["time", "gas", "gasUsed", "nameSalt", "nonce", "nextNonce", "height", "blockHeight", "top", "topBlockHeight", "ttl", "nameTtl", "clientTtl", "inbound", "outbound", "peerCount", "pendingTransactionsCount", "effectiveAtHeight", "version", "solutions", "round"];
11
- declare type BigIntPropertyNames = typeof bigIntPropertyNames[number];
12
- declare type NumberPropertyNames = typeof numberPropertyNames[number];
13
- declare type PreserveOptional<NewType, OrigType> = OrigType extends undefined ? NewType | undefined : NewType;
14
- export declare type TransformNodeType<Type> = Type extends (...args: infer Args) => infer Ret ? (...args: TransformNodeType<Args>) => TransformNodeType<Ret> : Type extends [infer Item, ...infer Rest] ? [TransformNodeType<Item>, ...TransformNodeType<Rest>] : Type extends Array<infer Item> ? Array<TransformNodeType<Item>> : Type extends Promise<infer T> ? Promise<TransformNodeType<T>> : Type extends {
5
+ type BigIntPropertyNames = typeof bigIntPropertyNames[number];
6
+ type NumberPropertyNames = typeof numberPropertyNames[number];
7
+ type PreserveOptional<NewType, OrigType> = OrigType extends undefined ? NewType | undefined : NewType;
8
+ export type TransformNodeType<Type> = Type extends (...args: infer Args) => infer Ret ? (...args: TransformNodeType<Args>) => TransformNodeType<Ret> : Type extends [infer Item, ...infer Rest] ? [TransformNodeType<Item>, ...TransformNodeType<Rest>] : Type extends Array<infer Item> ? Array<TransformNodeType<Item>> : Type extends Promise<infer T> ? Promise<TransformNodeType<T>> : Type extends {
15
9
  [P in any]: any;
16
10
  } ? {
17
11
  [Property in keyof Type]: Property extends BigIntPropertyNames ? PreserveOptional<bigint, Type[Property]> : Property extends NumberPropertyNames ? PreserveOptional<number, Type[Property]> : Property extends 'txHash' ? PreserveOptional<Encoded.TxHash, Type[Property]> : TransformNodeType<Type[Property]>;
18
12
  } : Type;
19
- declare type NodeTransformedApi = new (...args: ConstructorParameters<typeof NodeApi>) => {
13
+ type NodeTransformedApi = new (...args: ConstructorParameters<typeof NodeApi>) => {
20
14
  [Name in keyof InstanceType<typeof NodeApi>]: Name extends 'pipeline' | 'sendRequest' | 'sendOperationRequest' ? NodeApi[Name] : TransformNodeType<NodeApi[Name]>;
21
15
  };
22
16
  export interface NodeInfo {
@@ -27,7 +21,7 @@ export interface NodeInfo {
27
21
  }
28
22
  declare const Node_base: NodeTransformedApi;
29
23
  export default class Node extends Node_base {
30
- url: string;
24
+ #private;
31
25
  /**
32
26
  * @param url - Url for node API
33
27
  * @param options - Options
@@ -36,6 +30,7 @@ export default class Node extends Node_base {
36
30
  constructor(url: string, { ignoreVersion, ...options }?: NodeOptionalParams & {
37
31
  ignoreVersion?: boolean;
38
32
  });
33
+ getNetworkId(): Promise<string>;
39
34
  getNodeInfo(): Promise<NodeInfo>;
40
35
  }
41
36
  export {};