@xchainjs/xchain-utxo 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.esm.js +8 -1
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +8 -3
- package/lib/index.js.map +1 -1
- package/package.json +5 -5
package/lib/index.esm.js
CHANGED
|
@@ -15,6 +15,8 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
15
15
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
16
16
|
PERFORMANCE OF THIS SOFTWARE.
|
|
17
17
|
***************************************************************************** */
|
|
18
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
19
|
+
|
|
18
20
|
|
|
19
21
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
20
22
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
@@ -24,7 +26,12 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
24
26
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
25
27
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
26
28
|
});
|
|
27
|
-
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
32
|
+
var e = new Error(message);
|
|
33
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
34
|
+
};
|
|
28
35
|
|
|
29
36
|
/**
|
|
30
37
|
* Abstract base class for creating blockchain clients in the UTXO model.
|
package/lib/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/client.ts"],"sourcesContent":["import {\n BaseXChainClient,\n ExplorerProviders,\n FeeEstimateOptions,\n FeeRate,\n FeeRates,\n FeeType,\n Fees,\n FeesWithRates,\n Protocol,\n TxHash,\n TxHistoryParams,\n standardFeeRates,\n} from '@xchainjs/xchain-client'\nimport { Address, Asset, Chain, baseAmount } from '@xchainjs/xchain-util'\nimport { UtxoOnlineDataProviders } from '@xchainjs/xchain-utxo-providers'\n\nimport { Balance, Tx, TxParams, TxsPage, UTXO, UtxoClientParams } from './types'\n/**\n * Abstract base class for creating blockchain clients in the UTXO model.\n */\nexport abstract class Client extends BaseXChainClient {\n protected explorerProviders: ExplorerProviders\n protected dataProviders: UtxoOnlineDataProviders[]\n\n /**\n * Constructor for creating a UTXO client instance.\n *\n * @param {Chain} chain The blockchain chain type.\n * @param {UtxoClientParams} params The parameters required for client initialization.\n */\n constructor(chain: Chain, params: UtxoClientParams) {\n super(chain, {\n network: params.network,\n rootDerivationPaths: params.rootDerivationPaths,\n phrase: params.phrase,\n feeBounds: params.feeBounds,\n })\n this.explorerProviders = params.explorerProviders\n this.dataProviders = params.dataProviders\n }\n\n /**\n * Get the explorer URL based on the network.\n *\n * @returns {string} The explorer URL.\n */\n getExplorerUrl(): string {\n return this.explorerProviders[this.network].getExplorerUrl()\n }\n\n /**\n * Get the explorer URL for a given address based on the network.\n *\n * @param {string} address The address to query.\n * @returns {string} The explorer URL for the address.\n */\n getExplorerAddressUrl(address: string): string {\n return this.explorerProviders[this.network].getExplorerAddressUrl(address)\n }\n\n /**\n * Get the explorer URL for a given transaction ID based on the network.\n *\n * @param {string} txID The transaction ID.\n * @returns {string} The explorer URL for the transaction.\n */\n getExplorerTxUrl(txID: string): string {\n return this.explorerProviders[this.network].getExplorerTxUrl(txID)\n }\n\n /**\n * Get the transaction history of a given address with pagination options.\n *\n * @param {TxHistoryParams} params The options to get transaction history.\n * @returns {TxsPage} The transaction history.\n */\n async getTransactions(params?: TxHistoryParams): Promise<TxsPage> {\n // Filter the parameters for transaction history\n const filteredParams: TxHistoryParams = {\n address: params?.address || (await this.getAddress()),\n offset: params?.offset,\n limit: params?.limit,\n startTime: params?.startTime,\n asset: params?.asset,\n }\n\n return await this.roundRobinGetTransactions(filteredParams)\n }\n\n /**\n * Get the transaction details of a given transaction ID.\n *\n * @param {string} txId The transaction ID.\n * @returns {Tx} The transaction details.\n */\n async getTransactionData(txId: string): Promise<Tx> {\n return await this.roundRobinGetTransactionData(txId)\n }\n\n /**\n * Gets balance of a given address.\n *\n * @param {Address} address The address to get balances from\n * @param {undefined} Needed for legacy only to be in common with `XChainClient` interface - will be removed by a next version\n * @param {confirmedOnly} Flag to get balances of confirmed txs only\n *\n * @returns {Balance[]} BTC balances\n */\n // TODO (@xchain-team|@veado) Change params to be an object to be extendable more easily\n // see changes for `xchain-bitcoin` https://github.com/xchainjs/xchainjs-lib/pull/490\n async getBalance(address: Address, _assets?: Asset[] /* not used */, confirmedOnly?: boolean): Promise<Balance[]> {\n // The actual logic for getting balances\n confirmedOnly\n return await this.roundRobinGetBalance(address)\n }\n /**\n * Scan UTXOs for a given address.\n *\n * @param {string} address The address to scan.\n * @param {boolean} confirmedOnly Flag to scan only confirmed UTXOs.\n * @returns {UTXO[]} The UTXOs found.\n */\n protected async scanUTXOs(\n address: string,\n confirmedOnly = true, // default: scan only confirmed UTXOs\n ): Promise<UTXO[]> {\n return this.roundRobinGetUnspentTxs(address, confirmedOnly)\n }\n /**\n * Get estimated fees with fee rates.\n *\n * @param {FeeEstimateOptions} options Options for fee estimation.\n * @returns {Promise<FeesWithRates>} Estimated fees along with fee rates.\n */\n async getFeesWithRates(options?: FeeEstimateOptions): Promise<FeesWithRates> {\n // Scan UTXOs if sender address is provided\n const utxos = options?.sender ? await this.scanUTXOs(options.sender, false) : []\n // Compile memo if memo is provided\n const compiledMemo = options?.memo ? this.compileMemo(options.memo) : null\n // Get fee rates\n const rates = await this.getFeeRates()\n\n return {\n fees: {\n average: baseAmount(this.getFeeFromUtxos(utxos, rates.average, compiledMemo)),\n fast: baseAmount(this.getFeeFromUtxos(utxos, rates.fast, compiledMemo)),\n fastest: baseAmount(this.getFeeFromUtxos(utxos, rates.fastest, compiledMemo)),\n type: FeeType.PerByte,\n },\n rates,\n }\n }\n /**\n * Get estimated fees.\n *\n * @param {FeeEstimateOptions} options Options for fee estimation.\n * @returns {Promise<Fees>} Estimated fees.\n */\n async getFees(options?: FeeEstimateOptions): Promise<Fees> {\n const { fees } = await this.getFeesWithRates(options)\n return fees\n }\n\n /**\n * Get fee rates\n * @param {Protocol} protocol Protocol to interact with. If there's no protocol provided, fee rates are retrieved from chain data providers\n *\n * @returns {FeeRates} The fee rates (average, fast, fastest) in `Satoshis/byte`\n */\n async getFeeRates(protocol?: Protocol): Promise<FeeRates> {\n if (!protocol) {\n try {\n const feeRates = await this.roundRobinGetFeeRates()\n return feeRates\n } catch (error) {\n console.warn('Can not retrieve fee rates from provider')\n }\n }\n\n if (!protocol || Protocol.THORCHAIN) {\n try {\n const feeRate = await this.getFeeRateFromThorchain()\n return standardFeeRates(feeRate)\n } catch (error) {\n console.warn(`Can not retrieve fee rates from Thorchain`)\n }\n }\n // TODO: Return default value\n throw Error('Can not retrieve fee rates')\n }\n /**\n * Broadcast a transaction.\n *\n * @param {string} txHex The transaction hex string.\n * @returns {Promise<TxHash>} The transaction hash.\n */\n async broadcastTx(txHex: string): Promise<TxHash> {\n return await this.roundRobinBroadcastTx(txHex)\n }\n /**\n * Round-robin method to get balance from data providers.\n * Throws error if no provider can get balance.\n *\n * @param {Address} address The address to get balance for.\n * @returns {Promise<Balance[]>} The balances.\n * @throws Error If no provider is able to get balance.\n */\n\n protected async roundRobinGetBalance(address: Address) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.getBalance(address)\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to get balance')\n }\n /**\n * Round-robin method to get unspent transactions from data providers.\n * Throws error if no provider can get unspent transactions.\n *\n * @param {Address} address The address to get unspent transactions for.\n * @param {boolean} confirmed Flag to indicate whether to get confirmed transactions only.\n * @returns {Promise<UTXO[]>} The unspent transactions.\n * @throws Error If no provider is able to get unspent transactions.\n */\n protected async roundRobinGetUnspentTxs(address: Address, confirmed: boolean) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) {\n return confirmed ? await prov.getConfirmedUnspentTxs(address) : await prov.getUnspentTxs(address)\n }\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to GetUnspentTxs')\n }\n /**\n * Round-robin method to get transaction data from data providers.\n * Throws error if no provider can get transaction data.\n *\n * @param {string} txid The transaction ID to get data for.\n * @returns {Promise<Tx>} The transaction data.\n * @throws Error If no provider is able to get transaction data.\n */\n protected async roundRobinGetTransactionData(txid: string) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.getTransactionData(txid)\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to GetTransactionData')\n }\n /**\n * Round-robin method to get transactions from data providers.\n * Throws error if no provider can get transactions.\n *\n * @param {TxHistoryParams} params The parameters for fetching transactions.\n * @returns {Promise<TxsPage>} The transaction history.\n * @throws Error If no provider is able to get transactions.\n */\n protected async roundRobinGetTransactions(params: TxHistoryParams) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.getTransactions(params)\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to GetTransactions')\n }\n /**\n * Broadcasts a transaction hex using a round-robin approach across multiple data providers.\n * @param {string} txHex The transaction hex to broadcast.\n * @returns {Promise<TxHash>} The hash of the broadcasted transaction.\n * @throws {Error} Throws an error if no provider is able to broadcast the transaction.\n */\n protected async roundRobinBroadcastTx(txHex: string) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.broadcastTx(txHex)\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to BroadcastTx')\n }\n /**\n * Abstract method to compile a memo.\n * @param {string} memo The memo string to compile.\n * @returns {Buffer} The compiled memo.\n */\n protected abstract compileMemo(memo: string): Buffer\n /**\n * Abstract method to calculate the fee from a list of UTXOs.\n * @param {UTXO[]} inputs The list of UTXOs.\n * @param {FeeRate} feeRate The fee rate.\n * @param {Buffer | null} data Optional data buffer.\n * @returns {number} The calculated fee.\n */\n protected abstract getFeeFromUtxos(inputs: UTXO[], feeRate: FeeRate, data: Buffer | null): number\n /**\n * Retrieves fee rates using a round-robin approach across multiple data providers.\n * @returns {Promise<FeeRates>} The fee rates (average, fast, fastest) in `Satoshis/byte`.\n * @throws {Error} Throws an error if no provider is able to retrieve fee rates.\n */\n protected async roundRobinGetFeeRates(): Promise<FeeRates> {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.getFeeRates()\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to get fee rates')\n }\n public abstract transfer(params: TxParams & { feeRate?: number }): Promise<string>\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA;;AAEG;AACG,MAAgB,MAAO,SAAQ,gBAAgB,CAAA;AAInD;;;;;AAKG;IACH,WAAY,CAAA,KAAY,EAAE,MAAwB,EAAA;QAChD,KAAK,CAAC,KAAK,EAAE;YACX,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,mBAAmB,EAAE,MAAM,CAAC,mBAAmB;YAC/C,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,SAAS,EAAE,MAAM,CAAC,SAAS;AAC5B,SAAA,CAAC,CAAA;AACF,QAAA,IAAI,CAAC,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAA;AACjD,QAAA,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,CAAA;KAC1C;AAED;;;;AAIG;IACH,cAAc,GAAA;QACZ,OAAO,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,cAAc,EAAE,CAAA;KAC7D;AAED;;;;;AAKG;AACH,IAAA,qBAAqB,CAAC,OAAe,EAAA;AACnC,QAAA,OAAO,IAAI,CAAC,i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AAA,MAAM,KAAK,CAAC,iCAAiC,CAAC,CAAA;SAC/C,CAAA,CAAA;AAAA,KAAA;AAeD;;;;AAIG;IACa,qBAAqB,GAAA;;AACnC,YAAA,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,aAAa,EAAE;gBACzC,IAAI;oBACF,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;AACnC,oBAAA,IAAI,IAAI;AAAE,wBAAA,OAAO,MAAM,IAAI,CAAC,WAAW,EAAE,CAAA;AAC1C,iBAAA;AAAC,gBAAA,OAAO,KAAK,EAAE;AACd,oBAAA,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AACpB,iBAAA;AACF,aAAA;AACD,YAAA,MAAM,KAAK,CAAC,mCAAmC,CAAC,CAAA;SACjD,CAAA,CAAA;AAAA,KAAA;AAEF;;;;"}
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/client.ts"],"sourcesContent":["import {\n BaseXChainClient,\n ExplorerProviders,\n FeeEstimateOptions,\n FeeRate,\n FeeRates,\n FeeType,\n Fees,\n FeesWithRates,\n Protocol,\n TxHash,\n TxHistoryParams,\n standardFeeRates,\n} from '@xchainjs/xchain-client'\nimport { Address, Asset, Chain, baseAmount } from '@xchainjs/xchain-util'\nimport { UtxoOnlineDataProviders } from '@xchainjs/xchain-utxo-providers'\n\nimport { Balance, Tx, TxParams, TxsPage, UTXO, UtxoClientParams } from './types'\n/**\n * Abstract base class for creating blockchain clients in the UTXO model.\n */\nexport abstract class Client extends BaseXChainClient {\n protected explorerProviders: ExplorerProviders\n protected dataProviders: UtxoOnlineDataProviders[]\n\n /**\n * Constructor for creating a UTXO client instance.\n *\n * @param {Chain} chain The blockchain chain type.\n * @param {UtxoClientParams} params The parameters required for client initialization.\n */\n constructor(chain: Chain, params: UtxoClientParams) {\n super(chain, {\n network: params.network,\n rootDerivationPaths: params.rootDerivationPaths,\n phrase: params.phrase,\n feeBounds: params.feeBounds,\n })\n this.explorerProviders = params.explorerProviders\n this.dataProviders = params.dataProviders\n }\n\n /**\n * Get the explorer URL based on the network.\n *\n * @returns {string} The explorer URL.\n */\n getExplorerUrl(): string {\n return this.explorerProviders[this.network].getExplorerUrl()\n }\n\n /**\n * Get the explorer URL for a given address based on the network.\n *\n * @param {string} address The address to query.\n * @returns {string} The explorer URL for the address.\n */\n getExplorerAddressUrl(address: string): string {\n return this.explorerProviders[this.network].getExplorerAddressUrl(address)\n }\n\n /**\n * Get the explorer URL for a given transaction ID based on the network.\n *\n * @param {string} txID The transaction ID.\n * @returns {string} The explorer URL for the transaction.\n */\n getExplorerTxUrl(txID: string): string {\n return this.explorerProviders[this.network].getExplorerTxUrl(txID)\n }\n\n /**\n * Get the transaction history of a given address with pagination options.\n *\n * @param {TxHistoryParams} params The options to get transaction history.\n * @returns {TxsPage} The transaction history.\n */\n async getTransactions(params?: TxHistoryParams): Promise<TxsPage> {\n // Filter the parameters for transaction history\n const filteredParams: TxHistoryParams = {\n address: params?.address || (await this.getAddress()),\n offset: params?.offset,\n limit: params?.limit,\n startTime: params?.startTime,\n asset: params?.asset,\n }\n\n return await this.roundRobinGetTransactions(filteredParams)\n }\n\n /**\n * Get the transaction details of a given transaction ID.\n *\n * @param {string} txId The transaction ID.\n * @returns {Tx} The transaction details.\n */\n async getTransactionData(txId: string): Promise<Tx> {\n return await this.roundRobinGetTransactionData(txId)\n }\n\n /**\n * Gets balance of a given address.\n *\n * @param {Address} address The address to get balances from\n * @param {undefined} Needed for legacy only to be in common with `XChainClient` interface - will be removed by a next version\n * @param {confirmedOnly} Flag to get balances of confirmed txs only\n *\n * @returns {Balance[]} BTC balances\n */\n // TODO (@xchain-team|@veado) Change params to be an object to be extendable more easily\n // see changes for `xchain-bitcoin` https://github.com/xchainjs/xchainjs-lib/pull/490\n async getBalance(address: Address, _assets?: Asset[] /* not used */, confirmedOnly?: boolean): Promise<Balance[]> {\n // The actual logic for getting balances\n confirmedOnly\n return await this.roundRobinGetBalance(address)\n }\n /**\n * Scan UTXOs for a given address.\n *\n * @param {string} address The address to scan.\n * @param {boolean} confirmedOnly Flag to scan only confirmed UTXOs.\n * @returns {UTXO[]} The UTXOs found.\n */\n protected async scanUTXOs(\n address: string,\n confirmedOnly = true, // default: scan only confirmed UTXOs\n ): Promise<UTXO[]> {\n return this.roundRobinGetUnspentTxs(address, confirmedOnly)\n }\n /**\n * Get estimated fees with fee rates.\n *\n * @param {FeeEstimateOptions} options Options for fee estimation.\n * @returns {Promise<FeesWithRates>} Estimated fees along with fee rates.\n */\n async getFeesWithRates(options?: FeeEstimateOptions): Promise<FeesWithRates> {\n // Scan UTXOs if sender address is provided\n const utxos = options?.sender ? await this.scanUTXOs(options.sender, false) : []\n // Compile memo if memo is provided\n const compiledMemo = options?.memo ? this.compileMemo(options.memo) : null\n // Get fee rates\n const rates = await this.getFeeRates()\n\n return {\n fees: {\n average: baseAmount(this.getFeeFromUtxos(utxos, rates.average, compiledMemo)),\n fast: baseAmount(this.getFeeFromUtxos(utxos, rates.fast, compiledMemo)),\n fastest: baseAmount(this.getFeeFromUtxos(utxos, rates.fastest, compiledMemo)),\n type: FeeType.PerByte,\n },\n rates,\n }\n }\n /**\n * Get estimated fees.\n *\n * @param {FeeEstimateOptions} options Options for fee estimation.\n * @returns {Promise<Fees>} Estimated fees.\n */\n async getFees(options?: FeeEstimateOptions): Promise<Fees> {\n const { fees } = await this.getFeesWithRates(options)\n return fees\n }\n\n /**\n * Get fee rates\n * @param {Protocol} protocol Protocol to interact with. If there's no protocol provided, fee rates are retrieved from chain data providers\n *\n * @returns {FeeRates} The fee rates (average, fast, fastest) in `Satoshis/byte`\n */\n async getFeeRates(protocol?: Protocol): Promise<FeeRates> {\n if (!protocol) {\n try {\n const feeRates = await this.roundRobinGetFeeRates()\n return feeRates\n } catch (error) {\n console.warn('Can not retrieve fee rates from provider')\n }\n }\n\n if (!protocol || Protocol.THORCHAIN) {\n try {\n const feeRate = await this.getFeeRateFromThorchain()\n return standardFeeRates(feeRate)\n } catch (error) {\n console.warn(`Can not retrieve fee rates from Thorchain`)\n }\n }\n // TODO: Return default value\n throw Error('Can not retrieve fee rates')\n }\n /**\n * Broadcast a transaction.\n *\n * @param {string} txHex The transaction hex string.\n * @returns {Promise<TxHash>} The transaction hash.\n */\n async broadcastTx(txHex: string): Promise<TxHash> {\n return await this.roundRobinBroadcastTx(txHex)\n }\n /**\n * Round-robin method to get balance from data providers.\n * Throws error if no provider can get balance.\n *\n * @param {Address} address The address to get balance for.\n * @returns {Promise<Balance[]>} The balances.\n * @throws Error If no provider is able to get balance.\n */\n\n protected async roundRobinGetBalance(address: Address) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.getBalance(address)\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to get balance')\n }\n /**\n * Round-robin method to get unspent transactions from data providers.\n * Throws error if no provider can get unspent transactions.\n *\n * @param {Address} address The address to get unspent transactions for.\n * @param {boolean} confirmed Flag to indicate whether to get confirmed transactions only.\n * @returns {Promise<UTXO[]>} The unspent transactions.\n * @throws Error If no provider is able to get unspent transactions.\n */\n protected async roundRobinGetUnspentTxs(address: Address, confirmed: boolean) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) {\n return confirmed ? await prov.getConfirmedUnspentTxs(address) : await prov.getUnspentTxs(address)\n }\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to GetUnspentTxs')\n }\n /**\n * Round-robin method to get transaction data from data providers.\n * Throws error if no provider can get transaction data.\n *\n * @param {string} txid The transaction ID to get data for.\n * @returns {Promise<Tx>} The transaction data.\n * @throws Error If no provider is able to get transaction data.\n */\n protected async roundRobinGetTransactionData(txid: string) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.getTransactionData(txid)\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to GetTransactionData')\n }\n /**\n * Round-robin method to get transactions from data providers.\n * Throws error if no provider can get transactions.\n *\n * @param {TxHistoryParams} params The parameters for fetching transactions.\n * @returns {Promise<TxsPage>} The transaction history.\n * @throws Error If no provider is able to get transactions.\n */\n protected async roundRobinGetTransactions(params: TxHistoryParams) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.getTransactions(params)\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to GetTransactions')\n }\n /**\n * Broadcasts a transaction hex using a round-robin approach across multiple data providers.\n * @param {string} txHex The transaction hex to broadcast.\n * @returns {Promise<TxHash>} The hash of the broadcasted transaction.\n * @throws {Error} Throws an error if no provider is able to broadcast the transaction.\n */\n protected async roundRobinBroadcastTx(txHex: string) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.broadcastTx(txHex)\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to BroadcastTx')\n }\n /**\n * Abstract method to compile a memo.\n * @param {string} memo The memo string to compile.\n * @returns {Buffer} The compiled memo.\n */\n protected abstract compileMemo(memo: string): Buffer\n /**\n * Abstract method to calculate the fee from a list of UTXOs.\n * @param {UTXO[]} inputs The list of UTXOs.\n * @param {FeeRate} feeRate The fee rate.\n * @param {Buffer | null} data Optional data buffer.\n * @returns {number} The calculated fee.\n */\n protected abstract getFeeFromUtxos(inputs: UTXO[], feeRate: FeeRate, data: Buffer | null): number\n /**\n * Retrieves fee rates using a round-robin approach across multiple data providers.\n * @returns {Promise<FeeRates>} The fee rates (average, fast, fastest) in `Satoshis/byte`.\n * @throws {Error} Throws an error if no provider is able to retrieve fee rates.\n */\n protected async roundRobinGetFeeRates(): Promise<FeeRates> {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.getFeeRates()\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to get fee rates')\n }\n public abstract transfer(params: TxParams & { feeRate?: number }): Promise<string>\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;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
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var xchainClient = require('@xchainjs/xchain-client');
|
|
6
4
|
var xchainUtil = require('@xchainjs/xchain-util');
|
|
7
5
|
|
|
@@ -19,6 +17,8 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
19
17
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
20
18
|
PERFORMANCE OF THIS SOFTWARE.
|
|
21
19
|
***************************************************************************** */
|
|
20
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
21
|
+
|
|
22
22
|
|
|
23
23
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
24
24
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
@@ -28,7 +28,12 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
28
28
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
29
29
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
30
30
|
});
|
|
31
|
-
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
34
|
+
var e = new Error(message);
|
|
35
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
36
|
+
};
|
|
32
37
|
|
|
33
38
|
/**
|
|
34
39
|
* Abstract base class for creating blockchain clients in the UTXO model.
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/client.ts"],"sourcesContent":["import {\n BaseXChainClient,\n ExplorerProviders,\n FeeEstimateOptions,\n FeeRate,\n FeeRates,\n FeeType,\n Fees,\n FeesWithRates,\n Protocol,\n TxHash,\n TxHistoryParams,\n standardFeeRates,\n} from '@xchainjs/xchain-client'\nimport { Address, Asset, Chain, baseAmount } from '@xchainjs/xchain-util'\nimport { UtxoOnlineDataProviders } from '@xchainjs/xchain-utxo-providers'\n\nimport { Balance, Tx, TxParams, TxsPage, UTXO, UtxoClientParams } from './types'\n/**\n * Abstract base class for creating blockchain clients in the UTXO model.\n */\nexport abstract class Client extends BaseXChainClient {\n protected explorerProviders: ExplorerProviders\n protected dataProviders: UtxoOnlineDataProviders[]\n\n /**\n * Constructor for creating a UTXO client instance.\n *\n * @param {Chain} chain The blockchain chain type.\n * @param {UtxoClientParams} params The parameters required for client initialization.\n */\n constructor(chain: Chain, params: UtxoClientParams) {\n super(chain, {\n network: params.network,\n rootDerivationPaths: params.rootDerivationPaths,\n phrase: params.phrase,\n feeBounds: params.feeBounds,\n })\n this.explorerProviders = params.explorerProviders\n this.dataProviders = params.dataProviders\n }\n\n /**\n * Get the explorer URL based on the network.\n *\n * @returns {string} The explorer URL.\n */\n getExplorerUrl(): string {\n return this.explorerProviders[this.network].getExplorerUrl()\n }\n\n /**\n * Get the explorer URL for a given address based on the network.\n *\n * @param {string} address The address to query.\n * @returns {string} The explorer URL for the address.\n */\n getExplorerAddressUrl(address: string): string {\n return this.explorerProviders[this.network].getExplorerAddressUrl(address)\n }\n\n /**\n * Get the explorer URL for a given transaction ID based on the network.\n *\n * @param {string} txID The transaction ID.\n * @returns {string} The explorer URL for the transaction.\n */\n getExplorerTxUrl(txID: string): string {\n return this.explorerProviders[this.network].getExplorerTxUrl(txID)\n }\n\n /**\n * Get the transaction history of a given address with pagination options.\n *\n * @param {TxHistoryParams} params The options to get transaction history.\n * @returns {TxsPage} The transaction history.\n */\n async getTransactions(params?: TxHistoryParams): Promise<TxsPage> {\n // Filter the parameters for transaction history\n const filteredParams: TxHistoryParams = {\n address: params?.address || (await this.getAddress()),\n offset: params?.offset,\n limit: params?.limit,\n startTime: params?.startTime,\n asset: params?.asset,\n }\n\n return await this.roundRobinGetTransactions(filteredParams)\n }\n\n /**\n * Get the transaction details of a given transaction ID.\n *\n * @param {string} txId The transaction ID.\n * @returns {Tx} The transaction details.\n */\n async getTransactionData(txId: string): Promise<Tx> {\n return await this.roundRobinGetTransactionData(txId)\n }\n\n /**\n * Gets balance of a given address.\n *\n * @param {Address} address The address to get balances from\n * @param {undefined} Needed for legacy only to be in common with `XChainClient` interface - will be removed by a next version\n * @param {confirmedOnly} Flag to get balances of confirmed txs only\n *\n * @returns {Balance[]} BTC balances\n */\n // TODO (@xchain-team|@veado) Change params to be an object to be extendable more easily\n // see changes for `xchain-bitcoin` https://github.com/xchainjs/xchainjs-lib/pull/490\n async getBalance(address: Address, _assets?: Asset[] /* not used */, confirmedOnly?: boolean): Promise<Balance[]> {\n // The actual logic for getting balances\n confirmedOnly\n return await this.roundRobinGetBalance(address)\n }\n /**\n * Scan UTXOs for a given address.\n *\n * @param {string} address The address to scan.\n * @param {boolean} confirmedOnly Flag to scan only confirmed UTXOs.\n * @returns {UTXO[]} The UTXOs found.\n */\n protected async scanUTXOs(\n address: string,\n confirmedOnly = true, // default: scan only confirmed UTXOs\n ): Promise<UTXO[]> {\n return this.roundRobinGetUnspentTxs(address, confirmedOnly)\n }\n /**\n * Get estimated fees with fee rates.\n *\n * @param {FeeEstimateOptions} options Options for fee estimation.\n * @returns {Promise<FeesWithRates>} Estimated fees along with fee rates.\n */\n async getFeesWithRates(options?: FeeEstimateOptions): Promise<FeesWithRates> {\n // Scan UTXOs if sender address is provided\n const utxos = options?.sender ? await this.scanUTXOs(options.sender, false) : []\n // Compile memo if memo is provided\n const compiledMemo = options?.memo ? this.compileMemo(options.memo) : null\n // Get fee rates\n const rates = await this.getFeeRates()\n\n return {\n fees: {\n average: baseAmount(this.getFeeFromUtxos(utxos, rates.average, compiledMemo)),\n fast: baseAmount(this.getFeeFromUtxos(utxos, rates.fast, compiledMemo)),\n fastest: baseAmount(this.getFeeFromUtxos(utxos, rates.fastest, compiledMemo)),\n type: FeeType.PerByte,\n },\n rates,\n }\n }\n /**\n * Get estimated fees.\n *\n * @param {FeeEstimateOptions} options Options for fee estimation.\n * @returns {Promise<Fees>} Estimated fees.\n */\n async getFees(options?: FeeEstimateOptions): Promise<Fees> {\n const { fees } = await this.getFeesWithRates(options)\n return fees\n }\n\n /**\n * Get fee rates\n * @param {Protocol} protocol Protocol to interact with. If there's no protocol provided, fee rates are retrieved from chain data providers\n *\n * @returns {FeeRates} The fee rates (average, fast, fastest) in `Satoshis/byte`\n */\n async getFeeRates(protocol?: Protocol): Promise<FeeRates> {\n if (!protocol) {\n try {\n const feeRates = await this.roundRobinGetFeeRates()\n return feeRates\n } catch (error) {\n console.warn('Can not retrieve fee rates from provider')\n }\n }\n\n if (!protocol || Protocol.THORCHAIN) {\n try {\n const feeRate = await this.getFeeRateFromThorchain()\n return standardFeeRates(feeRate)\n } catch (error) {\n console.warn(`Can not retrieve fee rates from Thorchain`)\n }\n }\n // TODO: Return default value\n throw Error('Can not retrieve fee rates')\n }\n /**\n * Broadcast a transaction.\n *\n * @param {string} txHex The transaction hex string.\n * @returns {Promise<TxHash>} The transaction hash.\n */\n async broadcastTx(txHex: string): Promise<TxHash> {\n return await this.roundRobinBroadcastTx(txHex)\n }\n /**\n * Round-robin method to get balance from data providers.\n * Throws error if no provider can get balance.\n *\n * @param {Address} address The address to get balance for.\n * @returns {Promise<Balance[]>} The balances.\n * @throws Error If no provider is able to get balance.\n */\n\n protected async roundRobinGetBalance(address: Address) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.getBalance(address)\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to get balance')\n }\n /**\n * Round-robin method to get unspent transactions from data providers.\n * Throws error if no provider can get unspent transactions.\n *\n * @param {Address} address The address to get unspent transactions for.\n * @param {boolean} confirmed Flag to indicate whether to get confirmed transactions only.\n * @returns {Promise<UTXO[]>} The unspent transactions.\n * @throws Error If no provider is able to get unspent transactions.\n */\n protected async roundRobinGetUnspentTxs(address: Address, confirmed: boolean) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) {\n return confirmed ? await prov.getConfirmedUnspentTxs(address) : await prov.getUnspentTxs(address)\n }\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to GetUnspentTxs')\n }\n /**\n * Round-robin method to get transaction data from data providers.\n * Throws error if no provider can get transaction data.\n *\n * @param {string} txid The transaction ID to get data for.\n * @returns {Promise<Tx>} The transaction data.\n * @throws Error If no provider is able to get transaction data.\n */\n protected async roundRobinGetTransactionData(txid: string) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.getTransactionData(txid)\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to GetTransactionData')\n }\n /**\n * Round-robin method to get transactions from data providers.\n * Throws error if no provider can get transactions.\n *\n * @param {TxHistoryParams} params The parameters for fetching transactions.\n * @returns {Promise<TxsPage>} The transaction history.\n * @throws Error If no provider is able to get transactions.\n */\n protected async roundRobinGetTransactions(params: TxHistoryParams) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.getTransactions(params)\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to GetTransactions')\n }\n /**\n * Broadcasts a transaction hex using a round-robin approach across multiple data providers.\n * @param {string} txHex The transaction hex to broadcast.\n * @returns {Promise<TxHash>} The hash of the broadcasted transaction.\n * @throws {Error} Throws an error if no provider is able to broadcast the transaction.\n */\n protected async roundRobinBroadcastTx(txHex: string) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.broadcastTx(txHex)\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to BroadcastTx')\n }\n /**\n * Abstract method to compile a memo.\n * @param {string} memo The memo string to compile.\n * @returns {Buffer} The compiled memo.\n */\n protected abstract compileMemo(memo: string): Buffer\n /**\n * Abstract method to calculate the fee from a list of UTXOs.\n * @param {UTXO[]} inputs The list of UTXOs.\n * @param {FeeRate} feeRate The fee rate.\n * @param {Buffer | null} data Optional data buffer.\n * @returns {number} The calculated fee.\n */\n protected abstract getFeeFromUtxos(inputs: UTXO[], feeRate: FeeRate, data: Buffer | null): number\n /**\n * Retrieves fee rates using a round-robin approach across multiple data providers.\n * @returns {Promise<FeeRates>} The fee rates (average, fast, fastest) in `Satoshis/byte`.\n * @throws {Error} Throws an error if no provider is able to retrieve fee rates.\n */\n protected async roundRobinGetFeeRates(): Promise<FeeRates> {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.getFeeRates()\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to get fee rates')\n }\n public abstract transfer(params: TxParams & { feeRate?: number }): Promise<string>\n}\n"],"names":["BaseXChainClient","baseAmount","FeeType","Protocol","standardFeeRates"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA;;AAEG;AACG,MAAgB,MAAO,SAAQA,6BAAgB,CAAA;AAInD;;;;;AAKG;IACH,WAAY,CAAA,KAAY,EAAE,MAAwB,EAAA;QAChD,KAAK,CAAC,KAAK,EAAE;YACX,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,mBAAmB,EAAE,MAAM,CAAC,mBAAmB;YAC/C,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,SAAS,EAAE,MAAM,CAAC,SAAS;AAC5B,SAAA,CAAC,CAAA;AACF,QAAA,IAAI,CAAC,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAA;AACjD,QAAA,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,CAAA;KAC1C;AAED;;;;AAIG;IACH,cAAc,GAAA;QACZ,OAAO,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,cAAc,EAAE,CAAA;KAC7D;AAED;;;;;AAKG;AACH,IAAA,qBAAqB,CAAC,OAAe,EAAA;AACnC,Q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,CAAA;AACpB,iBAAA;AACF,aAAA;AACD,YAAA,MAAM,KAAK,CAAC,iCAAiC,CAAC,CAAA;SAC/C,CAAA,CAAA;AAAA,KAAA;AAeD;;;;AAIG;IACa,qBAAqB,GAAA;;AACnC,YAAA,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,aAAa,EAAE;gBACzC,IAAI;oBACF,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;AACnC,oBAAA,IAAI,IAAI;AAAE,wBAAA,OAAO,MAAM,IAAI,CAAC,WAAW,EAAE,CAAA;AAC1C,iBAAA;AAAC,gBAAA,OAAO,KAAK,EAAE;AACd,oBAAA,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AACpB,iBAAA;AACF,aAAA;AACD,YAAA,MAAM,KAAK,CAAC,mCAAmC,CAAC,CAAA;SACjD,CAAA,CAAA;AAAA,KAAA;AAEF;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/client.ts"],"sourcesContent":["import {\n BaseXChainClient,\n ExplorerProviders,\n FeeEstimateOptions,\n FeeRate,\n FeeRates,\n FeeType,\n Fees,\n FeesWithRates,\n Protocol,\n TxHash,\n TxHistoryParams,\n standardFeeRates,\n} from '@xchainjs/xchain-client'\nimport { Address, Asset, Chain, baseAmount } from '@xchainjs/xchain-util'\nimport { UtxoOnlineDataProviders } from '@xchainjs/xchain-utxo-providers'\n\nimport { Balance, Tx, TxParams, TxsPage, UTXO, UtxoClientParams } from './types'\n/**\n * Abstract base class for creating blockchain clients in the UTXO model.\n */\nexport abstract class Client extends BaseXChainClient {\n protected explorerProviders: ExplorerProviders\n protected dataProviders: UtxoOnlineDataProviders[]\n\n /**\n * Constructor for creating a UTXO client instance.\n *\n * @param {Chain} chain The blockchain chain type.\n * @param {UtxoClientParams} params The parameters required for client initialization.\n */\n constructor(chain: Chain, params: UtxoClientParams) {\n super(chain, {\n network: params.network,\n rootDerivationPaths: params.rootDerivationPaths,\n phrase: params.phrase,\n feeBounds: params.feeBounds,\n })\n this.explorerProviders = params.explorerProviders\n this.dataProviders = params.dataProviders\n }\n\n /**\n * Get the explorer URL based on the network.\n *\n * @returns {string} The explorer URL.\n */\n getExplorerUrl(): string {\n return this.explorerProviders[this.network].getExplorerUrl()\n }\n\n /**\n * Get the explorer URL for a given address based on the network.\n *\n * @param {string} address The address to query.\n * @returns {string} The explorer URL for the address.\n */\n getExplorerAddressUrl(address: string): string {\n return this.explorerProviders[this.network].getExplorerAddressUrl(address)\n }\n\n /**\n * Get the explorer URL for a given transaction ID based on the network.\n *\n * @param {string} txID The transaction ID.\n * @returns {string} The explorer URL for the transaction.\n */\n getExplorerTxUrl(txID: string): string {\n return this.explorerProviders[this.network].getExplorerTxUrl(txID)\n }\n\n /**\n * Get the transaction history of a given address with pagination options.\n *\n * @param {TxHistoryParams} params The options to get transaction history.\n * @returns {TxsPage} The transaction history.\n */\n async getTransactions(params?: TxHistoryParams): Promise<TxsPage> {\n // Filter the parameters for transaction history\n const filteredParams: TxHistoryParams = {\n address: params?.address || (await this.getAddress()),\n offset: params?.offset,\n limit: params?.limit,\n startTime: params?.startTime,\n asset: params?.asset,\n }\n\n return await this.roundRobinGetTransactions(filteredParams)\n }\n\n /**\n * Get the transaction details of a given transaction ID.\n *\n * @param {string} txId The transaction ID.\n * @returns {Tx} The transaction details.\n */\n async getTransactionData(txId: string): Promise<Tx> {\n return await this.roundRobinGetTransactionData(txId)\n }\n\n /**\n * Gets balance of a given address.\n *\n * @param {Address} address The address to get balances from\n * @param {undefined} Needed for legacy only to be in common with `XChainClient` interface - will be removed by a next version\n * @param {confirmedOnly} Flag to get balances of confirmed txs only\n *\n * @returns {Balance[]} BTC balances\n */\n // TODO (@xchain-team|@veado) Change params to be an object to be extendable more easily\n // see changes for `xchain-bitcoin` https://github.com/xchainjs/xchainjs-lib/pull/490\n async getBalance(address: Address, _assets?: Asset[] /* not used */, confirmedOnly?: boolean): Promise<Balance[]> {\n // The actual logic for getting balances\n confirmedOnly\n return await this.roundRobinGetBalance(address)\n }\n /**\n * Scan UTXOs for a given address.\n *\n * @param {string} address The address to scan.\n * @param {boolean} confirmedOnly Flag to scan only confirmed UTXOs.\n * @returns {UTXO[]} The UTXOs found.\n */\n protected async scanUTXOs(\n address: string,\n confirmedOnly = true, // default: scan only confirmed UTXOs\n ): Promise<UTXO[]> {\n return this.roundRobinGetUnspentTxs(address, confirmedOnly)\n }\n /**\n * Get estimated fees with fee rates.\n *\n * @param {FeeEstimateOptions} options Options for fee estimation.\n * @returns {Promise<FeesWithRates>} Estimated fees along with fee rates.\n */\n async getFeesWithRates(options?: FeeEstimateOptions): Promise<FeesWithRates> {\n // Scan UTXOs if sender address is provided\n const utxos = options?.sender ? await this.scanUTXOs(options.sender, false) : []\n // Compile memo if memo is provided\n const compiledMemo = options?.memo ? this.compileMemo(options.memo) : null\n // Get fee rates\n const rates = await this.getFeeRates()\n\n return {\n fees: {\n average: baseAmount(this.getFeeFromUtxos(utxos, rates.average, compiledMemo)),\n fast: baseAmount(this.getFeeFromUtxos(utxos, rates.fast, compiledMemo)),\n fastest: baseAmount(this.getFeeFromUtxos(utxos, rates.fastest, compiledMemo)),\n type: FeeType.PerByte,\n },\n rates,\n }\n }\n /**\n * Get estimated fees.\n *\n * @param {FeeEstimateOptions} options Options for fee estimation.\n * @returns {Promise<Fees>} Estimated fees.\n */\n async getFees(options?: FeeEstimateOptions): Promise<Fees> {\n const { fees } = await this.getFeesWithRates(options)\n return fees\n }\n\n /**\n * Get fee rates\n * @param {Protocol} protocol Protocol to interact with. If there's no protocol provided, fee rates are retrieved from chain data providers\n *\n * @returns {FeeRates} The fee rates (average, fast, fastest) in `Satoshis/byte`\n */\n async getFeeRates(protocol?: Protocol): Promise<FeeRates> {\n if (!protocol) {\n try {\n const feeRates = await this.roundRobinGetFeeRates()\n return feeRates\n } catch (error) {\n console.warn('Can not retrieve fee rates from provider')\n }\n }\n\n if (!protocol || Protocol.THORCHAIN) {\n try {\n const feeRate = await this.getFeeRateFromThorchain()\n return standardFeeRates(feeRate)\n } catch (error) {\n console.warn(`Can not retrieve fee rates from Thorchain`)\n }\n }\n // TODO: Return default value\n throw Error('Can not retrieve fee rates')\n }\n /**\n * Broadcast a transaction.\n *\n * @param {string} txHex The transaction hex string.\n * @returns {Promise<TxHash>} The transaction hash.\n */\n async broadcastTx(txHex: string): Promise<TxHash> {\n return await this.roundRobinBroadcastTx(txHex)\n }\n /**\n * Round-robin method to get balance from data providers.\n * Throws error if no provider can get balance.\n *\n * @param {Address} address The address to get balance for.\n * @returns {Promise<Balance[]>} The balances.\n * @throws Error If no provider is able to get balance.\n */\n\n protected async roundRobinGetBalance(address: Address) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.getBalance(address)\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to get balance')\n }\n /**\n * Round-robin method to get unspent transactions from data providers.\n * Throws error if no provider can get unspent transactions.\n *\n * @param {Address} address The address to get unspent transactions for.\n * @param {boolean} confirmed Flag to indicate whether to get confirmed transactions only.\n * @returns {Promise<UTXO[]>} The unspent transactions.\n * @throws Error If no provider is able to get unspent transactions.\n */\n protected async roundRobinGetUnspentTxs(address: Address, confirmed: boolean) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) {\n return confirmed ? await prov.getConfirmedUnspentTxs(address) : await prov.getUnspentTxs(address)\n }\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to GetUnspentTxs')\n }\n /**\n * Round-robin method to get transaction data from data providers.\n * Throws error if no provider can get transaction data.\n *\n * @param {string} txid The transaction ID to get data for.\n * @returns {Promise<Tx>} The transaction data.\n * @throws Error If no provider is able to get transaction data.\n */\n protected async roundRobinGetTransactionData(txid: string) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.getTransactionData(txid)\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to GetTransactionData')\n }\n /**\n * Round-robin method to get transactions from data providers.\n * Throws error if no provider can get transactions.\n *\n * @param {TxHistoryParams} params The parameters for fetching transactions.\n * @returns {Promise<TxsPage>} The transaction history.\n * @throws Error If no provider is able to get transactions.\n */\n protected async roundRobinGetTransactions(params: TxHistoryParams) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.getTransactions(params)\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to GetTransactions')\n }\n /**\n * Broadcasts a transaction hex using a round-robin approach across multiple data providers.\n * @param {string} txHex The transaction hex to broadcast.\n * @returns {Promise<TxHash>} The hash of the broadcasted transaction.\n * @throws {Error} Throws an error if no provider is able to broadcast the transaction.\n */\n protected async roundRobinBroadcastTx(txHex: string) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.broadcastTx(txHex)\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to BroadcastTx')\n }\n /**\n * Abstract method to compile a memo.\n * @param {string} memo The memo string to compile.\n * @returns {Buffer} The compiled memo.\n */\n protected abstract compileMemo(memo: string): Buffer\n /**\n * Abstract method to calculate the fee from a list of UTXOs.\n * @param {UTXO[]} inputs The list of UTXOs.\n * @param {FeeRate} feeRate The fee rate.\n * @param {Buffer | null} data Optional data buffer.\n * @returns {number} The calculated fee.\n */\n protected abstract getFeeFromUtxos(inputs: UTXO[], feeRate: FeeRate, data: Buffer | null): number\n /**\n * Retrieves fee rates using a round-robin approach across multiple data providers.\n * @returns {Promise<FeeRates>} The fee rates (average, fast, fastest) in `Satoshis/byte`.\n * @throws {Error} Throws an error if no provider is able to retrieve fee rates.\n */\n protected async roundRobinGetFeeRates(): Promise<FeeRates> {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.getFeeRates()\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to get fee rates')\n }\n public abstract transfer(params: TxParams & { feeRate?: number }): Promise<string>\n}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D,YAAA,MAAM,KAAK,CAAC,mCAAmC,CAAC,CAAA;SACjD,CAAA,CAAA;AAAA,KAAA;AAEF;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xchainjs/xchain-utxo",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Genereic UTXO client for XChainJS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"XChain",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
27
|
"clean": "rm -rf .turbo && rm -rf lib",
|
|
28
|
-
"build": "yarn clean && rollup -c",
|
|
28
|
+
"build": "yarn clean && rollup -c --bundleConfigAsCjs",
|
|
29
29
|
"build:release": "yarn exec rm -rf release && yarn pack && yarn exec \"mkdir release && tar zxvf package.tgz --directory release && rm package.tgz\"",
|
|
30
30
|
"lint": "eslint \"{src,__tests__, __mocks__}/**/*.ts\" --fix --max-warnings 0"
|
|
31
31
|
},
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"directory": "release/package"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@xchainjs/xchain-client": "1.0.
|
|
38
|
-
"@xchainjs/xchain-util": "1.0.
|
|
39
|
-
"@xchainjs/xchain-utxo-providers": "1.0.
|
|
37
|
+
"@xchainjs/xchain-client": "1.0.7",
|
|
38
|
+
"@xchainjs/xchain-util": "1.0.6",
|
|
39
|
+
"@xchainjs/xchain-utxo-providers": "1.0.7"
|
|
40
40
|
}
|
|
41
41
|
}
|