UNPKG

@ledgerhq/coin-hedera

Version:
39 lines 1.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.rpcClient = void 0; const sdk_1 = require("@hashgraph/sdk"); let _hederaClientPromise = null; async function broadcastTransaction(transaction) { return transaction.execute(await getInstance()); } async function createClient() { const client = await sdk_1.Client.forMainnetAsync(); client.setMaxNodesPerTransaction(1); return client; } async function getInstance() { _hederaClientPromise ??= createClient().catch(error => { _hederaClientPromise = null; throw error; }); return _hederaClientPromise; } // for testing purposes only, used to reset singleton client instance async function _resetInstance() { try { const client = await _hederaClientPromise; client?.close(); } catch { // intentionally ignored during clean up } finally { _hederaClientPromise = null; } } exports.rpcClient = { getInstance, broadcastTransaction, _resetInstance, }; //# sourceMappingURL=rpc.js.map