@hot-labs/kit 1.0.33

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 (300) hide show
  1. package/.eslintrc.cjs +11 -0
  2. package/.github/workflows/deploy-example.yml +55 -0
  3. package/.github/workflows/release.yml +74 -0
  4. package/.prettierrc +4 -0
  5. package/.prototools +2 -0
  6. package/.vscode/settings.json +3 -0
  7. package/CHANGELOG.md +1 -0
  8. package/README.md +67 -0
  9. package/build/GoogleConnector.d.ts +20 -0
  10. package/build/GoogleConnector.js +76 -0
  11. package/build/GoogleConnector.js.map +1 -0
  12. package/build/HotConnector.d.ts +91 -0
  13. package/build/HotConnector.js +285 -0
  14. package/build/HotConnector.js.map +1 -0
  15. package/build/OmniConnector.d.ts +95 -0
  16. package/build/OmniConnector.js +123 -0
  17. package/build/OmniConnector.js.map +1 -0
  18. package/build/OmniWallet.d.ts +57 -0
  19. package/build/OmniWallet.js +56 -0
  20. package/build/OmniWallet.js.map +1 -0
  21. package/build/cosmos/connector.d.ts +53 -0
  22. package/build/cosmos/connector.js +207 -0
  23. package/build/cosmos/connector.js.map +1 -0
  24. package/build/cosmos/wallet.d.ts +28 -0
  25. package/build/cosmos/wallet.js +59 -0
  26. package/build/cosmos/wallet.js.map +1 -0
  27. package/build/events.d.ts +42 -0
  28. package/build/events.js +64 -0
  29. package/build/events.js.map +1 -0
  30. package/build/evm/abi.d.ts +17 -0
  31. package/build/evm/abi.js +38 -0
  32. package/build/evm/abi.js.map +1 -0
  33. package/build/evm/connector.d.ts +35 -0
  34. package/build/evm/connector.js +124 -0
  35. package/build/evm/connector.js.map +1 -0
  36. package/build/evm/wallet.d.ts +47 -0
  37. package/build/evm/wallet.js +136 -0
  38. package/build/evm/wallet.js.map +1 -0
  39. package/build/exchange.d.ts +63 -0
  40. package/build/exchange.js +384 -0
  41. package/build/exchange.js.map +1 -0
  42. package/build/hot-wallet/evm.d.ts +1 -0
  43. package/build/hot-wallet/evm.js +33 -0
  44. package/build/hot-wallet/evm.js.map +1 -0
  45. package/build/hot-wallet/hot.d.ts +3 -0
  46. package/build/hot-wallet/hot.js +40 -0
  47. package/build/hot-wallet/hot.js.map +1 -0
  48. package/build/hot-wallet/index.d.ts +4 -0
  49. package/build/hot-wallet/index.js +5 -0
  50. package/build/hot-wallet/index.js.map +1 -0
  51. package/build/hot-wallet/solana/account.d.ts +11 -0
  52. package/build/hot-wallet/solana/account.js +42 -0
  53. package/build/hot-wallet/solana/account.js.map +1 -0
  54. package/build/hot-wallet/solana/index.d.ts +1 -0
  55. package/build/hot-wallet/solana/index.js +85 -0
  56. package/build/hot-wallet/solana/index.js.map +1 -0
  57. package/build/hot-wallet/solana/register.d.ts +2 -0
  58. package/build/hot-wallet/solana/register.js +41 -0
  59. package/build/hot-wallet/solana/register.js.map +1 -0
  60. package/build/hot-wallet/solana/solana-wallet.d.ts +34 -0
  61. package/build/hot-wallet/solana/solana-wallet.js +223 -0
  62. package/build/hot-wallet/solana/solana-wallet.js.map +1 -0
  63. package/build/hot-wallet/solana/utils.d.ts +32 -0
  64. package/build/hot-wallet/solana/utils.js +36 -0
  65. package/build/hot-wallet/solana/utils.js.map +1 -0
  66. package/build/hot-wallet/stellar.d.ts +38 -0
  67. package/build/hot-wallet/stellar.js +32 -0
  68. package/build/hot-wallet/stellar.js.map +1 -0
  69. package/build/hot-wallet/ton.d.ts +1 -0
  70. package/build/hot-wallet/ton.js +49 -0
  71. package/build/hot-wallet/ton.js.map +1 -0
  72. package/build/hot-wallet/wallet.d.ts +1 -0
  73. package/build/hot-wallet/wallet.js +40 -0
  74. package/build/hot-wallet/wallet.js.map +1 -0
  75. package/build/index.d.ts +24 -0
  76. package/build/index.js +25 -0
  77. package/build/index.js.map +1 -0
  78. package/build/near/connector.d.ts +28 -0
  79. package/build/near/connector.js +56 -0
  80. package/build/near/connector.js.map +1 -0
  81. package/build/near/wallet.d.ts +62 -0
  82. package/build/near/wallet.js +233 -0
  83. package/build/near/wallet.js.map +1 -0
  84. package/build/omni/Intents.d.ts +93 -0
  85. package/build/omni/Intents.js +395 -0
  86. package/build/omni/Intents.js.map +1 -0
  87. package/build/omni/bridge.d.ts +3 -0
  88. package/build/omni/bridge.js +34 -0
  89. package/build/omni/bridge.js.map +1 -0
  90. package/build/omni/config.d.ts +99 -0
  91. package/build/omni/config.js +126 -0
  92. package/build/omni/config.js.map +1 -0
  93. package/build/omni/defaultTokens.d.ts +17 -0
  94. package/build/omni/defaultTokens.js +1079 -0
  95. package/build/omni/defaultTokens.js.map +1 -0
  96. package/build/omni/index.d.ts +8 -0
  97. package/build/omni/index.js +9 -0
  98. package/build/omni/index.js.map +1 -0
  99. package/build/omni/nearRpc.d.ts +24 -0
  100. package/build/omni/nearRpc.js +167 -0
  101. package/build/omni/nearRpc.js.map +1 -0
  102. package/build/omni/recipient.d.ts +10 -0
  103. package/build/omni/recipient.js +40 -0
  104. package/build/omni/recipient.js.map +1 -0
  105. package/build/omni/token.d.ts +36 -0
  106. package/build/omni/token.js +136 -0
  107. package/build/omni/token.js.map +1 -0
  108. package/build/omni/tokens.d.ts +14 -0
  109. package/build/omni/tokens.js +57 -0
  110. package/build/omni/tokens.js.map +1 -0
  111. package/build/omni/types.d.ts +41 -0
  112. package/build/omni/types.js +2 -0
  113. package/build/omni/types.js.map +1 -0
  114. package/build/omni/utils.d.ts +24 -0
  115. package/build/omni/utils.js +150 -0
  116. package/build/omni/utils.js.map +1 -0
  117. package/build/settings.d.ts +5 -0
  118. package/build/settings.js +6 -0
  119. package/build/settings.js.map +1 -0
  120. package/build/solana/connector.d.ts +31 -0
  121. package/build/solana/connector.js +138 -0
  122. package/build/solana/connector.js.map +1 -0
  123. package/build/solana/protocol.d.ts +25 -0
  124. package/build/solana/protocol.js +56 -0
  125. package/build/solana/protocol.js.map +1 -0
  126. package/build/solana/wallet.d.ts +47 -0
  127. package/build/solana/wallet.js +188 -0
  128. package/build/solana/wallet.js.map +1 -0
  129. package/build/solana/wallets.d.ts +102 -0
  130. package/build/solana/wallets.js +150 -0
  131. package/build/solana/wallets.js.map +1 -0
  132. package/build/stellar/connector.d.ts +25 -0
  133. package/build/stellar/connector.js +56 -0
  134. package/build/stellar/connector.js.map +1 -0
  135. package/build/stellar/wallet.d.ts +70 -0
  136. package/build/stellar/wallet.js +225 -0
  137. package/build/stellar/wallet.js.map +1 -0
  138. package/build/storage.d.ts +10 -0
  139. package/build/storage.js +12 -0
  140. package/build/storage.js.map +1 -0
  141. package/build/ton/connector.d.ts +25 -0
  142. package/build/ton/connector.js +119 -0
  143. package/build/ton/connector.js.map +1 -0
  144. package/build/ton/utils.d.ts +45 -0
  145. package/build/ton/utils.js +64 -0
  146. package/build/ton/utils.js.map +1 -0
  147. package/build/ton/wallet.d.ts +70 -0
  148. package/build/ton/wallet.js +154 -0
  149. package/build/ton/wallet.js.map +1 -0
  150. package/build/ui/Popup.d.ts +10 -0
  151. package/build/ui/Popup.js +38 -0
  152. package/build/ui/Popup.js.map +1 -0
  153. package/build/ui/connect/AuthPopup.d.ts +2 -0
  154. package/build/ui/connect/AuthPopup.js +48 -0
  155. package/build/ui/connect/AuthPopup.js.map +1 -0
  156. package/build/ui/connect/ConnectWallet.d.ts +9 -0
  157. package/build/ui/connect/ConnectWallet.js +22 -0
  158. package/build/ui/connect/ConnectWallet.js.map +1 -0
  159. package/build/ui/connect/LogoutPopup.d.ts +10 -0
  160. package/build/ui/connect/LogoutPopup.js +8 -0
  161. package/build/ui/connect/LogoutPopup.js.map +1 -0
  162. package/build/ui/connect/WCPopup.d.ts +13 -0
  163. package/build/ui/connect/WCPopup.js +81 -0
  164. package/build/ui/connect/WCPopup.js.map +1 -0
  165. package/build/ui/connect/WCRequest.d.ts +9 -0
  166. package/build/ui/connect/WCRequest.js +13 -0
  167. package/build/ui/connect/WCRequest.js.map +1 -0
  168. package/build/ui/connect/WalletPicker.d.ts +11 -0
  169. package/build/ui/connect/WalletPicker.js +48 -0
  170. package/build/ui/connect/WalletPicker.js.map +1 -0
  171. package/build/ui/icons/arrow-right.d.ts +1 -0
  172. package/build/ui/icons/arrow-right.js +5 -0
  173. package/build/ui/icons/arrow-right.js.map +1 -0
  174. package/build/ui/icons/exchange.d.ts +6 -0
  175. package/build/ui/icons/exchange.js +6 -0
  176. package/build/ui/icons/exchange.js.map +1 -0
  177. package/build/ui/icons/logout.d.ts +1 -0
  178. package/build/ui/icons/logout.js +3 -0
  179. package/build/ui/icons/logout.js.map +1 -0
  180. package/build/ui/icons/pending.d.ts +1 -0
  181. package/build/ui/icons/pending.js +5 -0
  182. package/build/ui/icons/pending.js.map +1 -0
  183. package/build/ui/icons/qr.d.ts +1 -0
  184. package/build/ui/icons/qr.js +5 -0
  185. package/build/ui/icons/qr.js.map +1 -0
  186. package/build/ui/icons/search.d.ts +1 -0
  187. package/build/ui/icons/search.js +5 -0
  188. package/build/ui/icons/search.js.map +1 -0
  189. package/build/ui/icons/switch.d.ts +1 -0
  190. package/build/ui/icons/switch.js +5 -0
  191. package/build/ui/icons/switch.js.map +1 -0
  192. package/build/ui/icons/wallet.d.ts +1 -0
  193. package/build/ui/icons/wallet.js +5 -0
  194. package/build/ui/icons/wallet.js.map +1 -0
  195. package/build/ui/payment/Bridge.d.ts +27 -0
  196. package/build/ui/payment/Bridge.js +340 -0
  197. package/build/ui/payment/Bridge.js.map +1 -0
  198. package/build/ui/payment/DepositQR.d.ts +9 -0
  199. package/build/ui/payment/DepositQR.js +56 -0
  200. package/build/ui/payment/DepositQR.js.map +1 -0
  201. package/build/ui/payment/Payment.d.ts +16 -0
  202. package/build/ui/payment/Payment.js +50 -0
  203. package/build/ui/payment/Payment.js.map +1 -0
  204. package/build/ui/payment/Profile.d.ts +7 -0
  205. package/build/ui/payment/Profile.js +88 -0
  206. package/build/ui/payment/Profile.js.map +1 -0
  207. package/build/ui/payment/SelectRecipient.d.ts +14 -0
  208. package/build/ui/payment/SelectRecipient.js +68 -0
  209. package/build/ui/payment/SelectRecipient.js.map +1 -0
  210. package/build/ui/payment/SelectSender.d.ts +13 -0
  211. package/build/ui/payment/SelectSender.js +23 -0
  212. package/build/ui/payment/SelectSender.js.map +1 -0
  213. package/build/ui/payment/SelectToken.d.ts +13 -0
  214. package/build/ui/payment/SelectToken.js +92 -0
  215. package/build/ui/payment/SelectToken.js.map +1 -0
  216. package/build/ui/payment/TokenCard.d.ts +23 -0
  217. package/build/ui/payment/TokenCard.js +50 -0
  218. package/build/ui/payment/TokenCard.js.map +1 -0
  219. package/build/ui/router.d.ts +37 -0
  220. package/build/ui/router.js +56 -0
  221. package/build/ui/router.js.map +1 -0
  222. package/build/ui/styles.d.ts +11 -0
  223. package/build/ui/styles.js +273 -0
  224. package/build/ui/styles.js.map +1 -0
  225. package/package.json +60 -0
  226. package/skill.md +989 -0
  227. package/src/GoogleConnector.ts +102 -0
  228. package/src/HotConnector.ts +344 -0
  229. package/src/OmniConnector.ts +161 -0
  230. package/src/OmniWallet.ts +94 -0
  231. package/src/cosmos/connector.ts +242 -0
  232. package/src/cosmos/wallet.ts +77 -0
  233. package/src/events.ts +66 -0
  234. package/src/evm/abi.ts +39 -0
  235. package/src/evm/connector.ts +139 -0
  236. package/src/evm/wallet.ts +156 -0
  237. package/src/exchange.ts +426 -0
  238. package/src/hot-wallet/evm.ts +38 -0
  239. package/src/hot-wallet/hot.ts +39 -0
  240. package/src/hot-wallet/index.ts +4 -0
  241. package/src/hot-wallet/solana/account.ts +52 -0
  242. package/src/hot-wallet/solana/index.ts +98 -0
  243. package/src/hot-wallet/solana/register.ts +48 -0
  244. package/src/hot-wallet/solana/solana-wallet.ts +280 -0
  245. package/src/hot-wallet/solana/utils.ts +56 -0
  246. package/src/hot-wallet/stellar.ts +39 -0
  247. package/src/hot-wallet/ton.ts +56 -0
  248. package/src/hot-wallet/wallet.ts +44 -0
  249. package/src/index.ts +30 -0
  250. package/src/near/connector.ts +71 -0
  251. package/src/near/wallet.ts +255 -0
  252. package/src/omni/Intents.ts +454 -0
  253. package/src/omni/bridge.ts +38 -0
  254. package/src/omni/config.ts +130 -0
  255. package/src/omni/defaultTokens.ts +1078 -0
  256. package/src/omni/index.ts +8 -0
  257. package/src/omni/nearRpc.ts +187 -0
  258. package/src/omni/recipient.ts +41 -0
  259. package/src/omni/token.ts +125 -0
  260. package/src/omni/tokens.ts +68 -0
  261. package/src/omni/types.ts +46 -0
  262. package/src/omni/utils.ts +163 -0
  263. package/src/settings.ts +5 -0
  264. package/src/solana/connector.ts +151 -0
  265. package/src/solana/protocol.ts +66 -0
  266. package/src/solana/wallet.ts +230 -0
  267. package/src/solana/wallets.ts +243 -0
  268. package/src/stellar/connector.ts +69 -0
  269. package/src/stellar/wallet.ts +267 -0
  270. package/src/storage.ts +19 -0
  271. package/src/ton/connector.ts +138 -0
  272. package/src/ton/utils.ts +73 -0
  273. package/src/ton/wallet.ts +178 -0
  274. package/src/ui/Popup.tsx +62 -0
  275. package/src/ui/connect/AuthPopup.tsx +78 -0
  276. package/src/ui/connect/ConnectWallet.tsx +63 -0
  277. package/src/ui/connect/LogoutPopup.tsx +20 -0
  278. package/src/ui/connect/WCPopup.tsx +122 -0
  279. package/src/ui/connect/WCRequest.tsx +28 -0
  280. package/src/ui/connect/WalletPicker.tsx +92 -0
  281. package/src/ui/icons/arrow-right.tsx +8 -0
  282. package/src/ui/icons/exchange.tsx +17 -0
  283. package/src/ui/icons/logout.tsx +18 -0
  284. package/src/ui/icons/pending.tsx +18 -0
  285. package/src/ui/icons/qr.tsx +12 -0
  286. package/src/ui/icons/search.tsx +18 -0
  287. package/src/ui/icons/switch.tsx +10 -0
  288. package/src/ui/icons/wallet.tsx +18 -0
  289. package/src/ui/payment/Bridge.tsx +582 -0
  290. package/src/ui/payment/DepositQR.tsx +88 -0
  291. package/src/ui/payment/Payment.tsx +78 -0
  292. package/src/ui/payment/Profile.tsx +140 -0
  293. package/src/ui/payment/SelectRecipient.tsx +111 -0
  294. package/src/ui/payment/SelectSender.tsx +60 -0
  295. package/src/ui/payment/SelectToken.tsx +134 -0
  296. package/src/ui/payment/TokenCard.tsx +83 -0
  297. package/src/ui/router.tsx +92 -0
  298. package/src/ui/styles.ts +284 -0
  299. package/tsconfig.json +22 -0
  300. package/vite.config.ts +17 -0
@@ -0,0 +1,78 @@
1
+ import { observer } from "mobx-react-lite";
2
+ import { useEffect } from "react";
3
+
4
+ import { HotConnector } from "../../HotConnector";
5
+ import { openBridge, openConnector } from "../router";
6
+ import { Recipient } from "../../omni/recipient";
7
+ import { BridgeReview } from "../../exchange";
8
+ import { OmniWallet } from "../../OmniWallet";
9
+ import { Network } from "../../omni/config";
10
+ import { Token } from "../../omni/token";
11
+ import Popup from "../Popup";
12
+
13
+ import { TokenCard } from "./TokenCard";
14
+ import { PopupOption, PopupOptionInfo } from "../styles";
15
+ import { WalletIcon } from "../icons/wallet";
16
+
17
+ interface PaymentProps {
18
+ connector: HotConnector;
19
+ token: Token;
20
+ amount: bigint;
21
+ recipient?: Recipient;
22
+ onClose: () => void;
23
+ onProcess: (task: Promise<BridgeReview>) => void;
24
+ }
25
+
26
+ export const Payment = observer(({ connector, recipient, token: need, amount: needAmount, onProcess, onClose }: PaymentProps) => {
27
+ const title = `Need ${need.readable(needAmount)} ${need.symbol}`;
28
+ const selectToken = async (from: Token, wallet?: OmniWallet) => {
29
+ onProcess(
30
+ openBridge(connector, {
31
+ sender: wallet,
32
+ autoClose: true,
33
+ type: "exactOut",
34
+ recipient: recipient || Recipient.fromWallet(connector.priorityWallet!),
35
+ readonlyTo: recipient ? true : false,
36
+ amount: need.float(needAmount),
37
+ readonlyAmount: true,
38
+ title: title,
39
+ from: from,
40
+ to: need,
41
+ })
42
+ );
43
+ };
44
+
45
+ useEffect(() => {
46
+ if (connector.wallets.length !== 0) return;
47
+ openConnector(connector);
48
+ }, [connector.wallets.length, connector]);
49
+
50
+ return (
51
+ <Popup onClose={onClose} header={<p>{title}</p>}>
52
+ {connector.walletsTokens.map(({ token, wallet, balance }) => {
53
+ if (token.id === need.id) return null;
54
+ const availableBalance = token.float(balance) - token.reserve;
55
+
56
+ if (need.originalChain === Network.Gonka || need.originalChain === Network.Juno) {
57
+ if (token.id === need.id) return null;
58
+ if (token.originalAddress !== need.originalAddress) return null;
59
+ if (availableBalance <= need.float(needAmount)) return null;
60
+ return <TokenCard key={token.id} token={token} onSelect={selectToken} hot={connector} wallet={wallet} />;
61
+ }
62
+
63
+ if (availableBalance * token.usd <= need.usd * need.float(needAmount)) return null;
64
+ return <TokenCard key={token.id} token={token} onSelect={selectToken} hot={connector} wallet={wallet} />;
65
+ })}
66
+
67
+ <PopupOption onClick={() => openConnector(connector)}>
68
+ <div style={{ width: 44, height: 44, borderRadius: 16, background: "#000", display: "flex", alignItems: "center", justifyContent: "center" }}>
69
+ <WalletIcon />
70
+ </div>
71
+ <PopupOptionInfo>
72
+ <p>Connect wallet</p>
73
+ <span className="wallet-address">To more pay options</span>
74
+ </PopupOptionInfo>
75
+ </PopupOption>
76
+ </Popup>
77
+ );
78
+ });
@@ -0,0 +1,140 @@
1
+ import { observer } from "mobx-react-lite";
2
+ import styled from "styled-components";
3
+ import { useEffect } from "react";
4
+
5
+ import { LogoutIcon } from "../icons/logout";
6
+ import { openBridge, openConnector } from "../router";
7
+ import { HotConnector } from "../../HotConnector";
8
+ import { formatter } from "../../omni/utils";
9
+ import { OmniToken } from "../../omni/config";
10
+ import { tokens } from "../../omni/tokens";
11
+ import Popup from "../Popup";
12
+
13
+ import { ImageView, TokenCard } from "./TokenCard";
14
+ import ExchangeIcon from "../icons/exchange";
15
+
16
+ export const Profile = observer(({ hot, onClose }: { hot: HotConnector; onClose: () => void }) => {
17
+ let totalBalance = 0;
18
+ const tokensList = hot.wallets
19
+ .flatMap((wallet) => {
20
+ return tokens.list.map((token) => ({ token, wallet, balance: hot.balance(wallet, token) }));
21
+ })
22
+ .sort((a, b) => {
23
+ const balanceA = a.token.float(a.balance) * a.token.usd;
24
+ const balanceB = b.token.float(b.balance) * b.token.usd;
25
+ return balanceB - balanceA;
26
+ })
27
+ .map(({ token, wallet, balance }) => {
28
+ if (token.float(balance) < 0.000001) return null;
29
+ totalBalance += token.float(balance) * token.usd;
30
+ return {
31
+ chain: token.chain,
32
+ component: (
33
+ <TokenCard //
34
+ onSelect={() => {
35
+ if (token.chain === -4) hot.withdraw(token.address as OmniToken, +token.float(balance).toFixed(6), { sender: wallet });
36
+ else openBridge(hot, { title: "Exchange", sender: wallet, from: token });
37
+ }}
38
+ key={`${wallet.type}:${wallet.address}:${token.id}`}
39
+ wallet={wallet}
40
+ token={token}
41
+ hot={hot}
42
+ />
43
+ ),
44
+ };
45
+ });
46
+
47
+ useEffect(() => {
48
+ if (hot.wallets.length > 0) return;
49
+ onClose();
50
+ }, [hot.wallets.length]);
51
+
52
+ return (
53
+ <Popup onClose={onClose}>
54
+ <div style={{ display: "flex", flexWrap: "wrap", width: "100%", gap: 8 }}>
55
+ {hot.wallets.map((wallet) => (
56
+ <WalletCard onClick={() => wallet.disconnect()}>
57
+ <ImageView src={wallet.icon} alt={wallet.connector.name} size={20} />
58
+ <div>{formatter.truncateAddress(wallet.address, 8)}</div>
59
+ <LogoutIcon width={20} height={20} />
60
+ </WalletCard>
61
+ ))}
62
+
63
+ {hot.wallets.length < 6 && (
64
+ <WalletCard style={{ paddingLeft: 12, paddingRight: 12 }} onClick={() => openConnector(hot)}>
65
+ Add wallet
66
+ </WalletCard>
67
+ )}
68
+ </div>
69
+
70
+ <div style={{ display: "flex", alignItems: "center", width: "100%", gap: 8, marginTop: 16 }}>
71
+ <BalanceCard>${formatter.amount(totalBalance)}</BalanceCard>
72
+ <ExchangeButton onClick={() => (onClose(), openBridge(hot, { title: "Exchange" }))}>
73
+ <ExchangeIcon size={32} strokeColor="#d2d2d2" />
74
+ </ExchangeButton>
75
+ </div>
76
+
77
+ {tokensList.filter((t) => t != null && t.chain === -4).length > 0 && (
78
+ <TokenCards style={{ marginTop: 16 }}>
79
+ <p style={{ fontSize: 16, fontWeight: 600, color: "#d2d2d2", textAlign: "left" }}>Tokens to withdraw</p>
80
+ {tokensList.filter((t) => t != null && t.chain === -4).map((t) => t?.component)}
81
+ <div style={{ marginTop: 8, marginBottom: -4, width: "100%", height: 1, background: "#383d42" }}></div>
82
+ </TokenCards>
83
+ )}
84
+
85
+ {tokensList.filter((t) => t != null && t.chain !== -4).length > 0 && (
86
+ <TokenCards style={{ marginTop: 16 }}>
87
+ {/* Tokens to exchange */}
88
+ {tokensList.filter((t) => t != null && t.chain !== -4).map((t) => t?.component)}
89
+ </TokenCards>
90
+ )}
91
+ </Popup>
92
+ );
93
+ });
94
+
95
+ const ExchangeButton = styled.button`
96
+ display: flex;
97
+ align-items: center;
98
+ gap: 8px;
99
+ cursor: pointer;
100
+ outline: none;
101
+ border: none;
102
+ background: transparent;
103
+ padding: 8px;
104
+ border-radius: 24px;
105
+ transition: background 0.2s ease-in-out;
106
+ &:hover {
107
+ background: rgba(255, 255, 255, 0.1);
108
+ }
109
+ `;
110
+
111
+ const TokenCards = styled.div`
112
+ display: flex;
113
+ flex-direction: column;
114
+ gap: 8px;
115
+ width: 100%;
116
+ `;
117
+
118
+ const WalletCard = styled.div`
119
+ display: flex;
120
+ align-items: center;
121
+ gap: 8px;
122
+ border-radius: 24px;
123
+ border: 1px solid rgba(255, 255, 255, 0.1);
124
+ padding: 6px;
125
+ padding-left: 8px;
126
+ padding-right: 12px;
127
+ background: #1a1a1a;
128
+ cursor: pointer;
129
+ transition: background 0.2s ease-in-out;
130
+
131
+ &:hover {
132
+ background: rgba(255, 255, 255, 0.04);
133
+ }
134
+ `;
135
+
136
+ const BalanceCard = styled.h2`
137
+ font-size: 48px;
138
+ font-weight: 600;
139
+ color: #fff;
140
+ `;
@@ -0,0 +1,111 @@
1
+ import { observer } from "mobx-react-lite";
2
+ import styled from "styled-components";
3
+ import { useState } from "react";
4
+
5
+ import { ArrowRightIcon } from "../icons/arrow-right";
6
+ import { PopupOption, PopupOptionInfo } from "../styles";
7
+ import { ConnectorType, OmniConnector } from "../../OmniConnector";
8
+ import { HotConnector } from "../../HotConnector";
9
+ import { Recipient } from "../../omni/recipient";
10
+ import { WalletType } from "../../omni/config";
11
+ import { openWalletPicker } from "../router";
12
+ import { formatter } from "../../omni/utils";
13
+ import Popup from "../Popup";
14
+
15
+ import { ImageView } from "./TokenCard";
16
+
17
+ interface SelectRecipientProps {
18
+ recipient?: Recipient;
19
+ type: WalletType;
20
+ onSelect: (recipient?: Recipient) => void;
21
+ hot: HotConnector;
22
+ onClose: () => void;
23
+ }
24
+
25
+ export const SelectRecipient = observer(({ recipient, hot, type, onSelect, onClose }: SelectRecipientProps) => {
26
+ const connectors = hot.connectors.filter((t) => t.walletTypes.includes(type) && t.type !== ConnectorType.SOCIAL);
27
+ const [customAddress, setCustomAddress] = useState<string>(recipient?.address || "");
28
+
29
+ const selectCustom = async () => {
30
+ const recipient = await Recipient.fromAddress(type, customAddress);
31
+ onSelect(recipient);
32
+ onClose();
33
+ };
34
+
35
+ const selectWallet = async (t: OmniConnector) => {
36
+ if (!t.wallets[0]) return openWalletPicker(t, (w) => (onSelect(Recipient.fromWallet(w)), onClose()));
37
+ onSelect(Recipient.fromWallet(t.wallets[0]));
38
+ onClose();
39
+ };
40
+
41
+ return (
42
+ <Popup header={<p>Select recipient</p>} onClose={onClose}>
43
+ {type !== WalletType.OMNI && (
44
+ <div style={{ width: "100%", marginBottom: 24 }}>
45
+ <p style={{ fontSize: 16, textAlign: "left" }}>Enter recipient address, avoid CEX</p>
46
+ <CustomRecipient>
47
+ <input //
48
+ type="text"
49
+ placeholder="Enter wallet address"
50
+ onChange={(e) => setCustomAddress(e.target.value)}
51
+ value={customAddress}
52
+ />
53
+ <button onClick={selectCustom} disabled={customAddress.length === 0}>
54
+ Select
55
+ </button>
56
+ </CustomRecipient>
57
+ </div>
58
+ )}
59
+
60
+ {connectors.map((t) => (
61
+ <PopupOption key={t.id} onClick={() => selectWallet(t)}>
62
+ <ImageView src={t.icon} alt={t.name} size={44} />
63
+ <PopupOptionInfo>
64
+ <p style={{ fontSize: 20, fontWeight: "bold" }}>{t.name}</p>
65
+ {t.wallets[0]?.address && <span className="wallet-address">{formatter.truncateAddress(t.wallets[0].address)}</span>}
66
+ </PopupOptionInfo>
67
+ {!t.wallets[0]?.address ? <p>Connect</p> : <ArrowRightIcon style={{ flexShrink: 0 }} />}
68
+ </PopupOption>
69
+ ))}
70
+ </Popup>
71
+ );
72
+ });
73
+
74
+ const CustomRecipient = styled.div`
75
+ display: flex;
76
+ align-items: center;
77
+ border: 1px solid #2d2d2d;
78
+ border-radius: 12px;
79
+ overflow: hidden;
80
+ margin-top: 8px;
81
+ height: 50px;
82
+
83
+ input {
84
+ width: 100%;
85
+ padding: 12px;
86
+ background: #161616;
87
+ color: #fff;
88
+ outline: none;
89
+ font-size: 16px;
90
+ font-weight: bold;
91
+ text-align: left;
92
+ outline: none;
93
+ border: none;
94
+ height: 100%;
95
+ flex: 1;
96
+ }
97
+
98
+ button {
99
+ width: 100px;
100
+ color: #fff;
101
+ background: #000000;
102
+ border-radius: 0px;
103
+ margin: 0px;
104
+ outline: none;
105
+ border: none;
106
+ height: 100%;
107
+ font-size: 14px;
108
+ font-weight: bold;
109
+ cursor: pointer;
110
+ }
111
+ `;
@@ -0,0 +1,60 @@
1
+ import { observer } from "mobx-react-lite";
2
+
3
+ import { QRIcon } from "../icons/qr";
4
+ import { ArrowRightIcon } from "../icons/arrow-right";
5
+ import { PopupOption, PopupOptionInfo } from "../styles";
6
+
7
+ import { ConnectorType, OmniConnector } from "../../OmniConnector";
8
+ import { OmniWallet } from "../../OmniWallet";
9
+ import { WalletType } from "../../omni/config";
10
+ import { HotConnector } from "../../HotConnector";
11
+ import { openWalletPicker } from "../router";
12
+ import { formatter } from "../../omni/utils";
13
+ import Popup from "../Popup";
14
+
15
+ import { ImageView } from "./TokenCard";
16
+
17
+ interface SelectSenderProps {
18
+ type: WalletType;
19
+ onSelect: (wallet?: OmniWallet | "qr") => void;
20
+ hot: HotConnector;
21
+ onClose: () => void;
22
+ }
23
+
24
+ export const SelectSender = observer(({ hot, type, onSelect, onClose }: SelectSenderProps) => {
25
+ const connectors = hot.connectors.filter((t) => t.walletTypes.includes(type) && t.type !== ConnectorType.SOCIAL);
26
+ const noExternal = type === WalletType.OMNI || type === WalletType.COSMOS;
27
+
28
+ const selectWallet = async (t: OmniConnector) => {
29
+ if (!t.wallets[0]) return openWalletPicker(t, (w) => (onSelect(w), onClose()));
30
+ onSelect(t.wallets[0]);
31
+ onClose();
32
+ };
33
+
34
+ return (
35
+ <Popup header={<p>Select sender</p>} onClose={onClose}>
36
+ {!noExternal && (
37
+ <PopupOption onClick={() => (onSelect("qr"), onClose())}>
38
+ <div style={{ width: 44, height: 44, borderRadius: 16, background: "#000", display: "flex", alignItems: "center", justifyContent: "center" }}>
39
+ <QRIcon />
40
+ </div>
41
+ <PopupOptionInfo>
42
+ <p style={{ fontSize: 20, fontWeight: "bold" }}>Send via QR code</p>
43
+ <span className="wallet-address">From CEX or external wallet</span>
44
+ </PopupOptionInfo>
45
+ </PopupOption>
46
+ )}
47
+
48
+ {connectors.map((t) => (
49
+ <PopupOption key={t.id} onClick={() => selectWallet(t)}>
50
+ <ImageView src={t.icon} alt={t.name} size={44} />
51
+ <PopupOptionInfo>
52
+ <p style={{ fontSize: 20, fontWeight: "bold" }}>{t.name}</p>
53
+ {t.wallets[0]?.address && <span className="wallet-address">{formatter.truncateAddress(t.wallets[0].address)}</span>}
54
+ </PopupOptionInfo>
55
+ {!t.wallets[0]?.address ? <p>Connect</p> : <ArrowRightIcon style={{ flexShrink: 0 }} />}
56
+ </PopupOption>
57
+ ))}
58
+ </Popup>
59
+ );
60
+ });
@@ -0,0 +1,134 @@
1
+ import { useState } from "react";
2
+ import { observer } from "mobx-react-lite";
3
+ import styled from "styled-components";
4
+
5
+ import { formatter } from "../../omni/utils";
6
+ import { Token } from "../../omni/token";
7
+ import { HotConnector } from "../../HotConnector";
8
+ import { OmniWallet } from "../../OmniWallet";
9
+ import { Network, OmniToken } from "../../omni/config";
10
+ import { PopupOption } from "../styles";
11
+ import Popup from "../Popup";
12
+
13
+ import { TokenCard, ImageView } from "./TokenCard";
14
+ import { tokens } from "../../omni/tokens";
15
+
16
+ interface SelectTokenPopupProps {
17
+ hot: HotConnector;
18
+ initialChain?: number;
19
+ onClose: () => void;
20
+ onSelect: (token: Token, wallet?: OmniWallet) => void;
21
+ }
22
+
23
+ export const SelectTokenPopup = observer(({ hot, initialChain, onClose, onSelect }: SelectTokenPopupProps) => {
24
+ const [chain, setChain] = useState<number | null>(initialChain || null);
25
+ const [search, setSearch] = useState<string>("");
26
+
27
+ if (chain == null) {
28
+ const chains: Record<number, { chain: number; balance: number; name: string; icon: string }> = {};
29
+ tokens.list.forEach((token) => {
30
+ if (!chains[token.chain])
31
+ chains[token.chain] = {
32
+ chain: token.chain,
33
+ name: token.chainName,
34
+ icon: token.chainIcon,
35
+ balance: 0,
36
+ };
37
+
38
+ hot.wallets.forEach((wallet) => {
39
+ const balance = hot.balance(wallet, token);
40
+ chains[token.chain].balance += token.float(balance) * token.usd;
41
+ });
42
+ });
43
+
44
+ const sorted = Object.values(chains).sort((a, b) => {
45
+ if (a.chain === Network.Hot) return -1;
46
+ return b.balance - a.balance;
47
+ });
48
+
49
+ return (
50
+ <Popup onClose={onClose} header={<p>Select chain</p>} style={{ minHeight: 300 }}>
51
+ <SearchInput type="text" placeholder="Search chain" onChange={(e) => setSearch(e.target.value)} />
52
+
53
+ {sorted.map(({ chain, balance, name, icon }) => {
54
+ if (search && !name.toLowerCase().includes(search.toLowerCase())) return;
55
+
56
+ return (
57
+ <PopupOption onClick={() => (setChain(chain), setSearch(""))}>
58
+ <ImageView src={icon} alt={name} size={24} />
59
+ <p style={{ fontSize: 24, fontWeight: "bold" }}>{name}</p>
60
+ {balance > 0 && <p style={{ marginLeft: "auto", fontSize: 20, color: "#c6c6c6" }}>${formatter.amount(balance)}</p>}
61
+ </PopupOption>
62
+ );
63
+ })}
64
+ </Popup>
65
+ );
66
+ }
67
+
68
+ if (chain !== -4) {
69
+ return (
70
+ <Popup onClose={onClose} header={<p>Select token</p>} style={{ minHeight: 300 }}>
71
+ <SearchInput type="text" placeholder="Search token" onChange={(e) => setSearch(e.target.value)} />
72
+
73
+ {tokens.list
74
+ .filter((token) => token.chain === chain)
75
+ .sort((a, b) => {
76
+ const wallet = hot.wallets.find((w) => w.type === a.type)!;
77
+ const aBalance = a.float(hot.balance(wallet, a)) * a.usd;
78
+ const bBalance = b.float(hot.balance(wallet, b)) * b.usd;
79
+ return bBalance - aBalance;
80
+ })
81
+ .map((token) => {
82
+ const wallet = hot.wallets.find((w) => w.type === token.type);
83
+ if (search && !token.symbol.toLowerCase().includes(search.toLowerCase())) return;
84
+ return <TokenCard key={token.id} token={token} onSelect={onSelect} hot={hot} wallet={wallet} />;
85
+ })}
86
+ </Popup>
87
+ );
88
+ }
89
+
90
+ let used = new Set<string>();
91
+ return (
92
+ <Popup onClose={onClose} header={<p>Select token</p>}>
93
+ <SearchInput type="text" placeholder="Search token" onChange={(e) => setSearch(e.target.value)} />
94
+ {hot.walletsTokens
95
+ .filter(({ token, balance }) => {
96
+ if (token.chain !== Network.Hot) return false;
97
+ if (token.float(balance) < 0.0001) return false;
98
+ if (!token.symbol.toLowerCase().includes(search.toLowerCase())) return false;
99
+ used.add(token.address);
100
+ return true;
101
+ })
102
+ .sort((a, b) => {
103
+ const aBalance = a.token.float(a.balance) * a.token.usd;
104
+ const bBalance = b.token.float(b.balance) * b.token.usd;
105
+ return bBalance - aBalance;
106
+ })
107
+ .map(({ token, wallet }) => (
108
+ <TokenCard key={token.id} token={token} onSelect={onSelect} hot={hot} wallet={wallet} />
109
+ ))}
110
+
111
+ {Object.values(OmniToken)
112
+ .filter((token) => !used.has(token))
113
+ .map((token) => (
114
+ <TokenCard key={token} token={hot.omni(token)} onSelect={onSelect} hot={hot} wallet={hot.priorityWallet} />
115
+ ))}
116
+ </Popup>
117
+ );
118
+ });
119
+
120
+ const SearchInput = styled.input`
121
+ width: 100%;
122
+ padding: 12px 16px;
123
+ border-radius: 16px;
124
+ border: 1px solid #282c30;
125
+ background: #282c30;
126
+ color: #fff;
127
+ outline: none;
128
+ font-size: 20px;
129
+ font-weight: 500;
130
+ line-height: 24px;
131
+ letter-spacing: -0.32px;
132
+ text-align: left;
133
+ margin-bottom: 8px;
134
+ `;
@@ -0,0 +1,83 @@
1
+ import { observer } from "mobx-react-lite";
2
+ import { useEffect, useState } from "react";
3
+
4
+ import { formatter } from "../../omni/utils";
5
+ import { Token } from "../../omni/token";
6
+ import { HotConnector } from "../../HotConnector";
7
+ import { OmniWallet } from "../../OmniWallet";
8
+ import { PopupOption } from "../styles";
9
+ import { chainsMap } from "../../omni/config";
10
+
11
+ const images = {
12
+ cached: new Map<string, Promise<void>>(),
13
+ cache(url: string): Promise<void> {
14
+ if (this.cached.has(url)) return this.cached.get(url)!;
15
+ const promise = new Promise<void>((resolve, reject) => {
16
+ const img = new Image();
17
+ img.src = url;
18
+ img.onload = () => resolve();
19
+ img.onerror = () => reject(new Error("Failed to load image"));
20
+ });
21
+
22
+ this.cached.set(url, promise);
23
+ return promise;
24
+ },
25
+ };
26
+
27
+ enum ImageState {
28
+ Loading = "loading",
29
+ Loaded = "loaded",
30
+ Error = "error",
31
+ }
32
+
33
+ export const ImageView = ({ src, size = 40, alt, style }: { src: string; size?: number; alt: string; style?: React.CSSProperties }) => {
34
+ const [icon, setIcon] = useState<ImageState>(ImageState.Loading);
35
+ useEffect(() => {
36
+ setIcon(ImageState.Loading);
37
+ images
38
+ .cache(src)
39
+ .then(() => setIcon(ImageState.Loaded))
40
+ .catch(() => setIcon(ImageState.Error));
41
+ }, [src]);
42
+
43
+ if (icon === ImageState.Loaded) {
44
+ return <img src={src} alt={alt} style={{ objectFit: "contain", width: size, height: size, borderRadius: "50%", ...style }} />;
45
+ }
46
+
47
+ return (
48
+ <div style={{ display: "flex", alignItems: "center", justifyContent: "center", width: size, height: size, borderRadius: "50%", backgroundColor: "#0e0e0e", ...style }}>
49
+ <p style={{ fontWeight: "bold", fontSize: size / 2, color: "#ffffff" }}>{alt.charAt(0)?.toUpperCase()}</p>
50
+ </div>
51
+ );
52
+ };
53
+
54
+ export const TokenIcon = observer(({ token, wallet }: { token: Token; wallet?: OmniWallet }) => {
55
+ return (
56
+ <div style={{ position: "relative", width: 40, height: 40 }}>
57
+ <ImageView src={token.icon} alt={token.symbol} size={40} />
58
+ <ImageView src={token.chainIcon} alt={token.symbol} size={14} style={{ position: "absolute", bottom: 0, right: 0 }} />
59
+ {token.chain === -4 && wallet?.type && <ImageView src={wallet.icon} alt={chainsMap[wallet.type]?.name || ""} size={14} style={{ position: "absolute", bottom: 0, left: 0 }} />}
60
+ </div>
61
+ );
62
+ });
63
+
64
+ export const TokenCard = observer(({ token, onSelect, hot, wallet }: { token: Token; onSelect: (token: Token, wallet?: OmniWallet) => void; hot: HotConnector; wallet?: OmniWallet }) => {
65
+ const balance = hot.balance(wallet, token);
66
+ const symbol = token.chain === -4 && !token.isMainOmni ? `${token.originalChainSymbol}_${token.symbol}` : token.symbol;
67
+
68
+ return (
69
+ <PopupOption key={token.id} onClick={() => onSelect(token, wallet)}>
70
+ <TokenIcon token={token} wallet={wallet} />
71
+
72
+ <div style={{ marginTop: -2, display: "flex", flexDirection: "column", gap: 4, textAlign: "left" }}>
73
+ <p style={{ textAlign: "left", fontSize: 20, fontWeight: "bold" }}>{symbol}</p>
74
+ <p style={{ textAlign: "left", fontSize: 14, color: "#c6c6c6" }}>${formatter.amount(token.usd)}</p>
75
+ </div>
76
+
77
+ <div style={{ display: "flex", flexDirection: "column", gap: 4, paddingRight: 4, marginLeft: "auto", alignItems: "flex-end" }}>
78
+ <p style={{ textAlign: "right", fontSize: 20 }}>{token.readable(balance)}</p>
79
+ <p style={{ textAlign: "right", fontSize: 14, color: "#c6c6c6" }}>${token.readable(balance, token.usd)}</p>
80
+ </div>
81
+ </PopupOption>
82
+ );
83
+ });