Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fix for duplicate mintToken function on index.js #28

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions .vscode/extensions.json

This file was deleted.

2 changes: 2 additions & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*

.vercel
41 changes: 41 additions & 0 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"lodash": "^4.17.21",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
Expand Down Expand Up @@ -38,5 +39,8 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"prettier": "2.5.1"
}
}
66 changes: 62 additions & 4 deletions app/src/App.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,77 @@
import React from 'react';
import './App.css';
import twitterLogo from './assets/twitter-logo.svg';
import React, { useEffect, useState } from "react";
import "./App.css";
import twitterLogo from "./assets/twitter-logo.svg";
import _ from "lodash";
import CandyMachine from "./CandyMachine";

// Constants
const TWITTER_HANDLE = '_buildspace';
const TWITTER_HANDLE = "_buildspace";
const TWITTER_LINK = `https://twitter.com/${TWITTER_HANDLE}`;

const App = () => {
const [walletAddress, setWalletAddress] = useState(null);

const checkWalletConnection = async () => {
try {
const { solana } = window;
if (solana) {
if (solana.isPhantom) {
console.log("Phantom wallet found!");

const response = await solana.connect({ onlyIfTrusted: true });
console.log(
`Connected with public key: ${response.publicKey.toString()}`
);

setWalletAddress(response.publicKey.toString());
}
} else {
console.log("Solana is not on your browser, get a Phantom Wallet! 👻");
}
} catch (error) {
console.log(error);
}
};

const connectWallet = async () => {
const { solana } = window;

if (solana) {
const response = await solana.connect();
console.log(
`Connected with public key: ${response.publicKey.toString()}`
);
setWalletAddress(response.publicKey.toString());
}
};

const renderConnectButton = () => (
<button
className="cta-button connect-wallet-button"
onClick={connectWallet}
>
Connect wallet
</button>
);

useEffect(() => {
const onLoad = async () => {
await checkWalletConnection();
};

window.addEventListener("load", onLoad);
return () => window.removeEventListener("load", onLoad);
}, []);

return (
<div className="App">
<div className="container">
<div className="header-container">
<p className="header">🍭 Candy Drop</p>
<p className="sub-text">NFT drop machine with fair mint</p>
{_.isNull(walletAddress) && renderConnectButton()}
</div>
{walletAddress && <CandyMachine walletAddress={window.solana} />}
<div className="footer-container">
<img alt="Twitter Logo" className="twitter-logo" src={twitterLogo} />
<a
Expand Down
1 change: 1 addition & 0 deletions app/src/CandyMachine/CandyMachine.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.machine-container {
display: flex;
flex-direction: column;
align-items: center;
}

.gif-container {
Expand Down
Loading