@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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/types/transaction.d.ts
|
|
2
|
-
type UTXOTransaction = {
|
|
2
|
+
export type UTXOTransaction = {
|
|
3
3
|
blockhash?: string;
|
|
4
4
|
blocktime?: number;
|
|
5
5
|
confirmations?: number;
|
|
@@ -39,7 +39,7 @@ type UTXOTransaction = {
|
|
|
39
39
|
};
|
|
40
40
|
}[];
|
|
41
41
|
};
|
|
42
|
-
type UTXO = {
|
|
42
|
+
export type UTXO = {
|
|
43
43
|
txId: string;
|
|
44
44
|
vout: number;
|
|
45
45
|
value: number;
|
|
@@ -49,5 +49,4 @@ type UTXO = {
|
|
|
49
49
|
scriptHex: string;
|
|
50
50
|
};
|
|
51
51
|
//#endregion
|
|
52
|
-
export { UTXO, UTXOTransaction };
|
|
53
52
|
//# sourceMappingURL=transaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.d.ts","names":[],"sources":["../../../src/types/transaction.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"transaction.d.ts","names":[],"sources":["../../../src/types/transaction.ts"],"mappings":";YAAY;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;IAEM;IACA;IACA;;IAGA;IACA;IACA;MACE;MACA;;IAEF;IACA;;EAGN;IACE;IACA;IACA;MACE;MACA;MACA;MACA;MACA;;;;YAKM;EACV;EACA;EACA;EACA;EACA;EACA;EACA"}
|
|
@@ -3,25 +3,30 @@ import { OneOf } from "./utils.js";
|
|
|
3
3
|
import { UTXOMethod } from "../transports/types.js";
|
|
4
4
|
import { ErrorType } from "../errors/utils.js";
|
|
5
5
|
import { BtcRpcRequestFn, RpcSchema } from "./request.js";
|
|
6
|
-
|
|
7
6
|
//#region src/types/transport.d.ts
|
|
8
|
-
type TransportConfig<type extends string = string, rpcRequestFn extends BtcRpcRequestFn = BtcRpcRequestFn> = {
|
|
9
|
-
/** The name of the transport. */
|
|
10
|
-
|
|
7
|
+
export type TransportConfig<type extends string = string, rpcRequestFn extends BtcRpcRequestFn = BtcRpcRequestFn> = {
|
|
8
|
+
/** The name of the transport. */
|
|
9
|
+
name: string;
|
|
10
|
+
/** The key of the transport. */
|
|
11
|
+
key: string;
|
|
12
|
+
/** Methods to include or exclude from executing RPC requests. */
|
|
11
13
|
methods?: OneOf<{
|
|
12
14
|
include?: UTXOMethod[] | undefined;
|
|
13
15
|
} | {
|
|
14
16
|
exclude?: UTXOMethod[] | undefined;
|
|
15
|
-
}> | undefined;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
}> | undefined;
|
|
18
|
+
/** The JSON-RPC request function that matches the EIP-1193 request spec. */
|
|
19
|
+
request: rpcRequestFn;
|
|
20
|
+
/** The base delay (in ms) between retries. */
|
|
21
|
+
retryDelay?: number | undefined;
|
|
22
|
+
/** The max number of times to retry. */
|
|
23
|
+
retryCount?: number | undefined;
|
|
24
|
+
/** The timeout (in ms) for requests. */
|
|
25
|
+
timeout?: number | undefined;
|
|
26
|
+
/** The type of the transport. */
|
|
20
27
|
type: type;
|
|
21
28
|
};
|
|
22
|
-
type Transport<type extends string = string, rpcAttributes = Record<string, any>, rpcRequestFn extends BtcRpcRequestFn = BtcRpcRequestFn<RpcSchema>> = <chain extends Chain | undefined = Chain>({
|
|
23
|
-
chain
|
|
24
|
-
}: {
|
|
29
|
+
export type Transport<type extends string = string, rpcAttributes = Record<string, any>, rpcRequestFn extends BtcRpcRequestFn = BtcRpcRequestFn<RpcSchema>> = <chain extends Chain | undefined = Chain>({ chain }: {
|
|
25
30
|
chain?: chain | undefined;
|
|
26
31
|
pollingInterval?: number | undefined;
|
|
27
32
|
retryCount?: TransportConfig["retryCount"] | undefined;
|
|
@@ -31,7 +36,6 @@ type Transport<type extends string = string, rpcAttributes = Record<string, any>
|
|
|
31
36
|
request: rpcRequestFn;
|
|
32
37
|
value?: rpcAttributes | undefined;
|
|
33
38
|
};
|
|
34
|
-
type CreateTransportErrorType = ErrorType;
|
|
39
|
+
export type CreateTransportErrorType = ErrorType;
|
|
35
40
|
//#endregion
|
|
36
|
-
export { CreateTransportErrorType, Transport, TransportConfig };
|
|
37
41
|
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","names":[],"sources":["../../../src/types/transport.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"transport.d.ts","names":[],"sources":["../../../src/types/transport.ts"],"mappings":";;;;;;YAMY,gBACV,8BACA,qBAAqB,kBAAkB;;EAGvC;;EAEA;;EAEA,UACI;IAEM,UAAU;;IAGV,UAAU;;;EAKpB,SAAS;;EAET;;EAEA;;EAEA;;EAEA,MAAM;;YAGI,UACV,8BACA,gBAAgB,qBAChB,qBAAqB,kBAAkB,gBAAgB,eACpD,cAAc,oBAAoB,SACrC;EAEA,QAAQ;EACR;EACA,aAAa;EACb,UAAU;;EAEV,QAAQ,gBAAgB;EACxB,SAAS;EACT,QAAQ;;YAGE,2BAA2B"}
|
|
@@ -1,61 +1,60 @@
|
|
|
1
1
|
//#region src/types/utils.d.ts
|
|
2
2
|
/** Combines members of an intersection into a readable type. */
|
|
3
|
-
type Compute<type> = { [key in keyof type]: type[key] } & unknown;
|
|
3
|
+
export type Compute<type> = { [key in keyof type]: type[key]; } & unknown;
|
|
4
4
|
/**
|
|
5
|
-
* Makes all properties of an object optional.
|
|
6
|
-
*
|
|
7
|
-
* Compatible with [`exactOptionalPropertyTypes`](https://www.typescriptlang.org/tsconfig#exactOptionalPropertyTypes).
|
|
8
|
-
*/
|
|
9
|
-
type ExactPartial<type> = { [key in keyof type]?: type[key] | undefined };
|
|
5
|
+
* Makes all properties of an object optional.
|
|
6
|
+
*
|
|
7
|
+
* Compatible with [`exactOptionalPropertyTypes`](https://www.typescriptlang.org/tsconfig#exactOptionalPropertyTypes).
|
|
8
|
+
*/
|
|
9
|
+
export type ExactPartial<type> = { [key in keyof type]?: type[key] | undefined; };
|
|
10
10
|
/** Checks if {@link type} can be narrowed further than {@link type2} */
|
|
11
|
-
type IsNarrowable<type, type2> = IsUnknown<type> extends true ? false : undefined extends type ? false : IsNever<(type extends type2 ? true : false) & (type2 extends type ? false : true)> extends true ? false : true;
|
|
11
|
+
export type IsNarrowable<type, type2> = IsUnknown<type> extends true ? false : undefined extends type ? false : IsNever<(type extends type2 ? true : false) & (type2 extends type ? false : true)> extends true ? false : true;
|
|
12
12
|
/**
|
|
13
|
-
* @internal
|
|
14
|
-
* Checks if {@link type} is `never`
|
|
15
|
-
*/
|
|
16
|
-
type IsNever<type> = [type] extends [never] ? true : false;
|
|
13
|
+
* @internal
|
|
14
|
+
* Checks if {@link type} is `never`
|
|
15
|
+
*/
|
|
16
|
+
export type IsNever<type> = [type] extends [never] ? true : false;
|
|
17
17
|
/**
|
|
18
|
-
* @internal
|
|
19
|
-
* Checks if {@link type} is `unknown`
|
|
20
|
-
*/
|
|
21
|
-
type IsUnknown<type> = unknown extends type ? true : false;
|
|
18
|
+
* @internal
|
|
19
|
+
* Checks if {@link type} is `unknown`
|
|
20
|
+
*/
|
|
21
|
+
export type IsUnknown<type> = unknown extends type ? true : false;
|
|
22
22
|
/** Merges two object types into new type */
|
|
23
|
-
type Merge<obj1, obj2> = Compute<LooseOmit<obj1, keyof obj2 extends infer key extends string ? key : never> & obj2>;
|
|
23
|
+
export type Merge<obj1, obj2> = Compute<LooseOmit<obj1, keyof obj2 extends (infer key extends string) ? key : never> & obj2>;
|
|
24
24
|
/** Removes `readonly` from all properties of an object. */
|
|
25
|
-
type Mutable<type extends object> = { -readonly [key in keyof type]: type[key] };
|
|
25
|
+
export type Mutable<type extends object> = { -readonly [key in keyof type]: type[key]; };
|
|
26
26
|
/** Strict version of built-in Omit type */
|
|
27
|
-
type StrictOmit<type, keys extends keyof type> = Pick<type, Exclude<keyof type, keys>>;
|
|
27
|
+
export type StrictOmit<type, keys extends keyof type> = Pick<type, Exclude<keyof type, keys>>;
|
|
28
28
|
/** Makes objects destructurable. */
|
|
29
|
-
type OneOf<union extends object, keys extends KeyofUnion<union> = KeyofUnion<union>> = union extends infer Item ? Compute<Item & { [K in Exclude<keys, keyof Item>]?: undefined }> : never;
|
|
29
|
+
export type OneOf<union extends object, keys extends KeyofUnion<union> = KeyofUnion<union>> = union extends (infer Item) ? Compute<Item & { [K in Exclude<keys, keyof Item>]?: undefined; }> : never;
|
|
30
30
|
type KeyofUnion<type> = type extends type ? keyof type : never;
|
|
31
31
|
/** Makes {@link key} optional in {@link type} while preserving type inference. */
|
|
32
|
-
type PartialBy<type, key extends keyof type> = ExactPartial<Pick<type, key>> & StrictOmit<type, key>;
|
|
33
|
-
type RemoveUndefined<type> = { [key in keyof type]: NonNullable<type[key]
|
|
32
|
+
export type PartialBy<type, key extends keyof type> = ExactPartial<Pick<type, key>> & StrictOmit<type, key>;
|
|
33
|
+
export type RemoveUndefined<type> = { [key in keyof type]: NonNullable<type[key]>; };
|
|
34
34
|
/** Loose version of {@link StrictOmit} */
|
|
35
|
-
type LooseOmit<type, keys extends string> = Pick<type, Exclude<keyof type, keys>>;
|
|
36
|
-
type UnionCompute<type> = type extends object ? Compute<type> : type;
|
|
37
|
-
type UnionLooseOmit<type, keys extends string> = type extends any ? LooseOmit<type, keys> : never;
|
|
38
|
-
type UnionStrictOmit<type, keys extends keyof type> = type extends any ? StrictOmit<type, keys> : never;
|
|
39
|
-
type UnionExactPartial<type> = type extends object ? ExactPartial<type> : type;
|
|
35
|
+
export type LooseOmit<type, keys extends string> = Pick<type, Exclude<keyof type, keys>>;
|
|
36
|
+
export type UnionCompute<type> = type extends object ? Compute<type> : type;
|
|
37
|
+
export type UnionLooseOmit<type, keys extends string> = type extends any ? LooseOmit<type, keys> : never;
|
|
38
|
+
export type UnionStrictOmit<type, keys extends keyof type> = type extends any ? StrictOmit<type, keys> : never;
|
|
39
|
+
export type UnionExactPartial<type> = type extends object ? ExactPartial<type> : type;
|
|
40
40
|
/**
|
|
41
|
-
* @description Combines members of an intersection into a readable type.
|
|
42
|
-
*
|
|
43
|
-
* @see {@link https://twitter.com/mattpocockuk/status/1622730173446557697?s=20&t=NdpAcmEFXY01xkqU3KO0Mg}
|
|
44
|
-
* @example
|
|
45
|
-
* Prettify<{ a: string } & { b: string } & { c: number, d: bigint }>
|
|
46
|
-
* => { a: string, b: string, c: number, d: bigint }
|
|
47
|
-
*/
|
|
48
|
-
type Prettify<T> = { [K in keyof T]: T[K] } & {};
|
|
41
|
+
* @description Combines members of an intersection into a readable type.
|
|
42
|
+
*
|
|
43
|
+
* @see {@link https://twitter.com/mattpocockuk/status/1622730173446557697?s=20&t=NdpAcmEFXY01xkqU3KO0Mg}
|
|
44
|
+
* @example
|
|
45
|
+
* Prettify<{ a: string } & { b: string } & { c: number, d: bigint }>
|
|
46
|
+
* => { a: string, b: string, c: number, d: bigint }
|
|
47
|
+
*/
|
|
48
|
+
export type Prettify<T> = { [K in keyof T]: T[K]; } & {};
|
|
49
49
|
/**
|
|
50
|
-
* @description Assigns the properties of U onto T.
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* Assign<{ a: string, b: number }, { a: undefined, c: boolean }>
|
|
54
|
-
* => { a: undefined, b: number, c: boolean }
|
|
55
|
-
*/
|
|
56
|
-
type Assign<T, U> = Assign_<T, U> & U;
|
|
57
|
-
type Assign_<T, U> = { [K in keyof T as K extends keyof U ? U[K] extends void ? never : K : K]: K extends keyof U ? U[K] : T[K] };
|
|
58
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
50
|
+
* @description Assigns the properties of U onto T.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* Assign<{ a: string, b: number }, { a: undefined, c: boolean }>
|
|
54
|
+
* => { a: undefined, b: number, c: boolean }
|
|
55
|
+
*/
|
|
56
|
+
export type Assign<T, U> = Assign_<T, U> & U;
|
|
57
|
+
type Assign_<T, U> = { [K in keyof T as K extends keyof U ? U[K] extends void ? never : K : K]: K extends keyof U ? U[K] : T[K]; };
|
|
58
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
59
59
|
//#endregion
|
|
60
|
-
export { Assign, Compute, ExactPartial, IsNarrowable, IsNever, IsUnknown, LooseOmit, MaybePromise, Merge, Mutable, OneOf, PartialBy, Prettify, RemoveUndefined, StrictOmit, UnionCompute, UnionExactPartial, UnionLooseOmit, UnionStrictOmit };
|
|
61
60
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","names":[],"sources":["../../../src/types/utils.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","names":[],"sources":["../../../src/types/utils.ts"],"mappings":";;YAEY,QAAQ,WAAW,aAAa,OAAO,KAAK;;;;;;YAO5C,aAAa,WACtB,aAAa,QAAQ,KAAK;;YAIjB,aAAa,MAAM,SAC7B,UAAU,+CAEY,eAEhB,SACK,aAAa,yBACX,cAAc;;;;;YASjB,QAAQ,SAAS;;;;;YAMjB,UAAU,wBAAwB;;YAGlC,MAAM,MAAM,QAAQ,QAC9B,UAAU,YAAY,oBAAmB,sBAAqB,eAC5D;;YAIQ,QAAQ,oCACP,aAAa,OAAO,KAAK;;YAI1B,WAAW,MAAM,mBAAmB,QAAQ,KACtD,MACA,cAAc,MAAM;;YAIV,MACV,sBAEA,aAAa,WAAW,SAAS,WAAW,UAC1C,qBAAoB,QACpB,QAAQ,UAAU,KAAK,QAAQ,YAAY;KAE1C,WAAW,QAAQ,aAAa,aAAa;;YAItC,UAAU,MAAM,kBAAkB,QAAQ,aACpD,KAAK,MAAM,QAEX,WAAW,MAAM;YAGP,gBAAgB,WACzB,aAAa,OAAO,YAAY,KAAK;;YAO5B,UAAU,MAAM,uBAAuB,KACjD,MACA,cAAc,MAAM;YAMV,aAAa,QAAQ,sBAAsB,QAAQ,QAAQ;YAE3D,eAAe,MAAM,uBAAuB,mBACpD,UAAU,MAAM;YAGR,gBAAgB,MAAM,mBAAmB,QAAQ,mBACzD,WAAW,MAAM;YAGT,kBAAkB,QAAQ,sBAClC,aAAa,QACb;;;;;;;;;YAUQ,SAAS,QAClB,WAAW,IAAI,EAAE;;;;;;;;YAUR,OAAO,GAAG,KAAK,QAAQ,GAAG,KAAK;KACtC,QAAQ,GAAG,QACb,WAAW,KAAK,gBAAgB,IAC7B,EAAE,0BAEA,IACF,IAAI,gBAAgB,IAAI,EAAE,KAAK,EAAE;YAG3B,aAAa,KAAK,IAAI,QAAQ"}
|
package/dist/esm/types/xpub.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Address } from "./address.js";
|
|
2
|
-
|
|
3
2
|
//#region src/types/xpub.d.ts
|
|
4
|
-
type xPubAccount = {
|
|
3
|
+
export type xPubAccount = {
|
|
5
4
|
balance: bigint;
|
|
6
5
|
addresses: Array<{
|
|
7
6
|
address: Address;
|
|
@@ -11,5 +10,4 @@ type xPubAccount = {
|
|
|
11
10
|
}>;
|
|
12
11
|
};
|
|
13
12
|
//#endregion
|
|
14
|
-
export { xPubAccount };
|
|
15
13
|
//# sourceMappingURL=xpub.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xpub.d.ts","names":[],"sources":["../../../src/types/xpub.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"xpub.d.ts","names":[],"sources":["../../../src/types/xpub.ts"],"mappings":";;YAEY;EACV;EACA,WAAW;IACT,SAAS;IACT;IACA;IACA"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { ErrorType } from "../errors/utils.js";
|
|
2
2
|
import { BtcRpcRequestFn, BtcRpcRequestOptions, RpcSchema } from "../types/request.js";
|
|
3
|
-
|
|
4
3
|
//#region src/utils/buildRequest.d.ts
|
|
5
|
-
type RequestErrorType = ErrorType;
|
|
6
|
-
declare function buildRequest<request extends BtcRpcRequestFn<RpcSchema>>(request: request, options?: BtcRpcRequestOptions): BtcRpcRequestFn;
|
|
4
|
+
export type RequestErrorType = ErrorType;
|
|
5
|
+
export declare function buildRequest<request extends BtcRpcRequestFn<RpcSchema>>(request: request, options?: BtcRpcRequestOptions): BtcRpcRequestFn;
|
|
7
6
|
/** @internal */
|
|
8
|
-
declare function shouldRetry(error: Error): boolean;
|
|
7
|
+
export declare function shouldRetry(error: Error): boolean;
|
|
9
8
|
//#endregion
|
|
10
|
-
export { RequestErrorType, buildRequest, shouldRetry };
|
|
11
9
|
//# sourceMappingURL=buildRequest.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildRequest.d.ts","names":[],"sources":["../../../src/utils/buildRequest.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildRequest.d.ts","names":[],"sources":["../../../src/utils/buildRequest.ts"],"mappings":";;;YAkBY,mBAAmB;wBAEf,aAAa,gBAAgB,gBAAgB,YAC3D,SAAS,SACT,UAAS,uBACR;;wBA2Ea,YAAY,OAAO"}
|
|
@@ -15,6 +15,7 @@ function buildRequest(request, options = {}) {
|
|
|
15
15
|
const { method } = args;
|
|
16
16
|
if (methods?.exclude?.includes(method)) throw new MethodNotSupportedRpcError(method);
|
|
17
17
|
if (methods?.include && !methods.include.includes(method)) throw new MethodNotSupportedRpcError(method);
|
|
18
|
+
const requestId = dedupe ? stringToHex(`${uid}.${stringify(args)}`) : void 0;
|
|
18
19
|
return withDedupe(() => withRetry(async () => {
|
|
19
20
|
try {
|
|
20
21
|
return await request(args);
|
|
@@ -41,7 +42,7 @@ function buildRequest(request, options = {}) {
|
|
|
41
42
|
shouldRetry: ({ error }) => shouldRetry(error)
|
|
42
43
|
}), {
|
|
43
44
|
enabled: dedupe,
|
|
44
|
-
id:
|
|
45
|
+
id: requestId
|
|
45
46
|
});
|
|
46
47
|
};
|
|
47
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildRequest.js","names":[],"sources":["../../../src/utils/buildRequest.ts"],"sourcesContent":["import { BaseError } from '../errors/base.js'\nimport { HttpRequestError } from '../errors/request.js'\nimport {\n MethodNotSupportedRpcError,\n RpcErrorCode,\n UserRejectedRequestError,\n} from '../errors/rpc.js'\nimport type { ErrorType } from '../errors/utils.js'\nimport type {\n BtcRpcRequestFn,\n BtcRpcRequestOptions,\n RpcSchema,\n} from '../types/request.js'\nimport { stringToHex } from './converter.js'\nimport { stringify } from './stringify.js'\nimport { withDedupe } from './withDedupe.js'\nimport { withRetry } from './withRetry.js'\n\nexport type RequestErrorType = ErrorType\n\nexport function buildRequest<request extends BtcRpcRequestFn<RpcSchema>>(\n request: request,\n options: BtcRpcRequestOptions = {}\n): BtcRpcRequestFn {\n return async (args, overrideOptions = {}) => {\n const {\n dedupe = false,\n methods,\n retryDelay = 150,\n retryCount = 3,\n uid,\n } = {\n ...options,\n ...overrideOptions,\n }\n\n const { method } = args\n if (methods?.exclude?.includes(method)) {\n throw new MethodNotSupportedRpcError(method)\n }\n if (methods?.include && !methods.include.includes(method)) {\n throw new MethodNotSupportedRpcError(method)\n }\n\n const requestId = dedupe\n ? stringToHex(`${uid}.${stringify(args)}`)\n : undefined\n return withDedupe(\n () =>\n withRetry(\n async () => {\n try {\n return await request(args)\n } catch (err_) {\n const err = err_ as unknown as BaseError\n switch (err.code) {\n case RpcErrorCode.METHOD_NOT_SUPPORTED:\n throw new MethodNotSupportedRpcError(method)\n\n case RpcErrorCode.USER_REJECTION:\n throw new UserRejectedRequestError(err.message)\n\n // CAIP-25: User Rejected Error\n // https://docs.walletconnect.com/2.0/specs/clients/sign/error-codes#rejected-caip-25\n case 5000:\n throw new UserRejectedRequestError(err.message)\n\n default:\n if (err_ instanceof BaseError) {\n throw err_\n }\n throw new BaseError('Unknown Error', { cause: err_ as Error })\n }\n }\n },\n {\n delay: ({ count, error }) => {\n // If we find a Retry-After header, let's retry after the given time.\n if (error && error instanceof HttpRequestError) {\n const retryAfter = error?.headers?.get('Retry-After')\n if (retryAfter?.match(/\\d/)) {\n return Number.parseInt(retryAfter, 10) * 1000\n }\n }\n\n // Otherwise, let's retry with an exponential backoff.\n return ~~(1 << count) * retryDelay\n },\n retryCount,\n shouldRetry: ({ error }) => shouldRetry(error),\n }\n ),\n { enabled: dedupe, id: requestId }\n )\n }\n}\n\n/** @internal */\nexport function shouldRetry(error: Error): boolean {\n if ('code' in error && typeof error.code === 'number') {\n if (error.code === -1) {\n return true // Unknown error\n }\n if (error.code === RpcErrorCode.INTERNAL_ERROR) {\n return true\n }\n return false\n }\n if (error instanceof HttpRequestError && error.status) {\n // Forbidden\n if (error.status === 403) {\n return true\n }\n // Request Timeout\n if (error.status === 408) {\n return true\n }\n // Request Entity Too Large\n if (error.status === 413) {\n return true\n }\n // Too Many Requests\n if (error.status === 429) {\n return true\n }\n // Internal Server Error\n if (error.status === 500) {\n return true\n }\n // Bad Gateway\n if (error.status === 502) {\n return true\n }\n // Service Unavailable\n if (error.status === 503) {\n return true\n }\n // Gateway Timeout\n if (error.status === 504) {\n return true\n }\n return false\n }\n return true\n}\n"],"mappings":";;;;;;;;AAoBA,SAAgB,aACd,SACA,UAAgC,CAAC,GAChB;CACjB,OAAO,OAAO,MAAM,kBAAkB,CAAC,MAAM;EAC3C,MAAM,EACJ,SAAS,OACT,SACA,aAAa,KACb,aAAa,GACb,QACE;GACF,GAAG;GACH,GAAG;EACL;EAEA,MAAM,EAAE,WAAW;EACnB,IAAI,SAAS,SAAS,SAAS,MAAM,GACnC,MAAM,IAAI,2BAA2B,MAAM;EAE7C,IAAI,SAAS,WAAW,CAAC,QAAQ,QAAQ,SAAS,MAAM,GACtD,MAAM,IAAI,2BAA2B,MAAM;
|
|
1
|
+
{"version":3,"file":"buildRequest.js","names":[],"sources":["../../../src/utils/buildRequest.ts"],"sourcesContent":["import { BaseError } from '../errors/base.js'\nimport { HttpRequestError } from '../errors/request.js'\nimport {\n MethodNotSupportedRpcError,\n RpcErrorCode,\n UserRejectedRequestError,\n} from '../errors/rpc.js'\nimport type { ErrorType } from '../errors/utils.js'\nimport type {\n BtcRpcRequestFn,\n BtcRpcRequestOptions,\n RpcSchema,\n} from '../types/request.js'\nimport { stringToHex } from './converter.js'\nimport { stringify } from './stringify.js'\nimport { withDedupe } from './withDedupe.js'\nimport { withRetry } from './withRetry.js'\n\nexport type RequestErrorType = ErrorType\n\nexport function buildRequest<request extends BtcRpcRequestFn<RpcSchema>>(\n request: request,\n options: BtcRpcRequestOptions = {}\n): BtcRpcRequestFn {\n return async (args, overrideOptions = {}) => {\n const {\n dedupe = false,\n methods,\n retryDelay = 150,\n retryCount = 3,\n uid,\n } = {\n ...options,\n ...overrideOptions,\n }\n\n const { method } = args\n if (methods?.exclude?.includes(method)) {\n throw new MethodNotSupportedRpcError(method)\n }\n if (methods?.include && !methods.include.includes(method)) {\n throw new MethodNotSupportedRpcError(method)\n }\n\n const requestId = dedupe\n ? stringToHex(`${uid}.${stringify(args)}`)\n : undefined\n return withDedupe(\n () =>\n withRetry(\n async () => {\n try {\n return await request(args)\n } catch (err_) {\n const err = err_ as unknown as BaseError\n switch (err.code) {\n case RpcErrorCode.METHOD_NOT_SUPPORTED:\n throw new MethodNotSupportedRpcError(method)\n\n case RpcErrorCode.USER_REJECTION:\n throw new UserRejectedRequestError(err.message)\n\n // CAIP-25: User Rejected Error\n // https://docs.walletconnect.com/2.0/specs/clients/sign/error-codes#rejected-caip-25\n case 5000:\n throw new UserRejectedRequestError(err.message)\n\n default:\n if (err_ instanceof BaseError) {\n throw err_\n }\n throw new BaseError('Unknown Error', { cause: err_ as Error })\n }\n }\n },\n {\n delay: ({ count, error }) => {\n // If we find a Retry-After header, let's retry after the given time.\n if (error && error instanceof HttpRequestError) {\n const retryAfter = error?.headers?.get('Retry-After')\n if (retryAfter?.match(/\\d/)) {\n return Number.parseInt(retryAfter, 10) * 1000\n }\n }\n\n // Otherwise, let's retry with an exponential backoff.\n return ~~(1 << count) * retryDelay\n },\n retryCount,\n shouldRetry: ({ error }) => shouldRetry(error),\n }\n ),\n { enabled: dedupe, id: requestId }\n )\n }\n}\n\n/** @internal */\nexport function shouldRetry(error: Error): boolean {\n if ('code' in error && typeof error.code === 'number') {\n if (error.code === -1) {\n return true // Unknown error\n }\n if (error.code === RpcErrorCode.INTERNAL_ERROR) {\n return true\n }\n return false\n }\n if (error instanceof HttpRequestError && error.status) {\n // Forbidden\n if (error.status === 403) {\n return true\n }\n // Request Timeout\n if (error.status === 408) {\n return true\n }\n // Request Entity Too Large\n if (error.status === 413) {\n return true\n }\n // Too Many Requests\n if (error.status === 429) {\n return true\n }\n // Internal Server Error\n if (error.status === 500) {\n return true\n }\n // Bad Gateway\n if (error.status === 502) {\n return true\n }\n // Service Unavailable\n if (error.status === 503) {\n return true\n }\n // Gateway Timeout\n if (error.status === 504) {\n return true\n }\n return false\n }\n return true\n}\n"],"mappings":";;;;;;;;AAoBA,SAAgB,aACd,SACA,UAAgC,CAAC,GAChB;CACjB,OAAO,OAAO,MAAM,kBAAkB,CAAC,MAAM;EAC3C,MAAM,EACJ,SAAS,OACT,SACA,aAAa,KACb,aAAa,GACb,QACE;GACF,GAAG;GACH,GAAG;EACL;EAEA,MAAM,EAAE,WAAW;EACnB,IAAI,SAAS,SAAS,SAAS,MAAM,GACnC,MAAM,IAAI,2BAA2B,MAAM;EAE7C,IAAI,SAAS,WAAW,CAAC,QAAQ,QAAQ,SAAS,MAAM,GACtD,MAAM,IAAI,2BAA2B,MAAM;EAG7C,MAAM,YAAY,SACd,YAAY,GAAG,IAAI,GAAG,UAAU,IAAI,GAAG,IACvC,KAAA;EACJ,OAAO,iBAEH,UACE,YAAY;GACV,IAAI;IACF,OAAO,MAAM,QAAQ,IAAI;GAC3B,SAAS,MAAM;IACb,MAAM,MAAM;IACZ,QAAQ,IAAI,MAAZ;KACE,KAAA,QACE,MAAM,IAAI,2BAA2B,MAAM;KAE7C,KAAA,OACE,MAAM,IAAI,yBAAyB,IAAI,OAAO;KAIhD,KAAK,KACH,MAAM,IAAI,yBAAyB,IAAI,OAAO;KAEhD;MACE,IAAI,gBAAgB,WAClB,MAAM;MAER,MAAM,IAAI,UAAU,iBAAiB,EAAE,OAAO,KAAc,CAAC;IACjE;GACF;EACF,GACA;GACE,QAAQ,EAAE,OAAO,YAAY;IAE3B,IAAI,SAAS,iBAAiB,kBAAkB;KAC9C,MAAM,aAAa,OAAO,SAAS,IAAI,aAAa;KACpD,IAAI,YAAY,MAAM,IAAI,GACxB,OAAO,OAAO,SAAS,YAAY,EAAE,IAAI;IAE7C;IAGA,OAAO,CAAC,EAAE,KAAK,SAAS;GAC1B;GACA;GACA,cAAc,EAAE,YAAY,YAAY,KAAK;EAC/C,CACF,GACF;GAAE,SAAS;GAAQ,IAAI;EAAU,CACnC;CACF;AACF;;AAGA,SAAgB,YAAY,OAAuB;CACjD,IAAI,UAAU,SAAS,OAAO,MAAM,SAAS,UAAU;EACrD,IAAI,MAAM,SAAS,IACjB,OAAO;EAET,IAAI,MAAM,SAAA,QACR,OAAO;EAET,OAAO;CACT;CACA,IAAI,iBAAiB,oBAAoB,MAAM,QAAQ;EAErD,IAAI,MAAM,WAAW,KACnB,OAAO;EAGT,IAAI,MAAM,WAAW,KACnB,OAAO;EAGT,IAAI,MAAM,WAAW,KACnB,OAAO;EAGT,IAAI,MAAM,WAAW,KACnB,OAAO;EAGT,IAAI,MAAM,WAAW,KACnB,OAAO;EAGT,IAAI,MAAM,WAAW,KACnB,OAAO;EAGT,IAAI,MAAM,WAAW,KACnB,OAAO;EAGT,IAAI,MAAM,WAAW,KACnB,OAAO;EAET,OAAO;CACT;CACA,OAAO;AACT"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { Psbt } from "bitcoinjs-lib";
|
|
2
|
-
|
|
3
2
|
//#region src/utils/cancelTransaction.d.ts
|
|
4
|
-
declare function cancelTransaction(psbt: Psbt, accountAddress: string): Psbt;
|
|
3
|
+
export declare function cancelTransaction(psbt: Psbt, accountAddress: string): Psbt;
|
|
5
4
|
//#endregion
|
|
6
|
-
export { cancelTransaction };
|
|
7
5
|
//# sourceMappingURL=cancelTransaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cancelTransaction.d.ts","names":[],"sources":["../../../src/utils/cancelTransaction.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"cancelTransaction.d.ts","names":[],"sources":["../../../src/utils/cancelTransaction.ts"],"mappings":";;wBAcgB,kBAAkB,MAAM,MAAM,yBAAyB"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
//#region src/utils/converter.d.ts
|
|
2
|
-
declare function hexToBase64(hex: string): string;
|
|
3
|
-
declare function base64ToHex(base64: string): string;
|
|
4
|
-
declare function base64urlEncode(str: string): string;
|
|
5
|
-
declare function stringToHex(value: string): string;
|
|
6
|
-
declare function hexToUnit8Array(value: string): Uint8Array;
|
|
2
|
+
export declare function hexToBase64(hex: string): string;
|
|
3
|
+
export declare function base64ToHex(base64: string): string;
|
|
4
|
+
export declare function base64urlEncode(str: string): string;
|
|
5
|
+
export declare function stringToHex(value: string): string;
|
|
6
|
+
export declare function hexToUnit8Array(value: string): Uint8Array;
|
|
7
7
|
//#endregion
|
|
8
|
-
export { base64ToHex, base64urlEncode, hexToBase64, hexToUnit8Array, stringToHex };
|
|
9
8
|
//# sourceMappingURL=converter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"converter.d.ts","names":[],"sources":["../../../src/utils/converter.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"converter.d.ts","names":[],"sources":["../../../src/utils/converter.ts"],"mappings":";wBAAgB,YAAY;wBAQZ,YAAY;wBAUZ,gBAAgB;wBAShB,YAAY;wBAQZ,gBAAgB,gBAAgB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"converter.js","names":[],"sources":["../../../src/utils/converter.ts"],"sourcesContent":["export function hexToBase64(hex: string): string {\n const raw = hex\n .match(/.{1,2}/g)!\n .map((byte: string) => String.fromCharCode(Number.parseInt(byte, 16)))\n .join('')\n return btoa(raw)\n}\n\nexport function base64ToHex(base64: string): string {\n const raw = atob(base64)\n let hex = ''\n for (let i = 0; i < raw.length; i++) {\n const hexByte = raw.charCodeAt(i).toString(16)\n hex += hexByte.length === 2 ? hexByte : `0${hexByte}`\n }\n return hex\n}\n\nexport function base64urlEncode(str: string): string {\n const bytes = new TextEncoder().encode(str)\n const encodedString = btoa(String.fromCharCode(...bytes))\n return encodedString\n .replace(/\\+/g, '-')\n .replace(/\\//g, '_')\n .replace(/=+$/, '')\n}\n\nexport function stringToHex(value: string): string {\n const hex = Array.from(value)\n .map((char: string) => char.charCodeAt(0).toString(16).padStart(2, '0'))\n .join('')\n\n return `0x${hex}`\n}\n\nexport function hexToUnit8Array(value: string): Uint8Array {\n return new Uint8Array(\n value.match(/.{1,2}/g)?.map((byte) => Number.parseInt(byte, 16)) || []\n )\n}\n"],"mappings":";AAAA,SAAgB,YAAY,KAAqB;CAC/C,MAAM,MAAM,IACT,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"converter.js","names":[],"sources":["../../../src/utils/converter.ts"],"sourcesContent":["export function hexToBase64(hex: string): string {\n const raw = hex\n .match(/.{1,2}/g)!\n .map((byte: string) => String.fromCharCode(Number.parseInt(byte, 16)))\n .join('')\n return btoa(raw)\n}\n\nexport function base64ToHex(base64: string): string {\n const raw = atob(base64)\n let hex = ''\n for (let i = 0; i < raw.length; i++) {\n const hexByte = raw.charCodeAt(i).toString(16)\n hex += hexByte.length === 2 ? hexByte : `0${hexByte}`\n }\n return hex\n}\n\nexport function base64urlEncode(str: string): string {\n const bytes = new TextEncoder().encode(str)\n const encodedString = btoa(String.fromCharCode(...bytes))\n return encodedString\n .replace(/\\+/g, '-')\n .replace(/\\//g, '_')\n .replace(/=+$/, '')\n}\n\nexport function stringToHex(value: string): string {\n const hex = Array.from(value)\n .map((char: string) => char.charCodeAt(0).toString(16).padStart(2, '0'))\n .join('')\n\n return `0x${hex}`\n}\n\nexport function hexToUnit8Array(value: string): Uint8Array {\n return new Uint8Array(\n value.match(/.{1,2}/g)?.map((byte) => Number.parseInt(byte, 16)) || []\n )\n}\n"],"mappings":";AAAA,SAAgB,YAAY,KAAqB;CAC/C,MAAM,MAAM,IACT,MAAM,SAAS,CAAC,CAChB,KAAK,SAAiB,OAAO,aAAa,OAAO,SAAS,MAAM,EAAE,CAAC,CAAC,CAAC,CACrE,KAAK,EAAE;CACV,OAAO,KAAK,GAAG;AACjB;AAEA,SAAgB,YAAY,QAAwB;CAClD,MAAM,MAAM,KAAK,MAAM;CACvB,IAAI,MAAM;CACV,KAAK,IAAI,IAAI,GAAG,IAAI,IAAI,QAAQ,KAAK;EACnC,MAAM,UAAU,IAAI,WAAW,CAAC,CAAC,CAAC,SAAS,EAAE;EAC7C,OAAO,QAAQ,WAAW,IAAI,UAAU,IAAI;CAC9C;CACA,OAAO;AACT;AAEA,SAAgB,gBAAgB,KAAqB;CACnD,MAAM,QAAQ,IAAI,YAAY,CAAC,CAAC,OAAO,GAAG;CAE1C,OADsB,KAAK,OAAO,aAAa,GAAG,KAAK,CACpC,CAAC,CACjB,QAAQ,OAAO,GAAG,CAAC,CACnB,QAAQ,OAAO,GAAG,CAAC,CACnB,QAAQ,OAAO,EAAE;AACtB;AAEA,SAAgB,YAAY,OAAuB;CAKjD,OAAO,KAJK,MAAM,KAAK,KAAK,CAAC,CAC1B,KAAK,SAAiB,KAAK,WAAW,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,CACvE,KAAK,EAEM;AAChB;AAEA,SAAgB,gBAAgB,OAA2B;CACzD,OAAO,IAAI,WACT,MAAM,MAAM,SAAS,CAAC,EAAE,KAAK,SAAS,OAAO,SAAS,MAAM,EAAE,CAAC,KAAK,CAAC,CACvE;AACF"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ErrorType } from "../errors/utils.js";
|
|
2
|
-
|
|
3
2
|
//#region src/utils/createBatchScheduler.d.ts
|
|
4
3
|
type Resolved<returnType extends readonly unknown[] = any> = [result: returnType[number], results: returnType];
|
|
5
4
|
type BatchResultsCompareFn<result = unknown> = (a: result, b: result) => number;
|
|
@@ -14,15 +13,8 @@ type CreateBatchSchedulerReturnType<parameters = unknown, returnType extends rea
|
|
|
14
13
|
flush: () => void;
|
|
15
14
|
schedule: parameters extends undefined ? (args?: parameters | undefined) => Promise<Resolved<returnType>> : (args: parameters) => Promise<Resolved<returnType>>;
|
|
16
15
|
};
|
|
17
|
-
type CreateBatchSchedulerErrorType = ErrorType;
|
|
16
|
+
export type CreateBatchSchedulerErrorType = ErrorType;
|
|
18
17
|
/** @internal */
|
|
19
|
-
declare function createBatchScheduler<parameters, returnType extends readonly unknown[]>({
|
|
20
|
-
fn,
|
|
21
|
-
id,
|
|
22
|
-
shouldSplitBatch,
|
|
23
|
-
wait,
|
|
24
|
-
sort
|
|
25
|
-
}: CreateBatchSchedulerArguments<parameters, returnType>): CreateBatchSchedulerReturnType<parameters, returnType>;
|
|
18
|
+
export declare function createBatchScheduler<parameters, returnType extends readonly unknown[]>({ fn, id, shouldSplitBatch, wait, sort }: CreateBatchSchedulerArguments<parameters, returnType>): CreateBatchSchedulerReturnType<parameters, returnType>;
|
|
26
19
|
//#endregion
|
|
27
|
-
export { CreateBatchSchedulerErrorType, createBatchScheduler };
|
|
28
20
|
//# sourceMappingURL=createBatchScheduler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBatchScheduler.d.ts","names":[],"sources":["../../../src/utils/createBatchScheduler.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"createBatchScheduler.d.ts","names":[],"sources":["../../../src/utils/createBatchScheduler.ts"],"mappings":";;KAGK,SAAS,gDACZ,QAAQ,oBACR,SAAS;KASN,sBAAsB,qBAAqB,GAAG,QAAQ,GAAG;KAEzD,8BACH,sBACA;EAEA,KAAK,MAAM,iBAAiB,QAAQ;EACpC;EACA,qBAAqB,MAAM;EAC3B;EACA,OAAO,sBAAsB;;KAG1B,+BACH,sBACA;EAEA;EACA,UAAU,gCACL,OAAO,2BAA2B,QAAQ,SAAS,gBACnD,MAAM,eAAe,QAAQ,SAAS;;YAGjC,gCAAgC;;wBAK5B,qBACd,YACA,yCAEA,IACA,IACA,kBACA,MACA,QACC,8BACD,YACA,cACE,+BAA+B,YAAY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBatchScheduler.js","names":[],"sources":["../../../src/utils/createBatchScheduler.ts"],"sourcesContent":["import type { ErrorType } from '../errors/utils.js'\nimport { withResolvers } from './withResolvers.js'\n\ntype Resolved<returnType extends readonly unknown[] = any> = [\n result: returnType[number],\n results: returnType,\n]\n\ntype SchedulerItem = {\n args: unknown\n resolve: PromiseWithResolvers<unknown>['resolve']\n reject: PromiseWithResolvers<unknown>['reject']\n}\n\ntype BatchResultsCompareFn<result = unknown> = (a: result, b: result) => number\n\ntype CreateBatchSchedulerArguments<\n parameters = unknown,\n returnType extends readonly unknown[] = readonly unknown[],\n> = {\n fn: (args: parameters[]) => Promise<returnType>\n id: number | string\n shouldSplitBatch?: ((args: parameters[]) => boolean) | undefined\n wait?: number | undefined\n sort?: BatchResultsCompareFn<returnType[number]> | undefined\n}\n\ntype CreateBatchSchedulerReturnType<\n parameters = unknown,\n returnType extends readonly unknown[] = readonly unknown[],\n> = {\n flush: () => void\n schedule: parameters extends undefined\n ? (args?: parameters | undefined) => Promise<Resolved<returnType>>\n : (args: parameters) => Promise<Resolved<returnType>>\n}\n\nexport type CreateBatchSchedulerErrorType = ErrorType\n\nconst schedulerCache = /*#__PURE__*/ new Map<number | string, SchedulerItem[]>()\n\n/** @internal */\nexport function createBatchScheduler<\n parameters,\n returnType extends readonly unknown[],\n>({\n fn,\n id,\n shouldSplitBatch,\n wait = 0,\n sort,\n}: CreateBatchSchedulerArguments<\n parameters,\n returnType\n>): CreateBatchSchedulerReturnType<parameters, returnType> {\n const exec = async () => {\n const scheduler = getScheduler()\n flush()\n\n const args = scheduler.map(({ args }) => args)\n\n if (args.length === 0) {\n return\n }\n\n fn(args as parameters[])\n .then((data) => {\n if (sort && Array.isArray(data)) {\n data.sort(sort)\n }\n for (let i = 0; i < scheduler.length; i++) {\n const { resolve } = scheduler[i]\n resolve?.([data[i], data])\n }\n })\n .catch((err) => {\n for (let i = 0; i < scheduler.length; i++) {\n const { reject } = scheduler[i]\n reject?.(err)\n }\n })\n }\n\n const flush = () => schedulerCache.delete(id)\n\n const getBatchedArgs = () =>\n getScheduler().map(({ args }) => args) as parameters[]\n\n const getScheduler = () => schedulerCache.get(id) || []\n\n const setScheduler = (item: SchedulerItem) =>\n schedulerCache.set(id, [...getScheduler(), item])\n\n return {\n flush,\n async schedule(args: parameters) {\n const { promise, resolve, reject } = withResolvers()\n\n const split = shouldSplitBatch?.([...getBatchedArgs(), args])\n\n if (split) {\n exec()\n }\n\n const hasActiveScheduler = getScheduler().length > 0\n if (hasActiveScheduler) {\n setScheduler({ args, resolve, reject })\n return promise\n }\n\n setScheduler({ args, resolve, reject })\n setTimeout(exec, wait)\n return promise\n },\n } as unknown as CreateBatchSchedulerReturnType<parameters, returnType>\n}\n"],"mappings":";;AAuCA,MAAM,+BAA+B,IAAI,IAAsC;;AAG/E,SAAgB,qBAGd,EACA,IACA,IACA,kBACA,OAAO,GACP,QAIyD;CACzD,MAAM,OAAO,YAAY;EACvB,MAAM,YAAY,aAAa;EAC/B,MAAM;EAEN,MAAM,OAAO,UAAU,KAAK,EAAE,WAAW,IAAI;EAE7C,IAAI,KAAK,WAAW,GAClB;EAGF,GAAG,IAAoB,
|
|
1
|
+
{"version":3,"file":"createBatchScheduler.js","names":[],"sources":["../../../src/utils/createBatchScheduler.ts"],"sourcesContent":["import type { ErrorType } from '../errors/utils.js'\nimport { withResolvers } from './withResolvers.js'\n\ntype Resolved<returnType extends readonly unknown[] = any> = [\n result: returnType[number],\n results: returnType,\n]\n\ntype SchedulerItem = {\n args: unknown\n resolve: PromiseWithResolvers<unknown>['resolve']\n reject: PromiseWithResolvers<unknown>['reject']\n}\n\ntype BatchResultsCompareFn<result = unknown> = (a: result, b: result) => number\n\ntype CreateBatchSchedulerArguments<\n parameters = unknown,\n returnType extends readonly unknown[] = readonly unknown[],\n> = {\n fn: (args: parameters[]) => Promise<returnType>\n id: number | string\n shouldSplitBatch?: ((args: parameters[]) => boolean) | undefined\n wait?: number | undefined\n sort?: BatchResultsCompareFn<returnType[number]> | undefined\n}\n\ntype CreateBatchSchedulerReturnType<\n parameters = unknown,\n returnType extends readonly unknown[] = readonly unknown[],\n> = {\n flush: () => void\n schedule: parameters extends undefined\n ? (args?: parameters | undefined) => Promise<Resolved<returnType>>\n : (args: parameters) => Promise<Resolved<returnType>>\n}\n\nexport type CreateBatchSchedulerErrorType = ErrorType\n\nconst schedulerCache = /*#__PURE__*/ new Map<number | string, SchedulerItem[]>()\n\n/** @internal */\nexport function createBatchScheduler<\n parameters,\n returnType extends readonly unknown[],\n>({\n fn,\n id,\n shouldSplitBatch,\n wait = 0,\n sort,\n}: CreateBatchSchedulerArguments<\n parameters,\n returnType\n>): CreateBatchSchedulerReturnType<parameters, returnType> {\n const exec = async () => {\n const scheduler = getScheduler()\n flush()\n\n const args = scheduler.map(({ args }) => args)\n\n if (args.length === 0) {\n return\n }\n\n fn(args as parameters[])\n .then((data) => {\n if (sort && Array.isArray(data)) {\n data.sort(sort)\n }\n for (let i = 0; i < scheduler.length; i++) {\n const { resolve } = scheduler[i]\n resolve?.([data[i], data])\n }\n })\n .catch((err) => {\n for (let i = 0; i < scheduler.length; i++) {\n const { reject } = scheduler[i]\n reject?.(err)\n }\n })\n }\n\n const flush = () => schedulerCache.delete(id)\n\n const getBatchedArgs = () =>\n getScheduler().map(({ args }) => args) as parameters[]\n\n const getScheduler = () => schedulerCache.get(id) || []\n\n const setScheduler = (item: SchedulerItem) =>\n schedulerCache.set(id, [...getScheduler(), item])\n\n return {\n flush,\n async schedule(args: parameters) {\n const { promise, resolve, reject } = withResolvers()\n\n const split = shouldSplitBatch?.([...getBatchedArgs(), args])\n\n if (split) {\n exec()\n }\n\n const hasActiveScheduler = getScheduler().length > 0\n if (hasActiveScheduler) {\n setScheduler({ args, resolve, reject })\n return promise\n }\n\n setScheduler({ args, resolve, reject })\n setTimeout(exec, wait)\n return promise\n },\n } as unknown as CreateBatchSchedulerReturnType<parameters, returnType>\n}\n"],"mappings":";;AAuCA,MAAM,+BAA+B,IAAI,IAAsC;;AAG/E,SAAgB,qBAGd,EACA,IACA,IACA,kBACA,OAAO,GACP,QAIyD;CACzD,MAAM,OAAO,YAAY;EACvB,MAAM,YAAY,aAAa;EAC/B,MAAM;EAEN,MAAM,OAAO,UAAU,KAAK,EAAE,WAAW,IAAI;EAE7C,IAAI,KAAK,WAAW,GAClB;EAGF,GAAG,IAAoB,CAAC,CACrB,MAAM,SAAS;GACd,IAAI,QAAQ,MAAM,QAAQ,IAAI,GAC5B,KAAK,KAAK,IAAI;GAEhB,KAAK,IAAI,IAAI,GAAG,IAAI,UAAU,QAAQ,KAAK;IACzC,MAAM,EAAE,YAAY,UAAU;IAC9B,UAAU,CAAC,KAAK,IAAI,IAAI,CAAC;GAC3B;EACF,CAAC,CAAC,CACD,OAAO,QAAQ;GACd,KAAK,IAAI,IAAI,GAAG,IAAI,UAAU,QAAQ,KAAK;IACzC,MAAM,EAAE,WAAW,UAAU;IAC7B,SAAS,GAAG;GACd;EACF,CAAC;CACL;CAEA,MAAM,cAAc,eAAe,OAAO,EAAE;CAE5C,MAAM,uBACJ,aAAa,CAAC,CAAC,KAAK,EAAE,WAAW,IAAI;CAEvC,MAAM,qBAAqB,eAAe,IAAI,EAAE,KAAK,CAAC;CAEtD,MAAM,gBAAgB,SACpB,eAAe,IAAI,IAAI,CAAC,GAAG,aAAa,GAAG,IAAI,CAAC;CAElD,OAAO;EACL;EACA,MAAM,SAAS,MAAkB;GAC/B,MAAM,EAAE,SAAS,SAAS,WAAW,cAAc;GAInD,IAFc,mBAAmB,CAAC,GAAG,eAAe,GAAG,IAAI,CAAC,GAG1D,KAAK;GAIP,IAD2B,aAAa,CAAC,CAAC,SAAS,GAC3B;IACtB,aAAa;KAAE;KAAM;KAAS;IAAO,CAAC;IACtC,OAAO;GACT;GAEA,aAAa;IAAE;IAAM;IAAS;GAAO,CAAC;GACtC,WAAW,MAAM,IAAI;GACrB,OAAO;EACT;CACF;AACF"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
//#region src/utils/deepEqual.d.ts
|
|
2
2
|
/** Forked from https://github.com/epoberezkin/fast-deep-equal */
|
|
3
|
-
declare function deepEqual(a: any, b: any): boolean;
|
|
3
|
+
export declare function deepEqual(a: any, b: any): boolean;
|
|
4
4
|
//#endregion
|
|
5
|
-
export { deepEqual };
|
|
6
5
|
//# sourceMappingURL=deepEqual.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deepEqual.d.ts","names":[],"sources":["../../../src/utils/deepEqual.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"deepEqual.d.ts","names":[],"sources":["../../../src/utils/deepEqual.ts"],"mappings":";;wBAEgB,UAAU,QAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deepEqual.js","names":[],"sources":["../../../src/utils/deepEqual.ts"],"sourcesContent":["/** Forked from https://github.com/epoberezkin/fast-deep-equal */\n\nexport function deepEqual(a: any, b: any): boolean {\n if (a === b) {\n return true\n }\n\n if (a && b && typeof a === 'object' && typeof b === 'object') {\n if (a.constructor !== b.constructor) {\n return false\n }\n\n let length: number\n let i: number\n\n if (Array.isArray(a) && Array.isArray(b)) {\n length = a.length\n if (length !== b.length) {\n return false\n }\n for (i = length; i-- !== 0; ) {\n if (!deepEqual(a[i], b[i])) {\n return false\n }\n }\n return true\n }\n\n if (a.valueOf !== Object.prototype.valueOf) {\n return a.valueOf() === b.valueOf()\n }\n if (a.toString !== Object.prototype.toString) {\n return a.toString() === b.toString()\n }\n\n const keys = Object.keys(a)\n length = keys.length\n if (length !== Object.keys(b).length) {\n return false\n }\n\n for (i = length; i-- !== 0; ) {\n if (!Object.hasOwn(b, keys[i]!)) {\n return false\n }\n }\n\n for (i = length; i-- !== 0; ) {\n const key = keys[i]\n\n if (key && !deepEqual(a[key], b[key])) {\n return false\n }\n }\n\n return true\n }\n\n // true if both NaN, false otherwise\n // biome-ignore lint/suspicious/noSelfCompare: allowed in utils\n return a !== a && b !== b\n}\n"],"mappings":";;AAEA,SAAgB,UAAU,GAAQ,GAAiB;CACjD,IAAI,MAAM,GACR,OAAO;CAGT,IAAI,KAAK,KAAK,OAAO,MAAM,YAAY,OAAO,MAAM,UAAU;EAC5D,IAAI,EAAE,gBAAgB,EAAE,aACtB,OAAO;EAGT,IAAI;EACJ,IAAI;EAEJ,IAAI,MAAM,QAAQ,CAAC,KAAK,MAAM,QAAQ,CAAC,GAAG;GACxC,SAAS,EAAE;GACX,IAAI,WAAW,EAAE,QACf,OAAO;GAET,KAAK,IAAI,QAAQ,QAAQ,IACvB,IAAI,CAAC,UAAU,EAAE,IAAI,EAAE,EAAE,GACvB,OAAO;GAGX,OAAO;EACT;EAEA,IAAI,EAAE,YAAY,OAAO,UAAU,SACjC,OAAO,EAAE,QAAQ,MAAM,EAAE,QAAQ;EAEnC,IAAI,EAAE,aAAa,OAAO,UAAU,UAClC,OAAO,EAAE,SAAS,MAAM,EAAE,SAAS;EAGrC,MAAM,OAAO,OAAO,KAAK,CAAC;EAC1B,SAAS,KAAK;EACd,IAAI,WAAW,OAAO,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"deepEqual.js","names":[],"sources":["../../../src/utils/deepEqual.ts"],"sourcesContent":["/** Forked from https://github.com/epoberezkin/fast-deep-equal */\n\nexport function deepEqual(a: any, b: any): boolean {\n if (a === b) {\n return true\n }\n\n if (a && b && typeof a === 'object' && typeof b === 'object') {\n if (a.constructor !== b.constructor) {\n return false\n }\n\n let length: number\n let i: number\n\n if (Array.isArray(a) && Array.isArray(b)) {\n length = a.length\n if (length !== b.length) {\n return false\n }\n for (i = length; i-- !== 0; ) {\n if (!deepEqual(a[i], b[i])) {\n return false\n }\n }\n return true\n }\n\n if (a.valueOf !== Object.prototype.valueOf) {\n return a.valueOf() === b.valueOf()\n }\n if (a.toString !== Object.prototype.toString) {\n return a.toString() === b.toString()\n }\n\n const keys = Object.keys(a)\n length = keys.length\n if (length !== Object.keys(b).length) {\n return false\n }\n\n for (i = length; i-- !== 0; ) {\n if (!Object.hasOwn(b, keys[i]!)) {\n return false\n }\n }\n\n for (i = length; i-- !== 0; ) {\n const key = keys[i]\n\n if (key && !deepEqual(a[key], b[key])) {\n return false\n }\n }\n\n return true\n }\n\n // true if both NaN, false otherwise\n // biome-ignore lint/suspicious/noSelfCompare: allowed in utils\n return a !== a && b !== b\n}\n"],"mappings":";;AAEA,SAAgB,UAAU,GAAQ,GAAiB;CACjD,IAAI,MAAM,GACR,OAAO;CAGT,IAAI,KAAK,KAAK,OAAO,MAAM,YAAY,OAAO,MAAM,UAAU;EAC5D,IAAI,EAAE,gBAAgB,EAAE,aACtB,OAAO;EAGT,IAAI;EACJ,IAAI;EAEJ,IAAI,MAAM,QAAQ,CAAC,KAAK,MAAM,QAAQ,CAAC,GAAG;GACxC,SAAS,EAAE;GACX,IAAI,WAAW,EAAE,QACf,OAAO;GAET,KAAK,IAAI,QAAQ,QAAQ,IACvB,IAAI,CAAC,UAAU,EAAE,IAAI,EAAE,EAAE,GACvB,OAAO;GAGX,OAAO;EACT;EAEA,IAAI,EAAE,YAAY,OAAO,UAAU,SACjC,OAAO,EAAE,QAAQ,MAAM,EAAE,QAAQ;EAEnC,IAAI,EAAE,aAAa,OAAO,UAAU,UAClC,OAAO,EAAE,SAAS,MAAM,EAAE,SAAS;EAGrC,MAAM,OAAO,OAAO,KAAK,CAAC;EAC1B,SAAS,KAAK;EACd,IAAI,WAAW,OAAO,KAAK,CAAC,CAAC,CAAC,QAC5B,OAAO;EAGT,KAAK,IAAI,QAAQ,QAAQ,IACvB,IAAI,CAAC,OAAO,OAAO,GAAG,KAAK,EAAG,GAC5B,OAAO;EAIX,KAAK,IAAI,QAAQ,QAAQ,IAAK;GAC5B,MAAM,MAAM,KAAK;GAEjB,IAAI,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,GAClC,OAAO;EAEX;EAEA,OAAO;CACT;CAIA,OAAO,MAAM,KAAK,MAAM;AAC1B"}
|
|
@@ -5,18 +5,16 @@ import { Transport } from "../types/transport.js";
|
|
|
5
5
|
import { Client } from "../types/client.js";
|
|
6
6
|
import { PublicActions } from "../clients/decorators/public.js";
|
|
7
7
|
import { WalletActions } from "../clients/decorators/wallet.js";
|
|
8
|
-
|
|
9
8
|
//#region src/utils/getAction.d.ts
|
|
10
9
|
/**
|
|
11
|
-
* Retrieves and returns an action from the client (if exists), and falls
|
|
12
|
-
* back to the tree-shakable action.
|
|
13
|
-
*
|
|
14
|
-
* Useful for extracting overridden actions from a client (ie. if a consumer
|
|
15
|
-
* wants to override the `sendTransaction` implementation).
|
|
16
|
-
*/
|
|
17
|
-
declare function getAction<transport extends Transport, chain extends Chain | undefined, account extends Account | undefined, rpcSchema extends UTXOSchema | undefined, extended extends {
|
|
10
|
+
* Retrieves and returns an action from the client (if exists), and falls
|
|
11
|
+
* back to the tree-shakable action.
|
|
12
|
+
*
|
|
13
|
+
* Useful for extracting overridden actions from a client (ie. if a consumer
|
|
14
|
+
* wants to override the `sendTransaction` implementation).
|
|
15
|
+
*/
|
|
16
|
+
export declare function getAction<transport extends Transport, chain extends Chain | undefined, account extends Account | undefined, rpcSchema extends UTXOSchema | undefined, extended extends {
|
|
18
17
|
[key: string]: unknown;
|
|
19
18
|
}, client extends Client<transport, chain, account, rpcSchema, extended>, parameters, returnType>(client: client, actionFn: (_: any, parameters: parameters) => returnType, name: keyof PublicActions | keyof WalletActions | (string & {})): (parameters: parameters) => returnType;
|
|
20
19
|
//#endregion
|
|
21
|
-
export { getAction };
|
|
22
20
|
//# sourceMappingURL=getAction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAction.d.ts","names":[],"sources":["../../../src/utils/getAction.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getAction.d.ts","names":[],"sources":["../../../src/utils/getAction.ts"],"mappings":";;;;;;;;;;;;;;;wBAegB,UACd,kBAAkB,WAClB,cAAc,mBACd,gBAAgB,qBAChB,kBAAkB,wBAClB;;GACA,eAAe,OAAO,WAAW,OAAO,SAAS,WAAW,WAC5D,YACA,YAEA,QAAQ,QACR,WAAW,QAAQ,YAAY,eAAe,YAI9C,YAAY,sBAAsB,iCAChC,YAAY,eAAe"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { ChainId } from "../types/chain.js";
|
|
2
2
|
import { Address, AddressInfo } from "../types/address.js";
|
|
3
|
-
|
|
4
3
|
//#region src/utils/getAddressInfo.d.ts
|
|
5
|
-
declare const getAddressInfo: (address: Address) => AddressInfo;
|
|
6
|
-
declare const getAddressChainId: (address: Address) => ChainId;
|
|
4
|
+
export declare const getAddressInfo: (address: Address) => AddressInfo;
|
|
5
|
+
export declare const getAddressChainId: (address: Address) => ChainId;
|
|
7
6
|
//#endregion
|
|
8
|
-
export { getAddressChainId, getAddressInfo };
|
|
9
7
|
//# sourceMappingURL=getAddressInfo.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAddressInfo.d.ts","names":[],"sources":["../../../src/utils/getAddressInfo.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getAddressInfo.d.ts","names":[],"sources":["../../../src/utils/getAddressInfo.ts"],"mappings":";;;qBAyFa,iBAAkB,SAAS,YAAU;qBAkErC,oBAAqB,SAAS,YAAU"}
|
|
@@ -65,7 +65,8 @@ const getAddressInfo = (address) => {
|
|
|
65
65
|
if (length !== 25) throw new Error("Invalid address");
|
|
66
66
|
const version = decoded[0];
|
|
67
67
|
const checksum = decoded.slice(length - 4, length);
|
|
68
|
-
const
|
|
68
|
+
const body = decoded.slice(0, length - 4);
|
|
69
|
+
const expectedChecksum = sha256(sha256(body)).slice(0, 4);
|
|
69
70
|
if (checksum.some((value, index) => value !== expectedChecksum[index])) throw new Error("Invalid address");
|
|
70
71
|
if (!Object.keys(addressTypes).map(Number).includes(version)) throw new Error("Invalid address");
|
|
71
72
|
const addressType = addressTypes[version];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAddressInfo.js","names":[],"sources":["../../../src/utils/getAddressInfo.ts"],"sourcesContent":["import { sha256 } from '@noble/hashes/sha256'\nimport { bech32, bech32m, type Decoded } from 'bech32'\nimport bs58 from 'bs58'\n\nimport {\n type Address,\n type AddressInfo,\n type AddressPurpose,\n AddressType,\n} from '../types/address.js'\nimport { ChainId, Network } from '../types/chain.js'\n\nconst addressTypes: {\n [key: number]: { type: AddressType; network: Network }\n} = {\n 0: {\n type: AddressType.p2pkh,\n network: Network.Mainnet,\n },\n 111: {\n type: AddressType.p2pkh,\n network: Network.Testnet,\n },\n 5: {\n type: AddressType.p2sh,\n network: Network.Mainnet,\n },\n 196: {\n type: AddressType.p2sh,\n network: Network.Testnet,\n },\n}\n\nconst parseBech32 = (address: Address): AddressInfo => {\n let decoded: Decoded\n\n try {\n if (\n address.startsWith('bc1p') ||\n address.startsWith('tb1p') ||\n address.startsWith('bcrt1p')\n ) {\n decoded = bech32m.decode(address)\n } else {\n decoded = bech32.decode(address)\n }\n } catch (_error) {\n throw new Error('Invalid address')\n }\n\n const mapPrefixToNetwork: { [key: string]: Network } = {\n bc: Network.Mainnet,\n tb: Network.Testnet,\n bcrt: Network.Regtest,\n }\n\n const network: Network = mapPrefixToNetwork[decoded.prefix]\n\n if (network === undefined) {\n throw new Error('Invalid address')\n }\n\n const witnessVersion = decoded.words[0]\n\n if (witnessVersion < 0 || witnessVersion > 16) {\n throw new Error('Invalid address')\n }\n const data = bech32.fromWords(decoded.words.slice(1))\n\n let type: AddressType\n if (data.length === 20) {\n type = AddressType.p2wpkh\n } else if (witnessVersion === 1) {\n type = AddressType.p2tr\n } else {\n type = AddressType.p2wsh\n }\n\n const purpose = getAddressPurpose(type)\n\n return {\n bech32: true,\n network,\n address,\n type,\n purpose,\n }\n}\n\nexport const getAddressInfo = (address: Address): AddressInfo => {\n let decoded: Uint8Array\n const prefix = address.substring(0, 2).toLowerCase()\n\n if (prefix === 'bc' || prefix === 'tb') {\n return parseBech32(address)\n }\n\n try {\n decoded = bs58.decode(address)\n } catch (_error) {\n throw new Error('Invalid address')\n }\n\n const { length } = decoded\n\n if (length !== 25) {\n throw new Error('Invalid address')\n }\n\n const version = decoded[0]\n\n const checksum = decoded.slice(length - 4, length)\n const body = decoded.slice(0, length - 4)\n\n const expectedChecksum = sha256(sha256(body)).slice(0, 4)\n\n if (\n checksum.some(\n (value: number, index: number) => value !== expectedChecksum[index]\n )\n ) {\n throw new Error('Invalid address')\n }\n\n const validVersions = Object.keys(addressTypes).map(Number)\n\n if (!validVersions.includes(version)) {\n throw new Error('Invalid address')\n }\n\n const addressType = addressTypes[version]\n\n return {\n ...addressType,\n address,\n bech32: false,\n purpose: getAddressPurpose(addressType.type),\n }\n}\n\nconst getAddressPurpose = (type: AddressType): AddressPurpose => {\n switch (type) {\n case AddressType.p2tr:\n return 'ordinals'\n case AddressType.p2wsh:\n return 'stacks'\n case AddressType.p2wpkh:\n case AddressType.p2sh:\n case AddressType.p2pkh:\n return 'payment'\n default:\n throw new Error('Invalid address type')\n }\n}\n\nexport const getAddressChainId = (address: Address): ChainId => {\n const addressInfo = getAddressInfo(address)\n\n switch (addressInfo.network) {\n case Network.Mainnet:\n return ChainId.BITCOIN_MAINNET\n case Network.Testnet:\n return ChainId.BITCOIN_TESTNET\n case Network.Regtest:\n return ChainId.BITCOIN_SIGNET\n default:\n return ChainId.BITCOIN_MAINNET\n }\n}\n"],"mappings":";;;;;;AAYA,MAAM,eAEF;CACF,GAAG;EACD,MAAA;EACA,SAAA;CACF;CACA,KAAK;EACH,MAAA;EACA,SAAA;CACF;CACA,GAAG;EACD,MAAA;EACA,SAAA;CACF;CACA,KAAK;EACH,MAAA;EACA,SAAA;CACF;AACF;AAEA,MAAM,eAAe,YAAkC;CACrD,IAAI;CAEJ,IAAI;EACF,IACE,QAAQ,WAAW,MAAM,KACzB,QAAQ,WAAW,MAAM,KACzB,QAAQ,WAAW,QAAQ,GAE3B,UAAU,QAAQ,OAAO,OAAO;OAEhC,UAAU,OAAO,OAAO,OAAO;CAEnC,SAAS,QAAQ;EACf,MAAM,IAAI,MAAM,iBAAiB;CACnC;CAQA,MAAM,UAAmB;EALvB,IAAA;EACA,IAAA;EACA,MAAA;CAGwC,EAAE,QAAQ;CAEpD,IAAI,YAAY,KAAA,GACd,MAAM,IAAI,MAAM,iBAAiB;CAGnC,MAAM,iBAAiB,QAAQ,MAAM;CAErC,IAAI,iBAAiB,KAAK,iBAAiB,IACzC,MAAM,IAAI,MAAM,iBAAiB;CAEnC,MAAM,OAAO,OAAO,UAAU,QAAQ,MAAM,MAAM,CAAC,CAAC;CAEpD,IAAI;CACJ,IAAI,KAAK,WAAW,IAClB,OAAA;MACK,IAAI,mBAAmB,GAC5B,OAAA;MAEA,OAAA;CAGF,MAAM,UAAU,kBAAkB,IAAI;CAEtC,OAAO;EACL,QAAQ;EACR;EACA;EACA;EACA;CACF;AACF;AAEA,MAAa,kBAAkB,YAAkC;CAC/D,IAAI;CACJ,MAAM,SAAS,QAAQ,UAAU,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"getAddressInfo.js","names":[],"sources":["../../../src/utils/getAddressInfo.ts"],"sourcesContent":["import { sha256 } from '@noble/hashes/sha256'\nimport { bech32, bech32m, type Decoded } from 'bech32'\nimport bs58 from 'bs58'\n\nimport {\n type Address,\n type AddressInfo,\n type AddressPurpose,\n AddressType,\n} from '../types/address.js'\nimport { ChainId, Network } from '../types/chain.js'\n\nconst addressTypes: {\n [key: number]: { type: AddressType; network: Network }\n} = {\n 0: {\n type: AddressType.p2pkh,\n network: Network.Mainnet,\n },\n 111: {\n type: AddressType.p2pkh,\n network: Network.Testnet,\n },\n 5: {\n type: AddressType.p2sh,\n network: Network.Mainnet,\n },\n 196: {\n type: AddressType.p2sh,\n network: Network.Testnet,\n },\n}\n\nconst parseBech32 = (address: Address): AddressInfo => {\n let decoded: Decoded\n\n try {\n if (\n address.startsWith('bc1p') ||\n address.startsWith('tb1p') ||\n address.startsWith('bcrt1p')\n ) {\n decoded = bech32m.decode(address)\n } else {\n decoded = bech32.decode(address)\n }\n } catch (_error) {\n throw new Error('Invalid address')\n }\n\n const mapPrefixToNetwork: { [key: string]: Network } = {\n bc: Network.Mainnet,\n tb: Network.Testnet,\n bcrt: Network.Regtest,\n }\n\n const network: Network = mapPrefixToNetwork[decoded.prefix]\n\n if (network === undefined) {\n throw new Error('Invalid address')\n }\n\n const witnessVersion = decoded.words[0]\n\n if (witnessVersion < 0 || witnessVersion > 16) {\n throw new Error('Invalid address')\n }\n const data = bech32.fromWords(decoded.words.slice(1))\n\n let type: AddressType\n if (data.length === 20) {\n type = AddressType.p2wpkh\n } else if (witnessVersion === 1) {\n type = AddressType.p2tr\n } else {\n type = AddressType.p2wsh\n }\n\n const purpose = getAddressPurpose(type)\n\n return {\n bech32: true,\n network,\n address,\n type,\n purpose,\n }\n}\n\nexport const getAddressInfo = (address: Address): AddressInfo => {\n let decoded: Uint8Array\n const prefix = address.substring(0, 2).toLowerCase()\n\n if (prefix === 'bc' || prefix === 'tb') {\n return parseBech32(address)\n }\n\n try {\n decoded = bs58.decode(address)\n } catch (_error) {\n throw new Error('Invalid address')\n }\n\n const { length } = decoded\n\n if (length !== 25) {\n throw new Error('Invalid address')\n }\n\n const version = decoded[0]\n\n const checksum = decoded.slice(length - 4, length)\n const body = decoded.slice(0, length - 4)\n\n const expectedChecksum = sha256(sha256(body)).slice(0, 4)\n\n if (\n checksum.some(\n (value: number, index: number) => value !== expectedChecksum[index]\n )\n ) {\n throw new Error('Invalid address')\n }\n\n const validVersions = Object.keys(addressTypes).map(Number)\n\n if (!validVersions.includes(version)) {\n throw new Error('Invalid address')\n }\n\n const addressType = addressTypes[version]\n\n return {\n ...addressType,\n address,\n bech32: false,\n purpose: getAddressPurpose(addressType.type),\n }\n}\n\nconst getAddressPurpose = (type: AddressType): AddressPurpose => {\n switch (type) {\n case AddressType.p2tr:\n return 'ordinals'\n case AddressType.p2wsh:\n return 'stacks'\n case AddressType.p2wpkh:\n case AddressType.p2sh:\n case AddressType.p2pkh:\n return 'payment'\n default:\n throw new Error('Invalid address type')\n }\n}\n\nexport const getAddressChainId = (address: Address): ChainId => {\n const addressInfo = getAddressInfo(address)\n\n switch (addressInfo.network) {\n case Network.Mainnet:\n return ChainId.BITCOIN_MAINNET\n case Network.Testnet:\n return ChainId.BITCOIN_TESTNET\n case Network.Regtest:\n return ChainId.BITCOIN_SIGNET\n default:\n return ChainId.BITCOIN_MAINNET\n }\n}\n"],"mappings":";;;;;;AAYA,MAAM,eAEF;CACF,GAAG;EACD,MAAA;EACA,SAAA;CACF;CACA,KAAK;EACH,MAAA;EACA,SAAA;CACF;CACA,GAAG;EACD,MAAA;EACA,SAAA;CACF;CACA,KAAK;EACH,MAAA;EACA,SAAA;CACF;AACF;AAEA,MAAM,eAAe,YAAkC;CACrD,IAAI;CAEJ,IAAI;EACF,IACE,QAAQ,WAAW,MAAM,KACzB,QAAQ,WAAW,MAAM,KACzB,QAAQ,WAAW,QAAQ,GAE3B,UAAU,QAAQ,OAAO,OAAO;OAEhC,UAAU,OAAO,OAAO,OAAO;CAEnC,SAAS,QAAQ;EACf,MAAM,IAAI,MAAM,iBAAiB;CACnC;CAQA,MAAM,UAAmB;EALvB,IAAA;EACA,IAAA;EACA,MAAA;CAGwC,EAAE,QAAQ;CAEpD,IAAI,YAAY,KAAA,GACd,MAAM,IAAI,MAAM,iBAAiB;CAGnC,MAAM,iBAAiB,QAAQ,MAAM;CAErC,IAAI,iBAAiB,KAAK,iBAAiB,IACzC,MAAM,IAAI,MAAM,iBAAiB;CAEnC,MAAM,OAAO,OAAO,UAAU,QAAQ,MAAM,MAAM,CAAC,CAAC;CAEpD,IAAI;CACJ,IAAI,KAAK,WAAW,IAClB,OAAA;MACK,IAAI,mBAAmB,GAC5B,OAAA;MAEA,OAAA;CAGF,MAAM,UAAU,kBAAkB,IAAI;CAEtC,OAAO;EACL,QAAQ;EACR;EACA;EACA;EACA;CACF;AACF;AAEA,MAAa,kBAAkB,YAAkC;CAC/D,IAAI;CACJ,MAAM,SAAS,QAAQ,UAAU,GAAG,CAAC,CAAC,CAAC,YAAY;CAEnD,IAAI,WAAW,QAAQ,WAAW,MAChC,OAAO,YAAY,OAAO;CAG5B,IAAI;EACF,UAAU,KAAK,OAAO,OAAO;CAC/B,SAAS,QAAQ;EACf,MAAM,IAAI,MAAM,iBAAiB;CACnC;CAEA,MAAM,EAAE,WAAW;CAEnB,IAAI,WAAW,IACb,MAAM,IAAI,MAAM,iBAAiB;CAGnC,MAAM,UAAU,QAAQ;CAExB,MAAM,WAAW,QAAQ,MAAM,SAAS,GAAG,MAAM;CACjD,MAAM,OAAO,QAAQ,MAAM,GAAG,SAAS,CAAC;CAExC,MAAM,mBAAmB,OAAO,OAAO,IAAI,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC;CAExD,IACE,SAAS,MACN,OAAe,UAAkB,UAAU,iBAAiB,MAC/D,GAEA,MAAM,IAAI,MAAM,iBAAiB;CAKnC,IAAI,CAFkB,OAAO,KAAK,YAAY,CAAC,CAAC,IAAI,MAEnC,CAAC,CAAC,SAAS,OAAO,GACjC,MAAM,IAAI,MAAM,iBAAiB;CAGnC,MAAM,cAAc,aAAa;CAEjC,OAAO;EACL,GAAG;EACH;EACA,QAAQ;EACR,SAAS,kBAAkB,YAAY,IAAI;CAC7C;AACF;AAEA,MAAM,qBAAqB,SAAsC;CAC/D,QAAQ,MAAR;EACE,KAAA,QACE,OAAO;EACT,KAAA,SACE,OAAO;EACT,KAAA;EACA,KAAA;EACA,KAAA,SACE,OAAO;EACT,SACE,MAAM,IAAI,MAAM,sBAAsB;CAC1C;AACF;AAEA,MAAa,qBAAqB,YAA8B;CAG9D,QAFoB,eAAe,OAEjB,CAAC,CAAC,SAApB;EACE,KAAA,WACE,OAAA;EACF,KAAA,WACE,OAAA;EACF,KAAA,WACE,OAAA;EACF,SACE,OAAA;CACJ;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idCache.d.ts","names":[],"sources":["../../../src/utils/idCache.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"idCache.d.ts","names":[],"sources":["../../../src/utils/idCache.ts"],"mappings":";qBAYa;EAAW;EAAiB;EAAgB"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { Network } from "../types/chain.js";
|
|
2
|
-
|
|
3
2
|
//#region src/utils/isAddress.d.ts
|
|
4
|
-
declare const isAddress: (address: string, network?: Network) => boolean;
|
|
3
|
+
export declare const isAddress: (address: string, network?: Network) => boolean;
|
|
5
4
|
//#endregion
|
|
6
|
-
export { isAddress };
|
|
7
5
|
//# sourceMappingURL=isAddress.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isAddress.d.ts","names":[],"sources":["../../../src/utils/isAddress.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"isAddress.d.ts","names":[],"sources":["../../../src/utils/isAddress.ts"],"mappings":";;qBAIa,YAAa,iBAAiB,UAAU"}
|
package/dist/esm/utils/lru.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
//#region src/utils/lru.d.ts
|
|
2
2
|
/**
|
|
3
|
-
* Map with a LRU (Least recently used) policy.
|
|
4
|
-
*
|
|
5
|
-
* @link https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU
|
|
6
|
-
*/
|
|
7
|
-
declare class LruMap<value = unknown> extends Map<string, value> {
|
|
3
|
+
* Map with a LRU (Least recently used) policy.
|
|
4
|
+
*
|
|
5
|
+
* @link https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU
|
|
6
|
+
*/
|
|
7
|
+
export declare class LruMap<value = unknown> extends Map<string, value> {
|
|
8
8
|
maxSize: number;
|
|
9
9
|
constructor(size: number);
|
|
10
10
|
override get(key: string): value | undefined;
|
|
11
11
|
override set(key: string, value: value): this;
|
|
12
12
|
}
|
|
13
13
|
//#endregion
|
|
14
|
-
export { LruMap };
|
|
15
14
|
//# sourceMappingURL=lru.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lru.d.ts","names":[],"sources":["../../../src/utils/lru.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"lru.d.ts","names":[],"sources":["../../../src/utils/lru.ts"],"mappings":";;;;;;qBAKa,OAAO,yBAAyB,YAAY;EACvD;EAEA,YAAY;WAKH,IAAI,cAAc;WAWlB,IAAI,aAAa,OAAO"}
|