@hot-labs/kit 1.5.3 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/release.yml +1 -1
- package/README.md +5 -5
- package/build/HotBridgeWithdrawal.d.ts +10 -0
- package/build/HotBridgeWithdrawal.js +80 -0
- package/build/HotBridgeWithdrawal.js.map +1 -0
- package/build/{HotConnector.d.ts → HotKit.d.ts} +9 -5
- package/build/{HotConnector.js → HotKit.js} +14 -11
- package/build/HotKit.js.map +1 -0
- package/build/activity.d.ts +8 -12
- package/build/activity.js +16 -67
- package/build/activity.js.map +1 -1
- package/build/core/Intents.d.ts +6 -9
- package/build/core/Intents.js +28 -29
- package/build/core/Intents.js.map +1 -1
- package/build/core/OmniConnector.d.ts +3 -3
- package/build/core/OmniConnector.js +13 -13
- package/build/core/OmniConnector.js.map +1 -1
- package/build/core/OmniWallet.d.ts +3 -2
- package/build/core/OmniWallet.js +5 -5
- package/build/core/OmniWallet.js.map +1 -1
- package/build/core/chains.d.ts +2 -1
- package/build/core/chains.js +2 -1
- package/build/core/chains.js.map +1 -1
- package/build/core/exchange.d.ts +6 -9
- package/build/core/exchange.js +19 -81
- package/build/core/exchange.js.map +1 -1
- package/build/core/pendings.d.ts +32 -0
- package/build/core/pendings.js +143 -0
- package/build/core/pendings.js.map +1 -0
- package/build/core/telemetry.d.ts +3 -3
- package/build/core/telemetry.js +4 -4
- package/build/core/telemetry.js.map +1 -1
- package/build/cosmos/connector.d.ts +2 -2
- package/build/cosmos/connector.js +2 -2
- package/build/cosmos/connector.js.map +1 -1
- package/build/cosmos/index.d.ts +2 -2
- package/build/cosmos/index.js +1 -1
- package/build/cosmos/index.js.map +1 -1
- package/build/defaults.d.ts +1 -1
- package/build/evm/connector.d.ts +4 -4
- package/build/evm/connector.js +2 -2
- package/build/evm/connector.js.map +1 -1
- package/build/evm/index.d.ts +2 -2
- package/build/evm/index.js +1 -1
- package/build/evm/index.js.map +1 -1
- package/build/hocraft/connector.d.ts +3 -3
- package/build/hocraft/connector.js +7 -7
- package/build/hocraft/connector.js.map +1 -1
- package/build/hocraft/index.d.ts +2 -2
- package/build/hocraft/index.js +1 -1
- package/build/hocraft/index.js.map +1 -1
- package/build/hot-wallet/google.d.ts +2 -2
- package/build/hot-wallet/google.js +5 -5
- package/build/hot-wallet/google.js.map +1 -1
- package/build/hot-wallet/index.d.ts +2 -2
- package/build/hot-wallet/index.js +1 -1
- package/build/hot-wallet/index.js.map +1 -1
- package/build/index.d.ts +3 -2
- package/build/index.js +4 -2
- package/build/index.js.map +1 -1
- package/build/near/connector.d.ts +3 -3
- package/build/near/connector.js +4 -4
- package/build/near/connector.js.map +1 -1
- package/build/near/index.d.ts +2 -2
- package/build/near/index.js +1 -1
- package/build/near/index.js.map +1 -1
- package/build/solana/connector.d.ts +4 -4
- package/build/solana/connector.js +2 -2
- package/build/solana/connector.js.map +1 -1
- package/build/solana/index.d.ts +2 -2
- package/build/solana/index.js +1 -1
- package/build/solana/index.js.map +1 -1
- package/build/stellar/connector.d.ts +2 -2
- package/build/stellar/connector.js +3 -3
- package/build/stellar/connector.js.map +1 -1
- package/build/stellar/index.d.ts +2 -2
- package/build/stellar/index.js +1 -1
- package/build/stellar/index.js.map +1 -1
- package/build/storage.d.ts +10 -0
- package/build/storage.js +56 -0
- package/build/storage.js.map +1 -1
- package/build/ton/connector.d.ts +2 -2
- package/build/ton/connector.js +3 -3
- package/build/ton/connector.js.map +1 -1
- package/build/ton/index.d.ts +2 -2
- package/build/ton/index.js +1 -1
- package/build/ton/index.js.map +1 -1
- package/build/tron/connector.d.ts +2 -2
- package/build/tron/connector.js +2 -2
- package/build/tron/connector.js.map +1 -1
- package/build/tron/index.d.ts +2 -2
- package/build/tron/index.js +1 -1
- package/build/tron/index.js.map +1 -1
- package/build/ui/Popup.d.ts +2 -1
- package/build/ui/Popup.js +3 -3
- package/build/ui/Popup.js.map +1 -1
- package/build/ui/bridge/Bridge.d.ts +11 -3
- package/build/ui/bridge/Bridge.js +45 -47
- package/build/ui/bridge/Bridge.js.map +1 -1
- package/build/ui/bridge/SelectRecipient.d.ts +3 -3
- package/build/ui/bridge/SelectRecipient.js +2 -2
- package/build/ui/bridge/SelectSender.d.ts +3 -3
- package/build/ui/bridge/SelectSender.js +5 -5
- package/build/ui/bridge/SelectSender.js.map +1 -1
- package/build/ui/bridge/SelectToken.d.ts +3 -3
- package/build/ui/bridge/SelectToken.js +12 -12
- package/build/ui/bridge/TokenCard.d.ts +10 -8
- package/build/ui/bridge/TokenCard.js +3 -3
- package/build/ui/bridge/TokenCard.js.map +1 -1
- package/build/ui/connect/AuthPopup.d.ts +8 -1
- package/build/ui/connect/AuthPopup.js +2 -20
- package/build/ui/connect/AuthPopup.js.map +1 -1
- package/build/ui/connect/ConnectWallet.d.ts +3 -3
- package/build/ui/connect/ConnectWallet.js +3 -3
- package/build/ui/connect/PrimaryWallet.d.ts +3 -3
- package/build/ui/connect/PrimaryWallet.js +2 -2
- package/build/ui/connect/PrimaryWallet.js.map +1 -1
- package/build/ui/connect/WalletPicker.d.ts +1 -1
- package/build/ui/connect/WalletPicker.js +1 -0
- package/build/ui/connect/WalletPicker.js.map +1 -1
- package/build/ui/icons/copy.d.ts +1 -0
- package/build/ui/icons/copy.js +5 -0
- package/build/ui/icons/copy.js.map +1 -0
- package/build/ui/icons/warning.d.ts +1 -0
- package/build/ui/icons/warning.js +5 -0
- package/build/ui/icons/warning.js.map +1 -0
- package/build/ui/index.d.ts +12 -0
- package/build/ui/index.js +12 -0
- package/build/ui/index.js.map +1 -0
- package/build/ui/profile/DepositFlow.d.ts +8 -0
- package/build/ui/profile/DepositFlow.js +13 -0
- package/build/ui/profile/DepositFlow.js.map +1 -0
- package/build/ui/profile/DepositQR.d.ts +4 -2
- package/build/ui/profile/DepositQR.js +51 -22
- package/build/ui/profile/DepositQR.js.map +1 -1
- package/build/ui/profile/Payment.d.ts +6 -9
- package/build/ui/profile/Payment.js +36 -28
- package/build/ui/profile/Payment.js.map +1 -1
- package/build/ui/profile/Profile.d.ts +3 -3
- package/build/ui/profile/Profile.js +17 -52
- package/build/ui/profile/Profile.js.map +1 -1
- package/build/ui/router.d.ts +14 -15
- package/build/ui/router.js +37 -16
- package/build/ui/router.js.map +1 -1
- package/build/ui/styles.js +3 -0
- package/build/ui/styles.js.map +1 -1
- package/build/ui/toast/index.d.ts +42 -0
- package/build/ui/toast/index.js +165 -0
- package/build/ui/toast/index.js.map +1 -0
- package/build/ui/uikit/button.js +1 -1
- package/build/ui/uikit/checkbox.d.ts +8 -0
- package/build/ui/uikit/checkbox.js +39 -0
- package/build/ui/uikit/checkbox.js.map +1 -0
- package/build/ui/uikit/text.js +27 -27
- package/package.json +3 -2
- package/src/HotBridgeWithdrawal.ts +80 -0
- package/src/{HotConnector.ts → HotKit.ts} +17 -13
- package/src/activity.ts +22 -69
- package/src/core/Intents.ts +22 -36
- package/src/core/OmniConnector.ts +12 -12
- package/src/core/OmniWallet.ts +6 -6
- package/src/core/chains.ts +2 -1
- package/src/core/exchange.ts +22 -80
- package/src/core/pendings.ts +151 -0
- package/src/core/telemetry.ts +3 -3
- package/src/cosmos/connector.ts +3 -3
- package/src/cosmos/index.ts +3 -3
- package/src/evm/connector.ts +3 -3
- package/src/evm/index.ts +2 -2
- package/src/hocraft/connector.ts +6 -6
- package/src/hocraft/index.ts +2 -2
- package/src/hot-wallet/google.ts +6 -6
- package/src/hot-wallet/index.ts +2 -2
- package/src/index.ts +5 -2
- package/src/near/connector.ts +3 -3
- package/src/near/index.ts +2 -2
- package/src/solana/connector.ts +3 -3
- package/src/solana/index.ts +2 -2
- package/src/stellar/connector.ts +4 -4
- package/src/stellar/index.ts +2 -2
- package/src/storage.ts +69 -0
- package/src/ton/connector.ts +4 -4
- package/src/ton/index.ts +2 -2
- package/src/tron/connector.ts +3 -3
- package/src/tron/index.ts +2 -2
- package/src/ui/Popup.tsx +4 -3
- package/src/ui/bridge/Bridge.tsx +64 -61
- package/src/ui/bridge/SelectRecipient.tsx +4 -4
- package/src/ui/bridge/SelectSender.tsx +8 -8
- package/src/ui/bridge/SelectToken.tsx +14 -14
- package/src/ui/bridge/TokenCard.tsx +31 -24
- package/src/ui/connect/AuthPopup.tsx +1 -24
- package/src/ui/connect/ConnectWallet.tsx +5 -5
- package/src/ui/connect/PrimaryWallet.tsx +3 -3
- package/src/ui/connect/WalletPicker.tsx +6 -0
- package/src/ui/icons/copy.tsx +8 -0
- package/src/ui/icons/warning.tsx +10 -0
- package/src/ui/index.ts +14 -0
- package/src/ui/profile/DepositFlow.tsx +27 -0
- package/src/ui/profile/DepositQR.tsx +83 -46
- package/src/ui/profile/Payment.tsx +67 -37
- package/src/ui/profile/Profile.tsx +39 -68
- package/src/ui/router.tsx +48 -21
- package/src/ui/styles.ts +3 -0
- package/src/ui/toast/index.tsx +238 -0
- package/src/ui/uikit/button.tsx +1 -1
- package/src/ui/uikit/checkbox.tsx +60 -0
- package/src/ui/uikit/text.tsx +27 -27
- package/build/HotConnector.js.map +0 -1
- package/build/ui/uikit/Toast.d.ts +0 -4
- package/build/ui/uikit/Toast.js +0 -33
- package/build/ui/uikit/Toast.js.map +0 -1
- package/src/ui/uikit/Toast.tsx +0 -45
- package/vite.config.ts +0 -17
package/src/ui/bridge/Bridge.tsx
CHANGED
|
@@ -7,7 +7,7 @@ import { ArrowRightIcon } from "../icons/arrow-right";
|
|
|
7
7
|
import ExchangeIcon from "../icons/exchange";
|
|
8
8
|
import RefreshIcon from "../icons/refresh";
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { HotKit } from "../../HotKit";
|
|
11
11
|
import { chains, Network, WalletType } from "../../core/chains";
|
|
12
12
|
import { BridgeReview } from "../../core/exchange";
|
|
13
13
|
import { OmniWallet } from "../../core/OmniWallet";
|
|
@@ -17,12 +17,12 @@ import { tokens } from "../../core/tokens";
|
|
|
17
17
|
import { Token } from "../../core/token";
|
|
18
18
|
|
|
19
19
|
import { ActionButton, Button } from "../uikit/button";
|
|
20
|
-
import {
|
|
20
|
+
import { H5, PLarge, PSmall, PTiny } from "../uikit/text";
|
|
21
21
|
import { Skeleton } from "../uikit/loader";
|
|
22
22
|
import { ImageView } from "../uikit/image";
|
|
23
23
|
|
|
24
24
|
import Popup from "../Popup";
|
|
25
|
-
import { openSelectRecipient, openSelectSender, openSelectTokenPopup
|
|
25
|
+
import { openConnector, openSelectRecipient, openSelectSender, openSelectTokenPopup } from "../router";
|
|
26
26
|
import DepositQR from "../profile/DepositQR";
|
|
27
27
|
import { TokenIcon } from "./TokenCard";
|
|
28
28
|
|
|
@@ -32,10 +32,19 @@ const animations = {
|
|
|
32
32
|
loading: "https://hex.exchange/loading.json",
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
+
export interface ProcessingState {
|
|
36
|
+
status: "qr" | "processing" | "success" | "error";
|
|
37
|
+
resolve?: (value: BridgeReview) => void;
|
|
38
|
+
reject?: (error: Error) => void;
|
|
39
|
+
message?: string;
|
|
40
|
+
review: BridgeReview;
|
|
41
|
+
}
|
|
42
|
+
|
|
35
43
|
export interface BridgeProps {
|
|
36
|
-
|
|
44
|
+
kit: HotKit;
|
|
37
45
|
widget?: boolean;
|
|
38
46
|
onClose: () => void;
|
|
47
|
+
onStateUpdate?: (state: ProcessingState | null) => void;
|
|
39
48
|
onProcess: (task: Promise<BridgeReview>) => void;
|
|
40
49
|
onSelectPair?: (from: Token, to: Token) => void;
|
|
41
50
|
setup?: {
|
|
@@ -54,12 +63,12 @@ export interface BridgeProps {
|
|
|
54
63
|
|
|
55
64
|
const FIXED = 6;
|
|
56
65
|
|
|
57
|
-
export const Bridge = observer(({
|
|
58
|
-
const [isFiat, setIsFiat] = useState(false);
|
|
66
|
+
export const Bridge = observer(({ kit, widget, setup, onClose, onProcess, onStateUpdate, onSelectPair }: BridgeProps) => {
|
|
59
67
|
const [type, setType] = useState<"exactIn" | "exactOut">(setup?.type || "exactIn");
|
|
60
68
|
const [from, setFrom] = useState<Token>(setup?.from || tokens.list.find((t) => t.id === localStorage.getItem("bridge:from")) || tokens.list.find((t) => t.symbol === "NEAR")!);
|
|
61
69
|
const [to, setTo] = useState<Token>(setup?.to || tokens.list.find((t) => t.id === localStorage.getItem("bridge:to")) || tokens.list.find((t) => t.symbol === "USDT")!);
|
|
62
70
|
const [value, setValue] = useState<string>(setup?.amount?.toFixed(6) ?? "");
|
|
71
|
+
const [isFiat, setIsFiat] = useState(false);
|
|
63
72
|
|
|
64
73
|
const [review, setReview] = useState<BridgeReview | null>(null);
|
|
65
74
|
const [isError, setIsError] = useState<string | null>(null);
|
|
@@ -71,13 +80,11 @@ export const Bridge = observer(({ hot, widget, setup, onClose, onProcess, onSele
|
|
|
71
80
|
fetch(animations.failed);
|
|
72
81
|
});
|
|
73
82
|
|
|
74
|
-
const [processing, setProcessing] = useState<
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
review: BridgeReview;
|
|
80
|
-
} | null>(null);
|
|
83
|
+
const [processing, setProcessing] = useState<ProcessingState | null>(null);
|
|
84
|
+
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
onStateUpdate?.(processing);
|
|
87
|
+
}, [processing]);
|
|
81
88
|
|
|
82
89
|
useEffect(() => {
|
|
83
90
|
onSelectPair?.(from, to);
|
|
@@ -85,19 +92,19 @@ export const Bridge = observer(({ hot, widget, setup, onClose, onProcess, onSele
|
|
|
85
92
|
|
|
86
93
|
const [sender, setSender] = useState<OmniWallet | "qr" | undefined>(() => {
|
|
87
94
|
if (setup?.sender) return setup.sender;
|
|
88
|
-
if (from.type === WalletType.OMNI) return
|
|
89
|
-
return
|
|
95
|
+
if (from.type === WalletType.OMNI) return kit.priorityWallet;
|
|
96
|
+
return kit.wallets.find((w) => w.type === from.type);
|
|
90
97
|
});
|
|
91
98
|
|
|
92
99
|
useEffect(() => {
|
|
93
|
-
if (from.type === WalletType.OMNI) setSender(
|
|
94
|
-
if (to.type === WalletType.OMNI) setRecipient(Recipient.fromWallet(
|
|
95
|
-
}, [
|
|
100
|
+
if (from.type === WalletType.OMNI) setSender(kit.priorityWallet);
|
|
101
|
+
if (to.type === WalletType.OMNI) setRecipient(Recipient.fromWallet(kit.priorityWallet!));
|
|
102
|
+
}, [kit.priorityWallet]);
|
|
96
103
|
|
|
97
104
|
const [recipient, setRecipient] = useState<Recipient | undefined>(() => {
|
|
98
105
|
if (setup?.recipient) return setup.recipient;
|
|
99
|
-
if (to.type === WalletType.OMNI) return Recipient.fromWallet(
|
|
100
|
-
return Recipient.fromWallet(
|
|
106
|
+
if (to.type === WalletType.OMNI) return Recipient.fromWallet(kit.priorityWallet!);
|
|
107
|
+
return Recipient.fromWallet(kit.wallets.find((w) => w.type === to.type)!);
|
|
101
108
|
});
|
|
102
109
|
|
|
103
110
|
const initialSender = useRef<OmniWallet | "qr" | undefined>(sender);
|
|
@@ -110,7 +117,7 @@ export const Bridge = observer(({ hot, widget, setup, onClose, onProcess, onSele
|
|
|
110
117
|
const showAmountFrom = type === "exactOut" ? +from.float(review?.amountIn ?? 0).toFixed(FIXED) : formatter.fromInput(value);
|
|
111
118
|
const showAmountTo = type === "exactIn" ? +to.float(review?.amountOut ?? 0).toFixed(FIXED) : formatter.fromInput(value);
|
|
112
119
|
|
|
113
|
-
const availableBalance = sender !== "qr" ? +Math.max(0, from.float(
|
|
120
|
+
const availableBalance = sender !== "qr" ? +Math.max(0, from.float(kit.balance(sender, from)) - from.reserve).toFixed(FIXED) : 0;
|
|
114
121
|
|
|
115
122
|
let title = "Exchange";
|
|
116
123
|
if (from.chain === Network.HotCraft || from.chain === Network.Omni) title = `Withdraw ${from.symbol}`;
|
|
@@ -124,15 +131,15 @@ export const Bridge = observer(({ hot, widget, setup, onClose, onProcess, onSele
|
|
|
124
131
|
|
|
125
132
|
useEffect(() => {
|
|
126
133
|
if (initialSender.current == null) {
|
|
127
|
-
if (from.type === WalletType.OMNI) setSender(
|
|
128
|
-
else setSender(
|
|
134
|
+
if (from.type === WalletType.OMNI) setSender(kit.priorityWallet);
|
|
135
|
+
else setSender(kit.wallets.find((w) => w.type === from.type));
|
|
129
136
|
}
|
|
130
137
|
|
|
131
138
|
if (initialRecipient.current == null) {
|
|
132
|
-
if (to.type === WalletType.OMNI) setRecipient(Recipient.fromWallet(
|
|
133
|
-
else setRecipient(Recipient.fromWallet(
|
|
139
|
+
if (to.type === WalletType.OMNI) setRecipient(Recipient.fromWallet(kit.priorityWallet));
|
|
140
|
+
else setRecipient(Recipient.fromWallet(kit.wallets.find((w) => w.type === to.type)));
|
|
134
141
|
}
|
|
135
|
-
}, [to, from,
|
|
142
|
+
}, [to, from, kit.wallets, kit.priorityWallet]);
|
|
136
143
|
|
|
137
144
|
const reviewId = useRef(uuid4());
|
|
138
145
|
const throwError = (message: string) => {
|
|
@@ -151,6 +158,7 @@ export const Bridge = observer(({ hot, widget, setup, onClose, onProcess, onSele
|
|
|
151
158
|
}, 3000);
|
|
152
159
|
};
|
|
153
160
|
|
|
161
|
+
const refundWallet = sender !== "qr" ? sender : kit.priorityWallet;
|
|
154
162
|
const reviewSwap = useCallback(() => {
|
|
155
163
|
reviewId.current = uuid4();
|
|
156
164
|
const currentReviewId = reviewId.current;
|
|
@@ -158,15 +166,13 @@ export const Bridge = observer(({ hot, widget, setup, onClose, onProcess, onSele
|
|
|
158
166
|
setReview(null);
|
|
159
167
|
setIsError(null);
|
|
160
168
|
|
|
161
|
-
const refund = sender !== "qr" ? sender : hot.priorityWallet;
|
|
162
169
|
if (valueInTokens <= 0) return throwError("Enter amount");
|
|
163
|
-
|
|
164
170
|
const debounceTimer = setTimeout(async () => {
|
|
165
171
|
try {
|
|
166
172
|
if (currentReviewId !== reviewId.current) return;
|
|
167
173
|
const amount = type === "exactIn" ? from.int(valueInTokens) : to.int(valueInTokens);
|
|
168
|
-
const recipientWallet =
|
|
169
|
-
const review = await
|
|
174
|
+
const recipientWallet = kit.wallets.find((w) => w.address === recipient?.address && w.type === recipient?.type) || recipient;
|
|
175
|
+
const review = await kit.exchange.reviewSwap({ recipient: recipientWallet, slippage: 0.005, sender, refund: refundWallet, amount, type, from, to });
|
|
170
176
|
if (currentReviewId !== reviewId.current) return;
|
|
171
177
|
|
|
172
178
|
if (amount > 0) {
|
|
@@ -187,7 +193,7 @@ export const Bridge = observer(({ hot, widget, setup, onClose, onProcess, onSele
|
|
|
187
193
|
}, 500);
|
|
188
194
|
|
|
189
195
|
return () => clearTimeout(debounceTimer);
|
|
190
|
-
}, [valueInTokens, type, from, to, sender,
|
|
196
|
+
}, [valueInTokens, type, from, to, sender, kit.exchange, recipient, kit.priorityWallet]);
|
|
191
197
|
|
|
192
198
|
useEffect(() => {
|
|
193
199
|
reviewSwap();
|
|
@@ -196,21 +202,17 @@ export const Bridge = observer(({ hot, widget, setup, onClose, onProcess, onSele
|
|
|
196
202
|
const process = async (review: BridgeReview) => {
|
|
197
203
|
try {
|
|
198
204
|
const log = (message: string) => setProcessing({ status: "processing", message, review });
|
|
199
|
-
|
|
205
|
+
kit.exchange.bridge.logger = { log, warn: console.warn };
|
|
200
206
|
log("Signing transaction");
|
|
201
207
|
|
|
202
208
|
review.logger = { log };
|
|
203
|
-
const
|
|
204
|
-
let resultReview = result.review;
|
|
209
|
+
const pending = await kit.exchange.makeSwap(review);
|
|
205
210
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
resultReview = await result.processing();
|
|
209
|
-
}
|
|
211
|
+
setProcessing({ status: "success", review: pending.review });
|
|
212
|
+
kit.activity.addBridgePending(pending);
|
|
210
213
|
|
|
211
|
-
setProcessing({ status: "success", message: "Transaction signed", review: resultReview });
|
|
212
214
|
if (setup?.autoClose) onClose();
|
|
213
|
-
return
|
|
215
|
+
return pending.review;
|
|
214
216
|
} catch (e) {
|
|
215
217
|
setProcessing({ status: "error", message: e?.toString?.() ?? "Unknown error", review });
|
|
216
218
|
throw e;
|
|
@@ -245,6 +247,7 @@ export const Bridge = observer(({ hot, widget, setup, onClose, onProcess, onSele
|
|
|
245
247
|
return (
|
|
246
248
|
<Popup widget={widget} onClose={onClose} header={<p>{title}</p>} mobileFullscreen={setup?.mobileFullscreen}>
|
|
247
249
|
<DepositQR //
|
|
250
|
+
kit={kit}
|
|
248
251
|
review={processing.review}
|
|
249
252
|
onConfirm={() => onProcess(process(processing.review))}
|
|
250
253
|
onCancel={cancelReview}
|
|
@@ -259,7 +262,7 @@ export const Bridge = observer(({ hot, widget, setup, onClose, onProcess, onSele
|
|
|
259
262
|
<div style={{ width: "100%", height: 400, display: "flex", justifyContent: "center", alignItems: "center", flexDirection: "column" }}>
|
|
260
263
|
{/* @ts-expect-error: dotlottie-wc is not typed */}
|
|
261
264
|
<dotlottie-wc key="loading" src={animations.loading} speed="1" style={{ width: 300, height: 300 }} mode="forward" loop autoplay></dotlottie-wc>
|
|
262
|
-
<
|
|
265
|
+
<H5 style={{ marginTop: -32 }}>{processing.message}</H5>
|
|
263
266
|
</div>
|
|
264
267
|
</Popup>
|
|
265
268
|
);
|
|
@@ -271,7 +274,8 @@ export const Bridge = observer(({ hot, widget, setup, onClose, onProcess, onSele
|
|
|
271
274
|
<div style={{ width: "100%", height: 400, display: "flex", justifyContent: "center", alignItems: "center", flexDirection: "column" }}>
|
|
272
275
|
{/* @ts-expect-error: dotlottie-wc is not typed */}
|
|
273
276
|
<dotlottie-wc key="success" src={animations.success} speed="1" style={{ width: 300, height: 300 }} mode="forward" loop autoplay></dotlottie-wc>
|
|
274
|
-
<
|
|
277
|
+
<H5 style={{ marginTop: -32 }}>{title} in progress</H5>
|
|
278
|
+
<PSmall style={{ marginTop: 8 }}>You can track your transaction in the activity</PSmall>
|
|
275
279
|
</div>
|
|
276
280
|
<ActionButton style={{ marginTop: "auto" }} onClick={() => (cancelReview(), onClose())}>
|
|
277
281
|
Continue
|
|
@@ -286,19 +290,22 @@ export const Bridge = observer(({ hot, widget, setup, onClose, onProcess, onSele
|
|
|
286
290
|
<div style={{ width: "100%", height: 400, marginBottom: 8, gap: 8, display: "flex", justifyContent: "center", alignItems: "center", flexDirection: "column" }}>
|
|
287
291
|
{/* @ts-expect-error: dotlottie-wc is not typed */}
|
|
288
292
|
<dotlottie-wc key="error" src={animations.failed} speed="1" style={{ width: 300, height: 300 }} mode="forward" loop autoplay></dotlottie-wc>
|
|
289
|
-
<
|
|
293
|
+
<H5 style={{ marginTop: -32 }}>{title} failed</H5>
|
|
290
294
|
<TextField>{processing.message}</TextField>
|
|
291
295
|
</div>
|
|
292
296
|
|
|
293
|
-
<ActionButton onClick={() => (cancelReview(), onClose())}>
|
|
297
|
+
<ActionButton style={{ marginTop: "auto" }} onClick={() => (cancelReview(), onClose())}>
|
|
298
|
+
Continue
|
|
299
|
+
</ActionButton>
|
|
294
300
|
</Popup>
|
|
295
301
|
);
|
|
296
302
|
}
|
|
297
303
|
|
|
298
304
|
const button = () => {
|
|
305
|
+
if (refundWallet == null) return <ActionButton onClick={() => openConnector(kit)}>Sign in to HEX</ActionButton>;
|
|
299
306
|
if (sender == null) return <ActionButton disabled>Confirm</ActionButton>;
|
|
300
307
|
if (recipient == null) return <ActionButton disabled>Confirm</ActionButton>;
|
|
301
|
-
if (sender !== "qr" && +from.float(
|
|
308
|
+
if (sender !== "qr" && +from.float(kit.balance(sender, from)).toFixed(FIXED) < +amountFrom.toFixed(FIXED)) return <ActionButton disabled>Insufficient balance</ActionButton>;
|
|
302
309
|
return (
|
|
303
310
|
<ActionButton style={{ width: "100%", marginTop: 40 }} disabled={isReviewing || isError != null} onClick={handleConfirm}>
|
|
304
311
|
{isReviewing ? "Quoting..." : isError != null ? isError : "Confirm"}
|
|
@@ -311,7 +318,7 @@ export const Bridge = observer(({ hot, widget, setup, onClose, onProcess, onSele
|
|
|
311
318
|
<div style={{ display: "flex", flexDirection: "column", gap: 4, width: "100%", height: "100%" }}>
|
|
312
319
|
<Card style={{ borderRadius: "20px 20px 2px 2px" }}>
|
|
313
320
|
<CardHeader>
|
|
314
|
-
<ChainButton onClick={() => openSelectTokenPopup({
|
|
321
|
+
<ChainButton onClick={() => openSelectTokenPopup({ kit, onSelect: (token, wallet) => (setFrom(token), setSender(wallet)) })}>
|
|
315
322
|
<PSmall>From</PSmall>
|
|
316
323
|
<ImageView src={chains.get(from.chain)?.logo || ""} alt={from.symbol} size={16} />
|
|
317
324
|
<PSmall>{chains.get(from.chain)?.name}</PSmall>
|
|
@@ -320,13 +327,7 @@ export const Bridge = observer(({ hot, widget, setup, onClose, onProcess, onSele
|
|
|
320
327
|
|
|
321
328
|
<div style={{ display: "flex", alignItems: "center", gap: 8 }}>
|
|
322
329
|
<PSmall>Sender:</PSmall>
|
|
323
|
-
|
|
324
|
-
<BadgeButton
|
|
325
|
-
onClick={() => {
|
|
326
|
-
if (from.type === WalletType.OMNI) openSelectSender({ hot, type: from.type, onSelect: (sender) => setSender(sender) });
|
|
327
|
-
else openWalletPicker(hot.getWalletConnector(from.type)!, (wallet) => setSender(wallet));
|
|
328
|
-
}}
|
|
329
|
-
>
|
|
330
|
+
<BadgeButton onClick={() => openSelectSender({ kit, type: from.type, onSelect: (sender) => setSender(sender) })}>
|
|
330
331
|
<PSmall>{sender == null ? "Select" : sender !== "qr" ? formatter.truncateAddress(sender.address, 8) : "QR"}</PSmall>
|
|
331
332
|
<Tooltip id="sender-tooltip">
|
|
332
333
|
<PSmall>Select sender wallet</PSmall>
|
|
@@ -343,7 +344,7 @@ export const Bridge = observer(({ hot, widget, setup, onClose, onProcess, onSele
|
|
|
343
344
|
openSelectTokenPopup({
|
|
344
345
|
onSelect: (token, wallet) => (setFrom(token), setSender(wallet)),
|
|
345
346
|
initialChain: from.chain,
|
|
346
|
-
|
|
347
|
+
kit,
|
|
347
348
|
})
|
|
348
349
|
}
|
|
349
350
|
/>
|
|
@@ -372,7 +373,7 @@ export const Bridge = observer(({ hot, widget, setup, onClose, onProcess, onSele
|
|
|
372
373
|
{sender !== "qr" && (
|
|
373
374
|
<AvailableBalance>
|
|
374
375
|
<PSmall>Balance: ${from.readable(availableBalance, from.usd)}</PSmall>
|
|
375
|
-
<Button onClick={() => sender &&
|
|
376
|
+
<Button onClick={() => sender && kit.fetchToken(from, sender)}>
|
|
376
377
|
<RefreshIcon color="#fff" />
|
|
377
378
|
</Button>
|
|
378
379
|
</AvailableBalance>
|
|
@@ -403,7 +404,7 @@ export const Bridge = observer(({ hot, widget, setup, onClose, onProcess, onSele
|
|
|
403
404
|
{sender !== "qr" && (
|
|
404
405
|
<AvailableBalance>
|
|
405
406
|
<PSmall>Balance: {`${from.readable(availableBalance)} ${from.symbol}`}</PSmall>
|
|
406
|
-
<Button style={{ marginTop: 2 }} onClick={() => sender &&
|
|
407
|
+
<Button style={{ marginTop: 2 }} onClick={() => sender && kit.fetchToken(from, sender)}>
|
|
407
408
|
<RefreshIcon color="#fff" />
|
|
408
409
|
</Button>
|
|
409
410
|
</AvailableBalance>
|
|
@@ -433,7 +434,7 @@ export const Bridge = observer(({ hot, widget, setup, onClose, onProcess, onSele
|
|
|
433
434
|
onClick={() => {
|
|
434
435
|
setFrom(to);
|
|
435
436
|
setTo(from);
|
|
436
|
-
setSender(
|
|
437
|
+
setSender(kit.wallets.find((w) => w.address === recipient?.address));
|
|
437
438
|
setRecipient(sender === "qr" ? undefined : sender ? Recipient.fromWallet(sender) : undefined);
|
|
438
439
|
setType(type === "exactIn" ? "exactOut" : "exactIn");
|
|
439
440
|
setValue("");
|
|
@@ -445,7 +446,7 @@ export const Bridge = observer(({ hot, widget, setup, onClose, onProcess, onSele
|
|
|
445
446
|
|
|
446
447
|
<Card style={{ borderRadius: "2px 2px 20px 20px" }}>
|
|
447
448
|
<CardHeader>
|
|
448
|
-
<ChainButton onClick={() => openSelectTokenPopup({
|
|
449
|
+
<ChainButton onClick={() => openSelectTokenPopup({ kit, onSelect: (token, wallet) => (setTo(token), setRecipient(wallet)) })}>
|
|
449
450
|
<PSmall>To</PSmall>
|
|
450
451
|
<ImageView src={chains.get(to.chain)?.logo || ""} alt={to.symbol} size={16} />
|
|
451
452
|
<PSmall>{chains.get(to.chain)?.name}</PSmall>
|
|
@@ -454,7 +455,7 @@ export const Bridge = observer(({ hot, widget, setup, onClose, onProcess, onSele
|
|
|
454
455
|
|
|
455
456
|
<div style={{ display: "flex", alignItems: "center", gap: 8 }}>
|
|
456
457
|
<PSmall>Recipient:</PSmall>
|
|
457
|
-
<BadgeButton onClick={() => openSelectRecipient({
|
|
458
|
+
<BadgeButton onClick={() => openSelectRecipient({ kit, chain: to.chain, onSelect: (recipient) => setRecipient(recipient) })}>
|
|
458
459
|
<PSmall>{recipient == null ? "Select" : formatter.truncateAddress(recipient.address, 8)}</PSmall>
|
|
459
460
|
<Tooltip id="recipient-tooltip">
|
|
460
461
|
<PSmall>Select recipient wallet</PSmall>
|
|
@@ -469,7 +470,7 @@ export const Bridge = observer(({ hot, widget, setup, onClose, onProcess, onSele
|
|
|
469
470
|
token={to}
|
|
470
471
|
onSelect={() =>
|
|
471
472
|
openSelectTokenPopup({
|
|
472
|
-
|
|
473
|
+
kit,
|
|
473
474
|
initialChain: to.chain,
|
|
474
475
|
onSelect: (token, wallet) => {
|
|
475
476
|
setRecipient(wallet ? Recipient.fromWallet(wallet) : undefined);
|
|
@@ -521,7 +522,9 @@ const TokenPreview = ({ style, token, onSelect }: { style?: React.CSSProperties;
|
|
|
521
522
|
};
|
|
522
523
|
|
|
523
524
|
const TextField = styled(PTiny)`
|
|
524
|
-
width: 100%;
|
|
525
|
+
max-width: 100%;
|
|
526
|
+
min-width: 300px;
|
|
527
|
+
min-height: 64px;
|
|
525
528
|
overflow: auto;
|
|
526
529
|
max-height: 200px;
|
|
527
530
|
background: #2c2c2c;
|
|
@@ -12,19 +12,19 @@ import { PSmall } from "../uikit/text";
|
|
|
12
12
|
import { ImageView } from "../uikit/image";
|
|
13
13
|
import { ConnectorType, OmniConnector } from "../../core/OmniConnector";
|
|
14
14
|
import { PopupOption, PopupOptionInfo } from "../styles";
|
|
15
|
-
import {
|
|
15
|
+
import { HotKit } from "../../HotKit";
|
|
16
16
|
import { openWalletPicker } from "../router";
|
|
17
17
|
import Popup from "../Popup";
|
|
18
18
|
|
|
19
19
|
interface SelectRecipientProps {
|
|
20
20
|
chain: number;
|
|
21
|
-
|
|
21
|
+
kit: HotKit;
|
|
22
22
|
recipient?: Recipient;
|
|
23
23
|
onSelect: (recipient?: Recipient) => void;
|
|
24
24
|
onClose: () => void;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export const SelectRecipient = observer(({ recipient,
|
|
27
|
+
export const SelectRecipient = observer(({ recipient, kit, chain, onSelect, onClose }: SelectRecipientProps) => {
|
|
28
28
|
const [customAddress, setCustomAddress] = useState<string>(recipient?.address || "");
|
|
29
29
|
const type = chains.get(chain)?.type;
|
|
30
30
|
|
|
@@ -35,7 +35,7 @@ export const SelectRecipient = observer(({ recipient, hot, chain, onSelect, onCl
|
|
|
35
35
|
</Popup>
|
|
36
36
|
);
|
|
37
37
|
|
|
38
|
-
const connectors =
|
|
38
|
+
const connectors = kit.connectors.filter((t) => t.walletTypes.includes(type) && t.type !== ConnectorType.SOCIAL);
|
|
39
39
|
const isError = !Recipient.isValidAddress(chain, customAddress) && customAddress.length > 0;
|
|
40
40
|
|
|
41
41
|
const selectCustom = async () => {
|
|
@@ -2,27 +2,27 @@ import { observer } from "mobx-react-lite";
|
|
|
2
2
|
|
|
3
3
|
import { QRIcon } from "../icons/qr";
|
|
4
4
|
import { ArrowRightIcon } from "../icons/arrow-right";
|
|
5
|
+
import { ImageView } from "../uikit/image";
|
|
6
|
+
|
|
7
|
+
import { HotKit } from "../../HotKit";
|
|
5
8
|
import { PopupOption, PopupOptionInfo } from "../styles";
|
|
9
|
+
import { openWalletPicker } from "../router";
|
|
10
|
+
import Popup from "../Popup";
|
|
6
11
|
|
|
7
12
|
import { ConnectorType, OmniConnector } from "../../core/OmniConnector";
|
|
8
|
-
import { HotConnector } from "../../HotConnector";
|
|
9
13
|
import { OmniWallet } from "../../core/OmniWallet";
|
|
10
|
-
import { ImageView } from "../uikit/image";
|
|
11
|
-
|
|
12
14
|
import { WalletType } from "../../core/chains";
|
|
13
15
|
import { formatter } from "../../core/utils";
|
|
14
|
-
import { openWalletPicker } from "../router";
|
|
15
|
-
import Popup from "../Popup";
|
|
16
16
|
|
|
17
17
|
interface SelectSenderProps {
|
|
18
18
|
type: WalletType;
|
|
19
|
-
|
|
19
|
+
kit: HotKit;
|
|
20
20
|
onClose: () => void;
|
|
21
21
|
onSelect: (wallet?: OmniWallet | "qr") => void;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
export const SelectSender = observer(({
|
|
25
|
-
const connectors =
|
|
24
|
+
export const SelectSender = observer(({ kit, type, onSelect, onClose }: SelectSenderProps) => {
|
|
25
|
+
const connectors = kit.connectors.filter((t) => t.walletTypes.includes(type) && t.type !== ConnectorType.SOCIAL);
|
|
26
26
|
const noExternal = type === WalletType.OMNI || type === WalletType.COSMOS;
|
|
27
27
|
|
|
28
28
|
const selectWallet = async (t: OmniConnector) => {
|
|
@@ -2,7 +2,7 @@ import { useState } from "react";
|
|
|
2
2
|
import { observer } from "mobx-react-lite";
|
|
3
3
|
import styled from "styled-components";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { HotKit } from "../../HotKit";
|
|
6
6
|
import { OmniWallet } from "../../core/OmniWallet";
|
|
7
7
|
|
|
8
8
|
import { Network, OmniToken } from "../../core/chains";
|
|
@@ -16,13 +16,13 @@ import { ImageView } from "../uikit/image";
|
|
|
16
16
|
import { TokenCard } from "./TokenCard";
|
|
17
17
|
|
|
18
18
|
interface SelectTokenPopupProps {
|
|
19
|
-
|
|
19
|
+
kit: HotKit;
|
|
20
20
|
initialChain?: number;
|
|
21
21
|
onClose: () => void;
|
|
22
22
|
onSelect: (token: Token, wallet?: OmniWallet) => void;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export const SelectTokenPopup = observer(({
|
|
25
|
+
export const SelectTokenPopup = observer(({ kit, initialChain, onClose, onSelect }: SelectTokenPopupProps) => {
|
|
26
26
|
const [chain, setChain] = useState<number | null>(initialChain || null);
|
|
27
27
|
const [search, setSearch] = useState<string>("");
|
|
28
28
|
|
|
@@ -37,8 +37,8 @@ export const SelectTokenPopup = observer(({ hot, initialChain, onClose, onSelect
|
|
|
37
37
|
balance: 0,
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
const balance =
|
|
40
|
+
kit.wallets.forEach((wallet) => {
|
|
41
|
+
const balance = kit.balance(wallet, token);
|
|
42
42
|
chains[token.chain].balance += token.float(balance) * token.usd;
|
|
43
43
|
});
|
|
44
44
|
});
|
|
@@ -75,15 +75,15 @@ export const SelectTokenPopup = observer(({ hot, initialChain, onClose, onSelect
|
|
|
75
75
|
{tokens.list
|
|
76
76
|
.filter((token) => token.chain === chain && token.symbol.toLowerCase().includes(search.toLowerCase()))
|
|
77
77
|
.sort((a, b) => {
|
|
78
|
-
const wallet =
|
|
79
|
-
const aBalance = a.float(
|
|
80
|
-
const bBalance = b.float(
|
|
78
|
+
const wallet = kit.wallets.find((w) => w.type === a.type)!;
|
|
79
|
+
const aBalance = a.float(kit.balance(wallet, a)) * a.usd;
|
|
80
|
+
const bBalance = b.float(kit.balance(wallet, b)) * b.usd;
|
|
81
81
|
return bBalance - aBalance;
|
|
82
82
|
})
|
|
83
83
|
.map((token) => {
|
|
84
|
-
const wallet =
|
|
84
|
+
const wallet = kit.wallets.find((w) => w.type === token.type);
|
|
85
85
|
if (search && !token.symbol.toLowerCase().includes(search.toLowerCase())) return;
|
|
86
|
-
return <TokenCard key={token.id} token={token} onSelect={onSelect}
|
|
86
|
+
return <TokenCard key={token.id} token={token} onSelect={onSelect} kit={kit} wallet={wallet} />;
|
|
87
87
|
})}
|
|
88
88
|
</Popup>
|
|
89
89
|
);
|
|
@@ -93,7 +93,7 @@ export const SelectTokenPopup = observer(({ hot, initialChain, onClose, onSelect
|
|
|
93
93
|
return (
|
|
94
94
|
<Popup onClose={onClose} header={<p>Select token</p>}>
|
|
95
95
|
<SearchInput type="text" placeholder="Search token" onChange={(e) => setSearch(e.target.value)} />
|
|
96
|
-
{
|
|
96
|
+
{kit.walletsTokens
|
|
97
97
|
.filter(({ token, balance }) => {
|
|
98
98
|
if (token.chain !== Network.Omni) return false;
|
|
99
99
|
if (token.float(balance) < 0.0001) return false;
|
|
@@ -107,13 +107,13 @@ export const SelectTokenPopup = observer(({ hot, initialChain, onClose, onSelect
|
|
|
107
107
|
return bBalance - aBalance;
|
|
108
108
|
})
|
|
109
109
|
.map(({ token, wallet }) => (
|
|
110
|
-
<TokenCard key={token.id} token={token} onSelect={onSelect}
|
|
110
|
+
<TokenCard key={token.id} token={token} onSelect={onSelect} kit={kit} wallet={wallet} />
|
|
111
111
|
))}
|
|
112
112
|
|
|
113
113
|
{Object.values(OmniToken)
|
|
114
|
-
.filter((token) => !used.has(token) &&
|
|
114
|
+
.filter((token) => !used.has(token) && kit.omni(token).symbol.toLowerCase().includes(search.toLowerCase()))
|
|
115
115
|
.map((token) => (
|
|
116
|
-
<TokenCard key={token} token={
|
|
116
|
+
<TokenCard key={token} token={kit.omni(token)} onSelect={onSelect} kit={kit} wallet={kit.priorityWallet} />
|
|
117
117
|
))}
|
|
118
118
|
</Popup>
|
|
119
119
|
);
|
|
@@ -5,44 +5,51 @@ import { chains } from "../../core/chains";
|
|
|
5
5
|
import { formatter } from "../../core/utils";
|
|
6
6
|
import { Token } from "../../core/token";
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { HotKit } from "../../HotKit";
|
|
9
9
|
import { OmniWallet } from "../../core/OmniWallet";
|
|
10
10
|
import { ImageView } from "../uikit/image";
|
|
11
11
|
|
|
12
|
-
export const TokenIcon = observer(({ token, wallet, withoutChain, size = 40 }: { token: Token; wallet?: OmniWallet; withoutChain?: boolean; size?: number }) => {
|
|
12
|
+
export const TokenIcon = observer(({ token, wallet, withoutChain, size = 40 }: { token: Token; wallet?: OmniWallet | "qr"; withoutChain?: boolean; size?: number }) => {
|
|
13
13
|
return (
|
|
14
14
|
<div style={{ position: "relative", width: size, height: size, flexShrink: 0 }}>
|
|
15
15
|
<ImageView src={token.icon} alt={token.symbol} size={size} />
|
|
16
16
|
{!withoutChain && <ImageView src={token.chainIcon} alt={token.symbol} size={size / 2 - 6} style={{ position: "absolute", bottom: 0, right: 0 }} />}
|
|
17
|
-
{token.isOmni && wallet?.type && <ImageView src={wallet.icon} alt={chains.getByType(wallet.type)?.[0]?.name || ""} size={size / 2 - 6} style={{ position: "absolute", bottom: 0, left: 0 }} />}
|
|
17
|
+
{token.isOmni && wallet !== "qr" && wallet?.type && <ImageView src={wallet.icon} alt={chains.getByType(wallet.type)?.[0]?.name || ""} size={size / 2 - 6} style={{ position: "absolute", bottom: 0, left: 0 }} />}
|
|
18
18
|
</div>
|
|
19
19
|
);
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
interface TokenCardProps<T extends OmniWallet | "qr"> {
|
|
23
|
+
token: Token;
|
|
24
|
+
onSelect?: (token: Token, wallet?: T) => void;
|
|
25
|
+
amount?: bigint;
|
|
26
|
+
kit: HotKit;
|
|
27
|
+
wallet?: T;
|
|
28
|
+
rightControl?: React.ReactNode;
|
|
29
|
+
}
|
|
26
30
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
export const TokenCard = observer(<T extends OmniWallet | "qr">({ token, onSelect, amount, kit, wallet, rightControl }: TokenCardProps<T>) => {
|
|
32
|
+
const balance = amount || (wallet === "qr" ? 0n : kit.balance(wallet, token));
|
|
33
|
+
const symbol = token.isOmni && !token.isMainOmni ? `${token.symbol} (${token.originalChainSymbol})` : token.symbol;
|
|
30
34
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
</TokenWrap>
|
|
35
|
+
return (
|
|
36
|
+
<Card key={token.id} onClick={() => onSelect?.(token, wallet)}>
|
|
37
|
+
<TokenIcon token={token} wallet={wallet} />
|
|
35
38
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
<TokenWrap>
|
|
40
|
+
<Text style={{ textAlign: "left" }}>{symbol}</Text>
|
|
41
|
+
<PSmall style={{ textAlign: "left" }}>${formatter.amount(token.usd)}</PSmall>
|
|
42
|
+
</TokenWrap>
|
|
43
|
+
|
|
44
|
+
{rightControl || (
|
|
45
|
+
<TokenWrap style={{ textAlign: "right", paddingRight: 4, marginLeft: "auto", alignItems: "flex-end" }}>
|
|
46
|
+
<Text>{token.readable(balance)}</Text>
|
|
47
|
+
<PSmall>${token.readable(balance, token.usd)}</PSmall>
|
|
48
|
+
</TokenWrap>
|
|
49
|
+
)}
|
|
50
|
+
</Card>
|
|
51
|
+
);
|
|
52
|
+
});
|
|
46
53
|
|
|
47
54
|
const Card = styled.div`
|
|
48
55
|
display: flex;
|
|
@@ -19,7 +19,7 @@ const Loader: React.FC = () => {
|
|
|
19
19
|
);
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
const
|
|
22
|
+
export const AuthPopup: React.FC<AuthIntentPopupProps> = ({ onApprove, onReject }) => {
|
|
23
23
|
const [loading, setLoading] = useState(false);
|
|
24
24
|
|
|
25
25
|
const handleApprove = async () => {
|
|
@@ -53,26 +53,3 @@ const AuthIntentPopupComponent: React.FC<AuthIntentPopupProps> = ({ onApprove, o
|
|
|
53
53
|
</Popup>
|
|
54
54
|
);
|
|
55
55
|
};
|
|
56
|
-
|
|
57
|
-
export const openAuthPopup = <T,>(wallet: OmniWallet, then: () => Promise<T>) => {
|
|
58
|
-
return new Promise<T>((resolve, reject) => {
|
|
59
|
-
present((close) => {
|
|
60
|
-
return (
|
|
61
|
-
<AuthIntentPopupComponent
|
|
62
|
-
wallet={wallet}
|
|
63
|
-
onReject={() => (close(), reject())}
|
|
64
|
-
onApprove={async () => {
|
|
65
|
-
try {
|
|
66
|
-
const result = await then();
|
|
67
|
-
resolve(result);
|
|
68
|
-
} catch (e) {
|
|
69
|
-
reject(e);
|
|
70
|
-
} finally {
|
|
71
|
-
close();
|
|
72
|
-
}
|
|
73
|
-
}}
|
|
74
|
-
/>
|
|
75
|
-
);
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { observer } from "mobx-react-lite";
|
|
2
2
|
|
|
3
3
|
import { OmniWallet } from "../../core/OmniWallet";
|
|
4
|
-
import {
|
|
4
|
+
import { HotKit } from "../../HotKit";
|
|
5
5
|
import { ConnectorType, OmniConnector } from "../../core/OmniConnector";
|
|
6
6
|
|
|
7
7
|
import { formatter } from "../../core/utils";
|
|
@@ -14,16 +14,16 @@ import { ImageView } from "../uikit/image";
|
|
|
14
14
|
import Popup from "../Popup";
|
|
15
15
|
|
|
16
16
|
interface MultichainPopupProps {
|
|
17
|
-
|
|
17
|
+
kit: HotKit;
|
|
18
18
|
onClose: (wallet?: OmniWallet) => void;
|
|
19
19
|
title?: string;
|
|
20
20
|
walletType?: WalletType;
|
|
21
21
|
widget?: boolean;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
export const Connector = observer(({
|
|
25
|
-
const onechain =
|
|
26
|
-
const social =
|
|
24
|
+
export const Connector = observer(({ kit, onClose, title, walletType, widget }: MultichainPopupProps) => {
|
|
25
|
+
const onechain = kit.connectors.filter((t) => t.type === ConnectorType.WALLET && (walletType == null || t.walletTypes.includes(walletType as WalletType)) && t.options.length > 0);
|
|
26
|
+
const social = kit.connectors.filter((t) => t.type === ConnectorType.SOCIAL && (walletType == null || t.walletTypes.includes(walletType as WalletType)));
|
|
27
27
|
|
|
28
28
|
const selectConnector = async (t: OmniConnector) => {
|
|
29
29
|
if (t.wallets[0]) return t.disconnect();
|