@hot-labs/kit 1.3.3 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/HotConnector.d.ts +9 -13
- package/build/HotConnector.js +17 -57
- package/build/HotConnector.js.map +1 -1
- package/build/activity.d.ts +1 -1
- package/build/activity.js +8 -8
- package/build/activity.js.map +1 -1
- package/build/core/Intents.d.ts +3 -2
- package/build/core/Intents.js +11 -1
- package/build/core/Intents.js.map +1 -1
- package/build/{OmniConnector.d.ts → core/OmniConnector.d.ts} +4 -4
- package/build/{OmniConnector.js → core/OmniConnector.js} +2 -2
- package/build/core/OmniConnector.js.map +1 -0
- package/build/{OmniWallet.d.ts → core/OmniWallet.d.ts} +19 -13
- package/build/core/OmniWallet.js +97 -0
- package/build/core/OmniWallet.js.map +1 -0
- package/build/core/address.d.ts +25 -0
- package/build/core/address.js +162 -0
- package/build/core/address.js.map +1 -0
- package/build/core/chains.d.ts +1 -1
- package/build/core/chains.js +5 -5
- package/build/core/chains.js.map +1 -1
- package/build/{exchange.d.ts → core/exchange.d.ts} +13 -16
- package/build/{exchange.js → core/exchange.js} +76 -80
- package/build/core/exchange.js.map +1 -0
- package/build/core/index.d.ts +1 -1
- package/build/core/index.js +1 -1
- package/build/core/index.js.map +1 -1
- package/build/core/recipient.d.ts +2 -1
- package/build/core/recipient.js +6 -0
- package/build/core/recipient.js.map +1 -1
- package/build/core/telemetry.d.ts +3 -0
- package/build/core/telemetry.js.map +1 -1
- package/build/core/token.js +3 -3
- package/build/core/token.js.map +1 -1
- package/build/core/tokens.js +1 -1
- package/build/core/tokens.js.map +1 -1
- package/build/core/utils.d.ts +1 -0
- package/build/core/utils.js +19 -0
- package/build/core/utils.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/wallet.d.ts +2 -2
- package/build/cosmos/wallet.js +7 -10
- package/build/cosmos/wallet.js.map +1 -1
- package/build/defaults.d.ts +1 -1
- package/build/defaults.js +2 -2
- package/build/defaults.js.map +1 -1
- package/build/evm/connector.d.ts +4 -4
- package/build/evm/connector.js +10 -4
- package/build/evm/connector.js.map +1 -1
- package/build/evm/wallet.d.ts +5 -5
- package/build/evm/wallet.js +24 -23
- package/build/evm/wallet.js.map +1 -1
- package/build/hot-wallet/google.d.ts +2 -2
- package/build/hot-wallet/google.js +4 -4
- package/build/hot-wallet/google.js.map +1 -1
- package/build/index.d.ts +2 -2
- package/build/index.js +2 -2
- package/build/index.js.map +1 -1
- package/build/near/connector.d.ts +2 -2
- package/build/near/connector.js +8 -3
- package/build/near/connector.js.map +1 -1
- package/build/near/index.d.ts +1 -1
- package/build/near/index.js.map +1 -1
- package/build/near/standalone.d.ts +2 -0
- package/build/near/standalone.js +42 -0
- package/build/near/standalone.js.map +1 -0
- package/build/near/wallet.d.ts +3 -2
- package/build/near/wallet.js +21 -12
- package/build/near/wallet.js.map +1 -1
- package/build/solana/connector.d.ts +4 -4
- package/build/solana/connector.js +11 -4
- package/build/solana/connector.js.map +1 -1
- package/build/solana/wallet.d.ts +3 -3
- package/build/solana/wallet.js +14 -11
- package/build/solana/wallet.js.map +1 -1
- package/build/stellar/connector.d.ts +2 -2
- package/build/stellar/connector.js +3 -2
- package/build/stellar/connector.js.map +1 -1
- package/build/stellar/wallet.d.ts +3 -3
- package/build/stellar/wallet.js +27 -19
- package/build/stellar/wallet.js.map +1 -1
- package/build/ton/connector.d.ts +2 -2
- package/build/ton/connector.js +2 -2
- package/build/ton/connector.js.map +1 -1
- package/build/ton/wallet.d.ts +3 -3
- package/build/ton/wallet.js +26 -17
- package/build/ton/wallet.js.map +1 -1
- package/build/tron/connector.d.ts +2 -2
- package/build/tron/connector.js +1 -1
- package/build/tron/connector.js.map +1 -1
- package/build/tron/wallet.d.ts +2 -2
- package/build/tron/wallet.js +9 -15
- package/build/tron/wallet.js.map +1 -1
- package/build/ui/bridge/Bridge.d.ts +2 -2
- package/build/ui/bridge/Bridge.js +15 -13
- package/build/ui/bridge/Bridge.js.map +1 -1
- package/build/ui/bridge/SelectRecipient.d.ts +3 -3
- package/build/ui/bridge/SelectRecipient.js +8 -7
- package/build/ui/bridge/SelectRecipient.js.map +1 -1
- package/build/ui/bridge/SelectSender.d.ts +1 -1
- package/build/ui/bridge/SelectSender.js +1 -1
- package/build/ui/bridge/SelectSender.js.map +1 -1
- package/build/ui/bridge/SelectToken.d.ts +1 -1
- package/build/ui/bridge/SelectToken.js +2 -2
- package/build/ui/bridge/SelectToken.js.map +1 -1
- package/build/ui/bridge/TokenCard.d.ts +1 -1
- package/build/ui/connect/AuthPopup.d.ts +1 -1
- package/build/ui/connect/ConnectWallet.d.ts +1 -1
- package/build/ui/connect/ConnectWallet.js +1 -1
- package/build/ui/connect/ConnectWallet.js.map +1 -1
- package/build/ui/connect/LogoutPopup.d.ts +1 -1
- package/build/ui/connect/WCPopup.js +1 -1
- package/build/ui/connect/WCPopup.js.map +1 -1
- package/build/ui/connect/WalletPicker.d.ts +2 -2
- package/build/ui/profile/DepositQR.d.ts +1 -1
- package/build/ui/profile/Payment.d.ts +1 -1
- package/build/ui/profile/Payment.js +8 -8
- package/build/ui/profile/Payment.js.map +1 -1
- package/build/ui/profile/Profile.js.map +1 -1
- package/build/ui/router.d.ts +3 -3
- package/examples-node/package.json +17 -0
- package/examples-node/transfer.ts +12 -10
- package/examples-node/withdraw.ts +52 -0
- package/examples-node/yarn.lock +2691 -0
- package/package.json +1 -1
- package/src/HotConnector.ts +16 -60
- package/src/activity.ts +9 -9
- package/src/core/Intents.ts +14 -3
- package/src/{OmniConnector.ts → core/OmniConnector.ts} +4 -6
- package/src/core/OmniWallet.ts +125 -0
- package/src/core/address.ts +155 -0
- package/src/core/chains.ts +5 -5
- package/src/{exchange.ts → core/exchange.ts} +79 -85
- package/src/core/index.ts +1 -1
- package/src/core/recipient.ts +8 -1
- package/src/core/telemetry.ts +4 -0
- package/src/core/token.ts +3 -3
- package/src/core/tokens.ts +1 -1
- package/src/core/utils.ts +16 -0
- package/src/cosmos/connector.ts +3 -3
- package/src/cosmos/wallet.ts +8 -11
- package/src/defaults.ts +2 -2
- package/src/evm/connector.ts +12 -6
- package/src/evm/wallet.ts +24 -25
- package/src/hot-wallet/google.ts +5 -5
- package/src/index.ts +2 -2
- package/src/near/connector.ts +6 -3
- package/src/near/index.ts +2 -1
- package/src/near/standalone.ts +52 -0
- package/src/near/wallet.ts +21 -15
- package/src/solana/connector.ts +15 -6
- package/src/solana/wallet.ts +12 -12
- package/src/stellar/connector.ts +5 -4
- package/src/stellar/wallet.ts +28 -22
- package/src/ton/connector.ts +4 -3
- package/src/ton/wallet.ts +24 -18
- package/src/tron/connector.ts +2 -2
- package/src/tron/wallet.ts +9 -19
- package/src/ui/bridge/Bridge.tsx +18 -16
- package/src/ui/bridge/SelectRecipient.tsx +23 -16
- package/src/ui/bridge/SelectSender.tsx +2 -2
- package/src/ui/bridge/SelectToken.tsx +3 -3
- package/src/ui/bridge/TokenCard.tsx +1 -1
- package/src/ui/connect/AuthPopup.tsx +1 -1
- package/src/ui/connect/ConnectWallet.tsx +2 -2
- package/src/ui/connect/LogoutPopup.tsx +1 -1
- package/src/ui/connect/WCPopup.tsx +1 -1
- package/src/ui/connect/WalletPicker.tsx +2 -2
- package/src/ui/profile/DepositQR.tsx +1 -1
- package/src/ui/profile/Payment.tsx +12 -13
- package/src/ui/profile/Profile.tsx +1 -2
- package/src/ui/router.tsx +3 -3
- package/build/OmniConnector.js.map +0 -1
- package/build/OmniWallet.js +0 -61
- package/build/OmniWallet.js.map +0 -1
- package/build/core/signer.d.ts +0 -51
- package/build/core/signer.js +0 -99
- package/build/core/signer.js.map +0 -1
- package/build/exchange.js.map +0 -1
- package/build/ui/utils.d.ts +0 -1
- package/build/ui/utils.js +0 -20
- package/build/ui/utils.js.map +0 -1
- package/src/OmniWallet.ts +0 -85
- package/src/core/signer.ts +0 -116
- package/src/ui/utils.ts +0 -14
package/src/tron/wallet.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { base58, base64, hex } from "@scure/base";
|
|
2
2
|
|
|
3
|
+
import type { OmniConnector } from "../core/OmniConnector";
|
|
4
|
+
import { OmniWallet } from "../core/OmniWallet";
|
|
3
5
|
import { Network, WalletType } from "../core/chains";
|
|
4
6
|
import { ReviewFee } from "../core/bridge";
|
|
5
7
|
import { Token } from "../core/token";
|
|
6
8
|
import { Commitment } from "../core";
|
|
7
9
|
|
|
8
|
-
import type { OmniConnector } from "../OmniConnector";
|
|
9
|
-
import { OmniWallet } from "../OmniWallet";
|
|
10
|
-
|
|
11
10
|
interface TronWebLike {
|
|
12
11
|
ready?: boolean;
|
|
13
12
|
defaultAddress?: { base58?: string; hex?: string };
|
|
@@ -58,33 +57,24 @@ class TronWallet extends OmniWallet {
|
|
|
58
57
|
}
|
|
59
58
|
|
|
60
59
|
async fetchBalance(chain: number, address: string): Promise<bigint> {
|
|
61
|
-
if (chain !== Network.Tron)
|
|
60
|
+
if (chain !== Network.Tron) return super.fetchBalance(chain, address);
|
|
62
61
|
if (!this.tronWeb.trx) throw new Error("TronLink not available");
|
|
63
62
|
|
|
64
63
|
if (address === "native") {
|
|
65
64
|
const balance = await this.tronWeb.trx.getBalance?.(this.address);
|
|
66
|
-
return BigInt(balance || 0);
|
|
65
|
+
return this.setBalance(`${chain}:${address}`, BigInt(balance || 0));
|
|
67
66
|
}
|
|
68
67
|
|
|
69
|
-
return await this.trc20Balance(address);
|
|
68
|
+
return this.setBalance(`${chain}:${address}`, await this.trc20Balance(address));
|
|
70
69
|
}
|
|
71
70
|
|
|
72
71
|
async fetchBalances(chain: number, whitelist: string[]): Promise<Record<string, bigint>> {
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
if (chain === Network.Omni) return await super.fetchBalances(chain, whitelist);
|
|
75
73
|
try {
|
|
76
|
-
|
|
77
|
-
if (!res.ok) throw new Error("Failed to fetch balances");
|
|
78
|
-
const { balances } = await res.json();
|
|
79
|
-
return { ...balances, native };
|
|
74
|
+
return await super.fetchBalances(chain, whitelist);
|
|
80
75
|
} catch {
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
const balance = await this.fetchBalance(chain, token);
|
|
84
|
-
return [token, balance] as const;
|
|
85
|
-
})
|
|
86
|
-
);
|
|
87
|
-
return { ...Object.fromEntries(balances), native };
|
|
76
|
+
const tasks = whitelist.map(async (token) => [token, await this.fetchBalance(chain, token)]);
|
|
77
|
+
return Object.fromEntries(await Promise.all(tasks));
|
|
88
78
|
}
|
|
89
79
|
}
|
|
90
80
|
|
package/src/ui/bridge/Bridge.tsx
CHANGED
|
@@ -7,27 +7,27 @@ import RefreshIcon from "../icons/refresh";
|
|
|
7
7
|
import { ArrowRightIcon } from "../icons/arrow-right";
|
|
8
8
|
|
|
9
9
|
import { HotConnector } from "../../HotConnector";
|
|
10
|
-
import { BridgeReview } from "../../exchange";
|
|
11
|
-
import { OmniWallet } from "../../OmniWallet";
|
|
10
|
+
import { BridgeReview } from "../../core/exchange";
|
|
11
|
+
import { OmniWallet } from "../../core/OmniWallet";
|
|
12
12
|
|
|
13
|
+
import { chains, WalletType } from "../../core/chains";
|
|
14
|
+
import { Recipient } from "../../core/recipient";
|
|
13
15
|
import { formatter } from "../../core/utils";
|
|
14
16
|
import { tokens } from "../../core/tokens";
|
|
15
|
-
import { Recipient } from "../../core/recipient";
|
|
16
|
-
import { chains, WalletType } from "../../core/chains";
|
|
17
17
|
import { Token } from "../../core/token";
|
|
18
18
|
|
|
19
|
+
import { ActionButton, Button } from "../uikit/button";
|
|
20
|
+
import { PLarge, PSmall, PTiny } from "../uikit/text";
|
|
21
|
+
import { Skeleton } from "../uikit/loader";
|
|
22
|
+
import { ImageView } from "../uikit/image";
|
|
23
|
+
import ExchangeIcon from "../icons/exchange";
|
|
24
|
+
|
|
19
25
|
import Popup from "../Popup";
|
|
20
26
|
import { PopupButton } from "../styles";
|
|
21
|
-
import DepositQR from "../profile/DepositQR";
|
|
22
27
|
import { openSelectRecipient, openSelectSender, openSelectTokenPopup, openWalletPicker } from "../router";
|
|
28
|
+
import DepositQR from "../profile/DepositQR";
|
|
23
29
|
import { TokenIcon } from "./TokenCard";
|
|
24
30
|
|
|
25
|
-
import { PLarge, PMedium, PSmall, PTiny } from "../uikit/text";
|
|
26
|
-
import { Skeleton } from "../uikit/loader";
|
|
27
|
-
import { ImageView } from "../uikit/image";
|
|
28
|
-
import ExchangeIcon from "../icons/exchange";
|
|
29
|
-
import { ActionButton, Button } from "../uikit/button";
|
|
30
|
-
|
|
31
31
|
const animations = {
|
|
32
32
|
success: "https://hex.exchange/success.json",
|
|
33
33
|
failed: "https://hex.exchange/error.json",
|
|
@@ -161,7 +161,8 @@ export const Bridge = observer(({ hot, widget, setup, onClose, onProcess, onSele
|
|
|
161
161
|
try {
|
|
162
162
|
if (currentReviewId !== reviewId.current) return;
|
|
163
163
|
const amount = type === "exactIn" ? from.int(valueInTokens) : to.int(valueInTokens);
|
|
164
|
-
const
|
|
164
|
+
const recipientWallet = hot.wallets.find((w) => w.address === recipient?.address && w.type === recipient?.type) || recipient;
|
|
165
|
+
const review = await hot.exchange.reviewSwap({ recipient: recipientWallet, slippage: 0.005, sender, refund, amount, type, from, to });
|
|
165
166
|
if (currentReviewId !== reviewId.current) return;
|
|
166
167
|
setIsReviewing(false);
|
|
167
168
|
setIsError(null);
|
|
@@ -185,10 +186,11 @@ export const Bridge = observer(({ hot, widget, setup, onClose, onProcess, onSele
|
|
|
185
186
|
const process = async (review: BridgeReview) => {
|
|
186
187
|
try {
|
|
187
188
|
const log = (message: string) => setProcessing({ status: "processing", message, review });
|
|
188
|
-
hot.
|
|
189
|
+
hot.exchange.bridge.logger = { log, warn: console.warn };
|
|
189
190
|
log("Signing transaction");
|
|
190
191
|
|
|
191
|
-
|
|
192
|
+
review.logger = { log };
|
|
193
|
+
const result = await hot.exchange.makeSwap(review);
|
|
192
194
|
let resultReview = result.review;
|
|
193
195
|
|
|
194
196
|
if (result.processing) {
|
|
@@ -259,7 +261,7 @@ export const Bridge = observer(({ hot, widget, setup, onClose, onProcess, onSele
|
|
|
259
261
|
<div style={{ width: "100%", height: 400, display: "flex", justifyContent: "center", alignItems: "center", flexDirection: "column" }}>
|
|
260
262
|
{/* @ts-expect-error: dotlottie-wc is not typed */}
|
|
261
263
|
<dotlottie-wc key="success" src={animations.success} speed="1" style={{ width: 300, height: 300 }} mode="forward" loop autoplay></dotlottie-wc>
|
|
262
|
-
<p style={{ fontSize: 24, marginTop: -32, fontWeight: "bold" }}>
|
|
264
|
+
<p style={{ fontSize: 24, marginTop: -32, fontWeight: "bold" }}>{title} successful</p>
|
|
263
265
|
</div>
|
|
264
266
|
<PopupButton style={{ marginTop: "auto" }} onClick={() => (cancelReview(), onClose())}>
|
|
265
267
|
Continue
|
|
@@ -274,7 +276,7 @@ export const Bridge = observer(({ hot, widget, setup, onClose, onProcess, onSele
|
|
|
274
276
|
<div style={{ width: "100%", height: 400, gap: 8, display: "flex", justifyContent: "center", alignItems: "center", flexDirection: "column" }}>
|
|
275
277
|
{/* @ts-expect-error: dotlottie-wc is not typed */}
|
|
276
278
|
<dotlottie-wc key="error" src={animations.failed} speed="1" style={{ width: 300, height: 300 }} mode="forward" loop autoplay></dotlottie-wc>
|
|
277
|
-
<p style={{ fontSize: 24, marginTop: -32, fontWeight: "bold" }}>
|
|
279
|
+
<p style={{ fontSize: 24, marginTop: -32, fontWeight: "bold" }}>{title} failed</p>
|
|
278
280
|
<p style={{ fontSize: 14 }}>{processing.message}</p>
|
|
279
281
|
</div>
|
|
280
282
|
<ActionButton onClick={() => (cancelReview(), onClose())}>Continue</ActionButton>
|
|
@@ -4,23 +4,23 @@ import { useState } from "react";
|
|
|
4
4
|
|
|
5
5
|
import { ArrowRightIcon } from "../icons/arrow-right";
|
|
6
6
|
|
|
7
|
+
import { Recipient } from "../../core/recipient";
|
|
8
|
+
import { chains, WalletType } from "../../core/chains";
|
|
9
|
+
import { formatter } from "../../core/utils";
|
|
10
|
+
|
|
11
|
+
import { PSmall } from "../uikit/text";
|
|
7
12
|
import { ImageView } from "../uikit/image";
|
|
13
|
+
import { ConnectorType, OmniConnector } from "../../core/OmniConnector";
|
|
8
14
|
import { PopupOption, PopupOptionInfo } from "../styles";
|
|
9
|
-
import { ConnectorType, OmniConnector } from "../../OmniConnector";
|
|
10
15
|
import { HotConnector } from "../../HotConnector";
|
|
11
16
|
import { openWalletPicker } from "../router";
|
|
12
17
|
import Popup from "../Popup";
|
|
13
18
|
|
|
14
|
-
import { Recipient } from "../../core/recipient";
|
|
15
|
-
import { WalletType } from "../../core/chains";
|
|
16
|
-
import { formatter } from "../../core/utils";
|
|
17
|
-
import { PSmall } from "../uikit/text";
|
|
18
|
-
|
|
19
19
|
interface SelectRecipientProps {
|
|
20
|
-
recipient?: Recipient;
|
|
21
20
|
type: WalletType;
|
|
22
|
-
onSelect: (recipient?: Recipient) => void;
|
|
23
21
|
hot: HotConnector;
|
|
22
|
+
recipient?: Recipient;
|
|
23
|
+
onSelect: (recipient?: Recipient) => void;
|
|
24
24
|
onClose: () => void;
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -28,6 +28,8 @@ export const SelectRecipient = observer(({ recipient, hot, type, onSelect, onClo
|
|
|
28
28
|
const connectors = hot.connectors.filter((t) => t.walletTypes.includes(type) && t.type !== ConnectorType.SOCIAL);
|
|
29
29
|
const [customAddress, setCustomAddress] = useState<string>(recipient?.address || "");
|
|
30
30
|
|
|
31
|
+
const isError = !Recipient.isValidAddress(type, customAddress) && customAddress.length > 0;
|
|
32
|
+
|
|
31
33
|
const selectCustom = async () => {
|
|
32
34
|
const recipient = await Recipient.fromAddress(type, customAddress);
|
|
33
35
|
onSelect(recipient);
|
|
@@ -55,14 +57,17 @@ export const SelectRecipient = observer(({ recipient, hot, type, onSelect, onClo
|
|
|
55
57
|
|
|
56
58
|
{type !== WalletType.OMNI && (
|
|
57
59
|
<>
|
|
58
|
-
|
|
59
|
-
<div style={{
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
{connectors.length > 0 && (
|
|
61
|
+
<div style={{ display: "flex", alignItems: "center", gap: 8, width: "100%", margin: "12px 0" }}>
|
|
62
|
+
<div style={{ width: "100%", height: 1, background: "rgba(255,255,255,0.1)" }}></div>
|
|
63
|
+
<PSmall>OR</PSmall>
|
|
64
|
+
<div style={{ width: "100%", height: 1, background: "rgba(255,255,255,0.1)" }}></div>
|
|
65
|
+
</div>
|
|
66
|
+
)}
|
|
67
|
+
|
|
63
68
|
<div style={{ width: "100%" }}>
|
|
64
69
|
<PSmall style={{ textAlign: "left" }}>Enter recipient address, avoid CEX</PSmall>
|
|
65
|
-
<CustomRecipient>
|
|
70
|
+
<CustomRecipient $error={isError}>
|
|
66
71
|
<input //
|
|
67
72
|
type="text"
|
|
68
73
|
placeholder="Enter wallet address"
|
|
@@ -73,6 +78,8 @@ export const SelectRecipient = observer(({ recipient, hot, type, onSelect, onClo
|
|
|
73
78
|
Select
|
|
74
79
|
</button>
|
|
75
80
|
</CustomRecipient>
|
|
81
|
+
|
|
82
|
+
{isError && <PSmall style={{ marginTop: 4, textAlign: "left", color: "#F34747" }}>Invalid {chains.get(type)?.name} address</PSmall>}
|
|
76
83
|
</div>
|
|
77
84
|
</>
|
|
78
85
|
)}
|
|
@@ -80,10 +87,10 @@ export const SelectRecipient = observer(({ recipient, hot, type, onSelect, onClo
|
|
|
80
87
|
);
|
|
81
88
|
});
|
|
82
89
|
|
|
83
|
-
const CustomRecipient = styled.div
|
|
90
|
+
const CustomRecipient = styled.div<{ $error: boolean }>`
|
|
84
91
|
display: flex;
|
|
85
92
|
align-items: center;
|
|
86
|
-
border: 1px solid #2d2d2d;
|
|
93
|
+
border: 1px solid ${({ $error }) => ($error ? "#F34747" : "#2d2d2d")};
|
|
87
94
|
border-radius: 12px;
|
|
88
95
|
overflow: hidden;
|
|
89
96
|
margin-top: 8px;
|
|
@@ -4,9 +4,9 @@ import { QRIcon } from "../icons/qr";
|
|
|
4
4
|
import { ArrowRightIcon } from "../icons/arrow-right";
|
|
5
5
|
import { PopupOption, PopupOptionInfo } from "../styles";
|
|
6
6
|
|
|
7
|
-
import { ConnectorType, OmniConnector } from "../../OmniConnector";
|
|
7
|
+
import { ConnectorType, OmniConnector } from "../../core/OmniConnector";
|
|
8
8
|
import { HotConnector } from "../../HotConnector";
|
|
9
|
-
import { OmniWallet } from "../../OmniWallet";
|
|
9
|
+
import { OmniWallet } from "../../core/OmniWallet";
|
|
10
10
|
import { ImageView } from "../uikit/image";
|
|
11
11
|
|
|
12
12
|
import { WalletType } from "../../core/chains";
|
|
@@ -3,7 +3,7 @@ import { observer } from "mobx-react-lite";
|
|
|
3
3
|
import styled from "styled-components";
|
|
4
4
|
|
|
5
5
|
import { HotConnector } from "../../HotConnector";
|
|
6
|
-
import { OmniWallet } from "../../OmniWallet";
|
|
6
|
+
import { OmniWallet } from "../../core/OmniWallet";
|
|
7
7
|
|
|
8
8
|
import { Network, OmniToken } from "../../core/chains";
|
|
9
9
|
import { formatter } from "../../core/utils";
|
|
@@ -44,7 +44,7 @@ export const SelectTokenPopup = observer(({ hot, initialChain, onClose, onSelect
|
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
const sorted = Object.values(chains).sort((a, b) => {
|
|
47
|
-
if (a.chain === Network.
|
|
47
|
+
if (a.chain === Network.Omni) return -1;
|
|
48
48
|
return b.balance - a.balance;
|
|
49
49
|
});
|
|
50
50
|
|
|
@@ -95,7 +95,7 @@ export const SelectTokenPopup = observer(({ hot, initialChain, onClose, onSelect
|
|
|
95
95
|
<SearchInput type="text" placeholder="Search token" onChange={(e) => setSearch(e.target.value)} />
|
|
96
96
|
{hot.walletsTokens
|
|
97
97
|
.filter(({ token, balance }) => {
|
|
98
|
-
if (token.chain !== Network.
|
|
98
|
+
if (token.chain !== Network.Omni) return false;
|
|
99
99
|
if (token.float(balance) < 0.0001) return false;
|
|
100
100
|
if (!token.symbol.toLowerCase().includes(search.toLowerCase())) return false;
|
|
101
101
|
used.add(token.address);
|
|
@@ -6,7 +6,7 @@ import { formatter } from "../../core/utils";
|
|
|
6
6
|
import { Token } from "../../core/token";
|
|
7
7
|
|
|
8
8
|
import { HotConnector } from "../../HotConnector";
|
|
9
|
-
import { OmniWallet } from "../../OmniWallet";
|
|
9
|
+
import { OmniWallet } from "../../core/OmniWallet";
|
|
10
10
|
import { ImageView } from "../uikit/image";
|
|
11
11
|
|
|
12
12
|
export const TokenIcon = observer(({ token, wallet, withoutChain, size = 40 }: { token: Token; wallet?: OmniWallet; withoutChain?: boolean; size?: number }) => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { observer } from "mobx-react-lite";
|
|
2
2
|
|
|
3
|
-
import { OmniWallet } from "../../OmniWallet";
|
|
3
|
+
import { OmniWallet } from "../../core/OmniWallet";
|
|
4
4
|
import { HotConnector } from "../../HotConnector";
|
|
5
|
-
import { ConnectorType, OmniConnector } from "../../OmniConnector";
|
|
5
|
+
import { ConnectorType, OmniConnector } from "../../core/OmniConnector";
|
|
6
6
|
|
|
7
7
|
import { formatter } from "../../core/utils";
|
|
8
8
|
import { WalletType } from "../../core";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { observer } from "mobx-react-lite";
|
|
2
2
|
|
|
3
3
|
import Popup from "../Popup";
|
|
4
|
-
import { OmniConnector } from "../../OmniConnector";
|
|
4
|
+
import { OmniConnector } from "../../core/OmniConnector";
|
|
5
5
|
import { PopupButton } from "../styles";
|
|
6
6
|
|
|
7
7
|
interface LogoutPopupProps {
|
|
@@ -4,7 +4,7 @@ import QRCodeStyling from "qr-code-styling";
|
|
|
4
4
|
import styled from "styled-components";
|
|
5
5
|
|
|
6
6
|
import Popup from "../Popup";
|
|
7
|
-
import { WC_ICON } from "../../OmniConnector";
|
|
7
|
+
import { WC_ICON } from "../../core/OmniConnector";
|
|
8
8
|
|
|
9
9
|
interface WCPopupProps {
|
|
10
10
|
title: string;
|
|
@@ -2,8 +2,8 @@ import { useState } from "react";
|
|
|
2
2
|
import { observer } from "mobx-react-lite";
|
|
3
3
|
|
|
4
4
|
import { ImageView } from "../uikit/image";
|
|
5
|
-
import { OmniWallet } from "../../OmniWallet";
|
|
6
|
-
import { OmniConnector, OmniConnectorOption } from "../../OmniConnector";
|
|
5
|
+
import { OmniWallet } from "../../core/OmniWallet";
|
|
6
|
+
import { OmniConnector, OmniConnectorOption } from "../../core/OmniConnector";
|
|
7
7
|
import { PopupButton, PopupOption, PopupOptionInfo } from "../styles";
|
|
8
8
|
import { WCPopup } from "./WCPopup";
|
|
9
9
|
import Popup from "../Popup";
|
|
@@ -3,7 +3,7 @@ import QRCodeStyling from "qr-code-styling";
|
|
|
3
3
|
import { observer } from "mobx-react-lite";
|
|
4
4
|
import styled from "styled-components";
|
|
5
5
|
|
|
6
|
-
import { BridgeReview } from "../../exchange";
|
|
6
|
+
import { BridgeReview } from "../../core/exchange";
|
|
7
7
|
import { PopupButton } from "../styles";
|
|
8
8
|
|
|
9
9
|
const DepositQR = observer(({ review, onConfirm, onCancel }: { review: BridgeReview; onConfirm: () => void; onCancel: () => void }) => {
|
|
@@ -5,22 +5,20 @@ import styled from "styled-components";
|
|
|
5
5
|
import { WalletIcon } from "../icons/wallet";
|
|
6
6
|
import { PopupOption, PopupOptionInfo } from "../styles";
|
|
7
7
|
import { Commitment, Intents } from "../../core";
|
|
8
|
-
import { Recipient } from "../../core/recipient";
|
|
9
8
|
import { Token } from "../../core/token";
|
|
10
9
|
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
10
|
+
import { BridgeReview } from "../../core/exchange";
|
|
11
|
+
import { OmniWallet } from "../../core/OmniWallet";
|
|
12
|
+
import { formatter } from "../../core/utils";
|
|
14
13
|
|
|
15
|
-
import {
|
|
14
|
+
import { openConnector } from "../router";
|
|
15
|
+
import { TokenCard } from "../bridge/TokenCard";
|
|
16
16
|
import { HotConnector } from "../../HotConnector";
|
|
17
|
-
import Popup from "../Popup";
|
|
18
|
-
|
|
19
|
-
import { Loader } from "../uikit/loader";
|
|
20
17
|
import { HorizontalStepper } from "../uikit/Stepper";
|
|
21
18
|
import { ActionButton } from "../uikit/button";
|
|
22
19
|
import { H6, PSmall } from "../uikit/text";
|
|
23
|
-
import {
|
|
20
|
+
import { Loader } from "../uikit/loader";
|
|
21
|
+
import Popup from "../Popup";
|
|
24
22
|
|
|
25
23
|
interface PaymentProps {
|
|
26
24
|
onReject: (message: string) => void;
|
|
@@ -78,7 +76,7 @@ export const Payment = observer(({ connector, intents, title = "Payment", allowe
|
|
|
78
76
|
const insurance = (needAmount * BigInt(Math.floor(PAY_SLIPPAGE * 1000))) / BigInt(1000);
|
|
79
77
|
const extra = connector.exchange.isDirectDeposit(from, payableToken) ? insurance : 0n;
|
|
80
78
|
const review = await connector.exchange.reviewSwap({
|
|
81
|
-
recipient:
|
|
79
|
+
recipient: intents.signer!,
|
|
82
80
|
amount: needAmount + extra,
|
|
83
81
|
slippage: PAY_SLIPPAGE,
|
|
84
82
|
sender: wallet,
|
|
@@ -118,7 +116,8 @@ export const Payment = observer(({ connector, intents, title = "Payment", allowe
|
|
|
118
116
|
return;
|
|
119
117
|
}
|
|
120
118
|
|
|
121
|
-
|
|
119
|
+
flow.review.logger = console;
|
|
120
|
+
const result = await connector.exchange.makeSwap(flow.review);
|
|
122
121
|
await onConfirm({ depositQoute: result.review, processing: result.processing });
|
|
123
122
|
setFlow({ loading: false, step: "success" });
|
|
124
123
|
setTimeout(() => close(), 2000);
|
|
@@ -164,9 +163,9 @@ export const Payment = observer(({ connector, intents, title = "Payment", allowe
|
|
|
164
163
|
{/* @ts-expect-error: dotlottie-wc is not typed */}
|
|
165
164
|
<dotlottie-wc key="error" src={animations.failed} speed="1" style={{ width: 300, height: 300 }} mode="forward" loop autoplay></dotlottie-wc>
|
|
166
165
|
<p style={{ fontSize: 24, marginTop: -32, fontWeight: "bold" }}>Transaction failed</p>
|
|
167
|
-
<p style={{ fontSize: 14, width: "80%", textAlign: "center", overflowY: "auto", lineBreak: "anywhere" }}>{serializeError(flow.error)}</p>
|
|
166
|
+
<p style={{ fontSize: 14, width: "80%", textAlign: "center", overflowY: "auto", lineBreak: "anywhere" }}>{formatter.serializeError(flow.error)}</p>
|
|
168
167
|
</div>
|
|
169
|
-
<ActionButton onClick={() => onReject(serializeError(flow.error))}>Close</ActionButton>
|
|
168
|
+
<ActionButton onClick={() => onReject(formatter.serializeError(flow.error))}>Close</ActionButton>
|
|
170
169
|
</Popup>
|
|
171
170
|
);
|
|
172
171
|
}
|
|
@@ -10,9 +10,8 @@ import { formatter } from "../../core/utils";
|
|
|
10
10
|
import { OmniToken } from "../../core/chains";
|
|
11
11
|
import { tokens } from "../../core/tokens";
|
|
12
12
|
|
|
13
|
-
import { openBridge, openConnector } from "../router";
|
|
14
13
|
import { HotConnector } from "../../HotConnector";
|
|
15
|
-
|
|
14
|
+
import { openBridge, openConnector } from "../router";
|
|
16
15
|
import { TokenCard, TokenIcon } from "../bridge/TokenCard";
|
|
17
16
|
import { ImageView } from "../uikit/image";
|
|
18
17
|
import { Loader } from "../uikit/loader";
|
package/src/ui/router.tsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { HotConnector } from "../HotConnector";
|
|
2
|
-
import { OmniConnector } from "../OmniConnector";
|
|
3
|
-
import { OmniWallet } from "../OmniWallet";
|
|
2
|
+
import { OmniConnector } from "../core/OmniConnector";
|
|
3
|
+
import { OmniWallet } from "../core/OmniWallet";
|
|
4
4
|
|
|
5
|
-
import { BridgeReview } from "../exchange";
|
|
5
|
+
import { BridgeReview } from "../core/exchange";
|
|
6
6
|
import { WalletType } from "../core/chains";
|
|
7
7
|
import { Recipient } from "../core/recipient";
|
|
8
8
|
import { Intents } from "../core/Intents";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OmniConnector.js","sourceRoot":"","sources":["../src/OmniConnector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,E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vB,CAAC;CACF"}
|
package/build/OmniWallet.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { hex } from "@scure/base";
|
|
2
|
-
import { Intents } from "./core/Intents";
|
|
3
|
-
import { ReviewFee } from "./core/bridge";
|
|
4
|
-
import { api } from "./core/api";
|
|
5
|
-
export class OmniWallet {
|
|
6
|
-
async depositNfts(nftIds, receiver) {
|
|
7
|
-
// TODO
|
|
8
|
-
}
|
|
9
|
-
async withdrawNfts(nftIds, receiver) {
|
|
10
|
-
// TODO
|
|
11
|
-
}
|
|
12
|
-
async getDepositNftsFee(nfts) {
|
|
13
|
-
return new ReviewFee({ chain: -4 });
|
|
14
|
-
}
|
|
15
|
-
async transferNft(nftId, receiver) {
|
|
16
|
-
// TODO
|
|
17
|
-
}
|
|
18
|
-
async getTranferNftFee(nftId, receiver) {
|
|
19
|
-
return new ReviewFee({ chain: -4 });
|
|
20
|
-
}
|
|
21
|
-
async getNfts(onLoad) {
|
|
22
|
-
// TODO
|
|
23
|
-
}
|
|
24
|
-
async auth(intents, options) {
|
|
25
|
-
const authFn = async () => {
|
|
26
|
-
const seed = hex.encode(new Uint8Array(window.crypto.getRandomValues(new Uint8Array(32))));
|
|
27
|
-
const msgBuffer = new TextEncoder().encode(`${options?.domain || window.location.origin}_${seed}`);
|
|
28
|
-
const nonce = await window.crypto.subtle.digest("SHA-256", new Uint8Array(msgBuffer));
|
|
29
|
-
const signed = await this.signIntents(intents || [], { nonce: new Uint8Array(nonce), signerId: options?.signerId || this.omniAddress });
|
|
30
|
-
if (options?.customAuth)
|
|
31
|
-
return await options.customAuth(signed, seed);
|
|
32
|
-
return (await api.auth(signed, seed));
|
|
33
|
-
};
|
|
34
|
-
if (typeof window === "undefined")
|
|
35
|
-
return await authFn();
|
|
36
|
-
const { openAuthPopup } = await import("./ui/connect/AuthPopup");
|
|
37
|
-
return openAuthPopup(this, authFn);
|
|
38
|
-
}
|
|
39
|
-
async waitUntilBalance(need, receiver = this.omniAddress, attempts = 0) {
|
|
40
|
-
if (attempts > 120)
|
|
41
|
-
throw "Balance is not enough";
|
|
42
|
-
const assets = Object.keys(need);
|
|
43
|
-
const balances = await Intents.getIntentsBalances(assets, receiver);
|
|
44
|
-
if (assets.every((asset) => (balances[asset] || 0n) >= (need[asset] || 0n)))
|
|
45
|
-
return;
|
|
46
|
-
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
47
|
-
await this.waitUntilBalance(need, receiver, attempts + 1);
|
|
48
|
-
}
|
|
49
|
-
async getIntentsBalance(asset, receiver) {
|
|
50
|
-
const balances = await Intents.getIntentsBalances([asset], receiver);
|
|
51
|
-
return balances[asset] || 0n;
|
|
52
|
-
}
|
|
53
|
-
async getAssets() {
|
|
54
|
-
if (!this.omniAddress)
|
|
55
|
-
return {};
|
|
56
|
-
const assets = await Intents.getIntentsAssets(this.omniAddress);
|
|
57
|
-
const balances = await Intents.getIntentsBalances(assets, this.omniAddress);
|
|
58
|
-
return balances;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
//# sourceMappingURL=OmniWallet.js.map
|
package/build/OmniWallet.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OmniWallet.js","sourceRoot":"","sources":["../src/OmniWallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAGlC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG1C,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEjC,MAAM,OAAgB,UAAU;IAO9B,KAAK,CAAC,WAAW,CAAC,MAAgB,EAAE,QAAgB;QAClD,OAAO;IACT,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,MAAgB,EAAE,QAAgB;QACnD,OAAO;IACT,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,IAAc;QACpC,OAAO,IAAI,SAAS,CA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ACb,IAAI,CAAC,IAAI,CAAC,WAAW;YAAE,OAAO,EAAE,CAAC;QACjC,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAChE,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAC5E,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
|
package/build/core/signer.d.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { Commitment } from "./types";
|
|
2
|
-
import { WalletType } from "./chains";
|
|
3
|
-
import { OmniWallet } from "../OmniWallet";
|
|
4
|
-
import { ReviewFee } from "@hot-labs/omni-sdk";
|
|
5
|
-
import { Token } from "./token";
|
|
6
|
-
export declare class Secp256k1Wallet extends OmniWallet {
|
|
7
|
-
readonly privateKey: Buffer;
|
|
8
|
-
readonly address: string;
|
|
9
|
-
readonly publicKey: string;
|
|
10
|
-
readonly omniAddress: string;
|
|
11
|
-
readonly type = WalletType.EVM;
|
|
12
|
-
readonly icon = "";
|
|
13
|
-
constructor(privateKey: Buffer);
|
|
14
|
-
transferFee(token: Token, receiver: string, amount: bigint): Promise<ReviewFee>;
|
|
15
|
-
transfer(args: {
|
|
16
|
-
token: Token;
|
|
17
|
-
receiver: string;
|
|
18
|
-
amount: bigint;
|
|
19
|
-
comment?: string;
|
|
20
|
-
gasFee?: ReviewFee;
|
|
21
|
-
}): Promise<string>;
|
|
22
|
-
fetchBalance(chain: number, address: string): Promise<bigint>;
|
|
23
|
-
fetchBalances(chain?: number, whitelist?: string[]): Promise<Record<string, bigint>>;
|
|
24
|
-
signIntents(intents: Record<string, any>[], options?: {
|
|
25
|
-
deadline?: number;
|
|
26
|
-
nonce?: Uint8Array;
|
|
27
|
-
}): Promise<Commitment>;
|
|
28
|
-
}
|
|
29
|
-
export declare class Ed25519Wallet extends OmniWallet {
|
|
30
|
-
readonly privateKey: Buffer;
|
|
31
|
-
readonly omniAddress: string;
|
|
32
|
-
readonly publicKey: string;
|
|
33
|
-
readonly address: string;
|
|
34
|
-
readonly type = WalletType.EVM;
|
|
35
|
-
readonly icon = "";
|
|
36
|
-
constructor(privateKey: Buffer, signerId?: string);
|
|
37
|
-
transferFee(token: Token, receiver: string, amount: bigint): Promise<ReviewFee>;
|
|
38
|
-
transfer(args: {
|
|
39
|
-
token: Token;
|
|
40
|
-
receiver: string;
|
|
41
|
-
amount: bigint;
|
|
42
|
-
comment?: string;
|
|
43
|
-
gasFee?: ReviewFee;
|
|
44
|
-
}): Promise<string>;
|
|
45
|
-
fetchBalance(chain: number, address: string): Promise<bigint>;
|
|
46
|
-
fetchBalances(chain?: number, whitelist?: string[]): Promise<Record<string, bigint>>;
|
|
47
|
-
signIntents(intents: Record<string, any>[], options?: {
|
|
48
|
-
deadline?: number;
|
|
49
|
-
nonce?: Uint8Array;
|
|
50
|
-
}): Promise<Commitment>;
|
|
51
|
-
}
|