p-sdk-wallet
Version:
A comprehensive wallet SDK for React Native (pwc), supporting multi-chain and multi-account features.
123 lines (122 loc) • 4.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.NFTAPIService = void 0;
/**
* Service for interacting with NFT APIs for individual NFT details
*/
class NFTAPIService {
constructor(chainConfig, chainId, apiKey) {
this.chainConfig = chainConfig;
this.chainId = chainId;
this.apiKey = apiKey;
}
/**
* Gets detailed NFT information
* @param contractAddress - NFT contract address
* @param tokenId - Token ID
* @param options - Query options
* @returns Promise resolving to extended NFT detail
*/
async getNFTDetail(contractAddress, tokenId, options = {}) {
switch (this.chainConfig.type) {
case 'evm':
return this.getEVMNFTDetail(contractAddress, tokenId, options);
case 'solana':
return this.getSolanaNFTDetail(contractAddress, tokenId, options);
default:
throw new Error(`Unsupported chain type: ${this.chainConfig.type}`);
}
}
/**
* Gets collection information
* @param contractAddress - Collection contract address
* @returns Promise resolving to collection info
*/
async getCollectionInfo(contractAddress) {
switch (this.chainConfig.type) {
case 'evm':
return this.getEVMCollectionInfo(contractAddress);
case 'solana':
return this.getSolanaCollectionInfo(contractAddress);
default:
throw new Error(`Unsupported chain type: ${this.chainConfig.type}`);
}
}
/**
* Gets detailed EVM NFT information
* @param contractAddress - NFT contract address
* @param tokenId - Token ID
* @param options - Query options
* @returns Promise resolving to extended NFT detail
*/
async getEVMNFTDetail(contractAddress, tokenId, options) {
// For now, return basic info. In a real implementation,
// you'd fetch from OpenSea, Alchemy, or other APIs
const basicNFT = {
contractAddress,
tokenId,
tokenType: 'ERC-721',
name: `NFT #${tokenId}`,
description: '',
image: '',
owner: '',
chainId: this.chainId
};
return basicNFT;
}
/**
* Gets detailed Solana NFT information
* @param contractAddress - NFT contract address
* @param tokenId - Token ID
* @param options - Query options
* @returns Promise resolving to extended NFT detail
*/
async getSolanaNFTDetail(contractAddress, tokenId, options) {
// For now, return basic info. In a real implementation,
// you'd fetch from Helius, Solscan, or other APIs
const basicNFT = {
contractAddress,
tokenId,
tokenType: 'SPL-NFT',
name: `NFT #${tokenId}`,
description: '',
image: '',
owner: '',
chainId: this.chainId
};
return basicNFT;
}
/**
* Gets EVM collection information
* @param contractAddress - Collection contract address
* @returns Promise resolving to collection info
*/
async getEVMCollectionInfo(contractAddress) {
// For now, return basic info. In a real implementation,
// you'd fetch from OpenSea, Alchemy, or other APIs
return {
name: 'Unknown Collection',
description: '',
image: '',
verified: false,
total_supply: 0
};
}
/**
* Gets Solana collection information
* @param contractAddress - Collection contract address
* @returns Promise resolving to collection info
*/
async getSolanaCollectionInfo(contractAddress) {
// For now, return basic info. In a real implementation,
// you'd fetch from Helius, Solscan, or other APIs
return {
name: 'Unknown Collection',
description: '',
image: '',
verified: false,
total_supply: 0
};
}
}
exports.NFTAPIService = NFTAPIService;