UNPKG

@bagsfm/bags-sdk

Version:

TypeScript SDK for Bags

41 lines 1.68 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SolanaService = void 0; const base_1 = require("./base"); const solana_1 = require("../types/solana"); const helpers_1 = require("../utils/helpers"); class SolanaService extends base_1.BaseService { constructor(apiKey, connection, commitment = 'processed') { super(apiKey, connection, commitment); } async sendBundle(transactions, region = 'mainnet') { if (!transactions.length) { throw new Error('At least one transaction is required to send a bundle'); } if (!solana_1.JITO_REGIONS.includes(region)) { throw new Error(`Unsupported region "${region}". Expected one of: ${solana_1.JITO_REGIONS.join(', ')}`); } const payload = { transactions: transactions.map(helpers_1.serializeVersionedTransaction), region, }; return this.bagsApiClient.post('/solana/send-bundle', payload); } async getBundleStatuses(bundleIds, region = 'mainnet') { if (!bundleIds.length) { throw new Error('At least one bundle ID is required to fetch bundle statuses'); } if (!solana_1.JITO_REGIONS.includes(region)) { throw new Error(`Unsupported region "${region}". Expected one of: ${solana_1.JITO_REGIONS.join(', ')}`); } return this.bagsApiClient.post('/solana/get-bundle-statuses', { bundleIds, region, }); } async getJitoRecentFees() { return this.bagsApiClient.get('/solana/jito-recent-fees'); } } exports.SolanaService = SolanaService; //# sourceMappingURL=solana.js.map