@hot-labs/kit 1.1.3 → 1.2.0-alpha.1

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 (327) hide show
  1. package/README.md +9 -2
  2. package/package.json +4 -8
  3. package/src/HotConnector.ts +31 -24
  4. package/src/OmniConnector.ts +9 -10
  5. package/src/OmniWallet.ts +25 -24
  6. package/src/core/Intents.ts +151 -224
  7. package/src/core/api.ts +4 -44
  8. package/src/core/bridge.ts +2 -3
  9. package/src/core/index.ts +1 -1
  10. package/src/{near/rpc.ts → core/nearRpc.ts} +12 -7
  11. package/src/core/types.ts +0 -21
  12. package/src/core/utils.ts +1 -17
  13. package/src/cosmos/connector.ts +26 -22
  14. package/src/cosmos/wallet.ts +8 -3
  15. package/src/evm/connector.ts +0 -5
  16. package/src/evm/wallet.ts +6 -9
  17. package/src/exchange.ts +30 -24
  18. package/src/hot-wallet/google.ts +5 -12
  19. package/src/hot-wallet/proxy.ts +2 -2
  20. package/src/index.ts +0 -2
  21. package/src/near/connector.ts +2 -2
  22. package/src/near/wallet.ts +9 -4
  23. package/src/solana/connector.ts +8 -9
  24. package/src/solana/injected/solana-wallet.ts +6 -6
  25. package/src/solana/{WalletStandard.ts → protocol.ts} +4 -2
  26. package/src/solana/wallet.ts +20 -11
  27. package/src/stellar/connector.ts +6 -1
  28. package/src/stellar/wallet.ts +17 -17
  29. package/src/ton/connector.ts +5 -1
  30. package/src/ton/wallet.ts +3 -3
  31. package/src/ui/Popup.tsx +4 -12
  32. package/src/ui/connect/AuthPopup.tsx +1 -2
  33. package/src/ui/connect/ConnectWallet.tsx +6 -12
  34. package/src/ui/icons/arrow-right.tsx +2 -2
  35. package/src/ui/icons/close.tsx +1 -1
  36. package/src/ui/icons/exchange.tsx +4 -4
  37. package/src/ui/icons/logout.tsx +6 -6
  38. package/src/ui/icons/pending.tsx +4 -2
  39. package/src/ui/icons/qr.tsx +2 -1
  40. package/src/ui/icons/search.tsx +4 -4
  41. package/src/ui/icons/switch.tsx +4 -4
  42. package/src/ui/icons/wallet.tsx +4 -2
  43. package/src/ui/payment/Bridge.tsx +6 -25
  44. package/src/ui/payment/Payment.tsx +46 -244
  45. package/src/ui/payment/Profile.tsx +8 -10
  46. package/src/ui/payment/SelectToken.tsx +1 -1
  47. package/src/ui/payment/TokenCard.tsx +18 -22
  48. package/src/ui/router.tsx +16 -56
  49. package/src/ui/styles.ts +0 -2
  50. package/build/HotConnector.d.ts +0 -105
  51. package/build/HotConnector.js +0 -303
  52. package/build/HotConnector.js.map +0 -1
  53. package/build/OmniConnector.d.ts +0 -90
  54. package/build/OmniConnector.js +0 -121
  55. package/build/OmniConnector.js.map +0 -1
  56. package/build/OmniWallet.d.ts +0 -35
  57. package/build/OmniWallet.js +0 -56
  58. package/build/OmniWallet.js.map +0 -1
  59. package/build/activity.d.ts +0 -18
  60. package/build/activity.js +0 -87
  61. package/build/activity.js.map +0 -1
  62. package/build/core/Intents.d.ts +0 -100
  63. package/build/core/Intents.js +0 -474
  64. package/build/core/Intents.js.map +0 -1
  65. package/build/core/api.d.ts +0 -54
  66. package/build/core/api.js +0 -99
  67. package/build/core/api.js.map +0 -1
  68. package/build/core/bridge.d.ts +0 -3
  69. package/build/core/bridge.js +0 -36
  70. package/build/core/bridge.js.map +0 -1
  71. package/build/core/chains.d.ts +0 -115
  72. package/build/core/chains.js +0 -381
  73. package/build/core/chains.js.map +0 -1
  74. package/build/core/defaultTokens.d.ts +0 -17
  75. package/build/core/defaultTokens.js +0 -1079
  76. package/build/core/defaultTokens.js.map +0 -1
  77. package/build/core/events.d.ts +0 -42
  78. package/build/core/events.js +0 -64
  79. package/build/core/events.js.map +0 -1
  80. package/build/core/index.d.ts +0 -10
  81. package/build/core/index.js +0 -11
  82. package/build/core/index.js.map +0 -1
  83. package/build/core/recipient.d.ts +0 -10
  84. package/build/core/recipient.js +0 -40
  85. package/build/core/recipient.js.map +0 -1
  86. package/build/core/telemetry.d.ts +0 -13
  87. package/build/core/telemetry.js +0 -27
  88. package/build/core/telemetry.js.map +0 -1
  89. package/build/core/token.d.ts +0 -36
  90. package/build/core/token.js +0 -103
  91. package/build/core/token.js.map +0 -1
  92. package/build/core/tokens.d.ts +0 -14
  93. package/build/core/tokens.js +0 -59
  94. package/build/core/tokens.js.map +0 -1
  95. package/build/core/types.d.ts +0 -60
  96. package/build/core/types.js +0 -2
  97. package/build/core/types.js.map +0 -1
  98. package/build/core/utils.d.ts +0 -25
  99. package/build/core/utils.js +0 -170
  100. package/build/core/utils.js.map +0 -1
  101. package/build/cosmos/connector.d.ts +0 -36
  102. package/build/cosmos/connector.js +0 -211
  103. package/build/cosmos/connector.js.map +0 -1
  104. package/build/cosmos/helpers.d.ts +0 -2
  105. package/build/cosmos/helpers.js +0 -29
  106. package/build/cosmos/helpers.js.map +0 -1
  107. package/build/cosmos/index.d.ts +0 -6
  108. package/build/cosmos/index.js +0 -5
  109. package/build/cosmos/index.js.map +0 -1
  110. package/build/cosmos/wallet.d.ts +0 -26
  111. package/build/cosmos/wallet.js +0 -51
  112. package/build/cosmos/wallet.js.map +0 -1
  113. package/build/defaults.d.ts +0 -1
  114. package/build/defaults.js +0 -7
  115. package/build/defaults.js.map +0 -1
  116. package/build/evm/abi.d.ts +0 -17
  117. package/build/evm/abi.js +0 -38
  118. package/build/evm/abi.js.map +0 -1
  119. package/build/evm/connector.d.ts +0 -29
  120. package/build/evm/connector.js +0 -118
  121. package/build/evm/connector.js.map +0 -1
  122. package/build/evm/index.d.ts +0 -6
  123. package/build/evm/index.js +0 -5
  124. package/build/evm/index.js.map +0 -1
  125. package/build/evm/injected.d.ts +0 -1
  126. package/build/evm/injected.js +0 -33
  127. package/build/evm/injected.js.map +0 -1
  128. package/build/evm/wallet.d.ts +0 -42
  129. package/build/evm/wallet.js +0 -130
  130. package/build/evm/wallet.js.map +0 -1
  131. package/build/exchange.d.ts +0 -68
  132. package/build/exchange.js +0 -384
  133. package/build/exchange.js.map +0 -1
  134. package/build/hot-wallet/google.d.ts +0 -25
  135. package/build/hot-wallet/google.js +0 -117
  136. package/build/hot-wallet/google.js.map +0 -1
  137. package/build/hot-wallet/iframe.d.ts +0 -36
  138. package/build/hot-wallet/iframe.js +0 -140
  139. package/build/hot-wallet/iframe.js.map +0 -1
  140. package/build/hot-wallet/index.d.ts +0 -5
  141. package/build/hot-wallet/index.js +0 -4
  142. package/build/hot-wallet/index.js.map +0 -1
  143. package/build/hot-wallet/proxy.d.ts +0 -8
  144. package/build/hot-wallet/proxy.js +0 -45
  145. package/build/hot-wallet/proxy.js.map +0 -1
  146. package/build/index.d.ts +0 -6
  147. package/build/index.js +0 -7
  148. package/build/index.js.map +0 -1
  149. package/build/near/connector.d.ts +0 -18
  150. package/build/near/connector.js +0 -58
  151. package/build/near/connector.js.map +0 -1
  152. package/build/near/index.d.ts +0 -7
  153. package/build/near/index.js +0 -5
  154. package/build/near/index.js.map +0 -1
  155. package/build/near/rpc.d.ts +0 -23
  156. package/build/near/rpc.js +0 -162
  157. package/build/near/rpc.js.map +0 -1
  158. package/build/near/wallet.d.ts +0 -53
  159. package/build/near/wallet.js +0 -190
  160. package/build/near/wallet.js.map +0 -1
  161. package/build/solana/WalletStandard.d.ts +0 -25
  162. package/build/solana/WalletStandard.js +0 -56
  163. package/build/solana/WalletStandard.js.map +0 -1
  164. package/build/solana/connector.d.ts +0 -30
  165. package/build/solana/connector.js +0 -139
  166. package/build/solana/connector.js.map +0 -1
  167. package/build/solana/index.d.ts +0 -6
  168. package/build/solana/index.js +0 -5
  169. package/build/solana/index.js.map +0 -1
  170. package/build/solana/injected/account.d.ts +0 -11
  171. package/build/solana/injected/account.js +0 -41
  172. package/build/solana/injected/account.js.map +0 -1
  173. package/build/solana/injected/index.d.ts +0 -1
  174. package/build/solana/injected/index.js +0 -82
  175. package/build/solana/injected/index.js.map +0 -1
  176. package/build/solana/injected/register.d.ts +0 -2
  177. package/build/solana/injected/register.js +0 -41
  178. package/build/solana/injected/register.js.map +0 -1
  179. package/build/solana/injected/solana-wallet.d.ts +0 -34
  180. package/build/solana/injected/solana-wallet.js +0 -223
  181. package/build/solana/injected/solana-wallet.js.map +0 -1
  182. package/build/solana/injected/utils.d.ts +0 -32
  183. package/build/solana/injected/utils.js +0 -36
  184. package/build/solana/injected/utils.js.map +0 -1
  185. package/build/solana/wallet.d.ts +0 -40
  186. package/build/solana/wallet.js +0 -181
  187. package/build/solana/wallet.js.map +0 -1
  188. package/build/solana/walletStandartList.d.ts +0 -102
  189. package/build/solana/walletStandartList.js +0 -150
  190. package/build/solana/walletStandartList.js.map +0 -1
  191. package/build/stellar/connector.d.ts +0 -29
  192. package/build/stellar/connector.js +0 -64
  193. package/build/stellar/connector.js.map +0 -1
  194. package/build/stellar/freigher.d.ts +0 -46
  195. package/build/stellar/freigher.js +0 -110
  196. package/build/stellar/freigher.js.map +0 -1
  197. package/build/stellar/hotWallet.d.ts +0 -33
  198. package/build/stellar/hotWallet.js +0 -28
  199. package/build/stellar/hotWallet.js.map +0 -1
  200. package/build/stellar/index.d.ts +0 -6
  201. package/build/stellar/index.js +0 -5
  202. package/build/stellar/index.js.map +0 -1
  203. package/build/stellar/wallet.d.ts +0 -67
  204. package/build/stellar/wallet.js +0 -212
  205. package/build/stellar/wallet.js.map +0 -1
  206. package/build/storage.d.ts +0 -10
  207. package/build/storage.js +0 -12
  208. package/build/storage.js.map +0 -1
  209. package/build/ton/connector.d.ts +0 -24
  210. package/build/ton/connector.js +0 -111
  211. package/build/ton/connector.js.map +0 -1
  212. package/build/ton/index.d.ts +0 -7
  213. package/build/ton/index.js +0 -5
  214. package/build/ton/index.js.map +0 -1
  215. package/build/ton/injected.d.ts +0 -1
  216. package/build/ton/injected.js +0 -49
  217. package/build/ton/injected.js.map +0 -1
  218. package/build/ton/utils.d.ts +0 -45
  219. package/build/ton/utils.js +0 -63
  220. package/build/ton/utils.js.map +0 -1
  221. package/build/ton/wallet.d.ts +0 -54
  222. package/build/ton/wallet.js +0 -138
  223. package/build/ton/wallet.js.map +0 -1
  224. package/build/tron/connector.d.ts +0 -51
  225. package/build/tron/connector.js +0 -65
  226. package/build/tron/connector.js.map +0 -1
  227. package/build/tron/index.d.ts +0 -6
  228. package/build/tron/index.js +0 -5
  229. package/build/tron/index.js.map +0 -1
  230. package/build/tron/wallet.d.ts +0 -52
  231. package/build/tron/wallet.js +0 -122
  232. package/build/tron/wallet.js.map +0 -1
  233. package/build/ui/Popup.d.ts +0 -12
  234. package/build/ui/Popup.js +0 -43
  235. package/build/ui/Popup.js.map +0 -1
  236. package/build/ui/Toast.d.ts +0 -4
  237. package/build/ui/Toast.js +0 -33
  238. package/build/ui/Toast.js.map +0 -1
  239. package/build/ui/connect/AuthPopup.d.ts +0 -2
  240. package/build/ui/connect/AuthPopup.js +0 -48
  241. package/build/ui/connect/AuthPopup.js.map +0 -1
  242. package/build/ui/connect/ConnectWallet.d.ts +0 -14
  243. package/build/ui/connect/ConnectWallet.js +0 -22
  244. package/build/ui/connect/ConnectWallet.js.map +0 -1
  245. package/build/ui/connect/LogoutPopup.d.ts +0 -10
  246. package/build/ui/connect/LogoutPopup.js +0 -8
  247. package/build/ui/connect/LogoutPopup.js.map +0 -1
  248. package/build/ui/connect/PrimaryWallet.d.ts +0 -6
  249. package/build/ui/connect/PrimaryWallet.js +0 -18
  250. package/build/ui/connect/PrimaryWallet.js.map +0 -1
  251. package/build/ui/connect/WCPopup.d.ts +0 -13
  252. package/build/ui/connect/WCPopup.js +0 -81
  253. package/build/ui/connect/WCPopup.js.map +0 -1
  254. package/build/ui/connect/WCRequest.d.ts +0 -9
  255. package/build/ui/connect/WCRequest.js +0 -13
  256. package/build/ui/connect/WCRequest.js.map +0 -1
  257. package/build/ui/connect/WalletPicker.d.ts +0 -11
  258. package/build/ui/connect/WalletPicker.js +0 -48
  259. package/build/ui/connect/WalletPicker.js.map +0 -1
  260. package/build/ui/icons/arrow-right.d.ts +0 -1
  261. package/build/ui/icons/arrow-right.js +0 -5
  262. package/build/ui/icons/arrow-right.js.map +0 -1
  263. package/build/ui/icons/close.d.ts +0 -1
  264. package/build/ui/icons/close.js +0 -5
  265. package/build/ui/icons/close.js.map +0 -1
  266. package/build/ui/icons/exchange.d.ts +0 -6
  267. package/build/ui/icons/exchange.js +0 -6
  268. package/build/ui/icons/exchange.js.map +0 -1
  269. package/build/ui/icons/logout.d.ts +0 -1
  270. package/build/ui/icons/logout.js +0 -3
  271. package/build/ui/icons/logout.js.map +0 -1
  272. package/build/ui/icons/pending.d.ts +0 -1
  273. package/build/ui/icons/pending.js +0 -5
  274. package/build/ui/icons/pending.js.map +0 -1
  275. package/build/ui/icons/qr.d.ts +0 -1
  276. package/build/ui/icons/qr.js +0 -5
  277. package/build/ui/icons/qr.js.map +0 -1
  278. package/build/ui/icons/search.d.ts +0 -1
  279. package/build/ui/icons/search.js +0 -5
  280. package/build/ui/icons/search.js.map +0 -1
  281. package/build/ui/icons/switch.d.ts +0 -1
  282. package/build/ui/icons/switch.js +0 -5
  283. package/build/ui/icons/switch.js.map +0 -1
  284. package/build/ui/icons/wallet.d.ts +0 -1
  285. package/build/ui/icons/wallet.js +0 -5
  286. package/build/ui/icons/wallet.js.map +0 -1
  287. package/build/ui/payment/Bridge.d.ts +0 -29
  288. package/build/ui/payment/Bridge.js +0 -373
  289. package/build/ui/payment/Bridge.js.map +0 -1
  290. package/build/ui/payment/DepositQR.d.ts +0 -9
  291. package/build/ui/payment/DepositQR.js +0 -56
  292. package/build/ui/payment/DepositQR.js.map +0 -1
  293. package/build/ui/payment/Payment.d.ts +0 -23
  294. package/build/ui/payment/Payment.js +0 -139
  295. package/build/ui/payment/Payment.js.map +0 -1
  296. package/build/ui/payment/Profile.d.ts +0 -8
  297. package/build/ui/payment/Profile.js +0 -110
  298. package/build/ui/payment/Profile.js.map +0 -1
  299. package/build/ui/payment/SelectRecipient.d.ts +0 -14
  300. package/build/ui/payment/SelectRecipient.js +0 -68
  301. package/build/ui/payment/SelectRecipient.js.map +0 -1
  302. package/build/ui/payment/SelectSender.d.ts +0 -13
  303. package/build/ui/payment/SelectSender.js +0 -23
  304. package/build/ui/payment/SelectSender.js.map +0 -1
  305. package/build/ui/payment/SelectToken.d.ts +0 -13
  306. package/build/ui/payment/SelectToken.js +0 -92
  307. package/build/ui/payment/SelectToken.js.map +0 -1
  308. package/build/ui/payment/Stepper.d.ts +0 -13
  309. package/build/ui/payment/Stepper.js +0 -22
  310. package/build/ui/payment/Stepper.js.map +0 -1
  311. package/build/ui/payment/TokenCard.d.ts +0 -25
  312. package/build/ui/payment/TokenCard.js +0 -63
  313. package/build/ui/payment/TokenCard.js.map +0 -1
  314. package/build/ui/router.d.ts +0 -51
  315. package/build/ui/router.js +0 -68
  316. package/build/ui/router.js.map +0 -1
  317. package/build/ui/styles.d.ts +0 -13
  318. package/build/ui/styles.js +0 -290
  319. package/build/ui/styles.js.map +0 -1
  320. package/src/core/telemetry.ts +0 -28
  321. package/src/tron/connector.ts +0 -89
  322. package/src/tron/index.ts +0 -7
  323. package/src/tron/wallet.ts +0 -146
  324. package/src/ui/Toast.tsx +0 -45
  325. package/src/ui/connect/PrimaryWallet.tsx +0 -65
  326. package/src/ui/payment/Stepper.tsx +0 -50
  327. /package/src/solana/{walletStandartList.ts → wallets.ts} +0 -0
package/README.md CHANGED
@@ -36,10 +36,17 @@ export default defineConfig({
36
36
 
37
37
  ```ts
38
38
  import { HotConnector } from "@hot-labs/kit";
39
- import { defaultConnectors } from "@hot-labs/kit/defaults";
39
+
40
+ // Tree-shaking - use only chains what you need
41
+ import stellar from "@hot-labs/kit/stellar";
42
+ import solana from "@hot-labs/kit/solana";
43
+ import cosmos from "@hot-labs/kit/cosmos";
44
+ import near from "@hot-labs/kit/near";
45
+ import ton from "@hot-labs/kit/ton";
46
+ import evm from "@hot-labs/kit/evm";
40
47
 
41
48
  const connector = new HotConnector({
42
- connectors: defaultConnectors,
49
+ connectors: [near(), evm(), solana(), ton(), stellar(), cosmos()],
43
50
 
44
51
  // optional
45
52
  walletConnect: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hot-labs/kit",
3
- "version": "1.1.3",
3
+ "version": "1.2.0-alpha.1",
4
4
  "description": "HOT Labs Kit is chain agnostic connector with omni payments",
5
5
  "license": "ISC",
6
6
  "author": "",
@@ -17,7 +17,6 @@
17
17
  "./solana": "./build/solana/index.js",
18
18
  "./stellar": "./build/stellar/index.js",
19
19
  "./ton": "./build/ton/index.js",
20
- "./tron": "./build/tron/index.js",
21
20
  "./core": "./build/core/index.js"
22
21
  },
23
22
  "directories": {
@@ -32,31 +31,28 @@
32
31
  "@cosmjs/stargate": "^0.37.0",
33
32
  "@defuse-protocol/one-click-sdk-typescript": "^0.1.13",
34
33
  "@hot-labs/near-connect": "^0.8.1",
35
- "@hot-labs/omni-sdk": "^2.24.6",
34
+ "@hot-labs/omni-sdk": "^2.24.5",
36
35
  "@keplr-wallet/proto-types": "^0.12.291",
37
36
  "@keplr-wallet/provider-extension": "^0.12.291",
38
- "@lottiefiles/dotlottie-wc": "^0.8.11",
37
+ "@metamask/sdk": "^0.34.0",
39
38
  "@near-js/crypto": "^2.3.3",
40
39
  "@near-js/providers": "^2.5.1",
41
40
  "@near-js/utils": "^2.2.4",
42
41
  "@noble/hashes": "^2.0.1",
43
42
  "@scure/base": "^2.0.0",
44
43
  "@solana/spl-token": "^0.4.14",
45
- "@solana/wallet-standard-features": "^1.3.0",
46
44
  "@stellar/freighter-api": "^6.0.1",
47
45
  "@ton-api/client": "^0.4.0",
48
46
  "@ton/core": "^0.62.0",
49
47
  "@ton/crypto": "^3.3.0",
50
48
  "@tonconnect/ui": "^2.2.0",
51
49
  "@wallet-standard/base": "^1.1.0",
52
- "@wallet-standard/features": "^1.1.0",
53
50
  "@walletconnect/universal-provider": "^2.23.0",
54
51
  "ethers": "^6.15.0",
55
52
  "mobx": "^6.15.0",
56
53
  "mobx-react-lite": "^4.1.1",
57
54
  "qr-code-styling": "^1.9.2",
58
- "styled-components": "^6.1.19",
59
- "uuid4": "^2.0.3"
55
+ "styled-components": "^6.1.19"
60
56
  },
61
57
  "scripts": {
62
58
  "build": "rm -rf build && yarn tsc",
@@ -8,12 +8,10 @@ import { OmniToken } from "./core/chains";
8
8
  import { formatter } from "./core/utils";
9
9
  import { Intents } from "./core/Intents";
10
10
  import { tokens } from "./core/tokens";
11
- import { Telemetry } from "./core/telemetry";
11
+ import { rpc } from "./core/nearRpc";
12
12
  import { Token } from "./core/token";
13
13
  import { api } from "./core/api";
14
- import { rpc } from "./near/rpc";
15
14
 
16
- import { defaultConnectors } from "./defaults";
17
15
  import type CosmosWallet from "./cosmos/wallet";
18
16
  import type NearWallet from "./near/wallet";
19
17
  import type EvmWallet from "./evm/wallet";
@@ -21,7 +19,7 @@ import type SolanaWallet from "./solana/wallet";
21
19
  import type StellarWallet from "./stellar/wallet";
22
20
  import type TonWallet from "./ton/wallet";
23
21
 
24
- import { openBridge, openConnector, openProfile, openWalletPicker } from "./ui/router";
22
+ import { openBridge, openConnector, openPayment, openProfile, openWalletPicker } from "./ui/router";
25
23
  import { ConnectorType, OmniConnector } from "./OmniConnector";
26
24
  import { OmniWallet } from "./OmniWallet";
27
25
  import { Exchange } from "./exchange";
@@ -45,15 +43,16 @@ interface HotConnectorOptions {
45
43
  export class HotConnector {
46
44
  public connectors: OmniConnector[] = [];
47
45
  public balances: Record<string, Record<string, bigint>> = {};
48
- public telemetry: Telemetry;
49
46
 
50
47
  public activity: Activity;
51
48
  public hotBridge: HotBridge;
52
49
  public exchange: Exchange;
53
50
 
51
+ readonly version = "1.0.58";
52
+
54
53
  private events = new EventEmitter<{
55
- connect: { wallet: OmniWallet; connector: OmniConnector };
56
- disconnect: { wallet: OmniWallet; connector: OmniConnector };
54
+ connect: { wallet: OmniWallet };
55
+ disconnect: { wallet: OmniWallet };
57
56
  tokensUpdate: { tokens: Token[] };
58
57
  }>();
59
58
 
@@ -85,14 +84,12 @@ export class HotConnector {
85
84
  this.settings.metadata = options?.walletConnect?.metadata ?? undefined;
86
85
  Object.values(options?.chains ?? {}).forEach((chain) => chains.register(chain));
87
86
 
88
- this.telemetry = new Telemetry(this);
89
87
  this.hotBridge = createHotBridge();
90
88
  this.exchange = new Exchange(this);
91
89
  this.activity = new Activity(this);
92
90
 
93
91
  const connectors: OmniConnector[] = [];
94
- const configConnectors = options?.connectors || defaultConnectors;
95
- const tasks = configConnectors.map(async (initConnector, index) => {
92
+ const tasks = options?.connectors?.map(async (initConnector, index) => {
96
93
  const connector = await initConnector(this);
97
94
  connector.onConnect((payload) => this.events.emit("connect", payload));
98
95
  connector.onDisconnect((payload) => this.events.emit("disconnect", payload));
@@ -299,16 +296,36 @@ export class HotConnector {
299
296
  });
300
297
  }
301
298
 
302
- intentsBuilder(wallet?: OmniWallet) {
303
- return new Intents(this).attachWallet(wallet);
299
+ async requestToken(token: OmniToken, amount: bigint | number): Promise<{ wallet: OmniWallet; token: Token; amount: bigint }> {
300
+ if (!token) throw new Error("Token not found");
301
+
302
+ const tokensList = await tokens.getTokens();
303
+ const ftToken = tokensList.find((t) => t.address === token)!;
304
+ const amountInt = typeof amount === "number" ? ftToken.int(amount) : amount;
305
+ const [existed] = this.walletsTokens.filter((t) => t.token.id === ftToken.id);
306
+
307
+ if (existed?.balance >= amountInt) return { token: ftToken, wallet: existed.wallet, amount: amountInt };
308
+
309
+ const needed = amountInt - (existed?.balance ?? 0n);
310
+ const result = await openPayment(this, ftToken, needed, Recipient.fromWallet(existed?.wallet));
311
+
312
+ const recipientWallet = this.wallets.find((w) => w.address === result.recipient.address);
313
+ if (!recipientWallet) throw new Error("Recipient not found");
314
+ const exist = await this.fetchToken(ftToken, recipientWallet);
315
+
316
+ return {
317
+ token: result.to,
318
+ wallet: recipientWallet,
319
+ amount: formatter.bigIntMin(exist, amountInt),
320
+ };
304
321
  }
305
322
 
306
- onConnect(handler: (payload: { wallet: OmniWallet; connector: OmniConnector }) => void) {
323
+ onConnect(handler: (payload: { wallet: OmniWallet }) => void) {
307
324
  this.events.on("connect", handler);
308
325
  return () => this.events.off("connect", handler);
309
326
  }
310
327
 
311
- onDisconnect(handler: (payload: { wallet: OmniWallet; connector: OmniConnector }) => void) {
328
+ onDisconnect(handler: (payload: { wallet: OmniWallet }) => void) {
312
329
  this.events.on("disconnect", handler);
313
330
  return () => this.events.off("disconnect", handler);
314
331
  }
@@ -369,14 +386,4 @@ export class HotConnector {
369
386
  if (!connector) throw new Error("Connector not found");
370
387
  return openWalletPicker(connector);
371
388
  }
372
-
373
- async disconnect(wallet: WalletType | OmniWallet) {
374
- const connector = this.connectors.find((t) => {
375
- if (wallet instanceof OmniWallet) return t.wallets.includes(wallet);
376
- return t.walletTypes.includes(wallet);
377
- });
378
-
379
- if (!connector) throw new Error("Connector not found");
380
- await connector.disconnect();
381
- }
382
389
  }
@@ -19,7 +19,6 @@ export interface OmniConnectorOption {
19
19
  icon: string;
20
20
  id: string;
21
21
  download?: string;
22
- deeplink?: string;
23
22
  type: "extension" | "external";
24
23
  }
25
24
 
@@ -31,8 +30,8 @@ export abstract class OmniConnector<T extends OmniWallet = OmniWallet, O = {}> {
31
30
 
32
31
  private storage = new LocalStorage();
33
32
  protected events = new EventEmitter<{
34
- connect: { wallet: T; connector: OmniConnector<T, O> };
35
- disconnect: { wallet: T; connector: OmniConnector<T, O> };
33
+ connect: { wallet: T };
34
+ disconnect: { wallet: T };
36
35
  }>();
37
36
 
38
37
  protected wc: Promise<UniversalProvider> | null = null;
@@ -102,14 +101,14 @@ export abstract class OmniConnector<T extends OmniWallet = OmniWallet, O = {}> {
102
101
 
103
102
  protected setWallet(wallet: T) {
104
103
  runInAction(() => this.wallets.push(wallet));
105
- this.events.emit("connect", { wallet, connector: this });
104
+ this.events.emit("connect", { wallet });
106
105
  return wallet;
107
106
  }
108
107
 
109
108
  protected removeWallet() {
110
109
  runInAction(() => {
111
110
  const wallet = this.wallets.pop();
112
- if (wallet) this.events.emit("disconnect", { wallet, connector: this });
111
+ if (wallet) this.events.emit("disconnect", { wallet });
113
112
  });
114
113
  }
115
114
 
@@ -117,7 +116,7 @@ export abstract class OmniConnector<T extends OmniWallet = OmniWallet, O = {}> {
117
116
  runInAction(() => {
118
117
  const wallets = this.wallets;
119
118
  this.wallets = [];
120
- wallets.forEach((wallet) => this.events.emit("disconnect", { wallet, connector: this }));
119
+ wallets.forEach((wallet) => this.events.emit("disconnect", { wallet }));
121
120
  });
122
121
  }
123
122
 
@@ -131,7 +130,7 @@ export abstract class OmniConnector<T extends OmniWallet = OmniWallet, O = {}> {
131
130
 
132
131
  async getStorage(): Promise<{ type?: string; id?: string; address?: string; publicKey?: string }> {
133
132
  const data = await this.storage.get(`wibe3:${this.id}`);
134
- if (!data) return {};
133
+ if (!data) throw new Error("No storage found");
135
134
  return JSON.parse(data);
136
135
  }
137
136
 
@@ -139,19 +138,19 @@ export abstract class OmniConnector<T extends OmniWallet = OmniWallet, O = {}> {
139
138
  this.events.removeAllListeners();
140
139
  }
141
140
 
142
- onConnect(handler: (payload: { wallet: T; connector: OmniConnector<T, O> }) => void) {
141
+ onConnect(handler: (payload: { wallet: T }) => void) {
143
142
  this.events.on("connect", handler);
144
143
  return () => this.events.off("connect", handler);
145
144
  }
146
145
 
147
- onDisconnect(handler: (payload: { wallet: T; connector: OmniConnector<T, O> }) => void) {
146
+ onDisconnect(handler: (payload: { wallet: T }) => void) {
148
147
  this.events.on("disconnect", handler);
149
148
  return () => this.events.off("disconnect", handler);
150
149
  }
151
150
 
152
151
  async disconnect() {
153
152
  this.disconnectWalletConnect();
154
- this.removeAllWallets();
155
153
  this.removeStorage();
154
+ this.removeWallet();
156
155
  }
157
156
  }
package/src/OmniWallet.ts CHANGED
@@ -1,7 +1,9 @@
1
+ import { sha256 } from "@noble/hashes/sha2.js";
1
2
  import { hex } from "@scure/base";
2
3
 
3
4
  import { openAuthPopup } from "./ui/connect/AuthPopup";
4
- import { WalletType } from "./core/chains";
5
+ import { OmniToken, WalletType } from "./core/chains";
6
+ import { OmniConnector } from "./OmniConnector";
5
7
  import { Intents } from "./core/Intents";
6
8
  import { ReviewFee } from "./core/bridge";
7
9
  import { Token } from "./core/token";
@@ -9,44 +11,38 @@ import { Commitment } from "./core";
9
11
  import { api } from "./core/api";
10
12
 
11
13
  export abstract class OmniWallet {
14
+ constructor(readonly connector: OmniConnector) {}
15
+
12
16
  abstract address: string;
13
17
  abstract publicKey?: string;
14
18
  abstract omniAddress: string;
15
19
  abstract type: WalletType;
16
- abstract icon: string;
17
20
 
18
- async depositNfts(nftIds: string[], receiver: string) {
19
- // TODO
21
+ async disconnect() {
22
+ if (!this.connector) throw new Error("Connector not implemented");
23
+ await this.connector.disconnect();
20
24
  }
21
25
 
22
- async withdrawNfts(nftIds: string[], receiver: string) {
23
- // TODO
24
- }
26
+ abstract transferFee(token: Token, receiver: string, amount: bigint): Promise<ReviewFee>;
27
+ abstract transfer(args: { token: Token; receiver: string; amount: bigint; comment?: string; gasFee?: ReviewFee }): Promise<string>;
28
+ abstract signIntents(intents: Record<string, any>[], options?: { nonce?: Uint8Array; deadline?: number }): Promise<Commitment>;
25
29
 
26
- async getDepositNftsFee(nfts: string[]) {
27
- return new ReviewFee({ chain: -4 });
28
- }
30
+ abstract fetchBalance(chain: number, address: string): Promise<bigint>;
31
+ abstract fetchBalances(chain?: number, whitelist?: string[]): Promise<Record<string, bigint>>;
29
32
 
30
- async transferNft(nftId: string, receiver: string) {
31
- // TODO
33
+ async executeIntents(intents: Record<string, any>[], hashes: string[] = []) {
34
+ const signed = await this.signIntents(intents);
35
+ return await Intents.publishSignedIntents([signed], hashes);
32
36
  }
33
37
 
34
- async getTranferNftFee(nftId: string, receiver: string) {
35
- return new ReviewFee({ chain: -4 });
38
+ get icon() {
39
+ return this.connector?.icon;
36
40
  }
37
41
 
38
- async getNfts(onLoad: (nfts: string[]) => void) {
39
- // TODO
42
+ get intents() {
43
+ return new Intents(this.connector.wibe3).attachWallet(this);
40
44
  }
41
45
 
42
- abstract transferFee(token: Token, receiver: string, amount: bigint): Promise<ReviewFee>;
43
- abstract transfer(args: { token: Token; receiver: string; amount: bigint; comment?: string; gasFee?: ReviewFee }): Promise<string>;
44
-
45
- abstract fetchBalance(chain: number, address: string): Promise<bigint>;
46
- abstract fetchBalances(chain?: number, whitelist?: string[]): Promise<Record<string, bigint>>;
47
-
48
- abstract signIntents(intents: Record<string, any>[], options?: { nonce?: Uint8Array; deadline?: number }): Promise<Commitment>;
49
-
50
46
  async auth(intents?: Record<string, any>[]): Promise<string> {
51
47
  return openAuthPopup(this, async () => {
52
48
  const seed = hex.encode(new Uint8Array(window.crypto.getRandomValues(new Uint8Array(32))));
@@ -57,6 +53,11 @@ export abstract class OmniWallet {
57
53
  });
58
54
  }
59
55
 
56
+ async pay({ token, amount, recipient, paymentId }: { token: OmniToken; amount: number; recipient: string; paymentId: string }) {
57
+ const nonce = new Uint8Array(sha256(new TextEncoder().encode(paymentId))).slice(0, 32);
58
+ return this.intents.attachNonce(nonce).transfer({ recipient, token, amount }).execute();
59
+ }
60
+
60
61
  async waitUntilBalance(need: Record<string, bigint>, receiver: string, attempts = 0) {
61
62
  if (attempts > 120) throw "Balance is not enough";
62
63
  const assets = Object.keys(need) as string[];