react-solana-nftmint
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -10,3 +10,2 @@ import * as anchor from "@project-serum/anchor"; | ||
export type MintProps = { | ||
loading: boolean; | ||
title: string; | ||
@@ -24,4 +23,5 @@ rpc: string; | ||
ready: boolean; | ||
uploading: boolean; | ||
error: string; | ||
}; | ||
//# sourceMappingURL=useMint.d.ts.map |
@@ -11,5 +11,5 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
import * as anchor from "@project-serum/anchor"; | ||
import { useState, useEffect } from 'react'; | ||
import { createAssociatedTokenAccountInstruction, createInitializeMintInstruction, getAssociatedTokenAddress, MINT_SIZE, TOKEN_PROGRAM_ID } from "@solana/spl-token"; | ||
import { Connection, Keypair, PublicKey, SystemProgram, Transaction } from "@solana/web3.js"; | ||
import { useState, useEffect } from "react"; | ||
import { createAssociatedTokenAccountInstruction, createInitializeMintInstruction, getAssociatedTokenAddress, MINT_SIZE, TOKEN_PROGRAM_ID, } from "@solana/spl-token"; | ||
import { Connection, Keypair, PublicKey, SystemProgram, Transaction, } from "@solana/web3.js"; | ||
import mintIdl from "../idl/nft_mint.json"; | ||
@@ -28,3 +28,3 @@ function getAnchorEnvironment(rpc, idl, wallet, programId) { | ||
const [ready, setReady] = useState(false); | ||
const [loading, setLoading] = useState(false); | ||
const [uploading, setUploading] = useState(false); | ||
const [connection, setConnection] = useState(); | ||
@@ -89,12 +89,12 @@ const [program, setProgram] = useState(); | ||
} | ||
setLoading(true); | ||
setUploading(true); | ||
const getMetadata = (mint) => __awaiter(this, void 0, void 0, function* () { | ||
return (anchor.web3.PublicKey.findProgramAddressSync([ | ||
return anchor.web3.PublicKey.findProgramAddressSync([ | ||
Buffer.from("metadata"), | ||
TOKEN_METADATA_PROGRAM_ID.toBuffer(), | ||
mint.toBuffer(), | ||
], TOKEN_METADATA_PROGRAM_ID))[0]; | ||
], TOKEN_METADATA_PROGRAM_ID)[0]; | ||
}); | ||
const getMasterEdition = (mint) => __awaiter(this, void 0, void 0, function* () { | ||
return (anchor.web3.PublicKey.findProgramAddressSync([ | ||
return anchor.web3.PublicKey.findProgramAddressSync([ | ||
Buffer.from("metadata"), | ||
@@ -104,3 +104,3 @@ TOKEN_METADATA_PROGRAM_ID.toBuffer(), | ||
Buffer.from("edition"), | ||
], TOKEN_METADATA_PROGRAM_ID))[0]; | ||
], TOKEN_METADATA_PROGRAM_ID)[0]; | ||
}); | ||
@@ -132,3 +132,3 @@ const TOKEN_METADATA_PROGRAM_ID = new PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"); | ||
share: creator.share, | ||
})) | ||
})), | ||
]; | ||
@@ -163,8 +163,8 @@ try { | ||
finally { | ||
setLoading(false); | ||
setUploading(false); | ||
} | ||
}); | ||
} | ||
return { mintNft, ready, error }; | ||
return { mintNft, ready, uploading, error }; | ||
} | ||
//# sourceMappingURL=useMint.js.map |
{ | ||
"name": "react-solana-nftmint", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "UseEffect hook to mint NFT 1/1s", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -8,3 +8,2 @@ # React Solana NFT Mint | ||
* loading: boolean | ||
* rpc: devnet/mainnet URL | ||
@@ -50,3 +49,3 @@ * creators: array of pubkeys (total shares must sum up to 100) | ||
} | ||
const { mintNft, ready, error } = useMint(props, anchorWallet); | ||
const { mintNft, ready, uploading, error } = useMint(props, anchorWallet); | ||
@@ -64,2 +63,4 @@ const handleMint = useCallback(async () => { | ||
{error && <div>{error}</div>} | ||
{uploading && <div>NFT is cooking...</div>} | ||
<button disabled={!ready} onClick={handleMint}>Mint {props.title}</button> | ||
@@ -66,0 +67,0 @@ </div> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35565
68