ruạṛ
/** * test-shib-token.js * Test script to get information about the Shib token with a specific issuer * Run with: node --experimental-json-modules test-shib-token.js */ import dotenv from 'dotenv'; import { getTokenInfoForChat, getTokenInfo } from './src/utils/token-info.js'; import { stringToHex } from './src/utils/currency-utils.js'; // Load environment variables dotenv.config(); async function testShibToken() { try { console.log('Testing Shib token info...\n'); const issuer = 'rsfSrrxQUhgYCDD8jyMwbPHXvvVpHKPKCR'; // Try with the string format const stringCurrency = 'Shib'; console.log(`Attempting with string format "${stringCurrency}"...`); try { const stringInfo = await getTokenInfo(stringCurrency, issuer); console.log('Result:', JSON.stringify(stringInfo, null, 2)); } catch (error) { console.error('Error with string format:', error.message); } // Try with 3-letter code console.log('\nAttempting with 3-letter code "SHB"...'); try { const shortInfo = await getTokenInfo('SHB', issuer); console.log('Result:', JSON.stringify(shortInfo, null, 2)); } catch (error) { console.error('Error with 3-letter code:', error.message); } // Try with hex format const hexCurrency = stringToHex('SHIB'); console.log(`\nAttempting with hex format "${hexCurrency}"...`); try { const hexInfo = await getTokenInfo(hexCurrency, issuer); console.log('Result:', JSON.stringify(hexInfo, null, 2)); } catch (error) { console.error('Error with hex format:', error.message); } // Try with documented hex currency code for SHIB if available const knownShib = '534842000000000000000000000000000000000000'; console.log(`\nAttempting with known SHIB hex code "${knownShib}"...`); try { const knownInfo = await getTokenInfo(knownShib, issuer); console.log('Result:', JSON.stringify(knownInfo, null, 2)); } catch (error) { console.error('Error with known hex code:', error.message); } } catch (error) { console.error('Error in test script:', error.message); } finally { // Import cleanup function dynamically to avoid circular dependency const { cleanup } = await import('./src/utils/token-info.js'); await cleanup(); } } // Run the test testShibToken().catch(console.error);
cải xoăn