@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,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
|
package/dist/cjs/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,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
|
|
@@ -16,6 +16,7 @@ function buildRequest(request, options = {}) {
|
|
|
16
16
|
const { method } = args;
|
|
17
17
|
if (methods?.exclude?.includes(method)) throw new require_errors_rpc.MethodNotSupportedRpcError(method);
|
|
18
18
|
if (methods?.include && !methods.include.includes(method)) throw new require_errors_rpc.MethodNotSupportedRpcError(method);
|
|
19
|
+
const requestId = dedupe ? require_utils_converter.stringToHex(`${uid}.${require_utils_stringify.stringify(args)}`) : void 0;
|
|
19
20
|
return require_utils_withDedupe.withDedupe(() => require_utils_withRetry.withRetry(async () => {
|
|
20
21
|
try {
|
|
21
22
|
return await request(args);
|
|
@@ -42,7 +43,7 @@ function buildRequest(request, options = {}) {
|
|
|
42
43
|
shouldRetry: ({ error }) => shouldRetry(error)
|
|
43
44
|
}), {
|
|
44
45
|
enabled: dedupe,
|
|
45
|
-
id:
|
|
46
|
+
id: requestId
|
|
46
47
|
});
|
|
47
48
|
};
|
|
48
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildRequest.js","names":["MethodNotSupportedRpcError","
|
|
1
|
+
{"version":3,"file":"buildRequest.js","names":["MethodNotSupportedRpcError","stringToHex","stringify","withDedupe","withRetry","UserRejectedRequestError","BaseError","HttpRequestError"],"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,IAAIA,mBAAAA,2BAA2B,MAAM;EAE7C,IAAI,SAAS,WAAW,CAAC,QAAQ,QAAQ,SAAS,MAAM,GACtD,MAAM,IAAIA,mBAAAA,2BAA2B,MAAM;EAG7C,MAAM,YAAY,SACdC,wBAAAA,YAAY,GAAG,IAAI,GAAGC,wBAAAA,UAAU,IAAI,GAAG,IACvC,KAAA;EACJ,OAAOC,yBAAAA,iBAEHC,wBAAAA,UACE,YAAY;GACV,IAAI;IACF,OAAO,MAAM,QAAQ,IAAI;GAC3B,SAAS,MAAM;IACb,MAAM,MAAM;IACZ,QAAQ,IAAI,MAAZ;KACE,KAAA,QACE,MAAM,IAAIJ,mBAAAA,2BAA2B,MAAM;KAE7C,KAAA,OACE,MAAM,IAAIK,mBAAAA,yBAAyB,IAAI,OAAO;KAIhD,KAAK,KACH,MAAM,IAAIA,mBAAAA,yBAAyB,IAAI,OAAO;KAEhD;MACE,IAAI,gBAAgBC,oBAAAA,WAClB,MAAM;MAER,MAAM,IAAIA,oBAAAA,UAAU,iBAAiB,EAAE,OAAO,KAAc,CAAC;IACjE;GACF;EACF,GACA;GACE,QAAQ,EAAE,OAAO,YAAY;IAE3B,IAAI,SAAS,iBAAiBC,uBAAAA,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,iBAAiBA,uBAAAA,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,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.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.js","names":["withResolvers"],"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":["withResolvers"],"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,WAAWA,4BAAAA,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.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,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
|
|
@@ -68,7 +68,8 @@ const getAddressInfo = (address) => {
|
|
|
68
68
|
if (length !== 25) throw new Error("Invalid address");
|
|
69
69
|
const version = decoded[0];
|
|
70
70
|
const checksum = decoded.slice(length - 4, length);
|
|
71
|
-
const
|
|
71
|
+
const body = decoded.slice(0, length - 4);
|
|
72
|
+
const expectedChecksum = (0, _noble_hashes_sha256.sha256)((0, _noble_hashes_sha256.sha256)(body)).slice(0, 4);
|
|
72
73
|
if (checksum.some((value, index) => value !== expectedChecksum[index])) throw new Error("Invalid address");
|
|
73
74
|
if (!Object.keys(addressTypes).map(Number).includes(version)) throw new Error("Invalid address");
|
|
74
75
|
const addressType = addressTypes[version];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAddressInfo.js","names":["bech32m"],"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,UAAUA,OAAAA,QAAQ,OAAO,OAAO;OAEhC,UAAU,OAAA,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,OAAA,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":["bech32m","sha256"],"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,UAAUA,OAAAA,QAAQ,OAAO,OAAO;OAEhC,UAAU,OAAA,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,OAAA,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,KAAA,QAAK,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,oBAAA,GAAmBC,qBAAAA,OAAAA,EAAAA,GAAOA,qBAAAA,OAAAA,CAAO,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,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
|
package/dist/cjs/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.js","names":[],"sources":["../../../src/utils/lru.ts"],"sourcesContent":["/**\n * Map with a LRU (Least recently used) policy.\n *\n * @link https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU\n */\nexport class LruMap<value = unknown> extends Map<string, value> {\n maxSize: number\n\n constructor(size: number) {\n super()\n this.maxSize = size\n }\n\n override get(key: string): value | undefined {\n const value = super.get(key)\n\n if (super.has(key) && value !== undefined) {\n this.delete(key)\n super.set(key, value)\n }\n\n return value\n }\n\n override set(key: string, value: value): this {\n super.set(key, value)\n if (this.maxSize && this.size > this.maxSize) {\n const firstKey = this.keys().next().value\n if (firstKey) {\n this.delete(firstKey)\n }\n }\n return this\n }\n}\n"],"mappings":";;;;;;;AAKA,IAAa,SAAb,cAA6C,IAAmB;CAG9D,YAAY,MAAc;EACxB,MAAM;EACN,KAAK,UAAU;CACjB;CAEA,IAAa,KAAgC;EAC3C,MAAM,QAAQ,MAAM,IAAI,GAAG;EAE3B,IAAI,MAAM,IAAI,GAAG,KAAK,UAAU,KAAA,GAAW;GACzC,KAAK,OAAO,GAAG;GACf,MAAM,IAAI,KAAK,KAAK;EACtB;EAEA,OAAO;CACT;CAEA,IAAa,KAAa,OAAoB;EAC5C,MAAM,IAAI,KAAK,KAAK;EACpB,IAAI,KAAK,WAAW,KAAK,OAAO,KAAK,SAAS;GAC5C,MAAM,WAAW,KAAK,KAAK,
|
|
1
|
+
{"version":3,"file":"lru.js","names":[],"sources":["../../../src/utils/lru.ts"],"sourcesContent":["/**\n * Map with a LRU (Least recently used) policy.\n *\n * @link https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU\n */\nexport class LruMap<value = unknown> extends Map<string, value> {\n maxSize: number\n\n constructor(size: number) {\n super()\n this.maxSize = size\n }\n\n override get(key: string): value | undefined {\n const value = super.get(key)\n\n if (super.has(key) && value !== undefined) {\n this.delete(key)\n super.set(key, value)\n }\n\n return value\n }\n\n override set(key: string, value: value): this {\n super.set(key, value)\n if (this.maxSize && this.size > this.maxSize) {\n const firstKey = this.keys().next().value\n if (firstKey) {\n this.delete(firstKey)\n }\n }\n return this\n }\n}\n"],"mappings":";;;;;;;AAKA,IAAa,SAAb,cAA6C,IAAmB;CAG9D,YAAY,MAAc;EACxB,MAAM;EACN,KAAK,UAAU;CACjB;CAEA,IAAa,KAAgC;EAC3C,MAAM,QAAQ,MAAM,IAAI,GAAG;EAE3B,IAAI,MAAM,IAAI,GAAG,KAAK,UAAU,KAAA,GAAW;GACzC,KAAK,OAAO,GAAG;GACf,MAAM,IAAI,KAAK,KAAK;EACtB;EAEA,OAAO;CACT;CAEA,IAAa,KAAa,OAAoB;EAC5C,MAAM,IAAI,KAAK,KAAK;EACpB,IAAI,KAAK,WAAW,KAAK,OAAO,KAAK,SAAS;GAC5C,MAAM,WAAW,KAAK,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC;GACpC,IAAI,UACF,KAAK,OAAO,QAAQ;EAExB;EACA,OAAO;CACT;AACF"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { Psbt } from "bitcoinjs-lib";
|
|
2
|
-
|
|
3
2
|
//#region src/utils/modifyFee.d.ts
|
|
4
|
-
declare function modifyFee(psbt: Psbt, newFee: bigint, accountAddress: string): Psbt;
|
|
3
|
+
export declare function modifyFee(psbt: Psbt, newFee: bigint, accountAddress: string): Psbt;
|
|
5
4
|
//#endregion
|
|
6
|
-
export { modifyFee };
|
|
7
5
|
//# sourceMappingURL=modifyFee.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modifyFee.js","names":["Psbt","address"],"sources":["../../../src/utils/modifyFee.ts"],"sourcesContent":["import { address, Psbt } from 'bitcoinjs-lib'\n\ninterface InputData {\n hash: Uint8Array\n index: number\n nonWitnessUtxo?: Uint8Array\n witnessUtxo?: {\n script: Uint8Array\n value: bigint\n }\n redeemScript?: Uint8Array\n witnessScript?: Uint8Array\n}\n\nexport function modifyFee(\n psbt: Psbt,\n newFee: bigint,\n accountAddress: string\n): Psbt {\n const newPsbt = new Psbt()\n const inputs = psbt.data.inputs\n const outputs = psbt.txOutputs\n\n // Add inputs to the new PSBT\n for (let i = 0; i < inputs.length; i++) {\n const input = inputs[i]\n const inputData: InputData = {\n hash: psbt.txInputs[i].hash,\n index: psbt.txInputs[i].index,\n }\n\n // Include UTXO information\n if (input.nonWitnessUtxo) {\n inputData.nonWitnessUtxo = input.nonWitnessUtxo\n } else if (input.witnessUtxo) {\n inputData.witnessUtxo = input.witnessUtxo\n }\n\n // Include scripts if necessary\n if (input.redeemScript) {\n inputData.redeemScript = input.redeemScript\n }\n if (input.witnessScript) {\n inputData.witnessScript = input.witnessScript\n }\n\n newPsbt.addInput(inputData)\n }\n\n const changeOutputScript = address.toOutputScript(accountAddress)\n\n // Add outputs to the new PSBT\n for (const output of outputs) {\n const outputData = {\n script: output.script,\n value: output.value,\n }\n\n const scriptsAreEqual =\n output.script.length === changeOutputScript.length &&\n output.script.every((value, index) => value === changeOutputScript[index])\n\n if (scriptsAreEqual) {\n outputData.value = output.value - newFee\n if (outputData.value < 0) {\n throw new Error(\n 'Insufficient funds to adjust the fee by the specified amount.'\n )\n }\n }\n\n newPsbt.addOutput(outputData)\n }\n\n // Modify the input sequence number to enable RBF\n newPsbt.txInputs.forEach((_, index) => {\n // Set sequence number to less than 0xfffffffe, e.g., 0xfffffffd\n newPsbt.setInputSequence(index, 0xfffffffd)\n })\n\n return newPsbt\n}\n"],"mappings":";;;AAcA,SAAgB,UACd,MACA,QACA,gBACM;CACN,MAAM,UAAU,IAAIA,cAAAA,KAAK;CACzB,MAAM,SAAS,KAAK,KAAK;CACzB,MAAM,UAAU,KAAK;CAGrB,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;EACtC,MAAM,QAAQ,OAAO;EACrB,MAAM,YAAuB;GAC3B,MAAM,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"modifyFee.js","names":["Psbt","address"],"sources":["../../../src/utils/modifyFee.ts"],"sourcesContent":["import { address, Psbt } from 'bitcoinjs-lib'\n\ninterface InputData {\n hash: Uint8Array\n index: number\n nonWitnessUtxo?: Uint8Array\n witnessUtxo?: {\n script: Uint8Array\n value: bigint\n }\n redeemScript?: Uint8Array\n witnessScript?: Uint8Array\n}\n\nexport function modifyFee(\n psbt: Psbt,\n newFee: bigint,\n accountAddress: string\n): Psbt {\n const newPsbt = new Psbt()\n const inputs = psbt.data.inputs\n const outputs = psbt.txOutputs\n\n // Add inputs to the new PSBT\n for (let i = 0; i < inputs.length; i++) {\n const input = inputs[i]\n const inputData: InputData = {\n hash: psbt.txInputs[i].hash,\n index: psbt.txInputs[i].index,\n }\n\n // Include UTXO information\n if (input.nonWitnessUtxo) {\n inputData.nonWitnessUtxo = input.nonWitnessUtxo\n } else if (input.witnessUtxo) {\n inputData.witnessUtxo = input.witnessUtxo\n }\n\n // Include scripts if necessary\n if (input.redeemScript) {\n inputData.redeemScript = input.redeemScript\n }\n if (input.witnessScript) {\n inputData.witnessScript = input.witnessScript\n }\n\n newPsbt.addInput(inputData)\n }\n\n const changeOutputScript = address.toOutputScript(accountAddress)\n\n // Add outputs to the new PSBT\n for (const output of outputs) {\n const outputData = {\n script: output.script,\n value: output.value,\n }\n\n const scriptsAreEqual =\n output.script.length === changeOutputScript.length &&\n output.script.every((value, index) => value === changeOutputScript[index])\n\n if (scriptsAreEqual) {\n outputData.value = output.value - newFee\n if (outputData.value < 0) {\n throw new Error(\n 'Insufficient funds to adjust the fee by the specified amount.'\n )\n }\n }\n\n newPsbt.addOutput(outputData)\n }\n\n // Modify the input sequence number to enable RBF\n newPsbt.txInputs.forEach((_, index) => {\n // Set sequence number to less than 0xfffffffe, e.g., 0xfffffffd\n newPsbt.setInputSequence(index, 0xfffffffd)\n })\n\n return newPsbt\n}\n"],"mappings":";;;AAcA,SAAgB,UACd,MACA,QACA,gBACM;CACN,MAAM,UAAU,IAAIA,cAAAA,KAAK;CACzB,MAAM,SAAS,KAAK,KAAK;CACzB,MAAM,UAAU,KAAK;CAGrB,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;EACtC,MAAM,QAAQ,OAAO;EACrB,MAAM,YAAuB;GAC3B,MAAM,KAAK,SAAS,EAAE,CAAC;GACvB,OAAO,KAAK,SAAS,EAAE,CAAC;EAC1B;EAGA,IAAI,MAAM,gBACR,UAAU,iBAAiB,MAAM;OAC5B,IAAI,MAAM,aACf,UAAU,cAAc,MAAM;EAIhC,IAAI,MAAM,cACR,UAAU,eAAe,MAAM;EAEjC,IAAI,MAAM,eACR,UAAU,gBAAgB,MAAM;EAGlC,QAAQ,SAAS,SAAS;CAC5B;CAEA,MAAM,qBAAqBC,cAAAA,QAAQ,eAAe,cAAc;CAGhE,KAAK,MAAM,UAAU,SAAS;EAC5B,MAAM,aAAa;GACjB,QAAQ,OAAO;GACf,OAAO,OAAO;EAChB;EAMA,IAHE,OAAO,OAAO,WAAW,mBAAmB,UAC5C,OAAO,OAAO,OAAO,OAAO,UAAU,UAAU,mBAAmB,MAAM,GAEtD;GACnB,WAAW,QAAQ,OAAO,QAAQ;GAClC,IAAI,WAAW,QAAQ,GACrB,MAAM,IAAI,MACR,+DACF;EAEJ;EAEA,QAAQ,UAAU,UAAU;CAC9B;CAGA,QAAQ,SAAS,SAAS,GAAG,UAAU;EAErC,QAAQ,iBAAiB,OAAO,UAAU;CAC5C,CAAC;CAED,OAAO;AACT"}
|
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import { MaybePromise } from "../types/utils.js";
|
|
2
|
-
|
|
3
2
|
//#region src/utils/observe.d.ts
|
|
4
3
|
type Callback = ((...args: any[]) => any) | undefined;
|
|
5
4
|
type Callbacks = Record<string, Callback>;
|
|
6
5
|
/** @internal */
|
|
7
|
-
declare const listenersCache: Map<string, {
|
|
6
|
+
export declare const listenersCache: Map<string, {
|
|
8
7
|
id: number;
|
|
9
8
|
fns: Callbacks;
|
|
10
9
|
}[]>;
|
|
11
10
|
/** @internal */
|
|
12
|
-
declare const cleanupCache: Map<string, () => void>;
|
|
11
|
+
export declare const cleanupCache: Map<string, () => void>;
|
|
13
12
|
type EmitFunction<callbacks extends Callbacks> = (emit: callbacks) => MaybePromise<void | (() => void)>;
|
|
14
13
|
/**
|
|
15
|
-
* @description Sets up an observer for a given function. If another function
|
|
16
|
-
* is set up under the same observer id, the function will only be called once
|
|
17
|
-
* for both instances of the observer.
|
|
18
|
-
*/
|
|
19
|
-
declare function observe<callbacks extends Callbacks>(observerId: string, callbacks: callbacks, fn: EmitFunction<callbacks>): () => void;
|
|
14
|
+
* @description Sets up an observer for a given function. If another function
|
|
15
|
+
* is set up under the same observer id, the function will only be called once
|
|
16
|
+
* for both instances of the observer.
|
|
17
|
+
*/
|
|
18
|
+
export declare function observe<callbacks extends Callbacks>(observerId: string, callbacks: callbacks, fn: EmitFunction<callbacks>): () => void;
|
|
20
19
|
//#endregion
|
|
21
|
-
export { cleanupCache, listenersCache, observe };
|
|
22
20
|
//# sourceMappingURL=observe.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observe.js","names":[],"sources":["../../../src/utils/observe.ts"],"sourcesContent":["import type { MaybePromise } from '../types/utils.js'\n\ntype Callback = ((...args: any[]) => any) | undefined\ntype Callbacks = Record<string, Callback>\n\n/** @internal */\nexport const listenersCache: Map<string, { id: number; fns: Callbacks }[]> =\n /*#__PURE__*/ new Map()\n/** @internal */\nexport const cleanupCache: Map<string, () => void> = /*#__PURE__*/ new Map()\n\ntype EmitFunction<callbacks extends Callbacks> = (\n emit: callbacks\n) => MaybePromise<void | (() => void)>\n\nlet callbackCount = 0\n\n/**\n * @description Sets up an observer for a given function. If another function\n * is set up under the same observer id, the function will only be called once\n * for both instances of the observer.\n */\nexport function observe<callbacks extends Callbacks>(\n observerId: string,\n callbacks: callbacks,\n fn: EmitFunction<callbacks>\n): () => void {\n const callbackId = ++callbackCount\n\n const getListeners = () => listenersCache.get(observerId) || []\n\n const unsubscribe = () => {\n const listeners = getListeners()\n listenersCache.set(\n observerId,\n listeners.filter((cb: any) => cb.id !== callbackId)\n )\n }\n\n const unwatch = () => {\n const cleanup = cleanupCache.get(observerId)\n if (getListeners().length === 1 && cleanup) {\n cleanup()\n }\n unsubscribe()\n }\n\n const listeners = getListeners()\n listenersCache.set(observerId, [\n ...listeners,\n { id: callbackId, fns: callbacks },\n ])\n\n if (listeners && listeners.length > 0) {\n return unwatch\n }\n\n const emit: callbacks = {} as callbacks\n for (const key in callbacks) {\n emit[key] = ((\n ...args: Parameters<NonNullable<callbacks[keyof callbacks]>>\n ) => {\n const listeners = getListeners()\n if (listeners.length === 0) {\n return\n }\n for (const listener of listeners) {\n listener.fns[key]?.(...args)\n }\n }) as callbacks[Extract<keyof callbacks, string>]\n }\n\n const cleanup = fn(emit)\n if (typeof cleanup === 'function') {\n cleanupCache.set(observerId, cleanup)\n }\n\n return unwatch\n}\n"],"mappings":";;;AAMA,MAAa,+BACG,IAAI,IAAI;;AAExB,MAAa,6BAAsD,IAAI,IAAI;AAM3E,IAAI,gBAAgB;;;;;;AAOpB,SAAgB,QACd,YACA,WACA,IACY;CACZ,MAAM,aAAa,EAAE;CAErB,MAAM,qBAAqB,eAAe,IAAI,UAAU,KAAK,CAAC;CAE9D,MAAM,oBAAoB;EACxB,MAAM,YAAY,aAAa;EAC/B,eAAe,IACb,YACA,UAAU,QAAQ,OAAY,GAAG,OAAO,UAAU,CACpD;CACF;CAEA,MAAM,gBAAgB;EACpB,MAAM,UAAU,aAAa,IAAI,UAAU;EAC3C,IAAI,aAAa,
|
|
1
|
+
{"version":3,"file":"observe.js","names":[],"sources":["../../../src/utils/observe.ts"],"sourcesContent":["import type { MaybePromise } from '../types/utils.js'\n\ntype Callback = ((...args: any[]) => any) | undefined\ntype Callbacks = Record<string, Callback>\n\n/** @internal */\nexport const listenersCache: Map<string, { id: number; fns: Callbacks }[]> =\n /*#__PURE__*/ new Map()\n/** @internal */\nexport const cleanupCache: Map<string, () => void> = /*#__PURE__*/ new Map()\n\ntype EmitFunction<callbacks extends Callbacks> = (\n emit: callbacks\n) => MaybePromise<void | (() => void)>\n\nlet callbackCount = 0\n\n/**\n * @description Sets up an observer for a given function. If another function\n * is set up under the same observer id, the function will only be called once\n * for both instances of the observer.\n */\nexport function observe<callbacks extends Callbacks>(\n observerId: string,\n callbacks: callbacks,\n fn: EmitFunction<callbacks>\n): () => void {\n const callbackId = ++callbackCount\n\n const getListeners = () => listenersCache.get(observerId) || []\n\n const unsubscribe = () => {\n const listeners = getListeners()\n listenersCache.set(\n observerId,\n listeners.filter((cb: any) => cb.id !== callbackId)\n )\n }\n\n const unwatch = () => {\n const cleanup = cleanupCache.get(observerId)\n if (getListeners().length === 1 && cleanup) {\n cleanup()\n }\n unsubscribe()\n }\n\n const listeners = getListeners()\n listenersCache.set(observerId, [\n ...listeners,\n { id: callbackId, fns: callbacks },\n ])\n\n if (listeners && listeners.length > 0) {\n return unwatch\n }\n\n const emit: callbacks = {} as callbacks\n for (const key in callbacks) {\n emit[key] = ((\n ...args: Parameters<NonNullable<callbacks[keyof callbacks]>>\n ) => {\n const listeners = getListeners()\n if (listeners.length === 0) {\n return\n }\n for (const listener of listeners) {\n listener.fns[key]?.(...args)\n }\n }) as callbacks[Extract<keyof callbacks, string>]\n }\n\n const cleanup = fn(emit)\n if (typeof cleanup === 'function') {\n cleanupCache.set(observerId, cleanup)\n }\n\n return unwatch\n}\n"],"mappings":";;;AAMA,MAAa,+BACG,IAAI,IAAI;;AAExB,MAAa,6BAAsD,IAAI,IAAI;AAM3E,IAAI,gBAAgB;;;;;;AAOpB,SAAgB,QACd,YACA,WACA,IACY;CACZ,MAAM,aAAa,EAAE;CAErB,MAAM,qBAAqB,eAAe,IAAI,UAAU,KAAK,CAAC;CAE9D,MAAM,oBAAoB;EACxB,MAAM,YAAY,aAAa;EAC/B,eAAe,IACb,YACA,UAAU,QAAQ,OAAY,GAAG,OAAO,UAAU,CACpD;CACF;CAEA,MAAM,gBAAgB;EACpB,MAAM,UAAU,aAAa,IAAI,UAAU;EAC3C,IAAI,aAAa,CAAC,CAAC,WAAW,KAAK,SACjC,QAAQ;EAEV,YAAY;CACd;CAEA,MAAM,YAAY,aAAa;CAC/B,eAAe,IAAI,YAAY,CAC7B,GAAG,WACH;EAAE,IAAI;EAAY,KAAK;CAAU,CACnC,CAAC;CAED,IAAI,aAAa,UAAU,SAAS,GAClC,OAAO;CAGT,MAAM,OAAkB,CAAC;CACzB,KAAK,MAAM,OAAO,WAChB,KAAK,SACH,GAAG,SACA;EACH,MAAM,YAAY,aAAa;EAC/B,IAAI,UAAU,WAAW,GACvB;EAEF,KAAK,MAAM,YAAY,WACrB,SAAS,IAAI,IAAI,GAAG,GAAG,IAAI;CAE/B;CAGF,MAAM,UAAU,GAAG,IAAI;CACvB,IAAI,OAAO,YAAY,YACrB,aAAa,IAAI,YAAY,OAAO;CAGtC,OAAO;AACT"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { Address } from "../types/address.js";
|
|
2
2
|
import { Account } from "../types/account.js";
|
|
3
3
|
import { ErrorType } from "../errors/utils.js";
|
|
4
|
-
|
|
5
4
|
//#region src/utils/parseAccount.d.ts
|
|
6
|
-
type ParseAccountErrorType = ErrorType;
|
|
7
|
-
declare function parseAccount<accountOrAddress extends Address | Account>(account: accountOrAddress): accountOrAddress extends Address ? Account : accountOrAddress;
|
|
5
|
+
export type ParseAccountErrorType = ErrorType;
|
|
6
|
+
export declare function parseAccount<accountOrAddress extends Address | Account>(account: accountOrAddress): accountOrAddress extends Address ? Account : accountOrAddress;
|
|
8
7
|
//#endregion
|
|
9
|
-
export { ParseAccountErrorType, parseAccount };
|
|
10
8
|
//# sourceMappingURL=parseAccount.d.ts.map
|
package/dist/cjs/utils/poll.d.ts
CHANGED
|
@@ -5,17 +5,10 @@ type PollOptions<T> = {
|
|
|
5
5
|
interval: number;
|
|
6
6
|
};
|
|
7
7
|
/**
|
|
8
|
-
* @description Polls a function at a specified interval.
|
|
9
|
-
*/
|
|
10
|
-
declare function poll<T>(fn: ({
|
|
11
|
-
unpoll
|
|
12
|
-
}: {
|
|
8
|
+
* @description Polls a function at a specified interval.
|
|
9
|
+
*/
|
|
10
|
+
export declare function poll<T>(fn: ({ unpoll }: {
|
|
13
11
|
unpoll: () => void;
|
|
14
|
-
}) => Promise<T | undefined>, {
|
|
15
|
-
emitOnBegin,
|
|
16
|
-
initialWaitTime,
|
|
17
|
-
interval
|
|
18
|
-
}: PollOptions<T>): () => void;
|
|
12
|
+
}) => Promise<T | undefined>, { emitOnBegin, initialWaitTime, interval }: PollOptions<T>): () => void;
|
|
19
13
|
//#endregion
|
|
20
|
-
export { poll };
|
|
21
14
|
//# sourceMappingURL=poll.d.ts.map
|
package/dist/cjs/utils/poll.js
CHANGED
|
@@ -12,7 +12,8 @@ function poll(fn, { emitOnBegin, initialWaitTime, interval }) {
|
|
|
12
12
|
const watch = async () => {
|
|
13
13
|
let data;
|
|
14
14
|
if (emitOnBegin) data = await fn({ unpoll: unwatch });
|
|
15
|
-
|
|
15
|
+
const initialWait = await initialWaitTime?.(data) ?? interval;
|
|
16
|
+
await require_utils_sleep.sleep(initialWait);
|
|
16
17
|
const poll = async () => {
|
|
17
18
|
if (!active) return;
|
|
18
19
|
await fn({ unpoll: unwatch });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poll.js","names":["sleep"],"sources":["../../../src/utils/poll.ts"],"sourcesContent":["import { sleep } from './sleep.js'\n\ntype PollOptions<T> = {\n // Whether or not to emit when the polling starts.\n emitOnBegin?: boolean | undefined\n // The initial wait time (in ms) before polling.\n initialWaitTime?: ((data: T | undefined) => Promise<number>) | undefined\n // The interval (in ms).\n interval: number\n}\n\n/**\n * @description Polls a function at a specified interval.\n */\nexport function poll<T>(\n fn: ({ unpoll }: { unpoll: () => void }) => Promise<T | undefined>,\n { emitOnBegin, initialWaitTime, interval }: PollOptions<T>\n): () => void {\n let active = true\n\n const unwatch = () => {\n active = false\n }\n\n const watch = async () => {\n let data: T | undefined\n if (emitOnBegin) {\n data = await fn({ unpoll: unwatch })\n }\n\n const initialWait = (await initialWaitTime?.(data)) ?? interval\n await sleep(initialWait)\n\n const poll = async () => {\n if (!active) {\n return\n }\n await fn({ unpoll: unwatch })\n await sleep(interval)\n poll()\n }\n\n poll()\n }\n watch()\n\n return unwatch\n}\n"],"mappings":";;;;;;AAcA,SAAgB,KACd,IACA,EAAE,aAAa,iBAAiB,YACpB;CACZ,IAAI,SAAS;CAEb,MAAM,gBAAgB;EACpB,SAAS;CACX;CAEA,MAAM,QAAQ,YAAY;EACxB,IAAI;EACJ,IAAI,aACF,OAAO,MAAM,GAAG,EAAE,QAAQ,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"poll.js","names":["sleep"],"sources":["../../../src/utils/poll.ts"],"sourcesContent":["import { sleep } from './sleep.js'\n\ntype PollOptions<T> = {\n // Whether or not to emit when the polling starts.\n emitOnBegin?: boolean | undefined\n // The initial wait time (in ms) before polling.\n initialWaitTime?: ((data: T | undefined) => Promise<number>) | undefined\n // The interval (in ms).\n interval: number\n}\n\n/**\n * @description Polls a function at a specified interval.\n */\nexport function poll<T>(\n fn: ({ unpoll }: { unpoll: () => void }) => Promise<T | undefined>,\n { emitOnBegin, initialWaitTime, interval }: PollOptions<T>\n): () => void {\n let active = true\n\n const unwatch = () => {\n active = false\n }\n\n const watch = async () => {\n let data: T | undefined\n if (emitOnBegin) {\n data = await fn({ unpoll: unwatch })\n }\n\n const initialWait = (await initialWaitTime?.(data)) ?? interval\n await sleep(initialWait)\n\n const poll = async () => {\n if (!active) {\n return\n }\n await fn({ unpoll: unwatch })\n await sleep(interval)\n poll()\n }\n\n poll()\n }\n watch()\n\n return unwatch\n}\n"],"mappings":";;;;;;AAcA,SAAgB,KACd,IACA,EAAE,aAAa,iBAAiB,YACpB;CACZ,IAAI,SAAS;CAEb,MAAM,gBAAgB;EACpB,SAAS;CACX;CAEA,MAAM,QAAQ,YAAY;EACxB,IAAI;EACJ,IAAI,aACF,OAAO,MAAM,GAAG,EAAE,QAAQ,QAAQ,CAAC;EAGrC,MAAM,cAAe,MAAM,kBAAkB,IAAI,KAAM;EACvD,MAAMA,oBAAAA,MAAM,WAAW;EAEvB,MAAM,OAAO,YAAY;GACvB,IAAI,CAAC,QACH;GAEF,MAAM,GAAG,EAAE,QAAQ,QAAQ,CAAC;GAC5B,MAAMA,oBAAAA,MAAM,QAAQ;GACpB,KAAK;EACP;EAEA,KAAK;CACP;CACA,MAAM;CAEN,OAAO;AACT"}
|