diff --git a/packages/solana-utils/src/index.ts b/packages/solana-utils/src/index.ts index 35b3844e..3116a004 100755 --- a/packages/solana-utils/src/index.ts +++ b/packages/solana-utils/src/index.ts @@ -4,7 +4,6 @@ export { isValidatorActive } from './lib/isValidatorActive' export { getSPLTokenBalance } from './lib/getSPLTokenBalance' export { solanaTransfer } from './lib/solanaTransfer' export { getNftOwnerByTokenMint } from './lib/getNftOwnerByTokenMint' -export { getNftAttributes } from './lib/getNftAttributes' export { getMagicEdenOwner } from './lib/getMagicEdenOwner' export { getNftsByWalletAddress } from './lib/getNftsByWalletAddress' export { getNftsByWalletAddressAndCollectionMint } from './lib/getNftsByWalletAddressAndCollectionMint' diff --git a/packages/solana-utils/src/lib/getNftAttributes.ts b/packages/solana-utils/src/lib/getNftAttributes.ts deleted file mode 100644 index ada34204..00000000 --- a/packages/solana-utils/src/lib/getNftAttributes.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { NftMetadata } from '../solanaUtilsTypes' -import { fetchDigitalAssetWithTokenByMint } from '@metaplex-foundation/mpl-token-metadata' -import { createUmi } from '@metaplex-foundation/umi-bundle-defaults' -import { fromWeb3JsPublicKey } from '@metaplex-foundation/umi-web3js-adapters' -import { sendGet } from '@skeet-framework/utils' -import { PublicKey } from '@solana/web3.js' -/** - * Retrieves the attributes of an NFT by its mint address. - * - * @param {string} nftAddress - The mint address of the NFT. - * @param {string} endpoint - The Solana network endpoint to connect to. - * @returns {Promise} - A promise that resolves with the NFT metadata. - * @throws {Error} - Throws an error if unable to fetch the NFT metadata. - * - * @example - * ``` - * const run = async () => { - * try { - * const nftData = await getNftAttributes( - * 'EggwWJZsCjSY7f36zHHevBmuSyTDHzGxVC2PGX5ePsTh', - * 'https://api.mainnet-beta.solana.com' - * ); - * console.log(nftData); - * } catch (error) { - * console.error('Error:', error); - * } - * } - * - * run(); - * ``` - */ -export const getNftAttributes = async ( - nftAddress: string, - endpoint: string, -) => { - try { - const publicKey = new PublicKey(nftAddress) - const umi = createUmi(endpoint) - const nftMetadata = await fetchDigitalAssetWithTokenByMint( - umi, - fromWeb3JsPublicKey(publicKey), - ) - const jsonUrl = nftMetadata.metadata.uri - const json = await getJson(jsonUrl) - return json - } catch (error) { - throw new Error(`getNftAttributes: ${error}`) - } -} - -/** - * Fetches JSON data from a given URL. - * - * @param {string} url - The URL to fetch JSON data from. - * @returns {Promise} - A promise that resolves with the JSON data. - * @throws {Error} - Throws an error if unable to fetch or parse the JSON data. - */ -export const getJson = async (url: string) => { - try { - const res = await sendGet(url) - const json = await res.json() - return json as NftMetadata - } catch (error) { - throw new Error(`getJson: ${error}`) - } -}