diff --git a/README.md b/README.md index 8dc0817..5ae5db6 100644 --- a/README.md +++ b/README.md @@ -1 +1,76 @@ -## candy-machine-assistant \ No newline at end of file +## candy-machine-assistant + +A package which provides functions to connect with Solana's NFT mint accounts, generate PDAs, get candy machine state, send confirmation transactions, retrieving collection data, creating mint accounts easier by avoiding writing of boilerplate code. +This streamlines the minting from a deployed candy machine. + +In this extract, +```candyMachine``` has an interface given by + ```{ + id: anchor.web3.PublicKey; + program: anchor.Program; + state: CandyMachineState; + }``` + +other type interfaces are instances from ```@solana/web3.js;``` + +The most utilized examples are given below : + +```getAtaForMint : +const userTokenAccountAddress = (await getAtaForMint(mint.publicKey, payer))[0]; +// Generates the Associated Token Account Address given a mint and walletAddress. + +getCandyMachineState : +const cndy = await getCandyMachineState( + anchorWallet: anchor.Wallet, + candyMachineId: anchor.web3.PublicKey, + connection: anchor.web3.Connection, +); +// Returns the state of the candy machine. + +sendTransaction : +await sendTransaction( + connection: Connection, + wallet: any, + instructions: TransactionInstruction[] | Transaction, + signers: Keypair[], + awaitConfirmation = true, + commitment: Commitment = "singleGossip", + includesFeePayer: boolean = false, + block?: BlockhashAndFeeCalculator, +); +// Sends a transaction to the blockchain given a set of parameters, returns void. + +getCollectionPDA: +const [collectionPDA] = await getCollectionPDA(candyMachineAddress); +// Returns the Program Derived Address of the collection given a Candy Machine ID. + +mintOneToken: +const mintResult = await mintOneToken( + candyMachine, + walletAddress.publicKey, + beforeTransactions, + afterTransactions, + setupMint ?? setupTxn +); +// Returns a MintResult, given parameters and returns Mint Transaction ID and a Metadata Key. + + +createAccountsForMint: +let setupMint = await createAccountsForMint(candyMachine,walletAddress.publicKey); +// Returns the setup state of the account i.e. = { + mint: anchor.web3.Keypair; + userTokenAccount: anchor.web3.PublicKey; + transaction: string; +} + +awaitTransactionSignatureConfirmation: +await awaitTransactionSignatureConfirmation( + setupMint.transaction, + txTimeout, + connection, + true + ); +// Takes in a Transaction Signature, a timeout, a connection and queryStatus +// returns the slot, amount of confirmations, errors if any and the confirmation status. + +``` \ No newline at end of file diff --git a/package.json b/package.json index 2c5b5e2..2a09015 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "candy-machine-assistant", - "version": "1.0.0", - "description": "A tool to assist in the connection to the Candy Machine and initiate the Metaplex NFT Standard.", + "version": "1.0.1", + "description": "A tool to assist in the connecting to the Candy Machine, and mint account based on Metaplex NFTs on Solana.", "main": "lib", "type": "commonjs", "repository": { diff --git a/src/candyMachine.ts b/src/candyMachine.ts index 3564bd4..79fcf69 100644 --- a/src/candyMachine.ts +++ b/src/candyMachine.ts @@ -125,7 +125,6 @@ export const awaitTransactionSignatureConfirmation = async ( // ignore } done = true; - console.log("Returning status", status); return status; }; @@ -457,10 +456,8 @@ export const mintOneToken = async ( const collectionData = (await candyMachine.program.account.collectionPda.fetch( collectionPDA, )) as CollectionData; - console.log(collectionData); const collectionMint = collectionData.mint; const collectionAuthorityRecord = await getCollectionAuthorityRecordPDA(collectionMint, collectionPDA); - console.log(collectionMint); if (collectionMint) { const collectionMetadata = await getMetadata(collectionMint); const collectionMasterEdition = await getMasterEdition(collectionMint); diff --git a/src/connection.ts b/src/connection.ts index 1bb3c07..8a2b989 100644 --- a/src/connection.ts +++ b/src/connection.ts @@ -177,7 +177,6 @@ export const sendTransactions = async ( signedTxns = fullySignedTransactions.concat(signedTxns); const pendingTxns: Promise<{ txid: string; slot: number }>[] = []; - console.log("Signed txns length", signedTxns.length, "vs handed in length", instructionSet.length); for (let i = 0; i < signedTxns.length; i++) { const signedTxnPromise = sendSignedTransaction({ connection, @@ -457,10 +456,8 @@ async function awaitTransactionSignatureConfirmation( confirmations: 0, }; if (result.err) { - console.log("Rejected via websocket", result.err); reject(status); } else { - console.log("Resolved via websocket", result); resolve(status); } }, @@ -508,7 +505,6 @@ async function awaitTransactionSignatureConfirmation( // ignore } done = true; - console.log("Returning status", status); return status; } export function sleep(ms: number): Promise {