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

change to typescript implementation #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

shubh045
Copy link
Owner

Converted Javascript part to typescript

Copy link

vercel bot commented Feb 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nft-erc-1155 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 29, 2024 10:10am

contractAddress,
NFT.abi,
signer
)as BaseContract as SuperCarERC1155;;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

giving SuperERC1155 type to contract

Copy link
Collaborator

@AkulGaind AkulGaind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes Requested

const [mintPrice, setMintPrice] = useState<number>(0);
const [burnPrice, setBurnPrice] = useState<number>(0);
const [nftBalance, setNftBalance] = useState<number>(0);
const contractAddress: string = "0x80f7f95Ef489C181656C6c9999402c59Fd1e4E46";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

declare it in env file

try {
const signer = await provider.getSigner();
const address = await signer.getAddress();
const signer: ethers.JsonRpcSigner = await provider.getSigner();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

declare signer as a global variable do not declare it again and again

const [mintPrice, setMintPrice] = useState<number>(0);
const [burnPrice, setBurnPrice] = useState<number>(0);
const [nftBalance, setNftBalance] = useState<number>(0);
const contractAddress: string = "0x80f7f95Ef489C181656C6c9999402c59Fd1e4E46";

useEffect(() => {
setConnect(localStorage.getItem("address"));
}, []);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are two useEffects with no dependencies, use only one

toast("Account not connected!");
return;
}
const errorMessage = error.message.split("(")[0];
const error1 = error as Error;
const errorMessage: string = error1.message.split("(")[0];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't use 2 variables for a single error, try to use only one

const signer = await provider.getSigner();
const contract = new ethers.Contract(contractAddress, NFT.abi, signer);
const address = await signer.getAddress();
const signer: ethers.JsonRpcSigner = await provider.getSigner();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

declare a global variable for signer

app/page.tsx Show resolved Hide resolved
setMintPrice(ethers.formatEther(Number(currentMintPrice).toString()));
setBurnPrice(ethers.formatEther(Number(prevMintPrice).toString()));
const currentMintPrice: number = Number(await contract.currentPrice());
setMintPrice(Number(ethers.formatEther(currentMintPrice.toString())));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why currentMintPrice has to be converted to string


async function main() {

// const NFT = await hre.ethers.deployContract("NFT", ["Super Car", "SUP", hre.ethers.parseEther('0.02')]);
const NFT = await hre.ethers.deployContract("SuperCarERC1155", ["https://bafkreiebuhhy4e2p23nquu3llaftgvpy6cycpdfpuld7ccmfnksrzt2gom.ipfs.nftstorage.link/", 1000]);
const NFT = await ethers.deployContract("SuperCarERC1155", ["https://bafkreiebuhhy4e2p23nquu3llaftgvpy6cycpdfpuld7ccmfnksrzt2gom.ipfs.nftstorage.link/", 1000]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get this link from env file

import dotenv from 'dotenv';
dotenv.config();

let TESTNET_PRIVATE_KEY = process.env.TESTNET_PRIVATE_KEY as string;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let TESTNET_PRIVATE_KEY = process.env.TESTNET_PRIVATE_KEY as string;
const TESTNET_PRIVATE_KEY = process.env.TESTNET_PRIVATE_KEY as string;

dotenv.config();

let TESTNET_PRIVATE_KEY = process.env.TESTNET_PRIVATE_KEY as string;
let SEPOLIA_TESTNET_RPC_URL = process.env.SEPOLIA_TESTNET_RPC_URL as string;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let SEPOLIA_TESTNET_RPC_URL = process.env.SEPOLIA_TESTNET_RPC_URL as string;
const SEPOLIA_TESTNET_RPC_URL = process.env.SEPOLIA_TESTNET_RPC_URL as string;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants