@siphoyawe/mina-cli 1.1.0 → 1.2.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/dist/index.js +1095 -700
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3,16 +3,20 @@
|
|
|
3
3
|
// src/index.tsx
|
|
4
4
|
import { Command } from "commander";
|
|
5
5
|
import chalk from "chalk";
|
|
6
|
-
import
|
|
6
|
+
import React12 from "react";
|
|
7
7
|
import { render } from "ink";
|
|
8
8
|
|
|
9
9
|
// src/commands/wizard.tsx
|
|
10
|
-
import { useState, useEffect, useCallback } from "react";
|
|
11
|
-
import { Box as
|
|
10
|
+
import { useState as useState2, useEffect as useEffect2, useCallback } from "react";
|
|
11
|
+
import { Box as Box8, Text as Text8, useApp, useInput as useInput2 } from "ink";
|
|
12
12
|
import {
|
|
13
|
+
Mina,
|
|
13
14
|
getChains,
|
|
14
15
|
getBridgeableTokens,
|
|
15
|
-
|
|
16
|
+
getQuote,
|
|
17
|
+
HYPEREVM_CHAIN_ID,
|
|
18
|
+
HYPEREVM_USDC_ADDRESS,
|
|
19
|
+
normalizeError
|
|
16
20
|
} from "@siphoyawe/mina-sdk";
|
|
17
21
|
|
|
18
22
|
// src/ui/theme.ts
|
|
@@ -73,7 +77,9 @@ var symbols = {
|
|
|
73
77
|
bullet: "\u2022",
|
|
74
78
|
arrow: "\u203A",
|
|
75
79
|
check: "\u2714",
|
|
76
|
-
cross: "\u2718"
|
|
80
|
+
cross: "\u2718",
|
|
81
|
+
search: "\u2315",
|
|
82
|
+
star: "\u2605"
|
|
77
83
|
};
|
|
78
84
|
var MINA_LOGO = `
|
|
79
85
|
__ __ ___ _ _ _
|
|
@@ -209,28 +215,32 @@ function Select({
|
|
|
209
215
|
function ChainSelect({
|
|
210
216
|
chains,
|
|
211
217
|
onSelect,
|
|
212
|
-
label = "Select Chain:"
|
|
218
|
+
label = "Select Chain:",
|
|
219
|
+
limit = 8
|
|
213
220
|
}) {
|
|
214
221
|
return /* @__PURE__ */ jsx3(
|
|
215
222
|
Select,
|
|
216
223
|
{
|
|
217
224
|
items: chains,
|
|
218
225
|
onSelect: (item) => onSelect(item),
|
|
219
|
-
label
|
|
226
|
+
label,
|
|
227
|
+
limit
|
|
220
228
|
}
|
|
221
229
|
);
|
|
222
230
|
}
|
|
223
231
|
function TokenSelect({
|
|
224
232
|
tokens,
|
|
225
233
|
onSelect,
|
|
226
|
-
label = "Select Token:"
|
|
234
|
+
label = "Select Token:",
|
|
235
|
+
limit = 10
|
|
227
236
|
}) {
|
|
228
237
|
return /* @__PURE__ */ jsx3(
|
|
229
238
|
Select,
|
|
230
239
|
{
|
|
231
240
|
items: tokens,
|
|
232
241
|
onSelect: (item) => onSelect(item),
|
|
233
|
-
label
|
|
242
|
+
label,
|
|
243
|
+
limit
|
|
234
244
|
}
|
|
235
245
|
);
|
|
236
246
|
}
|
|
@@ -483,43 +493,349 @@ function KeyValue({
|
|
|
483
493
|
] }, index)) });
|
|
484
494
|
}
|
|
485
495
|
|
|
486
|
-
// src/
|
|
496
|
+
// src/ui/SearchableList.tsx
|
|
497
|
+
import { useState, useMemo, useEffect } from "react";
|
|
498
|
+
import { Box as Box7, Text as Text7, useInput, useStdin } from "ink";
|
|
487
499
|
import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
500
|
+
function fuzzyMatch(query, text) {
|
|
501
|
+
const lowerQuery = query.toLowerCase();
|
|
502
|
+
const lowerText = text.toLowerCase();
|
|
503
|
+
if (lowerText.includes(lowerQuery)) return true;
|
|
504
|
+
let queryIndex = 0;
|
|
505
|
+
for (const char of lowerText) {
|
|
506
|
+
if (char === lowerQuery[queryIndex]) {
|
|
507
|
+
queryIndex++;
|
|
508
|
+
if (queryIndex === lowerQuery.length) return true;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
return false;
|
|
512
|
+
}
|
|
513
|
+
function sortItems(items, popularIds) {
|
|
514
|
+
return [...items].sort((a, b) => {
|
|
515
|
+
const aPopular = popularIds.includes(a.id);
|
|
516
|
+
const bPopular = popularIds.includes(b.id);
|
|
517
|
+
if (aPopular && !bPopular) return -1;
|
|
518
|
+
if (!aPopular && bPopular) return 1;
|
|
519
|
+
return a.label.localeCompare(b.label);
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
function KeyboardHandler({
|
|
523
|
+
searchable,
|
|
524
|
+
totalItemsLength,
|
|
525
|
+
selectedIndex,
|
|
526
|
+
setSelectedIndex,
|
|
527
|
+
setQuery,
|
|
528
|
+
setViewportStart,
|
|
529
|
+
onSelect,
|
|
530
|
+
filteredItems
|
|
531
|
+
}) {
|
|
532
|
+
useInput((input, key) => {
|
|
533
|
+
if (searchable) {
|
|
534
|
+
if (key.backspace || key.delete) {
|
|
535
|
+
setQuery((q) => q.slice(0, -1));
|
|
536
|
+
setSelectedIndex(0);
|
|
537
|
+
setViewportStart(0);
|
|
538
|
+
} else if (input && !key.ctrl && !key.meta && input.length === 1 && input.match(/[a-zA-Z0-9 -]/)) {
|
|
539
|
+
setQuery((q) => q + input);
|
|
540
|
+
setSelectedIndex(0);
|
|
541
|
+
setViewportStart(0);
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
if (key.upArrow) {
|
|
545
|
+
setSelectedIndex((i) => Math.max(0, i - 1));
|
|
546
|
+
} else if (key.downArrow) {
|
|
547
|
+
setSelectedIndex((i) => Math.min(totalItemsLength - 1, i + 1));
|
|
548
|
+
} else if (key.return && onSelect && filteredItems[selectedIndex]) {
|
|
549
|
+
onSelect(filteredItems[selectedIndex]);
|
|
550
|
+
}
|
|
551
|
+
});
|
|
552
|
+
return null;
|
|
553
|
+
}
|
|
554
|
+
function SearchableList({
|
|
555
|
+
items,
|
|
556
|
+
title,
|
|
557
|
+
placeholder = "Type to search...",
|
|
558
|
+
pageSize = 8,
|
|
559
|
+
popularIds = [],
|
|
560
|
+
onSelect,
|
|
561
|
+
searchable = true,
|
|
562
|
+
maxDisplay = 10
|
|
563
|
+
}) {
|
|
564
|
+
const { isRawModeSupported } = useStdin();
|
|
565
|
+
const isInteractive = isRawModeSupported;
|
|
566
|
+
const [query, setQuery] = useState("");
|
|
567
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
568
|
+
const [viewportStart, setViewportStart] = useState(0);
|
|
569
|
+
const filteredItems = useMemo(() => {
|
|
570
|
+
let result = items;
|
|
571
|
+
if (query) {
|
|
572
|
+
result = items.filter(
|
|
573
|
+
(item) => fuzzyMatch(query, item.label) || item.sublabel && fuzzyMatch(query, item.sublabel)
|
|
574
|
+
);
|
|
575
|
+
}
|
|
576
|
+
return sortItems(result, popularIds);
|
|
577
|
+
}, [items, query, popularIds]);
|
|
578
|
+
const viewportSize = Math.min(maxDisplay, filteredItems.length);
|
|
579
|
+
useEffect(() => {
|
|
580
|
+
if (selectedIndex < viewportStart) {
|
|
581
|
+
setViewportStart(selectedIndex);
|
|
582
|
+
} else if (selectedIndex >= viewportStart + viewportSize) {
|
|
583
|
+
setViewportStart(Math.max(0, selectedIndex - viewportSize + 1));
|
|
584
|
+
}
|
|
585
|
+
}, [selectedIndex, viewportStart, viewportSize]);
|
|
586
|
+
const displayedItems = filteredItems.slice(viewportStart, viewportStart + viewportSize);
|
|
587
|
+
const hasMoreAbove = viewportStart > 0;
|
|
588
|
+
const hasMoreBelow = viewportStart + viewportSize < filteredItems.length;
|
|
589
|
+
const safeIndex = Math.min(selectedIndex, Math.max(0, filteredItems.length - 1));
|
|
590
|
+
const viewportSelectedIndex = safeIndex - viewportStart;
|
|
591
|
+
return /* @__PURE__ */ jsxs7(Box7, { flexDirection: "column", children: [
|
|
592
|
+
isInteractive && /* @__PURE__ */ jsx7(
|
|
593
|
+
KeyboardHandler,
|
|
594
|
+
{
|
|
595
|
+
searchable,
|
|
596
|
+
totalItemsLength: filteredItems.length,
|
|
597
|
+
selectedIndex,
|
|
598
|
+
setSelectedIndex,
|
|
599
|
+
setQuery,
|
|
600
|
+
setViewportStart,
|
|
601
|
+
onSelect,
|
|
602
|
+
filteredItems
|
|
603
|
+
}
|
|
604
|
+
),
|
|
605
|
+
title && /* @__PURE__ */ jsxs7(Box7, { marginBottom: 1, children: [
|
|
606
|
+
/* @__PURE__ */ jsxs7(Text7, { color: theme.secondary, children: [
|
|
607
|
+
symbols.arrow,
|
|
608
|
+
" ",
|
|
609
|
+
title
|
|
610
|
+
] }),
|
|
611
|
+
/* @__PURE__ */ jsxs7(Text7, { color: theme.muted, children: [
|
|
612
|
+
" (",
|
|
613
|
+
filteredItems.length,
|
|
614
|
+
")"
|
|
615
|
+
] })
|
|
616
|
+
] }),
|
|
617
|
+
searchable && isInteractive && /* @__PURE__ */ jsxs7(Box7, { marginBottom: 1, children: [
|
|
618
|
+
/* @__PURE__ */ jsx7(Text7, { color: theme.border, children: borders.vertical }),
|
|
619
|
+
/* @__PURE__ */ jsxs7(Text7, { color: theme.muted, children: [
|
|
620
|
+
" ",
|
|
621
|
+
symbols.search,
|
|
622
|
+
" "
|
|
623
|
+
] }),
|
|
624
|
+
query ? /* @__PURE__ */ jsx7(Text7, { color: theme.primary, children: query }) : /* @__PURE__ */ jsx7(Text7, { color: theme.muted, dimColor: true, children: placeholder }),
|
|
625
|
+
/* @__PURE__ */ jsx7(Text7, { color: theme.accent, children: "\u258C" })
|
|
626
|
+
] }),
|
|
627
|
+
hasMoreAbove && isInteractive && /* @__PURE__ */ jsxs7(Box7, { children: [
|
|
628
|
+
/* @__PURE__ */ jsx7(Text7, { color: theme.accent, children: " \u25B2" }),
|
|
629
|
+
/* @__PURE__ */ jsxs7(Text7, { color: theme.muted, dimColor: true, children: [
|
|
630
|
+
" ",
|
|
631
|
+
viewportStart,
|
|
632
|
+
" more above"
|
|
633
|
+
] })
|
|
634
|
+
] }),
|
|
635
|
+
/* @__PURE__ */ jsxs7(Box7, { flexDirection: "column", children: [
|
|
636
|
+
displayedItems.map((item, index) => {
|
|
637
|
+
const isSelected = isInteractive && index === viewportSelectedIndex;
|
|
638
|
+
const isPopular = popularIds.includes(item.id);
|
|
639
|
+
return /* @__PURE__ */ jsxs7(Box7, { children: [
|
|
640
|
+
isInteractive && /* @__PURE__ */ jsx7(Text7, { color: isSelected ? theme.accent : theme.border, children: isSelected ? symbols.arrow : " " }),
|
|
641
|
+
/* @__PURE__ */ jsx7(Text7, { children: " " }),
|
|
642
|
+
isPopular && /* @__PURE__ */ jsx7(Text7, { color: theme.warning, children: "\u2605 " }),
|
|
643
|
+
/* @__PURE__ */ jsx7(
|
|
644
|
+
Text7,
|
|
645
|
+
{
|
|
646
|
+
color: isSelected ? theme.primary : theme.secondary,
|
|
647
|
+
bold: isSelected,
|
|
648
|
+
children: item.label
|
|
649
|
+
}
|
|
650
|
+
),
|
|
651
|
+
item.sublabel && /* @__PURE__ */ jsxs7(Text7, { color: theme.muted, dimColor: true, children: [
|
|
652
|
+
" ",
|
|
653
|
+
"(",
|
|
654
|
+
item.sublabel,
|
|
655
|
+
")"
|
|
656
|
+
] }),
|
|
657
|
+
item.badge && /* @__PURE__ */ jsxs7(Text7, { color: item.badgeColor || theme.accent, children: [
|
|
658
|
+
" ",
|
|
659
|
+
"[",
|
|
660
|
+
item.badge,
|
|
661
|
+
"]"
|
|
662
|
+
] })
|
|
663
|
+
] }, item.id);
|
|
664
|
+
}),
|
|
665
|
+
displayedItems.length === 0 && /* @__PURE__ */ jsx7(Box7, { children: /* @__PURE__ */ jsxs7(Text7, { color: theme.muted, dimColor: true, children: [
|
|
666
|
+
'No matches for "',
|
|
667
|
+
query,
|
|
668
|
+
'"'
|
|
669
|
+
] }) })
|
|
670
|
+
] }),
|
|
671
|
+
hasMoreBelow && isInteractive && /* @__PURE__ */ jsxs7(Box7, { children: [
|
|
672
|
+
/* @__PURE__ */ jsx7(Text7, { color: theme.accent, children: " \u25BC" }),
|
|
673
|
+
/* @__PURE__ */ jsxs7(Text7, { color: theme.muted, dimColor: true, children: [
|
|
674
|
+
" ",
|
|
675
|
+
filteredItems.length - viewportStart - viewportSize,
|
|
676
|
+
" more below"
|
|
677
|
+
] })
|
|
678
|
+
] }),
|
|
679
|
+
isInteractive && /* @__PURE__ */ jsx7(Box7, { marginTop: 1, children: /* @__PURE__ */ jsxs7(Text7, { color: theme.muted, dimColor: true, children: [
|
|
680
|
+
"\u2191\u2193 scroll",
|
|
681
|
+
onSelect ? " \u2022 Enter select" : "",
|
|
682
|
+
searchable ? " \u2022 Type to filter" : "",
|
|
683
|
+
filteredItems.length > viewportSize && ` \u2022 ${safeIndex + 1}/${filteredItems.length}`
|
|
684
|
+
] }) })
|
|
685
|
+
] });
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
// src/lib/wallet.ts
|
|
689
|
+
import fs from "fs";
|
|
690
|
+
import readline from "readline";
|
|
691
|
+
async function loadPrivateKey(path3) {
|
|
692
|
+
if (path3) {
|
|
693
|
+
if (!fs.existsSync(path3)) {
|
|
694
|
+
throw new Error(`Key file not found: ${path3}`);
|
|
695
|
+
}
|
|
696
|
+
const content = fs.readFileSync(path3, "utf-8");
|
|
697
|
+
try {
|
|
698
|
+
const json = JSON.parse(content);
|
|
699
|
+
const key = json.privateKey || json.private_key || json.key;
|
|
700
|
+
if (key) {
|
|
701
|
+
return normalizePrivateKey(key);
|
|
702
|
+
}
|
|
703
|
+
return normalizePrivateKey(content.trim());
|
|
704
|
+
} catch {
|
|
705
|
+
return normalizePrivateKey(content.trim());
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
return promptForPrivateKey();
|
|
709
|
+
}
|
|
710
|
+
function promptForPrivateKey() {
|
|
711
|
+
return new Promise((resolve, reject) => {
|
|
712
|
+
const rl = readline.createInterface({
|
|
713
|
+
input: process.stdin,
|
|
714
|
+
output: process.stdout
|
|
715
|
+
});
|
|
716
|
+
process.stdout.write("Enter private key (input will be visible): ");
|
|
717
|
+
rl.on("line", (answer) => {
|
|
718
|
+
rl.close();
|
|
719
|
+
try {
|
|
720
|
+
resolve(normalizePrivateKey(answer.trim()));
|
|
721
|
+
} catch (err) {
|
|
722
|
+
reject(err);
|
|
723
|
+
}
|
|
724
|
+
});
|
|
725
|
+
rl.on("close", () => {
|
|
726
|
+
});
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
function normalizePrivateKey(key) {
|
|
730
|
+
const trimmed = key.trim();
|
|
731
|
+
const keyWithoutPrefix = trimmed.startsWith("0x") ? trimmed.slice(2) : trimmed;
|
|
732
|
+
if (!/^[0-9a-fA-F]{64}$/.test(keyWithoutPrefix)) {
|
|
733
|
+
throw new Error("Invalid private key format. Expected 64 hex characters.");
|
|
734
|
+
}
|
|
735
|
+
return trimmed.startsWith("0x") ? trimmed : `0x${trimmed}`;
|
|
736
|
+
}
|
|
737
|
+
async function getAddressFromPrivateKey(privateKey) {
|
|
738
|
+
const { privateKeyToAccount } = await import("viem/accounts");
|
|
739
|
+
const account = privateKeyToAccount(privateKey);
|
|
740
|
+
return account.address;
|
|
741
|
+
}
|
|
742
|
+
async function createSigner(privateKey, chainId, rpcUrl) {
|
|
743
|
+
const { privateKeyToAccount } = await import("viem/accounts");
|
|
744
|
+
const { createWalletClient, http } = await import("viem");
|
|
745
|
+
const { arbitrum, mainnet, optimism, polygon, base, avalanche, bsc } = await import("viem/chains");
|
|
746
|
+
const chainMap = {
|
|
747
|
+
1: mainnet,
|
|
748
|
+
42161: arbitrum,
|
|
749
|
+
10: optimism,
|
|
750
|
+
137: polygon,
|
|
751
|
+
8453: base,
|
|
752
|
+
43114: avalanche,
|
|
753
|
+
56: bsc,
|
|
754
|
+
// HyperEVM
|
|
755
|
+
999: {
|
|
756
|
+
id: 999,
|
|
757
|
+
name: "HyperEVM",
|
|
758
|
+
nativeCurrency: { name: "ETH", symbol: "ETH", decimals: 18 },
|
|
759
|
+
rpcUrls: {
|
|
760
|
+
default: { http: ["https://rpc.hyperliquid.xyz/evm"] }
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
};
|
|
764
|
+
const chain = chainMap[chainId];
|
|
765
|
+
if (!chain) {
|
|
766
|
+
throw new Error(`Unsupported chain ID: ${chainId}. Supported: ${Object.keys(chainMap).join(", ")}`);
|
|
767
|
+
}
|
|
768
|
+
const account = privateKeyToAccount(privateKey);
|
|
769
|
+
const transport = rpcUrl ? http(rpcUrl) : http();
|
|
770
|
+
const walletClient = createWalletClient({
|
|
771
|
+
account,
|
|
772
|
+
chain,
|
|
773
|
+
transport
|
|
774
|
+
});
|
|
775
|
+
return {
|
|
776
|
+
sendTransaction: async (request) => {
|
|
777
|
+
const txHash = await walletClient.sendTransaction({
|
|
778
|
+
to: request.to,
|
|
779
|
+
data: request.data,
|
|
780
|
+
value: BigInt(request.value || "0"),
|
|
781
|
+
gas: request.gasLimit ? BigInt(request.gasLimit) : void 0,
|
|
782
|
+
gasPrice: request.gasPrice ? BigInt(request.gasPrice) : void 0,
|
|
783
|
+
chain
|
|
784
|
+
});
|
|
785
|
+
return txHash;
|
|
786
|
+
},
|
|
787
|
+
getAddress: async () => {
|
|
788
|
+
return account.address;
|
|
789
|
+
},
|
|
790
|
+
getChainId: async () => {
|
|
791
|
+
return chainId;
|
|
792
|
+
}
|
|
793
|
+
};
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
// src/commands/wizard.tsx
|
|
797
|
+
import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
488
798
|
var initialState = {
|
|
489
799
|
step: "chain",
|
|
490
800
|
chain: null,
|
|
491
801
|
token: null,
|
|
492
802
|
amount: "",
|
|
493
803
|
quote: null,
|
|
494
|
-
error: null
|
|
804
|
+
error: null,
|
|
805
|
+
privateKey: null,
|
|
806
|
+
walletAddress: null,
|
|
807
|
+
executionResult: null,
|
|
808
|
+
executionStatus: ""
|
|
495
809
|
};
|
|
496
810
|
function NavigationHints({ step }) {
|
|
497
811
|
const hints = {
|
|
498
812
|
chain: "up/down Select Enter Confirm q Quit",
|
|
499
813
|
token: "up/down Select Enter Confirm b Back q Quit",
|
|
500
814
|
amount: "Enter Confirm b Back q Quit",
|
|
815
|
+
key: "Enter Confirm b Back q Quit",
|
|
501
816
|
confirm: "Enter Execute b Back q Quit",
|
|
502
817
|
execute: "Please wait..."
|
|
503
818
|
};
|
|
504
|
-
return /* @__PURE__ */
|
|
819
|
+
return /* @__PURE__ */ jsx8(Box8, { marginTop: 1, children: /* @__PURE__ */ jsx8(Text8, { color: theme.muted, dimColor: true, children: hints[step] }) });
|
|
505
820
|
}
|
|
506
821
|
function StepIndicator({ currentStep }) {
|
|
507
|
-
const steps = ["chain", "token", "amount", "confirm", "execute"];
|
|
822
|
+
const steps = ["chain", "token", "amount", "key", "confirm", "execute"];
|
|
508
823
|
const stepLabels = {
|
|
509
824
|
chain: "Chain",
|
|
510
825
|
token: "Token",
|
|
511
826
|
amount: "Amount",
|
|
827
|
+
key: "Wallet",
|
|
512
828
|
confirm: "Confirm",
|
|
513
829
|
execute: "Execute"
|
|
514
830
|
};
|
|
515
831
|
const currentIndex = steps.indexOf(currentStep);
|
|
516
|
-
return /* @__PURE__ */
|
|
832
|
+
return /* @__PURE__ */ jsx8(Box8, { marginBottom: 1, children: steps.map((step, index) => {
|
|
517
833
|
const isActive = index === currentIndex;
|
|
518
834
|
const isCompleted = index < currentIndex;
|
|
519
835
|
const separator = index < steps.length - 1 ? " > " : "";
|
|
520
|
-
return /* @__PURE__ */
|
|
521
|
-
/* @__PURE__ */
|
|
522
|
-
|
|
836
|
+
return /* @__PURE__ */ jsxs8(Text8, { children: [
|
|
837
|
+
/* @__PURE__ */ jsxs8(
|
|
838
|
+
Text8,
|
|
523
839
|
{
|
|
524
840
|
color: isActive ? theme.primary : isCompleted ? theme.success : theme.muted,
|
|
525
841
|
bold: isActive,
|
|
@@ -531,7 +847,7 @@ function StepIndicator({ currentStep }) {
|
|
|
531
847
|
]
|
|
532
848
|
}
|
|
533
849
|
),
|
|
534
|
-
/* @__PURE__ */
|
|
850
|
+
/* @__PURE__ */ jsx8(Text8, { color: theme.muted, dimColor: true, children: separator })
|
|
535
851
|
] }, step);
|
|
536
852
|
}) });
|
|
537
853
|
}
|
|
@@ -539,10 +855,10 @@ function ChainSelectionStep({
|
|
|
539
855
|
onSelect,
|
|
540
856
|
selectedChain
|
|
541
857
|
}) {
|
|
542
|
-
const [chains, setChains] =
|
|
543
|
-
const [loading, setLoading] =
|
|
544
|
-
const [error, setError] =
|
|
545
|
-
|
|
858
|
+
const [chains, setChains] = useState2([]);
|
|
859
|
+
const [loading, setLoading] = useState2(true);
|
|
860
|
+
const [error, setError] = useState2(null);
|
|
861
|
+
useEffect2(() => {
|
|
546
862
|
async function loadChains() {
|
|
547
863
|
try {
|
|
548
864
|
setLoading(true);
|
|
@@ -559,16 +875,16 @@ function ChainSelectionStep({
|
|
|
559
875
|
loadChains();
|
|
560
876
|
}, []);
|
|
561
877
|
if (loading) {
|
|
562
|
-
return /* @__PURE__ */
|
|
878
|
+
return /* @__PURE__ */ jsx8(Spinner, { text: "Loading available chains..." });
|
|
563
879
|
}
|
|
564
880
|
if (error) {
|
|
565
|
-
return /* @__PURE__ */
|
|
566
|
-
/* @__PURE__ */
|
|
881
|
+
return /* @__PURE__ */ jsxs8(Box8, { flexDirection: "column", children: [
|
|
882
|
+
/* @__PURE__ */ jsxs8(Text8, { color: theme.error, children: [
|
|
567
883
|
symbols.failed,
|
|
568
884
|
" Error: ",
|
|
569
885
|
error
|
|
570
886
|
] }),
|
|
571
|
-
/* @__PURE__ */
|
|
887
|
+
/* @__PURE__ */ jsx8(Text8, { color: theme.muted, children: "Press q to quit and try again" })
|
|
572
888
|
] });
|
|
573
889
|
}
|
|
574
890
|
const chainItems = chains.map((chain) => ({
|
|
@@ -578,9 +894,9 @@ function ChainSelectionStep({
|
|
|
578
894
|
type: "origin",
|
|
579
895
|
description: `Chain ID: ${chain.id}`
|
|
580
896
|
}));
|
|
581
|
-
return /* @__PURE__ */
|
|
582
|
-
/* @__PURE__ */
|
|
583
|
-
/* @__PURE__ */
|
|
897
|
+
return /* @__PURE__ */ jsxs8(Box8, { flexDirection: "column", children: [
|
|
898
|
+
/* @__PURE__ */ jsx8(Box8, { marginBottom: 1, children: /* @__PURE__ */ jsx8(Text8, { color: theme.secondary, bold: true, children: "Select source chain to bridge from:" }) }),
|
|
899
|
+
/* @__PURE__ */ jsx8(
|
|
584
900
|
ChainSelect,
|
|
585
901
|
{
|
|
586
902
|
chains: chainItems,
|
|
@@ -591,7 +907,7 @@ function ChainSelectionStep({
|
|
|
591
907
|
label: ""
|
|
592
908
|
}
|
|
593
909
|
),
|
|
594
|
-
/* @__PURE__ */
|
|
910
|
+
/* @__PURE__ */ jsx8(Box8, { marginTop: 1, children: /* @__PURE__ */ jsxs8(Text8, { color: theme.muted, dimColor: true, children: [
|
|
595
911
|
"Destination: HyperEVM (Chain ID: ",
|
|
596
912
|
HYPEREVM_CHAIN_ID,
|
|
597
913
|
")"
|
|
@@ -603,10 +919,10 @@ function TokenSelectionStep({
|
|
|
603
919
|
onSelect,
|
|
604
920
|
selectedToken
|
|
605
921
|
}) {
|
|
606
|
-
const [tokens, setTokens] =
|
|
607
|
-
const [loading, setLoading] =
|
|
608
|
-
const [error, setError] =
|
|
609
|
-
|
|
922
|
+
const [tokens, setTokens] = useState2([]);
|
|
923
|
+
const [loading, setLoading] = useState2(true);
|
|
924
|
+
const [error, setError] = useState2(null);
|
|
925
|
+
useEffect2(() => {
|
|
610
926
|
async function loadTokens() {
|
|
611
927
|
try {
|
|
612
928
|
setLoading(true);
|
|
@@ -622,26 +938,26 @@ function TokenSelectionStep({
|
|
|
622
938
|
loadTokens();
|
|
623
939
|
}, [chain.id]);
|
|
624
940
|
if (loading) {
|
|
625
|
-
return /* @__PURE__ */
|
|
941
|
+
return /* @__PURE__ */ jsx8(Spinner, { text: `Loading bridgeable tokens for ${chain.name}...` });
|
|
626
942
|
}
|
|
627
943
|
if (error) {
|
|
628
|
-
return /* @__PURE__ */
|
|
629
|
-
/* @__PURE__ */
|
|
944
|
+
return /* @__PURE__ */ jsxs8(Box8, { flexDirection: "column", children: [
|
|
945
|
+
/* @__PURE__ */ jsxs8(Text8, { color: theme.error, children: [
|
|
630
946
|
symbols.failed,
|
|
631
947
|
" Error: ",
|
|
632
948
|
error
|
|
633
949
|
] }),
|
|
634
|
-
/* @__PURE__ */
|
|
950
|
+
/* @__PURE__ */ jsx8(Text8, { color: theme.muted, children: "Press b to go back or q to quit" })
|
|
635
951
|
] });
|
|
636
952
|
}
|
|
637
953
|
if (tokens.length === 0) {
|
|
638
|
-
return /* @__PURE__ */
|
|
639
|
-
/* @__PURE__ */
|
|
954
|
+
return /* @__PURE__ */ jsxs8(Box8, { flexDirection: "column", children: [
|
|
955
|
+
/* @__PURE__ */ jsxs8(Text8, { color: theme.warning, children: [
|
|
640
956
|
symbols.pending,
|
|
641
957
|
" No bridgeable tokens found for ",
|
|
642
958
|
chain.name
|
|
643
959
|
] }),
|
|
644
|
-
/* @__PURE__ */
|
|
960
|
+
/* @__PURE__ */ jsx8(Text8, { color: theme.muted, children: "Press b to go back and select another chain" })
|
|
645
961
|
] });
|
|
646
962
|
}
|
|
647
963
|
const tokenItems = tokens.map((token) => ({
|
|
@@ -650,13 +966,13 @@ function TokenSelectionStep({
|
|
|
650
966
|
symbol: token.symbol,
|
|
651
967
|
description: token.name
|
|
652
968
|
}));
|
|
653
|
-
return /* @__PURE__ */
|
|
654
|
-
/* @__PURE__ */
|
|
969
|
+
return /* @__PURE__ */ jsxs8(Box8, { flexDirection: "column", children: [
|
|
970
|
+
/* @__PURE__ */ jsx8(Box8, { marginBottom: 1, children: /* @__PURE__ */ jsxs8(Text8, { color: theme.secondary, bold: true, children: [
|
|
655
971
|
"Select token to bridge from ",
|
|
656
972
|
chain.name,
|
|
657
973
|
":"
|
|
658
974
|
] }) }),
|
|
659
|
-
/* @__PURE__ */
|
|
975
|
+
/* @__PURE__ */ jsx8(
|
|
660
976
|
TokenSelect,
|
|
661
977
|
{
|
|
662
978
|
tokens: tokenItems,
|
|
@@ -677,14 +993,14 @@ function AmountInputStep({
|
|
|
677
993
|
onConfirm,
|
|
678
994
|
error
|
|
679
995
|
}) {
|
|
680
|
-
const [cursorVisible, setCursorVisible] =
|
|
681
|
-
|
|
996
|
+
const [cursorVisible, setCursorVisible] = useState2(true);
|
|
997
|
+
useEffect2(() => {
|
|
682
998
|
const interval = setInterval(() => {
|
|
683
999
|
setCursorVisible((v) => !v);
|
|
684
1000
|
}, 530);
|
|
685
1001
|
return () => clearInterval(interval);
|
|
686
1002
|
}, []);
|
|
687
|
-
|
|
1003
|
+
useInput2((input, key) => {
|
|
688
1004
|
if (key.return && amount.length > 0) {
|
|
689
1005
|
onConfirm();
|
|
690
1006
|
return;
|
|
@@ -701,52 +1017,117 @@ function AmountInputStep({
|
|
|
701
1017
|
});
|
|
702
1018
|
const cursor = cursorVisible ? "|" : " ";
|
|
703
1019
|
const displayAmount = amount || "0";
|
|
704
|
-
return /* @__PURE__ */
|
|
705
|
-
/* @__PURE__ */
|
|
1020
|
+
return /* @__PURE__ */ jsxs8(Box8, { flexDirection: "column", children: [
|
|
1021
|
+
/* @__PURE__ */ jsx8(Box8, { marginBottom: 1, children: /* @__PURE__ */ jsxs8(Text8, { color: theme.secondary, bold: true, children: [
|
|
706
1022
|
"Enter amount of ",
|
|
707
1023
|
token.symbol,
|
|
708
1024
|
" to bridge:"
|
|
709
1025
|
] }) }),
|
|
710
|
-
/* @__PURE__ */
|
|
711
|
-
/* @__PURE__ */
|
|
712
|
-
/* @__PURE__ */
|
|
713
|
-
/* @__PURE__ */
|
|
1026
|
+
/* @__PURE__ */ jsx8(Box, { bordered: true, padding: 1, children: /* @__PURE__ */ jsxs8(Box8, { children: [
|
|
1027
|
+
/* @__PURE__ */ jsx8(Text8, { color: theme.primary, bold: true, children: displayAmount }),
|
|
1028
|
+
/* @__PURE__ */ jsx8(Text8, { color: theme.primary, children: cursor }),
|
|
1029
|
+
/* @__PURE__ */ jsxs8(Text8, { color: theme.muted, children: [
|
|
714
1030
|
" ",
|
|
715
1031
|
token.symbol
|
|
716
1032
|
] })
|
|
717
1033
|
] }) }),
|
|
718
|
-
error && /* @__PURE__ */
|
|
1034
|
+
error && /* @__PURE__ */ jsx8(Box8, { marginTop: 1, children: /* @__PURE__ */ jsxs8(Text8, { color: theme.error, children: [
|
|
719
1035
|
symbols.failed,
|
|
720
1036
|
" ",
|
|
721
1037
|
error
|
|
722
1038
|
] }) }),
|
|
723
|
-
/* @__PURE__ */
|
|
1039
|
+
/* @__PURE__ */ jsx8(Box8, { marginTop: 1, children: /* @__PURE__ */ jsxs8(Text8, { color: theme.muted, dimColor: true, children: [
|
|
724
1040
|
"From: ",
|
|
725
1041
|
chain.name,
|
|
726
1042
|
" (",
|
|
727
1043
|
token.symbol,
|
|
728
1044
|
")"
|
|
729
1045
|
] }) }),
|
|
730
|
-
/* @__PURE__ */
|
|
1046
|
+
/* @__PURE__ */ jsx8(Box8, { children: /* @__PURE__ */ jsx8(Text8, { color: theme.muted, dimColor: true, children: "To: HyperEVM (USDC)" }) })
|
|
1047
|
+
] });
|
|
1048
|
+
}
|
|
1049
|
+
function KeyInputStep({
|
|
1050
|
+
privateKey,
|
|
1051
|
+
walletAddress,
|
|
1052
|
+
onKeyChange,
|
|
1053
|
+
onConfirm,
|
|
1054
|
+
error,
|
|
1055
|
+
loading
|
|
1056
|
+
}) {
|
|
1057
|
+
const [cursorVisible, setCursorVisible] = useState2(true);
|
|
1058
|
+
useEffect2(() => {
|
|
1059
|
+
const interval = setInterval(() => {
|
|
1060
|
+
setCursorVisible((v) => !v);
|
|
1061
|
+
}, 530);
|
|
1062
|
+
return () => clearInterval(interval);
|
|
1063
|
+
}, []);
|
|
1064
|
+
useInput2((input, key) => {
|
|
1065
|
+
if (loading) return;
|
|
1066
|
+
if (key.return && privateKey.length >= 64) {
|
|
1067
|
+
onConfirm();
|
|
1068
|
+
return;
|
|
1069
|
+
}
|
|
1070
|
+
if (key.backspace || key.delete) {
|
|
1071
|
+
onKeyChange(privateKey.slice(0, -1));
|
|
1072
|
+
return;
|
|
1073
|
+
}
|
|
1074
|
+
if (/^[0-9a-fA-Fx]$/.test(input)) {
|
|
1075
|
+
onKeyChange(privateKey + input);
|
|
1076
|
+
}
|
|
1077
|
+
});
|
|
1078
|
+
const cursor = cursorVisible ? "|" : " ";
|
|
1079
|
+
const maskedKey = privateKey.length > 10 ? `${privateKey.slice(0, 6)}${"*".repeat(Math.max(0, privateKey.length - 10))}${privateKey.slice(-4)}` : privateKey;
|
|
1080
|
+
return /* @__PURE__ */ jsxs8(Box8, { flexDirection: "column", children: [
|
|
1081
|
+
/* @__PURE__ */ jsx8(Box8, { marginBottom: 1, children: /* @__PURE__ */ jsx8(Text8, { color: theme.secondary, bold: true, children: "Enter your private key to sign the transaction:" }) }),
|
|
1082
|
+
/* @__PURE__ */ jsx8(Box, { bordered: true, padding: 1, children: /* @__PURE__ */ jsxs8(Box8, { children: [
|
|
1083
|
+
/* @__PURE__ */ jsx8(Text8, { color: theme.primary, bold: true, children: maskedKey || "0x" }),
|
|
1084
|
+
/* @__PURE__ */ jsx8(Text8, { color: theme.primary, children: cursor })
|
|
1085
|
+
] }) }),
|
|
1086
|
+
loading && /* @__PURE__ */ jsx8(Box8, { marginTop: 1, children: /* @__PURE__ */ jsx8(Spinner, { text: "Validating key and fetching quote..." }) }),
|
|
1087
|
+
walletAddress && !loading && /* @__PURE__ */ jsx8(Box8, { marginTop: 1, children: /* @__PURE__ */ jsxs8(Text8, { color: theme.success, children: [
|
|
1088
|
+
symbols.check,
|
|
1089
|
+
" Wallet: ",
|
|
1090
|
+
walletAddress.slice(0, 8),
|
|
1091
|
+
"...",
|
|
1092
|
+
walletAddress.slice(-6)
|
|
1093
|
+
] }) }),
|
|
1094
|
+
error && /* @__PURE__ */ jsx8(Box8, { marginTop: 1, children: /* @__PURE__ */ jsxs8(Text8, { color: theme.error, children: [
|
|
1095
|
+
symbols.failed,
|
|
1096
|
+
" ",
|
|
1097
|
+
error
|
|
1098
|
+
] }) }),
|
|
1099
|
+
/* @__PURE__ */ jsx8(Box8, { marginTop: 1, children: /* @__PURE__ */ jsx8(Text8, { color: theme.muted, dimColor: true, children: "Your key is only used locally to sign transactions" }) }),
|
|
1100
|
+
/* @__PURE__ */ jsx8(Box8, { children: /* @__PURE__ */ jsx8(Text8, { color: theme.muted, dimColor: true, children: "Tip: Paste your 64-character hex key (with or without 0x prefix)" }) })
|
|
731
1101
|
] });
|
|
732
1102
|
}
|
|
733
1103
|
function ConfirmationStep({
|
|
734
1104
|
chain,
|
|
735
1105
|
token,
|
|
736
1106
|
amount,
|
|
1107
|
+
quote,
|
|
1108
|
+
walletAddress,
|
|
737
1109
|
onConfirm
|
|
738
1110
|
}) {
|
|
739
|
-
|
|
740
|
-
if (key.return) {
|
|
1111
|
+
useInput2((_input, key) => {
|
|
1112
|
+
if (key.return && quote) {
|
|
741
1113
|
onConfirm();
|
|
742
1114
|
}
|
|
743
1115
|
});
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
1116
|
+
if (!quote) {
|
|
1117
|
+
return /* @__PURE__ */ jsx8(Spinner, { text: "Fetching quote..." });
|
|
1118
|
+
}
|
|
1119
|
+
const estimatedMinutes = Math.ceil(quote.estimatedTime / 60);
|
|
1120
|
+
const outputFormatted = (Number(quote.toAmount) / Math.pow(10, quote.toToken.decimals)).toFixed(2);
|
|
1121
|
+
return /* @__PURE__ */ jsxs8(Box8, { flexDirection: "column", children: [
|
|
1122
|
+
/* @__PURE__ */ jsx8(Box8, { marginBottom: 1, children: /* @__PURE__ */ jsx8(Text8, { color: theme.secondary, bold: true, children: "Review your bridge transaction:" }) }),
|
|
1123
|
+
walletAddress && /* @__PURE__ */ jsx8(Box8, { marginBottom: 1, children: /* @__PURE__ */ jsxs8(Text8, { color: theme.muted, dimColor: true, children: [
|
|
1124
|
+
"Wallet: ",
|
|
1125
|
+
walletAddress.slice(0, 8),
|
|
1126
|
+
"...",
|
|
1127
|
+
walletAddress.slice(-6)
|
|
1128
|
+
] }) }),
|
|
1129
|
+
/* @__PURE__ */ jsxs8(Box, { bordered: true, title: "Transaction Summary", padding: 1, children: [
|
|
1130
|
+
/* @__PURE__ */ jsx8(
|
|
750
1131
|
KeyValue,
|
|
751
1132
|
{
|
|
752
1133
|
items: [
|
|
@@ -754,72 +1135,143 @@ function ConfirmationStep({
|
|
|
754
1135
|
{ key: "Token", value: token.symbol },
|
|
755
1136
|
{ key: "Amount", value: `${amount} ${token.symbol}` },
|
|
756
1137
|
{ key: "To Chain", value: "HyperEVM" },
|
|
757
|
-
{ key: "Receive", value:
|
|
1138
|
+
{ key: "You Receive", value: `~${outputFormatted} ${quote.toToken.symbol}` }
|
|
758
1139
|
]
|
|
759
1140
|
}
|
|
760
1141
|
),
|
|
761
|
-
/* @__PURE__ */
|
|
762
|
-
/* @__PURE__ */
|
|
1142
|
+
/* @__PURE__ */ jsx8(Box8, { marginTop: 1, marginBottom: 1, children: /* @__PURE__ */ jsx8(Divider, { width: 40 }) }),
|
|
1143
|
+
/* @__PURE__ */ jsx8(
|
|
763
1144
|
KeyValue,
|
|
764
1145
|
{
|
|
765
1146
|
items: [
|
|
766
|
-
{ key: "
|
|
767
|
-
{ key: "
|
|
1147
|
+
{ key: "Gas Fee", value: `$${quote.fees.gasUsd.toFixed(2)}` },
|
|
1148
|
+
{ key: "Bridge Fee", value: `$${quote.fees.bridgeFeeUsd.toFixed(2)}` },
|
|
1149
|
+
{ key: "Total Fees", value: `$${quote.fees.totalUsd.toFixed(2)}` },
|
|
1150
|
+
{ key: "Est. Time", value: `~${estimatedMinutes} min` }
|
|
768
1151
|
],
|
|
769
1152
|
keyColor: theme.muted,
|
|
770
1153
|
valueColor: theme.warning
|
|
771
1154
|
}
|
|
772
1155
|
)
|
|
773
1156
|
] }),
|
|
774
|
-
/* @__PURE__ */
|
|
1157
|
+
quote.highImpact && /* @__PURE__ */ jsx8(Box8, { marginTop: 1, children: /* @__PURE__ */ jsxs8(Text8, { color: theme.warning, children: [
|
|
1158
|
+
symbols.pending,
|
|
1159
|
+
" Warning: High price impact (",
|
|
1160
|
+
(quote.priceImpact * 100).toFixed(2),
|
|
1161
|
+
"%)"
|
|
1162
|
+
] }) }),
|
|
1163
|
+
/* @__PURE__ */ jsx8(Box8, { marginTop: 1, children: /* @__PURE__ */ jsxs8(Text8, { color: theme.success, bold: true, children: [
|
|
775
1164
|
symbols.arrow,
|
|
776
1165
|
" Press Enter to execute the bridge"
|
|
777
1166
|
] }) }),
|
|
778
|
-
/* @__PURE__ */
|
|
1167
|
+
/* @__PURE__ */ jsx8(Box8, { children: /* @__PURE__ */ jsx8(Text8, { color: theme.muted, dimColor: true, children: "Press b to go back and edit" }) })
|
|
779
1168
|
] });
|
|
780
1169
|
}
|
|
781
1170
|
function ExecutionStep({
|
|
782
1171
|
chain,
|
|
783
1172
|
token,
|
|
784
|
-
amount
|
|
1173
|
+
amount,
|
|
1174
|
+
quote,
|
|
1175
|
+
privateKey,
|
|
1176
|
+
onComplete,
|
|
1177
|
+
onError
|
|
785
1178
|
}) {
|
|
786
|
-
const [
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
1179
|
+
const [stepState, setStepState] = useState2({
|
|
1180
|
+
approval: "active",
|
|
1181
|
+
bridge: "pending",
|
|
1182
|
+
confirm: "pending"
|
|
1183
|
+
});
|
|
1184
|
+
const [statusMessage, setStatusMessage] = useState2("Initializing...");
|
|
1185
|
+
const [txHash, setTxHash] = useState2(null);
|
|
1186
|
+
const [error, setError] = useState2(null);
|
|
1187
|
+
const [isExecuting, setIsExecuting] = useState2(false);
|
|
1188
|
+
useEffect2(() => {
|
|
1189
|
+
if (isExecuting) return;
|
|
1190
|
+
setIsExecuting(true);
|
|
1191
|
+
const executeBridge = async () => {
|
|
1192
|
+
try {
|
|
1193
|
+
const signer = await createSigner(privateKey, chain.id);
|
|
1194
|
+
const mina = new Mina({
|
|
1195
|
+
integrator: "mina-cli-wizard",
|
|
1196
|
+
autoDeposit: true
|
|
1197
|
+
});
|
|
1198
|
+
const result = await mina.execute({
|
|
1199
|
+
quote,
|
|
1200
|
+
signer,
|
|
1201
|
+
onStepChange: (stepStatus) => {
|
|
1202
|
+
setStatusMessage(`${stepStatus.step}: ${stepStatus.status}`);
|
|
1203
|
+
if (stepStatus.step === "approval") {
|
|
1204
|
+
if (stepStatus.status === "completed") {
|
|
1205
|
+
setStepState((prev) => ({ ...prev, approval: "completed", bridge: "active" }));
|
|
1206
|
+
} else if (stepStatus.status === "failed") {
|
|
1207
|
+
setStepState((prev) => ({ ...prev, approval: "failed" }));
|
|
1208
|
+
} else if (stepStatus.status === "active") {
|
|
1209
|
+
setStepState((prev) => ({ ...prev, approval: "active" }));
|
|
1210
|
+
}
|
|
1211
|
+
} else if (stepStatus.step === "bridge" || stepStatus.step === "swap") {
|
|
1212
|
+
if (stepStatus.status === "completed") {
|
|
1213
|
+
setStepState((prev) => ({ ...prev, bridge: "completed", confirm: "active" }));
|
|
1214
|
+
} else if (stepStatus.status === "failed") {
|
|
1215
|
+
setStepState((prev) => ({ ...prev, bridge: "failed" }));
|
|
1216
|
+
} else if (stepStatus.status === "active") {
|
|
1217
|
+
setStepState((prev) => ({ ...prev, bridge: "active" }));
|
|
1218
|
+
}
|
|
1219
|
+
if (stepStatus.txHash) {
|
|
1220
|
+
setTxHash(stepStatus.txHash);
|
|
1221
|
+
}
|
|
1222
|
+
} else if (stepStatus.step === "deposit") {
|
|
1223
|
+
if (stepStatus.status === "completed") {
|
|
1224
|
+
setStepState((prev) => ({ ...prev, confirm: "completed" }));
|
|
1225
|
+
} else if (stepStatus.status === "failed") {
|
|
1226
|
+
setStepState((prev) => ({ ...prev, confirm: "failed" }));
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
},
|
|
1230
|
+
onStatusChange: (status) => {
|
|
1231
|
+
setStatusMessage(status.substatus || `Step ${status.currentStep}/${status.totalSteps}`);
|
|
1232
|
+
if (status.txHash) {
|
|
1233
|
+
setTxHash(status.txHash);
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
});
|
|
1237
|
+
if (result.status === "completed") {
|
|
1238
|
+
setStepState({
|
|
1239
|
+
approval: "completed",
|
|
1240
|
+
bridge: "completed",
|
|
1241
|
+
confirm: "completed"
|
|
1242
|
+
});
|
|
1243
|
+
onComplete(result);
|
|
1244
|
+
} else if (result.status === "failed") {
|
|
1245
|
+
setError(result.error?.message || "Bridge execution failed");
|
|
1246
|
+
onError(result.error || new Error("Bridge execution failed"));
|
|
793
1247
|
}
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
1248
|
+
} catch (err) {
|
|
1249
|
+
const normalizedError = normalizeError(err instanceof Error ? err : new Error(String(err)));
|
|
1250
|
+
setError(normalizedError.message);
|
|
1251
|
+
onError(normalizedError);
|
|
1252
|
+
}
|
|
1253
|
+
};
|
|
1254
|
+
executeBridge();
|
|
798
1255
|
}, []);
|
|
799
1256
|
const steps = [
|
|
800
1257
|
{
|
|
801
|
-
label: "
|
|
802
|
-
status:
|
|
803
|
-
|
|
804
|
-
{
|
|
805
|
-
label: "Fetching quote",
|
|
806
|
-
status: currentStep > 1 ? "completed" : currentStep === 1 ? "active" : "pending"
|
|
807
|
-
},
|
|
808
|
-
{
|
|
809
|
-
label: "Approving token",
|
|
810
|
-
status: currentStep > 2 ? "completed" : currentStep === 2 ? "active" : "pending"
|
|
1258
|
+
label: "Approving token spend",
|
|
1259
|
+
status: stepState.approval,
|
|
1260
|
+
description: stepState.approval === "active" ? "Waiting for approval..." : void 0
|
|
811
1261
|
},
|
|
812
1262
|
{
|
|
813
|
-
label: "Executing bridge",
|
|
814
|
-
status:
|
|
1263
|
+
label: "Executing bridge transaction",
|
|
1264
|
+
status: stepState.bridge,
|
|
1265
|
+
description: stepState.bridge === "active" ? statusMessage : void 0
|
|
815
1266
|
},
|
|
816
1267
|
{
|
|
817
1268
|
label: "Confirming on destination",
|
|
818
|
-
status:
|
|
1269
|
+
status: stepState.confirm,
|
|
1270
|
+
description: stepState.confirm === "active" ? "Waiting for bridge confirmation..." : void 0
|
|
819
1271
|
}
|
|
820
1272
|
];
|
|
821
|
-
return /* @__PURE__ */
|
|
822
|
-
/* @__PURE__ */
|
|
1273
|
+
return /* @__PURE__ */ jsxs8(Box8, { flexDirection: "column", children: [
|
|
1274
|
+
/* @__PURE__ */ jsx8(Box8, { marginBottom: 1, children: /* @__PURE__ */ jsxs8(Text8, { color: theme.secondary, bold: true, children: [
|
|
823
1275
|
"Bridging ",
|
|
824
1276
|
amount,
|
|
825
1277
|
" ",
|
|
@@ -828,23 +1280,35 @@ function ExecutionStep({
|
|
|
828
1280
|
chain.name,
|
|
829
1281
|
" to HyperEVM"
|
|
830
1282
|
] }) }),
|
|
831
|
-
/* @__PURE__ */
|
|
832
|
-
|
|
1283
|
+
/* @__PURE__ */ jsx8(ProgressSteps, { steps, title: "Bridge Progress", showNumbers: true }),
|
|
1284
|
+
txHash && /* @__PURE__ */ jsx8(Box8, { marginTop: 1, children: /* @__PURE__ */ jsxs8(Text8, { color: theme.muted, children: [
|
|
1285
|
+
"TX: ",
|
|
1286
|
+
txHash.slice(0, 16),
|
|
1287
|
+
"...",
|
|
1288
|
+
txHash.slice(-8)
|
|
1289
|
+
] }) }),
|
|
1290
|
+
stepState.confirm === "completed" && /* @__PURE__ */ jsx8(Box8, { marginTop: 1, children: /* @__PURE__ */ jsxs8(Text8, { color: theme.success, bold: true, children: [
|
|
833
1291
|
symbols.check,
|
|
834
|
-
" Bridge
|
|
1292
|
+
" Bridge completed successfully!"
|
|
835
1293
|
] }) }),
|
|
836
|
-
/* @__PURE__ */
|
|
1294
|
+
error && /* @__PURE__ */ jsx8(Box8, { marginTop: 1, children: /* @__PURE__ */ jsxs8(Text8, { color: theme.error, children: [
|
|
1295
|
+
symbols.failed,
|
|
1296
|
+
" Error: ",
|
|
1297
|
+
error
|
|
1298
|
+
] }) }),
|
|
1299
|
+
!error && stepState.confirm !== "completed" && /* @__PURE__ */ jsx8(Box8, { marginTop: 1, children: /* @__PURE__ */ jsx8(Text8, { color: theme.muted, dimColor: true, children: statusMessage }) })
|
|
837
1300
|
] });
|
|
838
1301
|
}
|
|
839
1302
|
function Wizard() {
|
|
840
1303
|
const { exit } = useApp();
|
|
841
|
-
const [state, setState] =
|
|
842
|
-
|
|
1304
|
+
const [state, setState] = useState2(initialState);
|
|
1305
|
+
const [keyLoading, setKeyLoading] = useState2(false);
|
|
1306
|
+
useInput2((input, key) => {
|
|
843
1307
|
if (input === "q" && state.step !== "execute") {
|
|
844
1308
|
exit();
|
|
845
1309
|
return;
|
|
846
1310
|
}
|
|
847
|
-
if (input === "b" && state.step !== "chain" && state.step !== "execute" && state.step !== "amount") {
|
|
1311
|
+
if (input === "b" && state.step !== "chain" && state.step !== "execute" && state.step !== "amount" && state.step !== "key") {
|
|
848
1312
|
goBack();
|
|
849
1313
|
return;
|
|
850
1314
|
}
|
|
@@ -852,6 +1316,10 @@ function Wizard() {
|
|
|
852
1316
|
goBack();
|
|
853
1317
|
return;
|
|
854
1318
|
}
|
|
1319
|
+
if (input === "b" && state.step === "key" && !keyLoading) {
|
|
1320
|
+
goBack();
|
|
1321
|
+
return;
|
|
1322
|
+
}
|
|
855
1323
|
});
|
|
856
1324
|
const goBack = useCallback(() => {
|
|
857
1325
|
setState((prev) => {
|
|
@@ -860,8 +1328,10 @@ function Wizard() {
|
|
|
860
1328
|
return { ...prev, step: "chain", token: null, error: null };
|
|
861
1329
|
case "amount":
|
|
862
1330
|
return { ...prev, step: "token", amount: "", error: null };
|
|
1331
|
+
case "key":
|
|
1332
|
+
return { ...prev, step: "amount", privateKey: null, walletAddress: null, quote: null, error: null };
|
|
863
1333
|
case "confirm":
|
|
864
|
-
return { ...prev, step: "
|
|
1334
|
+
return { ...prev, step: "key", error: null };
|
|
865
1335
|
default:
|
|
866
1336
|
return prev;
|
|
867
1337
|
}
|
|
@@ -882,15 +1352,53 @@ function Wizard() {
|
|
|
882
1352
|
setState((prev) => ({ ...prev, error: "Please enter a valid positive amount" }));
|
|
883
1353
|
return;
|
|
884
1354
|
}
|
|
885
|
-
setState((prev) => ({ ...prev, step: "
|
|
1355
|
+
setState((prev) => ({ ...prev, step: "key", error: null }));
|
|
886
1356
|
}, [state.amount]);
|
|
1357
|
+
const handleKeyChange = useCallback((key) => {
|
|
1358
|
+
setState((prev) => ({ ...prev, privateKey: key, error: null }));
|
|
1359
|
+
}, []);
|
|
1360
|
+
const handleKeyConfirm = useCallback(async () => {
|
|
1361
|
+
if (!state.privateKey || !state.chain || !state.token) return;
|
|
1362
|
+
const keyWithoutPrefix = state.privateKey.startsWith("0x") ? state.privateKey.slice(2) : state.privateKey;
|
|
1363
|
+
if (!/^[0-9a-fA-F]{64}$/.test(keyWithoutPrefix)) {
|
|
1364
|
+
setState((prev) => ({ ...prev, error: "Invalid private key format. Expected 64 hex characters." }));
|
|
1365
|
+
return;
|
|
1366
|
+
}
|
|
1367
|
+
setKeyLoading(true);
|
|
1368
|
+
try {
|
|
1369
|
+
const normalizedKey = state.privateKey.startsWith("0x") ? state.privateKey : `0x${state.privateKey}`;
|
|
1370
|
+
const address = await getAddressFromPrivateKey(normalizedKey);
|
|
1371
|
+
setState((prev) => ({ ...prev, walletAddress: address, privateKey: normalizedKey }));
|
|
1372
|
+
const amountInSmallestUnit = (parseFloat(state.amount) * Math.pow(10, state.token.decimals)).toString();
|
|
1373
|
+
const quote = await getQuote({
|
|
1374
|
+
fromChainId: state.chain.id,
|
|
1375
|
+
toChainId: HYPEREVM_CHAIN_ID,
|
|
1376
|
+
fromToken: state.token.address,
|
|
1377
|
+
toToken: HYPEREVM_USDC_ADDRESS,
|
|
1378
|
+
fromAmount: amountInSmallestUnit,
|
|
1379
|
+
fromAddress: address
|
|
1380
|
+
});
|
|
1381
|
+
setState((prev) => ({ ...prev, quote, step: "confirm", error: null }));
|
|
1382
|
+
} catch (err) {
|
|
1383
|
+
const error = err instanceof Error ? err.message : "Failed to validate key or fetch quote";
|
|
1384
|
+
setState((prev) => ({ ...prev, error }));
|
|
1385
|
+
} finally {
|
|
1386
|
+
setKeyLoading(false);
|
|
1387
|
+
}
|
|
1388
|
+
}, [state.privateKey, state.chain, state.token, state.amount]);
|
|
887
1389
|
const handleConfirm = useCallback(() => {
|
|
888
1390
|
setState((prev) => ({ ...prev, step: "execute", error: null }));
|
|
889
1391
|
}, []);
|
|
1392
|
+
const handleExecutionComplete = useCallback((result) => {
|
|
1393
|
+
setState((prev) => ({ ...prev, executionResult: result, executionStatus: "completed" }));
|
|
1394
|
+
}, []);
|
|
1395
|
+
const handleExecutionError = useCallback((error) => {
|
|
1396
|
+
setState((prev) => ({ ...prev, error: error.message, executionStatus: "failed" }));
|
|
1397
|
+
}, []);
|
|
890
1398
|
const renderStepContent = () => {
|
|
891
1399
|
switch (state.step) {
|
|
892
1400
|
case "chain":
|
|
893
|
-
return /* @__PURE__ */
|
|
1401
|
+
return /* @__PURE__ */ jsx8(
|
|
894
1402
|
ChainSelectionStep,
|
|
895
1403
|
{
|
|
896
1404
|
onSelect: handleChainSelect,
|
|
@@ -899,7 +1407,7 @@ function Wizard() {
|
|
|
899
1407
|
);
|
|
900
1408
|
case "token":
|
|
901
1409
|
if (!state.chain) return null;
|
|
902
|
-
return /* @__PURE__ */
|
|
1410
|
+
return /* @__PURE__ */ jsx8(
|
|
903
1411
|
TokenSelectionStep,
|
|
904
1412
|
{
|
|
905
1413
|
chain: state.chain,
|
|
@@ -909,7 +1417,7 @@ function Wizard() {
|
|
|
909
1417
|
);
|
|
910
1418
|
case "amount":
|
|
911
1419
|
if (!state.chain || !state.token) return null;
|
|
912
|
-
return /* @__PURE__ */
|
|
1420
|
+
return /* @__PURE__ */ jsx8(
|
|
913
1421
|
AmountInputStep,
|
|
914
1422
|
{
|
|
915
1423
|
chain: state.chain,
|
|
@@ -920,50 +1428,69 @@ function Wizard() {
|
|
|
920
1428
|
error: state.error
|
|
921
1429
|
}
|
|
922
1430
|
);
|
|
1431
|
+
case "key":
|
|
1432
|
+
if (!state.chain || !state.token) return null;
|
|
1433
|
+
return /* @__PURE__ */ jsx8(
|
|
1434
|
+
KeyInputStep,
|
|
1435
|
+
{
|
|
1436
|
+
privateKey: state.privateKey || "",
|
|
1437
|
+
walletAddress: state.walletAddress,
|
|
1438
|
+
onKeyChange: handleKeyChange,
|
|
1439
|
+
onConfirm: handleKeyConfirm,
|
|
1440
|
+
error: state.error,
|
|
1441
|
+
loading: keyLoading
|
|
1442
|
+
}
|
|
1443
|
+
);
|
|
923
1444
|
case "confirm":
|
|
924
1445
|
if (!state.chain || !state.token) return null;
|
|
925
|
-
return /* @__PURE__ */
|
|
1446
|
+
return /* @__PURE__ */ jsx8(
|
|
926
1447
|
ConfirmationStep,
|
|
927
1448
|
{
|
|
928
1449
|
chain: state.chain,
|
|
929
1450
|
token: state.token,
|
|
930
1451
|
amount: state.amount,
|
|
1452
|
+
quote: state.quote,
|
|
1453
|
+
walletAddress: state.walletAddress,
|
|
931
1454
|
onConfirm: handleConfirm
|
|
932
1455
|
}
|
|
933
1456
|
);
|
|
934
1457
|
case "execute":
|
|
935
|
-
if (!state.chain || !state.token) return null;
|
|
936
|
-
return /* @__PURE__ */
|
|
1458
|
+
if (!state.chain || !state.token || !state.quote || !state.privateKey) return null;
|
|
1459
|
+
return /* @__PURE__ */ jsx8(
|
|
937
1460
|
ExecutionStep,
|
|
938
1461
|
{
|
|
939
1462
|
chain: state.chain,
|
|
940
1463
|
token: state.token,
|
|
941
|
-
amount: state.amount
|
|
1464
|
+
amount: state.amount,
|
|
1465
|
+
quote: state.quote,
|
|
1466
|
+
privateKey: state.privateKey,
|
|
1467
|
+
onComplete: handleExecutionComplete,
|
|
1468
|
+
onError: handleExecutionError
|
|
942
1469
|
}
|
|
943
1470
|
);
|
|
944
1471
|
default:
|
|
945
1472
|
return null;
|
|
946
1473
|
}
|
|
947
1474
|
};
|
|
948
|
-
return /* @__PURE__ */
|
|
949
|
-
/* @__PURE__ */
|
|
950
|
-
/* @__PURE__ */
|
|
951
|
-
/* @__PURE__ */
|
|
952
|
-
/* @__PURE__ */
|
|
1475
|
+
return /* @__PURE__ */ jsxs8(Box8, { flexDirection: "column", padding: 1, children: [
|
|
1476
|
+
/* @__PURE__ */ jsx8(Header, { showTagline: true, tagline: "Cross-chain bridge to Hyperliquid" }),
|
|
1477
|
+
/* @__PURE__ */ jsx8(StepIndicator, { currentStep: state.step }),
|
|
1478
|
+
/* @__PURE__ */ jsx8(Box8, { flexDirection: "column", marginY: 1, children: renderStepContent() }),
|
|
1479
|
+
/* @__PURE__ */ jsx8(NavigationHints, { step: state.step })
|
|
953
1480
|
] });
|
|
954
1481
|
}
|
|
955
1482
|
|
|
956
1483
|
// src/commands/quote.tsx
|
|
957
|
-
import { useState as
|
|
958
|
-
import { Box as
|
|
1484
|
+
import { useState as useState3, useEffect as useEffect3 } from "react";
|
|
1485
|
+
import { Box as Box9, Text as Text9, useApp as useApp2 } from "ink";
|
|
959
1486
|
import {
|
|
960
|
-
Mina,
|
|
1487
|
+
Mina as Mina2,
|
|
961
1488
|
getChains as getChains2,
|
|
962
1489
|
getTokens,
|
|
963
1490
|
HYPEREVM_CHAIN_ID as HYPEREVM_CHAIN_ID2,
|
|
964
|
-
HYPEREVM_USDC_ADDRESS
|
|
1491
|
+
HYPEREVM_USDC_ADDRESS as HYPEREVM_USDC_ADDRESS2
|
|
965
1492
|
} from "@siphoyawe/mina-sdk";
|
|
966
|
-
import { jsx as
|
|
1493
|
+
import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
967
1494
|
function parseAmount(amount, decimals) {
|
|
968
1495
|
const [whole, fraction = ""] = amount.split(".");
|
|
969
1496
|
const paddedFraction = fraction.padEnd(decimals, "0").slice(0, decimals);
|
|
@@ -1006,8 +1533,8 @@ function QuoteBox({
|
|
|
1006
1533
|
const gasFees = formatUsd(quote.fees.gasUsd);
|
|
1007
1534
|
const bridgeFees = formatUsd(quote.fees.bridgeFeeUsd);
|
|
1008
1535
|
const protocolFees = formatUsd(quote.fees.protocolFeeUsd);
|
|
1009
|
-
return /* @__PURE__ */
|
|
1010
|
-
/* @__PURE__ */
|
|
1536
|
+
return /* @__PURE__ */ jsx9(Box9, { flexDirection: "column", children: /* @__PURE__ */ jsxs9(Box, { bordered: true, title: "Bridge Quote", padding: 1, children: [
|
|
1537
|
+
/* @__PURE__ */ jsx9(
|
|
1011
1538
|
KeyValue,
|
|
1012
1539
|
{
|
|
1013
1540
|
items: [
|
|
@@ -1018,8 +1545,8 @@ function QuoteBox({
|
|
|
1018
1545
|
valueColor: theme.primary
|
|
1019
1546
|
}
|
|
1020
1547
|
),
|
|
1021
|
-
/* @__PURE__ */
|
|
1022
|
-
/* @__PURE__ */
|
|
1548
|
+
/* @__PURE__ */ jsx9(Box9, { marginY: 1, children: /* @__PURE__ */ jsx9(Divider, { width: 45 }) }),
|
|
1549
|
+
/* @__PURE__ */ jsx9(
|
|
1023
1550
|
KeyValue,
|
|
1024
1551
|
{
|
|
1025
1552
|
items: [
|
|
@@ -1031,9 +1558,9 @@ function QuoteBox({
|
|
|
1031
1558
|
valueColor: theme.secondary
|
|
1032
1559
|
}
|
|
1033
1560
|
),
|
|
1034
|
-
/* @__PURE__ */
|
|
1035
|
-
/* @__PURE__ */
|
|
1036
|
-
/* @__PURE__ */
|
|
1561
|
+
/* @__PURE__ */ jsx9(Box9, { marginY: 1, children: /* @__PURE__ */ jsx9(Divider, { width: 45 }) }),
|
|
1562
|
+
/* @__PURE__ */ jsx9(Box9, { marginBottom: 1, children: /* @__PURE__ */ jsx9(Text9, { color: theme.muted, bold: true, children: "Fee Breakdown:" }) }),
|
|
1563
|
+
/* @__PURE__ */ jsx9(
|
|
1037
1564
|
KeyValue,
|
|
1038
1565
|
{
|
|
1039
1566
|
items: [
|
|
@@ -1046,13 +1573,13 @@ function QuoteBox({
|
|
|
1046
1573
|
valueColor: theme.warning
|
|
1047
1574
|
}
|
|
1048
1575
|
),
|
|
1049
|
-
quote.highImpact && /* @__PURE__ */
|
|
1576
|
+
quote.highImpact && /* @__PURE__ */ jsx9(Box9, { marginTop: 1, children: /* @__PURE__ */ jsxs9(Text9, { color: theme.warning, children: [
|
|
1050
1577
|
symbols.pending,
|
|
1051
1578
|
" High price impact: ",
|
|
1052
1579
|
(quote.priceImpact * 100).toFixed(2),
|
|
1053
1580
|
"%"
|
|
1054
1581
|
] }) }),
|
|
1055
|
-
/* @__PURE__ */
|
|
1582
|
+
/* @__PURE__ */ jsx9(Box9, { marginTop: 1, children: /* @__PURE__ */ jsxs9(Text9, { color: theme.muted, children: [
|
|
1056
1583
|
"Min. received: ",
|
|
1057
1584
|
quote.minimumReceivedFormatted,
|
|
1058
1585
|
" ",
|
|
@@ -1102,17 +1629,17 @@ function JsonOutput({ quote, fromChain, sourceToken }) {
|
|
|
1102
1629
|
expiresAt: quote.expiresAt
|
|
1103
1630
|
}
|
|
1104
1631
|
};
|
|
1105
|
-
return /* @__PURE__ */
|
|
1632
|
+
return /* @__PURE__ */ jsx9(Text9, { children: JSON.stringify(jsonData, null, 2) });
|
|
1106
1633
|
}
|
|
1107
1634
|
function ErrorDisplay({ message }) {
|
|
1108
|
-
return /* @__PURE__ */
|
|
1109
|
-
/* @__PURE__ */
|
|
1635
|
+
return /* @__PURE__ */ jsxs9(Box9, { flexDirection: "column", padding: 1, children: [
|
|
1636
|
+
/* @__PURE__ */ jsx9(Box9, { children: /* @__PURE__ */ jsxs9(Text9, { color: theme.error, bold: true, children: [
|
|
1110
1637
|
symbols.failed,
|
|
1111
1638
|
" Error: ",
|
|
1112
1639
|
message
|
|
1113
1640
|
] }) }),
|
|
1114
|
-
/* @__PURE__ */
|
|
1115
|
-
/* @__PURE__ */
|
|
1641
|
+
/* @__PURE__ */ jsx9(Box9, { marginTop: 1, children: /* @__PURE__ */ jsx9(Text9, { color: theme.muted, children: "Usage: npx mina quote --from <chain> --token <symbol> --amount <number>" }) }),
|
|
1642
|
+
/* @__PURE__ */ jsx9(Box9, { marginTop: 1, children: /* @__PURE__ */ jsx9(Text9, { color: theme.muted, children: "Example: npx mina quote --from arbitrum --token USDC --amount 100" }) })
|
|
1116
1643
|
] });
|
|
1117
1644
|
}
|
|
1118
1645
|
function QuoteDisplay({
|
|
@@ -1123,13 +1650,13 @@ function QuoteDisplay({
|
|
|
1123
1650
|
jsonOutput
|
|
1124
1651
|
}) {
|
|
1125
1652
|
const { exit } = useApp2();
|
|
1126
|
-
const [loading, setLoading] =
|
|
1127
|
-
const [error, setError] =
|
|
1128
|
-
const [quote, setQuote] =
|
|
1129
|
-
const [sourceChain, setSourceChain] =
|
|
1130
|
-
const [sourceToken, setSourceToken] =
|
|
1131
|
-
const [destToken, setDestToken] =
|
|
1132
|
-
|
|
1653
|
+
const [loading, setLoading] = useState3(true);
|
|
1654
|
+
const [error, setError] = useState3(null);
|
|
1655
|
+
const [quote, setQuote] = useState3(null);
|
|
1656
|
+
const [sourceChain, setSourceChain] = useState3(null);
|
|
1657
|
+
const [sourceToken, setSourceToken] = useState3(null);
|
|
1658
|
+
const [destToken, setDestToken] = useState3(null);
|
|
1659
|
+
useEffect3(() => {
|
|
1133
1660
|
async function fetchQuote() {
|
|
1134
1661
|
try {
|
|
1135
1662
|
setLoading(true);
|
|
@@ -1161,7 +1688,7 @@ function QuoteDisplay({
|
|
|
1161
1688
|
}
|
|
1162
1689
|
setSourceToken(foundToken);
|
|
1163
1690
|
const destinationToken = {
|
|
1164
|
-
address:
|
|
1691
|
+
address: HYPEREVM_USDC_ADDRESS2,
|
|
1165
1692
|
symbol: "USDC",
|
|
1166
1693
|
name: "USD Coin",
|
|
1167
1694
|
decimals: 6,
|
|
@@ -1169,12 +1696,12 @@ function QuoteDisplay({
|
|
|
1169
1696
|
chainId: HYPEREVM_CHAIN_ID2
|
|
1170
1697
|
};
|
|
1171
1698
|
setDestToken(destinationToken);
|
|
1172
|
-
const mina = new
|
|
1699
|
+
const mina = new Mina2({ integrator: "mina-cli" });
|
|
1173
1700
|
const quoteResult = await mina.getQuote({
|
|
1174
1701
|
fromChainId: chain.id,
|
|
1175
1702
|
toChainId: HYPEREVM_CHAIN_ID2,
|
|
1176
1703
|
fromToken: foundToken.address,
|
|
1177
|
-
toToken:
|
|
1704
|
+
toToken: HYPEREVM_USDC_ADDRESS2,
|
|
1178
1705
|
fromAmount: parseAmount(amount, foundToken.decimals),
|
|
1179
1706
|
fromAddress: "0x0000000000000000000000000000000000000000"
|
|
1180
1707
|
// Placeholder for quote
|
|
@@ -1189,26 +1716,26 @@ function QuoteDisplay({
|
|
|
1189
1716
|
}
|
|
1190
1717
|
fetchQuote();
|
|
1191
1718
|
}, [fromChain, token, amount]);
|
|
1192
|
-
|
|
1719
|
+
useEffect3(() => {
|
|
1193
1720
|
if (!loading && jsonOutput) {
|
|
1194
1721
|
const timer = setTimeout(() => exit(), 100);
|
|
1195
1722
|
return () => clearTimeout(timer);
|
|
1196
1723
|
}
|
|
1197
1724
|
}, [loading, jsonOutput, exit]);
|
|
1198
1725
|
if (loading) {
|
|
1199
|
-
return /* @__PURE__ */
|
|
1726
|
+
return /* @__PURE__ */ jsx9(Box9, { padding: 1, children: /* @__PURE__ */ jsx9(Spinner, { text: `Fetching quote for ${amount} ${token} from ${fromChain}...` }) });
|
|
1200
1727
|
}
|
|
1201
1728
|
if (error) {
|
|
1202
|
-
return /* @__PURE__ */
|
|
1729
|
+
return /* @__PURE__ */ jsx9(ErrorDisplay, { message: error });
|
|
1203
1730
|
}
|
|
1204
1731
|
if (!quote || !sourceChain || !sourceToken || !destToken) {
|
|
1205
|
-
return /* @__PURE__ */
|
|
1732
|
+
return /* @__PURE__ */ jsx9(ErrorDisplay, { message: "Failed to fetch quote data" });
|
|
1206
1733
|
}
|
|
1207
1734
|
if (jsonOutput) {
|
|
1208
|
-
return /* @__PURE__ */
|
|
1735
|
+
return /* @__PURE__ */ jsx9(JsonOutput, { quote, fromChain: sourceChain, sourceToken });
|
|
1209
1736
|
}
|
|
1210
|
-
return /* @__PURE__ */
|
|
1211
|
-
/* @__PURE__ */
|
|
1737
|
+
return /* @__PURE__ */ jsxs9(Box9, { flexDirection: "column", padding: 1, children: [
|
|
1738
|
+
/* @__PURE__ */ jsx9(
|
|
1212
1739
|
QuoteBox,
|
|
1213
1740
|
{
|
|
1214
1741
|
quote,
|
|
@@ -1218,7 +1745,7 @@ function QuoteDisplay({
|
|
|
1218
1745
|
destToken
|
|
1219
1746
|
}
|
|
1220
1747
|
),
|
|
1221
|
-
/* @__PURE__ */
|
|
1748
|
+
/* @__PURE__ */ jsx9(Box9, { marginTop: 1, children: /* @__PURE__ */ jsxs9(Text9, { color: theme.muted, children: [
|
|
1222
1749
|
"Quote valid until: ",
|
|
1223
1750
|
new Date(quote.expiresAt).toLocaleTimeString()
|
|
1224
1751
|
] }) })
|
|
@@ -1226,19 +1753,37 @@ function QuoteDisplay({
|
|
|
1226
1753
|
}
|
|
1227
1754
|
|
|
1228
1755
|
// src/commands/chains.tsx
|
|
1229
|
-
import { useState as
|
|
1230
|
-
import { Box as
|
|
1756
|
+
import { useState as useState4, useEffect as useEffect4 } from "react";
|
|
1757
|
+
import { Box as Box10, Text as Text10, useApp as useApp3 } from "ink";
|
|
1231
1758
|
import {
|
|
1232
1759
|
getChains as getChains3,
|
|
1233
1760
|
HYPEREVM_CHAIN_ID as HYPEREVM_CHAIN_ID3
|
|
1234
1761
|
} from "@siphoyawe/mina-sdk";
|
|
1235
|
-
import { jsx as
|
|
1762
|
+
import { jsx as jsx10, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1763
|
+
var POPULAR_CHAIN_IDS = [
|
|
1764
|
+
1,
|
|
1765
|
+
// Ethereum
|
|
1766
|
+
42161,
|
|
1767
|
+
// Arbitrum
|
|
1768
|
+
10,
|
|
1769
|
+
// Optimism
|
|
1770
|
+
137,
|
|
1771
|
+
// Polygon
|
|
1772
|
+
8453,
|
|
1773
|
+
// Base
|
|
1774
|
+
43114,
|
|
1775
|
+
// Avalanche
|
|
1776
|
+
56,
|
|
1777
|
+
// BNB Chain
|
|
1778
|
+
999
|
|
1779
|
+
// HyperEVM (destination)
|
|
1780
|
+
];
|
|
1236
1781
|
function ChainsCommand({ json = false }) {
|
|
1237
1782
|
const { exit } = useApp3();
|
|
1238
|
-
const [chains, setChains] =
|
|
1239
|
-
const [loading, setLoading] =
|
|
1240
|
-
const [error, setError] =
|
|
1241
|
-
|
|
1783
|
+
const [chains, setChains] = useState4([]);
|
|
1784
|
+
const [loading, setLoading] = useState4(true);
|
|
1785
|
+
const [error, setError] = useState4(null);
|
|
1786
|
+
useEffect4(() => {
|
|
1242
1787
|
async function loadChains() {
|
|
1243
1788
|
try {
|
|
1244
1789
|
setLoading(true);
|
|
@@ -1262,12 +1807,6 @@ function ChainsCommand({ json = false }) {
|
|
|
1262
1807
|
hyperEvmChain.type = "Dest";
|
|
1263
1808
|
}
|
|
1264
1809
|
}
|
|
1265
|
-
chainRows.sort((a, b) => {
|
|
1266
|
-
if (a.type !== b.type) {
|
|
1267
|
-
return a.type === "Origin" ? -1 : 1;
|
|
1268
|
-
}
|
|
1269
|
-
return a.name.localeCompare(b.name);
|
|
1270
|
-
});
|
|
1271
1810
|
setChains(chainRows);
|
|
1272
1811
|
} catch (err) {
|
|
1273
1812
|
setError(err instanceof Error ? err.message : "Failed to load chains");
|
|
@@ -1277,7 +1816,7 @@ function ChainsCommand({ json = false }) {
|
|
|
1277
1816
|
}
|
|
1278
1817
|
loadChains();
|
|
1279
1818
|
}, []);
|
|
1280
|
-
|
|
1819
|
+
useEffect4(() => {
|
|
1281
1820
|
if (!loading && json) {
|
|
1282
1821
|
setTimeout(() => exit(), 100);
|
|
1283
1822
|
}
|
|
@@ -1292,86 +1831,81 @@ function ChainsCommand({ json = false }) {
|
|
|
1292
1831
|
return null;
|
|
1293
1832
|
}
|
|
1294
1833
|
if (loading) {
|
|
1295
|
-
return /* @__PURE__ */
|
|
1296
|
-
/* @__PURE__ */
|
|
1297
|
-
/* @__PURE__ */
|
|
1834
|
+
return /* @__PURE__ */ jsxs10(Box10, { flexDirection: "column", padding: 1, children: [
|
|
1835
|
+
/* @__PURE__ */ jsx10(Header, { compact: true, showTagline: false }),
|
|
1836
|
+
/* @__PURE__ */ jsx10(Spinner, { text: "Loading supported chains..." })
|
|
1298
1837
|
] });
|
|
1299
1838
|
}
|
|
1300
1839
|
if (error) {
|
|
1301
|
-
return /* @__PURE__ */
|
|
1302
|
-
/* @__PURE__ */
|
|
1303
|
-
/* @__PURE__ */
|
|
1840
|
+
return /* @__PURE__ */ jsxs10(Box10, { flexDirection: "column", padding: 1, children: [
|
|
1841
|
+
/* @__PURE__ */ jsx10(Header, { compact: true, showTagline: false }),
|
|
1842
|
+
/* @__PURE__ */ jsx10(Box10, { children: /* @__PURE__ */ jsxs10(Text10, { color: theme.error, children: [
|
|
1304
1843
|
symbols.failed,
|
|
1305
1844
|
" Error: ",
|
|
1306
1845
|
error
|
|
1307
1846
|
] }) })
|
|
1308
|
-
] });
|
|
1309
|
-
}
|
|
1310
|
-
const
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
headerColor: theme.primary,
|
|
1322
|
-
cellColor: theme.muted
|
|
1323
|
-
},
|
|
1324
|
-
{
|
|
1325
|
-
header: "Type",
|
|
1326
|
-
accessor: "type",
|
|
1327
|
-
headerColor: theme.primary,
|
|
1328
|
-
cellColor: (value) => value === "Origin" ? theme.success : theme.accent
|
|
1329
|
-
}
|
|
1330
|
-
];
|
|
1331
|
-
return /* @__PURE__ */ jsxs9(Box9, { flexDirection: "column", padding: 1, children: [
|
|
1332
|
-
/* @__PURE__ */ jsx9(Header, { compact: true, showTagline: false }),
|
|
1333
|
-
/* @__PURE__ */ jsx9(Box9, { marginBottom: 1, children: /* @__PURE__ */ jsxs9(Text9, { color: theme.secondary, children: [
|
|
1334
|
-
symbols.arrow,
|
|
1335
|
-
" Supported Chains (",
|
|
1336
|
-
chains.length,
|
|
1337
|
-
")"
|
|
1338
|
-
] }) }),
|
|
1339
|
-
/* @__PURE__ */ jsx9(
|
|
1340
|
-
Table,
|
|
1847
|
+
] });
|
|
1848
|
+
}
|
|
1849
|
+
const listItems = chains.map((chain) => ({
|
|
1850
|
+
id: chain.id,
|
|
1851
|
+
label: chain.name,
|
|
1852
|
+
sublabel: `ID: ${chain.id}`,
|
|
1853
|
+
badge: chain.type,
|
|
1854
|
+
badgeColor: chain.type === "Origin" ? theme.success : theme.accent
|
|
1855
|
+
}));
|
|
1856
|
+
return /* @__PURE__ */ jsxs10(Box10, { flexDirection: "column", padding: 1, children: [
|
|
1857
|
+
/* @__PURE__ */ jsx10(Header, { compact: true, showTagline: false }),
|
|
1858
|
+
/* @__PURE__ */ jsx10(
|
|
1859
|
+
SearchableList,
|
|
1341
1860
|
{
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1861
|
+
items: listItems,
|
|
1862
|
+
title: "Supported Chains",
|
|
1863
|
+
placeholder: "Type to filter chains...",
|
|
1864
|
+
popularIds: POPULAR_CHAIN_IDS,
|
|
1865
|
+
maxDisplay: 12,
|
|
1866
|
+
searchable: true
|
|
1346
1867
|
}
|
|
1347
1868
|
),
|
|
1348
|
-
/* @__PURE__ */
|
|
1869
|
+
/* @__PURE__ */ jsx10(Box10, { marginTop: 1, children: /* @__PURE__ */ jsx10(Text10, { color: theme.muted, dimColor: true, children: "\u2605 = Popular chains \u2022 Origin = Source for bridging \u2022 Dest = Destination" }) })
|
|
1349
1870
|
] });
|
|
1350
1871
|
}
|
|
1351
1872
|
|
|
1352
1873
|
// src/commands/tokens.tsx
|
|
1353
|
-
import { useState as
|
|
1354
|
-
import { Box as
|
|
1874
|
+
import { useState as useState5, useEffect as useEffect5 } from "react";
|
|
1875
|
+
import { Box as Box11, Text as Text11, useApp as useApp4 } from "ink";
|
|
1355
1876
|
import {
|
|
1356
1877
|
getChains as getChains4,
|
|
1357
1878
|
getBridgeableTokens as getBridgeableTokens2
|
|
1358
1879
|
} from "@siphoyawe/mina-sdk";
|
|
1359
|
-
import { jsx as
|
|
1880
|
+
import { jsx as jsx11, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1881
|
+
var POPULAR_TOKEN_SYMBOLS = [
|
|
1882
|
+
"USDC",
|
|
1883
|
+
"USDT",
|
|
1884
|
+
"ETH",
|
|
1885
|
+
"WETH",
|
|
1886
|
+
"WBTC",
|
|
1887
|
+
"DAI",
|
|
1888
|
+
"USDC.e",
|
|
1889
|
+
"LINK",
|
|
1890
|
+
"UNI",
|
|
1891
|
+
"ARB",
|
|
1892
|
+
"OP",
|
|
1893
|
+
"MATIC"
|
|
1894
|
+
];
|
|
1360
1895
|
function truncateAddress(address) {
|
|
1361
1896
|
if (address.length <= 14) return address;
|
|
1362
|
-
return `${address.slice(0,
|
|
1897
|
+
return `${address.slice(0, 6)}...${address.slice(-4)}`;
|
|
1363
1898
|
}
|
|
1364
1899
|
async function resolveChainId(chainInput) {
|
|
1900
|
+
const response = await getChains4();
|
|
1365
1901
|
const numericId = parseInt(chainInput, 10);
|
|
1366
1902
|
if (!isNaN(numericId)) {
|
|
1367
|
-
const
|
|
1368
|
-
const chain2 = response2.chains.find((c) => c.id === numericId);
|
|
1903
|
+
const chain2 = response.chains.find((c) => c.id === numericId);
|
|
1369
1904
|
if (chain2) {
|
|
1370
1905
|
return { chainId: chain2.id, chainName: chain2.name };
|
|
1371
1906
|
}
|
|
1372
1907
|
return { chainId: numericId, chainName: chainInput };
|
|
1373
1908
|
}
|
|
1374
|
-
const response = await getChains4();
|
|
1375
1909
|
const chainLower = chainInput.toLowerCase();
|
|
1376
1910
|
const chain = response.chains.find(
|
|
1377
1911
|
(c) => c.name.toLowerCase() === chainLower || c.key?.toLowerCase() === chainLower
|
|
@@ -1386,12 +1920,12 @@ function TokensCommand({
|
|
|
1386
1920
|
json = false
|
|
1387
1921
|
}) {
|
|
1388
1922
|
const { exit } = useApp4();
|
|
1389
|
-
const [tokens, setTokens] =
|
|
1390
|
-
const [loading, setLoading] =
|
|
1391
|
-
const [error, setError] =
|
|
1392
|
-
const [chainName, setChainName] =
|
|
1393
|
-
const [availableChains, setAvailableChains] =
|
|
1394
|
-
|
|
1923
|
+
const [tokens, setTokens] = useState5([]);
|
|
1924
|
+
const [loading, setLoading] = useState5(true);
|
|
1925
|
+
const [error, setError] = useState5(null);
|
|
1926
|
+
const [chainName, setChainName] = useState5("");
|
|
1927
|
+
const [availableChains, setAvailableChains] = useState5([]);
|
|
1928
|
+
useEffect5(() => {
|
|
1395
1929
|
async function loadTokens() {
|
|
1396
1930
|
try {
|
|
1397
1931
|
setLoading(true);
|
|
@@ -1413,14 +1947,13 @@ function TokensCommand({
|
|
|
1413
1947
|
}
|
|
1414
1948
|
setChainName(resolved.chainName);
|
|
1415
1949
|
const response = await getBridgeableTokens2(resolved.chainId);
|
|
1416
|
-
const tokenRows = response.tokens.map((token) => ({
|
|
1950
|
+
const tokenRows = response.tokens.filter((token) => token.symbol && token.symbol.trim() !== "").map((token) => ({
|
|
1417
1951
|
symbol: token.symbol,
|
|
1418
1952
|
address: token.address,
|
|
1419
1953
|
displayAddress: truncateAddress(token.address),
|
|
1420
1954
|
decimals: token.decimals,
|
|
1421
1955
|
name: token.name
|
|
1422
1956
|
}));
|
|
1423
|
-
tokenRows.sort((a, b) => a.symbol.localeCompare(b.symbol));
|
|
1424
1957
|
setTokens(tokenRows);
|
|
1425
1958
|
} catch (err) {
|
|
1426
1959
|
setError(err instanceof Error ? err.message : "Failed to load tokens");
|
|
@@ -1430,7 +1963,7 @@ function TokensCommand({
|
|
|
1430
1963
|
}
|
|
1431
1964
|
loadTokens();
|
|
1432
1965
|
}, [chain]);
|
|
1433
|
-
|
|
1966
|
+
useEffect5(() => {
|
|
1434
1967
|
if (!loading && json) {
|
|
1435
1968
|
setTimeout(() => exit(), 100);
|
|
1436
1969
|
}
|
|
@@ -1457,110 +1990,82 @@ function TokensCommand({
|
|
|
1457
1990
|
return null;
|
|
1458
1991
|
}
|
|
1459
1992
|
if (loading) {
|
|
1460
|
-
return /* @__PURE__ */
|
|
1461
|
-
/* @__PURE__ */
|
|
1462
|
-
/* @__PURE__ */
|
|
1993
|
+
return /* @__PURE__ */ jsxs11(Box11, { flexDirection: "column", padding: 1, children: [
|
|
1994
|
+
/* @__PURE__ */ jsx11(Header, { compact: true, showTagline: false }),
|
|
1995
|
+
/* @__PURE__ */ jsx11(Spinner, { text: chain ? `Loading tokens for ${chain}...` : "Loading..." })
|
|
1463
1996
|
] });
|
|
1464
1997
|
}
|
|
1465
1998
|
if (error) {
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1999
|
+
const popularChainIds = [1, 42161, 10, 137, 8453, 43114];
|
|
2000
|
+
const popularChains = availableChains.filter((c) => popularChainIds.includes(c.id)).slice(0, 6);
|
|
2001
|
+
return /* @__PURE__ */ jsxs11(Box11, { flexDirection: "column", padding: 1, children: [
|
|
2002
|
+
/* @__PURE__ */ jsx11(Header, { compact: true, showTagline: false }),
|
|
2003
|
+
/* @__PURE__ */ jsx11(Box11, { marginBottom: 1, children: /* @__PURE__ */ jsxs11(Text11, { color: theme.error, children: [
|
|
1469
2004
|
symbols.failed,
|
|
1470
2005
|
" ",
|
|
1471
2006
|
error
|
|
1472
2007
|
] }) }),
|
|
1473
|
-
availableChains.length > 0 && /* @__PURE__ */
|
|
1474
|
-
/* @__PURE__ */
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
/* @__PURE__ */ jsxs10(Text10, { color: theme.muted, children: [
|
|
1483
|
-
" (ID: ",
|
|
1484
|
-
c.id,
|
|
1485
|
-
")"
|
|
1486
|
-
] })
|
|
1487
|
-
] }, i)),
|
|
1488
|
-
availableChains.length > 10 && /* @__PURE__ */ jsx10(Box10, { marginTop: 1, children: /* @__PURE__ */ jsxs10(Text10, { color: theme.muted, dimColor: true, children: [
|
|
1489
|
-
"...and ",
|
|
1490
|
-
availableChains.length - 10,
|
|
1491
|
-
' more. Use "mina chains" to see all.'
|
|
1492
|
-
] }) }),
|
|
1493
|
-
/* @__PURE__ */ jsx10(Box10, { marginTop: 1, children: /* @__PURE__ */ jsx10(Text10, { color: theme.muted, dimColor: true, children: "Example: mina tokens --chain arbitrum" }) })
|
|
2008
|
+
availableChains.length > 0 && /* @__PURE__ */ jsxs11(Box11, { flexDirection: "column", children: [
|
|
2009
|
+
/* @__PURE__ */ jsx11(Box11, { marginBottom: 1, children: /* @__PURE__ */ jsx11(Text11, { color: theme.secondary, children: "Popular chains:" }) }),
|
|
2010
|
+
/* @__PURE__ */ jsx11(Box11, { flexDirection: "row", gap: 2, flexWrap: "wrap", children: popularChains.map((c) => /* @__PURE__ */ jsx11(Box11, { children: /* @__PURE__ */ jsx11(Text11, { color: theme.primary, children: c.name.toLowerCase() }) }, c.id)) }),
|
|
2011
|
+
/* @__PURE__ */ jsx11(Box11, { marginTop: 1, children: /* @__PURE__ */ jsx11(Text11, { color: theme.muted, dimColor: true, children: "Example: mina tokens --chain arbitrum" }) }),
|
|
2012
|
+
/* @__PURE__ */ jsx11(Box11, { marginTop: 1, children: /* @__PURE__ */ jsxs11(Text11, { color: theme.muted, dimColor: true, children: [
|
|
2013
|
+
'Run "mina chains" to see all ',
|
|
2014
|
+
availableChains.length,
|
|
2015
|
+
" supported chains"
|
|
2016
|
+
] }) })
|
|
1494
2017
|
] })
|
|
1495
2018
|
] });
|
|
1496
2019
|
}
|
|
1497
2020
|
if (tokens.length === 0) {
|
|
1498
|
-
return /* @__PURE__ */
|
|
1499
|
-
/* @__PURE__ */
|
|
1500
|
-
/* @__PURE__ */
|
|
2021
|
+
return /* @__PURE__ */ jsxs11(Box11, { flexDirection: "column", padding: 1, children: [
|
|
2022
|
+
/* @__PURE__ */ jsx11(Header, { compact: true, showTagline: false }),
|
|
2023
|
+
/* @__PURE__ */ jsx11(Box11, { children: /* @__PURE__ */ jsxs11(Text11, { color: theme.warning, children: [
|
|
1501
2024
|
symbols.pending,
|
|
1502
2025
|
" No bridgeable tokens found for ",
|
|
1503
2026
|
chainName
|
|
1504
2027
|
] }) })
|
|
1505
2028
|
] });
|
|
1506
2029
|
}
|
|
1507
|
-
const
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
width: 20
|
|
1520
|
-
},
|
|
1521
|
-
{
|
|
1522
|
-
header: "Decimals",
|
|
1523
|
-
accessor: (row) => String(row.decimals),
|
|
1524
|
-
align: "right",
|
|
1525
|
-
headerColor: theme.primary,
|
|
1526
|
-
cellColor: theme.secondary
|
|
1527
|
-
}
|
|
1528
|
-
];
|
|
1529
|
-
return /* @__PURE__ */ jsxs10(Box10, { flexDirection: "column", padding: 1, children: [
|
|
1530
|
-
/* @__PURE__ */ jsx10(Header, { compact: true, showTagline: false }),
|
|
1531
|
-
/* @__PURE__ */ jsxs10(Box10, { marginBottom: 1, children: [
|
|
1532
|
-
/* @__PURE__ */ jsxs10(Text10, { color: theme.secondary, children: [
|
|
2030
|
+
const listItems = tokens.map((token) => ({
|
|
2031
|
+
id: token.address,
|
|
2032
|
+
label: token.symbol,
|
|
2033
|
+
sublabel: token.displayAddress,
|
|
2034
|
+
badge: `${token.decimals}d`,
|
|
2035
|
+
badgeColor: theme.muted
|
|
2036
|
+
}));
|
|
2037
|
+
const popularTokenIds = tokens.filter((t) => POPULAR_TOKEN_SYMBOLS.includes(t.symbol.toUpperCase())).map((t) => t.address);
|
|
2038
|
+
return /* @__PURE__ */ jsxs11(Box11, { flexDirection: "column", padding: 1, children: [
|
|
2039
|
+
/* @__PURE__ */ jsx11(Header, { compact: true, showTagline: false }),
|
|
2040
|
+
/* @__PURE__ */ jsxs11(Box11, { marginBottom: 1, children: [
|
|
2041
|
+
/* @__PURE__ */ jsxs11(Text11, { color: theme.secondary, children: [
|
|
1533
2042
|
symbols.arrow,
|
|
1534
2043
|
" Bridgeable Tokens on",
|
|
1535
2044
|
" "
|
|
1536
2045
|
] }),
|
|
1537
|
-
/* @__PURE__ */
|
|
1538
|
-
/* @__PURE__ */ jsxs10(Text10, { color: theme.muted, children: [
|
|
1539
|
-
" (",
|
|
1540
|
-
tokens.length,
|
|
1541
|
-
")"
|
|
1542
|
-
] })
|
|
2046
|
+
/* @__PURE__ */ jsx11(Text11, { color: theme.primary, bold: true, children: chainName })
|
|
1543
2047
|
] }),
|
|
1544
|
-
/* @__PURE__ */
|
|
1545
|
-
|
|
2048
|
+
/* @__PURE__ */ jsx11(
|
|
2049
|
+
SearchableList,
|
|
1546
2050
|
{
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
2051
|
+
items: listItems,
|
|
2052
|
+
placeholder: "Type to filter tokens (e.g. USDC, ETH)...",
|
|
2053
|
+
popularIds: popularTokenIds,
|
|
2054
|
+
maxDisplay: 12,
|
|
2055
|
+
searchable: true
|
|
1551
2056
|
}
|
|
1552
2057
|
),
|
|
1553
|
-
/* @__PURE__ */
|
|
2058
|
+
/* @__PURE__ */ jsx11(Box11, { marginTop: 1, children: /* @__PURE__ */ jsx11(Text11, { color: theme.muted, dimColor: true, children: "\u2605 = Popular tokens \u2022 Tokens bridgeable to Hyperliquid via Mina" }) })
|
|
1554
2059
|
] });
|
|
1555
2060
|
}
|
|
1556
2061
|
|
|
1557
2062
|
// src/commands/status.tsx
|
|
1558
|
-
import { useState as
|
|
1559
|
-
import { Box as
|
|
2063
|
+
import { useState as useState6, useEffect as useEffect6, useCallback as useCallback2, useMemo as useMemo2 } from "react";
|
|
2064
|
+
import { Box as Box12, Text as Text12, useApp as useApp5 } from "ink";
|
|
1560
2065
|
import {
|
|
1561
|
-
Mina as
|
|
2066
|
+
Mina as Mina3
|
|
1562
2067
|
} from "@siphoyawe/mina-sdk";
|
|
1563
|
-
import { jsx as
|
|
2068
|
+
import { jsx as jsx12, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1564
2069
|
function formatDuration(ms) {
|
|
1565
2070
|
const seconds = Math.floor(ms / 1e3);
|
|
1566
2071
|
if (seconds < 60) return `${seconds}s`;
|
|
@@ -1591,15 +2096,15 @@ function getStatusColor2(status) {
|
|
|
1591
2096
|
function getStepIndicator(status) {
|
|
1592
2097
|
switch (status) {
|
|
1593
2098
|
case "pending":
|
|
1594
|
-
return /* @__PURE__ */
|
|
2099
|
+
return /* @__PURE__ */ jsx12(Text12, { color: theme.muted, children: symbols.pending });
|
|
1595
2100
|
case "executing":
|
|
1596
|
-
return /* @__PURE__ */
|
|
2101
|
+
return /* @__PURE__ */ jsx12(Text12, { color: theme.primary, children: /* @__PURE__ */ jsx12(Spinner, {}) });
|
|
1597
2102
|
case "completed":
|
|
1598
|
-
return /* @__PURE__ */
|
|
2103
|
+
return /* @__PURE__ */ jsx12(Text12, { color: theme.success, children: symbols.completed });
|
|
1599
2104
|
case "failed":
|
|
1600
|
-
return /* @__PURE__ */
|
|
2105
|
+
return /* @__PURE__ */ jsx12(Text12, { color: theme.error, children: symbols.failed });
|
|
1601
2106
|
default:
|
|
1602
|
-
return /* @__PURE__ */
|
|
2107
|
+
return /* @__PURE__ */ jsx12(Text12, { color: theme.muted, children: symbols.pending });
|
|
1603
2108
|
}
|
|
1604
2109
|
}
|
|
1605
2110
|
function calculateProgress(steps) {
|
|
@@ -1635,8 +2140,8 @@ function StatusDisplay({
|
|
|
1635
2140
|
const stepInfo = getCurrentStepInfo(status.steps);
|
|
1636
2141
|
const progress = calculateProgress(status.steps);
|
|
1637
2142
|
const statusLabel = status.status.charAt(0).toUpperCase() + status.status.slice(1);
|
|
1638
|
-
return /* @__PURE__ */
|
|
1639
|
-
/* @__PURE__ */
|
|
2143
|
+
return /* @__PURE__ */ jsxs12(Box12, { flexDirection: "column", children: [
|
|
2144
|
+
/* @__PURE__ */ jsx12(Box, { bordered: true, title: "Bridge Status", padding: 1, children: /* @__PURE__ */ jsx12(
|
|
1640
2145
|
KeyValue,
|
|
1641
2146
|
{
|
|
1642
2147
|
items: [
|
|
@@ -1646,11 +2151,11 @@ function StatusDisplay({
|
|
|
1646
2151
|
valueColor: getStatusColor2(status.status)
|
|
1647
2152
|
}
|
|
1648
2153
|
) }),
|
|
1649
|
-
/* @__PURE__ */
|
|
1650
|
-
status.steps.map((step, index) => /* @__PURE__ */
|
|
1651
|
-
/* @__PURE__ */
|
|
1652
|
-
/* @__PURE__ */
|
|
1653
|
-
|
|
2154
|
+
/* @__PURE__ */ jsx12(Box12, { marginTop: 1, children: /* @__PURE__ */ jsx12(Box, { bordered: true, padding: 1, children: /* @__PURE__ */ jsxs12(Box12, { flexDirection: "column", children: [
|
|
2155
|
+
status.steps.map((step, index) => /* @__PURE__ */ jsxs12(Box12, { children: [
|
|
2156
|
+
/* @__PURE__ */ jsx12(Box12, { width: 3, children: getStepIndicator(step.status) }),
|
|
2157
|
+
/* @__PURE__ */ jsx12(Box12, { flexGrow: 1, children: /* @__PURE__ */ jsxs12(
|
|
2158
|
+
Text12,
|
|
1654
2159
|
{
|
|
1655
2160
|
color: getStatusColor2(step.status),
|
|
1656
2161
|
bold: step.status === "executing",
|
|
@@ -1661,11 +2166,11 @@ function StatusDisplay({
|
|
|
1661
2166
|
]
|
|
1662
2167
|
}
|
|
1663
2168
|
) }),
|
|
1664
|
-
step.txHash && /* @__PURE__ */
|
|
2169
|
+
step.txHash && /* @__PURE__ */ jsx12(Box12, { marginLeft: 2, children: /* @__PURE__ */ jsx12(Text12, { color: theme.muted, dimColor: true, children: truncateHash(step.txHash) }) })
|
|
1665
2170
|
] }, step.stepId)),
|
|
1666
|
-
status.steps.length === 0 && /* @__PURE__ */
|
|
2171
|
+
status.steps.length === 0 && /* @__PURE__ */ jsx12(Text12, { color: theme.muted, children: "No steps found" })
|
|
1667
2172
|
] }) }) }),
|
|
1668
|
-
/* @__PURE__ */
|
|
2173
|
+
/* @__PURE__ */ jsx12(Box12, { marginTop: 1, children: /* @__PURE__ */ jsx12(Box, { bordered: true, padding: 1, children: /* @__PURE__ */ jsx12(
|
|
1669
2174
|
KeyValue,
|
|
1670
2175
|
{
|
|
1671
2176
|
items: [
|
|
@@ -1679,19 +2184,19 @@ function StatusDisplay({
|
|
|
1679
2184
|
valueColor: theme.secondary
|
|
1680
2185
|
}
|
|
1681
2186
|
) }) }),
|
|
1682
|
-
status.status === "failed" && /* @__PURE__ */
|
|
1683
|
-
/* @__PURE__ */
|
|
2187
|
+
status.status === "failed" && /* @__PURE__ */ jsx12(Box12, { marginTop: 1, children: /* @__PURE__ */ jsx12(Box, { bordered: true, borderColor: theme.error, padding: 1, children: /* @__PURE__ */ jsxs12(Box12, { flexDirection: "column", children: [
|
|
2188
|
+
/* @__PURE__ */ jsxs12(Text12, { color: theme.error, bold: true, children: [
|
|
1684
2189
|
symbols.failed,
|
|
1685
2190
|
" Transaction Failed"
|
|
1686
2191
|
] }),
|
|
1687
|
-
status.steps.find((s) => s.status === "failed")?.error && /* @__PURE__ */
|
|
2192
|
+
status.steps.find((s) => s.status === "failed")?.error && /* @__PURE__ */ jsx12(Box12, { marginTop: 1, children: /* @__PURE__ */ jsx12(Text12, { color: theme.muted, children: status.steps.find((s) => s.status === "failed")?.error }) })
|
|
1688
2193
|
] }) }) }),
|
|
1689
|
-
status.status === "completed" && /* @__PURE__ */
|
|
1690
|
-
/* @__PURE__ */
|
|
2194
|
+
status.status === "completed" && /* @__PURE__ */ jsx12(Box12, { marginTop: 1, children: /* @__PURE__ */ jsx12(Box, { bordered: true, borderColor: theme.success, padding: 1, children: /* @__PURE__ */ jsxs12(Box12, { flexDirection: "column", children: [
|
|
2195
|
+
/* @__PURE__ */ jsxs12(Text12, { color: theme.success, bold: true, children: [
|
|
1691
2196
|
symbols.completed,
|
|
1692
2197
|
" Bridge Completed Successfully"
|
|
1693
2198
|
] }),
|
|
1694
|
-
status.bridgeTxHash && /* @__PURE__ */
|
|
2199
|
+
status.bridgeTxHash && /* @__PURE__ */ jsx12(Box12, { marginTop: 1, children: /* @__PURE__ */ jsx12(
|
|
1695
2200
|
KeyValue,
|
|
1696
2201
|
{
|
|
1697
2202
|
items: [
|
|
@@ -1706,23 +2211,23 @@ function StatusDisplay({
|
|
|
1706
2211
|
] });
|
|
1707
2212
|
}
|
|
1708
2213
|
function LoadingState({ txHash }) {
|
|
1709
|
-
return /* @__PURE__ */
|
|
2214
|
+
return /* @__PURE__ */ jsx12(Box12, { flexDirection: "column", children: /* @__PURE__ */ jsx12(Box, { bordered: true, title: "Bridge Status", padding: 1, children: /* @__PURE__ */ jsx12(Box12, { children: /* @__PURE__ */ jsx12(Spinner, { text: `Looking up ${truncateHash(txHash)}...` }) }) }) });
|
|
1710
2215
|
}
|
|
1711
2216
|
function NotFoundState({ txHash }) {
|
|
1712
|
-
return /* @__PURE__ */
|
|
1713
|
-
/* @__PURE__ */
|
|
2217
|
+
return /* @__PURE__ */ jsx12(Box12, { flexDirection: "column", children: /* @__PURE__ */ jsx12(Box, { bordered: true, borderColor: theme.warning, title: "Bridge Status", padding: 1, children: /* @__PURE__ */ jsxs12(Box12, { flexDirection: "column", children: [
|
|
2218
|
+
/* @__PURE__ */ jsxs12(Text12, { color: theme.warning, children: [
|
|
1714
2219
|
symbols.pending,
|
|
1715
2220
|
" Transaction not found"
|
|
1716
2221
|
] }),
|
|
1717
|
-
/* @__PURE__ */
|
|
2222
|
+
/* @__PURE__ */ jsx12(Box12, { marginTop: 1, children: /* @__PURE__ */ jsxs12(Text12, { color: theme.muted, children: [
|
|
1718
2223
|
"TX: ",
|
|
1719
2224
|
truncateHash(txHash)
|
|
1720
2225
|
] }) }),
|
|
1721
|
-
/* @__PURE__ */
|
|
2226
|
+
/* @__PURE__ */ jsx12(Box12, { marginTop: 1, children: /* @__PURE__ */ jsx12(Text12, { color: theme.muted, dimColor: true, children: "The transaction may not have been initiated via this CLI, or it may have expired from the local cache." }) })
|
|
1722
2227
|
] }) }) });
|
|
1723
2228
|
}
|
|
1724
2229
|
function ErrorState({ error }) {
|
|
1725
|
-
return /* @__PURE__ */
|
|
2230
|
+
return /* @__PURE__ */ jsx12(Box12, { flexDirection: "column", children: /* @__PURE__ */ jsx12(Box, { bordered: true, borderColor: theme.error, title: "Error", padding: 1, children: /* @__PURE__ */ jsxs12(Text12, { color: theme.error, children: [
|
|
1726
2231
|
symbols.failed,
|
|
1727
2232
|
" ",
|
|
1728
2233
|
error
|
|
@@ -1730,13 +2235,13 @@ function ErrorState({ error }) {
|
|
|
1730
2235
|
}
|
|
1731
2236
|
function Status({ txHash, watch = false }) {
|
|
1732
2237
|
const { exit } = useApp5();
|
|
1733
|
-
const [status, setStatus] =
|
|
1734
|
-
const [loading, setLoading] =
|
|
1735
|
-
const [error, setError] =
|
|
1736
|
-
const [notFound, setNotFound] =
|
|
1737
|
-
const [startTime] =
|
|
1738
|
-
const [elapsedTime, setElapsedTime] =
|
|
1739
|
-
const mina =
|
|
2238
|
+
const [status, setStatus] = useState6(null);
|
|
2239
|
+
const [loading, setLoading] = useState6(true);
|
|
2240
|
+
const [error, setError] = useState6(null);
|
|
2241
|
+
const [notFound, setNotFound] = useState6(false);
|
|
2242
|
+
const [startTime] = useState6(Date.now());
|
|
2243
|
+
const [elapsedTime, setElapsedTime] = useState6(0);
|
|
2244
|
+
const mina = useMemo2(() => new Mina3({ integrator: "mina-cli" }), []);
|
|
1740
2245
|
const fetchStatus = useCallback2(async () => {
|
|
1741
2246
|
try {
|
|
1742
2247
|
const result = await mina.getStatus(txHash);
|
|
@@ -1762,17 +2267,17 @@ function Status({ txHash, watch = false }) {
|
|
|
1762
2267
|
}
|
|
1763
2268
|
}
|
|
1764
2269
|
}, [txHash, watch, exit, mina]);
|
|
1765
|
-
|
|
2270
|
+
useEffect6(() => {
|
|
1766
2271
|
fetchStatus();
|
|
1767
2272
|
}, [fetchStatus]);
|
|
1768
|
-
|
|
2273
|
+
useEffect6(() => {
|
|
1769
2274
|
if (!watch) return;
|
|
1770
2275
|
const interval = setInterval(() => {
|
|
1771
2276
|
fetchStatus();
|
|
1772
2277
|
}, 5e3);
|
|
1773
2278
|
return () => clearInterval(interval);
|
|
1774
2279
|
}, [watch, fetchStatus]);
|
|
1775
|
-
|
|
2280
|
+
useEffect6(() => {
|
|
1776
2281
|
const interval = setInterval(() => {
|
|
1777
2282
|
setElapsedTime(Date.now() - (status?.createdAt || startTime));
|
|
1778
2283
|
}, 1e3);
|
|
@@ -1786,17 +2291,17 @@ function Status({ txHash, watch = false }) {
|
|
|
1786
2291
|
const totalEstimated = elapsed / progress * 100;
|
|
1787
2292
|
return Math.max(0, totalEstimated - elapsed);
|
|
1788
2293
|
})() : null;
|
|
1789
|
-
return /* @__PURE__ */
|
|
1790
|
-
/* @__PURE__ */
|
|
1791
|
-
watch && /* @__PURE__ */
|
|
1792
|
-
/* @__PURE__ */
|
|
2294
|
+
return /* @__PURE__ */ jsxs12(Box12, { flexDirection: "column", padding: 1, children: [
|
|
2295
|
+
/* @__PURE__ */ jsx12(Header, { showTagline: false }),
|
|
2296
|
+
watch && /* @__PURE__ */ jsx12(Box12, { marginBottom: 1, children: /* @__PURE__ */ jsxs12(Text12, { color: theme.primary, children: [
|
|
2297
|
+
/* @__PURE__ */ jsx12(Spinner, {}),
|
|
1793
2298
|
" Watching for updates (polling every 5s)"
|
|
1794
2299
|
] }) }),
|
|
1795
|
-
/* @__PURE__ */
|
|
1796
|
-
loading && /* @__PURE__ */
|
|
1797
|
-
error && /* @__PURE__ */
|
|
1798
|
-
notFound && !loading && /* @__PURE__ */
|
|
1799
|
-
status && !loading && !error && /* @__PURE__ */
|
|
2300
|
+
/* @__PURE__ */ jsxs12(Box12, { marginTop: 1, children: [
|
|
2301
|
+
loading && /* @__PURE__ */ jsx12(LoadingState, { txHash }),
|
|
2302
|
+
error && /* @__PURE__ */ jsx12(ErrorState, { error }),
|
|
2303
|
+
notFound && !loading && /* @__PURE__ */ jsx12(NotFoundState, { txHash }),
|
|
2304
|
+
status && !loading && !error && /* @__PURE__ */ jsx12(
|
|
1800
2305
|
StatusDisplay,
|
|
1801
2306
|
{
|
|
1802
2307
|
status,
|
|
@@ -1806,153 +2311,43 @@ function Status({ txHash, watch = false }) {
|
|
|
1806
2311
|
}
|
|
1807
2312
|
)
|
|
1808
2313
|
] }),
|
|
1809
|
-
/* @__PURE__ */
|
|
2314
|
+
/* @__PURE__ */ jsx12(Box12, { marginTop: 1, children: /* @__PURE__ */ jsx12(Text12, { color: theme.muted, dimColor: true, children: watch ? "Ctrl+C to stop watching" : "Press any key to exit" }) })
|
|
1810
2315
|
] });
|
|
1811
2316
|
}
|
|
1812
2317
|
|
|
1813
2318
|
// src/commands/bridge.tsx
|
|
1814
|
-
import { useState as
|
|
1815
|
-
import { Box as
|
|
2319
|
+
import { useState as useState7, useEffect as useEffect7, useCallback as useCallback3 } from "react";
|
|
2320
|
+
import { Box as Box13, Text as Text13, useApp as useApp6, useInput as useInput3 } from "ink";
|
|
1816
2321
|
import {
|
|
1817
|
-
Mina as
|
|
2322
|
+
Mina as Mina4,
|
|
1818
2323
|
getChains as getChains5,
|
|
1819
2324
|
getBridgeableTokens as getBridgeableTokens3,
|
|
1820
|
-
getQuote,
|
|
2325
|
+
getQuote as getQuote2,
|
|
1821
2326
|
HYPEREVM_CHAIN_ID as HYPEREVM_CHAIN_ID4,
|
|
1822
|
-
HYPEREVM_USDC_ADDRESS as
|
|
1823
|
-
normalizeError,
|
|
2327
|
+
HYPEREVM_USDC_ADDRESS as HYPEREVM_USDC_ADDRESS3,
|
|
2328
|
+
normalizeError as normalizeError2,
|
|
1824
2329
|
isRecoverableError,
|
|
1825
2330
|
RECOVERY_ACTIONS
|
|
1826
2331
|
} from "@siphoyawe/mina-sdk";
|
|
1827
|
-
|
|
1828
|
-
// src/lib/wallet.ts
|
|
1829
|
-
import fs from "fs";
|
|
1830
|
-
import readline from "readline";
|
|
1831
|
-
async function loadPrivateKey(path3) {
|
|
1832
|
-
if (path3) {
|
|
1833
|
-
if (!fs.existsSync(path3)) {
|
|
1834
|
-
throw new Error(`Key file not found: ${path3}`);
|
|
1835
|
-
}
|
|
1836
|
-
const content = fs.readFileSync(path3, "utf-8");
|
|
1837
|
-
try {
|
|
1838
|
-
const json = JSON.parse(content);
|
|
1839
|
-
const key = json.privateKey || json.private_key || json.key;
|
|
1840
|
-
if (key) {
|
|
1841
|
-
return normalizePrivateKey(key);
|
|
1842
|
-
}
|
|
1843
|
-
return normalizePrivateKey(content.trim());
|
|
1844
|
-
} catch {
|
|
1845
|
-
return normalizePrivateKey(content.trim());
|
|
1846
|
-
}
|
|
1847
|
-
}
|
|
1848
|
-
return promptForPrivateKey();
|
|
1849
|
-
}
|
|
1850
|
-
function promptForPrivateKey() {
|
|
1851
|
-
return new Promise((resolve, reject) => {
|
|
1852
|
-
const rl = readline.createInterface({
|
|
1853
|
-
input: process.stdin,
|
|
1854
|
-
output: process.stdout
|
|
1855
|
-
});
|
|
1856
|
-
process.stdout.write("Enter private key (input will be visible): ");
|
|
1857
|
-
rl.on("line", (answer) => {
|
|
1858
|
-
rl.close();
|
|
1859
|
-
try {
|
|
1860
|
-
resolve(normalizePrivateKey(answer.trim()));
|
|
1861
|
-
} catch (err) {
|
|
1862
|
-
reject(err);
|
|
1863
|
-
}
|
|
1864
|
-
});
|
|
1865
|
-
rl.on("close", () => {
|
|
1866
|
-
});
|
|
1867
|
-
});
|
|
1868
|
-
}
|
|
1869
|
-
function normalizePrivateKey(key) {
|
|
1870
|
-
const trimmed = key.trim();
|
|
1871
|
-
const keyWithoutPrefix = trimmed.startsWith("0x") ? trimmed.slice(2) : trimmed;
|
|
1872
|
-
if (!/^[0-9a-fA-F]{64}$/.test(keyWithoutPrefix)) {
|
|
1873
|
-
throw new Error("Invalid private key format. Expected 64 hex characters.");
|
|
1874
|
-
}
|
|
1875
|
-
return trimmed.startsWith("0x") ? trimmed : `0x${trimmed}`;
|
|
1876
|
-
}
|
|
1877
|
-
async function getAddressFromPrivateKey(privateKey) {
|
|
1878
|
-
const { privateKeyToAccount } = await import("viem/accounts");
|
|
1879
|
-
const account = privateKeyToAccount(privateKey);
|
|
1880
|
-
return account.address;
|
|
1881
|
-
}
|
|
1882
|
-
async function createSigner(privateKey, chainId, rpcUrl) {
|
|
1883
|
-
const { privateKeyToAccount } = await import("viem/accounts");
|
|
1884
|
-
const { createWalletClient, http } = await import("viem");
|
|
1885
|
-
const { arbitrum, mainnet, optimism, polygon, base, avalanche, bsc } = await import("viem/chains");
|
|
1886
|
-
const chainMap = {
|
|
1887
|
-
1: mainnet,
|
|
1888
|
-
42161: arbitrum,
|
|
1889
|
-
10: optimism,
|
|
1890
|
-
137: polygon,
|
|
1891
|
-
8453: base,
|
|
1892
|
-
43114: avalanche,
|
|
1893
|
-
56: bsc,
|
|
1894
|
-
// HyperEVM
|
|
1895
|
-
999: {
|
|
1896
|
-
id: 999,
|
|
1897
|
-
name: "HyperEVM",
|
|
1898
|
-
nativeCurrency: { name: "ETH", symbol: "ETH", decimals: 18 },
|
|
1899
|
-
rpcUrls: {
|
|
1900
|
-
default: { http: ["https://rpc.hyperliquid.xyz/evm"] }
|
|
1901
|
-
}
|
|
1902
|
-
}
|
|
1903
|
-
};
|
|
1904
|
-
const chain = chainMap[chainId];
|
|
1905
|
-
if (!chain) {
|
|
1906
|
-
throw new Error(`Unsupported chain ID: ${chainId}. Supported: ${Object.keys(chainMap).join(", ")}`);
|
|
1907
|
-
}
|
|
1908
|
-
const account = privateKeyToAccount(privateKey);
|
|
1909
|
-
const transport = rpcUrl ? http(rpcUrl) : http();
|
|
1910
|
-
const walletClient = createWalletClient({
|
|
1911
|
-
account,
|
|
1912
|
-
chain,
|
|
1913
|
-
transport
|
|
1914
|
-
});
|
|
1915
|
-
return {
|
|
1916
|
-
sendTransaction: async (request) => {
|
|
1917
|
-
const txHash = await walletClient.sendTransaction({
|
|
1918
|
-
to: request.to,
|
|
1919
|
-
data: request.data,
|
|
1920
|
-
value: BigInt(request.value || "0"),
|
|
1921
|
-
gas: request.gasLimit ? BigInt(request.gasLimit) : void 0,
|
|
1922
|
-
gasPrice: request.gasPrice ? BigInt(request.gasPrice) : void 0,
|
|
1923
|
-
chain
|
|
1924
|
-
});
|
|
1925
|
-
return txHash;
|
|
1926
|
-
},
|
|
1927
|
-
getAddress: async () => {
|
|
1928
|
-
return account.address;
|
|
1929
|
-
},
|
|
1930
|
-
getChainId: async () => {
|
|
1931
|
-
return chainId;
|
|
1932
|
-
}
|
|
1933
|
-
};
|
|
1934
|
-
}
|
|
1935
|
-
|
|
1936
|
-
// src/commands/bridge.tsx
|
|
1937
|
-
import { jsx as jsx12, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
2332
|
+
import { jsx as jsx13, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1938
2333
|
function ErrorDisplay2({
|
|
1939
2334
|
error,
|
|
1940
2335
|
recoveryAction
|
|
1941
2336
|
}) {
|
|
1942
|
-
const normalizedError =
|
|
2337
|
+
const normalizedError = normalizeError2(error);
|
|
1943
2338
|
const isRecoverable = isRecoverableError(normalizedError);
|
|
1944
|
-
return /* @__PURE__ */
|
|
1945
|
-
/* @__PURE__ */
|
|
2339
|
+
return /* @__PURE__ */ jsxs13(Box13, { flexDirection: "column", marginTop: 1, children: [
|
|
2340
|
+
/* @__PURE__ */ jsx13(Box13, { children: /* @__PURE__ */ jsxs13(Text13, { color: theme.error, bold: true, children: [
|
|
1946
2341
|
symbols.failed,
|
|
1947
2342
|
" Error: ",
|
|
1948
2343
|
normalizedError.message
|
|
1949
2344
|
] }) }),
|
|
1950
|
-
recoveryAction && /* @__PURE__ */
|
|
2345
|
+
recoveryAction && /* @__PURE__ */ jsx13(Box13, { marginTop: 1, children: /* @__PURE__ */ jsxs13(Text13, { color: theme.warning, children: [
|
|
1951
2346
|
symbols.arrow,
|
|
1952
2347
|
" Recovery suggestion: ",
|
|
1953
2348
|
recoveryAction
|
|
1954
2349
|
] }) }),
|
|
1955
|
-
isRecoverable && /* @__PURE__ */
|
|
2350
|
+
isRecoverable && /* @__PURE__ */ jsx13(Box13, { marginTop: 1, children: /* @__PURE__ */ jsx13(Text13, { color: theme.muted, dimColor: true, children: "This error may be temporary. Try again in a few moments." }) })
|
|
1956
2351
|
] });
|
|
1957
2352
|
}
|
|
1958
2353
|
function QuoteDisplay2({
|
|
@@ -1963,8 +2358,8 @@ function QuoteDisplay2({
|
|
|
1963
2358
|
}) {
|
|
1964
2359
|
const estimatedMinutes = Math.ceil(quote.estimatedTime / 60);
|
|
1965
2360
|
const outputFormatted = (Number(quote.toAmount) / Math.pow(10, quote.toToken.decimals)).toFixed(2);
|
|
1966
|
-
return /* @__PURE__ */
|
|
1967
|
-
/* @__PURE__ */
|
|
2361
|
+
return /* @__PURE__ */ jsxs13(Box, { bordered: true, title: "Bridge Quote", padding: 1, children: [
|
|
2362
|
+
/* @__PURE__ */ jsx13(
|
|
1968
2363
|
KeyValue,
|
|
1969
2364
|
{
|
|
1970
2365
|
items: [
|
|
@@ -1975,8 +2370,8 @@ function QuoteDisplay2({
|
|
|
1975
2370
|
]
|
|
1976
2371
|
}
|
|
1977
2372
|
),
|
|
1978
|
-
/* @__PURE__ */
|
|
1979
|
-
/* @__PURE__ */
|
|
2373
|
+
/* @__PURE__ */ jsx13(Box13, { marginTop: 1, marginBottom: 1, children: /* @__PURE__ */ jsx13(Divider, { width: 40 }) }),
|
|
2374
|
+
/* @__PURE__ */ jsx13(
|
|
1980
2375
|
KeyValue,
|
|
1981
2376
|
{
|
|
1982
2377
|
items: [
|
|
@@ -1989,13 +2384,13 @@ function QuoteDisplay2({
|
|
|
1989
2384
|
valueColor: theme.warning
|
|
1990
2385
|
}
|
|
1991
2386
|
),
|
|
1992
|
-
quote.highImpact && /* @__PURE__ */
|
|
2387
|
+
quote.highImpact && /* @__PURE__ */ jsx13(Box13, { marginTop: 1, children: /* @__PURE__ */ jsxs13(Text13, { color: theme.warning, children: [
|
|
1993
2388
|
symbols.pending,
|
|
1994
2389
|
" Warning: High price impact (",
|
|
1995
2390
|
(quote.priceImpact * 100).toFixed(2),
|
|
1996
2391
|
"%)"
|
|
1997
2392
|
] }) }),
|
|
1998
|
-
quote.includesAutoDeposit && /* @__PURE__ */
|
|
2393
|
+
quote.includesAutoDeposit && /* @__PURE__ */ jsx13(Box13, { marginTop: 1, children: /* @__PURE__ */ jsxs13(Text13, { color: theme.success, dimColor: true, children: [
|
|
1999
2394
|
symbols.check,
|
|
2000
2395
|
" Auto-deposit to Hyperliquid L1 included"
|
|
2001
2396
|
] }) })
|
|
@@ -2041,7 +2436,7 @@ function BridgeProgressDisplay({
|
|
|
2041
2436
|
}
|
|
2042
2437
|
}
|
|
2043
2438
|
}
|
|
2044
|
-
return /* @__PURE__ */
|
|
2439
|
+
return /* @__PURE__ */ jsx13(ProgressSteps, { steps, title: "Bridge Progress", showNumbers: true });
|
|
2045
2440
|
}
|
|
2046
2441
|
function SuccessDisplay({
|
|
2047
2442
|
result,
|
|
@@ -2049,12 +2444,12 @@ function SuccessDisplay({
|
|
|
2049
2444
|
token,
|
|
2050
2445
|
amount
|
|
2051
2446
|
}) {
|
|
2052
|
-
return /* @__PURE__ */
|
|
2053
|
-
/* @__PURE__ */
|
|
2447
|
+
return /* @__PURE__ */ jsxs13(Box13, { flexDirection: "column", marginTop: 1, children: [
|
|
2448
|
+
/* @__PURE__ */ jsx13(Box13, { children: /* @__PURE__ */ jsxs13(Text13, { color: theme.success, bold: true, children: [
|
|
2054
2449
|
symbols.check,
|
|
2055
2450
|
" Bridge completed successfully!"
|
|
2056
2451
|
] }) }),
|
|
2057
|
-
/* @__PURE__ */
|
|
2452
|
+
/* @__PURE__ */ jsx13(Box13, { marginTop: 1, children: /* @__PURE__ */ jsx13(Box, { bordered: true, padding: 1, children: /* @__PURE__ */ jsx13(
|
|
2058
2453
|
KeyValue,
|
|
2059
2454
|
{
|
|
2060
2455
|
items: [
|
|
@@ -2067,29 +2462,29 @@ function SuccessDisplay({
|
|
|
2067
2462
|
valueColor: theme.success
|
|
2068
2463
|
}
|
|
2069
2464
|
) }) }),
|
|
2070
|
-
/* @__PURE__ */
|
|
2465
|
+
/* @__PURE__ */ jsx13(Box13, { marginTop: 1, children: /* @__PURE__ */ jsx13(Text13, { color: theme.muted, dimColor: true, children: "Your funds are now available on HyperEVM. Check your Hyperliquid balance." }) })
|
|
2071
2466
|
] });
|
|
2072
2467
|
}
|
|
2073
2468
|
function Bridge({ options }) {
|
|
2074
2469
|
const { exit } = useApp6();
|
|
2075
|
-
const [state, setState] =
|
|
2076
|
-
const [chain, setChain] =
|
|
2077
|
-
const [token, setToken] =
|
|
2078
|
-
const [quote, setQuote] =
|
|
2079
|
-
const [walletAddress, setWalletAddress] =
|
|
2080
|
-
const [privateKey, setPrivateKey] =
|
|
2081
|
-
const [error, setError] =
|
|
2082
|
-
const [recoveryAction, setRecoveryAction] =
|
|
2083
|
-
const [result, setResult] =
|
|
2084
|
-
const [currentStepDescription, setCurrentStepDescription] =
|
|
2085
|
-
const [stepState, setStepState] =
|
|
2470
|
+
const [state, setState] = useState7("loading");
|
|
2471
|
+
const [chain, setChain] = useState7(null);
|
|
2472
|
+
const [token, setToken] = useState7(null);
|
|
2473
|
+
const [quote, setQuote] = useState7(null);
|
|
2474
|
+
const [walletAddress, setWalletAddress] = useState7(null);
|
|
2475
|
+
const [privateKey, setPrivateKey] = useState7(null);
|
|
2476
|
+
const [error, setError] = useState7(null);
|
|
2477
|
+
const [recoveryAction, setRecoveryAction] = useState7(null);
|
|
2478
|
+
const [result, setResult] = useState7(null);
|
|
2479
|
+
const [currentStepDescription, setCurrentStepDescription] = useState7("");
|
|
2480
|
+
const [stepState, setStepState] = useState7({
|
|
2086
2481
|
loading: "active",
|
|
2087
2482
|
quote: "pending",
|
|
2088
2483
|
approval: "pending",
|
|
2089
2484
|
bridge: "pending",
|
|
2090
2485
|
confirm: "pending"
|
|
2091
2486
|
});
|
|
2092
|
-
|
|
2487
|
+
useInput3((input, key) => {
|
|
2093
2488
|
if (state === "confirming") {
|
|
2094
2489
|
if (key.return || input === "y" || input === "Y") {
|
|
2095
2490
|
executeBridge();
|
|
@@ -2103,7 +2498,7 @@ function Bridge({ options }) {
|
|
|
2103
2498
|
}
|
|
2104
2499
|
}
|
|
2105
2500
|
});
|
|
2106
|
-
|
|
2501
|
+
useEffect7(() => {
|
|
2107
2502
|
loadInitialData();
|
|
2108
2503
|
}, []);
|
|
2109
2504
|
const loadInitialData = async () => {
|
|
@@ -2131,11 +2526,11 @@ function Bridge({ options }) {
|
|
|
2131
2526
|
setToken(foundToken);
|
|
2132
2527
|
setStepState((prev) => ({ ...prev, loading: "completed", quote: "active" }));
|
|
2133
2528
|
const amountInSmallestUnit = (parseFloat(options.amount) * Math.pow(10, foundToken.decimals)).toString();
|
|
2134
|
-
const quoteResult = await
|
|
2529
|
+
const quoteResult = await getQuote2({
|
|
2135
2530
|
fromChainId: foundChain.id,
|
|
2136
2531
|
toChainId: HYPEREVM_CHAIN_ID4,
|
|
2137
2532
|
fromToken: foundToken.address,
|
|
2138
|
-
toToken:
|
|
2533
|
+
toToken: HYPEREVM_USDC_ADDRESS3,
|
|
2139
2534
|
fromAmount: amountInSmallestUnit,
|
|
2140
2535
|
fromAddress: address
|
|
2141
2536
|
});
|
|
@@ -2149,7 +2544,7 @@ function Bridge({ options }) {
|
|
|
2149
2544
|
setState("confirming");
|
|
2150
2545
|
}
|
|
2151
2546
|
} catch (err) {
|
|
2152
|
-
const normalizedError =
|
|
2547
|
+
const normalizedError = normalizeError2(err instanceof Error ? err : new Error(String(err)));
|
|
2153
2548
|
setError(normalizedError);
|
|
2154
2549
|
const action = RECOVERY_ACTIONS[normalizedError.code];
|
|
2155
2550
|
if (action) {
|
|
@@ -2169,7 +2564,7 @@ function Bridge({ options }) {
|
|
|
2169
2564
|
setState("executing");
|
|
2170
2565
|
setStepState((prev) => ({ ...prev, approval: "active" }));
|
|
2171
2566
|
const signer = await createSigner(privateKey, chain.id);
|
|
2172
|
-
const mina = new
|
|
2567
|
+
const mina = new Mina4({
|
|
2173
2568
|
integrator: "mina-cli",
|
|
2174
2569
|
autoDeposit: options.autoDeposit !== false
|
|
2175
2570
|
});
|
|
@@ -2216,7 +2611,7 @@ function Bridge({ options }) {
|
|
|
2216
2611
|
setState("failed");
|
|
2217
2612
|
}
|
|
2218
2613
|
} catch (err) {
|
|
2219
|
-
const normalizedError =
|
|
2614
|
+
const normalizedError = normalizeError2(err instanceof Error ? err : new Error(String(err)));
|
|
2220
2615
|
setError(normalizedError);
|
|
2221
2616
|
const action = RECOVERY_ACTIONS[normalizedError.code];
|
|
2222
2617
|
if (action) {
|
|
@@ -2225,9 +2620,9 @@ function Bridge({ options }) {
|
|
|
2225
2620
|
setState("failed");
|
|
2226
2621
|
}
|
|
2227
2622
|
}, [quote, chain, token, privateKey, walletAddress, options.autoDeposit]);
|
|
2228
|
-
return /* @__PURE__ */
|
|
2229
|
-
/* @__PURE__ */
|
|
2230
|
-
/* @__PURE__ */
|
|
2623
|
+
return /* @__PURE__ */ jsxs13(Box13, { flexDirection: "column", padding: 1, children: [
|
|
2624
|
+
/* @__PURE__ */ jsx13(Header, { compact: true, showTagline: false }),
|
|
2625
|
+
/* @__PURE__ */ jsx13(Box13, { marginBottom: 1, children: /* @__PURE__ */ jsxs13(Text13, { color: theme.primary, bold: true, children: [
|
|
2231
2626
|
"Bridge ",
|
|
2232
2627
|
options.amount,
|
|
2233
2628
|
" ",
|
|
@@ -2235,15 +2630,15 @@ function Bridge({ options }) {
|
|
|
2235
2630
|
" from ",
|
|
2236
2631
|
options.from
|
|
2237
2632
|
] }) }),
|
|
2238
|
-
walletAddress && /* @__PURE__ */
|
|
2633
|
+
walletAddress && /* @__PURE__ */ jsx13(Box13, { marginBottom: 1, children: /* @__PURE__ */ jsxs13(Text13, { color: theme.muted, dimColor: true, children: [
|
|
2239
2634
|
"Wallet: ",
|
|
2240
2635
|
walletAddress.slice(0, 8),
|
|
2241
2636
|
"...",
|
|
2242
2637
|
walletAddress.slice(-6)
|
|
2243
2638
|
] }) }),
|
|
2244
|
-
state === "loading" && /* @__PURE__ */
|
|
2245
|
-
state === "confirming" && quote && chain && token && /* @__PURE__ */
|
|
2246
|
-
/* @__PURE__ */
|
|
2639
|
+
state === "loading" && /* @__PURE__ */ jsx13(Box13, { flexDirection: "column", children: /* @__PURE__ */ jsx13(BridgeProgressDisplay, { stepState }) }),
|
|
2640
|
+
state === "confirming" && quote && chain && token && /* @__PURE__ */ jsxs13(Box13, { flexDirection: "column", children: [
|
|
2641
|
+
/* @__PURE__ */ jsx13(
|
|
2247
2642
|
QuoteDisplay2,
|
|
2248
2643
|
{
|
|
2249
2644
|
quote,
|
|
@@ -2252,22 +2647,22 @@ function Bridge({ options }) {
|
|
|
2252
2647
|
amount: options.amount
|
|
2253
2648
|
}
|
|
2254
2649
|
),
|
|
2255
|
-
!options.yes && /* @__PURE__ */
|
|
2650
|
+
!options.yes && /* @__PURE__ */ jsx13(Box13, { marginTop: 1, children: /* @__PURE__ */ jsxs13(Text13, { color: theme.warning, bold: true, children: [
|
|
2256
2651
|
symbols.arrow,
|
|
2257
2652
|
" Proceed with bridge? (y/n)"
|
|
2258
2653
|
] }) }),
|
|
2259
|
-
options.yes && /* @__PURE__ */
|
|
2654
|
+
options.yes && /* @__PURE__ */ jsx13(Box13, { marginTop: 1, children: /* @__PURE__ */ jsx13(Spinner, { text: "Auto-confirming..." }) })
|
|
2260
2655
|
] }),
|
|
2261
|
-
state === "executing" && /* @__PURE__ */
|
|
2656
|
+
state === "executing" && /* @__PURE__ */ jsx13(Box13, { flexDirection: "column", children: /* @__PURE__ */ jsx13(
|
|
2262
2657
|
BridgeProgressDisplay,
|
|
2263
2658
|
{
|
|
2264
2659
|
stepState,
|
|
2265
2660
|
currentStepDescription
|
|
2266
2661
|
}
|
|
2267
2662
|
) }),
|
|
2268
|
-
state === "completed" && result && chain && token && /* @__PURE__ */
|
|
2269
|
-
/* @__PURE__ */
|
|
2270
|
-
/* @__PURE__ */
|
|
2663
|
+
state === "completed" && result && chain && token && /* @__PURE__ */ jsxs13(Box13, { flexDirection: "column", children: [
|
|
2664
|
+
/* @__PURE__ */ jsx13(BridgeProgressDisplay, { stepState }),
|
|
2665
|
+
/* @__PURE__ */ jsx13(
|
|
2271
2666
|
SuccessDisplay,
|
|
2272
2667
|
{
|
|
2273
2668
|
result,
|
|
@@ -2276,24 +2671,24 @@ function Bridge({ options }) {
|
|
|
2276
2671
|
amount: options.amount
|
|
2277
2672
|
}
|
|
2278
2673
|
),
|
|
2279
|
-
/* @__PURE__ */
|
|
2674
|
+
/* @__PURE__ */ jsx13(Box13, { marginTop: 1, children: /* @__PURE__ */ jsx13(Text13, { color: theme.muted, dimColor: true, children: "Press Enter or q to exit" }) })
|
|
2280
2675
|
] }),
|
|
2281
|
-
state === "failed" && error && /* @__PURE__ */
|
|
2282
|
-
/* @__PURE__ */
|
|
2283
|
-
/* @__PURE__ */
|
|
2284
|
-
/* @__PURE__ */
|
|
2676
|
+
state === "failed" && error && /* @__PURE__ */ jsxs13(Box13, { flexDirection: "column", children: [
|
|
2677
|
+
/* @__PURE__ */ jsx13(BridgeProgressDisplay, { stepState, error: error.message }),
|
|
2678
|
+
/* @__PURE__ */ jsx13(ErrorDisplay2, { error, recoveryAction: recoveryAction || void 0 }),
|
|
2679
|
+
/* @__PURE__ */ jsx13(Box13, { marginTop: 1, children: /* @__PURE__ */ jsx13(Text13, { color: theme.muted, dimColor: true, children: "Press Enter or q to exit" }) })
|
|
2285
2680
|
] })
|
|
2286
2681
|
] });
|
|
2287
2682
|
}
|
|
2288
2683
|
async function bridgeCommand(options) {
|
|
2289
2684
|
const { render: render2 } = await import("ink");
|
|
2290
|
-
const
|
|
2291
|
-
render2(
|
|
2685
|
+
const React13 = await import("react");
|
|
2686
|
+
render2(React13.createElement(Bridge, { options }));
|
|
2292
2687
|
}
|
|
2293
2688
|
|
|
2294
2689
|
// src/commands/history.tsx
|
|
2295
|
-
import { useState as
|
|
2296
|
-
import { Box as
|
|
2690
|
+
import { useState as useState8, useEffect as useEffect8 } from "react";
|
|
2691
|
+
import { Box as Box14, Text as Text14, useApp as useApp7 } from "ink";
|
|
2297
2692
|
|
|
2298
2693
|
// src/lib/history.ts
|
|
2299
2694
|
import os from "os";
|
|
@@ -2326,7 +2721,7 @@ function getHistory(limit = 10, address) {
|
|
|
2326
2721
|
}
|
|
2327
2722
|
|
|
2328
2723
|
// src/commands/history.tsx
|
|
2329
|
-
import { Fragment, jsx as
|
|
2724
|
+
import { Fragment, jsx as jsx14, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2330
2725
|
function formatDate(timestamp) {
|
|
2331
2726
|
return new Date(timestamp).toLocaleString("en-US", {
|
|
2332
2727
|
month: "2-digit",
|
|
@@ -2366,19 +2761,19 @@ function transformToRows(entries) {
|
|
|
2366
2761
|
});
|
|
2367
2762
|
}
|
|
2368
2763
|
function EmptyState({ address }) {
|
|
2369
|
-
return /* @__PURE__ */
|
|
2370
|
-
|
|
2764
|
+
return /* @__PURE__ */ jsx14(Box14, { flexDirection: "column", children: /* @__PURE__ */ jsx14(
|
|
2765
|
+
Box14,
|
|
2371
2766
|
{
|
|
2372
2767
|
borderStyle: "round",
|
|
2373
2768
|
borderColor: theme.border,
|
|
2374
2769
|
paddingX: 2,
|
|
2375
2770
|
paddingY: 1,
|
|
2376
|
-
children: /* @__PURE__ */
|
|
2377
|
-
/* @__PURE__ */
|
|
2771
|
+
children: /* @__PURE__ */ jsxs14(Box14, { flexDirection: "column", children: [
|
|
2772
|
+
/* @__PURE__ */ jsxs14(Text14, { color: theme.muted, children: [
|
|
2378
2773
|
symbols.pending,
|
|
2379
2774
|
" No bridge history found"
|
|
2380
2775
|
] }),
|
|
2381
|
-
/* @__PURE__ */
|
|
2776
|
+
/* @__PURE__ */ jsx14(Box14, { marginTop: 1, children: /* @__PURE__ */ jsx14(Text14, { color: theme.muted, dimColor: true, children: address ? `No transactions found for address ${truncateHash2(address)}` : "Start by running a bridge transaction with: mina bridge --from <chain> --token USDC --amount 100" }) })
|
|
2382
2777
|
] })
|
|
2383
2778
|
}
|
|
2384
2779
|
) });
|
|
@@ -2389,14 +2784,14 @@ function HistoryCommand({
|
|
|
2389
2784
|
json = false
|
|
2390
2785
|
}) {
|
|
2391
2786
|
const { exit } = useApp7();
|
|
2392
|
-
const [entries, setEntries] =
|
|
2393
|
-
const [loading, setLoading] =
|
|
2394
|
-
|
|
2787
|
+
const [entries, setEntries] = useState8([]);
|
|
2788
|
+
const [loading, setLoading] = useState8(true);
|
|
2789
|
+
useEffect8(() => {
|
|
2395
2790
|
const history = getHistory(limit, address);
|
|
2396
2791
|
setEntries(history);
|
|
2397
2792
|
setLoading(false);
|
|
2398
2793
|
}, [limit, address]);
|
|
2399
|
-
|
|
2794
|
+
useEffect8(() => {
|
|
2400
2795
|
if (!loading && json) {
|
|
2401
2796
|
setTimeout(() => exit(), 100);
|
|
2402
2797
|
}
|
|
@@ -2407,9 +2802,9 @@ function HistoryCommand({
|
|
|
2407
2802
|
return null;
|
|
2408
2803
|
}
|
|
2409
2804
|
if (loading) {
|
|
2410
|
-
return /* @__PURE__ */
|
|
2411
|
-
/* @__PURE__ */
|
|
2412
|
-
/* @__PURE__ */
|
|
2805
|
+
return /* @__PURE__ */ jsxs14(Box14, { flexDirection: "column", padding: 1, children: [
|
|
2806
|
+
/* @__PURE__ */ jsx14(Header, { compact: true, showTagline: false }),
|
|
2807
|
+
/* @__PURE__ */ jsx14(Text14, { color: theme.muted, children: "Loading history..." })
|
|
2413
2808
|
] });
|
|
2414
2809
|
}
|
|
2415
2810
|
const rows = transformToRows(entries);
|
|
@@ -2440,25 +2835,25 @@ function HistoryCommand({
|
|
|
2440
2835
|
cellColor: (_, row) => row.statusColor
|
|
2441
2836
|
}
|
|
2442
2837
|
];
|
|
2443
|
-
return /* @__PURE__ */
|
|
2444
|
-
/* @__PURE__ */
|
|
2445
|
-
/* @__PURE__ */
|
|
2838
|
+
return /* @__PURE__ */ jsxs14(Box14, { flexDirection: "column", padding: 1, children: [
|
|
2839
|
+
/* @__PURE__ */ jsx14(Header, { compact: true, showTagline: false }),
|
|
2840
|
+
/* @__PURE__ */ jsx14(Box14, { marginBottom: 1, children: /* @__PURE__ */ jsxs14(Text14, { color: theme.secondary, children: [
|
|
2446
2841
|
symbols.arrow,
|
|
2447
2842
|
" Bridge History",
|
|
2448
|
-
address && /* @__PURE__ */
|
|
2843
|
+
address && /* @__PURE__ */ jsxs14(Text14, { color: theme.muted, children: [
|
|
2449
2844
|
" (",
|
|
2450
2845
|
truncateHash2(address),
|
|
2451
2846
|
")"
|
|
2452
2847
|
] }),
|
|
2453
|
-
entries.length > 0 && /* @__PURE__ */
|
|
2848
|
+
entries.length > 0 && /* @__PURE__ */ jsxs14(Text14, { color: theme.muted, children: [
|
|
2454
2849
|
" - ",
|
|
2455
2850
|
entries.length,
|
|
2456
2851
|
" transaction",
|
|
2457
2852
|
entries.length !== 1 ? "s" : ""
|
|
2458
2853
|
] })
|
|
2459
2854
|
] }) }),
|
|
2460
|
-
entries.length === 0 ? /* @__PURE__ */
|
|
2461
|
-
/* @__PURE__ */
|
|
2855
|
+
entries.length === 0 ? /* @__PURE__ */ jsx14(EmptyState, { address }) : /* @__PURE__ */ jsxs14(Fragment, { children: [
|
|
2856
|
+
/* @__PURE__ */ jsx14(
|
|
2462
2857
|
Table,
|
|
2463
2858
|
{
|
|
2464
2859
|
data: rows,
|
|
@@ -2467,8 +2862,8 @@ function HistoryCommand({
|
|
|
2467
2862
|
borderColor: theme.border
|
|
2468
2863
|
}
|
|
2469
2864
|
),
|
|
2470
|
-
/* @__PURE__ */
|
|
2471
|
-
/* @__PURE__ */
|
|
2865
|
+
/* @__PURE__ */ jsxs14(Box14, { marginTop: 1, flexDirection: "column", children: [
|
|
2866
|
+
/* @__PURE__ */ jsxs14(Text14, { color: theme.muted, dimColor: true, children: [
|
|
2472
2867
|
"Use ",
|
|
2473
2868
|
'"',
|
|
2474
2869
|
"mina status ",
|
|
@@ -2477,7 +2872,7 @@ function HistoryCommand({
|
|
|
2477
2872
|
'>"',
|
|
2478
2873
|
" for full transaction details"
|
|
2479
2874
|
] }),
|
|
2480
|
-
entries.length >= limit && /* @__PURE__ */
|
|
2875
|
+
entries.length >= limit && /* @__PURE__ */ jsxs14(Text14, { color: theme.muted, dimColor: true, children: [
|
|
2481
2876
|
"Showing last ",
|
|
2482
2877
|
limit,
|
|
2483
2878
|
" entries. Use --limit to see more."
|
|
@@ -2488,13 +2883,13 @@ function HistoryCommand({
|
|
|
2488
2883
|
}
|
|
2489
2884
|
|
|
2490
2885
|
// src/commands/balance.tsx
|
|
2491
|
-
import
|
|
2492
|
-
import { Box as
|
|
2886
|
+
import React10, { useState as useState9, useEffect as useEffect9 } from "react";
|
|
2887
|
+
import { Box as Box15, Text as Text15, useApp as useApp8 } from "ink";
|
|
2493
2888
|
import {
|
|
2494
|
-
Mina as
|
|
2889
|
+
Mina as Mina5,
|
|
2495
2890
|
getChains as getChains6
|
|
2496
2891
|
} from "@siphoyawe/mina-sdk";
|
|
2497
|
-
import { Fragment as Fragment2, jsx as
|
|
2892
|
+
import { Fragment as Fragment2, jsx as jsx15, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
2498
2893
|
function truncateAddress2(address) {
|
|
2499
2894
|
if (address.length <= 14) return address;
|
|
2500
2895
|
return `${address.slice(0, 6)}...${address.slice(-4)}`;
|
|
@@ -2555,16 +2950,16 @@ function BalanceCommand({
|
|
|
2555
2950
|
json = false
|
|
2556
2951
|
}) {
|
|
2557
2952
|
const { exit } = useApp8();
|
|
2558
|
-
const [chainBalances, setChainBalances] =
|
|
2559
|
-
const [loading, setLoading] =
|
|
2560
|
-
const [error, setError] =
|
|
2561
|
-
const [totalUsd, setTotalUsd] =
|
|
2562
|
-
|
|
2953
|
+
const [chainBalances, setChainBalances] = useState9([]);
|
|
2954
|
+
const [loading, setLoading] = useState9(true);
|
|
2955
|
+
const [error, setError] = useState9(null);
|
|
2956
|
+
const [totalUsd, setTotalUsd] = useState9(0);
|
|
2957
|
+
useEffect9(() => {
|
|
2563
2958
|
async function loadBalances() {
|
|
2564
2959
|
try {
|
|
2565
2960
|
setLoading(true);
|
|
2566
2961
|
setError(null);
|
|
2567
|
-
const mina = new
|
|
2962
|
+
const mina = new Mina5({ integrator: "mina-cli" });
|
|
2568
2963
|
let chainIds = [];
|
|
2569
2964
|
let chainNameMap = {};
|
|
2570
2965
|
if (chain) {
|
|
@@ -2637,7 +3032,7 @@ function BalanceCommand({
|
|
|
2637
3032
|
}
|
|
2638
3033
|
loadBalances();
|
|
2639
3034
|
}, [address, chain, showAll]);
|
|
2640
|
-
|
|
3035
|
+
useEffect9(() => {
|
|
2641
3036
|
if (!loading && json) {
|
|
2642
3037
|
setTimeout(() => exit(), 100);
|
|
2643
3038
|
}
|
|
@@ -2661,15 +3056,15 @@ function BalanceCommand({
|
|
|
2661
3056
|
return null;
|
|
2662
3057
|
}
|
|
2663
3058
|
if (loading) {
|
|
2664
|
-
return /* @__PURE__ */
|
|
2665
|
-
/* @__PURE__ */
|
|
2666
|
-
/* @__PURE__ */
|
|
3059
|
+
return /* @__PURE__ */ jsxs15(Box15, { flexDirection: "column", padding: 1, children: [
|
|
3060
|
+
/* @__PURE__ */ jsx15(Header, { compact: true, showTagline: false }),
|
|
3061
|
+
/* @__PURE__ */ jsx15(Spinner, { text: chain ? `Loading balances on ${chain}...` : "Loading balances across chains..." })
|
|
2667
3062
|
] });
|
|
2668
3063
|
}
|
|
2669
3064
|
if (error) {
|
|
2670
|
-
return /* @__PURE__ */
|
|
2671
|
-
/* @__PURE__ */
|
|
2672
|
-
/* @__PURE__ */
|
|
3065
|
+
return /* @__PURE__ */ jsxs15(Box15, { flexDirection: "column", padding: 1, children: [
|
|
3066
|
+
/* @__PURE__ */ jsx15(Header, { compact: true, showTagline: false }),
|
|
3067
|
+
/* @__PURE__ */ jsx15(Box15, { children: /* @__PURE__ */ jsxs15(Text15, { color: theme.error, children: [
|
|
2673
3068
|
symbols.failed,
|
|
2674
3069
|
" Error: ",
|
|
2675
3070
|
error
|
|
@@ -2686,105 +3081,105 @@ function BalanceCommand({
|
|
|
2686
3081
|
);
|
|
2687
3082
|
const boxWidth = Math.max(40, maxSymbolWidth + maxBalanceWidth + 20);
|
|
2688
3083
|
const hasAnyBalances = chainBalances.some((cb) => cb.balances.length > 0);
|
|
2689
|
-
return /* @__PURE__ */
|
|
2690
|
-
/* @__PURE__ */
|
|
2691
|
-
/* @__PURE__ */
|
|
3084
|
+
return /* @__PURE__ */ jsxs15(Box15, { flexDirection: "column", padding: 1, children: [
|
|
3085
|
+
/* @__PURE__ */ jsx15(Header, { compact: true, showTagline: false }),
|
|
3086
|
+
/* @__PURE__ */ jsx15(Box15, { children: /* @__PURE__ */ jsxs15(Text15, { color: theme.border, children: [
|
|
2692
3087
|
borders.topLeft,
|
|
2693
3088
|
borders.horizontal.repeat(boxWidth - 2),
|
|
2694
3089
|
borders.topRight
|
|
2695
3090
|
] }) }),
|
|
2696
|
-
/* @__PURE__ */
|
|
2697
|
-
/* @__PURE__ */
|
|
2698
|
-
/* @__PURE__ */
|
|
3091
|
+
/* @__PURE__ */ jsxs15(Box15, { children: [
|
|
3092
|
+
/* @__PURE__ */ jsx15(Text15, { color: theme.border, children: borders.vertical }),
|
|
3093
|
+
/* @__PURE__ */ jsx15(Box15, { width: boxWidth - 2, justifyContent: "center", children: /* @__PURE__ */ jsxs15(Text15, { color: theme.primary, bold: true, children: [
|
|
2699
3094
|
"Balances: ",
|
|
2700
3095
|
truncateAddress2(address)
|
|
2701
3096
|
] }) }),
|
|
2702
|
-
/* @__PURE__ */
|
|
3097
|
+
/* @__PURE__ */ jsx15(Text15, { color: theme.border, children: borders.vertical })
|
|
2703
3098
|
] }),
|
|
2704
|
-
/* @__PURE__ */
|
|
3099
|
+
/* @__PURE__ */ jsx15(Box15, { children: /* @__PURE__ */ jsxs15(Text15, { color: theme.border, children: [
|
|
2705
3100
|
borders.leftT,
|
|
2706
3101
|
borders.horizontal.repeat(boxWidth - 2),
|
|
2707
3102
|
borders.rightT
|
|
2708
3103
|
] }) }),
|
|
2709
|
-
!hasAnyBalances ? /* @__PURE__ */
|
|
2710
|
-
/* @__PURE__ */
|
|
2711
|
-
/* @__PURE__ */
|
|
2712
|
-
/* @__PURE__ */
|
|
2713
|
-
] }) }) : chainBalances.map((chainData, chainIndex) => /* @__PURE__ */
|
|
2714
|
-
/* @__PURE__ */
|
|
2715
|
-
/* @__PURE__ */
|
|
2716
|
-
/* @__PURE__ */
|
|
2717
|
-
/* @__PURE__ */
|
|
2718
|
-
/* @__PURE__ */
|
|
2719
|
-
/* @__PURE__ */
|
|
3104
|
+
!hasAnyBalances ? /* @__PURE__ */ jsx15(Fragment2, { children: /* @__PURE__ */ jsxs15(Box15, { children: [
|
|
3105
|
+
/* @__PURE__ */ jsx15(Text15, { color: theme.border, children: borders.vertical }),
|
|
3106
|
+
/* @__PURE__ */ jsx15(Box15, { width: boxWidth - 2, justifyContent: "center", children: /* @__PURE__ */ jsx15(Text15, { color: theme.muted, children: "No balances found" }) }),
|
|
3107
|
+
/* @__PURE__ */ jsx15(Text15, { color: theme.border, children: borders.vertical })
|
|
3108
|
+
] }) }) : chainBalances.map((chainData, chainIndex) => /* @__PURE__ */ jsxs15(React10.Fragment, { children: [
|
|
3109
|
+
/* @__PURE__ */ jsxs15(Box15, { children: [
|
|
3110
|
+
/* @__PURE__ */ jsx15(Text15, { color: theme.border, children: borders.vertical }),
|
|
3111
|
+
/* @__PURE__ */ jsx15(Text15, { children: " " }),
|
|
3112
|
+
/* @__PURE__ */ jsx15(Text15, { color: theme.accent, bold: true, children: chainData.chainName }),
|
|
3113
|
+
/* @__PURE__ */ jsx15(Box15, { flexGrow: 1 }),
|
|
3114
|
+
/* @__PURE__ */ jsx15(Text15, { color: theme.border, children: borders.vertical })
|
|
2720
3115
|
] }),
|
|
2721
|
-
chainData.balances.length === 0 ? /* @__PURE__ */
|
|
2722
|
-
/* @__PURE__ */
|
|
2723
|
-
/* @__PURE__ */
|
|
2724
|
-
/* @__PURE__ */
|
|
2725
|
-
/* @__PURE__ */
|
|
2726
|
-
/* @__PURE__ */
|
|
2727
|
-
] }) : chainData.balances.map((balance, i) => /* @__PURE__ */
|
|
2728
|
-
/* @__PURE__ */
|
|
2729
|
-
/* @__PURE__ */
|
|
2730
|
-
/* @__PURE__ */
|
|
2731
|
-
|
|
3116
|
+
chainData.balances.length === 0 ? /* @__PURE__ */ jsxs15(Box15, { children: [
|
|
3117
|
+
/* @__PURE__ */ jsx15(Text15, { color: theme.border, children: borders.vertical }),
|
|
3118
|
+
/* @__PURE__ */ jsx15(Text15, { children: " " }),
|
|
3119
|
+
/* @__PURE__ */ jsx15(Text15, { color: theme.muted, dimColor: true, children: "No balances" }),
|
|
3120
|
+
/* @__PURE__ */ jsx15(Box15, { flexGrow: 1 }),
|
|
3121
|
+
/* @__PURE__ */ jsx15(Text15, { color: theme.border, children: borders.vertical })
|
|
3122
|
+
] }) : chainData.balances.map((balance, i) => /* @__PURE__ */ jsxs15(Box15, { children: [
|
|
3123
|
+
/* @__PURE__ */ jsx15(Text15, { color: theme.border, children: borders.vertical }),
|
|
3124
|
+
/* @__PURE__ */ jsx15(Text15, { children: " " }),
|
|
3125
|
+
/* @__PURE__ */ jsx15(
|
|
3126
|
+
Text15,
|
|
2732
3127
|
{
|
|
2733
3128
|
color: balance.hasBalance ? theme.success : theme.muted,
|
|
2734
3129
|
dimColor: !balance.hasBalance,
|
|
2735
3130
|
children: balance.symbol.padEnd(maxSymbolWidth)
|
|
2736
3131
|
}
|
|
2737
3132
|
),
|
|
2738
|
-
/* @__PURE__ */
|
|
2739
|
-
/* @__PURE__ */
|
|
2740
|
-
|
|
3133
|
+
/* @__PURE__ */ jsx15(Text15, { children: " " }),
|
|
3134
|
+
/* @__PURE__ */ jsx15(
|
|
3135
|
+
Text15,
|
|
2741
3136
|
{
|
|
2742
3137
|
color: balance.hasBalance ? theme.secondary : theme.muted,
|
|
2743
3138
|
dimColor: !balance.hasBalance,
|
|
2744
3139
|
children: balance.balanceFormatted.padStart(maxBalanceWidth)
|
|
2745
3140
|
}
|
|
2746
3141
|
),
|
|
2747
|
-
/* @__PURE__ */
|
|
2748
|
-
/* @__PURE__ */
|
|
2749
|
-
|
|
3142
|
+
/* @__PURE__ */ jsx15(Text15, { children: " " }),
|
|
3143
|
+
/* @__PURE__ */ jsx15(
|
|
3144
|
+
Text15,
|
|
2750
3145
|
{
|
|
2751
3146
|
color: balance.hasBalance ? theme.muted : theme.muted,
|
|
2752
3147
|
dimColor: !balance.hasBalance,
|
|
2753
3148
|
children: formatUsd2(balance.usdValue).padStart(12)
|
|
2754
3149
|
}
|
|
2755
3150
|
),
|
|
2756
|
-
/* @__PURE__ */
|
|
2757
|
-
/* @__PURE__ */
|
|
3151
|
+
/* @__PURE__ */ jsx15(Box15, { flexGrow: 1 }),
|
|
3152
|
+
/* @__PURE__ */ jsx15(Text15, { color: theme.border, children: borders.vertical })
|
|
2758
3153
|
] }, `${chainData.chainId}-${balance.symbol}-${i}`)),
|
|
2759
|
-
chainIndex < chainBalances.length - 1 && /* @__PURE__ */
|
|
3154
|
+
chainIndex < chainBalances.length - 1 && /* @__PURE__ */ jsx15(Box15, { children: /* @__PURE__ */ jsxs15(Text15, { color: theme.border, children: [
|
|
2760
3155
|
borders.leftT,
|
|
2761
3156
|
borders.horizontal.repeat(boxWidth - 2),
|
|
2762
3157
|
borders.rightT
|
|
2763
3158
|
] }) })
|
|
2764
3159
|
] }, chainData.chainId)),
|
|
2765
|
-
/* @__PURE__ */
|
|
3160
|
+
/* @__PURE__ */ jsx15(Box15, { children: /* @__PURE__ */ jsxs15(Text15, { color: theme.border, children: [
|
|
2766
3161
|
borders.bottomLeft,
|
|
2767
3162
|
borders.horizontal.repeat(boxWidth - 2),
|
|
2768
3163
|
borders.bottomRight
|
|
2769
3164
|
] }) }),
|
|
2770
|
-
hasAnyBalances && totalUsd > 0 && /* @__PURE__ */
|
|
2771
|
-
/* @__PURE__ */
|
|
3165
|
+
hasAnyBalances && totalUsd > 0 && /* @__PURE__ */ jsxs15(Box15, { marginTop: 1, children: [
|
|
3166
|
+
/* @__PURE__ */ jsxs15(Text15, { color: theme.secondary, children: [
|
|
2772
3167
|
symbols.arrow,
|
|
2773
3168
|
" Total:"
|
|
2774
3169
|
] }),
|
|
2775
|
-
/* @__PURE__ */
|
|
3170
|
+
/* @__PURE__ */ jsxs15(Text15, { color: theme.success, bold: true, children: [
|
|
2776
3171
|
" ",
|
|
2777
3172
|
"$",
|
|
2778
3173
|
formatNumber(totalUsd, 2)
|
|
2779
3174
|
] })
|
|
2780
3175
|
] }),
|
|
2781
|
-
/* @__PURE__ */
|
|
3176
|
+
/* @__PURE__ */ jsx15(Box15, { marginTop: 1, children: /* @__PURE__ */ jsx15(Text15, { color: theme.muted, dimColor: true, children: chain ? "Use --all to show zero balances" : "Use --chain <name> for specific chain, --all for zero balances" }) })
|
|
2782
3177
|
] });
|
|
2783
3178
|
}
|
|
2784
3179
|
|
|
2785
3180
|
// src/commands/config.tsx
|
|
2786
|
-
import { useState as
|
|
2787
|
-
import { Box as
|
|
3181
|
+
import { useState as useState10, useEffect as useEffect10 } from "react";
|
|
3182
|
+
import { Box as Box16, Text as Text16, useApp as useApp9 } from "ink";
|
|
2788
3183
|
|
|
2789
3184
|
// src/lib/config.ts
|
|
2790
3185
|
import os2 from "os";
|
|
@@ -2905,11 +3300,11 @@ function getConfigPath() {
|
|
|
2905
3300
|
}
|
|
2906
3301
|
|
|
2907
3302
|
// src/commands/config.tsx
|
|
2908
|
-
import { jsx as
|
|
3303
|
+
import { jsx as jsx16, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2909
3304
|
function ConfigList() {
|
|
2910
3305
|
const { exit } = useApp9();
|
|
2911
|
-
const [items, setItems] =
|
|
2912
|
-
|
|
3306
|
+
const [items, setItems] = useState10([]);
|
|
3307
|
+
useEffect10(() => {
|
|
2913
3308
|
const configItems = getConfigList();
|
|
2914
3309
|
setItems(
|
|
2915
3310
|
configItems.map((item) => ({
|
|
@@ -2934,21 +3329,21 @@ function ConfigList() {
|
|
|
2934
3329
|
cellColor: (value, row) => row.isDefault ? theme.muted : theme.success
|
|
2935
3330
|
}
|
|
2936
3331
|
];
|
|
2937
|
-
return /* @__PURE__ */
|
|
2938
|
-
/* @__PURE__ */
|
|
2939
|
-
/* @__PURE__ */
|
|
3332
|
+
return /* @__PURE__ */ jsxs16(Box16, { flexDirection: "column", padding: 1, children: [
|
|
3333
|
+
/* @__PURE__ */ jsx16(Header, { compact: true, showTagline: false }),
|
|
3334
|
+
/* @__PURE__ */ jsx16(Box16, { marginBottom: 1, children: /* @__PURE__ */ jsxs16(Text16, { color: theme.secondary, children: [
|
|
2940
3335
|
symbols.arrow,
|
|
2941
3336
|
" Configuration Settings"
|
|
2942
3337
|
] }) }),
|
|
2943
|
-
/* @__PURE__ */
|
|
2944
|
-
/* @__PURE__ */
|
|
3338
|
+
/* @__PURE__ */ jsx16(Table, { data: items, columns, bordered: true, borderColor: theme.border }),
|
|
3339
|
+
/* @__PURE__ */ jsx16(Box16, { marginTop: 1, children: /* @__PURE__ */ jsx16(Text16, { color: theme.muted, dimColor: true, children: "Values in gray are defaults. Use 'mina config set <key> <value>' to customize." }) })
|
|
2945
3340
|
] });
|
|
2946
3341
|
}
|
|
2947
3342
|
function ConfigGet({ configKey }) {
|
|
2948
3343
|
const { exit } = useApp9();
|
|
2949
|
-
const [value, setValue] =
|
|
2950
|
-
const [error, setError] =
|
|
2951
|
-
|
|
3344
|
+
const [value, setValue] = useState10(null);
|
|
3345
|
+
const [error, setError] = useState10(null);
|
|
3346
|
+
useEffect10(() => {
|
|
2952
3347
|
if (!isValidKey(configKey)) {
|
|
2953
3348
|
setError(`Unknown config key: ${configKey}`);
|
|
2954
3349
|
} else {
|
|
@@ -2958,30 +3353,30 @@ function ConfigGet({ configKey }) {
|
|
|
2958
3353
|
setTimeout(() => exit(), 100);
|
|
2959
3354
|
}, [configKey, exit]);
|
|
2960
3355
|
if (error) {
|
|
2961
|
-
return /* @__PURE__ */
|
|
2962
|
-
/* @__PURE__ */
|
|
2963
|
-
/* @__PURE__ */
|
|
3356
|
+
return /* @__PURE__ */ jsxs16(Box16, { flexDirection: "column", padding: 1, children: [
|
|
3357
|
+
/* @__PURE__ */ jsx16(Header, { compact: true, showTagline: false }),
|
|
3358
|
+
/* @__PURE__ */ jsx16(Box16, { children: /* @__PURE__ */ jsxs16(Text16, { color: theme.error, children: [
|
|
2964
3359
|
symbols.failed,
|
|
2965
3360
|
" ",
|
|
2966
3361
|
error
|
|
2967
3362
|
] }) })
|
|
2968
3363
|
] });
|
|
2969
3364
|
}
|
|
2970
|
-
return /* @__PURE__ */
|
|
2971
|
-
/* @__PURE__ */
|
|
2972
|
-
/* @__PURE__ */
|
|
2973
|
-
/* @__PURE__ */
|
|
2974
|
-
/* @__PURE__ */
|
|
2975
|
-
/* @__PURE__ */
|
|
3365
|
+
return /* @__PURE__ */ jsxs16(Box16, { flexDirection: "column", padding: 1, children: [
|
|
3366
|
+
/* @__PURE__ */ jsx16(Header, { compact: true, showTagline: false }),
|
|
3367
|
+
/* @__PURE__ */ jsxs16(Box16, { children: [
|
|
3368
|
+
/* @__PURE__ */ jsx16(Text16, { color: theme.secondary, children: configKey }),
|
|
3369
|
+
/* @__PURE__ */ jsx16(Text16, { color: theme.muted, children: " = " }),
|
|
3370
|
+
/* @__PURE__ */ jsx16(Text16, { color: theme.primary, children: value })
|
|
2976
3371
|
] })
|
|
2977
3372
|
] });
|
|
2978
3373
|
}
|
|
2979
3374
|
function ConfigSet({ configKey, configValue }) {
|
|
2980
3375
|
const { exit } = useApp9();
|
|
2981
|
-
const [success, setSuccess] =
|
|
2982
|
-
const [error, setError] =
|
|
2983
|
-
const [parsedValue, setParsedValue] =
|
|
2984
|
-
|
|
3376
|
+
const [success, setSuccess] = useState10(false);
|
|
3377
|
+
const [error, setError] = useState10(null);
|
|
3378
|
+
const [parsedValue, setParsedValue] = useState10(null);
|
|
3379
|
+
useEffect10(() => {
|
|
2985
3380
|
if (!isValidKey(configKey)) {
|
|
2986
3381
|
setError(`Unknown config key: ${configKey}`);
|
|
2987
3382
|
} else {
|
|
@@ -2997,9 +3392,9 @@ function ConfigSet({ configKey, configValue }) {
|
|
|
2997
3392
|
setTimeout(() => exit(), 100);
|
|
2998
3393
|
}, [configKey, configValue, exit]);
|
|
2999
3394
|
if (error) {
|
|
3000
|
-
return /* @__PURE__ */
|
|
3001
|
-
/* @__PURE__ */
|
|
3002
|
-
/* @__PURE__ */
|
|
3395
|
+
return /* @__PURE__ */ jsxs16(Box16, { flexDirection: "column", padding: 1, children: [
|
|
3396
|
+
/* @__PURE__ */ jsx16(Header, { compact: true, showTagline: false }),
|
|
3397
|
+
/* @__PURE__ */ jsx16(Box16, { children: /* @__PURE__ */ jsxs16(Text16, { color: theme.error, children: [
|
|
3003
3398
|
symbols.failed,
|
|
3004
3399
|
" ",
|
|
3005
3400
|
error
|
|
@@ -3007,17 +3402,17 @@ function ConfigSet({ configKey, configValue }) {
|
|
|
3007
3402
|
] });
|
|
3008
3403
|
}
|
|
3009
3404
|
if (success) {
|
|
3010
|
-
return /* @__PURE__ */
|
|
3011
|
-
/* @__PURE__ */
|
|
3012
|
-
/* @__PURE__ */
|
|
3013
|
-
/* @__PURE__ */
|
|
3405
|
+
return /* @__PURE__ */ jsxs16(Box16, { flexDirection: "column", padding: 1, children: [
|
|
3406
|
+
/* @__PURE__ */ jsx16(Header, { compact: true, showTagline: false }),
|
|
3407
|
+
/* @__PURE__ */ jsxs16(Box16, { children: [
|
|
3408
|
+
/* @__PURE__ */ jsxs16(Text16, { color: theme.success, children: [
|
|
3014
3409
|
symbols.completed,
|
|
3015
3410
|
" "
|
|
3016
3411
|
] }),
|
|
3017
|
-
/* @__PURE__ */
|
|
3018
|
-
/* @__PURE__ */
|
|
3019
|
-
/* @__PURE__ */
|
|
3020
|
-
/* @__PURE__ */
|
|
3412
|
+
/* @__PURE__ */ jsx16(Text16, { color: theme.secondary, children: "Set " }),
|
|
3413
|
+
/* @__PURE__ */ jsx16(Text16, { color: theme.primary, children: configKey }),
|
|
3414
|
+
/* @__PURE__ */ jsx16(Text16, { color: theme.muted, children: " = " }),
|
|
3415
|
+
/* @__PURE__ */ jsx16(Text16, { color: theme.success, children: String(parsedValue) })
|
|
3021
3416
|
] })
|
|
3022
3417
|
] });
|
|
3023
3418
|
}
|
|
@@ -3025,94 +3420,94 @@ function ConfigSet({ configKey, configValue }) {
|
|
|
3025
3420
|
}
|
|
3026
3421
|
function ConfigPath() {
|
|
3027
3422
|
const { exit } = useApp9();
|
|
3028
|
-
|
|
3423
|
+
useEffect10(() => {
|
|
3029
3424
|
setTimeout(() => exit(), 100);
|
|
3030
3425
|
}, [exit]);
|
|
3031
|
-
return /* @__PURE__ */
|
|
3032
|
-
/* @__PURE__ */
|
|
3033
|
-
/* @__PURE__ */
|
|
3034
|
-
/* @__PURE__ */
|
|
3035
|
-
/* @__PURE__ */
|
|
3426
|
+
return /* @__PURE__ */ jsxs16(Box16, { flexDirection: "column", padding: 1, children: [
|
|
3427
|
+
/* @__PURE__ */ jsx16(Header, { compact: true, showTagline: false }),
|
|
3428
|
+
/* @__PURE__ */ jsxs16(Box16, { children: [
|
|
3429
|
+
/* @__PURE__ */ jsx16(Text16, { color: theme.muted, children: "Config file: " }),
|
|
3430
|
+
/* @__PURE__ */ jsx16(Text16, { color: theme.secondary, children: getConfigPath() })
|
|
3036
3431
|
] })
|
|
3037
3432
|
] });
|
|
3038
3433
|
}
|
|
3039
3434
|
function ConfigHelp() {
|
|
3040
3435
|
const { exit } = useApp9();
|
|
3041
|
-
|
|
3436
|
+
useEffect10(() => {
|
|
3042
3437
|
setTimeout(() => exit(), 100);
|
|
3043
3438
|
}, [exit]);
|
|
3044
|
-
return /* @__PURE__ */
|
|
3045
|
-
/* @__PURE__ */
|
|
3046
|
-
/* @__PURE__ */
|
|
3047
|
-
/* @__PURE__ */
|
|
3048
|
-
/* @__PURE__ */
|
|
3049
|
-
/* @__PURE__ */
|
|
3050
|
-
/* @__PURE__ */
|
|
3051
|
-
/* @__PURE__ */
|
|
3052
|
-
/* @__PURE__ */
|
|
3053
|
-
/* @__PURE__ */
|
|
3054
|
-
/* @__PURE__ */
|
|
3055
|
-
/* @__PURE__ */
|
|
3056
|
-
/* @__PURE__ */
|
|
3057
|
-
/* @__PURE__ */
|
|
3439
|
+
return /* @__PURE__ */ jsxs16(Box16, { flexDirection: "column", padding: 1, children: [
|
|
3440
|
+
/* @__PURE__ */ jsx16(Header, { compact: true, showTagline: false }),
|
|
3441
|
+
/* @__PURE__ */ jsx16(Box, { bordered: true, title: "Config Usage", padding: 1, children: /* @__PURE__ */ jsxs16(Box16, { flexDirection: "column", children: [
|
|
3442
|
+
/* @__PURE__ */ jsx16(Text16, { color: theme.secondary, children: "mina config list" }),
|
|
3443
|
+
/* @__PURE__ */ jsx16(Text16, { color: theme.muted, children: " Show all settings" }),
|
|
3444
|
+
/* @__PURE__ */ jsx16(Text16, { children: " " }),
|
|
3445
|
+
/* @__PURE__ */ jsx16(Text16, { color: theme.secondary, children: "mina config get <key>" }),
|
|
3446
|
+
/* @__PURE__ */ jsx16(Text16, { color: theme.muted, children: " Show single value" }),
|
|
3447
|
+
/* @__PURE__ */ jsx16(Text16, { children: " " }),
|
|
3448
|
+
/* @__PURE__ */ jsx16(Text16, { color: theme.secondary, children: "mina config set <key> <value>" }),
|
|
3449
|
+
/* @__PURE__ */ jsx16(Text16, { color: theme.muted, children: " Set a value" }),
|
|
3450
|
+
/* @__PURE__ */ jsx16(Text16, { children: " " }),
|
|
3451
|
+
/* @__PURE__ */ jsx16(Text16, { color: theme.secondary, children: "mina config path" }),
|
|
3452
|
+
/* @__PURE__ */ jsx16(Text16, { color: theme.muted, children: " Show config file location" })
|
|
3058
3453
|
] }) }),
|
|
3059
|
-
/* @__PURE__ */
|
|
3060
|
-
/* @__PURE__ */
|
|
3061
|
-
/* @__PURE__ */
|
|
3062
|
-
/* @__PURE__ */
|
|
3454
|
+
/* @__PURE__ */ jsx16(Box16, { marginTop: 1, children: /* @__PURE__ */ jsx16(Box, { bordered: true, title: "Available Settings", padding: 1, children: /* @__PURE__ */ jsxs16(Box16, { flexDirection: "column", children: [
|
|
3455
|
+
/* @__PURE__ */ jsxs16(Box16, { children: [
|
|
3456
|
+
/* @__PURE__ */ jsx16(Text16, { color: theme.primary, bold: true, children: "slippage" }),
|
|
3457
|
+
/* @__PURE__ */ jsx16(Text16, { color: theme.muted, children: " - Default slippage tolerance (e.g., 0.5)" })
|
|
3063
3458
|
] }),
|
|
3064
|
-
/* @__PURE__ */
|
|
3065
|
-
/* @__PURE__ */
|
|
3066
|
-
/* @__PURE__ */
|
|
3459
|
+
/* @__PURE__ */ jsxs16(Box16, { children: [
|
|
3460
|
+
/* @__PURE__ */ jsx16(Text16, { color: theme.primary, bold: true, children: "autoDeposit" }),
|
|
3461
|
+
/* @__PURE__ */ jsx16(Text16, { color: theme.muted, children: " - Auto-deposit to Hyperliquid (true/false)" })
|
|
3067
3462
|
] }),
|
|
3068
|
-
/* @__PURE__ */
|
|
3069
|
-
/* @__PURE__ */
|
|
3070
|
-
/* @__PURE__ */
|
|
3463
|
+
/* @__PURE__ */ jsxs16(Box16, { children: [
|
|
3464
|
+
/* @__PURE__ */ jsx16(Text16, { color: theme.primary, bold: true, children: "defaultChain" }),
|
|
3465
|
+
/* @__PURE__ */ jsx16(Text16, { color: theme.muted, children: " - Default source chain (e.g., arbitrum)" })
|
|
3071
3466
|
] }),
|
|
3072
|
-
/* @__PURE__ */
|
|
3073
|
-
/* @__PURE__ */
|
|
3074
|
-
/* @__PURE__ */
|
|
3467
|
+
/* @__PURE__ */ jsxs16(Box16, { children: [
|
|
3468
|
+
/* @__PURE__ */ jsx16(Text16, { color: theme.primary, bold: true, children: "rpc.<chain>" }),
|
|
3469
|
+
/* @__PURE__ */ jsx16(Text16, { color: theme.muted, children: " - Custom RPC URL for a chain" })
|
|
3075
3470
|
] })
|
|
3076
3471
|
] }) }) }),
|
|
3077
|
-
/* @__PURE__ */
|
|
3078
|
-
/* @__PURE__ */
|
|
3079
|
-
/* @__PURE__ */
|
|
3080
|
-
/* @__PURE__ */
|
|
3081
|
-
/* @__PURE__ */
|
|
3472
|
+
/* @__PURE__ */ jsx16(Box16, { marginTop: 1, children: /* @__PURE__ */ jsx16(Box, { bordered: true, title: "Examples", padding: 1, children: /* @__PURE__ */ jsxs16(Box16, { flexDirection: "column", children: [
|
|
3473
|
+
/* @__PURE__ */ jsx16(Text16, { color: theme.secondary, children: "mina config set slippage 0.5" }),
|
|
3474
|
+
/* @__PURE__ */ jsx16(Text16, { color: theme.secondary, children: "mina config set autoDeposit false" }),
|
|
3475
|
+
/* @__PURE__ */ jsx16(Text16, { color: theme.secondary, children: "mina config set rpc.arbitrum https://arb1.example.com" }),
|
|
3476
|
+
/* @__PURE__ */ jsx16(Text16, { color: theme.secondary, children: "mina config get slippage" })
|
|
3082
3477
|
] }) }) })
|
|
3083
3478
|
] });
|
|
3084
3479
|
}
|
|
3085
3480
|
function ConfigCommand({ action, key: configKey, value }) {
|
|
3086
3481
|
switch (action) {
|
|
3087
3482
|
case "list":
|
|
3088
|
-
return /* @__PURE__ */
|
|
3483
|
+
return /* @__PURE__ */ jsx16(ConfigList, {});
|
|
3089
3484
|
case "get":
|
|
3090
3485
|
if (!configKey) {
|
|
3091
|
-
return /* @__PURE__ */
|
|
3486
|
+
return /* @__PURE__ */ jsx16(ConfigHelp, {});
|
|
3092
3487
|
}
|
|
3093
|
-
return /* @__PURE__ */
|
|
3488
|
+
return /* @__PURE__ */ jsx16(ConfigGet, { configKey });
|
|
3094
3489
|
case "set":
|
|
3095
3490
|
if (!configKey || value === void 0) {
|
|
3096
|
-
return /* @__PURE__ */
|
|
3491
|
+
return /* @__PURE__ */ jsx16(ConfigHelp, {});
|
|
3097
3492
|
}
|
|
3098
|
-
return /* @__PURE__ */
|
|
3493
|
+
return /* @__PURE__ */ jsx16(ConfigSet, { configKey, configValue: value });
|
|
3099
3494
|
case "path":
|
|
3100
|
-
return /* @__PURE__ */
|
|
3495
|
+
return /* @__PURE__ */ jsx16(ConfigPath, {});
|
|
3101
3496
|
default:
|
|
3102
|
-
return /* @__PURE__ */
|
|
3497
|
+
return /* @__PURE__ */ jsx16(ConfigHelp, {});
|
|
3103
3498
|
}
|
|
3104
3499
|
}
|
|
3105
3500
|
|
|
3106
3501
|
// src/index.tsx
|
|
3107
|
-
var VERSION = "1.
|
|
3502
|
+
var VERSION = "1.2.1";
|
|
3108
3503
|
var program = new Command();
|
|
3109
3504
|
program.name("mina").description("Mina Bridge CLI - Bridge assets from any chain to Hyperliquid").version(VERSION, "-v, --version", "Display the current version").helpOption("-h, --help", "Display help information");
|
|
3110
3505
|
program.command("wizard").description("Launch the interactive bridge wizard").action(() => {
|
|
3111
|
-
render(
|
|
3506
|
+
render(React12.createElement(Wizard));
|
|
3112
3507
|
});
|
|
3113
3508
|
program.command("quote").description("Get a bridge quote").requiredOption("--from <chain>", "Source chain (e.g., ethereum, arbitrum, polygon)").option("--to <chain>", "Destination chain", "hyperliquid").requiredOption("--token <symbol>", "Token to bridge (e.g., USDC, ETH)").requiredOption("--amount <number>", "Amount to bridge").option("--json", "Output as JSON for machine-readable format").action((options) => {
|
|
3114
3509
|
render(
|
|
3115
|
-
|
|
3510
|
+
React12.createElement(QuoteDisplay, {
|
|
3116
3511
|
fromChain: options.from,
|
|
3117
3512
|
toChain: options.to,
|
|
3118
3513
|
token: options.token,
|
|
@@ -3123,7 +3518,7 @@ program.command("quote").description("Get a bridge quote").requiredOption("--fro
|
|
|
3123
3518
|
});
|
|
3124
3519
|
program.command("status <txHash>").description("Check bridge status").option("--watch", "Poll for updates").action((txHash, options) => {
|
|
3125
3520
|
render(
|
|
3126
|
-
|
|
3521
|
+
React12.createElement(Status, {
|
|
3127
3522
|
txHash,
|
|
3128
3523
|
watch: options.watch || false
|
|
3129
3524
|
})
|
|
@@ -3131,14 +3526,14 @@ program.command("status <txHash>").description("Check bridge status").option("--
|
|
|
3131
3526
|
});
|
|
3132
3527
|
program.command("chains").description("List supported chains").option("--json", "Output as JSON").action((options) => {
|
|
3133
3528
|
render(
|
|
3134
|
-
|
|
3529
|
+
React12.createElement(ChainsCommand, {
|
|
3135
3530
|
json: options.json || false
|
|
3136
3531
|
})
|
|
3137
3532
|
);
|
|
3138
3533
|
});
|
|
3139
3534
|
program.command("tokens").description("List bridgeable tokens").option("--chain <chain>", "Filter by chain (name or ID)").option("--json", "Output as JSON").action((options) => {
|
|
3140
3535
|
render(
|
|
3141
|
-
|
|
3536
|
+
React12.createElement(TokensCommand, {
|
|
3142
3537
|
chain: options.chain,
|
|
3143
3538
|
json: options.json || false
|
|
3144
3539
|
})
|
|
@@ -3149,7 +3544,7 @@ program.command("bridge").description("Execute a bridge transaction").requiredOp
|
|
|
3149
3544
|
});
|
|
3150
3545
|
program.command("history").description("View bridge transaction history").option("--limit <number>", "Number of entries to show", "10").option("--address <address>", "Filter by wallet address").option("--json", "Output as JSON").action((options) => {
|
|
3151
3546
|
render(
|
|
3152
|
-
|
|
3547
|
+
React12.createElement(HistoryCommand, {
|
|
3153
3548
|
limit: parseInt(options.limit, 10) || 10,
|
|
3154
3549
|
address: options.address,
|
|
3155
3550
|
json: options.json || false
|
|
@@ -3158,7 +3553,7 @@ program.command("history").description("View bridge transaction history").option
|
|
|
3158
3553
|
});
|
|
3159
3554
|
program.command("balance").description("Check wallet balances").requiredOption("--address <address>", "Wallet address").option("--chain <chain>", "Specific chain (name or ID)").option("--all", "Show all tokens including zero balance").option("--json", "Output as JSON").action((options) => {
|
|
3160
3555
|
render(
|
|
3161
|
-
|
|
3556
|
+
React12.createElement(BalanceCommand, {
|
|
3162
3557
|
address: options.address,
|
|
3163
3558
|
chain: options.chain,
|
|
3164
3559
|
showAll: options.all || false,
|
|
@@ -3168,7 +3563,7 @@ program.command("balance").description("Check wallet balances").requiredOption("
|
|
|
3168
3563
|
});
|
|
3169
3564
|
program.command("config [action] [key] [value]").description("Manage CLI configuration").action((action, key, value) => {
|
|
3170
3565
|
render(
|
|
3171
|
-
|
|
3566
|
+
React12.createElement(ConfigCommand, {
|
|
3172
3567
|
action,
|
|
3173
3568
|
key,
|
|
3174
3569
|
value
|
|
@@ -3222,7 +3617,7 @@ var args = process.argv.slice(2);
|
|
|
3222
3617
|
var hasCommand = args.length > 0 && !args[0]?.startsWith("-");
|
|
3223
3618
|
var isHelpOrVersion = args.some((arg) => ["-h", "--help", "-v", "--version"].includes(arg));
|
|
3224
3619
|
if (!hasCommand && !isHelpOrVersion) {
|
|
3225
|
-
render(
|
|
3620
|
+
render(React12.createElement(Wizard));
|
|
3226
3621
|
} else {
|
|
3227
3622
|
program.parse(process.argv);
|
|
3228
3623
|
}
|