UNPKG

@lifi/sdk

Version:

LI.FI Any-to-Any Cross-Chain-Swap SDK

31 lines 948 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.callSuiWithRetry = callSuiWithRetry; const types_1 = require("@lifi/types"); const client_1 = require("@mysten/sui/client"); const rpc_js_1 = require("../rpc.js"); const clients = new Map(); const ensureClients = async () => { const rpcUrls = await (0, rpc_js_1.getRpcUrls)(types_1.ChainId.SUI); for (const rpcUrl of rpcUrls) { if (!clients.get(rpcUrl)) { const client = new client_1.SuiClient({ url: rpcUrl }); clients.set(rpcUrl, client); } } }; async function callSuiWithRetry(fn) { await ensureClients(); let lastError = null; for (const client of clients.values()) { try { const result = await fn(client); return result; } catch (error) { lastError = error; } } throw lastError; } //# sourceMappingURL=suiClient.js.map