@cordystackx/cordy_minikit 2.0.10 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -753
- package/dist/client/jwt.d.ts +32 -0
- package/dist/client/jwt.d.ts.map +1 -0
- package/dist/client/jwt.js +84 -0
- package/dist/client/transfer.d.ts +104 -0
- package/dist/client/transfer.d.ts.map +1 -0
- package/dist/client/transfer.js +613 -0
- package/dist/client.d.ts +5 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +2 -0
- package/dist/client__provider.d.ts +3 -1
- package/dist/client__provider.d.ts.map +1 -1
- package/dist/client__provider.js +29 -2
- package/dist/components/Connect_wallet_bt.d.ts +9 -3
- package/dist/components/Connect_wallet_bt.d.ts.map +1 -1
- package/dist/components/Connect_wallet_bt.js +63 -47
- package/dist/components/UI_Comp.d.ts.map +1 -1
- package/dist/components/UI_Comp.js +51 -60
- package/dist/config/Image.json +2 -2
- package/dist/config/walletConfig.d.ts +3 -0
- package/dist/config/walletConfig.d.ts.map +1 -1
- package/dist/config/walletConfig.js +43 -2
- package/dist/controllers/Get_Account_Info.d.ts.map +1 -1
- package/dist/controllers/Get_Balance.d.ts +22 -0
- package/dist/controllers/Get_Balance.d.ts.map +1 -1
- package/dist/controllers/Get_Balance.js +90 -28
- package/dist/controllers/StellarButton.d.ts.map +1 -1
- package/dist/controllers/StellarButton.js +4 -0
- package/dist/controllers/WagmiButton.d.ts +2 -1
- package/dist/controllers/WagmiButton.d.ts.map +1 -1
- package/dist/controllers/WagmiButton.js +33 -33
- package/dist/controllers/loadStellarBalance.d.ts +23 -1
- package/dist/controllers/loadStellarBalance.d.ts.map +1 -1
- package/dist/controllers/loadStellarBalance.js +47 -14
- package/dist/css/UI_Comp/styles.module.css +121 -314
- package/dist/demo/next.config.d.ts +4 -0
- package/dist/demo/next.config.d.ts.map +1 -0
- package/dist/demo/next.config.js +12 -0
- package/dist/demo/src/app/layout.d.ts +5 -0
- package/dist/demo/src/app/layout.d.ts.map +1 -0
- package/dist/demo/src/app/layout.js +9 -0
- package/dist/demo/src/app/page.d.ts +2 -0
- package/dist/demo/src/app/page.d.ts.map +1 -0
- package/dist/demo/src/app/page.js +9 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/package.json +29 -14
- package/dist/server/jwt.d.ts +18 -0
- package/dist/server/jwt.d.ts.map +1 -0
- package/dist/server/jwt.js +35 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/wagmi__providers.d.ts +7 -2
- package/dist/wagmi__providers.d.ts.map +1 -1
- package/dist/wagmi__providers.js +24 -5
- package/package.json +29 -14
package/dist/client__provider.js
CHANGED
|
@@ -1,10 +1,37 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useMemo } from 'react';
|
|
4
|
+
import { configureCordyAssets } from './client/transfer';
|
|
5
|
+
import getConfig, { config as defaultConfig, setActiveWagmiConfig } from './config/walletConfig';
|
|
6
|
+
import { defineChain } from 'viem';
|
|
3
7
|
import dynamic from 'next/dynamic';
|
|
4
8
|
// Dynamically import WalletProviders with SSR disabled
|
|
5
9
|
const WalletProviders = dynamic(() => import('./wagmi__providers'), {
|
|
6
10
|
ssr: false,
|
|
7
11
|
});
|
|
8
|
-
export default function ProvidersClientWrapper({ children }) {
|
|
9
|
-
|
|
12
|
+
export default function ProvidersClientWrapper({ children, assets, }) {
|
|
13
|
+
const walletConfig = useMemo(() => {
|
|
14
|
+
const networks = assets?.networks ?? [];
|
|
15
|
+
if (networks.length === 0)
|
|
16
|
+
return defaultConfig;
|
|
17
|
+
const customChains = Object.fromEntries(networks.map((network) => [
|
|
18
|
+
String(network.chainId),
|
|
19
|
+
defineChain({
|
|
20
|
+
id: network.chainId,
|
|
21
|
+
name: network.name,
|
|
22
|
+
nativeCurrency: network.nativeCurrency,
|
|
23
|
+
rpcUrls: { default: { http: [network.rpcUrl] } },
|
|
24
|
+
...(network.blockExplorerUrl
|
|
25
|
+
? { blockExplorers: { default: { name: `${network.name} Explorer`, url: network.blockExplorerUrl } } }
|
|
26
|
+
: {}),
|
|
27
|
+
}),
|
|
28
|
+
]));
|
|
29
|
+
return getConfig(customChains);
|
|
30
|
+
}, [assets?.networks]);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (assets)
|
|
33
|
+
configureCordyAssets({ assets });
|
|
34
|
+
}, [assets]);
|
|
35
|
+
useEffect(() => setActiveWagmiConfig(walletConfig), [walletConfig]);
|
|
36
|
+
return _jsx(WalletProviders, { config: walletConfig, children: children });
|
|
10
37
|
}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
type ConnectWalletBTProps = {
|
|
2
2
|
className?: string;
|
|
3
|
-
}
|
|
4
|
-
|
|
3
|
+
} & ({
|
|
4
|
+
jwt_session: true;
|
|
5
|
+
navigate: string;
|
|
6
|
+
} | {
|
|
7
|
+
jwt_session?: false;
|
|
8
|
+
navigate?: never;
|
|
9
|
+
});
|
|
10
|
+
export default function ConnectWalletBT({ className, jwt_session, navigate, }: ConnectWalletBTProps): import("react").JSX.Element;
|
|
5
11
|
export {};
|
|
6
12
|
//# sourceMappingURL=Connect_wallet_bt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Connect_wallet_bt.d.ts","sourceRoot":"","sources":["../../components/Connect_wallet_bt.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Connect_wallet_bt.d.ts","sourceRoot":"","sources":["../../components/Connect_wallet_bt.tsx"],"names":[],"mappings":"AAWA,KAAK,oBAAoB,GAAG;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,CACA;IAAE,WAAW,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACvC;IAAE,WAAW,CAAC,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,EAAE,KAAK,CAAA;CAAE,CAC5C,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EACtC,SAAS,EACT,WAAmB,EACnB,QAAQ,GACT,EAAE,oBAAoB,+BAuFtB"}
|
|
@@ -1,69 +1,85 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { getTokenBalance, loadStellarBalance } from "../controllers";
|
|
4
|
-
import { useWalletModal, useStellarWallet } from "../wagmi__providers";
|
|
5
|
-
import { useAccount } from "wagmi";
|
|
6
3
|
import { useEffect, useState } from "react";
|
|
7
|
-
|
|
4
|
+
import { useRouter } from "next/navigation";
|
|
5
|
+
import { useAccount } from "wagmi";
|
|
6
|
+
import { getTokenBalance, loadStellarBalance } from "../controllers";
|
|
7
|
+
import { useStellarWallet, useWalletModal } from "../wagmi__providers";
|
|
8
|
+
// const ACTIVE_WALLET_SESSION_KEY = "cordy_minikit_active_wallet_session";
|
|
8
9
|
const STELLAR_BALANCE_REFRESH_EVENT = "cordy:stellar-balance-updated";
|
|
9
|
-
export default function ConnectWalletBT({ className, }) {
|
|
10
|
-
const
|
|
10
|
+
export default function ConnectWalletBT({ className, jwt_session = false, navigate, }) {
|
|
11
|
+
const router = useRouter();
|
|
12
|
+
const { openModal, closeModal } = useWalletModal();
|
|
11
13
|
const { stellarWallet, setStellarWallet } = useStellarWallet();
|
|
12
14
|
const { isConnected, address } = useAccount();
|
|
13
15
|
const [balance, setBalance] = useState("");
|
|
14
16
|
const [symbol, setSymbol] = useState("");
|
|
17
|
+
const walletConnected = Boolean((isConnected && address) || stellarWallet.address);
|
|
18
|
+
if (jwt_session !== Boolean(navigate)) {
|
|
19
|
+
throw new Error('ConnectWalletBT: provide both "jwt_session={true}" and a "navigate" path, or neither.');
|
|
20
|
+
}
|
|
21
|
+
if (jwt_session &&
|
|
22
|
+
navigate &&
|
|
23
|
+
(!navigate.startsWith("/") || navigate.startsWith("//") || navigate.includes("\\"))) {
|
|
24
|
+
throw new Error('ConnectWalletBT: "navigate" must be a safe internal path starting with "/".');
|
|
25
|
+
}
|
|
15
26
|
useEffect(() => {
|
|
16
|
-
if (
|
|
17
|
-
|
|
27
|
+
if (jwt_session && navigate && walletConnected) {
|
|
28
|
+
closeModal();
|
|
29
|
+
router.replace(navigate);
|
|
18
30
|
}
|
|
19
|
-
}, [
|
|
20
|
-
|
|
21
|
-
if (!address)
|
|
31
|
+
}, [closeModal, jwt_session, navigate, router, walletConnected]);
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (jwt_session || !isConnected || !address)
|
|
34
|
+
return;
|
|
35
|
+
void getTokenBalance(address).then(({ balance: nextBalance, symbol: nextSymbol }) => {
|
|
36
|
+
setBalance(nextBalance);
|
|
37
|
+
setSymbol(nextSymbol);
|
|
38
|
+
});
|
|
39
|
+
}, [address, isConnected, jwt_session]);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (!stellarWallet.address || jwt_session)
|
|
22
42
|
return;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
try {
|
|
29
|
-
const result = await loadStellarBalance(accountId);
|
|
43
|
+
let active = true;
|
|
44
|
+
void loadStellarBalance(stellarWallet.address)
|
|
45
|
+
.then((result) => {
|
|
46
|
+
if (!active)
|
|
47
|
+
return;
|
|
30
48
|
setStellarWallet((current) => ({
|
|
31
49
|
...current,
|
|
32
50
|
address: result.address,
|
|
33
51
|
network: result.network,
|
|
34
52
|
balance: result.balance,
|
|
35
53
|
}));
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
balance: "0",
|
|
45
|
-
}));
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
useEffect(() => {
|
|
49
|
-
if (stellarWallet.address) {
|
|
50
|
-
void handleLoadStellarBalance(stellarWallet.address);
|
|
51
|
-
}
|
|
52
|
-
}, [stellarWallet.address]);
|
|
54
|
+
})
|
|
55
|
+
.catch((error) => {
|
|
56
|
+
console.error("Failed to load Stellar balance:", error);
|
|
57
|
+
if (active)
|
|
58
|
+
setStellarWallet((current) => ({ ...current, balance: "0" }));
|
|
59
|
+
});
|
|
60
|
+
return () => { active = false; };
|
|
61
|
+
}, [jwt_session, setStellarWallet, stellarWallet.address]);
|
|
53
62
|
useEffect(() => {
|
|
63
|
+
if (jwt_session || !stellarWallet.address)
|
|
64
|
+
return;
|
|
54
65
|
const handler = () => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
66
|
+
void loadStellarBalance(stellarWallet.address).then((result) => {
|
|
67
|
+
setStellarWallet((current) => ({
|
|
68
|
+
...current,
|
|
69
|
+
address: result.address,
|
|
70
|
+
network: result.network,
|
|
71
|
+
balance: result.balance,
|
|
72
|
+
}));
|
|
73
|
+
});
|
|
58
74
|
};
|
|
59
75
|
window.addEventListener(STELLAR_BALANCE_REFRESH_EVENT, handler);
|
|
60
|
-
return () =>
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
76
|
+
return () => window.removeEventListener(STELLAR_BALANCE_REFRESH_EVENT, handler);
|
|
77
|
+
}, [jwt_session, setStellarWallet, stellarWallet.address]);
|
|
78
|
+
return (_jsx("button", { className: className, onClick: () => openModal({ jwtSession: jwt_session }), "data-jwt-session": jwt_session ? "enabled" : undefined, type: "button", children: jwt_session
|
|
79
|
+
? walletConnected ? "Connected" : "Connect Wallet"
|
|
80
|
+
: isConnected
|
|
81
|
+
? `BAL ${balance} ${symbol}`
|
|
82
|
+
: stellarWallet.address
|
|
83
|
+
? `BAL ${stellarWallet.balance ?? "0"} XLM`
|
|
84
|
+
: "Connect Wallet" }));
|
|
69
85
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UI_Comp.d.ts","sourceRoot":"","sources":["../../components/UI_Comp.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"UI_Comp.d.ts","sourceRoot":"","sources":["../../components/UI_Comp.tsx"],"names":[],"mappings":"AAuCA,MAAM,CAAC,OAAO,UAAU,OAAO,gCAkJ9B"}
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { UI_Comp__css } from "../css";
|
|
4
4
|
import { WalletButton, getTokenBalance, StellarWalletButton, loadStellarBalance, useDisconnectWallets } from "../controllers";
|
|
5
5
|
import { useWalletModal, useStellarWallet } from "../wagmi__providers";
|
|
6
6
|
import { useAccount } from "wagmi";
|
|
7
|
-
import { FaUser } from 'react-icons/fa';
|
|
8
7
|
import { useState, useEffect } from "react";
|
|
9
8
|
import pkg from "../package.json";
|
|
10
9
|
import links from "../config/links.json";
|
|
11
10
|
const ACTIVE_WALLET_SESSION_KEY = "cordy_minikit_active_wallet_session";
|
|
11
|
+
const walletRoutes = [
|
|
12
|
+
{ id: "browser-evm", title: "EVM · Browser", subtitle: "Use MetaMask, Coinbase Wallet, or another extension", icon: "E", hint: "Browser" },
|
|
13
|
+
{ id: "walletconnect", title: "WalletConnect · Mobile", subtitle: "Connect with a wallet on your phone using a QR code", icon: "W", hint: "QR code" },
|
|
14
|
+
{ id: "stellar", title: "Stellar · Non-EVM", subtitle: "Connect a Stellar account with Freighter", icon: "✦", hint: "Freighter" },
|
|
15
|
+
];
|
|
16
|
+
function CordyLogo() {
|
|
17
|
+
return (_jsxs("svg", { viewBox: "0 0 512 512", role: "img", "aria-label": "Cordy Minikit", children: [_jsxs("defs", { children: [_jsxs("linearGradient", { id: "cordy-logo-gradient", x1: "140", y1: "140", x2: "350", y2: "380", gradientUnits: "userSpaceOnUse", children: [_jsx("stop", { offset: "0", stopColor: "#F2F4F8" }), _jsx("stop", { offset: "1", stopColor: "#AEBBD6" })] }), _jsxs("linearGradient", { id: "cordy-star-gradient", x1: "307", y1: "218", x2: "383", y2: "294", gradientUnits: "userSpaceOnUse", children: [_jsx("stop", { offset: "0", stopColor: "#4F8CFF" }), _jsx("stop", { offset: "1", stopColor: "#5CE1E6" })] })] }), _jsx("rect", { width: "512", height: "512", rx: "112", fill: "#111214" }), _jsx("path", { d: "M355.6 172.4 A130 130 0 1 0 355.6 339.6 A105 105 0 1 1 355.6 172.4 Z", fill: "url(#cordy-logo-gradient)" }), _jsx("path", { d: "M345 218 Q345 256 383 256 Q345 256 345 294 Q345 256 307 256 Q345 256 345 218 Z", fill: "url(#cordy-star-gradient)" })] }));
|
|
18
|
+
}
|
|
12
19
|
export default function UI_Comp() {
|
|
13
|
-
const { closeModal } = useWalletModal();
|
|
20
|
+
const { closeModal, jwtSession } = useWalletModal();
|
|
14
21
|
const { stellarWallet, setStellarWallet } = useStellarWallet();
|
|
15
22
|
const { isConnected, address, chain } = useAccount();
|
|
16
23
|
const [loading, setLoading] = useState(false);
|
|
@@ -19,49 +26,35 @@ export default function UI_Comp() {
|
|
|
19
26
|
const [symbol, setSymbol] = useState("");
|
|
20
27
|
const [stellarLoading, setStellarLoading] = useState(false);
|
|
21
28
|
const [stellarError, setStellarError] = useState();
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
} = useDisconnectWallets();
|
|
29
|
+
const [selectedRoute, setSelectedRoute] = useState(null);
|
|
30
|
+
const { disconnectEVM, disconnectStellar } = useDisconnectWallets();
|
|
25
31
|
useEffect(() => {
|
|
26
|
-
if (isConnected && address)
|
|
27
|
-
Get_Balance();
|
|
28
|
-
|
|
29
|
-
}, [isConnected, address]);
|
|
32
|
+
if (!jwtSession && isConnected && address)
|
|
33
|
+
void Get_Balance();
|
|
34
|
+
}, [isConnected, address, jwtSession]);
|
|
30
35
|
useEffect(() => {
|
|
31
|
-
if (stellarWallet.address)
|
|
36
|
+
if (!jwtSession && stellarWallet.address)
|
|
32
37
|
void loadStellarBalance(stellarWallet.address);
|
|
33
|
-
|
|
34
|
-
}, [stellarWallet.address]);
|
|
38
|
+
}, [stellarWallet.address, jwtSession]);
|
|
35
39
|
const Get_Balance = async () => {
|
|
36
40
|
if (!address)
|
|
37
41
|
return;
|
|
38
|
-
const
|
|
39
|
-
setBalance(balance);
|
|
40
|
-
setSymbol(symbol);
|
|
41
|
-
return;
|
|
42
|
+
const result = await getTokenBalance(address);
|
|
43
|
+
setBalance(result.balance);
|
|
44
|
+
setSymbol(result.symbol);
|
|
42
45
|
};
|
|
43
46
|
const handleLoadStellarBalance = async (accountId) => {
|
|
44
47
|
setStellarError(undefined);
|
|
45
48
|
try {
|
|
46
49
|
const result = await loadStellarBalance(accountId);
|
|
47
|
-
setStellarWallet((current) => ({
|
|
48
|
-
|
|
49
|
-
address: result.address,
|
|
50
|
-
network: result.network,
|
|
51
|
-
balance: result.balance,
|
|
52
|
-
}));
|
|
53
|
-
if (typeof window !== "undefined") {
|
|
54
|
-
window.localStorage.setItem(ACTIVE_WALLET_SESSION_KEY, "stellar");
|
|
55
|
-
}
|
|
50
|
+
setStellarWallet((current) => ({ ...current, address: result.address, network: result.network, balance: result.balance }));
|
|
51
|
+
window.localStorage.setItem(ACTIVE_WALLET_SESSION_KEY, "stellar");
|
|
56
52
|
}
|
|
57
53
|
catch (err) {
|
|
58
54
|
const message = err instanceof Error ? err.message : "Failed to load Stellar balance";
|
|
59
55
|
console.error("Failed to load Stellar balance:", err);
|
|
60
56
|
setStellarError(message);
|
|
61
|
-
setStellarWallet((current) => ({
|
|
62
|
-
...current,
|
|
63
|
-
balance: "0",
|
|
64
|
-
}));
|
|
57
|
+
setStellarWallet((current) => ({ ...current, balance: "0" }));
|
|
65
58
|
}
|
|
66
59
|
};
|
|
67
60
|
const truncateAddress = (value, head = 8, tail = 4) => {
|
|
@@ -71,35 +64,33 @@ export default function UI_Comp() {
|
|
|
71
64
|
return value;
|
|
72
65
|
return `${value.slice(0, head)}...${value.slice(-tail)}`;
|
|
73
66
|
};
|
|
74
|
-
|
|
75
|
-
if (isConnected) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}, children: "DisConnect" }), _jsxs("a", { style: { marginTop: "2rem" }, href: links.NPM_Pack_links, children: ["Powered By CordyStackX | Version ", pkg.version] })] }) }));
|
|
67
|
+
const footer = _jsxs("a", { className: UI_Comp__css.footer_link, href: links.NPM_Pack_links, target: "_blank", rel: "noreferrer", children: ["Cordy Minikit ", _jsx("span", { "aria-hidden": "true", children: "\u00B7" }), " v", pkg.version] });
|
|
68
|
+
if (isConnected || stellarWallet.address) {
|
|
69
|
+
const isStellar = !isConnected && Boolean(stellarWallet.address);
|
|
70
|
+
const connectedAddress = isStellar ? stellarWallet.address : address;
|
|
71
|
+
const connectedNetwork = isStellar ? stellarWallet.network || "Stellar" : chain?.name || "Network unavailable";
|
|
72
|
+
const connectedBalance = isStellar
|
|
73
|
+
? stellarWallet.balance ? `${stellarWallet.balance} XLM` : "Loading balance…"
|
|
74
|
+
: balance ? `${Number(balance).toFixed(4)} ${symbol}` : "Loading balance…";
|
|
75
|
+
return (_jsx("div", { className: UI_Comp__css.container, children: _jsxs("section", { className: UI_Comp__css.connector, role: "dialog", "aria-modal": "true", "aria-labelledby": "wallet-modal-title", children: [_jsxs("header", { className: UI_Comp__css.modal_header, children: [_jsx("div", { className: UI_Comp__css.brand_mark, children: _jsx(CordyLogo, {}) }), _jsxs("div", { children: [_jsx("p", { className: UI_Comp__css.eyebrow, children: "CORDY MINIKIT" }), _jsx("h2", { id: "wallet-modal-title", children: "Wallet connected" })] }), _jsx("button", { className: UI_Comp__css.close_button, type: "button", onClick: closeModal, "aria-label": "Close wallet dialog", children: "\u00D7" })] }), _jsxs("div", { className: UI_Comp__css.connected_card, children: [_jsxs("div", { className: UI_Comp__css.connected_heading, children: [_jsx("span", { className: UI_Comp__css.connected_dot }), " ", isStellar ? "Stellar wallet" : "EVM wallet", _jsx("span", { className: UI_Comp__css.network_badge, children: connectedNetwork })] }), !jwtSession && _jsxs(_Fragment, { children: [_jsx("div", { className: UI_Comp__css.balance_value, children: connectedBalance }), _jsx("p", { className: UI_Comp__css.muted, children: isStellar ? "Native balance" : "Token balance" })] }), _jsxs("div", { className: UI_Comp__css.address_row, children: [_jsx("span", { children: "Address" }), _jsx("code", { title: connectedAddress || "", children: truncateAddress(connectedAddress, 12, 8) })] }), isStellar && stellarError && _jsx("p", { className: UI_Comp__css.error_message, role: "alert", children: stellarError })] }), _jsx("button", { className: UI_Comp__css.disconnect_button, type: "button", onClick: async () => { if (isStellar)
|
|
76
|
+
await disconnectStellar();
|
|
77
|
+
else
|
|
78
|
+
await disconnectEVM(); }, children: "Disconnect wallet" }), footer] }) }));
|
|
87
79
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
} })] })] }), _jsx("p", { style: { color: "#f00" }, children: errorMsg }), _jsx("p", { style: { color: "#f00" }, children: stellarError }), _jsxs("a", { style: { marginTop: "2rem" }, href: links.NPM_Pack_links, children: ["Powered By CordyStackX | Version ", pkg.version] })] }) }));
|
|
80
|
+
const selectedWalletRoute = walletRoutes.find((route) => route.id === selectedRoute);
|
|
81
|
+
return (_jsx("div", { className: UI_Comp__css.container, children: _jsxs("section", { className: UI_Comp__css.connector, role: "dialog", "aria-modal": "true", "aria-labelledby": "wallet-modal-title", "aria-describedby": "wallet-modal-description", children: [_jsxs("header", { className: UI_Comp__css.modal_header, children: [_jsx("div", { className: UI_Comp__css.brand_mark, children: _jsx(CordyLogo, {}) }), _jsxs("div", { children: [_jsxs("p", { className: UI_Comp__css.eyebrow, children: ["CORDY MINIKIT ", _jsx("span", { children: "\u00B7" }), " WALLET ACCESS"] }), _jsx("h2", { id: "wallet-modal-title", children: selectedWalletRoute?.title || "Choose a wallet" })] }), _jsx("button", { className: UI_Comp__css.close_button, type: "button", onClick: closeModal, "aria-label": "Close wallet dialog", children: "\u00D7" })] }), _jsx("p", { id: "wallet-modal-description", className: UI_Comp__css.modal_description, children: selectedWalletRoute ? selectedWalletRoute.subtitle : "Select how you want to connect." }), (loading || stellarLoading) && _jsxs("div", { className: UI_Comp__css.loading_notice, role: "status", children: [_jsx("span", { className: UI_Comp__css.spinner }), " Waiting for wallet approval\u2026"] }), !selectedRoute ? (_jsx("div", { className: UI_Comp__css.wallet_choices, role: "group", "aria-label": "Wallet connection options", children: walletRoutes.map((route) => (_jsxs("button", { type: "button", className: UI_Comp__css.wallet_choice, onClick: () => { setErrorMsg(undefined); setStellarError(undefined); setSelectedRoute(route.id); }, children: [_jsx("span", { className: `${UI_Comp__css.choice_icon} ${route.id === "stellar" ? UI_Comp__css.stellar_choice_icon : ""}`, "aria-hidden": "true", children: route.icon }), _jsxs("span", { className: UI_Comp__css.choice_copy, children: [_jsx("span", { className: UI_Comp__css.choice_title, children: route.title }), _jsx("span", { className: UI_Comp__css.choice_subtitle, children: route.subtitle })] }), _jsx("span", { className: UI_Comp__css.choice_hint, children: route.hint }), _jsx("svg", { className: UI_Comp__css.choice_chevron, "aria-hidden": "true", viewBox: "0 0 16 16", fill: "none", children: _jsx("path", { d: "m6 3 5 5-5 5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) })] }, route.id))) })) : (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", className: UI_Comp__css.back_button, onClick: () => { setSelectedRoute(null); setErrorMsg(undefined); setStellarError(undefined); }, children: [_jsx("svg", { "aria-hidden": "true", viewBox: "0 0 16 16", fill: "none", children: _jsx("path", { d: "M10 3 5 8l5 5M5 8h8", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }), "All connection options"] }), _jsxs("div", { className: UI_Comp__css.wallet_panel, children: [_jsx("p", { className: UI_Comp__css.panel_label, children: "AVAILABLE WALLETS" }), _jsxs("div", { className: UI_Comp__css.wallet_options, children: [selectedRoute === "browser-evm" && _jsx(WalletButton, { connectorGroup: "browser", onStatusChange: ({ isPending, error }) => { setLoading(isPending); setErrorMsg(error); } }), selectedRoute === "walletconnect" && _jsx(WalletButton, { connectorGroup: "walletconnect", onStatusChange: ({ isPending, error }) => { setLoading(isPending); setErrorMsg(error); } }), selectedRoute === "stellar" && _jsx(StellarWalletButton, { onConnect: (accountId) => {
|
|
82
|
+
setStellarWallet((current) => ({ ...current, address: accountId }));
|
|
83
|
+
if (!jwtSession)
|
|
84
|
+
void handleLoadStellarBalance(accountId);
|
|
85
|
+
}, onStatusChange: ({ isPending, error, address: accountId, network }) => {
|
|
86
|
+
setStellarLoading(isPending);
|
|
87
|
+
setStellarError(error);
|
|
88
|
+
if (accountId) {
|
|
89
|
+
setStellarWallet((current) => ({ ...current, address: accountId }));
|
|
90
|
+
if (!jwtSession)
|
|
91
|
+
void handleLoadStellarBalance(accountId);
|
|
92
|
+
}
|
|
93
|
+
if (network)
|
|
94
|
+
setStellarWallet((current) => ({ ...current, network }));
|
|
95
|
+
} })] }), _jsx("p", { className: UI_Comp__css.panel_note, children: selectedRoute === "walletconnect" ? "Scan the QR code with your mobile wallet to continue." : selectedRoute === "stellar" ? "Freighter will ask you to approve access to your Stellar account." : "Choose an installed browser wallet to continue." })] })] })), (errorMsg || stellarError) && _jsx("div", { className: UI_Comp__css.error_message, role: "alert", children: errorMsg || stellarError }), _jsxs("div", { className: UI_Comp__css.modal_footer, children: [_jsx("span", { children: "Connecting only shares your public wallet address." }), footer] })] }) }));
|
|
105
96
|
}
|
package/dist/config/Image.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"logo": "https://
|
|
2
|
+
"logo": "https://raw.githubusercontent.com/cordyStackX/cordy_minikit_official/main/assets/cordy-logo.svg",
|
|
3
3
|
"Coinbase Wallet": "https://raw.githubusercontent.com/cordyStackX/cordy_minikit_official/main/assets/coinbased.svg",
|
|
4
4
|
"MetaMask": "https://raw.githubusercontent.com/cordyStackX/cordy_minikit_official/main/assets/metamask.png",
|
|
5
5
|
"WalletConnect": "https://raw.githubusercontent.com/cordyStackX/cordy_minikit_official/5086ee7de9e94e331f9b595e17ec5d022f5b8674/assets/WalletConnect.svg",
|
|
6
|
-
"Trust Wallet": "https://raw.githubusercontent.com/cordyStackX/cordy_minikit_official/
|
|
6
|
+
"Trust Wallet": "https://raw.githubusercontent.com/cordyStackX/cordy_minikit_official/main/assets/trust-wallet-icon.png",
|
|
7
7
|
"Freighter": "https://raw.githubusercontent.com/cordyStackX/cordy_minikit_official/refs/heads/main/assets/freighter.jpeg"
|
|
8
8
|
}
|
|
@@ -2,4 +2,7 @@ import { createConfig } from 'wagmi';
|
|
|
2
2
|
import type { Chain } from 'wagmi/chains';
|
|
3
3
|
export default function getConfig(customChains?: Record<string, Chain>): ReturnType<typeof createConfig>;
|
|
4
4
|
export declare const config: ReturnType<typeof createConfig>;
|
|
5
|
+
export declare function setActiveWagmiConfig(nextConfig: ReturnType<typeof createConfig>): void;
|
|
6
|
+
export declare function getActiveWagmiConfig(): ReturnType<typeof createConfig>;
|
|
7
|
+
export declare function isEvmEnvironmentConfigured(): boolean;
|
|
5
8
|
//# sourceMappingURL=walletConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"walletConfig.d.ts","sourceRoot":"","sources":["../../config/walletConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,YAAY,EAAE,MAAM,OAAO,CAAC;AAG3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"walletConfig.d.ts","sourceRoot":"","sources":["../../config/walletConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,YAAY,EAAE,MAAM,OAAO,CAAC;AAG3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAgC1C,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,YAAY,GAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAM,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CA2B3G;AAED,eAAO,MAAM,MAAM,EAAE,UAAU,CAAC,OAAO,YAAY,CAGN,CAAC;AAI9C,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,GAAG,IAAI,CAEtF;AAED,wBAAgB,oBAAoB,IAAI,UAAU,CAAC,OAAO,YAAY,CAAC,CAEtE;AAED,wBAAgB,0BAA0B,IAAI,OAAO,CAEpD"}
|
|
@@ -1,9 +1,40 @@
|
|
|
1
1
|
import { http, createConfig } from 'wagmi';
|
|
2
|
-
import { mainnet, base } from 'wagmi/chains';
|
|
2
|
+
import { mainnet, base, sepolia } from 'wagmi/chains';
|
|
3
3
|
import { walletConnect, metaMask, coinbaseWallet } from 'wagmi/connectors';
|
|
4
|
+
import { defineChain } from 'viem';
|
|
4
5
|
const projectId = process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID;
|
|
6
|
+
const hasConfiguredEvmEnvironment = Boolean(process.env.NEXT_PUBLIC_RPC_ENDPOINT &&
|
|
7
|
+
process.env.NEXT_PUBLIC_CHAIN_ID &&
|
|
8
|
+
process.env.NEXT_PUBLIC_TOKENADDRESS);
|
|
9
|
+
const configuredChainId = Number(process.env.NEXT_PUBLIC_CHAIN_ID || mainnet.id);
|
|
10
|
+
if (!Number.isSafeInteger(configuredChainId) || configuredChainId <= 0) {
|
|
11
|
+
throw new Error('NEXT_PUBLIC_CHAIN_ID must be a positive integer.');
|
|
12
|
+
}
|
|
13
|
+
const configuredRpcEndpoint = process.env.NEXT_PUBLIC_RPC_ENDPOINT
|
|
14
|
+
|| mainnet.rpcUrls.default.http[0];
|
|
15
|
+
const configuredChain = defineChain({
|
|
16
|
+
id: configuredChainId,
|
|
17
|
+
name: process.env.NEXT_PUBLIC_CHAIN_NAME || mainnet.name,
|
|
18
|
+
nativeCurrency: process.env.NEXT_PUBLIC_CHAIN_ID
|
|
19
|
+
? { name: 'Configured native token', symbol: 'NATIVE', decimals: 18 }
|
|
20
|
+
: mainnet.nativeCurrency,
|
|
21
|
+
rpcUrls: {
|
|
22
|
+
default: { http: [configuredRpcEndpoint] },
|
|
23
|
+
},
|
|
24
|
+
blockExplorers: {
|
|
25
|
+
default: {
|
|
26
|
+
name: process.env.NEXT_PUBLIC_CHAIN_NAME ? `${process.env.NEXT_PUBLIC_CHAIN_NAME} Explorer` : mainnet.blockExplorers.default.name,
|
|
27
|
+
url: process.env.NEXT_PUBLIC_BLOCK_EXPLORER_URL || mainnet.blockExplorers.default.url,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
});
|
|
5
31
|
export default function getConfig(customChains = {}) {
|
|
6
|
-
const
|
|
32
|
+
const uniqueChains = [...Object.values(customChains), configuredChain, mainnet, base, sepolia]
|
|
33
|
+
.filter((chain, index, chains) => chains.findIndex((candidate) => candidate.id === chain.id) === index);
|
|
34
|
+
const [firstChain, ...otherChains] = uniqueChains;
|
|
35
|
+
if (!firstChain)
|
|
36
|
+
throw new Error('At least one EVM chain must be configured.');
|
|
37
|
+
const allChains = [firstChain, ...otherChains];
|
|
7
38
|
// Use the chain's RPC URL if available
|
|
8
39
|
const transports = allChains.reduce((acc, chain) => {
|
|
9
40
|
const rpcUrl = chain.rpcUrls?.default?.http?.[0];
|
|
@@ -25,3 +56,13 @@ export default function getConfig(customChains = {}) {
|
|
|
25
56
|
export const config = typeof window !== "undefined"
|
|
26
57
|
? getConfig()
|
|
27
58
|
: {};
|
|
59
|
+
let activeWagmiConfig = config;
|
|
60
|
+
export function setActiveWagmiConfig(nextConfig) {
|
|
61
|
+
activeWagmiConfig = nextConfig;
|
|
62
|
+
}
|
|
63
|
+
export function getActiveWagmiConfig() {
|
|
64
|
+
return activeWagmiConfig;
|
|
65
|
+
}
|
|
66
|
+
export function isEvmEnvironmentConfigured() {
|
|
67
|
+
return hasConfiguredEvmEnvironment;
|
|
68
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Get_Account_Info.d.ts","sourceRoot":"","sources":["../../controllers/Get_Account_Info.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;AAGjE,MAAM,CAAC,OAAO,UAAU,eAAe
|
|
1
|
+
{"version":3,"file":"Get_Account_Info.d.ts","sourceRoot":"","sources":["../../controllers/Get_Account_Info.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;AAGjE,MAAM,CAAC,OAAO,UAAU,eAAe;;;;;;;;;;;QA8KjC,WAAW;QACX,OAAO;QACP,OAAO;QACP,OAAO;QACP,KAAK;;6BA5JuC,OAAO,CAAC,OAAO,CAAC;wCAwB3C,MAAM,KAAG,OAAO,CAAC,OAAO,CAAC;2BAuCA,OAAO,CAAC,OAAO,CAAC;yBAS9B,OAAO,CAAC,OAAO,CAAC;6BAmBZ,OAAO,CAAC,OAAO,CAAC;yBAgBpB,OAAO,CAAC,OAAO,CAAC;EA4DjD"}
|
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
import { type Provider } from "ethers";
|
|
2
|
+
export type TokenBalanceOptions = {
|
|
3
|
+
tokenAddress?: string;
|
|
4
|
+
rpcUrl?: string;
|
|
5
|
+
provider?: Provider;
|
|
6
|
+
fallbackProvider?: Provider;
|
|
7
|
+
expectedChainId?: number;
|
|
8
|
+
networkName?: string;
|
|
9
|
+
symbol?: string;
|
|
10
|
+
decimals?: number;
|
|
11
|
+
};
|
|
12
|
+
export type TokenBalanceResult = {
|
|
13
|
+
balance: string;
|
|
14
|
+
rawBalance: string;
|
|
15
|
+
symbol: string;
|
|
16
|
+
decimals: number;
|
|
17
|
+
network: string;
|
|
18
|
+
chainId: number;
|
|
19
|
+
};
|
|
20
|
+
/** Shared ERC-20 balance reader used by wallet status and the Cordy API. */
|
|
21
|
+
export declare function readTokenBalance(address: string, options?: TokenBalanceOptions): Promise<TokenBalanceResult>;
|
|
22
|
+
/** Legacy controller API kept for existing `useWalletStatus` and button callers. */
|
|
1
23
|
export default function getTokenBalance(address: string, decimals?: number): Promise<{
|
|
2
24
|
balance: string;
|
|
3
25
|
symbol: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Get_Balance.d.ts","sourceRoot":"","sources":["../../controllers/Get_Balance.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Get_Balance.d.ts","sourceRoot":"","sources":["../../controllers/Get_Balance.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqD,KAAK,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAG1F,MAAM,MAAM,mBAAmB,GAAG;IAChC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,gBAAgB,CAAC,EAAE,QAAQ,CAAC;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,4EAA4E;AAC5E,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,kBAAkB,CAAC,CAmF7B;AAED,oFAAoF;AACpF,wBAA8B,eAAe,CAC3C,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAQ9C"}
|