-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
contractAddress, | ||
NFT.abi, | ||
signer | ||
)as BaseContract as SuperCarERC1155;; |
There was a problem hiding this comment.
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
There was a problem hiding this 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"; |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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")); | ||
}, []); |
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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
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()))); |
There was a problem hiding this comment.
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]); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; |
Converted Javascript part to typescript