@embarkai/ui-kit 0.4.20 → 0.4.22
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/dist/auth-JTFILPX3.cjs +115 -0
- package/dist/auth-S7VX73GX.js +115 -0
- package/dist/chunk-7H5TZZQT.cjs +1514 -0
- package/dist/chunk-DACL62OU.cjs +29 -0
- package/dist/chunk-DBFKMKYT.js +29 -0
- package/dist/chunk-FVUBVOOZ.cjs +1091 -0
- package/dist/chunk-IKKT5JDT.js +1091 -0
- package/dist/chunk-ISXWRCDC.js +1514 -0
- package/dist/chunk-KLC3OOWX.cjs +20150 -0
- package/dist/chunk-Q7PR2UUH.js +20150 -0
- package/dist/clients-EQIRT5QY.js +78 -0
- package/dist/clients-JG222VOC.cjs +78 -0
- package/dist/cloudStorage-SXE7HVID.cjs +207 -0
- package/dist/cloudStorage-WASWQ4KL.js +207 -0
- package/dist/hyperbridge-5ORI5ZDZ.cjs +932 -0
- package/dist/hyperbridge-OU2MDJ5Q.js +932 -0
- package/dist/iframe/index.html +1 -1
- package/dist/iframe/main.js +1 -1
- package/dist/iframe-manager-GCUMMQVH.js +14 -0
- package/dist/iframe-manager-KOR4O7PU.cjs +14 -0
- package/dist/index.cjs +6 -25083
- package/dist/index.d.cts +42 -2
- package/dist/index.d.ts +42 -2
- package/dist/index.js +86 -24997
- package/dist/passkey-NE5N2Q2W.cjs +13 -0
- package/dist/passkey-PFNFI7AP.cjs +19 -0
- package/dist/passkey-QGOQHMP2.js +19 -0
- package/dist/passkey-UQ4D7IBC.js +13 -0
- package/dist/profile-MN3MGEEE.js +14 -0
- package/dist/profile-OCWTUVLR.cjs +14 -0
- package/dist/styles.css +1 -1
- package/dist/vaultClient-2DRJXCTL.cjs +50 -0
- package/dist/vaultClient-RB5J5M5Z.js +50 -0
- package/package.json +5 -1
|
@@ -0,0 +1,932 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Badge,
|
|
3
|
+
BnbIcon,
|
|
4
|
+
Button,
|
|
5
|
+
EthereumIcon,
|
|
6
|
+
Highlight,
|
|
7
|
+
Input,
|
|
8
|
+
LumiaIcon,
|
|
9
|
+
TOKENS_ICONS,
|
|
10
|
+
cn,
|
|
11
|
+
formatPrice,
|
|
12
|
+
sendUserOperation,
|
|
13
|
+
useBridgeStore,
|
|
14
|
+
useFlowSelectorStore,
|
|
15
|
+
useSession,
|
|
16
|
+
useT
|
|
17
|
+
} from "./chunk-Q7PR2UUH.js";
|
|
18
|
+
import "./chunk-IKKT5JDT.js";
|
|
19
|
+
import "./chunk-ISXWRCDC.js";
|
|
20
|
+
import "./chunk-DBFKMKYT.js";
|
|
21
|
+
|
|
22
|
+
// src/internal/components/SendMenu/hyperbridge/HyperlaneBridge.tsx
|
|
23
|
+
import { useEffect as useEffect4 } from "react";
|
|
24
|
+
|
|
25
|
+
// src/internal/components/SendMenu/hyperbridge/components/TokenSelector.tsx
|
|
26
|
+
import { toPairs } from "lodash-es";
|
|
27
|
+
import { ArrowLeftRightIcon } from "lucide-react";
|
|
28
|
+
import { Fragment, useCallback } from "react";
|
|
29
|
+
|
|
30
|
+
// src/internal/components/SendMenu/hyperbridge/lib/chains.ts
|
|
31
|
+
import { lumiaMainnetChain as lumiaprism } from "@embarkai/core/read";
|
|
32
|
+
import { bsc, mainnet as ethereum } from "wagmi/chains";
|
|
33
|
+
var CHAINS_META = {
|
|
34
|
+
lumiaprism: {
|
|
35
|
+
chainID: lumiaprism.id,
|
|
36
|
+
chainLabel: lumiaprism.name,
|
|
37
|
+
chainName: "lumiaprism",
|
|
38
|
+
// exact hyperlane registry chain name
|
|
39
|
+
Icon: LumiaIcon
|
|
40
|
+
},
|
|
41
|
+
bsc: {
|
|
42
|
+
chainID: bsc.id,
|
|
43
|
+
chainLabel: bsc.name,
|
|
44
|
+
chainName: "bsc",
|
|
45
|
+
// exact hyperlane registry chain name
|
|
46
|
+
Icon: BnbIcon
|
|
47
|
+
},
|
|
48
|
+
ethereum: {
|
|
49
|
+
chainID: ethereum.id,
|
|
50
|
+
chainLabel: ethereum.name,
|
|
51
|
+
chainName: "ethereum",
|
|
52
|
+
// exact hyperlane registry chain name
|
|
53
|
+
Icon: EthereumIcon
|
|
54
|
+
}
|
|
55
|
+
// base: {
|
|
56
|
+
// chainID: base.id,
|
|
57
|
+
// chainLabel: base.name,
|
|
58
|
+
// chainName: 'ethereum', // exact hyperlane registry chain name
|
|
59
|
+
// Icon: EthereumIcon
|
|
60
|
+
// },
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// src/internal/components/SendMenu/hyperbridge/lib/warp.ts
|
|
64
|
+
import { lumiaMainnetChain as lumiaprism2 } from "@embarkai/core/read";
|
|
65
|
+
import { chainMetadata, warpRouteConfigs } from "@hyperlane-xyz/registry";
|
|
66
|
+
import {
|
|
67
|
+
MultiProtocolProvider,
|
|
68
|
+
WarpCore
|
|
69
|
+
} from "@hyperlane-xyz/sdk";
|
|
70
|
+
import { bsc as bsc2, base as ethereum2 } from "wagmi/chains";
|
|
71
|
+
var WARP_ROUTES = [
|
|
72
|
+
{
|
|
73
|
+
symbol: "LUMIA",
|
|
74
|
+
icon: TOKENS_ICONS.LUMIA,
|
|
75
|
+
id: "LUMIA/arbitrum-avalanche-base-bsc-ethereum-lumiaprism-optimism-polygon",
|
|
76
|
+
// Canonical LUMIA warp route (includes BSC + Lumia Prism).
|
|
77
|
+
name: "bsc-lumiaprism",
|
|
78
|
+
chainPair: [
|
|
79
|
+
{
|
|
80
|
+
chainID: bsc2.id,
|
|
81
|
+
chainLabel: bsc2.name,
|
|
82
|
+
chainName: "bsc",
|
|
83
|
+
Icon: BnbIcon
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
chainID: lumiaprism2.id,
|
|
87
|
+
chainLabel: lumiaprism2.name,
|
|
88
|
+
chainName: "lumiaprism",
|
|
89
|
+
Icon: LumiaIcon
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
symbol: "USDT",
|
|
95
|
+
icon: TOKENS_ICONS.USDT,
|
|
96
|
+
id: "USDT/ethereum-lumiaprism",
|
|
97
|
+
name: "ethereum-lumiaprism",
|
|
98
|
+
chainPair: [
|
|
99
|
+
{
|
|
100
|
+
chainID: ethereum2.id,
|
|
101
|
+
chainLabel: ethereum2.name,
|
|
102
|
+
chainName: "ethereum",
|
|
103
|
+
Icon: EthereumIcon
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
chainID: lumiaprism2.id,
|
|
107
|
+
chainLabel: lumiaprism2.name,
|
|
108
|
+
chainName: "lumiaprism",
|
|
109
|
+
Icon: LumiaIcon
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
symbol: "USDC",
|
|
115
|
+
icon: TOKENS_ICONS.USDC,
|
|
116
|
+
id: "USDC/lumia",
|
|
117
|
+
name: "ethereum-lumiaprism",
|
|
118
|
+
chainPair: [
|
|
119
|
+
{
|
|
120
|
+
chainID: ethereum2.id,
|
|
121
|
+
chainLabel: ethereum2.name,
|
|
122
|
+
chainName: "ethereum",
|
|
123
|
+
Icon: EthereumIcon
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
chainID: lumiaprism2.id,
|
|
127
|
+
chainLabel: lumiaprism2.name,
|
|
128
|
+
chainName: "lumiaprism",
|
|
129
|
+
Icon: LumiaIcon
|
|
130
|
+
}
|
|
131
|
+
]
|
|
132
|
+
}
|
|
133
|
+
];
|
|
134
|
+
function buildLumiaWarpConfig(warpRouteId) {
|
|
135
|
+
const config = warpRouteConfigs[warpRouteId];
|
|
136
|
+
if (!config) {
|
|
137
|
+
console.warn(`[HYPERLANE SDK] Warp route ${warpRouteId} not found in @hyperlane-xyz/registry`);
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
return config;
|
|
141
|
+
}
|
|
142
|
+
function tokenConnectionId(chainName, addressOrDenom) {
|
|
143
|
+
return `ethereum|${chainName}|${addressOrDenom}`.toLowerCase();
|
|
144
|
+
}
|
|
145
|
+
function filterWarpConfigForChains(config, chains) {
|
|
146
|
+
const chainSet = new Set(chains);
|
|
147
|
+
const tokens = config.tokens.filter((t) => chainSet.has(t.chainName) && t.addressOrDenom);
|
|
148
|
+
const allowedConnectionIds = new Set(tokens.map((t) => tokenConnectionId(t.chainName, t.addressOrDenom)));
|
|
149
|
+
const prunedTokens = tokens.map((token) => ({
|
|
150
|
+
...token,
|
|
151
|
+
connections: (token.connections ?? []).filter((c) => allowedConnectionIds.has(c.token.toLowerCase()))
|
|
152
|
+
}));
|
|
153
|
+
return { ...config, tokens: prunedTokens };
|
|
154
|
+
}
|
|
155
|
+
function isDirectRouteAvailable(config, originChain, destinationChain) {
|
|
156
|
+
const originTokens = config.tokens.find((t) => t.chainName === originChain);
|
|
157
|
+
const destinationTokens = config.tokens.find((t) => t.chainName === destinationChain);
|
|
158
|
+
if (!originTokens || !destinationTokens) return false;
|
|
159
|
+
const destinationTokensId = `ethereum|${destinationChain}|${destinationTokens.addressOrDenom}`.toLowerCase();
|
|
160
|
+
return (originTokens.connections ?? []).some((c) => c.token.toLowerCase() === destinationTokensId);
|
|
161
|
+
}
|
|
162
|
+
function createMultiProtocolProvider(chainNames) {
|
|
163
|
+
const metadata = {};
|
|
164
|
+
for (const name of chainNames) {
|
|
165
|
+
const meta = chainMetadata[name];
|
|
166
|
+
if (meta) metadata[name] = meta;
|
|
167
|
+
}
|
|
168
|
+
return new MultiProtocolProvider(metadata);
|
|
169
|
+
}
|
|
170
|
+
function createWarpCore(config, chainNames) {
|
|
171
|
+
const multiProvider = createMultiProtocolProvider(chainNames);
|
|
172
|
+
return WarpCore.FromConfig(multiProvider, config);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// src/internal/components/SendMenu/hyperbridge/components/TokenSelector.tsx
|
|
176
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
177
|
+
var BRIDGE_CHAINS_LIST = toPairs(CHAINS_META).map(([chainName]) => chainName);
|
|
178
|
+
function RouteItem(props) {
|
|
179
|
+
const { id, icon: Icon, chainPair, symbol } = props;
|
|
180
|
+
const hyperRouteID = useBridgeStore((st) => st.hyperRoute);
|
|
181
|
+
const selectRoute = useCallback((routeId) => {
|
|
182
|
+
const {
|
|
183
|
+
//
|
|
184
|
+
setHyperRoute,
|
|
185
|
+
setBridgeStep,
|
|
186
|
+
setWarpCore,
|
|
187
|
+
setWarpCoreConfig,
|
|
188
|
+
setOriginChain,
|
|
189
|
+
setDestinationChain
|
|
190
|
+
} = useBridgeStore.getState();
|
|
191
|
+
setHyperRoute(routeId);
|
|
192
|
+
const warpConfig = buildLumiaWarpConfig(routeId);
|
|
193
|
+
if (!warpConfig) {
|
|
194
|
+
useFlowSelectorStore.getState().setError(`Warp route ${routeId} not found in @hyperlane-xyz/registry`);
|
|
195
|
+
setBridgeStep("select");
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
console.log("[HYPERLANE SDK] Selecting route", routeId);
|
|
199
|
+
const filteredConfig = filterWarpConfigForChains(warpConfig, BRIDGE_CHAINS_LIST);
|
|
200
|
+
const warpCore = createWarpCore(filteredConfig, BRIDGE_CHAINS_LIST);
|
|
201
|
+
setWarpCore(warpCore);
|
|
202
|
+
setWarpCoreConfig(filteredConfig);
|
|
203
|
+
setOriginChain(chainPair[0].chainName);
|
|
204
|
+
setDestinationChain(chainPair[1].chainName);
|
|
205
|
+
setBridgeStep("select");
|
|
206
|
+
}, []);
|
|
207
|
+
return /* @__PURE__ */ jsxs(
|
|
208
|
+
Button,
|
|
209
|
+
{
|
|
210
|
+
size: "large",
|
|
211
|
+
variant: hyperRouteID === id ? "default" : "outline",
|
|
212
|
+
className: "justify-between",
|
|
213
|
+
onClick: () => selectRoute(id),
|
|
214
|
+
children: [
|
|
215
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-[var(--ui-kit-gap)]", children: [
|
|
216
|
+
/* @__PURE__ */ jsx(Icon, { className: "w-6 h-6" }),
|
|
217
|
+
/* @__PURE__ */ jsx("span", { children: symbol.toUpperCase() })
|
|
218
|
+
] }),
|
|
219
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-[var(--ui-kit-gap)]", children: chainPair.map((chain, chIdx) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
220
|
+
chIdx > 0 && /* @__PURE__ */ jsx(ArrowLeftRightIcon, { className: "w-4 h-4" }),
|
|
221
|
+
/* @__PURE__ */ jsx(chain.Icon, { className: "w-4 h-4" })
|
|
222
|
+
] }, `${id}-icon-${chain.chainID}-${chIdx}`)) })
|
|
223
|
+
]
|
|
224
|
+
}
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
function TokenSelector() {
|
|
228
|
+
return /* @__PURE__ */ jsx("div", { className: "w-full flex flex-col gap-[var(--ui-kit-gap)]", children: WARP_ROUTES.map((hyperRoute) => /* @__PURE__ */ jsx(RouteItem, { ...hyperRoute }, hyperRoute.id)) });
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// src/internal/components/SendMenu/hyperbridge/hooks/useBridge.ts
|
|
232
|
+
import { toWei } from "@hyperlane-xyz/utils";
|
|
233
|
+
import { useMutation } from "@tanstack/react-query";
|
|
234
|
+
import { debounce } from "lodash-es";
|
|
235
|
+
import { useCallback as useCallback2, useEffect as useEffect2 } from "react";
|
|
236
|
+
|
|
237
|
+
// src/internal/components/SendMenu/hyperbridge/lib/executeWarpTxs.ts
|
|
238
|
+
import { ProviderType, WarpTxCategory } from "@hyperlane-xyz/sdk";
|
|
239
|
+
async function executeWarpTransactions(txs) {
|
|
240
|
+
const { publicClient, session } = useSession.getState();
|
|
241
|
+
if (!session) {
|
|
242
|
+
throw new Error("No active session");
|
|
243
|
+
}
|
|
244
|
+
if (!publicClient) {
|
|
245
|
+
throw new Error("No public client available");
|
|
246
|
+
}
|
|
247
|
+
const hashes = [];
|
|
248
|
+
for (const tx of txs) {
|
|
249
|
+
if (tx.type !== ProviderType.EthersV5) {
|
|
250
|
+
throw new Error(`Unsupported transaction provider: ${tx.type}`);
|
|
251
|
+
}
|
|
252
|
+
const populated = tx.transaction;
|
|
253
|
+
if (!populated.to) {
|
|
254
|
+
throw new Error("Transaction missing `to` address");
|
|
255
|
+
}
|
|
256
|
+
const hash = await sendUserOperation(session, {
|
|
257
|
+
to: populated.to,
|
|
258
|
+
data: populated.data ?? "0x",
|
|
259
|
+
value: (populated.value ? BigInt(populated.value.toString()) : 0n).toString(),
|
|
260
|
+
chainId: publicClient.chain.id
|
|
261
|
+
});
|
|
262
|
+
await publicClient.waitForTransactionReceipt({ hash });
|
|
263
|
+
hashes.push(hash);
|
|
264
|
+
}
|
|
265
|
+
return hashes;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// src/internal/components/SendMenu/hyperbridge/hooks/useWarpCore.ts
|
|
269
|
+
import { Buffer } from "buffer";
|
|
270
|
+
import { toPairs as toPairs2 } from "lodash-es";
|
|
271
|
+
import { useEffect } from "react";
|
|
272
|
+
var BRIDGE_CHAINS_LIST2 = toPairs2(CHAINS_META).map(([chainName]) => chainName);
|
|
273
|
+
var DEFAULT_WARP_ROUTE_ID = "USDT/ethereum-lumiaprism";
|
|
274
|
+
globalThis.Buffer = Buffer;
|
|
275
|
+
function useWarpCore() {
|
|
276
|
+
useEffect(() => {
|
|
277
|
+
const existingWarpCore = useBridgeStore.getState().warpCore;
|
|
278
|
+
if (!!existingWarpCore) return;
|
|
279
|
+
const {
|
|
280
|
+
hyperRoute,
|
|
281
|
+
originChain,
|
|
282
|
+
destinationChain,
|
|
283
|
+
setWarpCore,
|
|
284
|
+
setWarpCoreConfig,
|
|
285
|
+
setBridgeStep,
|
|
286
|
+
setHyperRoute,
|
|
287
|
+
setOriginChain,
|
|
288
|
+
setDestinationChain
|
|
289
|
+
} = useBridgeStore.getState();
|
|
290
|
+
const hyperRouteID = hyperRoute || DEFAULT_WARP_ROUTE_ID;
|
|
291
|
+
console.debug("[HYPERLANE SDK] Initializing WarpCore...", hyperRouteID);
|
|
292
|
+
const fullConfig = buildLumiaWarpConfig(hyperRouteID);
|
|
293
|
+
if (!fullConfig) {
|
|
294
|
+
useFlowSelectorStore.getState().setError(`Warp route ${hyperRouteID} not found in @hyperlane-xyz/registry`);
|
|
295
|
+
setBridgeStep("select");
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
const filteredConfig = filterWarpConfigForChains(fullConfig, BRIDGE_CHAINS_LIST2);
|
|
299
|
+
const warpCore = createWarpCore(filteredConfig, BRIDGE_CHAINS_LIST2);
|
|
300
|
+
setWarpCore(warpCore);
|
|
301
|
+
setWarpCoreConfig(filteredConfig);
|
|
302
|
+
if (hyperRoute !== hyperRouteID) setHyperRoute(hyperRouteID);
|
|
303
|
+
const chainsPair = WARP_ROUTES.find((warpRoute) => warpRoute.id === hyperRouteID)?.chainPair;
|
|
304
|
+
if (!!chainsPair) {
|
|
305
|
+
console.debug(`[HYPERLANE SDK] chain pair ${chainsPair.map((c) => c.chainName).join(" - ")}`);
|
|
306
|
+
const persistedOrigin = originChain && chainsPair.find((c) => c.chainName === originChain);
|
|
307
|
+
const persistedDestination = destinationChain && chainsPair.find((c) => c.chainName === destinationChain);
|
|
308
|
+
setOriginChain(persistedOrigin?.chainName || chainsPair[0].chainName);
|
|
309
|
+
setDestinationChain(persistedDestination?.chainName || chainsPair[1].chainName);
|
|
310
|
+
}
|
|
311
|
+
return () => {
|
|
312
|
+
setWarpCore(null);
|
|
313
|
+
setWarpCoreConfig(null);
|
|
314
|
+
};
|
|
315
|
+
}, []);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// src/internal/components/SendMenu/hyperbridge/hooks/useBridge.ts
|
|
319
|
+
function findToken(warpCore, chain) {
|
|
320
|
+
return warpCore.tokens.find((t) => t.chainName === chain);
|
|
321
|
+
}
|
|
322
|
+
function findDestinationToken(warpCore, origin, destination) {
|
|
323
|
+
if (!origin.getConnectionForChain(destination)) return void 0;
|
|
324
|
+
return warpCore.tokens.find((t) => t.chainName === destination);
|
|
325
|
+
}
|
|
326
|
+
function useBridge() {
|
|
327
|
+
const { t } = useT();
|
|
328
|
+
useWarpCore();
|
|
329
|
+
const address = useSession((st) => st.address);
|
|
330
|
+
const currentChainId = useSession((st) => st.activeChainId);
|
|
331
|
+
const warpCore = useBridgeStore((st) => st.warpCore);
|
|
332
|
+
const amountToBridge = useBridgeStore((st) => st.amount);
|
|
333
|
+
const swapDirection = useCallback2(() => {
|
|
334
|
+
const {
|
|
335
|
+
bridgeStep,
|
|
336
|
+
originChain,
|
|
337
|
+
destinationChain,
|
|
338
|
+
amount,
|
|
339
|
+
//
|
|
340
|
+
setOriginChain,
|
|
341
|
+
setDestinationChain,
|
|
342
|
+
setAmount,
|
|
343
|
+
setQuote
|
|
344
|
+
} = useBridgeStore.getState();
|
|
345
|
+
useFlowSelectorStore.getState().setError(null);
|
|
346
|
+
useFlowSelectorStore.getState().setRenderKey(`${bridgeStep}-swaped-${Date.now()}`);
|
|
347
|
+
setOriginChain(destinationChain);
|
|
348
|
+
setDestinationChain(originChain);
|
|
349
|
+
const cacheAmount = amount;
|
|
350
|
+
setAmount("0");
|
|
351
|
+
setQuote(null);
|
|
352
|
+
setTimeout(() => setAmount(cacheAmount), 500);
|
|
353
|
+
}, []);
|
|
354
|
+
const { mutate: estimateQuote } = useMutation({
|
|
355
|
+
mutationFn: async (amountToBridge2) => {
|
|
356
|
+
useFlowSelectorStore.getState().setError(null);
|
|
357
|
+
const {
|
|
358
|
+
//
|
|
359
|
+
bridgeStep,
|
|
360
|
+
originChain,
|
|
361
|
+
destinationChain,
|
|
362
|
+
recipient,
|
|
363
|
+
// setQuote,
|
|
364
|
+
setIsQuoteEstimating
|
|
365
|
+
} = useBridgeStore.getState();
|
|
366
|
+
useFlowSelectorStore.getState().setRenderKey(`${bridgeStep}-quoted-${Date.now()}`);
|
|
367
|
+
setIsQuoteEstimating(true);
|
|
368
|
+
const originToken = findToken(warpCore, originChain);
|
|
369
|
+
const destToken = originToken ? findDestinationToken(warpCore, originToken, destinationChain) : void 0;
|
|
370
|
+
if (!originToken || !destToken) {
|
|
371
|
+
throw new Error(
|
|
372
|
+
// @ts-expect-error i18n typing
|
|
373
|
+
t("passport:bridgeMenu.errors.noConnections", { originChain, destinationChain })
|
|
374
|
+
);
|
|
375
|
+
}
|
|
376
|
+
const wei = toWei(amountToBridge2, originToken.decimals);
|
|
377
|
+
const originTokenAmount = originToken.amount(wei);
|
|
378
|
+
const { igpQuote, tokenFeeQuote } = await warpCore.getInterchainTransferFee({
|
|
379
|
+
originTokenAmount,
|
|
380
|
+
destination: destinationChain,
|
|
381
|
+
sender: address,
|
|
382
|
+
recipient: recipient || address,
|
|
383
|
+
destinationToken: destToken
|
|
384
|
+
});
|
|
385
|
+
const localQuote = await warpCore.getLocalTransferFeeAmount({
|
|
386
|
+
originToken,
|
|
387
|
+
destination: destinationChain,
|
|
388
|
+
sender: address,
|
|
389
|
+
interchainFee: igpQuote,
|
|
390
|
+
tokenFeeQuote,
|
|
391
|
+
amount: BigInt(wei.toString()),
|
|
392
|
+
destinationToken: destToken
|
|
393
|
+
});
|
|
394
|
+
return {
|
|
395
|
+
amount: amountToBridge2,
|
|
396
|
+
igpFee: String(igpQuote.getDecimalFormattedAmount()),
|
|
397
|
+
localFee: String(localQuote.getDecimalFormattedAmount()),
|
|
398
|
+
tokenFee: tokenFeeQuote ? String(tokenFeeQuote.getDecimalFormattedAmount()) : void 0,
|
|
399
|
+
igpSymbol: igpQuote.token.symbol,
|
|
400
|
+
localSymbol: localQuote.token.symbol
|
|
401
|
+
};
|
|
402
|
+
},
|
|
403
|
+
onSuccess: (quote) => {
|
|
404
|
+
const { bridgeStep, setQuote, setIsQuoteEstimating } = useBridgeStore.getState();
|
|
405
|
+
setQuote(quote);
|
|
406
|
+
setIsQuoteEstimating(false);
|
|
407
|
+
useFlowSelectorStore.getState().setRenderKey(`${bridgeStep}-quoted-${Date.now()}`);
|
|
408
|
+
},
|
|
409
|
+
onError: (error) => {
|
|
410
|
+
const { setQuote, setIsQuoteEstimating } = useBridgeStore.getState();
|
|
411
|
+
console.error("[HYPERLANE SDK] Quote estimation error", error);
|
|
412
|
+
setQuote(null);
|
|
413
|
+
setIsQuoteEstimating(false);
|
|
414
|
+
useFlowSelectorStore.getState().setError(error instanceof Error ? error.message : String(error));
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
const defferedQuoteEstimation = useCallback2(
|
|
418
|
+
debounce((amountToBridge2) => {
|
|
419
|
+
estimateQuote(amountToBridge2);
|
|
420
|
+
}, 600),
|
|
421
|
+
[]
|
|
422
|
+
);
|
|
423
|
+
useEffect2(() => {
|
|
424
|
+
if (!amountToBridge || !Number(amountToBridge)) return;
|
|
425
|
+
const { originChain, destinationChain } = useBridgeStore.getState();
|
|
426
|
+
if (!originChain || !destinationChain) return;
|
|
427
|
+
const warpCoreConfig = useBridgeStore.getState().warpCoreConfig;
|
|
428
|
+
const routeReady = isDirectRouteAvailable(warpCoreConfig, originChain, destinationChain);
|
|
429
|
+
if (!routeReady) {
|
|
430
|
+
console.warn("[HYPERLANE SDK] route not ready");
|
|
431
|
+
useFlowSelectorStore.getState().setError(
|
|
432
|
+
// @ts-expect-error i18n typing
|
|
433
|
+
t("passport:bridgeMenu.errors.routeUnavailable", { originChain, destinationChain })
|
|
434
|
+
);
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
defferedQuoteEstimation(amountToBridge);
|
|
438
|
+
}, [amountToBridge]);
|
|
439
|
+
const { mutate: bridgeAsset, isPending: isAssetBridging } = useMutation({
|
|
440
|
+
mutationFn: async () => {
|
|
441
|
+
const {
|
|
442
|
+
//
|
|
443
|
+
originChain,
|
|
444
|
+
destinationChain,
|
|
445
|
+
amount,
|
|
446
|
+
recipient,
|
|
447
|
+
setBridgeTxStatus,
|
|
448
|
+
setLastTxHashes
|
|
449
|
+
} = useBridgeStore.getState();
|
|
450
|
+
useFlowSelectorStore.getState().setError(null);
|
|
451
|
+
setBridgeTxStatus(null);
|
|
452
|
+
setLastTxHashes([]);
|
|
453
|
+
const expectedChainId = warpCore.multiProvider.getChainId(originChain);
|
|
454
|
+
console.warn("[HYPERLANE SDK] expectedChainId", expectedChainId, "currentChainId", currentChainId);
|
|
455
|
+
if (currentChainId !== expectedChainId) {
|
|
456
|
+
throw new Error(t("passport:bridgeMenu.errors.wrongNetwork"));
|
|
457
|
+
}
|
|
458
|
+
const originToken = findToken(warpCore, originChain);
|
|
459
|
+
const destToken = originToken ? findDestinationToken(warpCore, originToken, destinationChain) : void 0;
|
|
460
|
+
if (!originToken || !destToken) {
|
|
461
|
+
throw new Error(
|
|
462
|
+
// @ts-expect-error i18n typing
|
|
463
|
+
t("passport:bridgeMenu.errors.noConnections", { originChain, destinationChain })
|
|
464
|
+
);
|
|
465
|
+
}
|
|
466
|
+
setBridgeTxStatus(t("passport:bridgeMenu.statuses.txPrepare"));
|
|
467
|
+
const wei = toWei(amount, originToken.decimals);
|
|
468
|
+
const originTokenAmount = originToken.amount(wei);
|
|
469
|
+
const to = recipient || address;
|
|
470
|
+
console.log("[HYPERLANE SDK] tokens:\n", originToken, "->", destToken);
|
|
471
|
+
const { igpQuote, tokenFeeQuote } = await warpCore.getInterchainTransferFee({
|
|
472
|
+
originTokenAmount,
|
|
473
|
+
destination: destinationChain,
|
|
474
|
+
sender: address,
|
|
475
|
+
recipient: to,
|
|
476
|
+
destinationToken: destToken
|
|
477
|
+
});
|
|
478
|
+
const txs = await warpCore.getTransferRemoteTxs({
|
|
479
|
+
originTokenAmount,
|
|
480
|
+
destination: destinationChain,
|
|
481
|
+
sender: address,
|
|
482
|
+
recipient: to,
|
|
483
|
+
interchainFee: igpQuote,
|
|
484
|
+
tokenFeeQuote,
|
|
485
|
+
destinationToken: destToken
|
|
486
|
+
});
|
|
487
|
+
setBridgeTxStatus(
|
|
488
|
+
// @ts-expect-error i18n typing
|
|
489
|
+
t("passport:bridgeMenu.statuses.txSending", { txCount: txs.length })
|
|
490
|
+
);
|
|
491
|
+
return await executeWarpTransactions(txs);
|
|
492
|
+
},
|
|
493
|
+
onSuccess: (hashes) => {
|
|
494
|
+
const { setBridgeStep, setBridgeTxStatus, setLastTxHashes, destinationChain } = useBridgeStore.getState();
|
|
495
|
+
setLastTxHashes(hashes);
|
|
496
|
+
setBridgeTxStatus(
|
|
497
|
+
// @ts-expect-error i18n typing
|
|
498
|
+
t("passport:bridgeMenu.statuses.txSent", { destination: destinationChain })
|
|
499
|
+
);
|
|
500
|
+
setBridgeStep("success");
|
|
501
|
+
},
|
|
502
|
+
onError: (error) => {
|
|
503
|
+
console.error("[HYPERLANE SDK] Bridge execution error", error);
|
|
504
|
+
const { setBridgeTxStatus } = useBridgeStore.getState();
|
|
505
|
+
setBridgeTxStatus(null);
|
|
506
|
+
useFlowSelectorStore.getState().setError(error instanceof Error ? error.message : String(error));
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
return {
|
|
510
|
+
swapDirection,
|
|
511
|
+
bridgeAsset,
|
|
512
|
+
isAssetBridging
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
// src/internal/components/SendMenu/hyperbridge/hooks/useMenuTitle.ts
|
|
517
|
+
import { useEffect as useEffect3 } from "react";
|
|
518
|
+
function useMenuTitle() {
|
|
519
|
+
const { t } = useT();
|
|
520
|
+
const bridgeStep = useBridgeStore((st) => st.bridgeStep);
|
|
521
|
+
const hyperRouteMeta = useBridgeStore((st) => WARP_ROUTES.find((route) => route.id === st.hyperRoute));
|
|
522
|
+
useEffect3(() => {
|
|
523
|
+
const updateMenuTitle = useFlowSelectorStore.getState().setMenuTitle;
|
|
524
|
+
switch (true) {
|
|
525
|
+
case bridgeStep === "select-token":
|
|
526
|
+
updateMenuTitle(t("passport:bridgeMenu.labels.selectToken"));
|
|
527
|
+
break;
|
|
528
|
+
case bridgeStep === "confirm":
|
|
529
|
+
updateMenuTitle(t("passport:bridgeMenu.labels.confirm"));
|
|
530
|
+
break;
|
|
531
|
+
default:
|
|
532
|
+
updateMenuTitle(
|
|
533
|
+
// @ts-expect-error i18n typings
|
|
534
|
+
t("passport:bridgeMenu.labels.bridgeAsset", {
|
|
535
|
+
asset: hyperRouteMeta?.symbol || "Asset"
|
|
536
|
+
})
|
|
537
|
+
);
|
|
538
|
+
break;
|
|
539
|
+
}
|
|
540
|
+
}, [bridgeStep, hyperRouteMeta, t]);
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
// src/internal/components/SendMenu/hyperbridge/steps/SelectStep.tsx
|
|
544
|
+
import { ArrowLeftRightIcon as ArrowLeftRightIcon2, ArrowRightLeftIcon, LoaderIcon, Wallet2Icon, XIcon } from "lucide-react";
|
|
545
|
+
import { Fragment as Fragment2 } from "react";
|
|
546
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
547
|
+
function SelectStep({ swapChains }) {
|
|
548
|
+
const { t } = useT();
|
|
549
|
+
const {
|
|
550
|
+
// warpCore,
|
|
551
|
+
originChain,
|
|
552
|
+
destinationChain,
|
|
553
|
+
hyperRoute,
|
|
554
|
+
amount,
|
|
555
|
+
isQuoteEstimating,
|
|
556
|
+
quote,
|
|
557
|
+
recipient,
|
|
558
|
+
setBridgeStep,
|
|
559
|
+
setAmount,
|
|
560
|
+
setRecipient
|
|
561
|
+
} = useBridgeStore();
|
|
562
|
+
const isError = useFlowSelectorStore((st) => !!st.error);
|
|
563
|
+
const selectedWarpRoute = WARP_ROUTES.find((route) => route.id === hyperRoute);
|
|
564
|
+
const OriginChainIcon = originChain ? CHAINS_META[originChain]?.Icon : null;
|
|
565
|
+
const DestinationChainIcon = destinationChain ? CHAINS_META[destinationChain]?.Icon : null;
|
|
566
|
+
return /* @__PURE__ */ jsxs2("div", { className: "w-full flex flex-col gap-[var(--ui-kit-gap)] items-center", children: [
|
|
567
|
+
/* @__PURE__ */ jsxs2("div", { className: "w-full flex flex-col gap-[var(--ui-kit-gap)]", children: [
|
|
568
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex items-center justify-between gap-[var(--ui-kit-gap)] text-[10px]", children: [
|
|
569
|
+
/* @__PURE__ */ jsx2("span", { className: "text-[var(--ui-kit-fg-muted)]", children: t("passport:bridgeMenu.labels.selectToken") }),
|
|
570
|
+
/* @__PURE__ */ jsx2("span", { className: "w-4 h-4" }),
|
|
571
|
+
/* @__PURE__ */ jsxs2("span", { className: "flex items-center gap-[var(--ui-kit-gap)]", children: [
|
|
572
|
+
/* @__PURE__ */ jsxs2("span", { className: "text-[var(--ui-kit-fg-muted)]", children: [
|
|
573
|
+
t("passport:common.balance"),
|
|
574
|
+
": "
|
|
575
|
+
] }),
|
|
576
|
+
/* @__PURE__ */ jsx2("span", { children: "xx.xxx" })
|
|
577
|
+
] })
|
|
578
|
+
] }),
|
|
579
|
+
/* @__PURE__ */ jsxs2(
|
|
580
|
+
Button,
|
|
581
|
+
{
|
|
582
|
+
disabled: isQuoteEstimating,
|
|
583
|
+
variant: "outline",
|
|
584
|
+
className: "w-full justify-between",
|
|
585
|
+
onClick: () => {
|
|
586
|
+
useFlowSelectorStore.getState().setError(null);
|
|
587
|
+
setBridgeStep("select-token");
|
|
588
|
+
},
|
|
589
|
+
children: [
|
|
590
|
+
selectedWarpRoute && /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-[var(--ui-kit-gap)]", children: [
|
|
591
|
+
/* @__PURE__ */ jsx2(selectedWarpRoute.icon, { className: "w-6 h-6" }),
|
|
592
|
+
/* @__PURE__ */ jsx2("span", { children: selectedWarpRoute.symbol })
|
|
593
|
+
] }),
|
|
594
|
+
/* @__PURE__ */ jsx2("div", { className: "flex items-center gap-[var(--ui-kit-gap)]", children: selectedWarpRoute?.chainPair?.map((chain, chIdx) => /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
595
|
+
chIdx > 0 && /* @__PURE__ */ jsx2(ArrowLeftRightIcon2, { className: "w-4 h-4 opacity-50" }),
|
|
596
|
+
/* @__PURE__ */ jsx2(chain.Icon, { className: "w-4 h-4 opacity-50" })
|
|
597
|
+
] }, `${selectedWarpRoute.id}-icon-${chain.chainID}-${chIdx}`)) })
|
|
598
|
+
]
|
|
599
|
+
}
|
|
600
|
+
),
|
|
601
|
+
/* @__PURE__ */ jsxs2(
|
|
602
|
+
"div",
|
|
603
|
+
{
|
|
604
|
+
className: cn(
|
|
605
|
+
"flex items-center justify-between gap-[var(--ui-kit-gap)]",
|
|
606
|
+
"text-[10px] text-[var(--ui-kit-fg-muted)]"
|
|
607
|
+
),
|
|
608
|
+
children: [
|
|
609
|
+
/* @__PURE__ */ jsx2("span", { className: "block text-[10px] text-[var(--ui-kit-fg-muted)]", children: t("passport:bridgeMenu.labels.fromChain") }),
|
|
610
|
+
/* @__PURE__ */ jsx2("span", { className: "block text-[10px] text-[var(--ui-kit-fg-muted)]", children: t("passport:bridgeMenu.labels.toChain") })
|
|
611
|
+
]
|
|
612
|
+
}
|
|
613
|
+
),
|
|
614
|
+
/* @__PURE__ */ jsxs2("div", { className: "w-full flex items-center justify-center", children: [
|
|
615
|
+
/* @__PURE__ */ jsxs2(
|
|
616
|
+
Badge,
|
|
617
|
+
{
|
|
618
|
+
variant: "outline",
|
|
619
|
+
size: "large",
|
|
620
|
+
className: "block flex-1 flex gap-[var(--ui-kit-gap)] justify-center",
|
|
621
|
+
children: [
|
|
622
|
+
OriginChainIcon && /* @__PURE__ */ jsx2(OriginChainIcon, { className: "w-6 h-6" }),
|
|
623
|
+
originChain && /* @__PURE__ */ jsx2("span", { className: "block max-w-[100px] truncate", children: CHAINS_META[originChain]?.chainLabel })
|
|
624
|
+
]
|
|
625
|
+
}
|
|
626
|
+
),
|
|
627
|
+
/* @__PURE__ */ jsx2(Button, { size: "icon", variant: "ghost", onClick: swapChains, children: /* @__PURE__ */ jsx2(ArrowRightLeftIcon, { className: "w-4 h-4 " }) }),
|
|
628
|
+
/* @__PURE__ */ jsxs2(
|
|
629
|
+
Badge,
|
|
630
|
+
{
|
|
631
|
+
variant: "outline",
|
|
632
|
+
size: "large",
|
|
633
|
+
className: "block flex-1 flex gap-[var(--ui-kit-gap)] justify-center",
|
|
634
|
+
children: [
|
|
635
|
+
DestinationChainIcon && /* @__PURE__ */ jsx2(DestinationChainIcon, { className: "w-6 h-6" }),
|
|
636
|
+
destinationChain && /* @__PURE__ */ jsx2("span", { className: "block max-w-[100px] truncate", children: CHAINS_META[destinationChain]?.chainLabel })
|
|
637
|
+
]
|
|
638
|
+
}
|
|
639
|
+
)
|
|
640
|
+
] }),
|
|
641
|
+
/* @__PURE__ */ jsxs2(
|
|
642
|
+
"div",
|
|
643
|
+
{
|
|
644
|
+
className: cn(
|
|
645
|
+
//
|
|
646
|
+
"w-full flex flex-col",
|
|
647
|
+
"text-[10px]",
|
|
648
|
+
"gap-[var(--ui-kit-gap)]"
|
|
649
|
+
),
|
|
650
|
+
children: [
|
|
651
|
+
/* @__PURE__ */ jsx2("span", { className: "text-[var(--ui-kit-fg-muted)]", children: t("passport:common.amount") }),
|
|
652
|
+
/* @__PURE__ */ jsx2(
|
|
653
|
+
Input,
|
|
654
|
+
{
|
|
655
|
+
type: "text",
|
|
656
|
+
disabled: isQuoteEstimating || !originChain || !destinationChain || !hyperRoute,
|
|
657
|
+
placeholder: t("passport:common.amount"),
|
|
658
|
+
onChange: (e) => {
|
|
659
|
+
useFlowSelectorStore.getState().setError(null);
|
|
660
|
+
let { value } = e.target;
|
|
661
|
+
const regex = /^(0|[1-9]\d*)(\.\d{0,5})?$/;
|
|
662
|
+
if (value.length > 1 && value.startsWith("0") && !value.startsWith("0.")) {
|
|
663
|
+
value = value.slice(1);
|
|
664
|
+
}
|
|
665
|
+
if (regex.test(value) || value === "") {
|
|
666
|
+
if (value === "") {
|
|
667
|
+
setAmount("0");
|
|
668
|
+
} else {
|
|
669
|
+
setAmount(value);
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
},
|
|
673
|
+
value: amount
|
|
674
|
+
}
|
|
675
|
+
)
|
|
676
|
+
]
|
|
677
|
+
}
|
|
678
|
+
),
|
|
679
|
+
/* @__PURE__ */ jsxs2(
|
|
680
|
+
"div",
|
|
681
|
+
{
|
|
682
|
+
className: cn(
|
|
683
|
+
//
|
|
684
|
+
"w-full flex flex-col",
|
|
685
|
+
"text-[10px]",
|
|
686
|
+
"gap-[var(--ui-kit-gap)] pb-[var(--ui-kit-pd)]"
|
|
687
|
+
),
|
|
688
|
+
children: [
|
|
689
|
+
/* @__PURE__ */ jsx2("span", { className: "text-[var(--ui-kit-fg-muted)]", children: t("passport:bridgeMenu.labels.recipient") + " (optional)" }),
|
|
690
|
+
/* @__PURE__ */ jsx2(
|
|
691
|
+
Input,
|
|
692
|
+
{
|
|
693
|
+
type: "text",
|
|
694
|
+
disabled: isQuoteEstimating || !originChain || !destinationChain || !hyperRoute,
|
|
695
|
+
placeholder: t("passport:bridgeMenu.labels.recipient") + " (ex: 0x...)",
|
|
696
|
+
value: recipient || "",
|
|
697
|
+
Icon: Wallet2Icon,
|
|
698
|
+
onChange: (e) => {
|
|
699
|
+
useFlowSelectorStore.getState().setError(null);
|
|
700
|
+
setRecipient(e.target.value);
|
|
701
|
+
},
|
|
702
|
+
element: /* @__PURE__ */ jsx2(
|
|
703
|
+
Button,
|
|
704
|
+
{
|
|
705
|
+
size: "icon",
|
|
706
|
+
variant: "ghost",
|
|
707
|
+
onClick: (e) => {
|
|
708
|
+
e.stopPropagation();
|
|
709
|
+
setRecipient(null);
|
|
710
|
+
},
|
|
711
|
+
children: /* @__PURE__ */ jsx2(XIcon, { className: "w-4 h-4" })
|
|
712
|
+
}
|
|
713
|
+
)
|
|
714
|
+
}
|
|
715
|
+
)
|
|
716
|
+
]
|
|
717
|
+
}
|
|
718
|
+
)
|
|
719
|
+
] }),
|
|
720
|
+
quote && /* @__PURE__ */ jsxs2(Highlight, { type: "info", className: "flex flex-col gap-[var(--ui-kit-gap)] w-full", children: [
|
|
721
|
+
/* @__PURE__ */ jsxs2("p", { className: "flex-1 flex items-center justify-between gap-[var(--ui-kit-gap)]", children: [
|
|
722
|
+
/* @__PURE__ */ jsx2("span", { children: t("passport:bridgeMenu.quote.amount") }),
|
|
723
|
+
/* @__PURE__ */ jsx2("strong", { children: formatPrice(Number(quote.amount)) })
|
|
724
|
+
] }),
|
|
725
|
+
/* @__PURE__ */ jsxs2("p", { className: "flex-1 flex items-center justify-between gap-[var(--ui-kit-gap)]", children: [
|
|
726
|
+
/* @__PURE__ */ jsx2("span", { children: t("passport:bridgeMenu.quote.igpFee") }),
|
|
727
|
+
/* @__PURE__ */ jsxs2("strong", { children: [
|
|
728
|
+
/* @__PURE__ */ jsx2("span", { children: formatPrice(Number(quote.igpFee)) }),
|
|
729
|
+
/* @__PURE__ */ jsxs2("span", { children: [
|
|
730
|
+
" ",
|
|
731
|
+
quote.igpSymbol
|
|
732
|
+
] })
|
|
733
|
+
] })
|
|
734
|
+
] }),
|
|
735
|
+
/* @__PURE__ */ jsxs2("p", { className: "flex-1 flex items-center justify-between gap-[var(--ui-kit-gap)]", children: [
|
|
736
|
+
/* @__PURE__ */ jsx2("span", { children: t("passport:bridgeMenu.quote.localFee") }),
|
|
737
|
+
/* @__PURE__ */ jsxs2("strong", { children: [
|
|
738
|
+
/* @__PURE__ */ jsx2("span", { children: formatPrice(Number(quote.localFee)) }),
|
|
739
|
+
/* @__PURE__ */ jsxs2("span", { children: [
|
|
740
|
+
" ",
|
|
741
|
+
quote.localSymbol
|
|
742
|
+
] })
|
|
743
|
+
] })
|
|
744
|
+
] }),
|
|
745
|
+
quote.tokenFee && /* @__PURE__ */ jsxs2("p", { className: "flex-1 flex items-center justify-between gap-[var(--ui-kit-gap)]", children: [
|
|
746
|
+
/* @__PURE__ */ jsx2("span", { children: t("passport:bridgeMenu.quote.tokenFee") }),
|
|
747
|
+
/* @__PURE__ */ jsx2("strong", { children: formatPrice(Number(quote.tokenFee)) })
|
|
748
|
+
] })
|
|
749
|
+
] }),
|
|
750
|
+
/* @__PURE__ */ jsxs2(
|
|
751
|
+
Button,
|
|
752
|
+
{
|
|
753
|
+
size: "large",
|
|
754
|
+
variant: "default",
|
|
755
|
+
className: "w-full",
|
|
756
|
+
disabled: isQuoteEstimating || isError || !quote,
|
|
757
|
+
onClick: () => useBridgeStore.getState().setBridgeStep("confirm"),
|
|
758
|
+
children: [
|
|
759
|
+
isQuoteEstimating && /* @__PURE__ */ jsx2(LoaderIcon, { className: "h-4 w-4 animate-spin" }),
|
|
760
|
+
/* @__PURE__ */ jsx2("span", { children: t(
|
|
761
|
+
(() => {
|
|
762
|
+
switch (true) {
|
|
763
|
+
// case isWalletChainConnecting:
|
|
764
|
+
// return 'passport:bridgeMenu.statuses.switchingWalletChain'
|
|
765
|
+
case isQuoteEstimating:
|
|
766
|
+
return "passport:bridgeMenu.statuses.qouteEstimating";
|
|
767
|
+
default:
|
|
768
|
+
return "passport:bridgeMenu.actions.confirmBridge";
|
|
769
|
+
}
|
|
770
|
+
})()
|
|
771
|
+
).toUpperCase() })
|
|
772
|
+
]
|
|
773
|
+
}
|
|
774
|
+
)
|
|
775
|
+
] });
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
// src/internal/components/SendMenu/hyperbridge/steps/ConfirmStep.tsx
|
|
779
|
+
import { LoaderIcon as LoaderIcon2 } from "lucide-react";
|
|
780
|
+
import { Fragment as Fragment3, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
781
|
+
var P_CN = "flex-1 flex items-center justify-between gap-[var(--ui-kit-gap)]";
|
|
782
|
+
function ConfirmStep(props) {
|
|
783
|
+
const { isAssetBridging, bridgeAsset } = props;
|
|
784
|
+
const { t } = useT();
|
|
785
|
+
const address = useSession((st) => st.address);
|
|
786
|
+
const isError = useFlowSelectorStore((st) => !!st.error);
|
|
787
|
+
const quote = useBridgeStore((st) => st.quote);
|
|
788
|
+
const originChain = useBridgeStore((st) => st.originChain);
|
|
789
|
+
const destinationChain = useBridgeStore((st) => st.destinationChain);
|
|
790
|
+
const recipient = useBridgeStore((st) => st.recipient);
|
|
791
|
+
const bridgeTxStatus = useBridgeStore((st) => st.bridgeTxStatus);
|
|
792
|
+
const recipientAddress = (recipient || address).slice(0, 6) + "..." + (recipient || address).slice(-4);
|
|
793
|
+
return /* @__PURE__ */ jsxs3(Fragment3, { children: [
|
|
794
|
+
/* @__PURE__ */ jsxs3(Highlight, { type: "info", className: "flex flex-col gap-[var(--ui-kit-gap)] w-full", children: [
|
|
795
|
+
/* @__PURE__ */ jsxs3("p", { className: P_CN, children: [
|
|
796
|
+
/* @__PURE__ */ jsx3("span", { children: t("passport:bridgeMenu.quote.recipient") }),
|
|
797
|
+
/* @__PURE__ */ jsx3("strong", { children: recipientAddress })
|
|
798
|
+
] }),
|
|
799
|
+
/* @__PURE__ */ jsxs3("p", { className: P_CN, children: [
|
|
800
|
+
/* @__PURE__ */ jsx3("span", { children: t("passport:bridgeMenu.labels.fromChain") }),
|
|
801
|
+
/* @__PURE__ */ jsx3("strong", { children: CHAINS_META[originChain].chainLabel })
|
|
802
|
+
] }),
|
|
803
|
+
/* @__PURE__ */ jsxs3("p", { className: P_CN, children: [
|
|
804
|
+
/* @__PURE__ */ jsx3("span", { children: t("passport:bridgeMenu.labels.toChain") }),
|
|
805
|
+
/* @__PURE__ */ jsx3("strong", { children: CHAINS_META[destinationChain].chainLabel })
|
|
806
|
+
] }),
|
|
807
|
+
/* @__PURE__ */ jsxs3("p", { className: P_CN, children: [
|
|
808
|
+
/* @__PURE__ */ jsx3("span", { children: t("passport:bridgeMenu.quote.amount") }),
|
|
809
|
+
/* @__PURE__ */ jsx3("strong", { children: formatPrice(Number(quote.amount)) })
|
|
810
|
+
] }),
|
|
811
|
+
/* @__PURE__ */ jsxs3("p", { className: "flex-1 flex items-center justify-between gap-[var(--ui-kit-gap)]", children: [
|
|
812
|
+
/* @__PURE__ */ jsx3("span", { children: t("passport:bridgeMenu.quote.igpFee") }),
|
|
813
|
+
/* @__PURE__ */ jsxs3("strong", { children: [
|
|
814
|
+
/* @__PURE__ */ jsx3("span", { children: formatPrice(Number(quote.igpFee)) }),
|
|
815
|
+
/* @__PURE__ */ jsxs3("span", { children: [
|
|
816
|
+
" ",
|
|
817
|
+
quote.igpSymbol
|
|
818
|
+
] })
|
|
819
|
+
] })
|
|
820
|
+
] }),
|
|
821
|
+
/* @__PURE__ */ jsxs3("p", { className: "flex-1 flex items-center justify-between gap-[var(--ui-kit-gap)]", children: [
|
|
822
|
+
/* @__PURE__ */ jsx3("span", { children: t("passport:bridgeMenu.quote.localFee") }),
|
|
823
|
+
/* @__PURE__ */ jsxs3("strong", { children: [
|
|
824
|
+
/* @__PURE__ */ jsx3("span", { children: formatPrice(Number(quote.localFee)) }),
|
|
825
|
+
/* @__PURE__ */ jsxs3("span", { children: [
|
|
826
|
+
" ",
|
|
827
|
+
quote.localSymbol
|
|
828
|
+
] })
|
|
829
|
+
] })
|
|
830
|
+
] }),
|
|
831
|
+
quote.tokenFee && /* @__PURE__ */ jsxs3("p", { className: P_CN, children: [
|
|
832
|
+
/* @__PURE__ */ jsx3("span", { children: t("passport:bridgeMenu.quote.tokenFee") }),
|
|
833
|
+
/* @__PURE__ */ jsx3("strong", { children: formatPrice(Number(quote.tokenFee)) })
|
|
834
|
+
] })
|
|
835
|
+
] }),
|
|
836
|
+
!isError && /* @__PURE__ */ jsxs3(
|
|
837
|
+
Button,
|
|
838
|
+
{
|
|
839
|
+
size: "large",
|
|
840
|
+
variant: "default",
|
|
841
|
+
disabled: isAssetBridging,
|
|
842
|
+
onClick: () => bridgeAsset(),
|
|
843
|
+
className: "w-full",
|
|
844
|
+
children: [
|
|
845
|
+
isAssetBridging && /* @__PURE__ */ jsx3(LoaderIcon2, { className: "h-4 w-4 animate-spin" }),
|
|
846
|
+
/* @__PURE__ */ jsx3("span", { children: (bridgeTxStatus || t("passport:common.continue")).toUpperCase() })
|
|
847
|
+
]
|
|
848
|
+
}
|
|
849
|
+
)
|
|
850
|
+
] });
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
// src/internal/components/SendMenu/hyperbridge/steps/SuccessStep.tsx
|
|
854
|
+
import { Fragment as Fragment4, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
855
|
+
var P_CN2 = "flex-1 flex items-center justify-between gap-[var(--ui-kit-gap)]";
|
|
856
|
+
function SuccessStep() {
|
|
857
|
+
const { t } = useT();
|
|
858
|
+
const address = useSession((st) => st.address);
|
|
859
|
+
const amount = useBridgeStore((st) => st.amount);
|
|
860
|
+
const originChain = useBridgeStore((st) => st.originChain);
|
|
861
|
+
const destinationChain = useBridgeStore((st) => st.destinationChain);
|
|
862
|
+
const recipient = useBridgeStore((st) => st.recipient);
|
|
863
|
+
const lastTxHashes = useBridgeStore((st) => st.lastTxHashes);
|
|
864
|
+
const bridgeTxStatus = useBridgeStore((st) => st.bridgeTxStatus);
|
|
865
|
+
const recipientAddress = (recipient || address).slice(0, 6) + "..." + (recipient || address).slice(-4);
|
|
866
|
+
return /* @__PURE__ */ jsxs4(Fragment4, { children: [
|
|
867
|
+
/* @__PURE__ */ jsxs4(Highlight, { type: "info", className: "flex flex-col gap-[var(--ui-kit-gap)] w-full", children: [
|
|
868
|
+
/* @__PURE__ */ jsxs4("p", { className: P_CN2, children: [
|
|
869
|
+
/* @__PURE__ */ jsx4("span", { children: t("passport:bridgeMenu.quote.status") }),
|
|
870
|
+
/* @__PURE__ */ jsx4("strong", { children: bridgeTxStatus })
|
|
871
|
+
] }),
|
|
872
|
+
/* @__PURE__ */ jsxs4("p", { className: P_CN2, children: [
|
|
873
|
+
/* @__PURE__ */ jsx4("span", { children: t("passport:bridgeMenu.quote.recipient") }),
|
|
874
|
+
/* @__PURE__ */ jsx4("strong", { children: recipientAddress })
|
|
875
|
+
] }),
|
|
876
|
+
/* @__PURE__ */ jsxs4("p", { className: P_CN2, children: [
|
|
877
|
+
/* @__PURE__ */ jsx4("span", { children: t("passport:bridgeMenu.labels.fromChain") }),
|
|
878
|
+
/* @__PURE__ */ jsx4("strong", { children: CHAINS_META[originChain].chainLabel })
|
|
879
|
+
] }),
|
|
880
|
+
/* @__PURE__ */ jsxs4("p", { className: P_CN2, children: [
|
|
881
|
+
/* @__PURE__ */ jsx4("span", { children: t("passport:bridgeMenu.labels.toChain") }),
|
|
882
|
+
/* @__PURE__ */ jsx4("strong", { children: CHAINS_META[destinationChain].chainLabel })
|
|
883
|
+
] }),
|
|
884
|
+
/* @__PURE__ */ jsxs4("p", { className: P_CN2, children: [
|
|
885
|
+
/* @__PURE__ */ jsx4("span", { children: t("passport:bridgeMenu.quote.amount") }),
|
|
886
|
+
/* @__PURE__ */ jsx4("strong", { children: formatPrice(Number(amount)) })
|
|
887
|
+
] }),
|
|
888
|
+
lastTxHashes.map((hash) => /* @__PURE__ */ jsxs4("p", { className: P_CN2, children: [
|
|
889
|
+
/* @__PURE__ */ jsx4("span", { children: "TX" }),
|
|
890
|
+
/* @__PURE__ */ jsx4("strong", { children: hash })
|
|
891
|
+
] }))
|
|
892
|
+
] }),
|
|
893
|
+
/* @__PURE__ */ jsx4(
|
|
894
|
+
Button,
|
|
895
|
+
{
|
|
896
|
+
size: "large",
|
|
897
|
+
variant: "default",
|
|
898
|
+
className: "w-full",
|
|
899
|
+
onClick: () => {
|
|
900
|
+
useFlowSelectorStore.getState().setError(null);
|
|
901
|
+
useBridgeStore.getState().setBridgeTxStatus(null);
|
|
902
|
+
useBridgeStore.getState().setLastTxHashes([]);
|
|
903
|
+
useBridgeStore.getState().setBridgeStep("select");
|
|
904
|
+
},
|
|
905
|
+
children: /* @__PURE__ */ jsx4("span", { children: `${t("passport:common.continue")}`.toUpperCase() })
|
|
906
|
+
}
|
|
907
|
+
)
|
|
908
|
+
] });
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
// src/internal/components/SendMenu/hyperbridge/HyperlaneBridge.tsx
|
|
912
|
+
import { Fragment as Fragment5, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
913
|
+
function HyperlaneBridge() {
|
|
914
|
+
const { swapDirection, bridgeAsset, isAssetBridging } = useBridge();
|
|
915
|
+
useMenuTitle();
|
|
916
|
+
const bridgeStep = useBridgeStore((st) => st.bridgeStep);
|
|
917
|
+
useEffect4(() => () => useBridgeStore.getState().resetSelections(), []);
|
|
918
|
+
return /* @__PURE__ */ jsxs5(Fragment5, { children: [
|
|
919
|
+
bridgeStep === "select-token" && /* @__PURE__ */ jsx5(TokenSelector, {}),
|
|
920
|
+
bridgeStep === "select" && /* @__PURE__ */ jsx5(SelectStep, { swapChains: swapDirection }),
|
|
921
|
+
bridgeStep === "confirm" && /* @__PURE__ */ jsx5(ConfirmStep, { isAssetBridging, bridgeAsset }),
|
|
922
|
+
bridgeStep === "success" && /* @__PURE__ */ jsx5(SuccessStep, {})
|
|
923
|
+
] });
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
// src/internal/components/SendMenu/hyperbridge/index.ts
|
|
927
|
+
var hyperbridge_default = HyperlaneBridge;
|
|
928
|
+
export {
|
|
929
|
+
hyperbridge_default as default,
|
|
930
|
+
useBridgeStore
|
|
931
|
+
};
|
|
932
|
+
//# sourceMappingURL=hyperbridge-OU2MDJ5Q.js.map
|