UNPKG

@gorbchain-xyz/chaindecode

Version:

GorbchainSDK V1.3+ - Complete Solana development toolkit with advanced cryptography, messaging, and collaboration features. Build secure applications with blockchain, DeFi, and end-to-end encryption.

39 lines (38 loc) 1.8 kB
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; import { decodeMintAccount } from '../utils/decodeMintAccount.js'; export { decodeMintAccount }; // SDK helper to fetch and decode a mint account using Gor API // Moved to utils as a private helper, not exported from decoders export function fetchAndDecodeMintAccount(mint) { return __awaiter(this, void 0, void 0, function* () { var _a; const res = yield fetch(`https://gorbscan.com/api/account/${mint}/info`); if (!res.ok) return null; const data = yield res.json(); if (!((_a = data === null || data === void 0 ? void 0 : data.account) === null || _a === void 0 ? void 0 : _a.data)) return null; // Try to decode as base64 try { return decodeMintAccount(data.account.data, { encoding: 'base64' }); } catch (_e) { // fallback: try as hex try { return decodeMintAccount(data.account.data, { encoding: 'hex' }); } catch (_b) { return null; } } }); } // Add decodeAndMintAccount here as well if needed