@bigmi/core 0.8.1 → 0.9.1
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/CHANGELOG.md +22 -0
- package/README.md +2 -2
- package/dist/cjs/_virtual/_rolldown/runtime.js +1 -1
- package/dist/cjs/actions/getBalance.d.ts +5 -6
- package/dist/cjs/actions/getBlock.d.ts +3 -8
- package/dist/cjs/actions/getBlockCount.d.ts +2 -4
- package/dist/cjs/actions/getBlockStats.d.ts +3 -9
- package/dist/cjs/actions/getTransactionFee.d.ts +3 -7
- package/dist/cjs/actions/getTransactions.d.ts +3 -10
- package/dist/cjs/actions/getUTXOTransaction.d.ts +6 -9
- package/dist/cjs/actions/getUTXOs.d.ts +3 -8
- package/dist/cjs/actions/getXPubAddresses.d.ts +25 -26
- package/dist/cjs/actions/sendUTXOTransaction.d.ts +6 -9
- package/dist/cjs/actions/signPsbt.d.ts +1 -3
- package/dist/cjs/actions/waitForTransaction.d.ts +48 -55
- package/dist/cjs/actions/waitForTransaction.js.map +1 -1
- package/dist/cjs/actions/watchBlockNumber.d.ts +18 -21
- package/dist/cjs/actions/watchBlockNumber.js +3 -2
- package/dist/cjs/actions/watchBlockNumber.js.map +1 -1
- package/dist/cjs/chains/bitcoin.d.ts +1 -3
- package/dist/cjs/chains/bitcoin.js.map +1 -1
- package/dist/cjs/chains/defineChain.d.ts +1 -3
- package/dist/cjs/chains/signet.d.ts +1 -3
- package/dist/cjs/chains/signet.js.map +1 -1
- package/dist/cjs/clients/decorators/public.d.ts +2 -4
- package/dist/cjs/clients/decorators/wallet.d.ts +4 -6
- package/dist/cjs/errors/address.d.ts +3 -7
- package/dist/cjs/errors/base.d.ts +3 -4
- package/dist/cjs/errors/base.js.map +1 -1
- package/dist/cjs/errors/block.d.ts +3 -8
- package/dist/cjs/errors/provider.d.ts +1 -3
- package/dist/cjs/errors/request.d.ts +15 -39
- package/dist/cjs/errors/request.js.map +1 -1
- package/dist/cjs/errors/rpc.d.ts +28 -30
- package/dist/cjs/errors/transaction.d.ts +9 -21
- package/dist/cjs/errors/transport.d.ts +8 -17
- package/dist/cjs/errors/transport.js.map +1 -1
- package/dist/cjs/errors/utils.d.ts +3 -5
- package/dist/cjs/errors/utxo.d.ts +3 -9
- package/dist/cjs/factories/createClient.d.ts +55 -37
- package/dist/cjs/factories/createClient.js.map +1 -1
- package/dist/cjs/factories/createTransport.d.ts +3 -14
- package/dist/cjs/test/utils.d.ts +1 -2
- package/dist/cjs/transports/ankr/ankr.d.ts +1 -3
- package/dist/cjs/transports/ankr/ankr.types.d.ts +7 -8
- package/dist/cjs/transports/ankr/getBalance.d.ts +1 -3
- package/dist/cjs/transports/ankr/getTransactionFee.d.ts +1 -3
- package/dist/cjs/transports/ankr/getTransactions.d.ts +1 -3
- package/dist/cjs/transports/ankr/methods.d.ts +1 -3
- package/dist/cjs/transports/ankr/utils.d.ts +1 -3
- package/dist/cjs/transports/blockchair/blockchair.d.ts +1 -3
- package/dist/cjs/transports/blockchair/blockchair.types.d.ts +13 -14
- package/dist/cjs/transports/blockchair/getBalance.d.ts +1 -3
- package/dist/cjs/transports/blockchair/getTransactionFee.d.ts +1 -3
- package/dist/cjs/transports/blockchair/getTransactionFee.js.map +1 -1
- package/dist/cjs/transports/blockchair/getUTXOs.d.ts +1 -3
- package/dist/cjs/transports/blockchair/getUTXOs.js.map +1 -1
- package/dist/cjs/transports/blockchair/getXPubAddresses.d.ts +1 -3
- package/dist/cjs/transports/blockchair/getXPubAddresses.js.map +1 -1
- package/dist/cjs/transports/blockchair/methods.d.ts +1 -3
- package/dist/cjs/transports/blockcypher/blockcypher.d.ts +1 -3
- package/dist/cjs/transports/blockcypher/blockcypher.types.d.ts +8 -9
- package/dist/cjs/transports/blockcypher/getBalance.d.ts +1 -3
- package/dist/cjs/transports/blockcypher/getTransactionFee.d.ts +1 -3
- package/dist/cjs/transports/blockcypher/getUTXOs.d.ts +1 -3
- package/dist/cjs/transports/blockcypher/getUTXOs.js.map +1 -1
- package/dist/cjs/transports/blockcypher/methods.d.ts +1 -3
- package/dist/cjs/transports/blockcypher/utils.d.ts +1 -3
- package/dist/cjs/transports/blockcypher/utils.js.map +1 -1
- package/dist/cjs/transports/custom.d.ts +15 -12
- package/dist/cjs/transports/fallback.d.ts +38 -43
- package/dist/cjs/transports/fallback.js.map +1 -1
- package/dist/cjs/transports/getHttpRpcClient.d.ts +23 -16
- package/dist/cjs/transports/getHttpRpcClient.js.map +1 -1
- package/dist/cjs/transports/getRpcProviderMethods.d.ts +1 -3
- package/dist/cjs/transports/http.d.ts +35 -25
- package/dist/cjs/transports/mempool/getBalance.d.ts +1 -3
- package/dist/cjs/transports/mempool/getTransactionFee.d.ts +1 -3
- package/dist/cjs/transports/mempool/getTransactions.d.ts +1 -3
- package/dist/cjs/transports/mempool/getTransactions.js.map +1 -1
- package/dist/cjs/transports/mempool/mempool.d.ts +1 -3
- package/dist/cjs/transports/mempool/mempool.types.d.ts +7 -8
- package/dist/cjs/transports/mempool/methods.d.ts +1 -3
- package/dist/cjs/transports/mempool/utils.d.ts +1 -3
- package/dist/cjs/transports/types.d.ts +28 -27
- package/dist/cjs/transports/utxo.d.ts +1 -3
- package/dist/cjs/transports/utxo.js.map +1 -1
- package/dist/cjs/types/account.d.ts +1 -3
- package/dist/cjs/types/address.d.ts +4 -6
- package/dist/cjs/types/block.d.ts +18 -19
- package/dist/cjs/types/blockStats.d.ts +2 -3
- package/dist/cjs/types/chain.d.ts +26 -16
- package/dist/cjs/types/client.d.ts +43 -29
- package/dist/cjs/types/hash.d.ts +1 -2
- package/dist/cjs/types/request.d.ts +16 -13
- package/dist/cjs/types/rpc.d.ts +4 -5
- package/dist/cjs/types/transaction.d.ts +2 -3
- package/dist/cjs/types/transport.d.ts +18 -14
- package/dist/cjs/types/utils.d.ts +43 -44
- package/dist/cjs/types/xpub.d.ts +1 -3
- package/dist/cjs/utils/buildRequest.d.ts +3 -5
- package/dist/cjs/utils/buildRequest.js +2 -1
- package/dist/cjs/utils/buildRequest.js.map +1 -1
- package/dist/cjs/utils/cancelTransaction.d.ts +1 -3
- package/dist/cjs/utils/converter.d.ts +5 -6
- package/dist/cjs/utils/converter.js.map +1 -1
- package/dist/cjs/utils/createBatchScheduler.d.ts +2 -10
- package/dist/cjs/utils/createBatchScheduler.js.map +1 -1
- package/dist/cjs/utils/deepEqual.d.ts +1 -2
- package/dist/cjs/utils/deepEqual.js.map +1 -1
- package/dist/cjs/utils/getAction.d.ts +7 -9
- package/dist/cjs/utils/getAddressInfo.d.ts +2 -4
- package/dist/cjs/utils/getAddressInfo.js +2 -1
- package/dist/cjs/utils/getAddressInfo.js.map +1 -1
- package/dist/cjs/utils/idCache.d.ts +1 -2
- package/dist/cjs/utils/isAddress.d.ts +1 -3
- package/dist/cjs/utils/lru.d.ts +5 -6
- package/dist/cjs/utils/lru.js.map +1 -1
- package/dist/cjs/utils/modifyFee.d.ts +1 -3
- package/dist/cjs/utils/modifyFee.js.map +1 -1
- package/dist/cjs/utils/observe.d.ts +7 -9
- package/dist/cjs/utils/observe.js.map +1 -1
- package/dist/cjs/utils/parseAccount.d.ts +2 -4
- package/dist/cjs/utils/poll.d.ts +4 -11
- package/dist/cjs/utils/poll.js +2 -1
- package/dist/cjs/utils/poll.js.map +1 -1
- package/dist/cjs/utils/retryUntil.d.ts +18 -17
- package/dist/cjs/utils/retryUntil.js.map +1 -1
- package/dist/cjs/utils/sleep.d.ts +1 -2
- package/dist/cjs/utils/stringify.d.ts +2 -4
- package/dist/cjs/utils/uid.d.ts +1 -2
- package/dist/cjs/utils/uid.js.map +1 -1
- package/dist/cjs/utils/url.d.ts +1 -2
- package/dist/cjs/utils/url.js.map +1 -1
- package/dist/cjs/utils/wait.d.ts +1 -2
- package/dist/cjs/utils/withDedupe.d.ts +2 -7
- package/dist/cjs/utils/withDedupe.js.map +1 -1
- package/dist/cjs/utils/withResolvers.d.ts +2 -3
- package/dist/cjs/utils/withRetry.d.ts +4 -13
- package/dist/cjs/utils/withTimeout.d.ts +3 -11
- package/dist/cjs/utils/withTimeout.js.map +1 -1
- package/dist/cjs/version.d.ts +2 -3
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/cjs/vite-env.d.ts +1 -1
- package/dist/esm/actions/getBalance.d.ts +5 -6
- package/dist/esm/actions/getBalance.d.ts.map +1 -1
- package/dist/esm/actions/getBlock.d.ts +3 -8
- package/dist/esm/actions/getBlock.d.ts.map +1 -1
- package/dist/esm/actions/getBlockCount.d.ts +2 -4
- package/dist/esm/actions/getBlockCount.d.ts.map +1 -1
- package/dist/esm/actions/getBlockStats.d.ts +3 -9
- package/dist/esm/actions/getBlockStats.d.ts.map +1 -1
- package/dist/esm/actions/getTransactionFee.d.ts +3 -7
- package/dist/esm/actions/getTransactionFee.d.ts.map +1 -1
- package/dist/esm/actions/getTransactions.d.ts +3 -10
- package/dist/esm/actions/getTransactions.d.ts.map +1 -1
- package/dist/esm/actions/getUTXOTransaction.d.ts +6 -9
- package/dist/esm/actions/getUTXOTransaction.d.ts.map +1 -1
- package/dist/esm/actions/getUTXOs.d.ts +3 -8
- package/dist/esm/actions/getUTXOs.d.ts.map +1 -1
- package/dist/esm/actions/getXPubAddresses.d.ts +25 -26
- package/dist/esm/actions/getXPubAddresses.d.ts.map +1 -1
- package/dist/esm/actions/sendUTXOTransaction.d.ts +6 -9
- package/dist/esm/actions/sendUTXOTransaction.d.ts.map +1 -1
- package/dist/esm/actions/signPsbt.d.ts +1 -3
- package/dist/esm/actions/signPsbt.d.ts.map +1 -1
- package/dist/esm/actions/waitForTransaction.d.ts +48 -55
- package/dist/esm/actions/waitForTransaction.d.ts.map +1 -1
- package/dist/esm/actions/waitForTransaction.js.map +1 -1
- package/dist/esm/actions/watchBlockNumber.d.ts +18 -21
- package/dist/esm/actions/watchBlockNumber.d.ts.map +1 -1
- package/dist/esm/actions/watchBlockNumber.js +3 -2
- package/dist/esm/actions/watchBlockNumber.js.map +1 -1
- package/dist/esm/chains/bitcoin.d.ts +1 -3
- package/dist/esm/chains/bitcoin.d.ts.map +1 -1
- package/dist/esm/chains/defineChain.d.ts +1 -3
- package/dist/esm/chains/defineChain.d.ts.map +1 -1
- package/dist/esm/chains/signet.d.ts +1 -3
- package/dist/esm/chains/signet.d.ts.map +1 -1
- package/dist/esm/clients/decorators/public.d.ts +2 -4
- package/dist/esm/clients/decorators/public.d.ts.map +1 -1
- package/dist/esm/clients/decorators/wallet.d.ts +4 -6
- package/dist/esm/clients/decorators/wallet.d.ts.map +1 -1
- package/dist/esm/errors/address.d.ts +3 -7
- package/dist/esm/errors/address.d.ts.map +1 -1
- package/dist/esm/errors/base.d.ts +3 -4
- package/dist/esm/errors/base.d.ts.map +1 -1
- package/dist/esm/errors/base.js.map +1 -1
- package/dist/esm/errors/block.d.ts +3 -8
- package/dist/esm/errors/block.d.ts.map +1 -1
- package/dist/esm/errors/provider.d.ts +1 -3
- package/dist/esm/errors/provider.d.ts.map +1 -1
- package/dist/esm/errors/request.d.ts +15 -39
- package/dist/esm/errors/request.d.ts.map +1 -1
- package/dist/esm/errors/request.js.map +1 -1
- package/dist/esm/errors/rpc.d.ts +28 -30
- package/dist/esm/errors/rpc.d.ts.map +1 -1
- package/dist/esm/errors/transaction.d.ts +9 -21
- package/dist/esm/errors/transaction.d.ts.map +1 -1
- package/dist/esm/errors/transport.d.ts +8 -17
- package/dist/esm/errors/transport.d.ts.map +1 -1
- package/dist/esm/errors/transport.js.map +1 -1
- package/dist/esm/errors/utils.d.ts +3 -5
- package/dist/esm/errors/utils.d.ts.map +1 -1
- package/dist/esm/errors/utxo.d.ts +3 -9
- package/dist/esm/errors/utxo.d.ts.map +1 -1
- package/dist/esm/factories/createClient.d.ts +55 -37
- package/dist/esm/factories/createClient.d.ts.map +1 -1
- package/dist/esm/factories/createClient.js.map +1 -1
- package/dist/esm/factories/createTransport.d.ts +3 -14
- package/dist/esm/factories/createTransport.d.ts.map +1 -1
- package/dist/esm/test/utils.d.ts +1 -2
- package/dist/esm/test/utils.d.ts.map +1 -1
- package/dist/esm/transports/ankr/ankr.d.ts +1 -3
- package/dist/esm/transports/ankr/ankr.d.ts.map +1 -1
- package/dist/esm/transports/ankr/ankr.types.d.ts +7 -8
- package/dist/esm/transports/ankr/ankr.types.d.ts.map +1 -1
- package/dist/esm/transports/ankr/getBalance.d.ts +1 -3
- package/dist/esm/transports/ankr/getBalance.d.ts.map +1 -1
- package/dist/esm/transports/ankr/getTransactionFee.d.ts +1 -3
- package/dist/esm/transports/ankr/getTransactionFee.d.ts.map +1 -1
- package/dist/esm/transports/ankr/getTransactions.d.ts +1 -3
- package/dist/esm/transports/ankr/getTransactions.d.ts.map +1 -1
- package/dist/esm/transports/ankr/methods.d.ts +1 -3
- package/dist/esm/transports/ankr/methods.d.ts.map +1 -1
- package/dist/esm/transports/ankr/utils.d.ts +1 -3
- package/dist/esm/transports/ankr/utils.d.ts.map +1 -1
- package/dist/esm/transports/blockchair/blockchair.d.ts +1 -3
- package/dist/esm/transports/blockchair/blockchair.d.ts.map +1 -1
- package/dist/esm/transports/blockchair/blockchair.types.d.ts +13 -14
- package/dist/esm/transports/blockchair/blockchair.types.d.ts.map +1 -1
- package/dist/esm/transports/blockchair/getBalance.d.ts +1 -3
- package/dist/esm/transports/blockchair/getBalance.d.ts.map +1 -1
- package/dist/esm/transports/blockchair/getTransactionFee.d.ts +1 -3
- package/dist/esm/transports/blockchair/getTransactionFee.d.ts.map +1 -1
- package/dist/esm/transports/blockchair/getTransactionFee.js.map +1 -1
- package/dist/esm/transports/blockchair/getUTXOs.d.ts +1 -3
- package/dist/esm/transports/blockchair/getUTXOs.d.ts.map +1 -1
- package/dist/esm/transports/blockchair/getUTXOs.js.map +1 -1
- package/dist/esm/transports/blockchair/getXPubAddresses.d.ts +1 -3
- package/dist/esm/transports/blockchair/getXPubAddresses.d.ts.map +1 -1
- package/dist/esm/transports/blockchair/getXPubAddresses.js.map +1 -1
- package/dist/esm/transports/blockchair/methods.d.ts +1 -3
- package/dist/esm/transports/blockchair/methods.d.ts.map +1 -1
- package/dist/esm/transports/blockcypher/blockcypher.d.ts +1 -3
- package/dist/esm/transports/blockcypher/blockcypher.d.ts.map +1 -1
- package/dist/esm/transports/blockcypher/blockcypher.types.d.ts +8 -9
- package/dist/esm/transports/blockcypher/blockcypher.types.d.ts.map +1 -1
- package/dist/esm/transports/blockcypher/getBalance.d.ts +1 -3
- package/dist/esm/transports/blockcypher/getBalance.d.ts.map +1 -1
- package/dist/esm/transports/blockcypher/getTransactionFee.d.ts +1 -3
- package/dist/esm/transports/blockcypher/getTransactionFee.d.ts.map +1 -1
- package/dist/esm/transports/blockcypher/getUTXOs.d.ts +1 -3
- package/dist/esm/transports/blockcypher/getUTXOs.d.ts.map +1 -1
- package/dist/esm/transports/blockcypher/getUTXOs.js.map +1 -1
- package/dist/esm/transports/blockcypher/methods.d.ts +1 -3
- package/dist/esm/transports/blockcypher/methods.d.ts.map +1 -1
- package/dist/esm/transports/blockcypher/utils.d.ts +1 -3
- package/dist/esm/transports/blockcypher/utils.d.ts.map +1 -1
- package/dist/esm/transports/blockcypher/utils.js.map +1 -1
- package/dist/esm/transports/custom.d.ts +15 -12
- package/dist/esm/transports/custom.d.ts.map +1 -1
- package/dist/esm/transports/fallback.d.ts +38 -43
- package/dist/esm/transports/fallback.d.ts.map +1 -1
- package/dist/esm/transports/fallback.js.map +1 -1
- package/dist/esm/transports/getHttpRpcClient.d.ts +23 -16
- package/dist/esm/transports/getHttpRpcClient.d.ts.map +1 -1
- package/dist/esm/transports/getHttpRpcClient.js.map +1 -1
- package/dist/esm/transports/getRpcProviderMethods.d.ts +1 -3
- package/dist/esm/transports/getRpcProviderMethods.d.ts.map +1 -1
- package/dist/esm/transports/http.d.ts +35 -25
- package/dist/esm/transports/http.d.ts.map +1 -1
- package/dist/esm/transports/mempool/getBalance.d.ts +1 -3
- package/dist/esm/transports/mempool/getBalance.d.ts.map +1 -1
- package/dist/esm/transports/mempool/getTransactionFee.d.ts +1 -3
- package/dist/esm/transports/mempool/getTransactionFee.d.ts.map +1 -1
- package/dist/esm/transports/mempool/getTransactions.d.ts +1 -3
- package/dist/esm/transports/mempool/getTransactions.d.ts.map +1 -1
- package/dist/esm/transports/mempool/getTransactions.js.map +1 -1
- package/dist/esm/transports/mempool/mempool.d.ts +1 -3
- package/dist/esm/transports/mempool/mempool.d.ts.map +1 -1
- package/dist/esm/transports/mempool/mempool.types.d.ts +7 -8
- package/dist/esm/transports/mempool/mempool.types.d.ts.map +1 -1
- package/dist/esm/transports/mempool/methods.d.ts +1 -3
- package/dist/esm/transports/mempool/methods.d.ts.map +1 -1
- package/dist/esm/transports/mempool/utils.d.ts +1 -3
- package/dist/esm/transports/mempool/utils.d.ts.map +1 -1
- package/dist/esm/transports/types.d.ts +28 -27
- package/dist/esm/transports/types.d.ts.map +1 -1
- package/dist/esm/transports/utxo.d.ts +1 -3
- package/dist/esm/transports/utxo.d.ts.map +1 -1
- package/dist/esm/transports/utxo.js.map +1 -1
- package/dist/esm/types/account.d.ts +1 -3
- package/dist/esm/types/account.d.ts.map +1 -1
- package/dist/esm/types/address.d.ts +4 -6
- package/dist/esm/types/address.d.ts.map +1 -1
- package/dist/esm/types/block.d.ts +18 -19
- package/dist/esm/types/block.d.ts.map +1 -1
- package/dist/esm/types/blockStats.d.ts +2 -3
- package/dist/esm/types/blockStats.d.ts.map +1 -1
- package/dist/esm/types/chain.d.ts +26 -16
- package/dist/esm/types/chain.d.ts.map +1 -1
- package/dist/esm/types/client.d.ts +43 -29
- package/dist/esm/types/client.d.ts.map +1 -1
- package/dist/esm/types/hash.d.ts +1 -2
- package/dist/esm/types/hash.d.ts.map +1 -1
- package/dist/esm/types/request.d.ts +16 -13
- package/dist/esm/types/request.d.ts.map +1 -1
- package/dist/esm/types/rpc.d.ts +4 -5
- package/dist/esm/types/rpc.d.ts.map +1 -1
- package/dist/esm/types/transaction.d.ts +2 -3
- package/dist/esm/types/transaction.d.ts.map +1 -1
- package/dist/esm/types/transport.d.ts +18 -14
- package/dist/esm/types/transport.d.ts.map +1 -1
- package/dist/esm/types/utils.d.ts +43 -44
- package/dist/esm/types/utils.d.ts.map +1 -1
- package/dist/esm/types/xpub.d.ts +1 -3
- package/dist/esm/types/xpub.d.ts.map +1 -1
- package/dist/esm/utils/buildRequest.d.ts +3 -5
- package/dist/esm/utils/buildRequest.d.ts.map +1 -1
- package/dist/esm/utils/buildRequest.js +2 -1
- package/dist/esm/utils/buildRequest.js.map +1 -1
- package/dist/esm/utils/cancelTransaction.d.ts +1 -3
- package/dist/esm/utils/cancelTransaction.d.ts.map +1 -1
- package/dist/esm/utils/converter.d.ts +5 -6
- package/dist/esm/utils/converter.d.ts.map +1 -1
- package/dist/esm/utils/converter.js.map +1 -1
- package/dist/esm/utils/createBatchScheduler.d.ts +2 -10
- package/dist/esm/utils/createBatchScheduler.d.ts.map +1 -1
- package/dist/esm/utils/createBatchScheduler.js.map +1 -1
- package/dist/esm/utils/deepEqual.d.ts +1 -2
- package/dist/esm/utils/deepEqual.d.ts.map +1 -1
- package/dist/esm/utils/deepEqual.js.map +1 -1
- package/dist/esm/utils/getAction.d.ts +7 -9
- package/dist/esm/utils/getAction.d.ts.map +1 -1
- package/dist/esm/utils/getAddressInfo.d.ts +2 -4
- package/dist/esm/utils/getAddressInfo.d.ts.map +1 -1
- package/dist/esm/utils/getAddressInfo.js +2 -1
- package/dist/esm/utils/getAddressInfo.js.map +1 -1
- package/dist/esm/utils/idCache.d.ts +1 -2
- package/dist/esm/utils/idCache.d.ts.map +1 -1
- package/dist/esm/utils/isAddress.d.ts +1 -3
- package/dist/esm/utils/isAddress.d.ts.map +1 -1
- package/dist/esm/utils/lru.d.ts +5 -6
- package/dist/esm/utils/lru.d.ts.map +1 -1
- package/dist/esm/utils/lru.js.map +1 -1
- package/dist/esm/utils/modifyFee.d.ts +1 -3
- package/dist/esm/utils/modifyFee.d.ts.map +1 -1
- package/dist/esm/utils/modifyFee.js.map +1 -1
- package/dist/esm/utils/observe.d.ts +7 -9
- package/dist/esm/utils/observe.d.ts.map +1 -1
- package/dist/esm/utils/observe.js.map +1 -1
- package/dist/esm/utils/parseAccount.d.ts +2 -4
- package/dist/esm/utils/parseAccount.d.ts.map +1 -1
- package/dist/esm/utils/poll.d.ts +4 -11
- package/dist/esm/utils/poll.d.ts.map +1 -1
- package/dist/esm/utils/poll.js +2 -1
- package/dist/esm/utils/poll.js.map +1 -1
- package/dist/esm/utils/retryUntil.d.ts +18 -17
- package/dist/esm/utils/retryUntil.d.ts.map +1 -1
- package/dist/esm/utils/retryUntil.js.map +1 -1
- package/dist/esm/utils/sleep.d.ts +1 -2
- package/dist/esm/utils/sleep.d.ts.map +1 -1
- package/dist/esm/utils/stringify.d.ts +2 -4
- package/dist/esm/utils/stringify.d.ts.map +1 -1
- package/dist/esm/utils/uid.d.ts +1 -2
- package/dist/esm/utils/uid.d.ts.map +1 -1
- package/dist/esm/utils/uid.js.map +1 -1
- package/dist/esm/utils/url.d.ts +1 -2
- package/dist/esm/utils/url.d.ts.map +1 -1
- package/dist/esm/utils/url.js.map +1 -1
- package/dist/esm/utils/wait.d.ts +1 -2
- package/dist/esm/utils/wait.d.ts.map +1 -1
- package/dist/esm/utils/withDedupe.d.ts +2 -7
- package/dist/esm/utils/withDedupe.d.ts.map +1 -1
- package/dist/esm/utils/withDedupe.js.map +1 -1
- package/dist/esm/utils/withResolvers.d.ts +2 -3
- package/dist/esm/utils/withResolvers.d.ts.map +1 -1
- package/dist/esm/utils/withRetry.d.ts +4 -13
- package/dist/esm/utils/withRetry.d.ts.map +1 -1
- package/dist/esm/utils/withTimeout.d.ts +3 -11
- package/dist/esm/utils/withTimeout.d.ts.map +1 -1
- package/dist/esm/utils/withTimeout.js.map +1 -1
- package/dist/esm/version.d.ts +2 -3
- package/dist/esm/version.d.ts.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/esm/vite-env.d.ts +1 -1
- package/package.json +3 -3
- package/src/factories/createClient.ts +1 -2
- package/src/types/client.ts +1 -2
- package/src/version.ts +1 -1
|
@@ -6,62 +6,80 @@ import { Account } from "../types/account.js";
|
|
|
6
6
|
import { ErrorType } from "../errors/utils.js";
|
|
7
7
|
import { BtcRpcRequestFn, RpcSchema } from "../types/request.js";
|
|
8
8
|
import { Transport } from "../types/transport.js";
|
|
9
|
-
|
|
10
9
|
//#region src/factories/createClient.d.ts
|
|
11
|
-
type ClientConfig<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, accountOrAddress extends Account | Address | undefined = Account | Address | undefined, rpcSchema extends RpcSchema | undefined = undefined> = {
|
|
12
|
-
/** The Account to use for the Client. This will be used for Actions that require an account as an argument. */
|
|
10
|
+
export type ClientConfig<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, accountOrAddress extends Account | Address | undefined = Account | Address | undefined, rpcSchema extends RpcSchema | undefined = undefined> = {
|
|
11
|
+
/** The Account to use for the Client. This will be used for Actions that require an account as an argument. */
|
|
12
|
+
account?: accountOrAddress | Account | Address | undefined;
|
|
13
|
+
/** Flags for batch settings. */
|
|
13
14
|
batch?: {
|
|
14
|
-
/** Toggle to enable `eth_call` multicall aggregation. */
|
|
15
|
+
/** Toggle to enable `eth_call` multicall aggregation. */
|
|
16
|
+
multicall?: boolean | Prettify<MulticallBatchOptions> | undefined;
|
|
15
17
|
} | undefined;
|
|
16
18
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
cacheTime?: number | undefined;
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
* Time (in ms) that cached data will remain in memory.
|
|
20
|
+
* @default 4_000
|
|
21
|
+
*/
|
|
22
|
+
cacheTime?: number | undefined;
|
|
23
|
+
/** Chain for the client. */
|
|
24
|
+
chain?: Chain | undefined | chain;
|
|
25
|
+
/** A key for the client. */
|
|
26
|
+
key?: string | undefined;
|
|
27
|
+
/** A name for the client. */
|
|
23
28
|
name?: string | undefined;
|
|
24
29
|
/**
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
* Frequency (in ms) for polling enabled actions & events.
|
|
31
|
+
* @default 4_000
|
|
32
|
+
*/
|
|
28
33
|
pollingInterval?: number | undefined;
|
|
29
34
|
/**
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
rpcSchema?: rpcSchema | undefined;
|
|
33
|
-
|
|
35
|
+
* Typed JSON-RPC schema for the client.
|
|
36
|
+
*/
|
|
37
|
+
rpcSchema?: rpcSchema | undefined;
|
|
38
|
+
/** The RPC transport */
|
|
39
|
+
transport: transport;
|
|
40
|
+
/** The type of client. */
|
|
34
41
|
type?: string | undefined;
|
|
35
42
|
};
|
|
36
|
-
type Client<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined, rpcSchema extends RpcSchema | undefined = undefined, extended extends Extended | undefined = Extended | undefined> = Client_Base<transport, chain, account, rpcSchema> & (extended extends Extended ? extended : unknown) & {
|
|
43
|
+
export type Client<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined, rpcSchema extends RpcSchema | undefined = undefined, extended extends Extended | undefined = Extended | undefined> = Client_Base<transport, chain, account, rpcSchema> & (extended extends Extended ? extended : unknown) & {
|
|
37
44
|
extend: <const client extends Extended>(fn: (client: Client<transport, chain, account, rpcSchema, extended>) => client) => Client<transport, chain, account, rpcSchema, Prettify<client> & (extended extends Extended ? extended : unknown)>;
|
|
38
45
|
};
|
|
39
46
|
type Client_Base<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined, rpcSchema extends RpcSchema | undefined = undefined> = {
|
|
40
|
-
/** The Account of the Client. */
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
/** The Account of the Client. */
|
|
48
|
+
account: account;
|
|
49
|
+
/** Time (in ms) that cached data will remain in memory. */
|
|
50
|
+
cacheTime: number;
|
|
51
|
+
/** Chain for the client. */
|
|
52
|
+
chain: chain;
|
|
53
|
+
/** A key for the client. */
|
|
54
|
+
key: string;
|
|
55
|
+
/** A name for the client. */
|
|
56
|
+
name: string;
|
|
57
|
+
/** Frequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds. */
|
|
58
|
+
pollingInterval: number;
|
|
59
|
+
/** Request function wrapped with friendly error handling */
|
|
60
|
+
request: BtcRpcRequestFn<rpcSchema extends undefined ? BitcoinRpcMethods : rpcSchema>;
|
|
61
|
+
/** The RPC transport */
|
|
62
|
+
transport: ReturnType<transport>["config"] & ReturnType<transport>["value"];
|
|
63
|
+
/** The type of client. */
|
|
64
|
+
type: string;
|
|
65
|
+
/** A unique ID for the client. */
|
|
49
66
|
uid: string;
|
|
50
67
|
};
|
|
51
|
-
type Extended = Prettify<{ [_ in keyof Client_Base]?: undefined } & {
|
|
68
|
+
type Extended = Prettify<{ [_ in keyof Client_Base]?: undefined; } & {
|
|
52
69
|
[key: string]: unknown;
|
|
53
70
|
}>;
|
|
54
|
-
type MulticallBatchOptions = {
|
|
55
|
-
/** The maximum size (in bytes) for each calldata chunk. @default 1_024 */
|
|
71
|
+
export type MulticallBatchOptions = {
|
|
72
|
+
/** The maximum size (in bytes) for each calldata chunk. @default 1_024 */
|
|
73
|
+
batchSize?: number | undefined;
|
|
74
|
+
/** The maximum number of milliseconds to wait before sending a batch. @default 0 */
|
|
56
75
|
wait?: number | undefined;
|
|
57
76
|
};
|
|
58
|
-
type CreateClientErrorType = ErrorType;
|
|
59
|
-
declare function createClient<transport extends Transport, chain extends Chain | undefined = undefined, accountOrAddress extends Account | Address | undefined = undefined, rpcSchema extends RpcSchema | undefined = undefined>(parameters: ClientConfig<transport, chain, accountOrAddress, rpcSchema>): Prettify<Client<transport, chain, accountOrAddress extends Address ? Prettify<Account> : accountOrAddress, rpcSchema>>;
|
|
77
|
+
export type CreateClientErrorType = ErrorType;
|
|
78
|
+
export declare function createClient<transport extends Transport, chain extends Chain | undefined = undefined, accountOrAddress extends Account | Address | undefined = undefined, rpcSchema extends RpcSchema | undefined = undefined>(parameters: ClientConfig<transport, chain, accountOrAddress, rpcSchema>): Prettify<Client<transport, chain, accountOrAddress extends Address ? Prettify<Account> : accountOrAddress, rpcSchema>>;
|
|
60
79
|
/**
|
|
61
|
-
* Defines a typed JSON-RPC schema for the client.
|
|
62
|
-
* Note: This is a runtime noop function.
|
|
63
|
-
*/
|
|
64
|
-
declare function rpcSchema<rpcSchema extends RpcSchema>(): rpcSchema;
|
|
80
|
+
* Defines a typed JSON-RPC schema for the client.
|
|
81
|
+
* Note: This is a runtime noop function.
|
|
82
|
+
*/
|
|
83
|
+
export declare function rpcSchema<rpcSchema extends RpcSchema>(): rpcSchema;
|
|
65
84
|
//#endregion
|
|
66
|
-
export { Client, ClientConfig, CreateClientErrorType, MulticallBatchOptions, createClient, rpcSchema };
|
|
67
85
|
//# sourceMappingURL=createClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createClient.js","names":["parseAccount","uid"],"sources":["../../../src/factories/createClient.ts"],"sourcesContent":["import type { ErrorType } from '../errors/utils.js'\nimport type { Account } from '../types/account.js'\nimport type { Address } from '../types/address.js'\nimport type { Chain } from '../types/chain.js'\nimport type { BtcRpcRequestFn, RpcSchema } from '../types/request.js'\nimport type { BitcoinRpcMethods } from '../types/rpc.js'\nimport type { Transport } from '../types/transport.js'\nimport type { Prettify } from '../types/utils.js'\n\nimport { parseAccount } from '../utils/parseAccount.js'\nimport { uid } from '../utils/uid.js'\n\nexport type ClientConfig<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n accountOrAddress extends Account | Address | undefined =\n | Account\n | Address\n | undefined,\n rpcSchema extends RpcSchema | undefined = undefined,\n> = {\n /** The Account to use for the Client. This will be used for Actions that require an account as an argument. */\n account?: accountOrAddress | Account | Address | undefined\n /** Flags for batch settings. */\n batch?:\n | {\n /** Toggle to enable `eth_call` multicall aggregation. */\n multicall?: boolean | Prettify<MulticallBatchOptions> | undefined\n }\n | undefined\n /**\n * Time (in ms) that cached data will remain in memory.\n * @default 4_000\n */\n cacheTime?: number | undefined\n /** Chain for the client. */\n chain?: Chain | undefined | chain\n /** A key for the client. */\n key?: string | undefined\n /** A name for the client. */\n name?: string | undefined\n /**\n * Frequency (in ms) for polling enabled actions & events.\n * @default 4_000\n */\n pollingInterval?: number | undefined\n /**\n * Typed JSON-RPC schema for the client.\n */\n rpcSchema?: rpcSchema | undefined\n /** The RPC transport */\n transport: transport\n /** The type of client. */\n type?: string | undefined\n}\n\n// TODO: Move `transport` to slot index 2 since `chain` and `account` used more frequently.\n// Otherwise, we end up with a lot of `Client<Transport, chain, account>` in actions.\nexport type Client<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends Account | undefined = Account | undefined,\n rpcSchema extends RpcSchema | undefined = undefined,\n extended extends Extended | undefined = Extended | undefined,\n> = Client_Base<transport, chain, account, rpcSchema> &\n (extended extends Extended ? extended : unknown) & {\n extend: <const client extends Extended>(\n fn: (\n client: Client<transport, chain, account, rpcSchema, extended>\n ) => client\n ) => Client<\n transport,\n chain,\n account,\n rpcSchema,\n Prettify<client> & (extended extends Extended ? extended : unknown)\n >\n }\n\ntype Client_Base<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends Account | undefined = Account | undefined,\n rpcSchema extends RpcSchema | undefined = undefined,\n> = {\n /** The Account of the Client. */\n account: account\n /** Time (in ms) that cached data will remain in memory. */\n cacheTime: number\n /** Chain for the client. */\n chain: chain\n /** A key for the client. */\n key: string\n /** A name for the client. */\n name: string\n /** Frequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds. */\n pollingInterval: number\n /** Request function wrapped with friendly error handling */\n request: BtcRpcRequestFn<\n rpcSchema extends undefined ? BitcoinRpcMethods : rpcSchema\n >\n /** The RPC transport */\n transport: ReturnType<transport>['config'] & ReturnType<transport>['value']\n /** The type of client. */\n type: string\n /** A unique ID for the client. */\n uid: string\n}\n\ntype Extended = Prettify<\n // disallow redefining base properties\n { [_ in keyof Client_Base]?: undefined } & {\n [key: string]: unknown\n }
|
|
1
|
+
{"version":3,"file":"createClient.js","names":["parseAccount","uid"],"sources":["../../../src/factories/createClient.ts"],"sourcesContent":["import type { ErrorType } from '../errors/utils.js'\nimport type { Account } from '../types/account.js'\nimport type { Address } from '../types/address.js'\nimport type { Chain } from '../types/chain.js'\nimport type { BtcRpcRequestFn, RpcSchema } from '../types/request.js'\nimport type { BitcoinRpcMethods } from '../types/rpc.js'\nimport type { Transport } from '../types/transport.js'\nimport type { Prettify } from '../types/utils.js'\n\nimport { parseAccount } from '../utils/parseAccount.js'\nimport { uid } from '../utils/uid.js'\n\nexport type ClientConfig<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n accountOrAddress extends Account | Address | undefined =\n | Account\n | Address\n | undefined,\n rpcSchema extends RpcSchema | undefined = undefined,\n> = {\n /** The Account to use for the Client. This will be used for Actions that require an account as an argument. */\n account?: accountOrAddress | Account | Address | undefined\n /** Flags for batch settings. */\n batch?:\n | {\n /** Toggle to enable `eth_call` multicall aggregation. */\n multicall?: boolean | Prettify<MulticallBatchOptions> | undefined\n }\n | undefined\n /**\n * Time (in ms) that cached data will remain in memory.\n * @default 4_000\n */\n cacheTime?: number | undefined\n /** Chain for the client. */\n chain?: Chain | undefined | chain\n /** A key for the client. */\n key?: string | undefined\n /** A name for the client. */\n name?: string | undefined\n /**\n * Frequency (in ms) for polling enabled actions & events.\n * @default 4_000\n */\n pollingInterval?: number | undefined\n /**\n * Typed JSON-RPC schema for the client.\n */\n rpcSchema?: rpcSchema | undefined\n /** The RPC transport */\n transport: transport\n /** The type of client. */\n type?: string | undefined\n}\n\n// TODO: Move `transport` to slot index 2 since `chain` and `account` used more frequently.\n// Otherwise, we end up with a lot of `Client<Transport, chain, account>` in actions.\nexport type Client<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends Account | undefined = Account | undefined,\n rpcSchema extends RpcSchema | undefined = undefined,\n extended extends Extended | undefined = Extended | undefined,\n> = Client_Base<transport, chain, account, rpcSchema> &\n (extended extends Extended ? extended : unknown) & {\n extend: <const client extends Extended>(\n fn: (\n client: Client<transport, chain, account, rpcSchema, extended>\n ) => client\n ) => Client<\n transport,\n chain,\n account,\n rpcSchema,\n Prettify<client> & (extended extends Extended ? extended : unknown)\n >\n }\n\ntype Client_Base<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends Account | undefined = Account | undefined,\n rpcSchema extends RpcSchema | undefined = undefined,\n> = {\n /** The Account of the Client. */\n account: account\n /** Time (in ms) that cached data will remain in memory. */\n cacheTime: number\n /** Chain for the client. */\n chain: chain\n /** A key for the client. */\n key: string\n /** A name for the client. */\n name: string\n /** Frequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds. */\n pollingInterval: number\n /** Request function wrapped with friendly error handling */\n request: BtcRpcRequestFn<\n rpcSchema extends undefined ? BitcoinRpcMethods : rpcSchema\n >\n /** The RPC transport */\n transport: ReturnType<transport>['config'] & ReturnType<transport>['value']\n /** The type of client. */\n type: string\n /** A unique ID for the client. */\n uid: string\n}\n\ntype Extended = Prettify<\n // disallow redefining base properties\n { [_ in keyof Client_Base]?: undefined } & {\n [key: string]: unknown\n }>\n\nexport type MulticallBatchOptions = {\n /** The maximum size (in bytes) for each calldata chunk. @default 1_024 */\n batchSize?: number | undefined\n /** The maximum number of milliseconds to wait before sending a batch. @default 0 */\n wait?: number | undefined\n}\n\nexport type CreateClientErrorType = ErrorType\n\nexport function createClient<\n transport extends Transport,\n chain extends Chain | undefined = undefined,\n accountOrAddress extends Account | Address | undefined = undefined,\n rpcSchema extends RpcSchema | undefined = undefined,\n>(\n parameters: ClientConfig<transport, chain, accountOrAddress, rpcSchema>\n): Prettify<\n Client<\n transport,\n chain,\n accountOrAddress extends Address ? Prettify<Account> : accountOrAddress,\n rpcSchema\n >\n>\n\nexport function createClient(parameters: ClientConfig): Client {\n const {\n cacheTime = parameters.pollingInterval ?? 4_000,\n\n key = 'base',\n name = 'Base Client',\n pollingInterval = 4_000,\n type = 'base',\n } = parameters\n\n const chain = parameters.chain\n const account = parameters.account\n ? parseAccount(parameters.account)\n : undefined\n const { config, request, value } = parameters.transport({\n chain,\n pollingInterval,\n })\n const transport = { ...config, ...value }\n\n const client = {\n account,\n cacheTime,\n\n chain,\n key,\n name,\n pollingInterval,\n request,\n transport,\n type,\n uid: uid(),\n }\n\n function extend(base: typeof client) {\n type ExtendFn = (base: typeof client) => unknown\n return (extendFn: ExtendFn) => {\n const extended = extendFn(base) as Extended\n for (const key in client) {\n delete extended[key]\n }\n const combined = { ...base, ...extended }\n return Object.assign(combined, { extend: extend(combined as any) })\n }\n }\n\n return Object.assign(client, { extend: extend(client) as any })\n}\n\n/**\n * Defines a typed JSON-RPC schema for the client.\n * Note: This is a runtime noop function.\n */\nexport function rpcSchema<rpcSchema extends RpcSchema>(): rpcSchema {\n return null as any\n}\n"],"mappings":";;;;AA4IA,SAAgB,aAAa,YAAkC;CAC7D,MAAM,EACJ,YAAY,WAAW,mBAAmB,KAE1C,MAAM,QACN,OAAO,eACP,kBAAkB,KAClB,OAAO,WACL;CAEJ,MAAM,QAAQ,WAAW;CACzB,MAAM,UAAU,WAAW,UACvBA,2BAAAA,aAAa,WAAW,OAAO,IAC/B,KAAA;CACJ,MAAM,EAAE,QAAQ,SAAS,UAAU,WAAW,UAAU;EACtD;EACA;CACF,CAAC;CAGD,MAAM,SAAS;EACb;EACA;EAEA;EACA;EACA;EACA;EACA;EACA,WAAA;GAXkB,GAAG;GAAQ,GAAG;EAWxB;EACR;EACA,KAAKC,kBAAAA,IAAI;CACX;CAEA,SAAS,OAAO,MAAqB;EAEnC,QAAQ,aAAuB;GAC7B,MAAM,WAAW,SAAS,IAAI;GAC9B,KAAK,MAAM,OAAO,QAChB,OAAO,SAAS;GAElB,MAAM,WAAW;IAAE,GAAG;IAAM,GAAG;GAAS;GACxC,OAAO,OAAO,OAAO,UAAU,EAAE,QAAQ,OAAO,QAAe,EAAE,CAAC;EACpE;CACF;CAEA,OAAO,OAAO,OAAO,QAAQ,EAAE,QAAQ,OAAO,MAAM,EAAS,CAAC;AAChE;;;;;AAMA,SAAgB,YAAoD;CAClE,OAAO;AACT"}
|
|
@@ -1,19 +1,8 @@
|
|
|
1
1
|
import { Transport, TransportConfig } from "../types/transport.js";
|
|
2
|
-
|
|
3
2
|
//#region src/factories/createTransport.d.ts
|
|
4
3
|
/**
|
|
5
|
-
* @description Creates an transport intended to be used with a client.
|
|
6
|
-
*/
|
|
7
|
-
declare function createTransport<type extends string, rpcAttributes extends Record<string, any>>({
|
|
8
|
-
key,
|
|
9
|
-
methods,
|
|
10
|
-
name,
|
|
11
|
-
request,
|
|
12
|
-
retryCount,
|
|
13
|
-
retryDelay,
|
|
14
|
-
timeout,
|
|
15
|
-
type
|
|
16
|
-
}: TransportConfig<type>, value?: rpcAttributes | undefined): ReturnType<Transport<type, rpcAttributes>>;
|
|
4
|
+
* @description Creates an transport intended to be used with a client.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createTransport<type extends string, rpcAttributes extends Record<string, any>>({ key, methods, name, request, retryCount, retryDelay, timeout, type }: TransportConfig<type>, value?: rpcAttributes | undefined): ReturnType<Transport<type, rpcAttributes>>;
|
|
17
7
|
//#endregion
|
|
18
|
-
export { createTransport };
|
|
19
8
|
//# sourceMappingURL=createTransport.d.ts.map
|
package/dist/cjs/test/utils.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
//#region src/test/utils.d.ts
|
|
2
|
-
declare const createMockResponse: <T>(data: T, options?: Partial<Response>) => Response;
|
|
2
|
+
export declare const createMockResponse: <T>(data: T, options?: Partial<Response>) => Response;
|
|
3
3
|
//#endregion
|
|
4
|
-
export { createMockResponse };
|
|
5
4
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { HttpTransport, HttpTransportConfig } from "../http.js";
|
|
2
|
-
|
|
3
2
|
//#region src/transports/ankr/ankr.d.ts
|
|
4
3
|
type AnkrConfig = {
|
|
5
4
|
baseUrl?: string;
|
|
6
5
|
apiKey?: string;
|
|
7
6
|
} & HttpTransportConfig;
|
|
8
|
-
declare const ankr: (config?: AnkrConfig) => HttpTransport;
|
|
7
|
+
export declare const ankr: (config?: AnkrConfig) => HttpTransport;
|
|
9
8
|
//#endregion
|
|
10
|
-
export { ankr };
|
|
11
9
|
//# sourceMappingURL=ankr.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/transports/ankr/ankr.types.d.ts
|
|
2
|
-
type AnkrBalanceResponse = {
|
|
2
|
+
export type AnkrBalanceResponse = {
|
|
3
3
|
address: string;
|
|
4
4
|
balance: string;
|
|
5
5
|
totalReceived: string;
|
|
@@ -9,7 +9,7 @@ type AnkrBalanceResponse = {
|
|
|
9
9
|
txs: number;
|
|
10
10
|
error: string;
|
|
11
11
|
};
|
|
12
|
-
type AnkrUTXOResponse = {
|
|
12
|
+
export type AnkrUTXOResponse = {
|
|
13
13
|
txid: string;
|
|
14
14
|
vout: number;
|
|
15
15
|
value: string;
|
|
@@ -17,7 +17,7 @@ type AnkrUTXOResponse = {
|
|
|
17
17
|
confirmations: number;
|
|
18
18
|
coinbase: boolean;
|
|
19
19
|
}[];
|
|
20
|
-
type AnkrVin = {
|
|
20
|
+
export type AnkrVin = {
|
|
21
21
|
txid: string;
|
|
22
22
|
vout: number;
|
|
23
23
|
sequence: number;
|
|
@@ -31,7 +31,7 @@ type AnkrVin = {
|
|
|
31
31
|
hex: string;
|
|
32
32
|
};
|
|
33
33
|
};
|
|
34
|
-
type AnkrVout = {
|
|
34
|
+
export type AnkrVout = {
|
|
35
35
|
value: number;
|
|
36
36
|
n: number;
|
|
37
37
|
spent: boolean;
|
|
@@ -49,7 +49,7 @@ type AnkrVout = {
|
|
|
49
49
|
type: string;
|
|
50
50
|
};
|
|
51
51
|
};
|
|
52
|
-
type AnkrTransaction = {
|
|
52
|
+
export type AnkrTransaction = {
|
|
53
53
|
txid: string;
|
|
54
54
|
version: number;
|
|
55
55
|
vin: AnkrVin[];
|
|
@@ -74,12 +74,11 @@ type AnkrTransaction = {
|
|
|
74
74
|
version: number;
|
|
75
75
|
};
|
|
76
76
|
};
|
|
77
|
-
type AnkrAddressWithTxnsResponse = {
|
|
77
|
+
export type AnkrAddressWithTxnsResponse = {
|
|
78
78
|
transactions: AnkrTransaction[];
|
|
79
79
|
} & AnkrBalanceResponse;
|
|
80
|
-
type AnkrTxnResponse = {
|
|
80
|
+
export type AnkrTxnResponse = {
|
|
81
81
|
error?: string;
|
|
82
82
|
} & AnkrTransaction;
|
|
83
83
|
//#endregion
|
|
84
|
-
export { AnkrAddressWithTxnsResponse, AnkrBalanceResponse, AnkrTransaction, AnkrTxnResponse, AnkrUTXOResponse, AnkrVin, AnkrVout };
|
|
85
84
|
//# sourceMappingURL=ankr.types.d.ts.map
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { RpcMethodHandler } from "../types.js";
|
|
2
|
-
|
|
3
2
|
//#region src/transports/ankr/getBalance.d.ts
|
|
4
|
-
declare const getBalance: RpcMethodHandler<"getBalance">;
|
|
3
|
+
export declare const getBalance: RpcMethodHandler<"getBalance">;
|
|
5
4
|
//#endregion
|
|
6
|
-
export { getBalance };
|
|
7
5
|
//# sourceMappingURL=getBalance.d.ts.map
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { RpcMethodHandler } from "../types.js";
|
|
2
|
-
|
|
3
2
|
//#region src/transports/ankr/getTransactionFee.d.ts
|
|
4
|
-
declare const getTransactionFee: RpcMethodHandler<"getTransactionFee">;
|
|
3
|
+
export declare const getTransactionFee: RpcMethodHandler<"getTransactionFee">;
|
|
5
4
|
//#endregion
|
|
6
|
-
export { getTransactionFee };
|
|
7
5
|
//# sourceMappingURL=getTransactionFee.d.ts.map
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { RpcMethodHandler } from "../types.js";
|
|
2
|
-
|
|
3
2
|
//#region src/transports/ankr/getTransactions.d.ts
|
|
4
|
-
declare const getTransactions: RpcMethodHandler<"getTransactions">;
|
|
3
|
+
export declare const getTransactions: RpcMethodHandler<"getTransactions">;
|
|
5
4
|
//#endregion
|
|
6
|
-
export { getTransactions };
|
|
7
5
|
//# sourceMappingURL=getTransactions.d.ts.map
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { UTXOTransaction } from "../../types/transaction.js";
|
|
2
2
|
import { AnkrTransaction } from "./ankr.types.js";
|
|
3
|
-
|
|
4
3
|
//#region src/transports/ankr/utils.d.ts
|
|
5
|
-
declare const ankrTransactionTransformer: (txn: AnkrTransaction) => Partial<UTXOTransaction>;
|
|
4
|
+
export declare const ankrTransactionTransformer: (txn: AnkrTransaction) => Partial<UTXOTransaction>;
|
|
6
5
|
//#endregion
|
|
7
|
-
export { ankrTransactionTransformer };
|
|
8
6
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { HttpTransport, HttpTransportConfig } from "../http.js";
|
|
2
|
-
|
|
3
2
|
//#region src/transports/blockchair/blockchair.d.ts
|
|
4
3
|
type BlockchairConfig = {
|
|
5
4
|
baseUrl?: string;
|
|
6
5
|
apiKey?: string;
|
|
7
6
|
} & HttpTransportConfig;
|
|
8
|
-
declare const blockchair: (config?: BlockchairConfig) => HttpTransport;
|
|
7
|
+
export declare const blockchair: (config?: BlockchairConfig) => HttpTransport;
|
|
9
8
|
//#endregion
|
|
10
|
-
export { blockchair };
|
|
11
9
|
//# sourceMappingURL=blockchair.d.ts.map
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
//#region src/transports/blockchair/blockchair.types.d.ts
|
|
2
|
-
type BlockchairUTXO = {
|
|
2
|
+
export type BlockchairUTXO = {
|
|
3
3
|
block_id: number;
|
|
4
4
|
transaction_hash: string;
|
|
5
5
|
index: number;
|
|
6
6
|
value: number;
|
|
7
7
|
address: string;
|
|
8
8
|
};
|
|
9
|
-
type BlockChairDashboardAddressResponse = {
|
|
9
|
+
export type BlockChairDashboardAddressResponse = {
|
|
10
10
|
set: BlockChairDashboardSet;
|
|
11
11
|
addresses: Record<string, BlockchairDashboardAddress>;
|
|
12
12
|
transactions: Array<string>;
|
|
13
13
|
utxo: Array<BlockchairUTXO>;
|
|
14
14
|
};
|
|
15
|
-
type BlockChairDashboardSet = {
|
|
15
|
+
export type BlockChairDashboardSet = {
|
|
16
16
|
address_count: number;
|
|
17
17
|
balance: number;
|
|
18
18
|
balance_usd: number;
|
|
@@ -26,7 +26,7 @@ type BlockChairDashboardSet = {
|
|
|
26
26
|
last_seen_spending: string;
|
|
27
27
|
transaction_count: number;
|
|
28
28
|
};
|
|
29
|
-
type BlockchairDashboardAddress = {
|
|
29
|
+
export type BlockchairDashboardAddress = {
|
|
30
30
|
type: string;
|
|
31
31
|
script_hex: string;
|
|
32
32
|
balance: number;
|
|
@@ -42,8 +42,8 @@ type BlockchairDashboardAddress = {
|
|
|
42
42
|
first_seen_spending: string;
|
|
43
43
|
last_seen_spending: string;
|
|
44
44
|
};
|
|
45
|
-
type BlockchairAddressBalanceData<T = any> = Record<string, T>;
|
|
46
|
-
type BlockchairResponse<T = any> = {
|
|
45
|
+
export type BlockchairAddressBalanceData<T = any> = Record<string, T>;
|
|
46
|
+
export type BlockchairResponse<T = any> = {
|
|
47
47
|
data: T;
|
|
48
48
|
context: {
|
|
49
49
|
code: number;
|
|
@@ -53,10 +53,10 @@ type BlockchairResponse<T = any> = {
|
|
|
53
53
|
total_rows?: number;
|
|
54
54
|
};
|
|
55
55
|
};
|
|
56
|
-
type BlockchairXpubDashboardAddressResponse = BlockchairDashboardAddress & {
|
|
56
|
+
export type BlockchairXpubDashboardAddressResponse = BlockchairDashboardAddress & {
|
|
57
57
|
path: string;
|
|
58
58
|
};
|
|
59
|
-
type BlockchairXpubData = {
|
|
59
|
+
export type BlockchairXpubData = {
|
|
60
60
|
address_count: number;
|
|
61
61
|
balance: number;
|
|
62
62
|
balance_usd: number;
|
|
@@ -70,12 +70,12 @@ type BlockchairXpubData = {
|
|
|
70
70
|
last_seen_spending: string;
|
|
71
71
|
transaction_count: number;
|
|
72
72
|
};
|
|
73
|
-
type BlockchairXpubResponse = Record<string, {
|
|
73
|
+
export type BlockchairXpubResponse = Record<string, {
|
|
74
74
|
xpub: BlockchairXpubData;
|
|
75
75
|
addresses: Record<string, BlockchairXpubDashboardAddressResponse>;
|
|
76
76
|
}>;
|
|
77
|
-
type BlockchairTransactionResponse = BlockchairResponse<Record<string, BlockchairTransaction>>;
|
|
78
|
-
type BlockchairTransaction = {
|
|
77
|
+
export type BlockchairTransactionResponse = BlockchairResponse<Record<string, BlockchairTransaction>>;
|
|
78
|
+
export type BlockchairTransaction = {
|
|
79
79
|
transaction: {
|
|
80
80
|
block_id: number;
|
|
81
81
|
id: number;
|
|
@@ -106,7 +106,7 @@ type BlockchairTransaction = {
|
|
|
106
106
|
inputs: Array<BlockchairVin>;
|
|
107
107
|
outputs: Array<BlockchairVout>;
|
|
108
108
|
};
|
|
109
|
-
type BlockchairVin = {
|
|
109
|
+
export type BlockchairVin = {
|
|
110
110
|
block_id: number;
|
|
111
111
|
transaction_id: number;
|
|
112
112
|
index: number;
|
|
@@ -134,7 +134,6 @@ type BlockchairVin = {
|
|
|
134
134
|
lifespan: number | null;
|
|
135
135
|
cdd: number | null;
|
|
136
136
|
};
|
|
137
|
-
type BlockchairVout = BlockchairVin;
|
|
137
|
+
export type BlockchairVout = BlockchairVin;
|
|
138
138
|
//#endregion
|
|
139
|
-
export { BlockChairDashboardAddressResponse, BlockChairDashboardSet, BlockchairAddressBalanceData, BlockchairDashboardAddress, BlockchairResponse, BlockchairTransaction, BlockchairTransactionResponse, BlockchairUTXO, BlockchairVin, BlockchairVout, BlockchairXpubDashboardAddressResponse, BlockchairXpubData, BlockchairXpubResponse };
|
|
140
139
|
//# sourceMappingURL=blockchair.types.d.ts.map
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { RpcMethodHandler } from "../types.js";
|
|
2
|
-
|
|
3
2
|
//#region src/transports/blockchair/getBalance.d.ts
|
|
4
|
-
declare const getBalance: RpcMethodHandler<"getBalance">;
|
|
3
|
+
export declare const getBalance: RpcMethodHandler<"getBalance">;
|
|
5
4
|
//#endregion
|
|
6
|
-
export { getBalance };
|
|
7
5
|
//# sourceMappingURL=getBalance.d.ts.map
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { RpcMethodHandler } from "../types.js";
|
|
2
|
-
|
|
3
2
|
//#region src/transports/blockchair/getTransactionFee.d.ts
|
|
4
|
-
declare const getTransactionFee: RpcMethodHandler<"getTransactionFee">;
|
|
3
|
+
export declare const getTransactionFee: RpcMethodHandler<"getTransactionFee">;
|
|
5
4
|
//#endregion
|
|
6
|
-
export { getTransactionFee };
|
|
7
5
|
//# sourceMappingURL=getTransactionFee.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTransactionFee.js","names":["urlWithParams"],"sources":["../../../../src/transports/blockchair/getTransactionFee.ts"],"sourcesContent":["import { RpcErrorCode } from '../../errors/rpc.js'\nimport { urlWithParams } from '../../utils/url.js'\nimport type { RpcMethodHandler } from '../types.js'\nimport type { BlockchairTransactionResponse } from './blockchair.types.js'\n\nexport const getTransactionFee: RpcMethodHandler<'getTransactionFee'> = async (\n client,\n { baseUrl, apiKey },\n { txId }\n) => {\n const apiUrl = urlWithParams(`${baseUrl}/dashboards/transaction/${txId}`, {\n key: apiKey,\n })\n const response = (await client.request({\n url: apiUrl,\n fetchOptions: {\n method: 'GET',\n },\n })) as unknown as BlockchairTransactionResponse\n\n if (\n !response.data[txId] ||\n response.context.error ||\n response.context?.code !== 200\n ) {\n return {\n error: {\n code:\n response.context.code === 429\n ? RpcErrorCode.ACCESS_DENIED\n : RpcErrorCode.MISC_ERROR,\n message: response.context?.error,\n },\n }\n }\n\n return {\n result: BigInt(response.data[txId].transaction.fee),\n }\n}\n"],"mappings":";;;;AAKA,MAAa,oBAA2D,OACtE,QACA,EAAE,SAAS,UACX,EAAE,WACC;CACH,MAAM,SAASA,kBAAAA,cAAc,GAAG,QAAQ,0BAA0B,QAAQ,EACxE,KAAK,OACP,CAAC;CACD,MAAM,WAAY,MAAM,OAAO,QAAQ;EACrC,KAAK;EACL,cAAc,EACZ,QAAQ,MACV;CACF,CAAC;CAED,IACE,CAAC,SAAS,KAAK,SACf,SAAS,QAAQ,SACjB,SAAS,SAAS,SAAS,KAE3B,OAAO,EACL,OAAO;EACL,MACE,SAAS,QAAQ,SAAS,MAAA,SAAA;EAG5B,SAAS,SAAS,SAAS;CAC7B,EACF;CAGF,OAAO,EACL,QAAQ,OAAO,SAAS,KAAK,
|
|
1
|
+
{"version":3,"file":"getTransactionFee.js","names":["urlWithParams"],"sources":["../../../../src/transports/blockchair/getTransactionFee.ts"],"sourcesContent":["import { RpcErrorCode } from '../../errors/rpc.js'\nimport { urlWithParams } from '../../utils/url.js'\nimport type { RpcMethodHandler } from '../types.js'\nimport type { BlockchairTransactionResponse } from './blockchair.types.js'\n\nexport const getTransactionFee: RpcMethodHandler<'getTransactionFee'> = async (\n client,\n { baseUrl, apiKey },\n { txId }\n) => {\n const apiUrl = urlWithParams(`${baseUrl}/dashboards/transaction/${txId}`, {\n key: apiKey,\n })\n const response = (await client.request({\n url: apiUrl,\n fetchOptions: {\n method: 'GET',\n },\n })) as unknown as BlockchairTransactionResponse\n\n if (\n !response.data[txId] ||\n response.context.error ||\n response.context?.code !== 200\n ) {\n return {\n error: {\n code:\n response.context.code === 429\n ? RpcErrorCode.ACCESS_DENIED\n : RpcErrorCode.MISC_ERROR,\n message: response.context?.error,\n },\n }\n }\n\n return {\n result: BigInt(response.data[txId].transaction.fee),\n }\n}\n"],"mappings":";;;;AAKA,MAAa,oBAA2D,OACtE,QACA,EAAE,SAAS,UACX,EAAE,WACC;CACH,MAAM,SAASA,kBAAAA,cAAc,GAAG,QAAQ,0BAA0B,QAAQ,EACxE,KAAK,OACP,CAAC;CACD,MAAM,WAAY,MAAM,OAAO,QAAQ;EACrC,KAAK;EACL,cAAc,EACZ,QAAQ,MACV;CACF,CAAC;CAED,IACE,CAAC,SAAS,KAAK,SACf,SAAS,QAAQ,SACjB,SAAS,SAAS,SAAS,KAE3B,OAAO,EACL,OAAO;EACL,MACE,SAAS,QAAQ,SAAS,MAAA,SAAA;EAG5B,SAAS,SAAS,SAAS;CAC7B,EACF;CAGF,OAAO,EACL,QAAQ,OAAO,SAAS,KAAK,KAAK,CAAC,YAAY,GAAG,EACpD;AACF"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { RpcMethodHandler } from "../types.js";
|
|
2
|
-
|
|
3
2
|
//#region src/transports/blockchair/getUTXOs.d.ts
|
|
4
|
-
declare const getUTXOs: RpcMethodHandler<"getUTXOs">;
|
|
3
|
+
export declare const getUTXOs: RpcMethodHandler<"getUTXOs">;
|
|
5
4
|
//#endregion
|
|
6
|
-
export { getUTXOs };
|
|
7
5
|
//# sourceMappingURL=getUTXOs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getUTXOs.js","names":["urlWithParams","RpcRequestError","getBalance","BaseError","InsufficientUTXOBalanceError"],"sources":["../../../../src/transports/blockchair/getUTXOs.ts"],"sourcesContent":["import { BaseError } from '../../errors/base.js'\nimport { RpcRequestError } from '../../errors/request.js'\nimport { RpcErrorCode } from '../../errors/rpc.js'\nimport { InsufficientUTXOBalanceError } from '../../errors/utxo.js'\nimport type { UTXO } from '../../types/transaction.js'\n\nimport { urlWithParams } from '../../utils/url.js'\nimport type { RpcMethodHandler } from '../types.js'\nimport type {\n BlockChairDashboardAddressResponse,\n BlockchairResponse,\n BlockchairUTXO,\n} from './blockchair.types.js'\nimport { getBalance } from './getBalance.js'\n\nconst blockChairUTXOTransformer =\n (scriptHex: string) =>\n (data: BlockchairUTXO): UTXO => ({\n blockHeight: data.block_id,\n scriptHex,\n txId: data.transaction_hash,\n value: data.value,\n vout: data.index,\n })\n\nconst MAX_API_LIMIT = '100,100'\n\nexport const getUTXOs: RpcMethodHandler<'getUTXOs'> = async (\n client,\n { baseUrl, apiKey },\n { address, minValue }\n) => {\n async function* fetchUTXOs() {\n let offset = 0\n let hasMore = true\n\n while (hasMore) {\n const apiUrl = urlWithParams(\n `${baseUrl}/dashboards/addresses/${address}`,\n {\n key: apiKey,\n offset: `0,${offset}`,\n limit: MAX_API_LIMIT,\n }\n )\n const response = (await client.request({\n url: apiUrl,\n fetchOptions: { method: 'GET' },\n })) as unknown as BlockchairResponse<BlockChairDashboardAddressResponse>\n\n if (response.context?.code !== 200 && response.context?.code !== 404) {\n throw new RpcRequestError({\n url: apiUrl,\n body: {\n method: 'fetchUTXOs',\n params: {\n address,\n minValue,\n },\n },\n error: {\n code:\n response.context.code === 429\n ? RpcErrorCode.ACCESS_DENIED\n : RpcErrorCode.MISC_ERROR,\n message: response.context.error || 'Error fetching utxos',\n },\n })\n }\n\n if (!response.data || response.data.utxo.length === 0) {\n hasMore = false\n continue\n }\n\n const { limit } = response.context\n const totalRows = response.data.addresses[address].unspent_output_count\n if (limit && totalRows) {\n const [, utxoLimit] = String(limit)\n .split(',')\n .map((val) => Number(val))\n hasMore = offset + utxoLimit < totalRows\n offset += utxoLimit\n } else {\n hasMore = false\n offset += 0\n }\n\n yield response.data\n }\n }\n\n if (minValue) {\n const { error, result: balance } = await getBalance(\n client,\n { baseUrl, apiKey },\n { address }\n )\n\n if (error) {\n throw new BaseError('Error fetching balance', {\n cause: error,\n })\n }\n\n if (balance === undefined) {\n throw new BaseError('Balance is undefined', {\n cause: new Error('Unable to determine balance'),\n })\n }\n\n if (minValue > Number(balance)) {\n throw new InsufficientUTXOBalanceError({\n minValue,\n address,\n balance: Number(balance),\n })\n }\n }\n const utxos: UTXO[] = []\n let valueCount = 0\n\n for await (const batch of fetchUTXOs()) {\n const addressScriptHex = batch.addresses[address].script_hex\n const utxoBatch = batch.utxo.map(\n blockChairUTXOTransformer(addressScriptHex)\n )\n utxos.push(...utxoBatch)\n\n if (minValue) {\n valueCount += utxoBatch.reduce((sum, utxo) => sum + utxo.value, 0)\n if (valueCount >= minValue) {\n break\n }\n }\n }\n\n return { result: utxos }\n}\n"],"mappings":";;;;;;;;AAeA,MAAM,6BACH,eACA,UAAgC;CAC/B,aAAa,KAAK;CAClB;CACA,MAAM,KAAK;CACX,OAAO,KAAK;CACZ,MAAM,KAAK;AACb;AAEF,MAAM,gBAAgB;AAEtB,MAAa,WAAyC,OACpD,QACA,EAAE,SAAS,UACX,EAAE,SAAS,eACR;CACH,gBAAgB,aAAa;EAC3B,IAAI,SAAS;EACb,IAAI,UAAU;EAEd,OAAO,SAAS;GACd,MAAM,SAASA,kBAAAA,cACb,GAAG,QAAQ,wBAAwB,WACnC;IACE,KAAK;IACL,QAAQ,KAAK;IACb,OAAO;GACT,CACF;GACA,MAAM,WAAY,MAAM,OAAO,QAAQ;IACrC,KAAK;IACL,cAAc,EAAE,QAAQ,MAAM;GAChC,CAAC;GAED,IAAI,SAAS,SAAS,SAAS,OAAO,SAAS,SAAS,SAAS,KAC/D,MAAM,IAAIC,uBAAAA,gBAAgB;IACxB,KAAK;IACL,MAAM;KACJ,QAAQ;KACR,QAAQ;MACN;MACA;KACF;IACF;IACA,OAAO;KACL,MACE,SAAS,QAAQ,SAAS,MAAA,SAAA;KAG5B,SAAS,SAAS,QAAQ,SAAS;IACrC;GACF,CAAC;GAGH,IAAI,CAAC,SAAS,QAAQ,SAAS,KAAK,KAAK,WAAW,GAAG;IACrD,UAAU;IACV;GACF;GAEA,MAAM,EAAE,UAAU,SAAS;GAC3B,MAAM,YAAY,SAAS,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"getUTXOs.js","names":["urlWithParams","RpcRequestError","getBalance","BaseError","InsufficientUTXOBalanceError"],"sources":["../../../../src/transports/blockchair/getUTXOs.ts"],"sourcesContent":["import { BaseError } from '../../errors/base.js'\nimport { RpcRequestError } from '../../errors/request.js'\nimport { RpcErrorCode } from '../../errors/rpc.js'\nimport { InsufficientUTXOBalanceError } from '../../errors/utxo.js'\nimport type { UTXO } from '../../types/transaction.js'\n\nimport { urlWithParams } from '../../utils/url.js'\nimport type { RpcMethodHandler } from '../types.js'\nimport type {\n BlockChairDashboardAddressResponse,\n BlockchairResponse,\n BlockchairUTXO,\n} from './blockchair.types.js'\nimport { getBalance } from './getBalance.js'\n\nconst blockChairUTXOTransformer =\n (scriptHex: string) =>\n (data: BlockchairUTXO): UTXO => ({\n blockHeight: data.block_id,\n scriptHex,\n txId: data.transaction_hash,\n value: data.value,\n vout: data.index,\n })\n\nconst MAX_API_LIMIT = '100,100'\n\nexport const getUTXOs: RpcMethodHandler<'getUTXOs'> = async (\n client,\n { baseUrl, apiKey },\n { address, minValue }\n) => {\n async function* fetchUTXOs() {\n let offset = 0\n let hasMore = true\n\n while (hasMore) {\n const apiUrl = urlWithParams(\n `${baseUrl}/dashboards/addresses/${address}`,\n {\n key: apiKey,\n offset: `0,${offset}`,\n limit: MAX_API_LIMIT,\n }\n )\n const response = (await client.request({\n url: apiUrl,\n fetchOptions: { method: 'GET' },\n })) as unknown as BlockchairResponse<BlockChairDashboardAddressResponse>\n\n if (response.context?.code !== 200 && response.context?.code !== 404) {\n throw new RpcRequestError({\n url: apiUrl,\n body: {\n method: 'fetchUTXOs',\n params: {\n address,\n minValue,\n },\n },\n error: {\n code:\n response.context.code === 429\n ? RpcErrorCode.ACCESS_DENIED\n : RpcErrorCode.MISC_ERROR,\n message: response.context.error || 'Error fetching utxos',\n },\n })\n }\n\n if (!response.data || response.data.utxo.length === 0) {\n hasMore = false\n continue\n }\n\n const { limit } = response.context\n const totalRows = response.data.addresses[address].unspent_output_count\n if (limit && totalRows) {\n const [, utxoLimit] = String(limit)\n .split(',')\n .map((val) => Number(val))\n hasMore = offset + utxoLimit < totalRows\n offset += utxoLimit\n } else {\n hasMore = false\n offset += 0\n }\n\n yield response.data\n }\n }\n\n if (minValue) {\n const { error, result: balance } = await getBalance(\n client,\n { baseUrl, apiKey },\n { address }\n )\n\n if (error) {\n throw new BaseError('Error fetching balance', {\n cause: error,\n })\n }\n\n if (balance === undefined) {\n throw new BaseError('Balance is undefined', {\n cause: new Error('Unable to determine balance'),\n })\n }\n\n if (minValue > Number(balance)) {\n throw new InsufficientUTXOBalanceError({\n minValue,\n address,\n balance: Number(balance),\n })\n }\n }\n const utxos: UTXO[] = []\n let valueCount = 0\n\n for await (const batch of fetchUTXOs()) {\n const addressScriptHex = batch.addresses[address].script_hex\n const utxoBatch = batch.utxo.map(\n blockChairUTXOTransformer(addressScriptHex)\n )\n utxos.push(...utxoBatch)\n\n if (minValue) {\n valueCount += utxoBatch.reduce((sum, utxo) => sum + utxo.value, 0)\n if (valueCount >= minValue) {\n break\n }\n }\n }\n\n return { result: utxos }\n}\n"],"mappings":";;;;;;;;AAeA,MAAM,6BACH,eACA,UAAgC;CAC/B,aAAa,KAAK;CAClB;CACA,MAAM,KAAK;CACX,OAAO,KAAK;CACZ,MAAM,KAAK;AACb;AAEF,MAAM,gBAAgB;AAEtB,MAAa,WAAyC,OACpD,QACA,EAAE,SAAS,UACX,EAAE,SAAS,eACR;CACH,gBAAgB,aAAa;EAC3B,IAAI,SAAS;EACb,IAAI,UAAU;EAEd,OAAO,SAAS;GACd,MAAM,SAASA,kBAAAA,cACb,GAAG,QAAQ,wBAAwB,WACnC;IACE,KAAK;IACL,QAAQ,KAAK;IACb,OAAO;GACT,CACF;GACA,MAAM,WAAY,MAAM,OAAO,QAAQ;IACrC,KAAK;IACL,cAAc,EAAE,QAAQ,MAAM;GAChC,CAAC;GAED,IAAI,SAAS,SAAS,SAAS,OAAO,SAAS,SAAS,SAAS,KAC/D,MAAM,IAAIC,uBAAAA,gBAAgB;IACxB,KAAK;IACL,MAAM;KACJ,QAAQ;KACR,QAAQ;MACN;MACA;KACF;IACF;IACA,OAAO;KACL,MACE,SAAS,QAAQ,SAAS,MAAA,SAAA;KAG5B,SAAS,SAAS,QAAQ,SAAS;IACrC;GACF,CAAC;GAGH,IAAI,CAAC,SAAS,QAAQ,SAAS,KAAK,KAAK,WAAW,GAAG;IACrD,UAAU;IACV;GACF;GAEA,MAAM,EAAE,UAAU,SAAS;GAC3B,MAAM,YAAY,SAAS,KAAK,UAAU,QAAQ,CAAC;GACnD,IAAI,SAAS,WAAW;IACtB,MAAM,GAAG,aAAa,OAAO,KAAK,CAAC,CAChC,MAAM,GAAG,CAAC,CACV,KAAK,QAAQ,OAAO,GAAG,CAAC;IAC3B,UAAU,SAAS,YAAY;IAC/B,UAAU;GACZ,OAAO;IACL,UAAU;IACV,UAAU;GACZ;GAEA,MAAM,SAAS;EACjB;CACF;CAEA,IAAI,UAAU;EACZ,MAAM,EAAE,OAAO,QAAQ,YAAY,MAAMC,yCAAAA,WACvC,QACA;GAAE;GAAS;EAAO,GAClB,EAAE,QAAQ,CACZ;EAEA,IAAI,OACF,MAAM,IAAIC,oBAAAA,UAAU,0BAA0B,EAC5C,OAAO,MACT,CAAC;EAGH,IAAI,YAAY,KAAA,GACd,MAAM,IAAIA,oBAAAA,UAAU,wBAAwB,EAC1C,uBAAO,IAAI,MAAM,6BAA6B,EAChD,CAAC;EAGH,IAAI,WAAW,OAAO,OAAO,GAC3B,MAAM,IAAIC,oBAAAA,6BAA6B;GACrC;GACA;GACA,SAAS,OAAO,OAAO;EACzB,CAAC;CAEL;CACA,MAAM,QAAgB,CAAC;CACvB,IAAI,aAAa;CAEjB,WAAW,MAAM,SAAS,WAAW,GAAG;EACtC,MAAM,mBAAmB,MAAM,UAAU,QAAQ,CAAC;EAClD,MAAM,YAAY,MAAM,KAAK,IAC3B,0BAA0B,gBAAgB,CAC5C;EACA,MAAM,KAAK,GAAG,SAAS;EAEvB,IAAI,UAAU;GACZ,cAAc,UAAU,QAAQ,KAAK,SAAS,MAAM,KAAK,OAAO,CAAC;GACjE,IAAI,cAAc,UAChB;EAEJ;CACF;CAEA,OAAO,EAAE,QAAQ,MAAM;AACzB"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { RpcMethodHandler } from "../types.js";
|
|
2
|
-
|
|
3
2
|
//#region src/transports/blockchair/getXPubAddresses.d.ts
|
|
4
|
-
declare const getXPubAddresses: RpcMethodHandler<"getXPubAddresses">;
|
|
3
|
+
export declare const getXPubAddresses: RpcMethodHandler<"getXPubAddresses">;
|
|
5
4
|
//#endregion
|
|
6
|
-
export { getXPubAddresses };
|
|
7
5
|
//# sourceMappingURL=getXPubAddresses.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getXPubAddresses.js","names":["urlWithParams"],"sources":["../../../../src/transports/blockchair/getXPubAddresses.ts"],"sourcesContent":["import { RpcErrorCode } from '../../errors/rpc.js'\nimport { urlWithParams } from '../../utils/url.js'\nimport type { RpcMethodHandler } from '../types.js'\nimport type {\n BlockchairResponse,\n BlockchairXpubResponse,\n} from './blockchair.types.js'\n\nexport const getXPubAddresses: RpcMethodHandler<'getXPubAddresses'> = async (\n client,\n { baseUrl, apiKey },\n { xPubKey }\n) => {\n const apiUrl = urlWithParams(`${baseUrl}/dashboards/xpub/${xPubKey}`, {\n key: apiKey,\n })\n const response = (await client.request({\n url: apiUrl,\n fetchOptions: { method: 'GET' },\n })) as unknown as BlockchairResponse<BlockchairXpubResponse>\n\n if (response.context.error || response.context?.code !== 200) {\n return {\n error: {\n code:\n response.context.code === 429\n ? RpcErrorCode.ACCESS_DENIED\n : RpcErrorCode.MISC_ERROR,\n message: response.context?.error,\n },\n }\n }\n\n if (response.data[xPubKey] === undefined) {\n return {\n result: {\n balance: 0n,\n addresses: [],\n },\n }\n }\n\n const xpubData = response.data[xPubKey]\n\n const result = {\n balance: BigInt(xpubData.xpub.balance),\n addresses: Object.entries(xpubData.addresses).map(([address, data]) => ({\n address,\n balance: BigInt(data.balance),\n path: data.path,\n scriptHex: data.script_hex,\n })),\n }\n\n return {\n result,\n }\n}\n"],"mappings":";;;;AAQA,MAAa,mBAAyD,OACpE,QACA,EAAE,SAAS,UACX,EAAE,cACC;CACH,MAAM,SAASA,kBAAAA,cAAc,GAAG,QAAQ,mBAAmB,WAAW,EACpE,KAAK,OACP,CAAC;CACD,MAAM,WAAY,MAAM,OAAO,QAAQ;EACrC,KAAK;EACL,cAAc,EAAE,QAAQ,MAAM;CAChC,CAAC;CAED,IAAI,SAAS,QAAQ,SAAS,SAAS,SAAS,SAAS,KACvD,OAAO,EACL,OAAO;EACL,MACE,SAAS,QAAQ,SAAS,MAAA,SAAA;EAG5B,SAAS,SAAS,SAAS;CAC7B,EACF;CAGF,IAAI,SAAS,KAAK,aAAa,KAAA,GAC7B,OAAO,EACL,QAAQ;EACN,SAAS;EACT,WAAW,CAAC;CACd,EACF;CAGF,MAAM,WAAW,SAAS,KAAK;CAY/B,OAAO,EACL,QAAA;EAVA,SAAS,OAAO,SAAS,KAAK,OAAO;EACrC,WAAW,OAAO,QAAQ,SAAS,SAAS,
|
|
1
|
+
{"version":3,"file":"getXPubAddresses.js","names":["urlWithParams"],"sources":["../../../../src/transports/blockchair/getXPubAddresses.ts"],"sourcesContent":["import { RpcErrorCode } from '../../errors/rpc.js'\nimport { urlWithParams } from '../../utils/url.js'\nimport type { RpcMethodHandler } from '../types.js'\nimport type {\n BlockchairResponse,\n BlockchairXpubResponse,\n} from './blockchair.types.js'\n\nexport const getXPubAddresses: RpcMethodHandler<'getXPubAddresses'> = async (\n client,\n { baseUrl, apiKey },\n { xPubKey }\n) => {\n const apiUrl = urlWithParams(`${baseUrl}/dashboards/xpub/${xPubKey}`, {\n key: apiKey,\n })\n const response = (await client.request({\n url: apiUrl,\n fetchOptions: { method: 'GET' },\n })) as unknown as BlockchairResponse<BlockchairXpubResponse>\n\n if (response.context.error || response.context?.code !== 200) {\n return {\n error: {\n code:\n response.context.code === 429\n ? RpcErrorCode.ACCESS_DENIED\n : RpcErrorCode.MISC_ERROR,\n message: response.context?.error,\n },\n }\n }\n\n if (response.data[xPubKey] === undefined) {\n return {\n result: {\n balance: 0n,\n addresses: [],\n },\n }\n }\n\n const xpubData = response.data[xPubKey]\n\n const result = {\n balance: BigInt(xpubData.xpub.balance),\n addresses: Object.entries(xpubData.addresses).map(([address, data]) => ({\n address,\n balance: BigInt(data.balance),\n path: data.path,\n scriptHex: data.script_hex,\n })),\n }\n\n return {\n result,\n }\n}\n"],"mappings":";;;;AAQA,MAAa,mBAAyD,OACpE,QACA,EAAE,SAAS,UACX,EAAE,cACC;CACH,MAAM,SAASA,kBAAAA,cAAc,GAAG,QAAQ,mBAAmB,WAAW,EACpE,KAAK,OACP,CAAC;CACD,MAAM,WAAY,MAAM,OAAO,QAAQ;EACrC,KAAK;EACL,cAAc,EAAE,QAAQ,MAAM;CAChC,CAAC;CAED,IAAI,SAAS,QAAQ,SAAS,SAAS,SAAS,SAAS,KACvD,OAAO,EACL,OAAO;EACL,MACE,SAAS,QAAQ,SAAS,MAAA,SAAA;EAG5B,SAAS,SAAS,SAAS;CAC7B,EACF;CAGF,IAAI,SAAS,KAAK,aAAa,KAAA,GAC7B,OAAO,EACL,QAAQ;EACN,SAAS;EACT,WAAW,CAAC;CACd,EACF;CAGF,MAAM,WAAW,SAAS,KAAK;CAY/B,OAAO,EACL,QAAA;EAVA,SAAS,OAAO,SAAS,KAAK,OAAO;EACrC,WAAW,OAAO,QAAQ,SAAS,SAAS,CAAC,CAAC,KAAK,CAAC,SAAS,WAAW;GACtE;GACA,SAAS,OAAO,KAAK,OAAO;GAC5B,MAAM,KAAK;GACX,WAAW,KAAK;EAClB,EAAE;CAIG,EACP;AACF"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { RpcMethods } from "../types.js";
|
|
2
|
-
|
|
3
2
|
//#region src/transports/blockchair/methods.d.ts
|
|
4
|
-
declare const blockchairMethods: RpcMethods;
|
|
3
|
+
export declare const blockchairMethods: RpcMethods;
|
|
5
4
|
//#endregion
|
|
6
|
-
export { blockchairMethods };
|
|
7
5
|
//# sourceMappingURL=methods.d.ts.map
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { HttpTransport, HttpTransportConfig } from "../http.js";
|
|
2
|
-
|
|
3
2
|
//#region src/transports/blockcypher/blockcypher.d.ts
|
|
4
3
|
type BlockcypherConfig = {
|
|
5
4
|
baseUrl?: string;
|
|
6
5
|
apiKey?: string;
|
|
7
6
|
} & HttpTransportConfig;
|
|
8
|
-
declare const blockcypher: (config?: BlockcypherConfig) => HttpTransport;
|
|
7
|
+
export declare const blockcypher: (config?: BlockcypherConfig) => HttpTransport;
|
|
9
8
|
//#endregion
|
|
10
|
-
export { blockcypher };
|
|
11
9
|
//# sourceMappingURL=blockcypher.d.ts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
//#region src/transports/blockcypher/blockcypher.types.d.ts
|
|
2
|
-
type BlockcypherErrorResponse = {
|
|
2
|
+
export type BlockcypherErrorResponse = {
|
|
3
3
|
error: string;
|
|
4
4
|
};
|
|
5
|
-
type BlockcypherBalanceResponse = {
|
|
5
|
+
export type BlockcypherBalanceResponse = {
|
|
6
6
|
address: string;
|
|
7
7
|
total_received: number;
|
|
8
8
|
total_sent: number;
|
|
@@ -15,7 +15,7 @@ type BlockcypherBalanceResponse = {
|
|
|
15
15
|
error?: string;
|
|
16
16
|
hasMore?: boolean;
|
|
17
17
|
};
|
|
18
|
-
type BlockcypherUTXO = {
|
|
18
|
+
export type BlockcypherUTXO = {
|
|
19
19
|
tx_hash: string;
|
|
20
20
|
block_height: number;
|
|
21
21
|
tx_input_n: number;
|
|
@@ -28,10 +28,10 @@ type BlockcypherUTXO = {
|
|
|
28
28
|
double_spend: boolean;
|
|
29
29
|
script: string;
|
|
30
30
|
};
|
|
31
|
-
type BlockcypherUTXOsResponse = BlockcypherBalanceResponse & {
|
|
31
|
+
export type BlockcypherUTXOsResponse = BlockcypherBalanceResponse & {
|
|
32
32
|
txrefs: BlockcypherUTXO[];
|
|
33
33
|
};
|
|
34
|
-
type BlockcypherTransactionInput = {
|
|
34
|
+
export type BlockcypherTransactionInput = {
|
|
35
35
|
prev_hash: string;
|
|
36
36
|
output_index: number;
|
|
37
37
|
script: string;
|
|
@@ -40,14 +40,14 @@ type BlockcypherTransactionInput = {
|
|
|
40
40
|
addresses: string[];
|
|
41
41
|
script_type: string;
|
|
42
42
|
};
|
|
43
|
-
type BlockcypherTransactionOutput = {
|
|
43
|
+
export type BlockcypherTransactionOutput = {
|
|
44
44
|
value: number;
|
|
45
45
|
script: string;
|
|
46
46
|
spent_by: string;
|
|
47
47
|
addresses: string[];
|
|
48
48
|
script_type: string;
|
|
49
49
|
};
|
|
50
|
-
type BlockcypherTransaction = {
|
|
50
|
+
export type BlockcypherTransaction = {
|
|
51
51
|
block_hash: string;
|
|
52
52
|
block_height: number;
|
|
53
53
|
hash: string;
|
|
@@ -69,9 +69,8 @@ type BlockcypherTransaction = {
|
|
|
69
69
|
inputs: BlockcypherTransactionInput[];
|
|
70
70
|
outputs: BlockcypherTransactionOutput[];
|
|
71
71
|
};
|
|
72
|
-
type BlockcypherTransactionReponse = BlockcypherTransaction & {
|
|
72
|
+
export type BlockcypherTransactionReponse = BlockcypherTransaction & {
|
|
73
73
|
error?: string;
|
|
74
74
|
};
|
|
75
75
|
//#endregion
|
|
76
|
-
export { BlockcypherBalanceResponse, BlockcypherErrorResponse, BlockcypherTransaction, BlockcypherTransactionInput, BlockcypherTransactionOutput, BlockcypherTransactionReponse, BlockcypherUTXO, BlockcypherUTXOsResponse };
|
|
77
76
|
//# sourceMappingURL=blockcypher.types.d.ts.map
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { RpcMethodHandler } from "../types.js";
|
|
2
|
-
|
|
3
2
|
//#region src/transports/blockcypher/getBalance.d.ts
|
|
4
|
-
declare const getBalance: RpcMethodHandler<"getBalance">;
|
|
3
|
+
export declare const getBalance: RpcMethodHandler<"getBalance">;
|
|
5
4
|
//#endregion
|
|
6
|
-
export { getBalance };
|
|
7
5
|
//# sourceMappingURL=getBalance.d.ts.map
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { RpcMethodHandler } from "../types.js";
|
|
2
|
-
|
|
3
2
|
//#region src/transports/blockcypher/getTransactionFee.d.ts
|
|
4
|
-
declare const getTransactionFee: RpcMethodHandler<"getTransactionFee">;
|
|
3
|
+
export declare const getTransactionFee: RpcMethodHandler<"getTransactionFee">;
|
|
5
4
|
//#endregion
|
|
6
|
-
export { getTransactionFee };
|
|
7
5
|
//# sourceMappingURL=getTransactionFee.d.ts.map
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { RpcMethodHandler } from "../types.js";
|
|
2
|
-
|
|
3
2
|
//#region src/transports/blockcypher/getUTXOs.d.ts
|
|
4
|
-
declare const getUTXOs: RpcMethodHandler<"getUTXOs">;
|
|
3
|
+
export declare const getUTXOs: RpcMethodHandler<"getUTXOs">;
|
|
5
4
|
//#endregion
|
|
6
|
-
export { getUTXOs };
|
|
7
5
|
//# sourceMappingURL=getUTXOs.d.ts.map
|