freeCodeCamp / solana-curriculum

freeCodeCamp Solana Curriculum
BSD 3-Clause "New" or "Revised" License
123 stars 50 forks source link

Update index.d.ts #328

Closed adityakaaltatva closed 11 months ago

adityakaaltatva commented 11 months ago

In this code, I've added comments to clarify the purpose of each function, specified the return types for functions, and provided placeholders for test cases. You'll need to replace the placeholders with actual input and assertions to validate the functionality of each function.

Checklist:

Closes #XXXXX

import { MetaplexFile, MintNftOutput, Creator, Data, } from '@metaplex-foundation/js'; import { Account, createMint } from '@solana/spl-token'; import { AccountInfo, ParsedAccountData, PublicKey, Signer, } from '@solana/web3.js';

// Updated TypeScript declarations

declare function uploadFile({ metaplexFile, payer, }: { metaplexFile: MetaplexFile; payer: Signer; }): Promise;

declare function createMintAccount({ payer, }: { payer: Signer; }): Promise; // Specify the return type as Account

declare function getMintAccounts({ payer, }: { payer: Signer; }): Promise<AccountInfo[]>; // Specify the return type

declare function createTokenAccount({ payer, mintAddress, ownerAddress, }: { payer: Signer; mintAddress: PublicKey; ownerAddress: PublicKey; }): Promise; // Specify the return type as Account

declare function mintToken({ payer, mintAddress, ownerAddress, year, uri, }: { payer: Signer; mintAddress: PublicKey; ownerAddress: PublicKey; year: number; uri: string; }): Promise; // Specify the return type

declare function getNFTs({ ownerAddress, }: { ownerAddress: PublicKey; }): Promise<MintNftOutput[]>; // Specify the return type as an array

// Test cases for the functions

describe('Metaplex Functions', () => { it('should upload a file', async () => { const metaplexFile: MetaplexFile = {}; // Provide required input const payer: Signer = {}; // Provide required input const result = await uploadFile({ metaplexFile, payer }); // Add assertions to check the result });

it('should create a mint account', async () => { const payer: Signer = {}; // Provide required input const result = await createMintAccount({ payer }); // Add assertions to check the result });

it('should get mint accounts', async () => { const payer: Signer = {}; // Provide required input const result = await getMintAccounts({ payer }); // Add assertions to check the result });

it('should create a token account', async () => { const payer: Signer = {}; // Provide required input const mintAddress: PublicKey = {}; // Provide required input const ownerAddress: PublicKey = {}; // Provide required input const result = await createTokenAccount({ payer, mintAddress, ownerAddress }); // Add assertions to check the result });

it('should mint a token', async () => { const payer: Signer = {}; // Provide required input const mintAddress: PublicKey = {}; // Provide required input const ownerAddress: PublicKey = {}; // Provide required input const year: number = 2023; // Provide required input const uri: string = 'sample_uri'; // Provide required input const result = await mintToken({ payer, mintAddress, ownerAddress, year, uri }); // Add assertions to check the result });

it('should get NFTs', async () => { const ownerAddress: PublicKey = {}; // Provide required input const result = await getNFTs({ ownerAddress }); // Add assertions to check the result }); });

// In this code, I've added comments to clarify the purpose of each function, // specified the return types for functions, and provided placeholders for test cases. // You'll need to replace the placeholders with actual input and assertions // to validate the functionality of each function.

ShaunSHamilton commented 11 months ago

Hello there, Thank you for taking the time to contribute. After reviewing this PR, we have decided to not move forward with the proposed changes.

The index.d.ts file is for definitions (e.g. function signatures). Not implementations nor tests.


For future contributions, please perform the checklist provided in the PR description.