Skip to content

Commit b5a30df

Browse files
authored
Merge pull request #12 from Apillon/develop
Updated packages, ethers replaced with wagmi/viem, added Embedded wal…
2 parents 67ad884 + 2537cfb commit b5a30df

39 files changed

+8849
-12535
lines changed

.env

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
# Paste the address of the NFT collection.
2-
VITE_CONTRACT_ADDRESS=
31

4-
# Uncomment the chain you are using:
5-
# Moonbase
6-
VITE_CHAIN_ID=0x507
7-
8-
# Moonbeam
9-
# VITE_CHAIN_ID=0x504
10-
11-
# Astar
12-
# VITE_CHAIN_ID=0x250
2+
VITE_CHAIN_ID=1287
3+
VITE_CONTRACT_ADDRESS=0x8Bd4ACcE018db9F2F7fDc635a0c5c8e22D56aD11
4+
VITE_IMG_LOGO='https://eu1.web3approved.com/ipfs/bafybeieedfxw22oay6vhuedcabtulzmibnwv63we3zqmlc7uz4r4ha5fve/?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjaWQiOiJiYWZ5YmVpZWVkZnh3MjJvYXk2dmh1ZWRjYWJ0dWx6bWlibnd2NjN3ZTN6cW1sYzd1ejRyNGhhNWZ2ZSIsInByb2plY3RfdXVpZCI6ImY2N2RkOTlhLTY5ZDEtNGY2Zi05Y2QzLWYwYWMyZDdmYWRjNCIsImlhdCI6MTc0NzA0NTY3OCwic3ViIjoiSVBGUy10b2tlbiJ9.jCP7GpAgHWhb-dv3YFR5EoQ2jqer6g0ExN7hRhbg7Xg'
5+
VITE_IMG_COVER='https://eu1.web3approved.com/ipfs/bafybeibq4iekgwetrnkb6fkrihx7mgxnvdwtl3ly3r4mrb5a473pixheoa/?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjaWQiOiJiYWZ5YmVpYnE0aWVrZ3dldHJua2I2ZmtyaWh4N21neG52ZHd0bDNseTNyNG1yYjVhNDczcGl4aGVvYSIsInByb2plY3RfdXVpZCI6ImY2N2RkOTlhLTY5ZDEtNGY2Zi05Y2QzLWYwYWMyZDdmYWRjNCIsImlhdCI6MTc0NzA0NTY3OCwic3ViIjoiSVBGUy10b2tlbiJ9.prqYcSc8ISfJfBA_72A1nrL4RgIz99g3x2WVpooSCGM'
6+
VITE_EMBEDDED_WALLET_CLIENT=0abc5bd9-d804-4f46-89d8-b16ccbdd5300

package-lock.json

Lines changed: 7052 additions & 10435 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010
"preview": "vite preview"
1111
},
1212
"dependencies": {
13-
"@tanstack/react-query": "^5.66.0",
14-
"ethers": "^5.5.4",
15-
"react": "^19.0.0",
16-
"react-dom": "^19.0.0",
17-
"react-modal": "^3.16.3",
13+
"@apillon/wallet-react": "^2.1.2",
14+
"@tanstack/react-query": "^5.76.1",
15+
"react": "^18.2.0",
16+
"react-dom": "^18.2.0",
17+
"react-modal": "^3.16.1",
1818
"react-toastify": "^9.1.3",
19-
"react-tooltip": "^5.21.1"
19+
"react-tooltip": "^5.21.1",
20+
"viem": "^2.29.4",
21+
"wagmi": "^2.15.4"
2022
},
2123
"devDependencies": {
2224
"@biomejs/biome": "^1.1.2",
@@ -25,17 +27,17 @@
2527
"@types/react-dom": "^18.2.7",
2628
"@types/react-modal": "^3.16.3",
2729
"@vitejs/plugin-react": "^4.1.0",
28-
"@wagmi/cli": "^2.1.0",
29-
"autoprefixer": "^10.4.17",
30+
"autoprefixer": "^10.4.21",
3031
"buffer": "^6.0.3",
3132
"eslint": "^8.56.0",
3233
"eslint-config-prettier": "^9.1.0",
3334
"eslint-config-standard": "^17.1.0",
3435
"eslint-plugin-prettier": "^5.1.3",
35-
"postcss": "^8.4.35",
36+
"postcss": "^8.5.3",
3637
"prettier": "^3.2.5",
37-
"tailwindcss": "^3.4.1",
38+
"tailwindcss": "^3.4.17",
3839
"typescript": "^5.2.2",
39-
"vite": "^4.4.9"
40+
"vite": "^6.3.5",
41+
"vite-plugin-mkcert": "^1.17.8"
4042
}
4143
}

postcss.config.cjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
module.exports = {
22
plugins: {
3-
'tailwindcss/nesting': {},
43
tailwindcss: {},
54
autoprefixer: {},
65
},
Lines changed: 11 additions & 0 deletions
Loading
Lines changed: 43 additions & 0 deletions
Loading
Lines changed: 12 additions & 0 deletions
Loading

src/App.tsx

Lines changed: 114 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,119 @@
1-
import Main from './components/Main'
2-
import Web3ContextProvider from './context/Web3Context'
1+
import { useEffect, useMemo, useState } from 'react';
2+
import { type Events } from '@apillon/wallet-sdk';
3+
import { useWallet } from '@apillon/wallet-react';
4+
import { useWeb3Context } from './context/Web3Context';
5+
import { useContract } from './hooks/useContract';
6+
import { useWalletConnect } from './hooks/useWalletConnect';
7+
import { useNft } from './hooks/useNft';
8+
import Btn from './components/Btn';
9+
import NftGallery from './components/Nft/NftGallery';
10+
import CollectionInfo from './components/CollectionInfo';
11+
import WalletConnect from './components/WalletConnect';
12+
import Spinner from './components/Spinner';
13+
import { toast } from 'react-toastify';
314

415
function App() {
16+
const { collectionInfo, filterByAddress, loadingNfts, nfts, myNftIDs } = useWeb3Context();
17+
const { loadCollectionInfo } = useContract();
18+
const { wallet } = useWallet();
19+
const { connected } = useWalletConnect();
20+
const { getNfts, showNfts, showMyNfts } = useNft();
21+
const [myNfts, setMyNfts] = useState(false);
22+
23+
const filteredNfts = useMemo(() => {
24+
if (!filterByAddress) {
25+
return Object.values(nfts);
26+
}
27+
return Object.values(nfts).filter((nft) => myNftIDs.includes(nft.id));
28+
}, [nfts, filterByAddress]);
29+
30+
useEffect(() => {
31+
loadCollectionInfo();
32+
}, []);
33+
34+
useEffect(() => {
35+
if (connected) {
36+
getNfts();
37+
loadCollectionInfo();
38+
}
39+
}, [connected]);
40+
41+
useEffect(() => {
42+
if (myNfts) {
43+
showMyNfts();
44+
} else {
45+
showNfts();
46+
}
47+
}, [myNfts]);
48+
49+
useEffect(() => {
50+
if (wallet?.events) {
51+
wallet.events.on('addTokenStatus', ({ success }: Events['addTokenStatus']) => {
52+
success
53+
? toast.success(`NFT successfully imported into the wallet!`)
54+
: toast.info('If you want to import NFT to wallet, paste contract address and token ID into your wallet.');
55+
});
56+
}
57+
}, [wallet]);
58+
559
return (
6-
<Web3ContextProvider>
7-
<Main />
8-
</Web3ContextProvider>
9-
)
60+
<div>
61+
<div className='relative flex flex-col justify-between gap-4 overflow-hidden rounded-xl bg-white p-8 text-center mobile:pt-14'>
62+
<CollectionInfo />
63+
64+
<div className='absolute right-[10px] top-[10px] flex flex-col items-end'>
65+
<WalletConnect />
66+
</div>
67+
</div>
68+
69+
{connected && collectionInfo?.name && (
70+
<div className='max-w-lg mx-auto my-12'>
71+
<h3>
72+
The collection you are viewing supports nesting NFTs you own. To setup the nested relationship between NFTs,
73+
you first have to own them.
74+
</h3>
75+
<strong>Instructions:</strong>
76+
<ol>
77+
<li>Mint one or multiple NFTs</li>
78+
<li>Once minted, click on “My NFTs”</li>
79+
<li>The NFTs you own will be displayed</li>
80+
</ol>
81+
</div>
82+
)}
83+
84+
{connected && collectionInfo?.name && (
85+
<div className='mb-6'>
86+
<h2 className='text-center'>Show NFTs:</h2>
87+
<div className='flex justify-center items-center gap-2'>
88+
<Btn loading={loadingNfts && !filterByAddress} disabled={false} onClick={() => setMyNfts(false)}>
89+
All nfts
90+
</Btn>
91+
<Btn loading={loadingNfts && filterByAddress} disabled={false} onClick={() => setMyNfts(true)}>
92+
My nfts
93+
</Btn>
94+
</div>
95+
</div>
96+
)}
97+
98+
{connected && (
99+
<div>
100+
{(() => {
101+
if (loadingNfts) {
102+
return <Spinner />;
103+
} else if (Number(collectionInfo.totalSupply) === 0) {
104+
return <h2 className='text-center'>No NFTs, they must be minted first.</h2>;
105+
} else if (filterByAddress && !filteredNfts.length) {
106+
return <h2 className='text-center'>You don`t have any NFTs</h2>;
107+
} else if (!filteredNfts.length) {
108+
return <h2 className='text-center'>No NFTs, they must be minted first.</h2>;
109+
} else {
110+
return <NftGallery nfts={filteredNfts} />;
111+
}
112+
})()}
113+
</div>
114+
)}
115+
</div>
116+
);
10117
}
11118

12-
export default App
119+
export default App;

0 commit comments

Comments
 (0)