Skip to content

Commit

Permalink
Removed logs and added README
Browse files Browse the repository at this point in the history
  • Loading branch information
priyansh71 committed Jul 26, 2022
1 parent bdec7eb commit be18290
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 10 deletions.
77 changes: 76 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,76 @@
## candy-machine-assistant
## 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.
```
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
3 changes: 0 additions & 3 deletions src/candyMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ export const awaitTransactionSignatureConfirmation = async (
// ignore
}
done = true;
console.log("Returning status", status);
return status;
};

Expand Down Expand Up @@ -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);
Expand Down
4 changes: 0 additions & 4 deletions src/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}
},
Expand Down Expand Up @@ -508,7 +505,6 @@ async function awaitTransactionSignatureConfirmation(
// ignore
}
done = true;
console.log("Returning status", status);
return status;
}
export function sleep(ms: number): Promise<void> {
Expand Down

0 comments on commit be18290

Please sign in to comment.