@cordystackx/cordy_minikit 0.3.1 → 0.3.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.
Files changed (54) hide show
  1. package/README.md +15 -88
  2. package/dist/chains/base__sepolia.d.ts +43 -0
  3. package/dist/chains/base__sepolia.d.ts.map +1 -0
  4. package/dist/chains/base__sepolia.js +30 -0
  5. package/dist/chains/core.d.ts +40 -0
  6. package/dist/chains/core.d.ts.map +1 -0
  7. package/dist/chains/core.js +27 -0
  8. package/dist/chains/index.d.ts +3 -0
  9. package/dist/chains/index.d.ts.map +1 -0
  10. package/dist/chains/index.js +3 -0
  11. package/dist/client__provider.d.ts +5 -0
  12. package/dist/client__provider.d.ts.map +1 -0
  13. package/dist/client__provider.jsx +9 -0
  14. package/dist/components/Connect_wallet_bt.d.ts +2 -0
  15. package/dist/components/Connect_wallet_bt.d.ts.map +1 -0
  16. package/dist/components/Connect_wallet_bt.jsx +11 -0
  17. package/dist/components/UI_Comp.d.ts +2 -0
  18. package/dist/components/UI_Comp.d.ts.map +1 -0
  19. package/dist/components/UI_Comp.jsx +69 -0
  20. package/dist/components/index.d.ts +3 -0
  21. package/dist/components/index.d.ts.map +1 -0
  22. package/dist/components/index.js +2 -0
  23. package/dist/config/ERC20_ABI.json +26 -0
  24. package/dist/config/Image.json +3 -0
  25. package/dist/config/walletConfig.d.ts +3 -0
  26. package/dist/config/walletConfig.d.ts.map +1 -0
  27. package/dist/config/walletConfig.js +16 -0
  28. package/dist/controllers/Disconnect.d.ts +2 -0
  29. package/dist/controllers/Disconnect.d.ts.map +1 -0
  30. package/dist/controllers/Disconnect.jsx +5 -0
  31. package/dist/controllers/Get_Balance.d.ts +2 -0
  32. package/dist/controllers/Get_Balance.d.ts.map +1 -0
  33. package/dist/controllers/Get_Balance.jsx +16 -0
  34. package/dist/controllers/Transactions.d.ts +2 -0
  35. package/dist/controllers/Transactions.d.ts.map +1 -0
  36. package/dist/controllers/Transactions.jsx +31 -0
  37. package/dist/controllers/WagmiButton.d.ts +8 -0
  38. package/dist/controllers/WagmiButton.d.ts.map +1 -0
  39. package/dist/controllers/WagmiButton.jsx +46 -0
  40. package/dist/controllers/index.d.ts +5 -0
  41. package/dist/controllers/index.d.ts.map +1 -0
  42. package/dist/controllers/index.js +4 -0
  43. package/dist/css/index.d.ts +4 -0
  44. package/dist/css/index.d.ts.map +1 -0
  45. package/dist/css/index.js +3 -0
  46. package/dist/index.d.ts +4 -24
  47. package/dist/index.d.ts.map +1 -0
  48. package/dist/index.js +6 -2321
  49. package/dist/tsconfig.tsbuildinfo +1 -0
  50. package/dist/wagmi__providers.d.ts +11 -0
  51. package/dist/wagmi__providers.d.ts.map +1 -0
  52. package/dist/wagmi__providers.jsx +28 -0
  53. package/package.json +38 -21
  54. package/dist/index.css +0 -132
package/README.md CHANGED
@@ -8,100 +8,27 @@ MiniKit CordyStack is my tiny, power-packed dev setup. Perfect for coding, hacki
8
8
  - Web3 & Next.js ready 🚀
9
9
  - Easy to customize
10
10
 
11
- ## Set Up
12
- 1. Create .env
13
-
14
- ```bash
15
- NEXT_PUBLIC_LINK_PROJECT_ID_SEPOLIA=
16
- NEXT_PUBLIC_PLATFORM_ADDRESS=
17
- NEXT_PUBLIC_TOKENADDRESS=
18
- NEXT_PUBLIC_SYMBOL=
19
- NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=
20
-
21
- ```
22
- Get your Sepolia Project ID here: https://portal.cdp.coinbase.com/
23
-
24
- Get your WalletConnect Project ID here: https://dashboard.reown.com/
25
-
26
- Create your own wallet using:
27
- * Based Extentions https://chromewebstore.google.com/detail/coinbase-wallet-extension/hnfanknocfeofbddgcijnmhnfnkdnaad?pli=1
28
-
29
- * MetaMask Extentions https://chromewebstore.google.com/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn
30
-
31
- Create your own token address using Hardhat or another Ethereum dev tool.
32
-
33
- 2. Create a file name providers.tsx
34
-
35
- ```bash
36
- import { ReactNode } from "react";
37
-
38
- import { ProvidersClientWrapper } from "@cordystackx/cordy_minikit";
39
- import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
40
-
41
- const queryClient = new QueryClient();
42
-
43
- export default function WalletProviders({ children }: { children: ReactNode }) {
44
-
45
- return(
46
- <QueryClientProvider client={queryClient}>
47
- <ProvidersClientWrapper>
48
- {children}
49
- </ProvidersClientWrapper>
50
- </QueryClientProvider>
51
- );
52
-
53
- }
54
- ```
55
- 3. Then Create client_wrapper.tsx
56
- ```bash
57
- 'use client';
58
- import { ReactNode } from 'react';
59
- import dynamic from 'next/dynamic';
60
-
61
- // Dynamically import WalletProviders with SSR disabled
62
- const WalletProviders = dynamic(() => import('./providers'), {
63
- ssr: false,
64
- });
65
-
66
- export default function ClientWrapper({ children }: { children: ReactNode }) {
67
- return <WalletProviders>{children}</WalletProviders>;
68
- }
69
-
70
- ```
71
- 4. Then inside your layout.tsx import all of the functions
11
+ ## Usage
12
+ 1. Import the Providers inside the layout.ts
72
13
  ```bash
73
- import { ClientWrapper } from "./client_wrapper";
74
- import '@cordystackx/cordy_minikit/dist/index.css';
14
+ import { ProvidersClientWrapper } from "@cordystackx/cordy_minikit";
15
+
16
+ <ProvidersClientWrapper>
17
+ {children}
18
+ </ProvidersClientWrapper>
75
19
 
76
- export default function RootLayout({
77
- children,
78
- }: Readonly<{
79
- children: React.ReactNode;
80
- }>) {
81
- return (
82
- <html lang="en">
83
- <body className={`${geistSans.variable} ${geistMono.variable}`}>
84
- <ClientWrapper>
85
- {children}
86
- </ClientWrapper>
87
- </body>
88
- </html>
89
- );
90
- }
91
20
  ```
92
-
93
- ## Usage
94
-
95
- ### Button Connect
21
+ 2. Use of Connect Buttons
96
22
  ```bash
97
- import { ConnectWalletBT } from "@cordystackx/cordy_minikit";
23
+ import { ConnectWalletBT } from "@cordystackx/cordy_minikit";
24
+
25
+ <ConnectWalletBT/>
98
26
 
99
- <ConnectWalletBT />
100
27
  ```
101
-
102
- ### Funtions Transactions
28
+ 2. Use of Transactions
103
29
  ```bash
104
- import { CordyStackTrans } from "@cordystackx/cordy_minikit";
30
+ import { CordyStackTrans } from "@cordystackx/cordy_minikit";
31
+
32
+ CordyStackTrans(address: string, cost: number | string);
105
33
 
106
- CordyStackTrans(address: string, cost: number | string)
107
34
  ```
@@ -0,0 +1,43 @@
1
+ export default function BaseSepolia(): {
2
+ blockExplorers: {
3
+ readonly default: {
4
+ readonly name: "Basescan";
5
+ readonly url: "https://sepolia.basescan.org";
6
+ };
7
+ };
8
+ blockTime?: number | undefined | undefined;
9
+ contracts?: {
10
+ [x: string]: import("viem").ChainContract | {
11
+ [sourceId: number]: import("viem").ChainContract | undefined;
12
+ } | undefined;
13
+ ensRegistry?: import("viem").ChainContract | undefined;
14
+ ensUniversalResolver?: import("viem").ChainContract | undefined;
15
+ multicall3?: import("viem").ChainContract | undefined;
16
+ erc6492Verifier?: import("viem").ChainContract | undefined;
17
+ } | undefined;
18
+ ensTlds?: readonly string[] | undefined;
19
+ id: 84532;
20
+ name: "Base Sepolia";
21
+ nativeCurrency: {
22
+ readonly name: "Base Sepolia Ether";
23
+ readonly symbol: "ETH";
24
+ readonly decimals: 18;
25
+ };
26
+ experimental_preconfirmationTime?: number | undefined | undefined;
27
+ rpcUrls: {
28
+ readonly default: {
29
+ readonly http: readonly [string];
30
+ };
31
+ readonly public: {
32
+ readonly http: readonly [string];
33
+ };
34
+ };
35
+ sourceId?: number | undefined | undefined;
36
+ testnet: true;
37
+ custom?: Record<string, unknown> | undefined;
38
+ fees?: import("viem").ChainFees<undefined> | undefined;
39
+ formatters?: undefined;
40
+ serializers?: import("viem").ChainSerializers<undefined, import("viem").TransactionSerializable> | undefined;
41
+ readonly network: "base-sepolia";
42
+ };
43
+ //# sourceMappingURL=base__sepolia.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base__sepolia.d.ts","sourceRoot":"","sources":["../../chains/base__sepolia.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+BlC"}
@@ -0,0 +1,30 @@
1
+ import { defineChain } from "viem";
2
+ export default function BaseSepolia() {
3
+ const baseSepolia = defineChain({
4
+ id: 84532,
5
+ name: 'Base Sepolia',
6
+ network: 'base-sepolia',
7
+ nativeCurrency: {
8
+ name: 'Base Sepolia Ether',
9
+ symbol: 'ETH',
10
+ decimals: 18,
11
+ },
12
+ rpcUrls: {
13
+ default: {
14
+ http: [
15
+ process.env.NEXT_PUBLIC_LINK_PROJECT_ID_SEPOLIA || "",
16
+ ],
17
+ },
18
+ public: {
19
+ http: [
20
+ process.env.NEXT_PUBLIC_LINK_PROJECT_ID_SEPOLIA || "",
21
+ ],
22
+ },
23
+ },
24
+ blockExplorers: {
25
+ default: { name: 'Basescan', url: 'https://sepolia.basescan.org' },
26
+ },
27
+ testnet: true,
28
+ });
29
+ return baseSepolia;
30
+ }
@@ -0,0 +1,40 @@
1
+ export default function CoreTestnet(): {
2
+ blockExplorers: {
3
+ readonly default: {
4
+ readonly name: "CoreScan";
5
+ readonly url: "https://scan.test2.btcs.network";
6
+ };
7
+ };
8
+ blockTime?: number | undefined | undefined;
9
+ contracts?: {
10
+ [x: string]: import("viem").ChainContract | {
11
+ [sourceId: number]: import("viem").ChainContract | undefined;
12
+ } | undefined;
13
+ ensRegistry?: import("viem").ChainContract | undefined;
14
+ ensUniversalResolver?: import("viem").ChainContract | undefined;
15
+ multicall3?: import("viem").ChainContract | undefined;
16
+ erc6492Verifier?: import("viem").ChainContract | undefined;
17
+ } | undefined;
18
+ ensTlds?: readonly string[] | undefined;
19
+ id: 1114;
20
+ name: "tCORE2";
21
+ nativeCurrency: {
22
+ readonly name: "tCORE2";
23
+ readonly symbol: "tCORE2";
24
+ readonly decimals: 18;
25
+ };
26
+ experimental_preconfirmationTime?: number | undefined | undefined;
27
+ rpcUrls: {
28
+ readonly default: {
29
+ readonly http: readonly ["https://rpc.test2.btcs.network"];
30
+ };
31
+ };
32
+ sourceId?: number | undefined | undefined;
33
+ testnet: true;
34
+ custom?: Record<string, unknown> | undefined;
35
+ fees?: import("viem").ChainFees<undefined> | undefined;
36
+ formatters?: undefined;
37
+ serializers?: import("viem").ChainSerializers<undefined, import("viem").TransactionSerializable> | undefined;
38
+ readonly network: "core-testnet";
39
+ };
40
+ //# sourceMappingURL=core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../chains/core.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4BlC"}
@@ -0,0 +1,27 @@
1
+ import { defineChain } from "viem";
2
+ export default function CoreTestnet() {
3
+ // Custom Chain
4
+ const coreTestnet = defineChain({
5
+ id: 1114,
6
+ name: 'tCORE2',
7
+ network: 'core-testnet',
8
+ nativeCurrency: {
9
+ name: 'tCORE2',
10
+ symbol: 'tCORE2',
11
+ decimals: 18,
12
+ },
13
+ rpcUrls: {
14
+ default: {
15
+ http: ['https://rpc.test2.btcs.network'],
16
+ },
17
+ },
18
+ blockExplorers: {
19
+ default: {
20
+ name: 'CoreScan',
21
+ url: 'https://scan.test2.btcs.network',
22
+ },
23
+ },
24
+ testnet: true,
25
+ });
26
+ return coreTestnet;
27
+ }
@@ -0,0 +1,3 @@
1
+ export { default as CoreTestnet } from './core';
2
+ export { default as BaseSepolia } from './base__sepolia';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../chains/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,QAAQ,CAAC;AAEhD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,3 @@
1
+ // Chains
2
+ export { default as CoreTestnet } from './core';
3
+ export { default as BaseSepolia } from './base__sepolia';
@@ -0,0 +1,5 @@
1
+ import { ReactNode } from 'react';
2
+ export default function ProvidersClientWrapper({ children }: {
3
+ children: ReactNode;
4
+ }): import("react").JSX.Element;
5
+ //# sourceMappingURL=client__provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client__provider.d.ts","sourceRoot":"","sources":["../client__provider.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAQlC,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,+BAEnF"}
@@ -0,0 +1,9 @@
1
+ 'use client';
2
+ import dynamic from 'next/dynamic';
3
+ // Dynamically import WalletProviders with SSR disabled
4
+ const WalletProviders = dynamic(() => import('./wagmi__providers'), {
5
+ ssr: false,
6
+ });
7
+ export default function ProvidersClientWrapper({ children }) {
8
+ return <WalletProviders>{children}</WalletProviders>;
9
+ }
@@ -0,0 +1,2 @@
1
+ export default function ConnectWalletBT(): import("react").JSX.Element;
2
+ //# sourceMappingURL=Connect_wallet_bt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Connect_wallet_bt.d.ts","sourceRoot":"","sources":["../../components/Connect_wallet_bt.tsx"],"names":[],"mappings":"AAKA,MAAM,CAAC,OAAO,UAAU,eAAe,gCAYtC"}
@@ -0,0 +1,11 @@
1
+ "use client";
2
+ import { Buttons__css } from "../css";
3
+ import { useWalletModal } from "../wagmi__providers";
4
+ import { useAccount } from "wagmi";
5
+ export default function ConnectWalletBT() {
6
+ const { openModal } = useWalletModal();
7
+ const { isConnected, address } = useAccount();
8
+ return (<button className={Buttons__css.button__button} onClick={openModal}>
9
+ {isConnected ? `Connected ${address}` : "Connect Wallet"}
10
+ </button>);
11
+ }
@@ -0,0 +1,2 @@
1
+ export default function UI_Comp(): import("react").JSX.Element;
2
+ //# sourceMappingURL=UI_Comp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UI_Comp.d.ts","sourceRoot":"","sources":["../../components/UI_Comp.tsx"],"names":[],"mappings":"AASA,MAAM,CAAC,OAAO,UAAU,OAAO,gCAmF9B"}
@@ -0,0 +1,69 @@
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
+ export default function UI_Comp() {
10
+ const { closeModal } = useWalletModal();
11
+ const { isConnected, address } = useAccount();
12
+ const [loading, setLoading] = useState(false);
13
+ const [errorMsg, setErrorMsg] = useState();
14
+ const [balance, setBalance] = useState("");
15
+ useEffect(() => {
16
+ Get_Balance();
17
+ }, [balance]);
18
+ const Get_Balance = async () => {
19
+ if (!address || !process.env.NEXT_PUBLIC_TOKENADDRESS)
20
+ return;
21
+ const balance = await getTokenBalance(address, process.env.NEXT_PUBLIC_TOKENADDRESS);
22
+ setBalance(balance);
23
+ return;
24
+ };
25
+ if (isConnected) {
26
+ if (balance === "") {
27
+ Get_Balance();
28
+ }
29
+ return (<div className={UI_Comp__css.container}>
30
+ <div className={UI_Comp__css.connector}>
31
+ <p className={UI_Comp__css.closed} onClick={closeModal}>✕</p>
32
+ {isConnected && (<div className={UI_Comp__css.info}>
33
+ {balance ? (<span>
34
+ <FaUser size={70}/>
35
+ <p style={{ color: "#0f0" }}>Connected</p>
36
+ <p style={{ color: "#0ff" }}>Balance: {Number(balance).toFixed(2)} {process.env.NEXT_PUBLIC_SYMBOL}</p>
37
+ <p style={{ color: "#ff0" }}>{address}</p>
38
+ </span>) : (<p style={{ color: "var(--foreground_wagmi)" }}>Loading balance...</p>)}
39
+
40
+ </div>)}
41
+
42
+ <Disconnect />
43
+ <a href="https://cordy-stack-x.vercel.app/">
44
+ Powered By CordyStackX
45
+ </a>
46
+
47
+ </div>
48
+ </div>);
49
+ }
50
+ return (<div className={UI_Comp__css.container}>
51
+ <div className={UI_Comp__css.connector}>
52
+ <p className={UI_Comp__css.closed} onClick={closeModal}>✕</p>
53
+ <img src={Image__src.logo} width={50} height={50}/>
54
+ <h2>Cordy MiniKit</h2>
55
+
56
+ <div>
57
+ <h3>{loading ? "Loading..." : ""}</h3>
58
+ <WalletButton onStatusChange={({ isPending, error }) => {
59
+ setLoading(isPending);
60
+ setErrorMsg(error);
61
+ }}/>
62
+ <p>{errorMsg}</p>
63
+ </div>
64
+ <a href="https://cordy-stack-x.vercel.app/">
65
+ Powered By CordyStackX
66
+ </a>
67
+ </div>
68
+ </div>);
69
+ }
@@ -0,0 +1,3 @@
1
+ export { default as UI_Comp } from "./UI_Comp";
2
+ export { default as ConnectWalletBT } from "./Connect_wallet_bt";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../components/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { default as UI_Comp } from "./UI_Comp";
2
+ export { default as ConnectWalletBT } from "./Connect_wallet_bt";
@@ -0,0 +1,26 @@
1
+ [
2
+ {
3
+ "constant": true,
4
+ "inputs": [{ "name": "owner", "type": "address" }],
5
+ "name": "balanceOf",
6
+ "outputs": [{ "name": "balance", "type": "uint256" }],
7
+ "type": "function"
8
+ },
9
+ {
10
+ "constant": false,
11
+ "inputs": [
12
+ { "name": "to", "type": "address" },
13
+ { "name": "value", "type": "uint256" }
14
+ ],
15
+ "name": "transfer",
16
+ "outputs": [{ "name": "", "type": "bool" }],
17
+ "type": "function"
18
+ },
19
+ {
20
+ "constant": true,
21
+ "inputs": [],
22
+ "name": "decimals",
23
+ "outputs": [{ "name": "", "type": "uint8" }],
24
+ "type": "function"
25
+ }
26
+ ]
@@ -0,0 +1,3 @@
1
+ {
2
+ "logo": "https://cordy-stack-x.vercel.app/logo.svg"
3
+ }
@@ -0,0 +1,3 @@
1
+ import { createConfig } from 'wagmi';
2
+ export declare const config: ReturnType<typeof createConfig>;
3
+ //# sourceMappingURL=walletConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"walletConfig.d.ts","sourceRoot":"","sources":["../../config/walletConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,YAAY,EAAE,MAAM,OAAO,CAAC;AAO3C,eAAO,MAAM,MAAM,EAAE,UAAU,CAAC,OAAO,YAAY,CAUjD,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { http, createConfig } from 'wagmi';
2
+ import { mainnet, base } from 'wagmi/chains';
3
+ import { walletConnect } from 'wagmi/connectors';
4
+ import { BaseSepolia } from "../chains";
5
+ const projectId = process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID;
6
+ export const config = createConfig({
7
+ chains: [mainnet, base, BaseSepolia()],
8
+ connectors: [
9
+ walletConnect({ projectId })
10
+ ],
11
+ transports: {
12
+ [mainnet.id]: http(),
13
+ [base.id]: http(),
14
+ [BaseSepolia().id]: http()
15
+ },
16
+ });
@@ -0,0 +1,2 @@
1
+ export default function Disconnect(): import("react").JSX.Element;
2
+ //# sourceMappingURL=Disconnect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Disconnect.d.ts","sourceRoot":"","sources":["../../controllers/Disconnect.tsx"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,UAAU,gCAMjC"}
@@ -0,0 +1,5 @@
1
+ import { useDisconnect } from 'wagmi';
2
+ export default function Disconnect() {
3
+ const { disconnect } = useDisconnect();
4
+ return (<button onClick={() => disconnect()}>Disconnect</button>);
5
+ }
@@ -0,0 +1,2 @@
1
+ export default function getTokenBalance(address: string, tokenAddress: string): Promise<string>;
2
+ //# sourceMappingURL=Get_Balance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Get_Balance.d.ts","sourceRoot":"","sources":["../../controllers/Get_Balance.tsx"],"names":[],"mappings":"AAGA,wBAA8B,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAcpG"}
@@ -0,0 +1,16 @@
1
+ import { ethers } from "ethers";
2
+ import ERC20_ABI from "../config/ERC20_ABI.json";
3
+ export default async function getTokenBalance(address, tokenAddress) {
4
+ if (!address)
5
+ return "0";
6
+ try {
7
+ const provider = new ethers.JsonRpcProvider(process.env.NEXT_PUBLIC_LINK_PROJECT_ID_SEPOLIA);
8
+ const contract = new ethers.Contract(tokenAddress, ERC20_ABI, provider);
9
+ const balance = await contract.balanceOf(address);
10
+ return ethers.formatUnits(balance, 18);
11
+ }
12
+ catch (err) {
13
+ console.error("Error fetching token balance:", err);
14
+ return "0";
15
+ }
16
+ }
@@ -0,0 +1,2 @@
1
+ export default function CordyStackTrans(address: string, cost: number | string): Promise<void>;
2
+ //# sourceMappingURL=Transactions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Transactions.d.ts","sourceRoot":"","sources":["../../controllers/Transactions.tsx"],"names":[],"mappings":"AAMA,wBAA8B,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,iBA4BnF"}
@@ -0,0 +1,31 @@
1
+ import { ethers, parseUnits } from 'ethers';
2
+ import tokenAbi from '../config/ERC20_ABI.json';
3
+ const tokenAddress = process.env.NEXT_PUBLIC_TOKENADDRESS || "";
4
+ const platformAddress = process.env.NEXT_PUBLIC_PLATFORM_ADDRESS || "";
5
+ export default async function CordyStackTrans(address, cost) {
6
+ if (!address)
7
+ return alert("Address Not Found");
8
+ try {
9
+ const provider = new ethers.BrowserProvider(window.ethereum);
10
+ const signer = await provider.getSigner();
11
+ const tokenContract = new ethers.Contract(tokenAddress, tokenAbi, signer);
12
+ const decimals = 18;
13
+ const amount = parseUnits(String(cost), decimals);
14
+ const balance = await tokenContract.balanceOf(await signer.getAddress());
15
+ if (balance < amount) {
16
+ return alert("Insuficient Funds");
17
+ }
18
+ const tx = await tokenContract.transfer(platformAddress, amount);
19
+ const receipt = await tx.wait();
20
+ if (receipt) {
21
+ return alert("Transactions Complete");
22
+ }
23
+ else {
24
+ return alert("Transaction Failed");
25
+ }
26
+ }
27
+ catch (err) {
28
+ console.error(err);
29
+ }
30
+ }
31
+ ;
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ export default function WalletButton({ onStatusChange, }: {
3
+ onStatusChange?: (status: {
4
+ isPending: boolean;
5
+ error?: string;
6
+ }) => void;
7
+ }): React.JSX.Element;
8
+ //# sourceMappingURL=WagmiButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WagmiButton.d.ts","sourceRoot":"","sources":["../../controllers/WagmiButton.tsx"],"names":[],"mappings":"AACA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAIzC,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,cAAc,GACf,EAAE;IACD,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CAC3E,qBAwCA"}
@@ -0,0 +1,46 @@
1
+ "use client";
2
+ import React, { useEffect } from "react";
3
+ import { useConnect } from "wagmi";
4
+ export default function WalletButton({ onStatusChange, }) {
5
+ const { connectors, connectAsync, status } = useConnect();
6
+ const [pendingConnector, setPendingConnector] = React.useState(null);
7
+ const [errorMsg, setErrorMsg] = React.useState();
8
+ // Derived isPending (true/false only)
9
+ const isPending = status === "pending";
10
+ // Notify parent whenever status changes
11
+ useEffect(() => {
12
+ if (onStatusChange) {
13
+ onStatusChange({
14
+ isPending,
15
+ error: errorMsg,
16
+ });
17
+ }
18
+ }, [isPending, errorMsg, onStatusChange]);
19
+ return (<>
20
+ {connectors.map((connector) => (<WalletOption key={connector.uid} connector={connector} onClick={async () => {
21
+ setPendingConnector(connector);
22
+ setErrorMsg(undefined); // reset old errors
23
+ try {
24
+ await connectAsync({ connector });
25
+ }
26
+ catch (err) {
27
+ setErrorMsg(err?.message || "Connection failed");
28
+ }
29
+ finally {
30
+ setPendingConnector(null);
31
+ }
32
+ }} isPending={pendingConnector?.uid === connector.uid && isPending}/>))}
33
+ </>);
34
+ }
35
+ function WalletOption({ connector, onClick, isPending, }) {
36
+ const [ready, setReady] = React.useState(false);
37
+ React.useEffect(() => {
38
+ (async () => {
39
+ const provider = await connector.getProvider();
40
+ setReady(!!provider);
41
+ })();
42
+ }, [connector]);
43
+ return (<button disabled={!ready || isPending} onClick={onClick}>
44
+ {isPending ? "Connecting..." : connector.name}
45
+ </button>);
46
+ }
@@ -0,0 +1,5 @@
1
+ export { default as WalletButton } from "./WagmiButton";
2
+ export { default as Disconnect } from "./Disconnect";
3
+ export { default as CordyStackTrans } from "./Transactions";
4
+ export { default as getTokenBalance } from "./Get_Balance";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../controllers/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,eAAe,CAAC;AAExD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAE5D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { default as WalletButton } from "./WagmiButton";
2
+ export { default as Disconnect } from "./Disconnect";
3
+ export { default as CordyStackTrans } from "./Transactions";
4
+ export { default as getTokenBalance } from "./Get_Balance";
@@ -0,0 +1,4 @@
1
+ import UI_Comp__css from "./UI_Comp/styles.module.css";
2
+ import Buttons__css from "./Buttons/styles.module.css";
3
+ export { Buttons__css, UI_Comp__css };
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../css/index.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,6BAA6B,CAAC;AAEvD,OAAO,YAAY,MAAM,6BAA6B,CAAC;AAEvD,OAAO,EACH,YAAY,EACZ,YAAY,EACf,CAAC"}
@@ -0,0 +1,3 @@
1
+ import UI_Comp__css from "./UI_Comp/styles.module.css";
2
+ import Buttons__css from "./Buttons/styles.module.css";
3
+ export { Buttons__css, UI_Comp__css };