@cordystackx/cordy_minikit 0.1.8 → 0.2.2

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.
@@ -1,18 +0,0 @@
1
- "use client";
2
- import { Buttons__css } from "../css";
3
- import { useWalletModal } from "../wagmi__providers";
4
- import { useAccount } from "wagmi";
5
-
6
- export default function ConnectWalletBT() {
7
- const { openModal } = useWalletModal();
8
- const { isConnected, address } = useAccount();
9
-
10
- return (
11
- <button
12
- className={Buttons__css.button__button}
13
- onClick={openModal}
14
- >
15
- {isConnected ? `Connected ${address}` : "Connect Wallet"}
16
- </button>
17
- );
18
- }
@@ -1,94 +0,0 @@
1
- "use client";
2
- import Image__src from "../config/Image.json";
3
- import { UI_Comp__css } from "../css";
4
- import { WalletButton, Disconnect, getTokenBalance } from "../controllers";
5
- import { useWalletModal } from "../wagmi__providers";
6
- import { useAccount } from "wagmi";
7
- import { FaUser } from 'react-icons/fa';
8
- import { useState, useEffect } from "react";
9
-
10
- export default function UI_Comp() {
11
- const { closeModal } = useWalletModal();
12
- const { isConnected, address } = useAccount();
13
- const [loading, setLoading] = useState(false);
14
- const [errorMsg, setErrorMsg] = useState<string>();
15
- const [balance, setBalance] = useState("");
16
-
17
- useEffect(() => {
18
-
19
- Get_Balance();
20
-
21
- }, [balance]);
22
-
23
- const Get_Balance = async () => {
24
-
25
- if (!address || !process.env.NEXT_PUBLIC_TOKENADDRESS) {
26
- throw new Error("Address or token address is undefined");
27
- }
28
- const balance = await getTokenBalance(address, process.env.NEXT_PUBLIC_TOKENADDRESS);
29
-
30
- setBalance(balance);
31
- return;
32
- };
33
-
34
- if (isConnected) {
35
-
36
- if (balance === "") {
37
- Get_Balance();
38
- }
39
-
40
- return(
41
- <div className={UI_Comp__css.container}>
42
- <div className={UI_Comp__css.connector}>
43
- <p className={UI_Comp__css.closed} onClick={closeModal}>✕</p>
44
- {isConnected && (
45
- <div className={UI_Comp__css.info}>
46
- {balance ? (
47
- <span>
48
- <FaUser size={70} />
49
- <p style={{color: "#0f0"}}>Connected</p>
50
- <p style={{color: "#0ff"}}>Balance: {Number(balance).toFixed(2)} {process.env.NEXT_PUBLIC_SYMBOL}</p>
51
- <p style={{color: "#ff0"}}>{address}</p>
52
- </span>
53
-
54
- ) : (
55
- <p style={{color: "var(--foreground_wagmi)"}}>Loading balance...</p>
56
- )}
57
-
58
- </div>
59
- )}
60
-
61
- <Disconnect />
62
- <a href="https://cordy-stack-x.vercel.app/">
63
- Powered By CordyStackX
64
- </a>
65
-
66
- </div>
67
- </div>
68
- );
69
- }
70
-
71
- return (
72
- <div className={UI_Comp__css.container}>
73
- <div className={UI_Comp__css.connector}>
74
- <p className={UI_Comp__css.closed} onClick={closeModal}>✕</p>
75
- <img src={Image__src.logo} width={50} height={50} />
76
- <h2>Cordy MiniKit</h2>
77
-
78
- <div>
79
- <h3>{loading ? "Loading..." : ""}</h3>
80
- <WalletButton
81
- onStatusChange={({ isPending, error }) => {
82
- setLoading(isPending);
83
- setErrorMsg(error);
84
- }}
85
- />
86
- <p>{errorMsg}</p>
87
- </div>
88
- <a href="https://cordy-stack-x.vercel.app/">
89
- Powered By CordyStackX
90
- </a>
91
- </div>
92
- </div>
93
- );
94
- }
@@ -1,5 +0,0 @@
1
-
2
-
3
- export { default as UI_Comp } from "./UI_Comp";
4
-
5
- export { default as ConnectWalletBT } from "./Connect_wallet_bt";
@@ -1,9 +0,0 @@
1
- import { useDisconnect } from 'wagmi';
2
-
3
- export default function Disconnect() {
4
- const { disconnect } = useDisconnect();
5
-
6
- return (
7
- <button onClick={() => disconnect()}>Disconnect</button>
8
- );
9
- }
@@ -1,18 +0,0 @@
1
- import { ethers } from "ethers";
2
- import ERC20_ABI from "../config/ERC20_ABI.json";
3
-
4
- export default async function getTokenBalance(address: string, tokenAddress: string): Promise<string> {
5
-
6
- if (!address) return "0";
7
-
8
- try {
9
- const provider = new ethers.JsonRpcProvider(process.env.NEXT_PUBLIC_LINK_PROJECT_ID_SEPOLIA);
10
- const contract = new ethers.Contract(tokenAddress, ERC20_ABI, provider);
11
- const balance = await contract.balanceOf(address);
12
- return ethers.formatUnits(balance, 18);
13
-
14
- } catch (err) {
15
- console.error("Error fetching token balance:", err);
16
- return "0";
17
- }
18
- }
@@ -1,35 +0,0 @@
1
- import { ethers, parseUnits } from 'ethers';
2
- import tokenAbi from '../config/ERC20_ABI.json';
3
-
4
- const tokenAddress = process.env.NEXT_PUBLIC_TOKENADDRESS || "";
5
- const platformAddress = process.env.NEXT_PUBLIC_PLATFORM_ADDRESS || "";
6
-
7
- export default async function CordyStackTrans(address: string, cost: number | string) {
8
-
9
- if (!address) return alert("Address Not Found");
10
-
11
- try {
12
- const provider = new ethers.BrowserProvider(window.ethereum);
13
- const signer = await provider.getSigner();
14
- const tokenContract = new ethers.Contract(tokenAddress, tokenAbi, signer);
15
-
16
- const decimals = 18;
17
- const amount = parseUnits(String(cost), decimals);
18
-
19
- const balance = await tokenContract.balanceOf(await signer.getAddress());
20
- if (balance < amount) {
21
- return alert("Insuficient Funds");
22
- }
23
-
24
- const tx = await tokenContract.transfer(platformAddress, amount);
25
- const receipt = await tx.wait();
26
-
27
- if (receipt) {
28
- return alert("Transactions Complete");
29
- } else {
30
- return alert("Transaction Failed");
31
- }
32
- } catch (err: unknown) {
33
- console.error(err);
34
- }
35
- };
@@ -1,75 +0,0 @@
1
- "use client";
2
- import React, { useEffect } from "react";
3
- import { useConnect } from "wagmi";
4
- import type { Connector } from "wagmi";
5
-
6
- export default function WalletButton({
7
- onStatusChange,
8
- }: {
9
- onStatusChange?: (status: { isPending: boolean; error?: string }) => void;
10
- }) {
11
- const { connectors, connectAsync, status } = useConnect();
12
- const [pendingConnector, setPendingConnector] = React.useState<Connector | null>(null);
13
- const [errorMsg, setErrorMsg] = React.useState<string | undefined>();
14
-
15
- // Derived isPending (true/false only)
16
- const isPending = status === "pending";
17
-
18
- // Notify parent whenever status changes
19
- useEffect(() => {
20
- if (onStatusChange) {
21
- onStatusChange({
22
- isPending,
23
- error: errorMsg,
24
- });
25
- }
26
- }, [isPending, errorMsg, onStatusChange]);
27
-
28
- return (
29
- <>
30
- {connectors.map((connector: Connector) => (
31
- <WalletOption
32
- key={connector.uid}
33
- connector={connector}
34
- onClick={async () => {
35
- setPendingConnector(connector);
36
- setErrorMsg(undefined); // reset old errors
37
- try {
38
- await connectAsync({ connector });
39
- } catch (err) {
40
- setErrorMsg((err as Error)?.message || "Connection failed");
41
- } finally {
42
- setPendingConnector(null);
43
- }
44
- }}
45
- isPending={pendingConnector?.uid === connector.uid && isPending}
46
- />
47
- ))}
48
- </>
49
- );
50
- }
51
-
52
- function WalletOption({
53
- connector,
54
- onClick,
55
- isPending,
56
- }: {
57
- connector: Connector;
58
- onClick: () => void;
59
- isPending: boolean;
60
- }) {
61
- const [ready, setReady] = React.useState(false);
62
-
63
- React.useEffect(() => {
64
- (async () => {
65
- const provider = await connector.getProvider();
66
- setReady(!!provider);
67
- })();
68
- }, [connector]);
69
-
70
- return (
71
- <button disabled={!ready || isPending} onClick={onClick}>
72
- {isPending ? "Connecting..." : connector.name}
73
- </button>
74
- );
75
- }
@@ -1,8 +0,0 @@
1
-
2
- export { default as WalletButton } from "./WagmiButton";
3
-
4
- export { default as Disconnect } from "./Disconnect";
5
-
6
- export { default as CordyStackTrans } from "./Transactions";
7
-
8
- export { default as getTokenBalance } from "./Get_Balance";
package/index.ts DELETED
@@ -1,10 +0,0 @@
1
-
2
- // Clients
3
- export { default as ProvidersClientWrapper } from "./client__provider";
4
-
5
-
6
- //Components
7
- export * from "./components";
8
-
9
- //Controllers
10
- export * from "./controllers";