@hot-labs/kit 1.6.2 → 1.6.4
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/build/core/exchange.d.ts +1 -1
- package/build/core/exchange.js +4 -8
- package/build/core/exchange.js.map +1 -1
- package/build/core/recipient.d.ts +2 -0
- package/build/core/recipient.js +7 -0
- package/build/core/recipient.js.map +1 -1
- package/build/cosmos/connector.d.ts +8 -5
- package/build/cosmos/connector.js +26 -7
- package/build/cosmos/connector.js.map +1 -1
- package/build/ui/bridge/Bridge.js +22 -4
- package/build/ui/bridge/Bridge.js.map +1 -1
- package/build/ui/bridge/SelectSender.d.ts +4 -1
- package/build/ui/bridge/SelectSender.js +36 -7
- package/build/ui/bridge/SelectSender.js.map +1 -1
- package/build/ui/bridge/TokenAmountCard.d.ts +2 -4
- package/build/ui/bridge/TokenAmountCard.js +3 -8
- package/build/ui/bridge/TokenAmountCard.js.map +1 -1
- package/build/ui/icons/hex.d.ts +1 -0
- package/build/ui/icons/hex.js +5 -0
- package/build/ui/icons/hex.js.map +1 -0
- package/build/ui/profile/DepositFlow.js +40 -10
- package/build/ui/profile/DepositFlow.js.map +1 -1
- package/build/ui/profile/Payment.js +4 -3
- package/build/ui/profile/Payment.js.map +1 -1
- package/build/ui/profile/Profile.js +11 -11
- package/build/ui/profile/Profile.js.map +1 -1
- package/build/ui/router.d.ts +2 -0
- package/build/ui/router.js.map +1 -1
- package/package.json +1 -1
- package/src/core/exchange.ts +5 -5
- package/src/core/recipient.ts +9 -0
- package/src/cosmos/connector.ts +32 -10
- package/src/ui/bridge/Bridge.tsx +26 -6
- package/src/ui/bridge/SelectSender.tsx +64 -18
- package/src/ui/bridge/TokenAmountCard.tsx +17 -27
- package/src/ui/icons/hex.tsx +18 -0
- package/src/ui/profile/DepositFlow.tsx +65 -14
- package/src/ui/profile/Payment.tsx +4 -4
- package/src/ui/profile/Profile.tsx +81 -83
- package/src/ui/router.tsx +1 -1
package/src/cosmos/connector.ts
CHANGED
|
@@ -17,6 +17,7 @@ import CosmosWallet from "./wallet";
|
|
|
17
17
|
|
|
18
18
|
declare global {
|
|
19
19
|
interface Window {
|
|
20
|
+
gonkaWallet?: Keplr;
|
|
20
21
|
keplr?: Keplr;
|
|
21
22
|
leap?: Keplr;
|
|
22
23
|
}
|
|
@@ -24,12 +25,19 @@ declare global {
|
|
|
24
25
|
|
|
25
26
|
const wallets: Record<string, OmniConnectorOption> = {
|
|
26
27
|
gonkaWallet: {
|
|
27
|
-
name: "
|
|
28
|
+
name: "GG Wallet",
|
|
29
|
+
icon: "https://avatars.githubusercontent.com/u/260310621?v=4",
|
|
30
|
+
download: "https://chromewebstore.google.com/detail/gg-wallet/elicodfmaffbndngiifcpmammicgjidd",
|
|
31
|
+
type: "extension",
|
|
32
|
+
id: "gonkaWallet",
|
|
33
|
+
},
|
|
34
|
+
tgGonkaWallet: {
|
|
35
|
+
name: "Gonka Telegram Wallet",
|
|
28
36
|
icon: "https://gonka-wallet.startonus.com/images/logo.png",
|
|
29
37
|
download: "https://t.me/gonka_wallet",
|
|
30
38
|
deeplink: "https://wallet.gonka.top/wc?wc=",
|
|
31
39
|
type: "external",
|
|
32
|
-
id: "
|
|
40
|
+
id: "tgGonkaWallet",
|
|
33
41
|
},
|
|
34
42
|
keplr: {
|
|
35
43
|
name: "Keplr Wallet",
|
|
@@ -77,6 +85,14 @@ export default class CosmosConnector extends OmniConnector<CosmosWallet> {
|
|
|
77
85
|
else await this.disconnect();
|
|
78
86
|
}
|
|
79
87
|
|
|
88
|
+
if (data.type === "gonkaWallet" && window.gonkaWallet) {
|
|
89
|
+
await this.createKeplrWallet({
|
|
90
|
+
wallet: window.gonkaWallet,
|
|
91
|
+
account: data[this.chainId],
|
|
92
|
+
isNew: false,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
80
96
|
if (data.type === "leap" && window.leap) {
|
|
81
97
|
await this.createKeplrWallet({
|
|
82
98
|
wallet: window.leap,
|
|
@@ -120,7 +136,7 @@ export default class CosmosConnector extends OmniConnector<CosmosWallet> {
|
|
|
120
136
|
return chains.getByType(WalletType.COSMOS).map((t) => t.key);
|
|
121
137
|
}
|
|
122
138
|
|
|
123
|
-
async getAccountFromWalletConnect(wc: UniversalProvider, chainId: string, id?:
|
|
139
|
+
async getAccountFromWalletConnect(wc: UniversalProvider, chainId: string, id?: keyof typeof wallets) {
|
|
124
140
|
const properties = JSON.parse(wc.session?.sessionProperties?.keys || "{}");
|
|
125
141
|
const account = properties?.find?.((t: any) => t.chainId === chainId);
|
|
126
142
|
|
|
@@ -147,7 +163,7 @@ export default class CosmosConnector extends OmniConnector<CosmosWallet> {
|
|
|
147
163
|
return { publicKey: hex.encode(base64.decode(data[0].pubkey)), address: data[0].address };
|
|
148
164
|
}
|
|
149
165
|
|
|
150
|
-
async createWalletConnect({ id, isNew }: { id?:
|
|
166
|
+
async createWalletConnect({ id, isNew }: { id?: keyof typeof wallets; isNew: boolean }): Promise<CosmosWallet> {
|
|
151
167
|
const wc = await this.wc;
|
|
152
168
|
if (!wc) throw new Error("WalletConnect not found");
|
|
153
169
|
|
|
@@ -248,10 +264,10 @@ export default class CosmosConnector extends OmniConnector<CosmosWallet> {
|
|
|
248
264
|
return this.setWallet({ wallet: instance, isNew });
|
|
249
265
|
}
|
|
250
266
|
|
|
251
|
-
async
|
|
267
|
+
async connectGonkaTelegramWallet(): Promise<OmniWallet | { qrcode: string; deeplink?: string; task: Promise<OmniWallet> }> {
|
|
252
268
|
const result = await this.connectWalletConnect({
|
|
253
|
-
onConnect: async () => await this.createWalletConnect({ id: "
|
|
254
|
-
deeplink: wallets["
|
|
269
|
+
onConnect: async () => await this.createWalletConnect({ id: "tgGonkaWallet", isNew: true }),
|
|
270
|
+
deeplink: wallets["tgGonkaWallet"].deeplink,
|
|
255
271
|
namespaces: {
|
|
256
272
|
cosmos: {
|
|
257
273
|
chains: [...new Set([`cosmos:${this.chainId}`, "cosmos:cosmoshub-4"])],
|
|
@@ -266,8 +282,8 @@ export default class CosmosConnector extends OmniConnector<CosmosWallet> {
|
|
|
266
282
|
return result;
|
|
267
283
|
}
|
|
268
284
|
|
|
269
|
-
async connectKeplr(type:
|
|
270
|
-
if (!extension) {
|
|
285
|
+
async connectKeplr(type: keyof typeof wallets, extension?: Keplr): Promise<OmniWallet | { qrcode: string; deeplink?: string; task: Promise<OmniWallet> }> {
|
|
286
|
+
if (!extension && wallets[type].deeplink != null) {
|
|
271
287
|
return await this.connectWalletConnect({
|
|
272
288
|
onConnect: async () => await this.createWalletConnect({ id: type, isNew: true }),
|
|
273
289
|
deeplink: wallets[type].deeplink,
|
|
@@ -282,6 +298,8 @@ export default class CosmosConnector extends OmniConnector<CosmosWallet> {
|
|
|
282
298
|
});
|
|
283
299
|
}
|
|
284
300
|
|
|
301
|
+
if (!extension) throw new Error("Extension not found");
|
|
302
|
+
|
|
285
303
|
if (this.chainId === "gonka-mainnet") {
|
|
286
304
|
await extension.experimentalSuggestChain({
|
|
287
305
|
bech32Config: { bech32PrefixAccAddr: "gonka", bech32PrefixAccPub: "gonka", bech32PrefixValAddr: "gonka", bech32PrefixValPub: "gonka", bech32PrefixConsAddr: "gonka", bech32PrefixConsPub: "gonka" },
|
|
@@ -320,8 +338,12 @@ export default class CosmosConnector extends OmniConnector<CosmosWallet> {
|
|
|
320
338
|
});
|
|
321
339
|
}
|
|
322
340
|
|
|
341
|
+
if (id === "tgGonkaWallet") {
|
|
342
|
+
return await this.connectGonkaTelegramWallet();
|
|
343
|
+
}
|
|
344
|
+
|
|
323
345
|
if (id === "gonkaWallet") {
|
|
324
|
-
return await this.
|
|
346
|
+
return await this.connectKeplr("gonkaWallet", window.gonkaWallet);
|
|
325
347
|
}
|
|
326
348
|
|
|
327
349
|
if (id === "keplr") {
|
package/src/ui/bridge/Bridge.tsx
CHANGED
|
@@ -159,8 +159,7 @@ export const Bridge = observer(({ kit, widget, setup, onClose, onProcess, onStat
|
|
|
159
159
|
try {
|
|
160
160
|
if (currentReviewId !== reviewId.current) return;
|
|
161
161
|
const amount = type === "exactIn" ? from.int(valueInTokens) : to.int(valueInTokens);
|
|
162
|
-
const
|
|
163
|
-
const review = await kit.exchange.reviewSwap({ recipient: recipientWallet, slippage: 0.005, sender, refund: refundWallet, amount, type, from, to });
|
|
162
|
+
const review = await kit.exchange.reviewSwap({ recipient, slippage: 0.005, sender, refund: refundWallet, amount, type, from, to });
|
|
164
163
|
if (currentReviewId !== reviewId.current) return;
|
|
165
164
|
|
|
166
165
|
if (amount > 0) {
|
|
@@ -315,11 +314,32 @@ export const Bridge = observer(({ kit, widget, setup, onClose, onProcess, onStat
|
|
|
315
314
|
readonlyAmount={setup?.readonlyAmount}
|
|
316
315
|
availableBalance={availableBalance}
|
|
317
316
|
isReviewing={isReviewing && type === "exactOut"}
|
|
318
|
-
|
|
317
|
+
handleSelectSender={(token) =>
|
|
318
|
+
kit.router.openSelectSender({
|
|
319
|
+
kit,
|
|
320
|
+
disableQR: true,
|
|
321
|
+
depositFlow: !token.isOmni,
|
|
322
|
+
type: token.type,
|
|
323
|
+
onSelect: (sender) => setSender(sender as OmniWallet),
|
|
324
|
+
onDeposit: () => {
|
|
325
|
+
kit.router.openDepositFlow(kit, from);
|
|
326
|
+
setFrom(tokens.get(from.omniAddress));
|
|
327
|
+
},
|
|
328
|
+
})
|
|
329
|
+
}
|
|
330
|
+
handleSelectToken={() =>
|
|
331
|
+
kit.router.openSelectTokenPopup({
|
|
332
|
+
kit,
|
|
333
|
+
onSelect: (token) => {
|
|
334
|
+
if (sender == null || sender === "qr") setSender(undefined);
|
|
335
|
+
else setSender(kit.wallets.find((w) => w.type === token.type));
|
|
336
|
+
setFrom(token);
|
|
337
|
+
},
|
|
338
|
+
})
|
|
339
|
+
}
|
|
340
|
+
setValue={(v) => (setValue(v), setType("exactIn"))}
|
|
319
341
|
setIsFiat={setIsFiat}
|
|
320
|
-
setSender={setSender}
|
|
321
342
|
handleMax={handleMax}
|
|
322
|
-
setToken={setFrom}
|
|
323
343
|
kit={kit}
|
|
324
344
|
/>
|
|
325
345
|
|
|
@@ -340,7 +360,7 @@ export const Bridge = observer(({ kit, widget, setup, onClose, onProcess, onStat
|
|
|
340
360
|
|
|
341
361
|
<Card style={{ borderRadius: "2px 2px 20px 20px" }}>
|
|
342
362
|
<CardHeader>
|
|
343
|
-
<ChainButton onClick={() => kit.router.openSelectTokenPopup({ kit, onSelect: (token, wallet) => (setTo(token), setRecipient(wallet)) })}>
|
|
363
|
+
<ChainButton onClick={() => kit.router.openSelectTokenPopup({ kit, onSelect: (token, wallet) => (setTo(token), setRecipient(Recipient.fromWallet(wallet))) })}>
|
|
344
364
|
<PSmall>To</PSmall>
|
|
345
365
|
<ImageView src={chains.get(to.chain)?.logo || ""} alt={to.symbol} size={16} />
|
|
346
366
|
<PSmall>{chains.get(to.chain)?.name}</PSmall>
|
|
@@ -2,9 +2,13 @@ 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 { HexIcon } from "../icons/hex";
|
|
6
|
+
|
|
5
7
|
import { ImageView } from "../uikit/image";
|
|
8
|
+
import { PLarge, PMedium, PSmall } from "../uikit/text";
|
|
6
9
|
|
|
7
10
|
import { HotKit } from "../../HotKit";
|
|
11
|
+
import { WalletPicker } from "../connect/WalletPicker";
|
|
8
12
|
import { PopupOption, PopupOptionInfo } from "../styles";
|
|
9
13
|
import { openWalletPicker } from "../router";
|
|
10
14
|
import Popup from "../Popup";
|
|
@@ -13,19 +17,19 @@ import { ConnectorType, OmniConnector } from "../../core/OmniConnector";
|
|
|
13
17
|
import { OmniWallet } from "../../core/OmniWallet";
|
|
14
18
|
import { WalletType } from "../../core/chains";
|
|
15
19
|
import { formatter } from "../../core/utils";
|
|
16
|
-
import
|
|
17
|
-
import { WalletPicker } from "../connect/WalletPicker";
|
|
18
|
-
import { QRAnimation } from "../profile/DepositQR";
|
|
20
|
+
import styled from "styled-components";
|
|
19
21
|
|
|
20
22
|
interface SelectSenderProps {
|
|
21
23
|
type: WalletType;
|
|
22
24
|
kit: HotKit;
|
|
23
25
|
disableQR?: boolean;
|
|
26
|
+
depositFlow?: boolean;
|
|
24
27
|
onClose: () => void;
|
|
25
28
|
onSelect: (wallet?: OmniWallet | "qr") => void;
|
|
29
|
+
onDeposit?: () => void;
|
|
26
30
|
}
|
|
27
31
|
|
|
28
|
-
export const SelectSender = observer(({ kit, type, disableQR, onSelect, onClose }: SelectSenderProps) => {
|
|
32
|
+
export const SelectSender = observer(({ kit, type, depositFlow, disableQR, onDeposit, onSelect, onClose }: SelectSenderProps) => {
|
|
29
33
|
const connectors = kit.connectors.filter((t) => t.walletTypes.includes(type) && t.type !== ConnectorType.SOCIAL);
|
|
30
34
|
const noExternal = type === WalletType.OMNI || type === WalletType.COSMOS;
|
|
31
35
|
|
|
@@ -35,7 +39,7 @@ export const SelectSender = observer(({ kit, type, disableQR, onSelect, onClose
|
|
|
35
39
|
onClose();
|
|
36
40
|
};
|
|
37
41
|
|
|
38
|
-
if (connectors.length === 0 && (noExternal || disableQR)) {
|
|
42
|
+
if (connectors.length === 0 && (noExternal || disableQR) && !depositFlow) {
|
|
39
43
|
return (
|
|
40
44
|
<Popup onClose={onClose} header={<p>Select sender</p>}>
|
|
41
45
|
<div style={{ width: "100%", height: 200, display: "flex", justifyContent: "center", alignItems: "center", flexDirection: "column", gap: 12 }}>
|
|
@@ -49,34 +53,76 @@ export const SelectSender = observer(({ kit, type, disableQR, onSelect, onClose
|
|
|
49
53
|
);
|
|
50
54
|
}
|
|
51
55
|
|
|
52
|
-
if (connectors.length === 1 && (noExternal || disableQR)) {
|
|
56
|
+
if (connectors.length === 1 && (noExternal || disableQR) && !depositFlow) {
|
|
53
57
|
return <WalletPicker initialConnector={connectors[0]} onSelect={onSelect} onClose={onClose} />;
|
|
54
58
|
}
|
|
55
59
|
|
|
56
60
|
return (
|
|
57
61
|
<Popup header={<p>Select sender</p>} onClose={onClose}>
|
|
62
|
+
{connectors.map((t) => (
|
|
63
|
+
<DepositOption key={t.id} onClick={() => selectWallet(t)}>
|
|
64
|
+
<ImageView src={t.icon} alt={t.name} size={44} />
|
|
65
|
+
<PopupOptionInfo>
|
|
66
|
+
<PMedium>{t.name}</PMedium>
|
|
67
|
+
{t.wallets[0]?.address && <PSmall className="wallet-address">{formatter.truncateAddress(t.wallets[0].address)}</PSmall>}
|
|
68
|
+
</PopupOptionInfo>
|
|
69
|
+
{!t.wallets[0]?.address ? <PLarge>Connect</PLarge> : <ArrowRightIcon style={{ flexShrink: 0 }} />}
|
|
70
|
+
</DepositOption>
|
|
71
|
+
))}
|
|
72
|
+
|
|
58
73
|
{!noExternal && !disableQR && (
|
|
59
|
-
<
|
|
74
|
+
<DepositOption onClick={() => (onSelect("qr"), onClose())}>
|
|
60
75
|
<div style={{ width: 44, height: 44, borderRadius: 16, background: "#000", display: "flex", alignItems: "center", justifyContent: "center" }}>
|
|
61
76
|
<QRIcon />
|
|
62
77
|
</div>
|
|
78
|
+
|
|
63
79
|
<PopupOptionInfo>
|
|
64
|
-
<
|
|
65
|
-
<
|
|
80
|
+
<PMedium>Send via QR code</PMedium>
|
|
81
|
+
<PSmall className="wallet-address">From CEX or external wallet</PSmall>
|
|
66
82
|
</PopupOptionInfo>
|
|
67
|
-
</
|
|
83
|
+
</DepositOption>
|
|
68
84
|
)}
|
|
69
85
|
|
|
70
|
-
{
|
|
71
|
-
<
|
|
72
|
-
<
|
|
86
|
+
{depositFlow && (
|
|
87
|
+
<DepositOption onClick={() => (onDeposit?.(), onClose())}>
|
|
88
|
+
<div style={{ width: 44, height: 44, borderRadius: 16, background: "#000", display: "flex", alignItems: "center", justifyContent: "center" }}>
|
|
89
|
+
<HexIcon />
|
|
90
|
+
</div>
|
|
91
|
+
|
|
73
92
|
<PopupOptionInfo>
|
|
74
|
-
<
|
|
75
|
-
|
|
93
|
+
<PMedium>Deposit to HEX Balance</PMedium>
|
|
94
|
+
<PSmall className="wallet-address">Deposit funds from any exchange or external wallet to make your exchanges super fast.</PSmall>
|
|
76
95
|
</PopupOptionInfo>
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
))}
|
|
96
|
+
</DepositOption>
|
|
97
|
+
)}
|
|
80
98
|
</Popup>
|
|
81
99
|
);
|
|
82
100
|
});
|
|
101
|
+
|
|
102
|
+
export const DepositOption = styled.button`
|
|
103
|
+
display: flex;
|
|
104
|
+
padding: 8px;
|
|
105
|
+
align-items: center;
|
|
106
|
+
align-self: stretch;
|
|
107
|
+
cursor: pointer;
|
|
108
|
+
transition: background 0.2s ease-in-out;
|
|
109
|
+
border-radius: 24px;
|
|
110
|
+
outline: none;
|
|
111
|
+
border: none;
|
|
112
|
+
background: transparent;
|
|
113
|
+
width: 100%;
|
|
114
|
+
gap: 12px;
|
|
115
|
+
margin-top: 4px;
|
|
116
|
+
|
|
117
|
+
img {
|
|
118
|
+
width: 44px;
|
|
119
|
+
height: 44px;
|
|
120
|
+
border-radius: 16px;
|
|
121
|
+
object-fit: cover;
|
|
122
|
+
flex-shrink: 0;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
&:hover {
|
|
126
|
+
background: rgba(255, 255, 255, 0.04);
|
|
127
|
+
}
|
|
128
|
+
`;
|
|
@@ -20,15 +20,13 @@ import { TokenIcon } from "./TokenCard";
|
|
|
20
20
|
interface TokenAmountCardProps {
|
|
21
21
|
setValue: (value: string) => void;
|
|
22
22
|
setIsFiat: (isFiat: boolean) => void;
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
handleSelectSender: (token: Token) => void;
|
|
24
|
+
handleSelectToken: () => void;
|
|
25
25
|
handleMax: () => void;
|
|
26
26
|
|
|
27
27
|
kit: HotKit;
|
|
28
28
|
style?: React.CSSProperties;
|
|
29
|
-
disableChains?: number[];
|
|
30
29
|
|
|
31
|
-
disableQR?: boolean;
|
|
32
30
|
sender: OmniWallet | "qr" | undefined;
|
|
33
31
|
isReviewing: boolean;
|
|
34
32
|
readonlyAmount?: boolean;
|
|
@@ -40,43 +38,35 @@ interface TokenAmountCardProps {
|
|
|
40
38
|
}
|
|
41
39
|
|
|
42
40
|
export const TokenAmountCard = observer((props: TokenAmountCardProps) => {
|
|
43
|
-
const { style, token, sender, kit, isReviewing, isFiat, amount,
|
|
44
|
-
const { setValue, setIsFiat,
|
|
41
|
+
const { style, token, sender, kit, isReviewing, isFiat, amount, readableAmount, availableBalance, readonlyAmount } = props;
|
|
42
|
+
const { setValue, setIsFiat, handleSelectToken, handleSelectSender, handleMax } = props;
|
|
45
43
|
|
|
46
44
|
return (
|
|
47
45
|
<Card style={{ borderRadius: "20px 20px 2px 2px", ...style }}>
|
|
48
46
|
<CardHeader>
|
|
49
|
-
<ChainButton onClick={() =>
|
|
47
|
+
<ChainButton onClick={() => handleSelectToken()}>
|
|
50
48
|
<PSmall>From:</PSmall>
|
|
51
49
|
{token != null && <ImageView src={chains.get(token.chain)?.logo || ""} alt={token.symbol} size={16} />}
|
|
52
50
|
<PSmall>{token != null ? chains.get(token.chain)?.name : "Select chain"}</PSmall>
|
|
53
51
|
<ArrowRightIcon style={{ marginLeft: -8, transform: "rotate(-270deg)" }} color="#ababab" />
|
|
54
52
|
</ChainButton>
|
|
55
53
|
|
|
56
|
-
|
|
57
|
-
<
|
|
58
|
-
|
|
59
|
-
<
|
|
60
|
-
|
|
61
|
-
<
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
54
|
+
{token != null && (
|
|
55
|
+
<div style={{ display: "flex", alignItems: "center", gap: 8 }}>
|
|
56
|
+
<PSmall>Sender:</PSmall>
|
|
57
|
+
<BadgeButton onClick={() => handleSelectSender(token)}>
|
|
58
|
+
<PSmall>{sender == null ? "Select" : sender !== "qr" ? formatter.truncateAddress(sender.address, 8) : "QR"}</PSmall>
|
|
59
|
+
<Tooltip id="sender-tooltip">
|
|
60
|
+
<PSmall>Select sender wallet</PSmall>
|
|
61
|
+
</Tooltip>
|
|
62
|
+
</BadgeButton>
|
|
63
|
+
</div>
|
|
64
|
+
)}
|
|
65
65
|
</CardHeader>
|
|
66
66
|
|
|
67
67
|
<CardBody>
|
|
68
68
|
<div style={{ width: "100%", display: "flex", alignItems: "center", gap: 8, justifyContent: "space-between" }}>
|
|
69
|
-
<TokenPreview
|
|
70
|
-
token={token}
|
|
71
|
-
onSelect={() =>
|
|
72
|
-
kit.router.openSelectTokenPopup({
|
|
73
|
-
onSelect: (token, wallet) => (setToken(token), setSender(wallet)),
|
|
74
|
-
disableChains: disableChains,
|
|
75
|
-
initialChain: token?.chain,
|
|
76
|
-
kit,
|
|
77
|
-
})
|
|
78
|
-
}
|
|
79
|
-
/>
|
|
69
|
+
<TokenPreview token={token} onSelect={handleSelectToken} />
|
|
80
70
|
|
|
81
71
|
{isReviewing ? (
|
|
82
72
|
<Skeleton />
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const HexIcon = (props: React.SVGProps<SVGSVGElement>) => {
|
|
2
|
+
return (
|
|
3
|
+
<svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
|
|
4
|
+
<path
|
|
5
|
+
d="M16.7188 18.2763C16.533 18.2668 16.3487 18.3144 16.1907 18.4125C16.0383 18.5418 15.9419 18.7251 15.9217 18.924C15.8628 19.2873 15.8372 19.6553 15.8453 20.0233V22.0161C15.8596 22.4509 15.7977 22.8847 15.6626 23.2982C15.5671 23.5817 15.4183 23.8444 15.2242 24.0721C15.0809 24.2343 14.918 24.3782 14.7393 24.5005C14.9111 24.6238 15.0683 24.7665 15.2076 24.9256C15.3966 25.142 15.5471 25.3891 15.6526 25.6563C15.7925 26.0205 15.8581 26.409 15.8453 26.7989V28.9943C15.8371 29.3623 15.8626 29.7303 15.9217 30.0937C15.9431 30.2931 16.0392 30.477 16.1907 30.6085C16.3498 30.7039 16.5335 30.7501 16.7188 30.7413H17.4728V32.1164H16.3999C16.1209 32.1164 15.8486 32.1164 15.5862 32.0931C15.3394 32.0789 15.0988 32.0096 14.8821 31.8905C14.6441 31.7343 14.4688 31.499 14.3872 31.2263C14.2448 30.7881 14.1818 30.3281 14.2012 29.8678V27.2107C14.2007 26.8906 14.156 26.5721 14.0684 26.2641C13.9873 25.9749 13.8393 25.7087 13.6366 25.487C13.5389 25.3776 13.4184 25.2911 13.2835 25.2337C13.1485 25.1763 13.0026 25.1493 12.8561 25.1548V23.7765C13.0021 23.778 13.1468 23.7494 13.2811 23.6922C13.4155 23.635 13.5365 23.5506 13.6366 23.4443C13.8394 23.2193 13.9862 22.9496 14.0651 22.6572C14.154 22.3461 14.1987 22.0241 14.1979 21.7006V18.914C14.1781 18.4999 14.2437 18.0861 14.3905 17.6984C14.4918 17.4592 14.6647 17.2573 14.8854 17.1205C15.1009 17.0042 15.3387 16.9352 15.5829 16.9179C15.8453 16.8946 16.1177 16.8846 16.3967 16.8846H17.4694V18.2763H16.7188Z"
|
|
6
|
+
fill="white"
|
|
7
|
+
/>
|
|
8
|
+
<path
|
|
9
|
+
d="M31.2895 30.7281C31.4835 30.7404 31.6767 30.6941 31.8441 30.5952C31.9906 30.4583 32.0826 30.2731 32.1032 30.0737C32.1631 29.7127 32.1887 29.3469 32.1796 28.981V26.769C32.1679 26.3824 32.2335 25.9974 32.3722 25.6364C32.4765 25.3663 32.6308 25.1184 32.8272 24.9057C32.9662 24.7555 33.121 24.6207 33.2889 24.5038C33.1224 24.374 32.9648 24.2331 32.8173 24.082C32.6194 23.8749 32.4657 23.6297 32.3656 23.3613C32.2314 22.9969 32.1682 22.6102 32.1796 22.2221V20.0067C32.19 19.6353 32.1644 19.2638 32.1032 18.8974C32.0827 18.7055 31.9901 18.5286 31.8441 18.4025C31.6754 18.3074 31.4827 18.2636 31.2895 18.2763H30.5521V16.8846H31.6249C31.884 16.8846 32.143 16.8846 32.4054 16.9112C32.6515 16.9224 32.892 16.9882 33.1096 17.1038C33.3391 17.2375 33.5169 17.4446 33.6144 17.6917C33.7617 18.0759 33.8273 18.4865 33.807 18.8974V21.5545C33.8087 21.7981 33.8287 22.0412 33.8668 22.2818C33.9049 22.5377 33.9718 22.7883 34.0661 23.0292C34.1533 23.253 34.2949 23.4516 34.4779 23.6071C34.6642 23.7616 34.9003 23.843 35.1422 23.8362V25.2279C34.8991 25.2204 34.662 25.3046 34.4779 25.4637C34.2978 25.6218 34.1568 25.8197 34.0661 26.0416C33.9709 26.2787 33.9041 26.5262 33.8668 26.779C33.8282 27.0262 33.8082 27.276 33.807 27.5263V30.1103C33.8272 30.5182 33.7651 30.9259 33.6244 31.3093C33.5283 31.5526 33.3527 31.7563 33.1262 31.8872C32.9082 32.0023 32.6681 32.0691 32.422 32.0832C32.1597 32.0998 31.8939 32.1064 31.6249 32.1064H30.5521V30.7314L31.2895 30.7281Z"
|
|
10
|
+
fill="white"
|
|
11
|
+
/>
|
|
12
|
+
<path
|
|
13
|
+
d="M18.5656 28.5852C18.4237 28.4622 18.3115 28.3087 18.2373 28.1361C18.1631 27.9636 18.1289 27.7765 18.1372 27.5888C18.1316 27.3527 18.2186 27.1238 18.3797 26.9511C18.4495 26.8686 18.5365 26.8024 18.6346 26.757C18.7327 26.7117 18.8395 26.6884 18.9476 26.6887C19.3428 26.6887 19.572 26.9312 19.6119 27.4128C19.6717 27.8379 19.8244 28.0505 20.0736 28.0505C20.2534 28.0481 20.4275 27.9862 20.5684 27.8745C20.7956 27.6695 20.9914 27.4322 21.1497 27.1703L23.3849 23.9686L24.285 23.5733L25.6136 21.5539C25.9178 21.071 26.2993 20.6412 26.7428 20.2819C27.0928 20.0139 27.521 19.8681 27.9618 19.8667C28.3196 19.8475 28.6726 19.9557 28.9582 20.1722C29.0742 20.2594 29.1684 20.3722 29.2335 20.5019C29.2986 20.6315 29.3329 20.7745 29.3335 20.9196C29.3405 21.188 29.2549 21.4508 29.091 21.6635C29.027 21.7565 28.9419 21.833 28.8425 21.8867C28.7432 21.9404 28.6326 21.9698 28.5198 21.9724C28.4385 21.9801 28.3565 21.9704 28.2792 21.9441C28.2019 21.9177 28.1311 21.8753 28.0714 21.8196C27.9593 21.6798 27.887 21.5122 27.8621 21.3347C27.8409 21.166 27.7807 21.0045 27.6861 20.8631C27.6448 20.8033 27.589 20.7549 27.524 20.7224C27.4589 20.6898 27.3868 20.6743 27.3141 20.6771C27.0708 20.6849 26.837 20.7737 26.6499 20.9295C26.3631 21.1773 26.1185 21.4701 25.9258 21.7964L24.5209 23.8822L23.6008 24.2974L21.4054 27.5224C21.1499 27.9287 20.8353 28.2947 20.4721 28.6085C20.2089 28.824 19.879 28.9414 19.5388 28.9406C19.182 28.9444 18.8361 28.818 18.5656 28.5852ZM24.1256 28.2332C23.6307 27.7516 23.2554 26.9777 23.0096 25.9082L22.1295 22.1584C22.0457 21.7048 21.8981 21.2653 21.691 20.8531C21.6291 20.74 21.537 20.6463 21.425 20.5824C21.3131 20.5185 21.1855 20.4869 21.0567 20.4911C20.9175 20.5012 20.7821 20.5405 20.6591 20.6063C20.5361 20.6721 20.4282 20.7629 20.3426 20.8731C20.0549 21.225 19.8617 21.6446 19.7813 22.092C19.7813 22.1783 19.7016 22.2215 19.5853 22.2215C19.5416 22.2219 19.4992 22.2066 19.4658 22.1783C19.4471 22.1631 19.4339 22.1423 19.4279 22.119C19.4219 22.0957 19.4235 22.0711 19.4325 22.0488C19.5229 21.4229 19.824 20.8465 20.2861 20.4147C20.7665 20.0378 21.3668 19.8467 21.9767 19.8766C22.3302 19.8654 22.6824 19.9255 23.0123 20.0533C23.3421 20.1811 23.6428 20.3741 23.8964 20.6206C24.4013 21.1188 24.7633 21.8927 24.9825 22.9456L25.6833 25.8186C25.7834 26.3551 25.9267 26.8827 26.1118 27.3962C26.1933 27.6518 26.328 27.8872 26.507 28.087C26.6366 28.2017 26.8058 28.2613 26.9787 28.2531C27.1217 28.2453 27.2603 28.2008 27.3813 28.1241C27.5023 28.0473 27.6015 27.9408 27.6695 27.8147C27.8973 27.4461 28.0507 27.0365 28.1212 26.609C28.1478 26.4895 28.2009 26.433 28.274 26.433C28.347 26.433 28.4201 26.4895 28.4068 26.609C28.3999 27.2309 28.1633 27.8283 27.7425 28.2863C27.5097 28.5157 27.2311 28.6935 26.9249 28.8079C26.6188 28.9224 26.2919 28.971 25.9656 28.9506C25.6264 28.9614 25.2885 28.9034 24.9722 28.7801C24.656 28.6568 24.368 28.4708 24.1256 28.2332Z"
|
|
14
|
+
fill="white"
|
|
15
|
+
/>
|
|
16
|
+
</svg>
|
|
17
|
+
);
|
|
18
|
+
};
|
|
@@ -30,14 +30,17 @@ interface DepositFlowProps {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export const DepositFlow: React.FC<DepositFlowProps> = observer(({ kit, initialToken, onClose, widget }) => {
|
|
33
|
-
const
|
|
33
|
+
const availableChainsToConnect = Array.from(new Set(kit.connectors.flatMap((c) => c.walletTypes)));
|
|
34
|
+
const animations = useAnimations();
|
|
34
35
|
|
|
35
36
|
const [token, setToken] = useState<Token | null>(initialToken ?? null);
|
|
36
37
|
const [state, setState] = useState<"loading" | "success" | "error" | null>(null);
|
|
37
38
|
const [sender, setSender] = useState<OmniWallet | undefined>(kit.wallets.find((w) => w.type === token?.type));
|
|
38
|
-
const animations = useAnimations();
|
|
39
39
|
|
|
40
|
-
const
|
|
40
|
+
const [type, setType] = useState<"external" | "connected">(() => {
|
|
41
|
+
if (token == null) return "connected";
|
|
42
|
+
return availableChainsToConnect.includes(token.type) ? "connected" : "external";
|
|
43
|
+
});
|
|
41
44
|
|
|
42
45
|
const [depositQoute, setDepositQoute] = useState<{
|
|
43
46
|
execute: (sender: OmniWallet, amount: bigint) => Promise<void>;
|
|
@@ -55,6 +58,11 @@ export const DepositFlow: React.FC<DepositFlowProps> = observer(({ kit, initialT
|
|
|
55
58
|
return Recipient.fromWallet(kit.priorityWallet);
|
|
56
59
|
});
|
|
57
60
|
|
|
61
|
+
const selectToken = (token: Token) => {
|
|
62
|
+
if (token.type !== sender?.type) setSender(undefined);
|
|
63
|
+
setToken(token);
|
|
64
|
+
};
|
|
65
|
+
|
|
58
66
|
useEffect(() => {
|
|
59
67
|
setError(null);
|
|
60
68
|
setDepositQoute(null);
|
|
@@ -70,14 +78,14 @@ export const DepositFlow: React.FC<DepositFlowProps> = observer(({ kit, initialT
|
|
|
70
78
|
}, [token, recipient]);
|
|
71
79
|
|
|
72
80
|
useEffect(() => {
|
|
73
|
-
|
|
81
|
+
const availableChainsToConnect = Array.from(new Set(kit.connectors.flatMap((c) => c.walletTypes)));
|
|
82
|
+
if (!availableChainsToConnect) setType("external");
|
|
74
83
|
}, [token]);
|
|
75
84
|
|
|
76
85
|
if (type === "connected") {
|
|
77
86
|
const amountInTokens = isFiat ? +formatter.fromInput(amount) / (token?.usd || 0) : +formatter.fromInput(amount);
|
|
78
87
|
const availableBalance = token != null ? +Math.max(0, token.float(kit.balance(sender, token)) - token.reserve).toFixed(4) : 0;
|
|
79
88
|
const minimumAmount = token?.float(depositQoute?.minAmount ?? 0) ?? 0;
|
|
80
|
-
const isDisabled = amountInTokens <= 0 || amountInTokens > availableBalance || depositQoute == null || minimumAmount > amountInTokens;
|
|
81
89
|
|
|
82
90
|
const handleDeposit = async () => {
|
|
83
91
|
setState("loading");
|
|
@@ -155,7 +163,7 @@ export const DepositFlow: React.FC<DepositFlowProps> = observer(({ kit, initialT
|
|
|
155
163
|
{recipient == null && <PSmall>Choose receiver</PSmall>}
|
|
156
164
|
{recipient != null && (
|
|
157
165
|
<PSmall>
|
|
158
|
-
Deposit to <b style={{ color: "#b4b4b4" }}>{
|
|
166
|
+
Deposit to your <b style={{ color: "#b4b4b4" }}>{recipient.chainName}</b> wallet
|
|
159
167
|
</PSmall>
|
|
160
168
|
)}
|
|
161
169
|
|
|
@@ -164,7 +172,6 @@ export const DepositFlow: React.FC<DepositFlowProps> = observer(({ kit, initialT
|
|
|
164
172
|
|
|
165
173
|
<TokenAmountCard
|
|
166
174
|
kit={kit}
|
|
167
|
-
disableQR
|
|
168
175
|
sender={sender}
|
|
169
176
|
isFiat={isFiat}
|
|
170
177
|
isReviewing={false}
|
|
@@ -172,13 +179,26 @@ export const DepositFlow: React.FC<DepositFlowProps> = observer(({ kit, initialT
|
|
|
172
179
|
token={token ?? undefined}
|
|
173
180
|
availableBalance={availableBalance}
|
|
174
181
|
readableAmount={formatter.fromInput(amount)}
|
|
175
|
-
disableChains={[Network.Omni, Network.HotCraft].concat(tokens.list.filter((t) => !availableChainsToConnect.includes(t.type)).map((t) => t.chain))}
|
|
176
182
|
style={{ marginTop: 12, borderRadius: "20px 20px", overflow: "hidden", marginBottom: 8 }}
|
|
177
|
-
setSender={(sender) => setSender(sender as OmniWallet)}
|
|
178
183
|
handleMax={() => setAmount(String(isFiat ? availableBalance * (token?.usd || 0) : availableBalance))}
|
|
184
|
+
handleSelectSender={(token) =>
|
|
185
|
+
kit.router.openSelectSender({
|
|
186
|
+
onSelect: (sender) => setSender(sender as OmniWallet),
|
|
187
|
+
type: token?.type,
|
|
188
|
+
depositFlow: false,
|
|
189
|
+
disableQR: true,
|
|
190
|
+
kit,
|
|
191
|
+
})
|
|
192
|
+
}
|
|
193
|
+
handleSelectToken={() =>
|
|
194
|
+
kit.router.openSelectTokenPopup({
|
|
195
|
+
kit,
|
|
196
|
+
disableChains: [Network.Omni, Network.HotCraft],
|
|
197
|
+
onSelect: selectToken,
|
|
198
|
+
})
|
|
199
|
+
}
|
|
179
200
|
setValue={setAmount}
|
|
180
201
|
setIsFiat={setIsFiat}
|
|
181
|
-
setToken={setToken}
|
|
182
202
|
/>
|
|
183
203
|
|
|
184
204
|
{minimumAmount > 0 && (
|
|
@@ -190,9 +210,38 @@ export const DepositFlow: React.FC<DepositFlowProps> = observer(({ kit, initialT
|
|
|
190
210
|
</div>
|
|
191
211
|
)}
|
|
192
212
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
213
|
+
{(() => {
|
|
214
|
+
if (token == null) {
|
|
215
|
+
return (
|
|
216
|
+
<ActionButton style={{ marginTop: "auto" }} disabled>
|
|
217
|
+
Deposit
|
|
218
|
+
</ActionButton>
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (!availableChainsToConnect.includes(token?.type)) {
|
|
223
|
+
return (
|
|
224
|
+
<ActionButton style={{ marginTop: "auto" }} onClick={() => setType("external")}>
|
|
225
|
+
Deposit from external wallet
|
|
226
|
+
</ActionButton>
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (sender == null) {
|
|
231
|
+
return (
|
|
232
|
+
<ActionButton style={{ marginTop: "auto" }} onClick={() => kit.router.openSelectSender({ kit, type: token.type, onSelect: (sender) => setSender(sender as OmniWallet) })}>
|
|
233
|
+
Connect {token.chainName} wallet
|
|
234
|
+
</ActionButton>
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const isDisabled = amountInTokens <= 0 || amountInTokens > availableBalance || depositQoute == null || minimumAmount > amountInTokens;
|
|
239
|
+
return (
|
|
240
|
+
<ActionButton style={{ marginTop: "auto" }} disabled={isDisabled} onClick={handleDeposit}>
|
|
241
|
+
Deposit
|
|
242
|
+
</ActionButton>
|
|
243
|
+
);
|
|
244
|
+
})()}
|
|
196
245
|
</Popup>
|
|
197
246
|
);
|
|
198
247
|
}
|
|
@@ -221,12 +270,14 @@ export const DepositFlow: React.FC<DepositFlowProps> = observer(({ kit, initialT
|
|
|
221
270
|
|
|
222
271
|
<Card onClick={() => kit.router.openSelectRecipient({ kit, chain: Network.Omni, onSelect: (r) => setRecipient(r) })}>
|
|
223
272
|
<ImageView src={chains.get(Network.Omni)?.logo || ""} alt="HEX Wallet" size={24} />
|
|
273
|
+
|
|
224
274
|
{recipient == null && <PSmall>Choose receiver</PSmall>}
|
|
225
275
|
{recipient != null && (
|
|
226
276
|
<PSmall>
|
|
227
|
-
Deposit to <b style={{ color: "#b4b4b4" }}>{
|
|
277
|
+
Deposit to your <b style={{ color: "#b4b4b4" }}>{recipient.chainName}</b> wallet
|
|
228
278
|
</PSmall>
|
|
229
279
|
)}
|
|
280
|
+
|
|
230
281
|
<ArrowRightIcon style={{ transform: "rotate(90deg)", marginLeft: "auto" }} />
|
|
231
282
|
</Card>
|
|
232
283
|
|
|
@@ -6,7 +6,7 @@ import { HelpIcon } from "../icons/help";
|
|
|
6
6
|
import { WalletIcon } from "../icons/wallet";
|
|
7
7
|
import { QRIcon } from "../icons/qr";
|
|
8
8
|
|
|
9
|
-
import { Commitment, Intents, tokens } from "../../core";
|
|
9
|
+
import { Commitment, Intents, Recipient, tokens } from "../../core";
|
|
10
10
|
import { BridgeReview } from "../../core/exchange";
|
|
11
11
|
import { BridgePending } from "../../core/pendings";
|
|
12
12
|
import { OmniWallet } from "../../core/OmniWallet";
|
|
@@ -90,7 +90,7 @@ export const Payment = observer(({ kit, intents, title = "Payment", allowedToken
|
|
|
90
90
|
const extra = (needAmount * BigInt(Math.floor(slippage * 1000))) / BigInt(1000);
|
|
91
91
|
return kit.exchange.reviewSwap({
|
|
92
92
|
amount: from.int(payableToken.float(needAmount + extra)),
|
|
93
|
-
recipient: intents.signer
|
|
93
|
+
recipient: Recipient.fromWallet(intents.signer!),
|
|
94
94
|
slippage: slippage,
|
|
95
95
|
sender: wallet,
|
|
96
96
|
type: "exactIn",
|
|
@@ -104,12 +104,12 @@ export const Payment = observer(({ kit, intents, title = "Payment", allowedToken
|
|
|
104
104
|
const exectOutReview = await kit.exchange
|
|
105
105
|
.reviewSwap({
|
|
106
106
|
slippage: isStable ? STABLE_SLIPPAGE : PAY_SLIPPAGE,
|
|
107
|
-
|
|
108
|
-
recipient: intents.signer!,
|
|
107
|
+
recipient: Recipient.fromWallet(intents.signer!),
|
|
109
108
|
amount: needAmount,
|
|
110
109
|
sender: wallet,
|
|
111
110
|
type: "exactOut",
|
|
112
111
|
to: payableToken,
|
|
112
|
+
refund: wallet,
|
|
113
113
|
from,
|
|
114
114
|
})
|
|
115
115
|
.catch((e) => {
|