@hot-labs/kit 1.1.2 → 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 (322) hide show
  1. package/README.md +9 -2
  2. package/package.json +4 -8
  3. package/src/HotConnector.ts +31 -21
  4. package/src/OmniConnector.ts +9 -10
  5. package/src/OmniWallet.ts +25 -24
  6. package/src/core/Intents.ts +151 -222
  7. package/src/core/api.ts +4 -37
  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} +11 -4
  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/index.ts +0 -2
  20. package/src/near/connector.ts +2 -2
  21. package/src/near/wallet.ts +9 -4
  22. package/src/solana/connector.ts +8 -9
  23. package/src/solana/injected/solana-wallet.ts +6 -6
  24. package/src/solana/{WalletStandard.ts → protocol.ts} +4 -2
  25. package/src/solana/wallet.ts +20 -11
  26. package/src/stellar/connector.ts +6 -1
  27. package/src/stellar/wallet.ts +17 -17
  28. package/src/ton/connector.ts +5 -1
  29. package/src/ton/wallet.ts +3 -3
  30. package/src/ui/Popup.tsx +4 -12
  31. package/src/ui/connect/AuthPopup.tsx +1 -2
  32. package/src/ui/connect/ConnectWallet.tsx +6 -12
  33. package/src/ui/icons/arrow-right.tsx +2 -2
  34. package/src/ui/icons/close.tsx +1 -1
  35. package/src/ui/icons/exchange.tsx +4 -4
  36. package/src/ui/icons/logout.tsx +6 -6
  37. package/src/ui/icons/pending.tsx +4 -2
  38. package/src/ui/icons/qr.tsx +2 -1
  39. package/src/ui/icons/search.tsx +4 -4
  40. package/src/ui/icons/switch.tsx +4 -4
  41. package/src/ui/icons/wallet.tsx +4 -2
  42. package/src/ui/payment/Bridge.tsx +6 -25
  43. package/src/ui/payment/Payment.tsx +46 -241
  44. package/src/ui/payment/Profile.tsx +8 -10
  45. package/src/ui/payment/SelectToken.tsx +1 -1
  46. package/src/ui/payment/TokenCard.tsx +18 -22
  47. package/src/ui/router.tsx +16 -56
  48. package/src/ui/styles.ts +0 -2
  49. package/build/HotConnector.d.ts +0 -103
  50. package/build/HotConnector.js +0 -300
  51. package/build/HotConnector.js.map +0 -1
  52. package/build/OmniConnector.d.ts +0 -90
  53. package/build/OmniConnector.js +0 -121
  54. package/build/OmniConnector.js.map +0 -1
  55. package/build/OmniWallet.d.ts +0 -35
  56. package/build/OmniWallet.js +0 -56
  57. package/build/OmniWallet.js.map +0 -1
  58. package/build/activity.d.ts +0 -18
  59. package/build/activity.js +0 -87
  60. package/build/activity.js.map +0 -1
  61. package/build/core/Intents.d.ts +0 -100
  62. package/build/core/Intents.js +0 -472
  63. package/build/core/Intents.js.map +0 -1
  64. package/build/core/api.d.ts +0 -48
  65. package/build/core/api.js +0 -93
  66. package/build/core/api.js.map +0 -1
  67. package/build/core/bridge.d.ts +0 -3
  68. package/build/core/bridge.js +0 -36
  69. package/build/core/bridge.js.map +0 -1
  70. package/build/core/chains.d.ts +0 -115
  71. package/build/core/chains.js +0 -381
  72. package/build/core/chains.js.map +0 -1
  73. package/build/core/defaultTokens.d.ts +0 -17
  74. package/build/core/defaultTokens.js +0 -1079
  75. package/build/core/defaultTokens.js.map +0 -1
  76. package/build/core/events.d.ts +0 -42
  77. package/build/core/events.js +0 -64
  78. package/build/core/events.js.map +0 -1
  79. package/build/core/index.d.ts +0 -10
  80. package/build/core/index.js +0 -11
  81. package/build/core/index.js.map +0 -1
  82. package/build/core/recipient.d.ts +0 -10
  83. package/build/core/recipient.js +0 -40
  84. package/build/core/recipient.js.map +0 -1
  85. package/build/core/token.d.ts +0 -36
  86. package/build/core/token.js +0 -103
  87. package/build/core/token.js.map +0 -1
  88. package/build/core/tokens.d.ts +0 -14
  89. package/build/core/tokens.js +0 -59
  90. package/build/core/tokens.js.map +0 -1
  91. package/build/core/types.d.ts +0 -60
  92. package/build/core/types.js +0 -2
  93. package/build/core/types.js.map +0 -1
  94. package/build/core/utils.d.ts +0 -25
  95. package/build/core/utils.js +0 -170
  96. package/build/core/utils.js.map +0 -1
  97. package/build/cosmos/connector.d.ts +0 -36
  98. package/build/cosmos/connector.js +0 -211
  99. package/build/cosmos/connector.js.map +0 -1
  100. package/build/cosmos/helpers.d.ts +0 -2
  101. package/build/cosmos/helpers.js +0 -29
  102. package/build/cosmos/helpers.js.map +0 -1
  103. package/build/cosmos/index.d.ts +0 -6
  104. package/build/cosmos/index.js +0 -5
  105. package/build/cosmos/index.js.map +0 -1
  106. package/build/cosmos/wallet.d.ts +0 -26
  107. package/build/cosmos/wallet.js +0 -51
  108. package/build/cosmos/wallet.js.map +0 -1
  109. package/build/defaults.d.ts +0 -1
  110. package/build/defaults.js +0 -7
  111. package/build/defaults.js.map +0 -1
  112. package/build/evm/abi.d.ts +0 -17
  113. package/build/evm/abi.js +0 -38
  114. package/build/evm/abi.js.map +0 -1
  115. package/build/evm/connector.d.ts +0 -29
  116. package/build/evm/connector.js +0 -118
  117. package/build/evm/connector.js.map +0 -1
  118. package/build/evm/index.d.ts +0 -6
  119. package/build/evm/index.js +0 -5
  120. package/build/evm/index.js.map +0 -1
  121. package/build/evm/injected.d.ts +0 -1
  122. package/build/evm/injected.js +0 -33
  123. package/build/evm/injected.js.map +0 -1
  124. package/build/evm/wallet.d.ts +0 -42
  125. package/build/evm/wallet.js +0 -130
  126. package/build/evm/wallet.js.map +0 -1
  127. package/build/exchange.d.ts +0 -68
  128. package/build/exchange.js +0 -384
  129. package/build/exchange.js.map +0 -1
  130. package/build/hot-wallet/google.d.ts +0 -25
  131. package/build/hot-wallet/google.js +0 -117
  132. package/build/hot-wallet/google.js.map +0 -1
  133. package/build/hot-wallet/iframe.d.ts +0 -36
  134. package/build/hot-wallet/iframe.js +0 -140
  135. package/build/hot-wallet/iframe.js.map +0 -1
  136. package/build/hot-wallet/index.d.ts +0 -5
  137. package/build/hot-wallet/index.js +0 -4
  138. package/build/hot-wallet/index.js.map +0 -1
  139. package/build/hot-wallet/proxy.d.ts +0 -8
  140. package/build/hot-wallet/proxy.js +0 -45
  141. package/build/hot-wallet/proxy.js.map +0 -1
  142. package/build/index.d.ts +0 -6
  143. package/build/index.js +0 -7
  144. package/build/index.js.map +0 -1
  145. package/build/near/connector.d.ts +0 -18
  146. package/build/near/connector.js +0 -58
  147. package/build/near/connector.js.map +0 -1
  148. package/build/near/index.d.ts +0 -7
  149. package/build/near/index.js +0 -5
  150. package/build/near/index.js.map +0 -1
  151. package/build/near/rpc.d.ts +0 -23
  152. package/build/near/rpc.js +0 -161
  153. package/build/near/rpc.js.map +0 -1
  154. package/build/near/wallet.d.ts +0 -53
  155. package/build/near/wallet.js +0 -190
  156. package/build/near/wallet.js.map +0 -1
  157. package/build/solana/WalletStandard.d.ts +0 -25
  158. package/build/solana/WalletStandard.js +0 -56
  159. package/build/solana/WalletStandard.js.map +0 -1
  160. package/build/solana/connector.d.ts +0 -30
  161. package/build/solana/connector.js +0 -139
  162. package/build/solana/connector.js.map +0 -1
  163. package/build/solana/index.d.ts +0 -6
  164. package/build/solana/index.js +0 -5
  165. package/build/solana/index.js.map +0 -1
  166. package/build/solana/injected/account.d.ts +0 -11
  167. package/build/solana/injected/account.js +0 -41
  168. package/build/solana/injected/account.js.map +0 -1
  169. package/build/solana/injected/index.d.ts +0 -1
  170. package/build/solana/injected/index.js +0 -82
  171. package/build/solana/injected/index.js.map +0 -1
  172. package/build/solana/injected/register.d.ts +0 -2
  173. package/build/solana/injected/register.js +0 -41
  174. package/build/solana/injected/register.js.map +0 -1
  175. package/build/solana/injected/solana-wallet.d.ts +0 -34
  176. package/build/solana/injected/solana-wallet.js +0 -223
  177. package/build/solana/injected/solana-wallet.js.map +0 -1
  178. package/build/solana/injected/utils.d.ts +0 -32
  179. package/build/solana/injected/utils.js +0 -36
  180. package/build/solana/injected/utils.js.map +0 -1
  181. package/build/solana/wallet.d.ts +0 -40
  182. package/build/solana/wallet.js +0 -181
  183. package/build/solana/wallet.js.map +0 -1
  184. package/build/solana/walletStandartList.d.ts +0 -102
  185. package/build/solana/walletStandartList.js +0 -150
  186. package/build/solana/walletStandartList.js.map +0 -1
  187. package/build/stellar/connector.d.ts +0 -29
  188. package/build/stellar/connector.js +0 -64
  189. package/build/stellar/connector.js.map +0 -1
  190. package/build/stellar/freigher.d.ts +0 -46
  191. package/build/stellar/freigher.js +0 -110
  192. package/build/stellar/freigher.js.map +0 -1
  193. package/build/stellar/hotWallet.d.ts +0 -33
  194. package/build/stellar/hotWallet.js +0 -28
  195. package/build/stellar/hotWallet.js.map +0 -1
  196. package/build/stellar/index.d.ts +0 -6
  197. package/build/stellar/index.js +0 -5
  198. package/build/stellar/index.js.map +0 -1
  199. package/build/stellar/wallet.d.ts +0 -67
  200. package/build/stellar/wallet.js +0 -212
  201. package/build/stellar/wallet.js.map +0 -1
  202. package/build/storage.d.ts +0 -10
  203. package/build/storage.js +0 -12
  204. package/build/storage.js.map +0 -1
  205. package/build/ton/connector.d.ts +0 -24
  206. package/build/ton/connector.js +0 -111
  207. package/build/ton/connector.js.map +0 -1
  208. package/build/ton/index.d.ts +0 -7
  209. package/build/ton/index.js +0 -5
  210. package/build/ton/index.js.map +0 -1
  211. package/build/ton/injected.d.ts +0 -1
  212. package/build/ton/injected.js +0 -49
  213. package/build/ton/injected.js.map +0 -1
  214. package/build/ton/utils.d.ts +0 -45
  215. package/build/ton/utils.js +0 -63
  216. package/build/ton/utils.js.map +0 -1
  217. package/build/ton/wallet.d.ts +0 -54
  218. package/build/ton/wallet.js +0 -138
  219. package/build/ton/wallet.js.map +0 -1
  220. package/build/tron/connector.d.ts +0 -51
  221. package/build/tron/connector.js +0 -65
  222. package/build/tron/connector.js.map +0 -1
  223. package/build/tron/index.d.ts +0 -6
  224. package/build/tron/index.js +0 -5
  225. package/build/tron/index.js.map +0 -1
  226. package/build/tron/wallet.d.ts +0 -52
  227. package/build/tron/wallet.js +0 -122
  228. package/build/tron/wallet.js.map +0 -1
  229. package/build/ui/Popup.d.ts +0 -12
  230. package/build/ui/Popup.js +0 -43
  231. package/build/ui/Popup.js.map +0 -1
  232. package/build/ui/Toast.d.ts +0 -4
  233. package/build/ui/Toast.js +0 -33
  234. package/build/ui/Toast.js.map +0 -1
  235. package/build/ui/connect/AuthPopup.d.ts +0 -2
  236. package/build/ui/connect/AuthPopup.js +0 -48
  237. package/build/ui/connect/AuthPopup.js.map +0 -1
  238. package/build/ui/connect/ConnectWallet.d.ts +0 -14
  239. package/build/ui/connect/ConnectWallet.js +0 -22
  240. package/build/ui/connect/ConnectWallet.js.map +0 -1
  241. package/build/ui/connect/LogoutPopup.d.ts +0 -10
  242. package/build/ui/connect/LogoutPopup.js +0 -8
  243. package/build/ui/connect/LogoutPopup.js.map +0 -1
  244. package/build/ui/connect/PrimaryWallet.d.ts +0 -6
  245. package/build/ui/connect/PrimaryWallet.js +0 -18
  246. package/build/ui/connect/PrimaryWallet.js.map +0 -1
  247. package/build/ui/connect/WCPopup.d.ts +0 -13
  248. package/build/ui/connect/WCPopup.js +0 -81
  249. package/build/ui/connect/WCPopup.js.map +0 -1
  250. package/build/ui/connect/WCRequest.d.ts +0 -9
  251. package/build/ui/connect/WCRequest.js +0 -13
  252. package/build/ui/connect/WCRequest.js.map +0 -1
  253. package/build/ui/connect/WalletPicker.d.ts +0 -11
  254. package/build/ui/connect/WalletPicker.js +0 -48
  255. package/build/ui/connect/WalletPicker.js.map +0 -1
  256. package/build/ui/icons/arrow-right.d.ts +0 -1
  257. package/build/ui/icons/arrow-right.js +0 -5
  258. package/build/ui/icons/arrow-right.js.map +0 -1
  259. package/build/ui/icons/close.d.ts +0 -1
  260. package/build/ui/icons/close.js +0 -5
  261. package/build/ui/icons/close.js.map +0 -1
  262. package/build/ui/icons/exchange.d.ts +0 -6
  263. package/build/ui/icons/exchange.js +0 -6
  264. package/build/ui/icons/exchange.js.map +0 -1
  265. package/build/ui/icons/logout.d.ts +0 -1
  266. package/build/ui/icons/logout.js +0 -3
  267. package/build/ui/icons/logout.js.map +0 -1
  268. package/build/ui/icons/pending.d.ts +0 -1
  269. package/build/ui/icons/pending.js +0 -5
  270. package/build/ui/icons/pending.js.map +0 -1
  271. package/build/ui/icons/qr.d.ts +0 -1
  272. package/build/ui/icons/qr.js +0 -5
  273. package/build/ui/icons/qr.js.map +0 -1
  274. package/build/ui/icons/search.d.ts +0 -1
  275. package/build/ui/icons/search.js +0 -5
  276. package/build/ui/icons/search.js.map +0 -1
  277. package/build/ui/icons/switch.d.ts +0 -1
  278. package/build/ui/icons/switch.js +0 -5
  279. package/build/ui/icons/switch.js.map +0 -1
  280. package/build/ui/icons/wallet.d.ts +0 -1
  281. package/build/ui/icons/wallet.js +0 -5
  282. package/build/ui/icons/wallet.js.map +0 -1
  283. package/build/ui/payment/Bridge.d.ts +0 -29
  284. package/build/ui/payment/Bridge.js +0 -373
  285. package/build/ui/payment/Bridge.js.map +0 -1
  286. package/build/ui/payment/DepositQR.d.ts +0 -9
  287. package/build/ui/payment/DepositQR.js +0 -56
  288. package/build/ui/payment/DepositQR.js.map +0 -1
  289. package/build/ui/payment/Payment.d.ts +0 -23
  290. package/build/ui/payment/Payment.js +0 -136
  291. package/build/ui/payment/Payment.js.map +0 -1
  292. package/build/ui/payment/Profile.d.ts +0 -8
  293. package/build/ui/payment/Profile.js +0 -110
  294. package/build/ui/payment/Profile.js.map +0 -1
  295. package/build/ui/payment/SelectRecipient.d.ts +0 -14
  296. package/build/ui/payment/SelectRecipient.js +0 -68
  297. package/build/ui/payment/SelectRecipient.js.map +0 -1
  298. package/build/ui/payment/SelectSender.d.ts +0 -13
  299. package/build/ui/payment/SelectSender.js +0 -23
  300. package/build/ui/payment/SelectSender.js.map +0 -1
  301. package/build/ui/payment/SelectToken.d.ts +0 -13
  302. package/build/ui/payment/SelectToken.js +0 -92
  303. package/build/ui/payment/SelectToken.js.map +0 -1
  304. package/build/ui/payment/Stepper.d.ts +0 -13
  305. package/build/ui/payment/Stepper.js +0 -22
  306. package/build/ui/payment/Stepper.js.map +0 -1
  307. package/build/ui/payment/TokenCard.d.ts +0 -25
  308. package/build/ui/payment/TokenCard.js +0 -63
  309. package/build/ui/payment/TokenCard.js.map +0 -1
  310. package/build/ui/router.d.ts +0 -51
  311. package/build/ui/router.js +0 -68
  312. package/build/ui/router.js.map +0 -1
  313. package/build/ui/styles.d.ts +0 -13
  314. package/build/ui/styles.js +0 -290
  315. package/build/ui/styles.js.map +0 -1
  316. package/src/tron/connector.ts +0 -89
  317. package/src/tron/index.ts +0 -7
  318. package/src/tron/wallet.ts +0 -146
  319. package/src/ui/Toast.tsx +0 -45
  320. package/src/ui/connect/PrimaryWallet.tsx +0 -65
  321. package/src/ui/payment/Stepper.tsx +0 -50
  322. /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.2",
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,11 +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 { rpc } from "./near/rpc";
11
+ import { rpc } from "./core/nearRpc";
12
12
  import { Token } from "./core/token";
13
13
  import { api } from "./core/api";
14
14
 
15
- import { defaultConnectors } from "./defaults";
16
15
  import type CosmosWallet from "./cosmos/wallet";
17
16
  import type NearWallet from "./near/wallet";
18
17
  import type EvmWallet from "./evm/wallet";
@@ -20,7 +19,7 @@ import type SolanaWallet from "./solana/wallet";
20
19
  import type StellarWallet from "./stellar/wallet";
21
20
  import type TonWallet from "./ton/wallet";
22
21
 
23
- import { openBridge, openConnector, openProfile, openWalletPicker } from "./ui/router";
22
+ import { openBridge, openConnector, openPayment, openProfile, openWalletPicker } from "./ui/router";
24
23
  import { ConnectorType, OmniConnector } from "./OmniConnector";
25
24
  import { OmniWallet } from "./OmniWallet";
26
25
  import { Exchange } from "./exchange";
@@ -49,9 +48,11 @@ export class HotConnector {
49
48
  public hotBridge: HotBridge;
50
49
  public exchange: Exchange;
51
50
 
51
+ readonly version = "1.0.58";
52
+
52
53
  private events = new EventEmitter<{
53
- connect: { wallet: OmniWallet; connector: OmniConnector };
54
- disconnect: { wallet: OmniWallet; connector: OmniConnector };
54
+ connect: { wallet: OmniWallet };
55
+ disconnect: { wallet: OmniWallet };
55
56
  tokensUpdate: { tokens: Token[] };
56
57
  }>();
57
58
 
@@ -88,8 +89,7 @@ export class HotConnector {
88
89
  this.activity = new Activity(this);
89
90
 
90
91
  const connectors: OmniConnector[] = [];
91
- const configConnectors = options?.connectors || defaultConnectors;
92
- const tasks = configConnectors.map(async (initConnector, index) => {
92
+ const tasks = options?.connectors?.map(async (initConnector, index) => {
93
93
  const connector = await initConnector(this);
94
94
  connector.onConnect((payload) => this.events.emit("connect", payload));
95
95
  connector.onDisconnect((payload) => this.events.emit("disconnect", payload));
@@ -296,16 +296,36 @@ export class HotConnector {
296
296
  });
297
297
  }
298
298
 
299
- intentsBuilder(wallet?: OmniWallet) {
300
- 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
+ };
301
321
  }
302
322
 
303
- onConnect(handler: (payload: { wallet: OmniWallet; connector: OmniConnector }) => void) {
323
+ onConnect(handler: (payload: { wallet: OmniWallet }) => void) {
304
324
  this.events.on("connect", handler);
305
325
  return () => this.events.off("connect", handler);
306
326
  }
307
327
 
308
- onDisconnect(handler: (payload: { wallet: OmniWallet; connector: OmniConnector }) => void) {
328
+ onDisconnect(handler: (payload: { wallet: OmniWallet }) => void) {
309
329
  this.events.on("disconnect", handler);
310
330
  return () => this.events.off("disconnect", handler);
311
331
  }
@@ -366,14 +386,4 @@ export class HotConnector {
366
386
  if (!connector) throw new Error("Connector not found");
367
387
  return openWalletPicker(connector);
368
388
  }
369
-
370
- async disconnect(wallet: WalletType | OmniWallet) {
371
- const connector = this.connectors.find((t) => {
372
- if (wallet instanceof OmniWallet) return t.wallets.includes(wallet);
373
- return t.walletTypes.includes(wallet);
374
- });
375
-
376
- if (!connector) throw new Error("Connector not found");
377
- await connector.disconnect();
378
- }
379
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[];