Skip to content

Commit

Permalink
docs: add documentation to sdk functions (#2)
Browse files Browse the repository at this point in the history
* feat: add jsdocs to the exported functions

* Update src/lib/cache/actions.ts

Co-authored-by: Begoña Álvarez de la Cruz <balvarez@boxfish.studio>

* Update src/lib/mint/mint.ts

Co-authored-by: Begoña Álvarez de la Cruz <balvarez@boxfish.studio>

* Update src/lib/mint/mint.ts

Co-authored-by: Begoña Álvarez de la Cruz <balvarez@boxfish.studio>

* Update src/lib/update.ts

Co-authored-by: Begoña Álvarez de la Cruz <balvarez@boxfish.studio>

* Update src/lib/upload/arweave.ts

Co-authored-by: Begoña Álvarez de la Cruz <balvarez@boxfish.studio>

* Update src/lib/upload/transactions.ts

Co-authored-by: Begoña Álvarez de la Cruz <balvarez@boxfish.studio>

* Update src/lib/upload/transactions.ts

Co-authored-by: Begoña Álvarez de la Cruz <balvarez@boxfish.studio>

* Update src/lib/upload/transactions.ts

Co-authored-by: Begoña Álvarez de la Cruz <balvarez@boxfish.studio>

* Update src/lib/upload/transactions.ts

Co-authored-by: Begoña Álvarez de la Cruz <balvarez@boxfish.studio>

* Update src/lib/upload/upload.ts

Co-authored-by: Begoña Álvarez de la Cruz <balvarez@boxfish.studio>

* Update src/lib/upload/config.ts

Co-authored-by: Begoña Álvarez de la Cruz <balvarez@boxfish.studio>

* Update src/lib/upload/config.ts

Co-authored-by: Begoña Álvarez de la Cruz <balvarez@boxfish.studio>

* Update src/lib/upload/helpers.ts

Co-authored-by: Begoña Álvarez de la Cruz <balvarez@boxfish.studio>

* Update src/lib/upload/helpers.ts

Co-authored-by: Begoña Álvarez de la Cruz <balvarez@boxfish.studio>

* Update src/lib/upload/helpers.ts

Co-authored-by: Begoña Álvarez de la Cruz <balvarez@boxfish.studio>

* Update src/lib/upload/transactions.ts

Co-authored-by: Begoña Álvarez de la Cruz <balvarez@boxfish.studio>

Co-authored-by: Begoña Álvarez de la Cruz <balvarez@boxfish.studio>
  • Loading branch information
aspnxdd and begonaalvarezd authored Aug 17, 2022
1 parent ad52b5c commit b216a71
Show file tree
Hide file tree
Showing 9 changed files with 506 additions and 272 deletions.
7 changes: 7 additions & 0 deletions src/lib/cache/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ import { ICache } from './interfaces'
// return JSON.parse(fs.readFileSync(path).toString());
// }

/**
* Save the cache to the cache path.
* @param cacheName The name of the cache to save.
* @param env The environment used 'mainnet-beta' | 'devnet' | 'testnet'
* @param cacheContent The content of the cache to save.
*/

export function saveCache(cacheName: string, env: string, cacheContent: ICache) {
cacheContent.env = env
cacheContent.cacheName = cacheName
Expand Down
108 changes: 75 additions & 33 deletions src/lib/mint/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,81 @@
import { web3 } from '@project-serum/anchor'
import { web3 } from "@project-serum/anchor";
import {
CANDY_MACHINE_PROGRAM_V2_ID,
SPL_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID,
TOKEN_METADATA_PROGRAM_ID,
TOKEN_PROGRAM_ID,
} from '../constants'
CANDY_MACHINE_PROGRAM_V2_ID,
SPL_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID,
TOKEN_METADATA_PROGRAM_ID,
TOKEN_PROGRAM_ID,
} from "../constants";

export const getAtaForMint = async (mint: web3.PublicKey, buyer: web3.PublicKey): Promise<[web3.PublicKey, number]> => {
return await web3.PublicKey.findProgramAddress(
[buyer.toBuffer(), TOKEN_PROGRAM_ID.toBuffer(), mint.toBuffer()],
SPL_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID
)
}
/**
* Get the associated token account from a mint and the owner.
*
* @param mint The mint to get the associated token account of.
* @param buyer The owner of the associated token account.
* @returns The associated token account
*/
export const getAtaForMint = async (
mint: web3.PublicKey,
buyer: web3.PublicKey
): Promise<[web3.PublicKey, number]> => {
return await web3.PublicKey.findProgramAddress(
[buyer.toBuffer(), TOKEN_PROGRAM_ID.toBuffer(), mint.toBuffer()],
SPL_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID
);
};

export const getMetadata = async (mint: web3.PublicKey): Promise<web3.PublicKey> => {
return (
await web3.PublicKey.findProgramAddress(
[Buffer.from('metadata'), TOKEN_METADATA_PROGRAM_ID.toBuffer(), mint.toBuffer()],
TOKEN_METADATA_PROGRAM_ID
)
)[0]
}
/**
* Get the mint metadata.
*
* @param mint The mint to get the metadata of.
* @returns The mint metadata.
* */

export const getMasterEdition = async (mint: web3.PublicKey): Promise<web3.PublicKey> => {
return (
await web3.PublicKey.findProgramAddress(
[Buffer.from('metadata'), TOKEN_METADATA_PROGRAM_ID.toBuffer(), mint.toBuffer(), Buffer.from('edition')],
TOKEN_METADATA_PROGRAM_ID
)
)[0]
}
export const getMetadata = async (
mint: web3.PublicKey
): Promise<web3.PublicKey> => {
return (
await web3.PublicKey.findProgramAddress(
[
Buffer.from("metadata"),
TOKEN_METADATA_PROGRAM_ID.toBuffer(),
mint.toBuffer(),
],
TOKEN_METADATA_PROGRAM_ID
)
)[0];
};

export const getCandyMachineCreator = async (candyMachine: web3.PublicKey): Promise<[web3.PublicKey, number]> => {
return await web3.PublicKey.findProgramAddress(
[Buffer.from('candy_machine'), candyMachine.toBuffer()],
CANDY_MACHINE_PROGRAM_V2_ID
/**
* Get the mint edition.
* @param mint The mint to get the edition of.
* @returns The mint edition.
*
**/
export const getMasterEdition = async (
mint: web3.PublicKey
): Promise<web3.PublicKey> => {
return (
await web3.PublicKey.findProgramAddress(
[
Buffer.from("metadata"),
TOKEN_METADATA_PROGRAM_ID.toBuffer(),
mint.toBuffer(),
Buffer.from("edition"),
],
TOKEN_METADATA_PROGRAM_ID
)
}
)[0];
};
/**
* Get the creator of a candy machine.
* @param candyMachine The candy machine to get the mint of.
* @returns The creator of the Candy Machine.
*/
export const getCandyMachineCreator = async (
candyMachine: web3.PublicKey
): Promise<[web3.PublicKey, number]> => {
return await web3.PublicKey.findProgramAddress(
[Buffer.from("candy_machine"), candyMachine.toBuffer()],
CANDY_MACHINE_PROGRAM_V2_ID
);
};
Loading

0 comments on commit b216a71

Please sign in to comment.