@cordystackx/cordy_minikit 0.7.6 → 0.7.8

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 CHANGED
@@ -67,7 +67,6 @@ root
67
67
  ```bash
68
68
  NEXT_PUBLIC_RPC_ENDPOINT=
69
69
  NEXT_PUBLIC_TOKENADDRESS=
70
- NEXT_PUBLIC_SYMBOL=
71
70
  NEXT_PUBLIC_PLATFORM_ADDRESS=
72
71
  NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=
73
72
  ```
@@ -1 +1 @@
1
- {"version":3,"file":"UI_Comp.d.ts","sourceRoot":"","sources":["../../components/UI_Comp.tsx"],"names":[],"mappings":"AASA,MAAM,CAAC,OAAO,UAAU,OAAO,4CAoF9B"}
1
+ {"version":3,"file":"UI_Comp.d.ts","sourceRoot":"","sources":["../../components/UI_Comp.tsx"],"names":[],"mappings":"AASA,MAAM,CAAC,OAAO,UAAU,OAAO,4CAsF9B"}
@@ -13,21 +13,23 @@ export default function UI_Comp() {
13
13
  const [loading, setLoading] = useState(false);
14
14
  const [errorMsg, setErrorMsg] = useState();
15
15
  const [balance, setBalance] = useState("");
16
+ const [symbol, setSymbol] = useState("");
16
17
  useEffect(() => {
17
18
  Get_Balance();
18
19
  }, [balance]);
19
20
  const Get_Balance = async () => {
20
21
  if (!address || !process.env.NEXT_PUBLIC_TOKENADDRESS)
21
22
  return;
22
- const balance = await getTokenBalance(address, process.env.NEXT_PUBLIC_TOKENADDRESS);
23
+ const { balance, symbol } = await getTokenBalance(address, process.env.NEXT_PUBLIC_TOKENADDRESS);
23
24
  setBalance(balance);
25
+ setSymbol(symbol);
24
26
  return;
25
27
  };
26
28
  if (isConnected) {
27
29
  if (balance === "") {
28
30
  Get_Balance();
29
31
  }
30
- return (_jsx("div", { className: UI_Comp__css.container, children: _jsxs("div", { className: UI_Comp__css.connector, children: [_jsx("p", { className: UI_Comp__css.closed, onClick: closeModal, children: "\u2715" }), isConnected && (_jsx("div", { className: UI_Comp__css.info, children: balance ? (_jsxs("span", { children: [_jsx(FaUser, { size: 70 }), "chainchain", _jsx("p", { style: { color: "#0f0" }, children: "Connected" }), _jsxs("p", { style: { color: "#f0f" }, children: ["Network: ", chain?.name || "Unknown"] }), _jsxs("p", { style: { color: "#0ff" }, children: ["Balance: ", Number(balance).toFixed(2), " ", process.env.NEXT_PUBLIC_SYMBOL] }), _jsx("p", { style: { color: "#ff0" }, children: address })] })) : (_jsx("p", { style: { color: "var(--foreground_wagmi)" }, children: "Loading balance..." })) })), _jsx(Disconnect, {}), _jsx("a", { href: "https://cordy-stack-x.vercel.app/", children: "Powered By CordyStackX" })] }) }));
32
+ return (_jsx("div", { className: UI_Comp__css.container, children: _jsxs("div", { className: UI_Comp__css.connector, children: [_jsx("p", { className: UI_Comp__css.closed, onClick: closeModal, children: "\u2715" }), isConnected && (_jsx("div", { className: UI_Comp__css.info, children: balance ? (_jsxs("span", { children: [_jsx(FaUser, { size: 70 }), _jsx("p", { style: { color: "#0f0" }, children: "Connected" }), _jsxs("p", { style: { color: "#f0f" }, children: ["Network: ", chain?.name || "Unknown"] }), _jsxs("p", { style: { color: "#0ff" }, children: ["Balance: ", Number(balance).toFixed(2), " ", symbol] }), _jsx("p", { style: { color: "#ff0" }, children: address })] })) : (_jsx("p", { style: { color: "var(--foreground_wagmi)" }, children: "Loading balance..." })) })), _jsx(Disconnect, {}), _jsx("a", { href: "https://cordy-stack-x.vercel.app/", children: "Powered By CordyStackX" })] }) }));
31
33
  }
32
34
  return (_jsx("div", { className: UI_Comp__css.container, children: _jsxs("div", { className: UI_Comp__css.connector, children: [_jsx("p", { className: UI_Comp__css.closed, onClick: closeModal, children: "\u2715" }), _jsx("img", { src: Image__src.logo, width: 50, height: 50 }), _jsx("h2", { children: "Cordy MiniKit" }), _jsxs("div", { children: [_jsx("h3", { children: loading ? "Loading..." : "" }), _jsx(WalletButton, { onStatusChange: ({ isPending, error }) => {
33
35
  setLoading(isPending);
@@ -1,2 +1,5 @@
1
- export default function getTokenBalance(address: string, tokenAddress: string, decimals?: number): Promise<string>;
1
+ export default function getTokenBalance(address: string, tokenAddress: string, decimals?: number): Promise<{
2
+ balance: string;
3
+ symbol: string;
4
+ }>;
2
5
  //# sourceMappingURL=Get_Balance.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Get_Balance.d.ts","sourceRoot":"","sources":["../../controllers/Get_Balance.tsx"],"names":[],"mappings":"AAGA,wBAA8B,eAAe,CAC3C,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,QAAQ,GAAE,MAAW,mBAYtB"}
1
+ {"version":3,"file":"Get_Balance.d.ts","sourceRoot":"","sources":["../../controllers/Get_Balance.tsx"],"names":[],"mappings":"AAGA,wBAA8B,eAAe,CAC3C,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,QAAQ,GAAE,MAAW;;;GAuBtB"}
@@ -4,11 +4,21 @@ export default async function getTokenBalance(address, tokenAddress, decimals =
4
4
  try {
5
5
  const provider = new ethers.JsonRpcProvider(process.env.NEXT_PUBLIC_RPC_ENDPOINT);
6
6
  const contract = new ethers.Contract(tokenAddress, ERC20_ABI, provider);
7
+ // Fetch balance
7
8
  const balance = await contract.balanceOf(address);
8
- return ethers.formatUnits(balance, decimals);
9
+ const formattedBalance = ethers.formatUnits(balance, decimals);
10
+ // Fetch token symbol
11
+ let symbol;
12
+ try {
13
+ symbol = await contract.symbol();
14
+ }
15
+ catch {
16
+ symbol = ""; // fallback if the contract doesn't implement symbol()
17
+ }
18
+ return { balance: formattedBalance, symbol };
9
19
  }
10
20
  catch (err) {
11
21
  console.error("Error fetching token balance:", err);
12
- return "0";
22
+ return { balance: "0", symbol: "" };
13
23
  }
14
24
  }