@cordystackx/cordy_minikit 0.1.7
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 +34 -0
- package/chains/base__sepolia.ts +34 -0
- package/chains/core.ts +31 -0
- package/chains/index.ts +6 -0
- package/client__provider.tsx +12 -0
- package/components/Connect_wallet_bt.tsx +18 -0
- package/components/UI_Comp.tsx +94 -0
- package/components/index.ts +5 -0
- package/config/ERC20_ABI.json +26 -0
- package/config/Image.json +3 -0
- package/config/walletConfig.ts +18 -0
- package/controllers/Disconnect.tsx +9 -0
- package/controllers/Get_Balance.tsx +18 -0
- package/controllers/Transactions.tsx +35 -0
- package/controllers/WagmiButton.tsx +75 -0
- package/controllers/index.ts +8 -0
- package/css/Buttons/styles.module.css +40 -0
- package/css/UI_Comp/styles.module.css +99 -0
- package/css/index.ts +9 -0
- package/index.ts +10 -0
- package/package.json +18 -0
- package/wagmi__providers.tsx +41 -0
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# MiniKit CordyStack NPM Packages 😎
|
|
2
|
+
|
|
3
|
+
MiniKit CordyStack is my tiny, power-packed dev setup. Perfect for coding, hacking, and stacking cool stuff.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
- Lightweight & minimal
|
|
7
|
+
- Optimized for Arch Linux 🐧
|
|
8
|
+
- Web3 & Next.js ready 🚀
|
|
9
|
+
- Easy to customize
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
1. Import the Providers inside the layout.ts
|
|
13
|
+
```bash
|
|
14
|
+
import { ProvidersClientWrapper } from "@cordystackx/cordy_minikit";
|
|
15
|
+
|
|
16
|
+
<ProvidersClientWrapper>
|
|
17
|
+
{children}
|
|
18
|
+
</ProvidersClientWrapper>
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
2. Use of Connect Buttons
|
|
22
|
+
```bash
|
|
23
|
+
import { ConnectWalletBT } from "@cordystackx/cordy_minikit";
|
|
24
|
+
|
|
25
|
+
<ConnectWalletBT/>
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
2. Use of Transactions
|
|
29
|
+
```bash
|
|
30
|
+
import { CordyStackTrans } from "@cordystackx/cordy_minikit";
|
|
31
|
+
|
|
32
|
+
CordyStackTrans(address: string, cost: number | string);
|
|
33
|
+
|
|
34
|
+
```
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { defineChain } from "viem";
|
|
2
|
+
|
|
3
|
+
export default function BaseSepolia() {
|
|
4
|
+
const baseSepolia = defineChain({
|
|
5
|
+
id: 84532,
|
|
6
|
+
name: 'Base Sepolia',
|
|
7
|
+
network: 'base-sepolia',
|
|
8
|
+
nativeCurrency: {
|
|
9
|
+
name: 'Base Sepolia Ether',
|
|
10
|
+
symbol: 'ETH',
|
|
11
|
+
decimals: 18,
|
|
12
|
+
},
|
|
13
|
+
rpcUrls: {
|
|
14
|
+
default: {
|
|
15
|
+
http: [
|
|
16
|
+
process.env.NEXT_PUBLIC_LINK_PROJECT_ID_SEPOLIA || "",
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
public: {
|
|
20
|
+
http: [
|
|
21
|
+
process.env.NEXT_PUBLIC_LINK_PROJECT_ID_SEPOLIA || "",
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
blockExplorers: {
|
|
26
|
+
default: { name: 'Basescan', url: 'https://sepolia.basescan.org' },
|
|
27
|
+
},
|
|
28
|
+
testnet: true,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
return baseSepolia;
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
}
|
package/chains/core.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { defineChain } from "viem";
|
|
2
|
+
|
|
3
|
+
export default function CoreTestnet() {
|
|
4
|
+
// Custom Chain
|
|
5
|
+
const coreTestnet = defineChain({
|
|
6
|
+
id: 1114,
|
|
7
|
+
name: 'tCORE2',
|
|
8
|
+
network: 'core-testnet',
|
|
9
|
+
nativeCurrency: {
|
|
10
|
+
name: 'tCORE2',
|
|
11
|
+
symbol: 'tCORE2',
|
|
12
|
+
decimals: 18,
|
|
13
|
+
},
|
|
14
|
+
rpcUrls: {
|
|
15
|
+
default: {
|
|
16
|
+
http: ['https://rpc.test2.btcs.network'],
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
blockExplorers: {
|
|
20
|
+
default: {
|
|
21
|
+
name: 'CoreScan',
|
|
22
|
+
url: 'https://scan.test2.btcs.network',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
testnet: true,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
return coreTestnet;
|
|
30
|
+
|
|
31
|
+
}
|
package/chains/index.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import dynamic from 'next/dynamic';
|
|
4
|
+
|
|
5
|
+
// Dynamically import WalletProviders with SSR disabled
|
|
6
|
+
const WalletProviders = dynamic(() => import('./wagmi__providers'), {
|
|
7
|
+
ssr: false,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export default function ProvidersClientWrapper({ children }: { children: ReactNode }) {
|
|
11
|
+
return <WalletProviders>{children}</WalletProviders>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
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
|
+
}
|
|
@@ -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,18 @@
|
|
|
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
|
+
|
|
6
|
+
const projectId = process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID!;
|
|
7
|
+
|
|
8
|
+
export const config = createConfig({
|
|
9
|
+
chains: [mainnet, base, BaseSepolia()],
|
|
10
|
+
connectors: [
|
|
11
|
+
walletConnect({ projectId })
|
|
12
|
+
],
|
|
13
|
+
transports: {
|
|
14
|
+
[mainnet.id]: http(),
|
|
15
|
+
[base.id]: http(),
|
|
16
|
+
[BaseSepolia().id]: http()
|
|
17
|
+
},
|
|
18
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--foreground_wagmi: #171717;
|
|
3
|
+
--background_wagmi: #FAFAFA;
|
|
4
|
+
--invert-cordy-image: invert(1);
|
|
5
|
+
--invert-cordy-image_1: invert(0);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
@media (prefers-color-scheme: dark) {
|
|
9
|
+
:root {
|
|
10
|
+
--foreground_wagmi: #ededed;
|
|
11
|
+
--background_wagmi: #121212;
|
|
12
|
+
--invert-cordy-image: invert(0);
|
|
13
|
+
--invert-cordy-image_1: invert(1);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.button__button {
|
|
18
|
+
width: 150px;
|
|
19
|
+
padding: 0.8rem;
|
|
20
|
+
background-color: var(--foreground_wagmi);
|
|
21
|
+
color: var(--background_wagmi);
|
|
22
|
+
font-weight: bold;
|
|
23
|
+
cursor: pointer;
|
|
24
|
+
border: transparent;
|
|
25
|
+
transition: all 0.5s ease-in-out;
|
|
26
|
+
overflow: hidden;
|
|
27
|
+
white-space: nowrap;
|
|
28
|
+
text-overflow: ellipsis;
|
|
29
|
+
text-align: center;
|
|
30
|
+
}
|
|
31
|
+
.button__button img {
|
|
32
|
+
filter: var(--invert-cordy-image_1);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.button__button:hover {
|
|
36
|
+
opacity: 0.5;
|
|
37
|
+
}
|
|
38
|
+
.button__button:active {
|
|
39
|
+
transform: scale(0.6);
|
|
40
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
.container,
|
|
2
|
+
.connector,
|
|
3
|
+
.connector div,
|
|
4
|
+
.info,
|
|
5
|
+
.info span {
|
|
6
|
+
display: flex;
|
|
7
|
+
justify-content: center;
|
|
8
|
+
align-items: center;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.container {
|
|
12
|
+
width: 100dvw;
|
|
13
|
+
height: 100dvh;
|
|
14
|
+
backdrop-filter: blur(10px);
|
|
15
|
+
z-index: 999;
|
|
16
|
+
position: fixed;
|
|
17
|
+
top: 50%;
|
|
18
|
+
left: 50%;
|
|
19
|
+
transform: translate(-50%, -50%);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.connector {
|
|
23
|
+
width: min(400px, 100dvw);
|
|
24
|
+
height: 500px;
|
|
25
|
+
background-color: var(--background_wagmi);
|
|
26
|
+
position: fixed;
|
|
27
|
+
border: 2px solid var(--foreground_wagmi);
|
|
28
|
+
flex-flow: column;
|
|
29
|
+
overflow: hidden;
|
|
30
|
+
animation: fadeIn 0.5s ease forwards;
|
|
31
|
+
}
|
|
32
|
+
.connector div {
|
|
33
|
+
flex-flow: column;
|
|
34
|
+
padding: 1rem 0;
|
|
35
|
+
width: 90%;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.connector div p {
|
|
39
|
+
color: #f00;
|
|
40
|
+
text-align: center;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@keyframes fadeIn {
|
|
44
|
+
from {
|
|
45
|
+
opacity: 0;
|
|
46
|
+
transform: scale(0.9);
|
|
47
|
+
}
|
|
48
|
+
to {
|
|
49
|
+
opacity: 1;
|
|
50
|
+
transform: scale(1);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
.connector img {
|
|
54
|
+
margin: 1rem 0;
|
|
55
|
+
filter: var(--invert-cordy-image);
|
|
56
|
+
}
|
|
57
|
+
.connector button {
|
|
58
|
+
width: 300px;
|
|
59
|
+
padding: 1rem;
|
|
60
|
+
background-color: var(--foreground_wagmi);
|
|
61
|
+
color: var(--background_wagmi);
|
|
62
|
+
font-weight: bold;
|
|
63
|
+
cursor: pointer;
|
|
64
|
+
border: transparent;
|
|
65
|
+
transition: all 0.5s ease;
|
|
66
|
+
margin: 1rem 0;
|
|
67
|
+
transition: all 0.5s ease-in-out;
|
|
68
|
+
}
|
|
69
|
+
.connector button:hover {
|
|
70
|
+
opacity: 0.5;
|
|
71
|
+
}
|
|
72
|
+
.connector button:active {
|
|
73
|
+
transform: scale(0.5);
|
|
74
|
+
}
|
|
75
|
+
.info span {
|
|
76
|
+
flex-flow: column;
|
|
77
|
+
}
|
|
78
|
+
.info span p {
|
|
79
|
+
width: 80%;
|
|
80
|
+
overflow: hidden;
|
|
81
|
+
white-space: nowrap;
|
|
82
|
+
text-overflow: ellipsis;
|
|
83
|
+
margin: 1rem 0;
|
|
84
|
+
font-weight: bolder;
|
|
85
|
+
}
|
|
86
|
+
.closed {
|
|
87
|
+
padding: 1rem;
|
|
88
|
+
position: absolute;
|
|
89
|
+
top: 0;
|
|
90
|
+
right: 0;
|
|
91
|
+
font-weight: bolder;
|
|
92
|
+
cursor: pointer;
|
|
93
|
+
}
|
|
94
|
+
@media (max-width: 800px) {
|
|
95
|
+
.connector {
|
|
96
|
+
bottom: 0;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
package/css/index.ts
ADDED
package/index.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cordystackx/cordy_minikit",
|
|
3
|
+
"version": "0.1.7",
|
|
4
|
+
"main": "index.ts",
|
|
5
|
+
"peerDependencies": {
|
|
6
|
+
"react": ">=19",
|
|
7
|
+
"wagmi": ">=2",
|
|
8
|
+
"viem": ">=2",
|
|
9
|
+
"ethers": ">=6"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/cordystackx/cordy_portfolio.git"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext, useContext, useState, ReactNode } from "react";
|
|
3
|
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
4
|
+
import { WagmiProvider } from "wagmi";
|
|
5
|
+
import { config } from "./config/walletConfig";
|
|
6
|
+
import { UI_Comp } from "./components";
|
|
7
|
+
|
|
8
|
+
type WalletContextType = {
|
|
9
|
+
openModal: () => void;
|
|
10
|
+
closeModal: () => void;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const WalletContext = createContext<WalletContextType | null>(null);
|
|
14
|
+
|
|
15
|
+
const queryClient = new QueryClient();
|
|
16
|
+
|
|
17
|
+
export default function WalletProviders({ children }: { children: ReactNode }) {
|
|
18
|
+
const [open, setOpen] = useState(false);
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<WagmiProvider config={config}>
|
|
22
|
+
<QueryClientProvider client={queryClient}>
|
|
23
|
+
<WalletContext.Provider
|
|
24
|
+
value={{
|
|
25
|
+
openModal: () => setOpen(true),
|
|
26
|
+
closeModal: () => setOpen(false),
|
|
27
|
+
}}
|
|
28
|
+
>
|
|
29
|
+
{children}
|
|
30
|
+
{open && <UI_Comp />} {/* show modal only when open */}
|
|
31
|
+
</WalletContext.Provider>
|
|
32
|
+
</QueryClientProvider>
|
|
33
|
+
</WagmiProvider>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function useWalletModal() {
|
|
38
|
+
const ctx = useContext(WalletContext);
|
|
39
|
+
if (!ctx) throw new Error("Wrap in <WalletProviders>");
|
|
40
|
+
return ctx;
|
|
41
|
+
}
|