@bigmi/core 0.8.0 → 0.8.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 +7 -0
- package/dist/cjs/actions/getBalance.js.map +1 -1
- package/dist/cjs/actions/getBlock.js +0 -1
- package/dist/cjs/actions/getBlock.js.map +1 -1
- package/dist/cjs/actions/getBlockCount.js.map +1 -1
- package/dist/cjs/actions/getBlockStats.js.map +1 -1
- package/dist/cjs/actions/getTransactionFee.js.map +1 -1
- package/dist/cjs/actions/getTransactions.js.map +1 -1
- package/dist/cjs/actions/getUTXOTransaction.js.map +1 -1
- package/dist/cjs/actions/getUTXOs.js.map +1 -1
- package/dist/cjs/actions/getXPubAddresses.js.map +1 -1
- package/dist/cjs/actions/sendUTXOTransaction.js.map +1 -1
- package/dist/cjs/actions/signPsbt.js.map +1 -1
- package/dist/cjs/actions/waitForTransaction.js +0 -1
- package/dist/cjs/actions/waitForTransaction.js.map +1 -1
- package/dist/cjs/actions/watchBlockNumber.js.map +1 -1
- package/dist/cjs/chains/bitcoin.js +3 -3
- package/dist/cjs/chains/bitcoin.js.map +1 -1
- package/dist/cjs/chains/defineChain.js.map +1 -1
- package/dist/cjs/chains/signet.js +3 -3
- package/dist/cjs/chains/signet.js.map +1 -1
- package/dist/cjs/clients/decorators/public.js.map +1 -1
- package/dist/cjs/clients/decorators/wallet.js.map +1 -1
- package/dist/cjs/errors/address.js.map +1 -1
- package/dist/cjs/errors/base.js.map +1 -1
- package/dist/cjs/errors/block.js.map +1 -1
- package/dist/cjs/errors/provider.js.map +1 -1
- package/dist/cjs/errors/request.js.map +1 -1
- package/dist/cjs/errors/rpc.js +3 -3
- package/dist/cjs/errors/rpc.js.map +1 -1
- package/dist/cjs/errors/transaction.js.map +1 -1
- package/dist/cjs/errors/transport.js.map +1 -1
- package/dist/cjs/errors/utxo.js.map +1 -1
- package/dist/cjs/factories/createClient.js.map +1 -1
- package/dist/cjs/factories/createTransport.js.map +1 -1
- package/dist/cjs/test/utils.js.map +1 -1
- package/dist/cjs/transports/ankr/ankr.js.map +1 -1
- package/dist/cjs/transports/ankr/getBalance.js +2 -2
- package/dist/cjs/transports/ankr/getBalance.js.map +1 -1
- package/dist/cjs/transports/ankr/getTransactionFee.js.map +1 -1
- package/dist/cjs/transports/ankr/getTransactions.js.map +1 -1
- package/dist/cjs/transports/ankr/methods.js.map +1 -1
- package/dist/cjs/transports/ankr/utils.js.map +1 -1
- package/dist/cjs/transports/blockchair/blockchair.js.map +1 -1
- package/dist/cjs/transports/blockchair/getBalance.js +2 -2
- package/dist/cjs/transports/blockchair/getBalance.js.map +1 -1
- package/dist/cjs/transports/blockchair/getTransactionFee.js +2 -2
- package/dist/cjs/transports/blockchair/getTransactionFee.js.map +1 -1
- package/dist/cjs/transports/blockchair/getUTXOs.js +2 -2
- package/dist/cjs/transports/blockchair/getUTXOs.js.map +1 -1
- package/dist/cjs/transports/blockchair/getXPubAddresses.js +2 -2
- package/dist/cjs/transports/blockchair/getXPubAddresses.js.map +1 -1
- package/dist/cjs/transports/blockchair/methods.js.map +1 -1
- package/dist/cjs/transports/blockcypher/blockcypher.js.map +1 -1
- package/dist/cjs/transports/blockcypher/getBalance.js.map +1 -1
- package/dist/cjs/transports/blockcypher/getTransactionFee.js.map +1 -1
- package/dist/cjs/transports/blockcypher/getUTXOs.js.map +1 -1
- package/dist/cjs/transports/blockcypher/methods.js.map +1 -1
- package/dist/cjs/transports/blockcypher/utils.js +3 -3
- package/dist/cjs/transports/blockcypher/utils.js.map +1 -1
- package/dist/cjs/transports/custom.js.map +1 -1
- package/dist/cjs/transports/fallback.js +2 -2
- package/dist/cjs/transports/fallback.js.map +1 -1
- package/dist/cjs/transports/getHttpRpcClient.js.map +1 -1
- package/dist/cjs/transports/getRpcProviderMethods.js.map +1 -1
- package/dist/cjs/transports/http.js.map +1 -1
- package/dist/cjs/transports/mempool/getBalance.js.map +1 -1
- package/dist/cjs/transports/mempool/getTransactionFee.js.map +1 -1
- package/dist/cjs/transports/mempool/getTransactions.js.map +1 -1
- package/dist/cjs/transports/mempool/mempool.js.map +1 -1
- package/dist/cjs/transports/mempool/methods.js.map +1 -1
- package/dist/cjs/transports/mempool/utils.js.map +1 -1
- package/dist/cjs/transports/types.js.map +1 -1
- package/dist/cjs/transports/utxo.js.map +1 -1
- package/dist/cjs/types/address.js.map +1 -1
- package/dist/cjs/types/chain.js.map +1 -1
- package/dist/cjs/utils/buildRequest.js +3 -3
- package/dist/cjs/utils/buildRequest.js.map +1 -1
- package/dist/cjs/utils/cancelTransaction.js +0 -1
- package/dist/cjs/utils/cancelTransaction.js.map +1 -1
- package/dist/cjs/utils/converter.js.map +1 -1
- package/dist/cjs/utils/createBatchScheduler.js +1 -1
- package/dist/cjs/utils/createBatchScheduler.js.map +1 -1
- package/dist/cjs/utils/deepEqual.js.map +1 -1
- package/dist/cjs/utils/getAction.js.map +1 -1
- package/dist/cjs/utils/getAddressInfo.js +26 -26
- package/dist/cjs/utils/getAddressInfo.js.map +1 -1
- package/dist/cjs/utils/idCache.js.map +1 -1
- package/dist/cjs/utils/isAddress.js.map +1 -1
- package/dist/cjs/utils/lru.js.map +1 -1
- package/dist/cjs/utils/modifyFee.js +0 -1
- package/dist/cjs/utils/modifyFee.js.map +1 -1
- package/dist/cjs/utils/observe.js +2 -2
- package/dist/cjs/utils/observe.js.map +1 -1
- package/dist/cjs/utils/parseAccount.js.map +1 -1
- package/dist/cjs/utils/poll.js.map +1 -1
- package/dist/cjs/utils/retryUntil.js.map +1 -1
- package/dist/cjs/utils/sleep.js.map +1 -1
- package/dist/cjs/utils/stringify.js.map +1 -1
- package/dist/cjs/utils/uid.js.map +1 -1
- package/dist/cjs/utils/url.js.map +1 -1
- package/dist/cjs/utils/wait.js.map +1 -1
- package/dist/cjs/utils/withDedupe.js +1 -1
- package/dist/cjs/utils/withDedupe.js.map +1 -1
- package/dist/cjs/utils/withResolvers.js.map +1 -1
- package/dist/cjs/utils/withRetry.js.map +1 -1
- package/dist/cjs/utils/withTimeout.js.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/actions/getBalance.d.ts.map +1 -1
- package/dist/esm/actions/getBalance.js.map +1 -1
- package/dist/esm/actions/getBlock.d.ts.map +1 -1
- package/dist/esm/actions/getBlock.js.map +1 -1
- package/dist/esm/actions/getBlockCount.d.ts.map +1 -1
- package/dist/esm/actions/getBlockCount.js.map +1 -1
- package/dist/esm/actions/getBlockStats.d.ts.map +1 -1
- package/dist/esm/actions/getBlockStats.js.map +1 -1
- package/dist/esm/actions/getTransactionFee.d.ts.map +1 -1
- package/dist/esm/actions/getTransactionFee.js.map +1 -1
- package/dist/esm/actions/getTransactions.d.ts.map +1 -1
- package/dist/esm/actions/getTransactions.js.map +1 -1
- package/dist/esm/actions/getUTXOTransaction.d.ts.map +1 -1
- package/dist/esm/actions/getUTXOTransaction.js.map +1 -1
- package/dist/esm/actions/getUTXOs.d.ts.map +1 -1
- package/dist/esm/actions/getUTXOs.js.map +1 -1
- package/dist/esm/actions/getXPubAddresses.d.ts.map +1 -1
- package/dist/esm/actions/getXPubAddresses.js.map +1 -1
- package/dist/esm/actions/sendUTXOTransaction.d.ts.map +1 -1
- package/dist/esm/actions/sendUTXOTransaction.js.map +1 -1
- package/dist/esm/actions/signPsbt.d.ts.map +1 -1
- package/dist/esm/actions/signPsbt.js.map +1 -1
- 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.map +1 -1
- package/dist/esm/actions/watchBlockNumber.js.map +1 -1
- package/dist/esm/chains/bitcoin.js +3 -3
- package/dist/esm/chains/bitcoin.js.map +1 -1
- package/dist/esm/chains/defineChain.d.ts.map +1 -1
- package/dist/esm/chains/defineChain.js.map +1 -1
- package/dist/esm/chains/signet.js +3 -3
- package/dist/esm/chains/signet.js.map +1 -1
- package/dist/esm/clients/decorators/public.d.ts.map +1 -1
- package/dist/esm/clients/decorators/public.js.map +1 -1
- package/dist/esm/clients/decorators/wallet.d.ts.map +1 -1
- package/dist/esm/clients/decorators/wallet.js.map +1 -1
- package/dist/esm/errors/address.d.ts.map +1 -1
- package/dist/esm/errors/address.js.map +1 -1
- 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.map +1 -1
- package/dist/esm/errors/block.js.map +1 -1
- package/dist/esm/errors/provider.js.map +1 -1
- 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.map +1 -1
- package/dist/esm/errors/rpc.js +3 -3
- package/dist/esm/errors/rpc.js.map +1 -1
- package/dist/esm/errors/transaction.d.ts.map +1 -1
- package/dist/esm/errors/transaction.js.map +1 -1
- package/dist/esm/errors/transport.d.ts.map +1 -1
- package/dist/esm/errors/transport.js.map +1 -1
- package/dist/esm/errors/utxo.d.ts.map +1 -1
- package/dist/esm/errors/utxo.js.map +1 -1
- 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.map +1 -1
- package/dist/esm/factories/createTransport.js.map +1 -1
- package/dist/esm/test/utils.js.map +1 -1
- package/dist/esm/transports/ankr/ankr.js.map +1 -1
- package/dist/esm/transports/ankr/getBalance.js +2 -2
- package/dist/esm/transports/ankr/getBalance.js.map +1 -1
- package/dist/esm/transports/ankr/getTransactionFee.js.map +1 -1
- package/dist/esm/transports/ankr/getTransactions.js.map +1 -1
- package/dist/esm/transports/ankr/methods.js.map +1 -1
- package/dist/esm/transports/ankr/utils.js.map +1 -1
- package/dist/esm/transports/blockchair/blockchair.js.map +1 -1
- package/dist/esm/transports/blockchair/getBalance.js +2 -2
- package/dist/esm/transports/blockchair/getBalance.js.map +1 -1
- package/dist/esm/transports/blockchair/getTransactionFee.js +2 -2
- package/dist/esm/transports/blockchair/getTransactionFee.js.map +1 -1
- package/dist/esm/transports/blockchair/getUTXOs.js +2 -2
- package/dist/esm/transports/blockchair/getUTXOs.js.map +1 -1
- package/dist/esm/transports/blockchair/getXPubAddresses.js +2 -2
- package/dist/esm/transports/blockchair/getXPubAddresses.js.map +1 -1
- package/dist/esm/transports/blockchair/methods.js.map +1 -1
- package/dist/esm/transports/blockcypher/blockcypher.js.map +1 -1
- package/dist/esm/transports/blockcypher/getBalance.js.map +1 -1
- package/dist/esm/transports/blockcypher/getTransactionFee.js.map +1 -1
- package/dist/esm/transports/blockcypher/getUTXOs.js.map +1 -1
- package/dist/esm/transports/blockcypher/methods.js.map +1 -1
- package/dist/esm/transports/blockcypher/utils.js +3 -3
- package/dist/esm/transports/blockcypher/utils.js.map +1 -1
- package/dist/esm/transports/custom.d.ts.map +1 -1
- package/dist/esm/transports/custom.js.map +1 -1
- package/dist/esm/transports/fallback.d.ts.map +1 -1
- package/dist/esm/transports/fallback.js +2 -2
- package/dist/esm/transports/fallback.js.map +1 -1
- package/dist/esm/transports/getHttpRpcClient.d.ts.map +1 -1
- package/dist/esm/transports/getHttpRpcClient.js.map +1 -1
- package/dist/esm/transports/getRpcProviderMethods.js.map +1 -1
- package/dist/esm/transports/http.d.ts.map +1 -1
- package/dist/esm/transports/http.js.map +1 -1
- package/dist/esm/transports/mempool/getBalance.js.map +1 -1
- package/dist/esm/transports/mempool/getTransactionFee.js.map +1 -1
- package/dist/esm/transports/mempool/getTransactions.js.map +1 -1
- package/dist/esm/transports/mempool/mempool.js.map +1 -1
- package/dist/esm/transports/mempool/methods.js.map +1 -1
- package/dist/esm/transports/mempool/utils.js.map +1 -1
- package/dist/esm/transports/types.d.ts.map +1 -1
- package/dist/esm/transports/types.js.map +1 -1
- package/dist/esm/transports/utxo.js.map +1 -1
- package/dist/esm/types/address.js.map +1 -1
- package/dist/esm/types/block.d.ts.map +1 -1
- package/dist/esm/types/chain.js.map +1 -1
- package/dist/esm/types/client.d.ts.map +1 -1
- package/dist/esm/types/request.d.ts.map +1 -1
- package/dist/esm/types/utils.d.ts.map +1 -1
- package/dist/esm/utils/buildRequest.d.ts.map +1 -1
- package/dist/esm/utils/buildRequest.js +4 -4
- package/dist/esm/utils/buildRequest.js.map +1 -1
- package/dist/esm/utils/cancelTransaction.js.map +1 -1
- package/dist/esm/utils/converter.js.map +1 -1
- package/dist/esm/utils/createBatchScheduler.d.ts.map +1 -1
- package/dist/esm/utils/createBatchScheduler.js +1 -1
- package/dist/esm/utils/createBatchScheduler.js.map +1 -1
- package/dist/esm/utils/deepEqual.js.map +1 -1
- package/dist/esm/utils/getAction.d.ts.map +1 -1
- package/dist/esm/utils/getAction.js.map +1 -1
- package/dist/esm/utils/getAddressInfo.js +25 -25
- package/dist/esm/utils/getAddressInfo.js.map +1 -1
- package/dist/esm/utils/idCache.js.map +1 -1
- package/dist/esm/utils/isAddress.js.map +1 -1
- package/dist/esm/utils/lru.js.map +1 -1
- package/dist/esm/utils/modifyFee.js.map +1 -1
- package/dist/esm/utils/observe.d.ts.map +1 -1
- package/dist/esm/utils/observe.js +2 -2
- package/dist/esm/utils/observe.js.map +1 -1
- package/dist/esm/utils/parseAccount.d.ts.map +1 -1
- package/dist/esm/utils/parseAccount.js.map +1 -1
- package/dist/esm/utils/poll.d.ts.map +1 -1
- package/dist/esm/utils/poll.js.map +1 -1
- package/dist/esm/utils/retryUntil.d.ts.map +1 -1
- package/dist/esm/utils/retryUntil.js.map +1 -1
- package/dist/esm/utils/sleep.js.map +1 -1
- package/dist/esm/utils/stringify.js.map +1 -1
- package/dist/esm/utils/uid.js.map +1 -1
- package/dist/esm/utils/url.js.map +1 -1
- package/dist/esm/utils/wait.js.map +1 -1
- package/dist/esm/utils/withDedupe.d.ts.map +1 -1
- package/dist/esm/utils/withDedupe.js +1 -1
- package/dist/esm/utils/withDedupe.js.map +1 -1
- package/dist/esm/utils/withResolvers.d.ts.map +1 -1
- package/dist/esm/utils/withResolvers.js.map +1 -1
- package/dist/esm/utils/withRetry.d.ts.map +1 -1
- package/dist/esm/utils/withRetry.js.map +1 -1
- 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 +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/package.json +3 -2
- package/src/version.ts +1 -1
- package/dist/cjs/transports/__mocks__/getTransactionFee.d.ts +0 -7
- package/dist/cjs/transports/__mocks__/getTransactionFee.js +0 -11
- package/dist/cjs/transports/__mocks__/getTransactionFee.js.map +0 -1
- package/dist/esm/transports/__mocks__/getTransactionFee.d.ts +0 -7
- package/dist/esm/transports/__mocks__/getTransactionFee.d.ts.map +0 -1
- package/dist/esm/transports/__mocks__/getTransactionFee.js +0 -8
- package/dist/esm/transports/__mocks__/getTransactionFee.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block.js","names":[],"sources":["../../../src/errors/block.ts"],"sourcesContent":["import type { Hash } from '../types/hash.js'\nimport { BaseError } from './base.js'\n\nexport type BlockNotFoundErrorType = BlockNotFoundError & {\n name: 'BlockNotFoundError'\n}\nexport class BlockNotFoundError extends BaseError {\n constructor({\n blockHash,\n blockNumber,\n }: {\n blockHash?: Hash | undefined\n blockNumber?: bigint | undefined\n }) {\n let identifier = 'Block'\n if (blockHash) {\n identifier = `Block at hash \"${blockHash}\"`\n }\n if (blockNumber) {\n identifier = `Block at number \"${blockNumber}\"`\n }\n super(`${identifier} could not be found.`, { name: 'BlockNotFoundError' })\n }\n}\n"],"mappings":";;AAMA,IAAa,qBAAb,cAAwC,UAAU;CAChD,YAAY,EACV,WACA,eAIC;EACD,IAAI,aAAa;
|
|
1
|
+
{"version":3,"file":"block.js","names":[],"sources":["../../../src/errors/block.ts"],"sourcesContent":["import type { Hash } from '../types/hash.js'\nimport { BaseError } from './base.js'\n\nexport type BlockNotFoundErrorType = BlockNotFoundError & {\n name: 'BlockNotFoundError'\n}\nexport class BlockNotFoundError extends BaseError {\n constructor({\n blockHash,\n blockNumber,\n }: {\n blockHash?: Hash | undefined\n blockNumber?: bigint | undefined\n }) {\n let identifier = 'Block'\n if (blockHash) {\n identifier = `Block at hash \"${blockHash}\"`\n }\n if (blockNumber) {\n identifier = `Block at number \"${blockNumber}\"`\n }\n super(`${identifier} could not be found.`, { name: 'BlockNotFoundError' })\n }\n}\n"],"mappings":";;AAMA,IAAa,qBAAb,cAAwC,UAAU;CAChD,YAAY,EACV,WACA,eAIC;EACD,IAAI,aAAa;EACjB,IAAI,WACF,aAAa,kBAAkB,UAAU;EAE3C,IAAI,aACF,aAAa,oBAAoB,YAAY;EAE/C,MAAM,GAAG,WAAW,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;CAC3E;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","names":[],"sources":["../../../src/errors/provider.ts"],"sourcesContent":["import { BaseError } from './base.js'\n\nexport class ProviderNotFoundError extends BaseError {\n constructor(message?: string) {\n const name = 'ProviderNotFoundError'\n const defaultMessage = 'The provider for this connector was not found'\n super(`${name}: ${message || defaultMessage}`, {\n name,\n })\n }\n}\n"],"mappings":";;AAEA,IAAa,wBAAb,cAA2C,UAAU;CACnD,YAAY,SAAkB;EAC5B,MAAM,OAAO;
|
|
1
|
+
{"version":3,"file":"provider.js","names":[],"sources":["../../../src/errors/provider.ts"],"sourcesContent":["import { BaseError } from './base.js'\n\nexport class ProviderNotFoundError extends BaseError {\n constructor(message?: string) {\n const name = 'ProviderNotFoundError'\n const defaultMessage = 'The provider for this connector was not found'\n super(`${name}: ${message || defaultMessage}`, {\n name,\n })\n }\n}\n"],"mappings":";;AAEA,IAAa,wBAAb,cAA2C,UAAU;CACnD,YAAY,SAAkB;EAC5B,MAAM,OAAO;EAEb,MAAM,GAAG,KAAK,IAAI,WAAW,mDAAkB,EAC7C,KACF,CAAC;CACH;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.ts","names":[],"sources":["../../../src/errors/request.ts"],"mappings":";;;KAKY,oBAAA,GAAuB,gBAAA;EACjC,IAAA;AAAA;AAAA,cAEW,gBAAA,SAAyB,SAAA;EACpC,IAAA;IAAA;;;;EACA,OAAA,GAAU,OAAA;EACV,MAAA;EACA,GAAA;EAEA,WAAA
|
|
1
|
+
{"version":3,"file":"request.d.ts","names":[],"sources":["../../../src/errors/request.ts"],"mappings":";;;KAKY,oBAAA,GAAuB,gBAAA;EACjC,IAAA;AAAA;AAAA,cAEW,gBAAA,SAAyB,SAAA;EACpC,IAAA;IAAA;;;;EACA,OAAA,GAAU,OAAA;EACV,MAAA;EACA,GAAA;EAEA,WAAA;IACE,IAAA;IACA,KAAA;IACA,OAAA;IACA,OAAA;IACA,MAAA;IACA;EAAA;IAEA,IAAA;MAAA;;;;IACA,KAAA,GAAQ,KAAA;IACR,OAAA;IACA,OAAA,GAAU,OAAA;IACV,MAAA;IACA,GAAA;EAAA;AAAA;AAAA,KAmBQ,yBAAA,GAA4B,qBAAA;EACtC,IAAA;AAAA;AAAA,cAEW,qBAAA,SAA8B,SAAA;EACzC,WAAA;IACE,IAAA;IACA,KAAA;IACA,OAAA;IACA;EAAA;IAEA,IAAA;MAAA;;IACA,KAAA,GAAQ,KAAA;IACR,OAAA;IACA,GAAA;EAAA;AAAA;AAAA,KAcQ,mBAAA,GAAsB,eAAA;EAChC,IAAA;AAAA;AAAA,cAEW,eAAA,SAAwB,SAAA;EAAA,SAC1B,IAAA;EACT,IAAA;EAEA,WAAA;IACE,IAAA;IACA,KAAA;IACA;EAAA;IAEA,IAAA;MAAA;;;;IACA,KAAA;MAAS,IAAA;MAAc,IAAA;MAAgB,OAAA;IAAA;IACvC,GAAA;EAAA;AAAA;AAAA,KAaQ,qBAAA,GAAwB,iBAAA;EAClC,IAAA;AAAA;AAAA,cAEW,iBAAA,SAA0B,SAAA;EACrC,WAAA;IACE;EAAA;IAEA,GAAA;EAAA;AAAA;AAAA,KASQ,gBAAA,GAAmB,YAAA;EAC7B,IAAA;AAAA;AAAA,cAEW,YAAA,SAAqB,SAAA;EAChC,WAAA;IACE,IAAA;IACA,GAAA;IACA;EAAA;IAEA,IAAA;MAAA;;;;IACA,GAAA;IACA,OAAA;EAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.js","names":[],"sources":["../../../src/errors/request.ts"],"sourcesContent":["import { stringify } from '../utils/stringify.js'\n\nimport { BaseError } from './base.js'\nimport { getUrl } from './utils.js'\n\nexport type HttpRequestErrorType = HttpRequestError & {\n name: 'HttpRequestError'\n}\nexport class HttpRequestError extends BaseError {\n body?: { [x: string]: unknown } | { [y: string]: unknown }[] | undefined\n headers?: Headers | undefined\n status?: number | undefined\n url: string\n\n constructor({\n body,\n cause,\n details,\n headers,\n status,\n url,\n }: {\n body?: { [x: string]: unknown } | { [y: string]: unknown }[] | undefined\n cause?: Error | undefined\n details?: string | undefined\n headers?: Headers | undefined\n status?: number | undefined\n url: string\n }) {\n super('HTTP request failed.', {\n cause,\n details,\n metaMessages: [\n status && `Status: ${status}`,\n `URL: ${getUrl(url)}`,\n body && `Request body: ${stringify(body)}`,\n ].filter(Boolean) as string[],\n name: 'HttpRequestError',\n })\n this.body = body\n this.headers = headers\n this.status = status\n this.url = url\n }\n}\n\nexport type WebSocketRequestErrorType = WebSocketRequestError & {\n name: 'WebSocketRequestError'\n}\nexport class WebSocketRequestError extends BaseError {\n constructor({\n body,\n cause,\n details,\n url,\n }: {\n body?: { [key: string]: unknown } | undefined\n cause?: Error | undefined\n details?: string | undefined\n url: string\n }) {\n super('WebSocket request failed.', {\n cause,\n details,\n metaMessages: [\n `URL: ${getUrl(url)}`,\n body && `Request body: ${stringify(body)}`,\n ].filter(Boolean) as string[],\n name: 'WebSocketRequestError',\n })\n }\n}\n\nexport type RpcRequestErrorType = RpcRequestError & {\n name: 'RpcRequestError'\n}\nexport class RpcRequestError extends BaseError {\n override code: number\n data?: unknown\n\n constructor({\n body,\n error,\n url,\n }: {\n body: { [x: string]: unknown } | { [y: string]: unknown }[]\n error: { code: number; data?: unknown; message: string }\n url: string\n }) {\n super('RPC Request failed.', {\n cause: error as any,\n details: error.message,\n metaMessages: [`URL: ${getUrl(url)}`, `Request body: ${stringify(body)}`],\n name: 'RpcRequestError',\n })\n this.code = error.code\n this.data = error.data\n }\n}\n\nexport type SocketClosedErrorType = SocketClosedError & {\n name: 'SocketClosedError'\n}\nexport class SocketClosedError extends BaseError {\n constructor({\n url,\n }: {\n url?: string | undefined\n } = {}) {\n super('The socket has been closed.', {\n metaMessages: [url && `URL: ${getUrl(url)}`].filter(Boolean) as string[],\n name: 'SocketClosedError',\n })\n }\n}\n\nexport type TimeoutErrorType = TimeoutError & {\n name: 'TimeoutError'\n}\nexport class TimeoutError extends BaseError {\n constructor({\n body,\n url,\n timeout,\n }: {\n body: { [x: string]: unknown } | { [y: string]: unknown }[]\n url: string\n timeout: number\n }) {\n super('The request took too long to respond.', {\n details: `The request timed out after ${timeout}ms.`,\n metaMessages: [`URL: ${getUrl(url)}`, `Request body: ${stringify(body)}`],\n name: 'TimeoutError',\n })\n }\n}\n"],"mappings":";;;;AAQA,IAAa,mBAAb,cAAsC,UAAU;CAM9C,YAAY,EACV,MACA,OACA,SACA,SACA,QACA,OAQC;
|
|
1
|
+
{"version":3,"file":"request.js","names":[],"sources":["../../../src/errors/request.ts"],"sourcesContent":["import { stringify } from '../utils/stringify.js'\n\nimport { BaseError } from './base.js'\nimport { getUrl } from './utils.js'\n\nexport type HttpRequestErrorType = HttpRequestError & {\n name: 'HttpRequestError'\n}\nexport class HttpRequestError extends BaseError {\n body?: { [x: string]: unknown } | { [y: string]: unknown }[] | undefined\n headers?: Headers | undefined\n status?: number | undefined\n url: string\n\n constructor({\n body,\n cause,\n details,\n headers,\n status,\n url,\n }: {\n body?: { [x: string]: unknown } | { [y: string]: unknown }[] | undefined\n cause?: Error | undefined\n details?: string | undefined\n headers?: Headers | undefined\n status?: number | undefined\n url: string\n }) {\n super('HTTP request failed.', {\n cause,\n details,\n metaMessages: [\n status && `Status: ${status}`,\n `URL: ${getUrl(url)}`,\n body && `Request body: ${stringify(body)}`,\n ].filter(Boolean) as string[],\n name: 'HttpRequestError',\n })\n this.body = body\n this.headers = headers\n this.status = status\n this.url = url\n }\n}\n\nexport type WebSocketRequestErrorType = WebSocketRequestError & {\n name: 'WebSocketRequestError'\n}\nexport class WebSocketRequestError extends BaseError {\n constructor({\n body,\n cause,\n details,\n url,\n }: {\n body?: { [key: string]: unknown } | undefined\n cause?: Error | undefined\n details?: string | undefined\n url: string\n }) {\n super('WebSocket request failed.', {\n cause,\n details,\n metaMessages: [\n `URL: ${getUrl(url)}`,\n body && `Request body: ${stringify(body)}`,\n ].filter(Boolean) as string[],\n name: 'WebSocketRequestError',\n })\n }\n}\n\nexport type RpcRequestErrorType = RpcRequestError & {\n name: 'RpcRequestError'\n}\nexport class RpcRequestError extends BaseError {\n override code: number\n data?: unknown\n\n constructor({\n body,\n error,\n url,\n }: {\n body: { [x: string]: unknown } | { [y: string]: unknown }[]\n error: { code: number; data?: unknown; message: string }\n url: string\n }) {\n super('RPC Request failed.', {\n cause: error as any,\n details: error.message,\n metaMessages: [`URL: ${getUrl(url)}`, `Request body: ${stringify(body)}`],\n name: 'RpcRequestError',\n })\n this.code = error.code\n this.data = error.data\n }\n}\n\nexport type SocketClosedErrorType = SocketClosedError & {\n name: 'SocketClosedError'\n}\nexport class SocketClosedError extends BaseError {\n constructor({\n url,\n }: {\n url?: string | undefined\n } = {}) {\n super('The socket has been closed.', {\n metaMessages: [url && `URL: ${getUrl(url)}`].filter(Boolean) as string[],\n name: 'SocketClosedError',\n })\n }\n}\n\nexport type TimeoutErrorType = TimeoutError & {\n name: 'TimeoutError'\n}\nexport class TimeoutError extends BaseError {\n constructor({\n body,\n url,\n timeout,\n }: {\n body: { [x: string]: unknown } | { [y: string]: unknown }[]\n url: string\n timeout: number\n }) {\n super('The request took too long to respond.', {\n details: `The request timed out after ${timeout}ms.`,\n metaMessages: [`URL: ${getUrl(url)}`, `Request body: ${stringify(body)}`],\n name: 'TimeoutError',\n })\n }\n}\n"],"mappings":";;;;AAQA,IAAa,mBAAb,cAAsC,UAAU;CAM9C,YAAY,EACV,MACA,OACA,SACA,SACA,QACA,OAQC;EACD,MAAM,wBAAwB;GAC5B;GACA;GACA,cAAc;IACZ,UAAU,WAAW;IACrB,QAAQ,OAAO,GAAG;IAClB,QAAQ,iBAAiB,UAAU,IAAI;GACzC,EAAE,OAAO,OAAO;GAChB,MAAM;EACR,CAAC;EACD,KAAK,OAAO;EACZ,KAAK,UAAU;EACf,KAAK,SAAS;EACd,KAAK,MAAM;CACb;AACF;AAKA,IAAa,wBAAb,cAA2C,UAAU;CACnD,YAAY,EACV,MACA,OACA,SACA,OAMC;EACD,MAAM,6BAA6B;GACjC;GACA;GACA,cAAc,CACZ,QAAQ,OAAO,GAAG,KAClB,QAAQ,iBAAiB,UAAU,IAAI,GACzC,EAAE,OAAO,OAAO;GAChB,MAAM;EACR,CAAC;CACH;AACF;AAKA,IAAa,kBAAb,cAAqC,UAAU;CAI7C,YAAY,EACV,MACA,OACA,OAKC;EACD,MAAM,uBAAuB;GAC3B,OAAO;GACP,SAAS,MAAM;GACf,cAAc,CAAC,QAAQ,OAAO,GAAG,KAAK,iBAAiB,UAAU,IAAI,GAAG;GACxE,MAAM;EACR,CAAC;EACD,KAAK,OAAO,MAAM;EAClB,KAAK,OAAO,MAAM;CACpB;AACF;AAKA,IAAa,oBAAb,cAAuC,UAAU;CAC/C,YAAY,EACV,QAGE,CAAC,GAAG;EACN,MAAM,+BAA+B;GACnC,cAAc,CAAC,OAAO,QAAQ,OAAO,GAAG,GAAG,EAAE,OAAO,OAAO;GAC3D,MAAM;EACR,CAAC;CACH;AACF;AAKA,IAAa,eAAb,cAAkC,UAAU;CAC1C,YAAY,EACV,MACA,KACA,WAKC;EACD,MAAM,yCAAyC;GAC7C,SAAS,+BAA+B,QAAQ;GAChD,cAAc,CAAC,QAAQ,OAAO,GAAG,KAAK,iBAAiB,UAAU,IAAI,GAAG;GACxE,MAAM;EACR,CAAC;CACH;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc.d.ts","names":[],"sources":["../../../src/errors/rpc.ts"],"mappings":";;;;;AAOA;;;aAAY,YAAA;;;;EAIV,WAAA;;;;EAIA,eAAA
|
|
1
|
+
{"version":3,"file":"rpc.d.ts","names":[],"sources":["../../../src/errors/rpc.ts"],"mappings":";;;;;AAOA;;;aAAY,YAAA;;;;EAIV,WAAA;;;;EAIA,eAAA;;;AA6BA;EAzBA,gBAAA;EA4BW;;;EAxBX,cAAA;;;;;EAKA,cAAA;EA+BF;;;EA3BE,cAAA;;;;EAIA,oBAAA;EAyBY;AAAA;AASd;EA9BE,aAAA;;;;EAIA,UAAA;AAAA;AAAA,cAGW,wBAAA,SAAiC,SAAA;EAAA,SACnC,IAAA;EACT,WAAA,CAAY,OAAA;AAAA;AAAA,cAUD,0BAAA,SAAmC,SAAA;EAAA,SACrC,IAAA;EACT,WAAA,CAAY,MAAA;AAAA;AAAA,cASD,UAAA,SAAmB,SAAA;EAAA,SACrB,IAAA;EACT,WAAA,CAAY,OAAA;AAAA"}
|
package/dist/esm/errors/rpc.js
CHANGED
|
@@ -49,7 +49,7 @@ var UserRejectedRequestError = class extends BaseError {
|
|
|
49
49
|
constructor(message) {
|
|
50
50
|
const name = "UserRejectedRequestError";
|
|
51
51
|
super(`${name}: ${message || "The user rejected your request, please try again"}`, { name });
|
|
52
|
-
this.code =
|
|
52
|
+
this.code = -32e3;
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
var MethodNotSupportedRpcError = class extends BaseError {
|
|
@@ -57,14 +57,14 @@ var MethodNotSupportedRpcError = class extends BaseError {
|
|
|
57
57
|
const name = "MethodNotSupportedError";
|
|
58
58
|
const message = `The method ${method} you are calling is not supported`;
|
|
59
59
|
super(`${name}: ${message}`, { name });
|
|
60
|
-
this.code =
|
|
60
|
+
this.code = -32001;
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
var ParseError = class extends BaseError {
|
|
64
64
|
constructor(message) {
|
|
65
65
|
const name = "ParseError";
|
|
66
66
|
super(`${name}: ${message || "Invalid JSON, there was an error parsing your request."}`, { name });
|
|
67
|
-
this.code =
|
|
67
|
+
this.code = -32700;
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
70
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc.js","names":[],"sources":["../../../src/errors/rpc.ts"],"sourcesContent":["import { BaseError } from './base.js'\n\n/**\n * @enum {number} RpcErrorCode\n * @description JSON-RPC error codes\n * @see https://www.jsonrpc.org/specification#error_object\n */\nexport enum RpcErrorCode {\n /**\n * Parse error Invalid JSON\n **/\n PARSE_ERROR = -32700,\n /**\n * The JSON sent is not a valid Request object.\n **/\n INVALID_REQUEST = -32600,\n /**\n * The method does not exist/is not available.\n **/\n METHOD_NOT_FOUND = -32601,\n /**\n * Invalid method parameter(s).\n */\n INVALID_PARAMS = -32602,\n /**\n * Internal JSON-RPC error.\n * This is a generic error, used when the server encounters an error in performing the request.\n **/\n INTERNAL_ERROR = -32603,\n /**\n * user rejected/canceled the request\n */\n USER_REJECTION = -32000,\n /**\n * method is not supported for the address provided\n */\n METHOD_NOT_SUPPORTED = -32001,\n /**\n * The client does not have permission to access the requested resource.\n */\n ACCESS_DENIED = -32002,\n /**\n * Unknown generic errors\n */\n MISC_ERROR = -1,\n}\n\nexport class UserRejectedRequestError extends BaseError {\n override code: number = RpcErrorCode.USER_REJECTION\n constructor(message?: string) {\n const name = 'UserRejectedRequestError'\n const errMessage =\n message || 'The user rejected your request, please try again'\n super(`${name}: ${errMessage}`, {\n name,\n })\n }\n}\n\nexport class MethodNotSupportedRpcError extends BaseError {\n override code: number = RpcErrorCode.METHOD_NOT_SUPPORTED\n constructor(method?: string) {\n const name = 'MethodNotSupportedError'\n const message = `The method ${method} you are calling is not supported`\n super(`${name}: ${message}`, {\n name,\n })\n }\n}\n\nexport class ParseError extends BaseError {\n override code: number = RpcErrorCode.PARSE_ERROR\n constructor(message?: string) {\n const name = 'ParseError'\n const errMessage =\n message || 'Invalid JSON, there was an error parsing your request.'\n super(`${name}: ${errMessage}`, {\n name,\n })\n }\n}\n"],"mappings":";;;;;;;AAOA,IAAY,eAAL,yBAAA,cAAA;;;;
|
|
1
|
+
{"version":3,"file":"rpc.js","names":[],"sources":["../../../src/errors/rpc.ts"],"sourcesContent":["import { BaseError } from './base.js'\n\n/**\n * @enum {number} RpcErrorCode\n * @description JSON-RPC error codes\n * @see https://www.jsonrpc.org/specification#error_object\n */\nexport enum RpcErrorCode {\n /**\n * Parse error Invalid JSON\n **/\n PARSE_ERROR = -32700,\n /**\n * The JSON sent is not a valid Request object.\n **/\n INVALID_REQUEST = -32600,\n /**\n * The method does not exist/is not available.\n **/\n METHOD_NOT_FOUND = -32601,\n /**\n * Invalid method parameter(s).\n */\n INVALID_PARAMS = -32602,\n /**\n * Internal JSON-RPC error.\n * This is a generic error, used when the server encounters an error in performing the request.\n **/\n INTERNAL_ERROR = -32603,\n /**\n * user rejected/canceled the request\n */\n USER_REJECTION = -32000,\n /**\n * method is not supported for the address provided\n */\n METHOD_NOT_SUPPORTED = -32001,\n /**\n * The client does not have permission to access the requested resource.\n */\n ACCESS_DENIED = -32002,\n /**\n * Unknown generic errors\n */\n MISC_ERROR = -1,\n}\n\nexport class UserRejectedRequestError extends BaseError {\n override code: number = RpcErrorCode.USER_REJECTION\n constructor(message?: string) {\n const name = 'UserRejectedRequestError'\n const errMessage =\n message || 'The user rejected your request, please try again'\n super(`${name}: ${errMessage}`, {\n name,\n })\n }\n}\n\nexport class MethodNotSupportedRpcError extends BaseError {\n override code: number = RpcErrorCode.METHOD_NOT_SUPPORTED\n constructor(method?: string) {\n const name = 'MethodNotSupportedError'\n const message = `The method ${method} you are calling is not supported`\n super(`${name}: ${message}`, {\n name,\n })\n }\n}\n\nexport class ParseError extends BaseError {\n override code: number = RpcErrorCode.PARSE_ERROR\n constructor(message?: string) {\n const name = 'ParseError'\n const errMessage =\n message || 'Invalid JSON, there was an error parsing your request.'\n super(`${name}: ${errMessage}`, {\n name,\n })\n }\n}\n"],"mappings":";;;;;;;AAOA,IAAY,eAAL,yBAAA,cAAA;;;;CAIL,aAAA,aAAA,iBAAA,UAAA;;;;CAIA,aAAA,aAAA,qBAAA,UAAA;;;;CAIA,aAAA,aAAA,sBAAA,UAAA;;;;CAIA,aAAA,aAAA,oBAAA,UAAA;;;;;CAKA,aAAA,aAAA,oBAAA,UAAA;;;;CAIA,aAAA,aAAA,oBAAA,SAAA;;;;CAIA,aAAA,aAAA,0BAAA,UAAA;;;;CAIA,aAAA,aAAA,mBAAA,UAAA;;;;CAIA,aAAA,aAAA,gBAAA,MAAA;;AACF,EAAA,CAAA,CAAA;AAEA,IAAa,2BAAb,cAA8C,UAAU;CAEtD,YAAY,SAAkB;EAC5B,MAAM,OAAO;EAGb,MAAM,GAAG,KAAK,KADZ,WAAW,sDACoB,EAC/B,KACF,CAAC;;CACH;AACF;AAEA,IAAa,6BAAb,cAAgD,UAAU;CAExD,YAAY,QAAiB;EAC3B,MAAM,OAAO;EACb,MAAM,UAAU,cAAc,OAAO;EACrC,MAAM,GAAG,KAAK,IAAI,WAAW,EAC3B,KACF,CAAC;;CACH;AACF;AAEA,IAAa,aAAb,cAAgC,UAAU;CAExC,YAAY,SAAkB;EAC5B,MAAM,OAAO;EAGb,MAAM,GAAG,KAAK,IADZ,WAAW,4DACmB,EAC9B,KACF,CAAC;;CACH;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.d.ts","names":[],"sources":["../../../src/errors/transaction.ts"],"mappings":";;;;;KAIY,4BAAA,GAA+B,wBAAA;EACzC,IAAA;AAAA;AAAA,cAEW,wBAAA,SAAiC,SAAA;EAC5C,WAAA
|
|
1
|
+
{"version":3,"file":"transaction.d.ts","names":[],"sources":["../../../src/errors/transaction.ts"],"mappings":";;;;;KAIY,4BAAA,GAA+B,wBAAA;EACzC,IAAA;AAAA;AAAA,cAEW,wBAAA,SAAiC,SAAA;EAC5C,WAAA;IACE,SAAA;IACA,WAAA;IACA,QAAA;IACA,IAAA;IACA;EAAA;IAEA,SAAA,GAAY,IAAA;IACZ,WAAA;IACA,QAAA,GAAW,QAAA;IACX,IAAA,GAAO,IAAA;IACP,KAAA;EAAA;AAAA;AAAA,KAqBQ,mCAAA,GACV,+BAAA;EACE,IAAA;AAAA;AAAA,cAES,+BAAA,SAAwC,SAAA;EACnD,WAAA;IAAc;EAAA;IAAU,IAAA,EAAM,IAAA;EAAA;AAAA;AAAA,KAUpB,yCAAA,GACV,qCAAA;EACE,IAAA;AAAA;AAAA,cAES,qCAAA,SAA8C,SAAA;EACzD,WAAA;IAAc;EAAA;IAAU,IAAA,EAAM,IAAA;EAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.js","names":[],"sources":["../../../src/errors/transaction.ts"],"sourcesContent":["import type { BlockTag } from '../types/block.js'\nimport type { Hash } from '../types/hash.js'\nimport { BaseError } from './base.js'\n\nexport type TransactionNotFoundErrorType = TransactionNotFoundError & {\n name: 'TransactionNotFoundError'\n}\nexport class TransactionNotFoundError extends BaseError {\n constructor({\n blockHash,\n blockNumber,\n blockTag,\n hash,\n index,\n }: {\n blockHash?: Hash | undefined\n blockNumber?: bigint | undefined\n blockTag?: BlockTag | undefined\n hash?: Hash | undefined\n index?: number | undefined\n }) {\n let identifier = 'Transaction'\n if (blockTag && index !== undefined) {\n identifier = `Transaction at block time \"${blockTag}\" at index \"${index}\"`\n }\n if (blockHash && index !== undefined) {\n identifier = `Transaction at block hash \"${blockHash}\" at index \"${index}\"`\n }\n if (blockNumber && index !== undefined) {\n identifier = `Transaction at block number \"${blockNumber}\" at index \"${index}\"`\n }\n if (hash) {\n identifier = `Transaction with hash \"${hash}\"`\n }\n super(`${identifier} could not be found.`, {\n name: 'TransactionNotFoundError',\n })\n }\n}\n\nexport type TransactionReceiptNotFoundErrorType =\n TransactionReceiptNotFoundError & {\n name: 'TransactionReceiptNotFoundError'\n }\nexport class TransactionReceiptNotFoundError extends BaseError {\n constructor({ hash }: { hash: Hash }) {\n super(\n `Transaction receipt with hash \"${hash}\" could not be found. The Transaction may not be processed on a block yet.`,\n {\n name: 'TransactionReceiptNotFoundError',\n }\n )\n }\n}\n\nexport type WaitForTransactionReceiptTimeoutErrorType =\n WaitForTransactionReceiptTimeoutError & {\n name: 'WaitForTransactionReceiptTimeoutError'\n }\nexport class WaitForTransactionReceiptTimeoutError extends BaseError {\n constructor({ hash }: { hash: Hash }) {\n super(\n `Timed out while waiting for transaction with hash \"${hash}\" to be confirmed.`,\n { name: 'WaitForTransactionReceiptTimeoutError' }\n )\n }\n}\n"],"mappings":";;AAOA,IAAa,2BAAb,cAA8C,UAAU;CACtD,YAAY,EACV,WACA,aACA,UACA,MACA,SAOC;EACD,IAAI,aAAa;
|
|
1
|
+
{"version":3,"file":"transaction.js","names":[],"sources":["../../../src/errors/transaction.ts"],"sourcesContent":["import type { BlockTag } from '../types/block.js'\nimport type { Hash } from '../types/hash.js'\nimport { BaseError } from './base.js'\n\nexport type TransactionNotFoundErrorType = TransactionNotFoundError & {\n name: 'TransactionNotFoundError'\n}\nexport class TransactionNotFoundError extends BaseError {\n constructor({\n blockHash,\n blockNumber,\n blockTag,\n hash,\n index,\n }: {\n blockHash?: Hash | undefined\n blockNumber?: bigint | undefined\n blockTag?: BlockTag | undefined\n hash?: Hash | undefined\n index?: number | undefined\n }) {\n let identifier = 'Transaction'\n if (blockTag && index !== undefined) {\n identifier = `Transaction at block time \"${blockTag}\" at index \"${index}\"`\n }\n if (blockHash && index !== undefined) {\n identifier = `Transaction at block hash \"${blockHash}\" at index \"${index}\"`\n }\n if (blockNumber && index !== undefined) {\n identifier = `Transaction at block number \"${blockNumber}\" at index \"${index}\"`\n }\n if (hash) {\n identifier = `Transaction with hash \"${hash}\"`\n }\n super(`${identifier} could not be found.`, {\n name: 'TransactionNotFoundError',\n })\n }\n}\n\nexport type TransactionReceiptNotFoundErrorType =\n TransactionReceiptNotFoundError & {\n name: 'TransactionReceiptNotFoundError'\n }\nexport class TransactionReceiptNotFoundError extends BaseError {\n constructor({ hash }: { hash: Hash }) {\n super(\n `Transaction receipt with hash \"${hash}\" could not be found. The Transaction may not be processed on a block yet.`,\n {\n name: 'TransactionReceiptNotFoundError',\n }\n )\n }\n}\n\nexport type WaitForTransactionReceiptTimeoutErrorType =\n WaitForTransactionReceiptTimeoutError & {\n name: 'WaitForTransactionReceiptTimeoutError'\n }\nexport class WaitForTransactionReceiptTimeoutError extends BaseError {\n constructor({ hash }: { hash: Hash }) {\n super(\n `Timed out while waiting for transaction with hash \"${hash}\" to be confirmed.`,\n { name: 'WaitForTransactionReceiptTimeoutError' }\n )\n }\n}\n"],"mappings":";;AAOA,IAAa,2BAAb,cAA8C,UAAU;CACtD,YAAY,EACV,WACA,aACA,UACA,MACA,SAOC;EACD,IAAI,aAAa;EACjB,IAAI,YAAY,UAAU,KAAA,GACxB,aAAa,8BAA8B,SAAS,cAAc,MAAM;EAE1E,IAAI,aAAa,UAAU,KAAA,GACzB,aAAa,8BAA8B,UAAU,cAAc,MAAM;EAE3E,IAAI,eAAe,UAAU,KAAA,GAC3B,aAAa,gCAAgC,YAAY,cAAc,MAAM;EAE/E,IAAI,MACF,aAAa,0BAA0B,KAAK;EAE9C,MAAM,GAAG,WAAW,uBAAuB,EACzC,MAAM,2BACR,CAAC;CACH;AACF;AAMA,IAAa,kCAAb,cAAqD,UAAU;CAC7D,YAAY,EAAE,QAAwB;EACpC,MACE,kCAAkC,KAAK,6EACvC,EACE,MAAM,kCACR,CACF;CACF;AACF;AAMA,IAAa,wCAAb,cAA2D,UAAU;CACnE,YAAY,EAAE,QAAwB;EACpC,MACE,sDAAsD,KAAK,qBAC3D,EAAE,MAAM,wCAAwC,CAClD;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","names":[],"sources":["../../../src/errors/transport.ts"],"mappings":";;;KAEY,oBAAA,GAAuB,gBAAA;EACjC,IAAA;AAAA;AAAA,cAEW,gBAAA,SAAyB,SAAA;EACpC,WAAA
|
|
1
|
+
{"version":3,"file":"transport.d.ts","names":[],"sources":["../../../src/errors/transport.ts"],"mappings":";;;KAEY,oBAAA,GAAuB,gBAAA;EACjC,IAAA;AAAA;AAAA,cAEW,gBAAA,SAAyB,SAAA;EACpC,WAAA;AAAA;AAAA,KAUU,oCAAA,GACV,gCAAA;EACE,IAAA;AAAA;AAAA,cAES,gCAAA,SAAyC,SAAA;EACpD,WAAA;IAAc;EAAA;IAAY,MAAA;EAAA;AAAA;AAAA,KAOhB,4BAAA,GAA+B,wBAAA;EACzC,IAAA;AAAA;AAAA,cAEW,wBAAA,SAAiC,SAAA;EAC5C,WAAA;IACE,MAAA;IACA,MAAA;IACA,MAAA;IACA;EAAA;IAEA,MAAA;IACA,MAAA;IACA,MAAA,EAAQ,KAAA;MACN,SAAA;MACA,KAAA,EAAO,KAAA;MACP,OAAA;IAAA;IAEF,aAAA;EAAA;EA2BF,MAAA;EACA,MAAA;EACA,MAAA,EAAQ,KAAA;IACN,SAAA;IACA,KAAA,EAAO,KAAA;IACP,OAAA;EAAA;EAEF,aAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.js","names":[],"sources":["../../../src/errors/transport.ts"],"sourcesContent":["import { BaseError } from './base.js'\n\nexport type UrlRequiredErrorType = UrlRequiredError & {\n name: 'UrlRequiredError'\n}\nexport class UrlRequiredError extends BaseError {\n constructor() {\n super(\n 'No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.',\n {\n name: 'UrlRequiredError',\n }\n )\n }\n}\n\nexport type TransportMethodNotSupportedErrorType =\n TransportMethodNotSupportedError & {\n name: 'TransportMethodNotSupportedError'\n }\nexport class TransportMethodNotSupportedError extends BaseError {\n constructor({ method }: { method: string }) {\n super(`No transport found that supports the method: ${method}`, {\n name: 'TransportMethodNotSupportedError',\n })\n }\n}\n\nexport type AllTransportsFailedErrorType = AllTransportsFailedError & {\n name: 'AllTransportsFailedError'\n}\nexport class AllTransportsFailedError extends BaseError {\n constructor({\n method,\n params,\n errors,\n totalAttempts,\n }: {\n method: string\n params: unknown\n errors: Array<{\n transport: string\n error: Error\n attempt: number\n }>\n totalAttempts: number\n }) {\n const errorMessages = errors\n .map(\n ({ transport, error, attempt }) =>\n `${attempt}. ${transport}: ${error.message}`\n )\n .join('\\n')\n\n super(\n `All ${totalAttempts} transports failed for method \"${method}\": \\n${errorMessages}`,\n {\n name: 'AllTransportsFailedError',\n metaMessages: [\n `Method: ${method}`,\n `Total attempts: ${totalAttempts}`,\n `Failed transports: ${errors.map((e) => e.transport).join(', ')}`,\n ],\n }\n )\n\n this.method = method\n this.params = params\n this.errors = errors\n this.totalAttempts = totalAttempts\n }\n\n method: string\n params: unknown\n errors: Array<{\n transport: string\n error: Error\n attempt: number\n }>\n totalAttempts: number\n}\n"],"mappings":";;AAKA,IAAa,mBAAb,cAAsC,UAAU;CAC9C,cAAc;
|
|
1
|
+
{"version":3,"file":"transport.js","names":[],"sources":["../../../src/errors/transport.ts"],"sourcesContent":["import { BaseError } from './base.js'\n\nexport type UrlRequiredErrorType = UrlRequiredError & {\n name: 'UrlRequiredError'\n}\nexport class UrlRequiredError extends BaseError {\n constructor() {\n super(\n 'No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.',\n {\n name: 'UrlRequiredError',\n }\n )\n }\n}\n\nexport type TransportMethodNotSupportedErrorType =\n TransportMethodNotSupportedError & {\n name: 'TransportMethodNotSupportedError'\n }\nexport class TransportMethodNotSupportedError extends BaseError {\n constructor({ method }: { method: string }) {\n super(`No transport found that supports the method: ${method}`, {\n name: 'TransportMethodNotSupportedError',\n })\n }\n}\n\nexport type AllTransportsFailedErrorType = AllTransportsFailedError & {\n name: 'AllTransportsFailedError'\n}\nexport class AllTransportsFailedError extends BaseError {\n constructor({\n method,\n params,\n errors,\n totalAttempts,\n }: {\n method: string\n params: unknown\n errors: Array<{\n transport: string\n error: Error\n attempt: number\n }>\n totalAttempts: number\n }) {\n const errorMessages = errors\n .map(\n ({ transport, error, attempt }) =>\n `${attempt}. ${transport}: ${error.message}`\n )\n .join('\\n')\n\n super(\n `All ${totalAttempts} transports failed for method \"${method}\": \\n${errorMessages}`,\n {\n name: 'AllTransportsFailedError',\n metaMessages: [\n `Method: ${method}`,\n `Total attempts: ${totalAttempts}`,\n `Failed transports: ${errors.map((e) => e.transport).join(', ')}`,\n ],\n }\n )\n\n this.method = method\n this.params = params\n this.errors = errors\n this.totalAttempts = totalAttempts\n }\n\n method: string\n params: unknown\n errors: Array<{\n transport: string\n error: Error\n attempt: number\n }>\n totalAttempts: number\n}\n"],"mappings":";;AAKA,IAAa,mBAAb,cAAsC,UAAU;CAC9C,cAAc;EACZ,MACE,0FACA,EACE,MAAM,mBACR,CACF;CACF;AACF;AAMA,IAAa,mCAAb,cAAsD,UAAU;CAC9D,YAAY,EAAE,UAA8B;EAC1C,MAAM,gDAAgD,UAAU,EAC9D,MAAM,mCACR,CAAC;CACH;AACF;AAKA,IAAa,2BAAb,cAA8C,UAAU;CACtD,YAAY,EACV,QACA,QACA,QACA,iBAUC;EACD,MAAM,gBAAgB,OACnB,KACE,EAAE,WAAW,OAAO,cACnB,GAAG,QAAQ,IAAI,UAAU,IAAI,MAAM,SACvC,EACC,KAAK,IAAI;EAEZ,MACE,OAAO,cAAc,iCAAiC,OAAO,OAAO,iBACpE;GACE,MAAM;GACN,cAAc;IACZ,WAAW;IACX,mBAAmB;IACnB,sBAAsB,OAAO,KAAK,MAAM,EAAE,SAAS,EAAE,KAAK,IAAI;GAChE;EACF,CACF;EAEA,KAAK,SAAS;EACd,KAAK,SAAS;EACd,KAAK,SAAS;EACd,KAAK,gBAAgB;CACvB;AAUF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utxo.d.ts","names":[],"sources":["../../../src/errors/utxo.ts"],"mappings":";;;KAEY,gCAAA,GAAmC,4BAAA;EAC7C,IAAA;AAAA;AAAA,cAGW,4BAAA,SAAqC,SAAA;EAChD,WAAA
|
|
1
|
+
{"version":3,"file":"utxo.d.ts","names":[],"sources":["../../../src/errors/utxo.ts"],"mappings":";;;KAEY,gCAAA,GAAmC,4BAAA;EAC7C,IAAA;AAAA;AAAA,cAGW,4BAAA,SAAqC,SAAA;EAChD,WAAA;IACE,QAAA;IACA,OAAA;IACA;EAAA;IACG,QAAA;IAAkB,OAAA;IAAkB,OAAA;EAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utxo.js","names":[],"sources":["../../../src/errors/utxo.ts"],"sourcesContent":["import { BaseError } from './base.js'\n\nexport type InsufficientUTXOBalanceErrorType = InsufficientUTXOBalanceError & {\n name: 'InsufficientUTXOBalanceError'\n}\n\nexport class InsufficientUTXOBalanceError extends BaseError {\n constructor({\n minValue,\n address,\n balance,\n }: { minValue: number; address?: string; balance?: number }) {\n super(`Not enough UTXOs required for ${minValue}`, {\n metaMessages: [\n `${address && balance && `Address ${address} has a balance of ${balance}.`}`,\n ],\n name: 'InsufficientUTXOBalanceError',\n })\n }\n}\n"],"mappings":";;AAMA,IAAa,+BAAb,cAAkD,UAAU;CAC1D,YAAY,EACV,UACA,SACA,WAC2D;
|
|
1
|
+
{"version":3,"file":"utxo.js","names":[],"sources":["../../../src/errors/utxo.ts"],"sourcesContent":["import { BaseError } from './base.js'\n\nexport type InsufficientUTXOBalanceErrorType = InsufficientUTXOBalanceError & {\n name: 'InsufficientUTXOBalanceError'\n}\n\nexport class InsufficientUTXOBalanceError extends BaseError {\n constructor({\n minValue,\n address,\n balance,\n }: { minValue: number; address?: string; balance?: number }) {\n super(`Not enough UTXOs required for ${minValue}`, {\n metaMessages: [\n `${address && balance && `Address ${address} has a balance of ${balance}.`}`,\n ],\n name: 'InsufficientUTXOBalanceError',\n })\n }\n}\n"],"mappings":";;AAMA,IAAa,+BAAb,cAAkD,UAAU;CAC1D,YAAY,EACV,UACA,SACA,WAC2D;EAC3D,MAAM,iCAAiC,YAAY;GACjD,cAAc,CACZ,GAAG,WAAW,WAAW,WAAW,QAAQ,oBAAoB,QAAQ,IAC1E;GACA,MAAM;EACR,CAAC;CACH;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createClient.d.ts","names":[],"sources":["../../../src/factories/createClient.ts"],"mappings":";;;;;;;;;;KAYY,YAAA,mBACQ,SAAA,GAAY,SAAA,gBAChB,KAAA,eAAoB,KAAA,uCACT,OAAA,GAAU,OAAA,eAC/B,OAAA,GACA,OAAA,gCAEc,SAAA;iHAGlB,OAAA,GAAU,gBAAA,GAAmB,OAAA,GAAU,OAAA;EAEvC,KAAA;IATmC,yDAY7B,SAAA,aAAsB,QAAA,CAAS,qBAAA;EAAA;;;;;EAOrC,SAAA;EAEA,KAAA,GAAQ,KAAA,eAAoB,KAAA;EAE5B,GAAA;EAEA,IAAA;EAWW;;;;EANX,eAAA;;;;EAIA,SAAA,GAAY,SAAA;EAEZ,SAAA,EAAW,SAAA;EAEX,IAAA;AAAA;AAAA,KAKU,MAAA,mBACQ,SAAA,GAAY,SAAA,gBAChB,KAAA,eAAoB,KAAA,8BAClB,OAAA,eAAsB,OAAA,gCACpB,SAAA,2CACD,QAAA,eAAuB,QAAA,gBACtC,WAAA,CAAY,SAAA,EAAW,KAAA,EAAO,OAAA,EAAS,SAAA,KACxC,QAAA,SAAiB,QAAA,GAAW,QAAA;EAC3B,MAAA,wBAA8B,QAAA,EAC5B,EAAA,GACE,MAAA,EAAQ,MAAA,CAAO,SAAA,EAAW,KAAA,EAAO,OAAA,EAAS,SAAA,EAAW,QAAA,MAClD,MAAA,KACF,MAAA,CACH,SAAA,EACA,KAAA,EACA,OAAA,EACA,SAAA,EACA,QAAA,CAAS,MAAA,KAAW,QAAA,SAAiB,QAAA,GAAW,QAAA;AAAA;AAAA,KAIjD,WAAA,mBACe,SAAA,GAAY,SAAA,gBAChB,KAAA,eAAoB,KAAA,8BAClB,OAAA,eAAsB,OAAA,gCACpB,SAAA;mCAGlB,OAAA,EAAS,OAAA;EAET,SAAA;EAEA,KAAA,EAAO,KAAA,EArCP;EAuCA,GAAA,UAlCU;EAoCV,IAAA;EAEA,eAAA;EAEA,OAAA,EAAS,eAAA,CACP,SAAA,qBAA8B,iBAAA,GAAoB,SAAA;EAGpD,SAAA,EAAW,UAAA,CAAW,SAAA,cAAuB,UAAA,CAAW,SAAA;EAExD,IAAA;EAEA,GAAA;AAAA;AAAA,KAGG,QAAA,GAAW,QAAA,eAEA,WAAA;EAAA;;KAKJ,qBAAA;4EAEV,SAAA;EAEA,IAAA;AAAA;AAAA,KAGU,qBAAA,GAAwB,SAAA;AAAA,iBAEpB,YAAA,mBACI,SAAA,gBACJ,KAAA,mDACW,OAAA,GAAU,OAAA,4CACjB,SAAA,
|
|
1
|
+
{"version":3,"file":"createClient.d.ts","names":[],"sources":["../../../src/factories/createClient.ts"],"mappings":";;;;;;;;;;KAYY,YAAA,mBACQ,SAAA,GAAY,SAAA,gBAChB,KAAA,eAAoB,KAAA,uCACT,OAAA,GAAU,OAAA,eAC/B,OAAA,GACA,OAAA,gCAEc,SAAA;iHAGlB,OAAA,GAAU,gBAAA,GAAmB,OAAA,GAAU,OAAA;EAEvC,KAAA;IATmC,yDAY7B,SAAA,aAAsB,QAAA,CAAS,qBAAA;EAAA;;;;;EAOrC,SAAA;EAEA,KAAA,GAAQ,KAAA,eAAoB,KAAA;EAE5B,GAAA;EAEA,IAAA;EAWW;;;;EANX,eAAA;;;;EAIA,SAAA,GAAY,SAAA;EAEZ,SAAA,EAAW,SAAA;EAEX,IAAA;AAAA;AAAA,KAKU,MAAA,mBACQ,SAAA,GAAY,SAAA,gBAChB,KAAA,eAAoB,KAAA,8BAClB,OAAA,eAAsB,OAAA,gCACpB,SAAA,2CACD,QAAA,eAAuB,QAAA,gBACtC,WAAA,CAAY,SAAA,EAAW,KAAA,EAAO,OAAA,EAAS,SAAA,KACxC,QAAA,SAAiB,QAAA,GAAW,QAAA;EAC3B,MAAA,wBAA8B,QAAA,EAC5B,EAAA,GACE,MAAA,EAAQ,MAAA,CAAO,SAAA,EAAW,KAAA,EAAO,OAAA,EAAS,SAAA,EAAW,QAAA,MAClD,MAAA,KACF,MAAA,CACH,SAAA,EACA,KAAA,EACA,OAAA,EACA,SAAA,EACA,QAAA,CAAS,MAAA,KAAW,QAAA,SAAiB,QAAA,GAAW,QAAA;AAAA;AAAA,KAIjD,WAAA,mBACe,SAAA,GAAY,SAAA,gBAChB,KAAA,eAAoB,KAAA,8BAClB,OAAA,eAAsB,OAAA,gCACpB,SAAA;mCAGlB,OAAA,EAAS,OAAA;EAET,SAAA;EAEA,KAAA,EAAO,KAAA,EArCP;EAuCA,GAAA,UAlCU;EAoCV,IAAA;EAEA,eAAA;EAEA,OAAA,EAAS,eAAA,CACP,SAAA,qBAA8B,iBAAA,GAAoB,SAAA;EAGpD,SAAA,EAAW,UAAA,CAAW,SAAA,cAAuB,UAAA,CAAW,SAAA;EAExD,IAAA;EAEA,GAAA;AAAA;AAAA,KAGG,QAAA,GAAW,QAAA,eAEA,WAAA;EAAA;;KAKJ,qBAAA;4EAEV,SAAA;EAEA,IAAA;AAAA;AAAA,KAGU,qBAAA,GAAwB,SAAA;AAAA,iBAEpB,YAAA,mBACI,SAAA,gBACJ,KAAA,mDACW,OAAA,GAAU,OAAA,4CACjB,SAAA,0BAElB,UAAA,EAAY,YAAA,CAAa,SAAA,EAAW,KAAA,EAAO,gBAAA,EAAkB,SAAA,IAC5D,QAAA,CACD,MAAA,CACE,SAAA,EACA,KAAA,EACA,gBAAA,SAAyB,OAAA,GAAU,QAAA,CAAS,OAAA,IAAW,gBAAA,EACvD,SAAA;;;;;iBAyDY,SAAA,mBAA4B,SAAA,KAAc,SAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createClient.js","names":[],"sources":["../../../src/factories/createClient.ts"],"sourcesContent":["import type { ErrorType } from '../errors/utils.js'\nimport type { Account } from '../types/account.js'\nimport type { Address } from '../types/address.js'\nimport type { Chain } from '../types/chain.js'\nimport type { BtcRpcRequestFn, RpcSchema } from '../types/request.js'\nimport type { BitcoinRpcMethods } from '../types/rpc.js'\nimport type { Transport } from '../types/transport.js'\nimport type { Prettify } from '../types/utils.js'\n\nimport { parseAccount } from '../utils/parseAccount.js'\nimport { uid } from '../utils/uid.js'\n\nexport type ClientConfig<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n accountOrAddress extends Account | Address | undefined =\n | Account\n | Address\n | undefined,\n rpcSchema extends RpcSchema | undefined = undefined,\n> = {\n /** The Account to use for the Client. This will be used for Actions that require an account as an argument. */\n account?: accountOrAddress | Account | Address | undefined\n /** Flags for batch settings. */\n batch?:\n | {\n /** Toggle to enable `eth_call` multicall aggregation. */\n multicall?: boolean | Prettify<MulticallBatchOptions> | undefined\n }\n | undefined\n /**\n * Time (in ms) that cached data will remain in memory.\n * @default 4_000\n */\n cacheTime?: number | undefined\n /** Chain for the client. */\n chain?: Chain | undefined | chain\n /** A key for the client. */\n key?: string | undefined\n /** A name for the client. */\n name?: string | undefined\n /**\n * Frequency (in ms) for polling enabled actions & events.\n * @default 4_000\n */\n pollingInterval?: number | undefined\n /**\n * Typed JSON-RPC schema for the client.\n */\n rpcSchema?: rpcSchema | undefined\n /** The RPC transport */\n transport: transport\n /** The type of client. */\n type?: string | undefined\n}\n\n// TODO: Move `transport` to slot index 2 since `chain` and `account` used more frequently.\n// Otherwise, we end up with a lot of `Client<Transport, chain, account>` in actions.\nexport type Client<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends Account | undefined = Account | undefined,\n rpcSchema extends RpcSchema | undefined = undefined,\n extended extends Extended | undefined = Extended | undefined,\n> = Client_Base<transport, chain, account, rpcSchema> &\n (extended extends Extended ? extended : unknown) & {\n extend: <const client extends Extended>(\n fn: (\n client: Client<transport, chain, account, rpcSchema, extended>\n ) => client\n ) => Client<\n transport,\n chain,\n account,\n rpcSchema,\n Prettify<client> & (extended extends Extended ? extended : unknown)\n >\n }\n\ntype Client_Base<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends Account | undefined = Account | undefined,\n rpcSchema extends RpcSchema | undefined = undefined,\n> = {\n /** The Account of the Client. */\n account: account\n /** Time (in ms) that cached data will remain in memory. */\n cacheTime: number\n /** Chain for the client. */\n chain: chain\n /** A key for the client. */\n key: string\n /** A name for the client. */\n name: string\n /** Frequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds. */\n pollingInterval: number\n /** Request function wrapped with friendly error handling */\n request: BtcRpcRequestFn<\n rpcSchema extends undefined ? BitcoinRpcMethods : rpcSchema\n >\n /** The RPC transport */\n transport: ReturnType<transport>['config'] & ReturnType<transport>['value']\n /** The type of client. */\n type: string\n /** A unique ID for the client. */\n uid: string\n}\n\ntype Extended = Prettify<\n // disallow redefining base properties\n { [_ in keyof Client_Base]?: undefined } & {\n [key: string]: unknown\n }\n>\n\nexport type MulticallBatchOptions = {\n /** The maximum size (in bytes) for each calldata chunk. @default 1_024 */\n batchSize?: number | undefined\n /** The maximum number of milliseconds to wait before sending a batch. @default 0 */\n wait?: number | undefined\n}\n\nexport type CreateClientErrorType = ErrorType\n\nexport function createClient<\n transport extends Transport,\n chain extends Chain | undefined = undefined,\n accountOrAddress extends Account | Address | undefined = undefined,\n rpcSchema extends RpcSchema | undefined = undefined,\n>(\n parameters: ClientConfig<transport, chain, accountOrAddress, rpcSchema>\n): Prettify<\n Client<\n transport,\n chain,\n accountOrAddress extends Address ? Prettify<Account> : accountOrAddress,\n rpcSchema\n >\n>\n\nexport function createClient(parameters: ClientConfig): Client {\n const {\n cacheTime = parameters.pollingInterval ?? 4_000,\n\n key = 'base',\n name = 'Base Client',\n pollingInterval = 4_000,\n type = 'base',\n } = parameters\n\n const chain = parameters.chain\n const account = parameters.account\n ? parseAccount(parameters.account)\n : undefined\n const { config, request, value } = parameters.transport({\n chain,\n pollingInterval,\n })\n const transport = { ...config, ...value }\n\n const client = {\n account,\n cacheTime,\n\n chain,\n key,\n name,\n pollingInterval,\n request,\n transport,\n type,\n uid: uid(),\n }\n\n function extend(base: typeof client) {\n type ExtendFn = (base: typeof client) => unknown\n return (extendFn: ExtendFn) => {\n const extended = extendFn(base) as Extended\n for (const key in client) {\n delete extended[key]\n }\n const combined = { ...base, ...extended }\n return Object.assign(combined, { extend: extend(combined as any) })\n }\n }\n\n return Object.assign(client, { extend: extend(client) as any })\n}\n\n/**\n * Defines a typed JSON-RPC schema for the client.\n * Note: This is a runtime noop function.\n */\nexport function rpcSchema<rpcSchema extends RpcSchema>(): rpcSchema {\n return null as any\n}\n"],"mappings":";;;AA6IA,SAAgB,aAAa,YAAkC;CAC7D,MAAM,EACJ,YAAY,WAAW,mBAAmB,KAE1C,MAAM,QACN,OAAO,eACP,kBAAkB,KAClB,OAAO,WACL;CAEJ,MAAM,QAAQ,WAAW;CACzB,MAAM,UAAU,WAAW,UACvB,aAAa,WAAW,
|
|
1
|
+
{"version":3,"file":"createClient.js","names":[],"sources":["../../../src/factories/createClient.ts"],"sourcesContent":["import type { ErrorType } from '../errors/utils.js'\nimport type { Account } from '../types/account.js'\nimport type { Address } from '../types/address.js'\nimport type { Chain } from '../types/chain.js'\nimport type { BtcRpcRequestFn, RpcSchema } from '../types/request.js'\nimport type { BitcoinRpcMethods } from '../types/rpc.js'\nimport type { Transport } from '../types/transport.js'\nimport type { Prettify } from '../types/utils.js'\n\nimport { parseAccount } from '../utils/parseAccount.js'\nimport { uid } from '../utils/uid.js'\n\nexport type ClientConfig<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n accountOrAddress extends Account | Address | undefined =\n | Account\n | Address\n | undefined,\n rpcSchema extends RpcSchema | undefined = undefined,\n> = {\n /** The Account to use for the Client. This will be used for Actions that require an account as an argument. */\n account?: accountOrAddress | Account | Address | undefined\n /** Flags for batch settings. */\n batch?:\n | {\n /** Toggle to enable `eth_call` multicall aggregation. */\n multicall?: boolean | Prettify<MulticallBatchOptions> | undefined\n }\n | undefined\n /**\n * Time (in ms) that cached data will remain in memory.\n * @default 4_000\n */\n cacheTime?: number | undefined\n /** Chain for the client. */\n chain?: Chain | undefined | chain\n /** A key for the client. */\n key?: string | undefined\n /** A name for the client. */\n name?: string | undefined\n /**\n * Frequency (in ms) for polling enabled actions & events.\n * @default 4_000\n */\n pollingInterval?: number | undefined\n /**\n * Typed JSON-RPC schema for the client.\n */\n rpcSchema?: rpcSchema | undefined\n /** The RPC transport */\n transport: transport\n /** The type of client. */\n type?: string | undefined\n}\n\n// TODO: Move `transport` to slot index 2 since `chain` and `account` used more frequently.\n// Otherwise, we end up with a lot of `Client<Transport, chain, account>` in actions.\nexport type Client<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends Account | undefined = Account | undefined,\n rpcSchema extends RpcSchema | undefined = undefined,\n extended extends Extended | undefined = Extended | undefined,\n> = Client_Base<transport, chain, account, rpcSchema> &\n (extended extends Extended ? extended : unknown) & {\n extend: <const client extends Extended>(\n fn: (\n client: Client<transport, chain, account, rpcSchema, extended>\n ) => client\n ) => Client<\n transport,\n chain,\n account,\n rpcSchema,\n Prettify<client> & (extended extends Extended ? extended : unknown)\n >\n }\n\ntype Client_Base<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends Account | undefined = Account | undefined,\n rpcSchema extends RpcSchema | undefined = undefined,\n> = {\n /** The Account of the Client. */\n account: account\n /** Time (in ms) that cached data will remain in memory. */\n cacheTime: number\n /** Chain for the client. */\n chain: chain\n /** A key for the client. */\n key: string\n /** A name for the client. */\n name: string\n /** Frequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds. */\n pollingInterval: number\n /** Request function wrapped with friendly error handling */\n request: BtcRpcRequestFn<\n rpcSchema extends undefined ? BitcoinRpcMethods : rpcSchema\n >\n /** The RPC transport */\n transport: ReturnType<transport>['config'] & ReturnType<transport>['value']\n /** The type of client. */\n type: string\n /** A unique ID for the client. */\n uid: string\n}\n\ntype Extended = Prettify<\n // disallow redefining base properties\n { [_ in keyof Client_Base]?: undefined } & {\n [key: string]: unknown\n }\n>\n\nexport type MulticallBatchOptions = {\n /** The maximum size (in bytes) for each calldata chunk. @default 1_024 */\n batchSize?: number | undefined\n /** The maximum number of milliseconds to wait before sending a batch. @default 0 */\n wait?: number | undefined\n}\n\nexport type CreateClientErrorType = ErrorType\n\nexport function createClient<\n transport extends Transport,\n chain extends Chain | undefined = undefined,\n accountOrAddress extends Account | Address | undefined = undefined,\n rpcSchema extends RpcSchema | undefined = undefined,\n>(\n parameters: ClientConfig<transport, chain, accountOrAddress, rpcSchema>\n): Prettify<\n Client<\n transport,\n chain,\n accountOrAddress extends Address ? Prettify<Account> : accountOrAddress,\n rpcSchema\n >\n>\n\nexport function createClient(parameters: ClientConfig): Client {\n const {\n cacheTime = parameters.pollingInterval ?? 4_000,\n\n key = 'base',\n name = 'Base Client',\n pollingInterval = 4_000,\n type = 'base',\n } = parameters\n\n const chain = parameters.chain\n const account = parameters.account\n ? parseAccount(parameters.account)\n : undefined\n const { config, request, value } = parameters.transport({\n chain,\n pollingInterval,\n })\n const transport = { ...config, ...value }\n\n const client = {\n account,\n cacheTime,\n\n chain,\n key,\n name,\n pollingInterval,\n request,\n transport,\n type,\n uid: uid(),\n }\n\n function extend(base: typeof client) {\n type ExtendFn = (base: typeof client) => unknown\n return (extendFn: ExtendFn) => {\n const extended = extendFn(base) as Extended\n for (const key in client) {\n delete extended[key]\n }\n const combined = { ...base, ...extended }\n return Object.assign(combined, { extend: extend(combined as any) })\n }\n }\n\n return Object.assign(client, { extend: extend(client) as any })\n}\n\n/**\n * Defines a typed JSON-RPC schema for the client.\n * Note: This is a runtime noop function.\n */\nexport function rpcSchema<rpcSchema extends RpcSchema>(): rpcSchema {\n return null as any\n}\n"],"mappings":";;;AA6IA,SAAgB,aAAa,YAAkC;CAC7D,MAAM,EACJ,YAAY,WAAW,mBAAmB,KAE1C,MAAM,QACN,OAAO,eACP,kBAAkB,KAClB,OAAO,WACL;CAEJ,MAAM,QAAQ,WAAW;CACzB,MAAM,UAAU,WAAW,UACvB,aAAa,WAAW,OAAO,IAC/B,KAAA;CACJ,MAAM,EAAE,QAAQ,SAAS,UAAU,WAAW,UAAU;EACtD;EACA;CACF,CAAC;CAGD,MAAM,SAAS;EACb;EACA;EAEA;EACA;EACA;EACA;EACA;EACA,WAAA;GAXkB,GAAG;GAAQ,GAAG;EAWxB;EACR;EACA,KAAK,IAAI;CACX;CAEA,SAAS,OAAO,MAAqB;EAEnC,QAAQ,aAAuB;GAC7B,MAAM,WAAW,SAAS,IAAI;GAC9B,KAAK,MAAM,OAAO,QAChB,OAAO,SAAS;GAElB,MAAM,WAAW;IAAE,GAAG;IAAM,GAAG;GAAS;GACxC,OAAO,OAAO,OAAO,UAAU,EAAE,QAAQ,OAAO,QAAe,EAAE,CAAC;EACpE;CACF;CAEA,OAAO,OAAO,OAAO,QAAQ,EAAE,QAAQ,OAAO,MAAM,EAAS,CAAC;AAChE;;;;;AAMA,SAAgB,YAAoD;CAClE,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTransport.d.ts","names":[],"sources":["../../../src/factories/createTransport.ts"],"mappings":";;;;;AAOA;iBAAgB,eAAA,4CAEQ,MAAA
|
|
1
|
+
{"version":3,"file":"createTransport.d.ts","names":[],"sources":["../../../src/factories/createTransport.ts"],"mappings":";;;;;AAOA;iBAAgB,eAAA,4CAEQ,MAAA;EAGpB,GAAA;EACA,OAAA;EACA,IAAA;EACA,OAAA;EACA,UAAA;EACA,UAAA;EACA,OAAA;EACA;AAAA,GACC,eAAA,CAAgB,IAAA,GACnB,KAAA,GAAQ,aAAA,eACP,UAAA,CAAW,SAAA,CAAU,IAAA,EAAM,aAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTransport.js","names":["uid","uid_"],"sources":["../../../src/factories/createTransport.ts"],"sourcesContent":["import type { Transport, TransportConfig } from '../types/transport.js'\nimport { buildRequest } from '../utils/buildRequest.js'\nimport { uid as uid_ } from '../utils/uid.js'\n\n/**\n * @description Creates an transport intended to be used with a client.\n */\nexport function createTransport<\n type extends string,\n rpcAttributes extends Record<string, any>,\n>(\n {\n key,\n methods,\n name,\n request,\n retryCount = 3,\n retryDelay = 150,\n timeout,\n type,\n }: TransportConfig<type>,\n value?: rpcAttributes | undefined\n): ReturnType<Transport<type, rpcAttributes>> {\n const uid = uid_()\n return {\n config: {\n key,\n methods,\n name,\n request,\n retryCount,\n retryDelay,\n timeout,\n type,\n },\n request: buildRequest(request, { methods, retryCount, retryDelay, uid }),\n value,\n }\n}\n"],"mappings":";;;;;;AAOA,SAAgB,gBAId,EACE,KACA,SACA,MACA,SACA,aAAa,GACb,aAAa,KACb,SACA,QAEF,OAC4C;CAC5C,MAAMA,QAAMC,
|
|
1
|
+
{"version":3,"file":"createTransport.js","names":["uid","uid_"],"sources":["../../../src/factories/createTransport.ts"],"sourcesContent":["import type { Transport, TransportConfig } from '../types/transport.js'\nimport { buildRequest } from '../utils/buildRequest.js'\nimport { uid as uid_ } from '../utils/uid.js'\n\n/**\n * @description Creates an transport intended to be used with a client.\n */\nexport function createTransport<\n type extends string,\n rpcAttributes extends Record<string, any>,\n>(\n {\n key,\n methods,\n name,\n request,\n retryCount = 3,\n retryDelay = 150,\n timeout,\n type,\n }: TransportConfig<type>,\n value?: rpcAttributes | undefined\n): ReturnType<Transport<type, rpcAttributes>> {\n const uid = uid_()\n return {\n config: {\n key,\n methods,\n name,\n request,\n retryCount,\n retryDelay,\n timeout,\n type,\n },\n request: buildRequest(request, { methods, retryCount, retryDelay, uid }),\n value,\n }\n}\n"],"mappings":";;;;;;AAOA,SAAgB,gBAId,EACE,KACA,SACA,MACA,SACA,aAAa,GACb,aAAa,KACb,SACA,QAEF,OAC4C;CAC5C,MAAMA,QAAMC,IAAK;CACjB,OAAO;EACL,QAAQ;GACN;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF;EACA,SAAS,aAAa,SAAS;GAAE;GAAS;GAAY;GAAY,KAAA;EAAI,CAAC;EACvE;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../../../src/test/utils.ts"],"sourcesContent":["export const createMockResponse = <T>(\n data: T,\n options?: Partial<Response>\n): Response =>\n ({\n ok: true,\n json: () => Promise.resolve(data),\n headers: new Headers({\n 'Content-type': 'application/json',\n }),\n ...options,\n }) as Response\n"],"mappings":";AAAA,MAAa,sBACX,MACA,aAEC;CACC,IAAI;CACJ,YAAY,QAAQ,QAAQ,
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../../src/test/utils.ts"],"sourcesContent":["export const createMockResponse = <T>(\n data: T,\n options?: Partial<Response>\n): Response =>\n ({\n ok: true,\n json: () => Promise.resolve(data),\n headers: new Headers({\n 'Content-type': 'application/json',\n }),\n ...options,\n }) as Response\n"],"mappings":";AAAA,MAAa,sBACX,MACA,aAEC;CACC,IAAI;CACJ,YAAY,QAAQ,QAAQ,IAAI;CAChC,SAAS,IAAI,QAAQ,EACnB,gBAAgB,mBAClB,CAAC;CACD,GAAG;AACL"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ankr.js","names":[],"sources":["../../../../src/transports/ankr/ankr.ts"],"sourcesContent":["import type { TransportConfig } from '../../types/transport.js'\nimport type { HttpTransport, HttpTransportConfig } from '../http.js'\nimport type { UTXOMethod } from '../types.js'\nimport { utxo } from '../utxo.js'\nimport { ankrMethods } from './methods.js'\n\ntype AnkrConfig = { baseUrl?: string; apiKey?: string } & HttpTransportConfig\n\nexport const ankr = (config?: AnkrConfig): HttpTransport => {\n const methods: TransportConfig['methods'] = {\n include: Object.keys(ankrMethods) as UTXOMethod[],\n }\n if (config?.baseUrl) {\n return utxo(config.baseUrl, { key: 'ankr', ...config, methods })\n }\n\n if (!config?.apiKey) {\n throw Error('Ankr API KEY is required')\n }\n return utxo(\n `https://rpc.ankr.com/premium-http/btc_blockbook/${config.apiKey}/api/v2`,\n {\n name: 'Ankr API',\n key: 'ankr',\n methods,\n ...config,\n }\n )\n}\n"],"mappings":";;;AAQA,MAAa,QAAQ,WAAuC;CAC1D,MAAM,UAAsC,EAC1C,SAAS,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"ankr.js","names":[],"sources":["../../../../src/transports/ankr/ankr.ts"],"sourcesContent":["import type { TransportConfig } from '../../types/transport.js'\nimport type { HttpTransport, HttpTransportConfig } from '../http.js'\nimport type { UTXOMethod } from '../types.js'\nimport { utxo } from '../utxo.js'\nimport { ankrMethods } from './methods.js'\n\ntype AnkrConfig = { baseUrl?: string; apiKey?: string } & HttpTransportConfig\n\nexport const ankr = (config?: AnkrConfig): HttpTransport => {\n const methods: TransportConfig['methods'] = {\n include: Object.keys(ankrMethods) as UTXOMethod[],\n }\n if (config?.baseUrl) {\n return utxo(config.baseUrl, { key: 'ankr', ...config, methods })\n }\n\n if (!config?.apiKey) {\n throw Error('Ankr API KEY is required')\n }\n return utxo(\n `https://rpc.ankr.com/premium-http/btc_blockbook/${config.apiKey}/api/v2`,\n {\n name: 'Ankr API',\n key: 'ankr',\n methods,\n ...config,\n }\n )\n}\n"],"mappings":";;;AAQA,MAAa,QAAQ,WAAuC;CAC1D,MAAM,UAAsC,EAC1C,SAAS,OAAO,KAAK,WAAW,EAClC;CACA,IAAI,QAAQ,SACV,OAAO,KAAK,OAAO,SAAS;EAAE,KAAK;EAAQ,GAAG;EAAQ;CAAQ,CAAC;CAGjE,IAAI,CAAC,QAAQ,QACX,MAAM,MAAM,0BAA0B;CAExC,OAAO,KACL,mDAAmD,OAAO,OAAO,UACjE;EACE,MAAM;EACN,KAAK;EACL;EACA,GAAG;CACL,CACF;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "../../errors/rpc.js";
|
|
2
2
|
//#region src/transports/ankr/getBalance.ts
|
|
3
3
|
const getBalance = async (client, { baseUrl }, { address }) => {
|
|
4
4
|
const apiUrl = `${baseUrl}/address/${address}?details=basic`;
|
|
@@ -7,7 +7,7 @@ const getBalance = async (client, { baseUrl }, { address }) => {
|
|
|
7
7
|
fetchOptions: { method: "GET" }
|
|
8
8
|
});
|
|
9
9
|
if (response.error) return { error: {
|
|
10
|
-
code:
|
|
10
|
+
code: -1,
|
|
11
11
|
message: response.error
|
|
12
12
|
} };
|
|
13
13
|
return { result: BigInt(response.balance) };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBalance.js","names":[],"sources":["../../../../src/transports/ankr/getBalance.ts"],"sourcesContent":["import { RpcErrorCode } from '../../errors/rpc.js'\nimport type { RpcMethodHandler } from '../types.js'\nimport type { AnkrBalanceResponse } from './ankr.types.js'\n\nexport const getBalance: RpcMethodHandler<'getBalance'> = async (\n client,\n { baseUrl },\n { address }\n) => {\n const apiUrl = `${baseUrl}/address/${address}?details=basic`\n\n const response = (await client.request({\n url: apiUrl,\n fetchOptions: {\n method: 'GET',\n },\n })) as unknown as AnkrBalanceResponse\n if (response.error) {\n return {\n error: { code: RpcErrorCode.MISC_ERROR, message: response.error },\n }\n }\n return {\n result: BigInt(response.balance),\n }\n}\n"],"mappings":";;AAIA,MAAa,aAA6C,OACxD,QACA,EAAE,WACF,EAAE,cACC;CACH,MAAM,SAAS,GAAG,QAAQ,WAAW,QAAQ;CAE7C,MAAM,WAAY,MAAM,OAAO,QAAQ;EACrC,KAAK;EACL,cAAc,EACZ,QAAQ,
|
|
1
|
+
{"version":3,"file":"getBalance.js","names":[],"sources":["../../../../src/transports/ankr/getBalance.ts"],"sourcesContent":["import { RpcErrorCode } from '../../errors/rpc.js'\nimport type { RpcMethodHandler } from '../types.js'\nimport type { AnkrBalanceResponse } from './ankr.types.js'\n\nexport const getBalance: RpcMethodHandler<'getBalance'> = async (\n client,\n { baseUrl },\n { address }\n) => {\n const apiUrl = `${baseUrl}/address/${address}?details=basic`\n\n const response = (await client.request({\n url: apiUrl,\n fetchOptions: {\n method: 'GET',\n },\n })) as unknown as AnkrBalanceResponse\n if (response.error) {\n return {\n error: { code: RpcErrorCode.MISC_ERROR, message: response.error },\n }\n }\n return {\n result: BigInt(response.balance),\n }\n}\n"],"mappings":";;AAIA,MAAa,aAA6C,OACxD,QACA,EAAE,WACF,EAAE,cACC;CACH,MAAM,SAAS,GAAG,QAAQ,WAAW,QAAQ;CAE7C,MAAM,WAAY,MAAM,OAAO,QAAQ;EACrC,KAAK;EACL,cAAc,EACZ,QAAQ,MACV;CACF,CAAC;CACD,IAAI,SAAS,OACX,OAAO,EACL,OAAO;EAAE,MAAA;EAA+B,SAAS,SAAS;CAAM,EAClE;CAEF,OAAO,EACL,QAAQ,OAAO,SAAS,OAAO,EACjC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTransactionFee.js","names":[],"sources":["../../../../src/transports/ankr/getTransactionFee.ts"],"sourcesContent":["import type { RpcMethodHandler } from '../types.js'\nimport type { AnkrTxnResponse } from './ankr.types.js'\n\nexport const getTransactionFee: RpcMethodHandler<'getTransactionFee'> = async (\n client,\n { baseUrl },\n { txId }\n) => {\n const apiUrl = `${baseUrl}/tx/${txId}`\n const response = (await client.request({\n url: apiUrl,\n fetchOptions: { method: 'GET' },\n })) as unknown as AnkrTxnResponse\n if (response.error) {\n return { error: response.error }\n }\n\n return {\n result: BigInt(response.fees),\n }\n}\n"],"mappings":";AAGA,MAAa,oBAA2D,OACtE,QACA,EAAE,WACF,EAAE,WACC;CACH,MAAM,SAAS,GAAG,QAAQ,MAAM;CAChC,MAAM,WAAY,MAAM,OAAO,QAAQ;EACrC,KAAK;EACL,cAAc,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"getTransactionFee.js","names":[],"sources":["../../../../src/transports/ankr/getTransactionFee.ts"],"sourcesContent":["import type { RpcMethodHandler } from '../types.js'\nimport type { AnkrTxnResponse } from './ankr.types.js'\n\nexport const getTransactionFee: RpcMethodHandler<'getTransactionFee'> = async (\n client,\n { baseUrl },\n { txId }\n) => {\n const apiUrl = `${baseUrl}/tx/${txId}`\n const response = (await client.request({\n url: apiUrl,\n fetchOptions: { method: 'GET' },\n })) as unknown as AnkrTxnResponse\n if (response.error) {\n return { error: response.error }\n }\n\n return {\n result: BigInt(response.fees),\n }\n}\n"],"mappings":";AAGA,MAAa,oBAA2D,OACtE,QACA,EAAE,WACF,EAAE,WACC;CACH,MAAM,SAAS,GAAG,QAAQ,MAAM;CAChC,MAAM,WAAY,MAAM,OAAO,QAAQ;EACrC,KAAK;EACL,cAAc,EAAE,QAAQ,MAAM;CAChC,CAAC;CACD,IAAI,SAAS,OACX,OAAO,EAAE,OAAO,SAAS,MAAM;CAGjC,OAAO,EACL,QAAQ,OAAO,SAAS,IAAI,EAC9B;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTransactions.js","names":[],"sources":["../../../../src/transports/ankr/getTransactions.ts"],"sourcesContent":["import { urlWithParams } from '../../utils/url.js'\nimport type { RpcMethodHandler } from '../types.js'\nimport type { AnkrAddressWithTxnsResponse } from './ankr.types.js'\nimport { ankrTransactionTransformer } from './utils.js'\n\nexport const getTransactions: RpcMethodHandler<'getTransactions'> = async (\n client,\n { baseUrl },\n { address, limit = 50, offset = 0, lastBlock }\n) => {\n const apiUrl = urlWithParams(`${baseUrl}/address/${address}`, {\n details: 'txs',\n pageSize: limit,\n to: lastBlock,\n })\n\n const response = (await client.request({\n url: apiUrl,\n fetchOptions: { method: 'GET' },\n })) as unknown as AnkrAddressWithTxnsResponse\n\n if (response.error) {\n return { error: response.error }\n }\n\n const total = response.txs || 0\n const page = Math.floor(offset / limit) + 1\n const hasMore = total > offset + response.transactions.length\n\n const data = {\n transactions: response.transactions.map(ankrTransactionTransformer),\n total,\n page,\n itemsPerPage: limit,\n hasMore,\n }\n\n return { result: data }\n}\n"],"mappings":";;;AAKA,MAAa,kBAAuD,OAClE,QACA,EAAE,WACF,EAAE,SAAS,QAAQ,IAAI,SAAS,GAAG,gBAChC;CACH,MAAM,SAAS,cAAc,GAAG,QAAQ,WAAW,WAAW;EAC5D,SAAS;EACT,UAAU;EACV,IAAI;
|
|
1
|
+
{"version":3,"file":"getTransactions.js","names":[],"sources":["../../../../src/transports/ankr/getTransactions.ts"],"sourcesContent":["import { urlWithParams } from '../../utils/url.js'\nimport type { RpcMethodHandler } from '../types.js'\nimport type { AnkrAddressWithTxnsResponse } from './ankr.types.js'\nimport { ankrTransactionTransformer } from './utils.js'\n\nexport const getTransactions: RpcMethodHandler<'getTransactions'> = async (\n client,\n { baseUrl },\n { address, limit = 50, offset = 0, lastBlock }\n) => {\n const apiUrl = urlWithParams(`${baseUrl}/address/${address}`, {\n details: 'txs',\n pageSize: limit,\n to: lastBlock,\n })\n\n const response = (await client.request({\n url: apiUrl,\n fetchOptions: { method: 'GET' },\n })) as unknown as AnkrAddressWithTxnsResponse\n\n if (response.error) {\n return { error: response.error }\n }\n\n const total = response.txs || 0\n const page = Math.floor(offset / limit) + 1\n const hasMore = total > offset + response.transactions.length\n\n const data = {\n transactions: response.transactions.map(ankrTransactionTransformer),\n total,\n page,\n itemsPerPage: limit,\n hasMore,\n }\n\n return { result: data }\n}\n"],"mappings":";;;AAKA,MAAa,kBAAuD,OAClE,QACA,EAAE,WACF,EAAE,SAAS,QAAQ,IAAI,SAAS,GAAG,gBAChC;CACH,MAAM,SAAS,cAAc,GAAG,QAAQ,WAAW,WAAW;EAC5D,SAAS;EACT,UAAU;EACV,IAAI;CACN,CAAC;CAED,MAAM,WAAY,MAAM,OAAO,QAAQ;EACrC,KAAK;EACL,cAAc,EAAE,QAAQ,MAAM;CAChC,CAAC;CAED,IAAI,SAAS,OACX,OAAO,EAAE,OAAO,SAAS,MAAM;CAGjC,MAAM,QAAQ,SAAS,OAAO;CAC9B,MAAM,OAAO,KAAK,MAAM,SAAS,KAAK,IAAI;CAC1C,MAAM,UAAU,QAAQ,SAAS,SAAS,aAAa;CAUvD,OAAO,EAAE,QAAQ;EAPf,cAAc,SAAS,aAAa,IAAI,0BAA0B;EAClE;EACA;EACA,cAAc;EACd;CAGkB,EAAE;AACxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"methods.js","names":[],"sources":["../../../../src/transports/ankr/methods.ts"],"sourcesContent":["import type { RpcMethods } from '../types.js'\nimport { getBalance } from './getBalance.js'\nimport { getTransactionFee } from './getTransactionFee.js'\nimport { getTransactions } from './getTransactions.js'\n\nexport const ankrMethods: RpcMethods = {\n getBalance,\n getTransactions,\n getTransactionFee,\n}\n"],"mappings":";;;;AAKA,MAAa,cAA0B;CACrC;CACA;CACA;
|
|
1
|
+
{"version":3,"file":"methods.js","names":[],"sources":["../../../../src/transports/ankr/methods.ts"],"sourcesContent":["import type { RpcMethods } from '../types.js'\nimport { getBalance } from './getBalance.js'\nimport { getTransactionFee } from './getTransactionFee.js'\nimport { getTransactions } from './getTransactions.js'\n\nexport const ankrMethods: RpcMethods = {\n getBalance,\n getTransactions,\n getTransactionFee,\n}\n"],"mappings":";;;;AAKA,MAAa,cAA0B;CACrC;CACA;CACA;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../../../../src/transports/ankr/utils.ts"],"sourcesContent":["import type { UTXOTransaction } from '../../types/transaction.js'\nimport type { AnkrTransaction } from './ankr.types.js'\n\nexport const ankrTransactionTransformer = (\n txn: AnkrTransaction\n): Partial<UTXOTransaction> => ({\n blockhash: txn?.blockHash,\n blocktime: txn.blockTime,\n confirmations: txn.confirmations,\n hex: txn.hex,\n locktime: txn?.coinSpecificData?.locktime,\n hash: txn.coinSpecificData?.hash,\n size: txn.size,\n txid: txn.txid,\n version: txn.version,\n vin: txn.vin.map((vin) => ({\n scriptSig: vin.scriptSig,\n sequence: vin.sequence,\n txid: vin.txid,\n vout: vin.vout,\n txinwitness: vin.addresses,\n })),\n vsize: txn.vsize,\n vout: txn.vout.map((vout) => ({\n n: vout.n,\n scriptPubKey: vout.scriptPubKey,\n value: vout.value,\n })),\n})\n"],"mappings":";AAGA,MAAa,8BACX,SAC8B;CAC9B,WAAW,KAAK;CAChB,WAAW,IAAI;CACf,eAAe,IAAI;CACnB,KAAK,IAAI;CACT,UAAU,KAAK,kBAAkB;CACjC,MAAM,IAAI,kBAAkB;CAC5B,MAAM,IAAI;CACV,MAAM,IAAI;CACV,SAAS,IAAI;CACb,KAAK,IAAI,IAAI,KAAK,SAAS;EACzB,WAAW,IAAI;EACf,UAAU,IAAI;EACd,MAAM,IAAI;EACV,MAAM,IAAI;EACV,aAAa,IAAI;
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../../../src/transports/ankr/utils.ts"],"sourcesContent":["import type { UTXOTransaction } from '../../types/transaction.js'\nimport type { AnkrTransaction } from './ankr.types.js'\n\nexport const ankrTransactionTransformer = (\n txn: AnkrTransaction\n): Partial<UTXOTransaction> => ({\n blockhash: txn?.blockHash,\n blocktime: txn.blockTime,\n confirmations: txn.confirmations,\n hex: txn.hex,\n locktime: txn?.coinSpecificData?.locktime,\n hash: txn.coinSpecificData?.hash,\n size: txn.size,\n txid: txn.txid,\n version: txn.version,\n vin: txn.vin.map((vin) => ({\n scriptSig: vin.scriptSig,\n sequence: vin.sequence,\n txid: vin.txid,\n vout: vin.vout,\n txinwitness: vin.addresses,\n })),\n vsize: txn.vsize,\n vout: txn.vout.map((vout) => ({\n n: vout.n,\n scriptPubKey: vout.scriptPubKey,\n value: vout.value,\n })),\n})\n"],"mappings":";AAGA,MAAa,8BACX,SAC8B;CAC9B,WAAW,KAAK;CAChB,WAAW,IAAI;CACf,eAAe,IAAI;CACnB,KAAK,IAAI;CACT,UAAU,KAAK,kBAAkB;CACjC,MAAM,IAAI,kBAAkB;CAC5B,MAAM,IAAI;CACV,MAAM,IAAI;CACV,SAAS,IAAI;CACb,KAAK,IAAI,IAAI,KAAK,SAAS;EACzB,WAAW,IAAI;EACf,UAAU,IAAI;EACd,MAAM,IAAI;EACV,MAAM,IAAI;EACV,aAAa,IAAI;CACnB,EAAE;CACF,OAAO,IAAI;CACX,MAAM,IAAI,KAAK,KAAK,UAAU;EAC5B,GAAG,KAAK;EACR,cAAc,KAAK;EACnB,OAAO,KAAK;CACd,EAAE;AACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blockchair.js","names":[],"sources":["../../../../src/transports/blockchair/blockchair.ts"],"sourcesContent":["import type { HttpTransport, HttpTransportConfig } from '../http.js'\nimport type { UTXOMethod } from '../types.js'\nimport { utxo } from '../utxo.js'\nimport { blockchairMethods } from './methods.js'\n\ntype BlockchairConfig = {\n baseUrl?: string\n apiKey?: string\n} & HttpTransportConfig\n\nexport const blockchair = (config?: BlockchairConfig): HttpTransport =>\n utxo(config?.baseUrl || 'https://api.blockchair.com', {\n name: 'Blockchair API',\n key: 'blockchair',\n includeChainToURL: true,\n methods: {\n include: Object.keys(blockchairMethods) as UTXOMethod[],\n },\n ...config,\n })\n"],"mappings":";;;AAUA,MAAa,cAAc,WACzB,KAAK,QAAQ,WAAW,8BAA8B;CACpD,MAAM;CACN,KAAK;CACL,mBAAmB;CACnB,SAAS,EACP,SAAS,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"blockchair.js","names":[],"sources":["../../../../src/transports/blockchair/blockchair.ts"],"sourcesContent":["import type { HttpTransport, HttpTransportConfig } from '../http.js'\nimport type { UTXOMethod } from '../types.js'\nimport { utxo } from '../utxo.js'\nimport { blockchairMethods } from './methods.js'\n\ntype BlockchairConfig = {\n baseUrl?: string\n apiKey?: string\n} & HttpTransportConfig\n\nexport const blockchair = (config?: BlockchairConfig): HttpTransport =>\n utxo(config?.baseUrl || 'https://api.blockchair.com', {\n name: 'Blockchair API',\n key: 'blockchair',\n includeChainToURL: true,\n methods: {\n include: Object.keys(blockchairMethods) as UTXOMethod[],\n },\n ...config,\n })\n"],"mappings":";;;AAUA,MAAa,cAAc,WACzB,KAAK,QAAQ,WAAW,8BAA8B;CACpD,MAAM;CACN,KAAK;CACL,mBAAmB;CACnB,SAAS,EACP,SAAS,OAAO,KAAK,iBAAiB,EACxC;CACA,GAAG;AACL,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "../../errors/rpc.js";
|
|
2
2
|
import { urlWithParams } from "../../utils/url.js";
|
|
3
3
|
//#region src/transports/blockchair/getBalance.ts
|
|
4
4
|
const getBalance = async (client, { baseUrl, apiKey }, { address }) => {
|
|
@@ -11,7 +11,7 @@ const getBalance = async (client, { baseUrl, apiKey }, { address }) => {
|
|
|
11
11
|
fetchOptions: { method: "GET" }
|
|
12
12
|
});
|
|
13
13
|
if (response.data[address] === void 0 || response.context.error || response.context?.code !== 200) return { error: {
|
|
14
|
-
code: response.context.code === 429 ?
|
|
14
|
+
code: response.context.code === 429 ? -32002 : -1,
|
|
15
15
|
message: response.context?.error
|
|
16
16
|
} };
|
|
17
17
|
return { result: BigInt(response.data[address]) };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBalance.js","names":[],"sources":["../../../../src/transports/blockchair/getBalance.ts"],"sourcesContent":["import { RpcErrorCode } from '../../errors/rpc.js'\nimport { urlWithParams } from '../../utils/url.js'\nimport type { RpcMethodHandler } from '../types.js'\nimport type {\n BlockchairAddressBalanceData,\n BlockchairResponse,\n} from './blockchair.types.js'\n\nexport const getBalance: RpcMethodHandler<'getBalance'> = async (\n client,\n { baseUrl, apiKey },\n { address }\n) => {\n const apiUrl = urlWithParams(`${baseUrl}/addresses/balances`, {\n key: apiKey,\n addresses: address,\n })\n const response = (await client.request({\n url: apiUrl,\n fetchOptions: { method: 'GET' },\n })) as unknown as BlockchairResponse<BlockchairAddressBalanceData>\n\n if (\n response.data[address] === undefined ||\n response.context.error ||\n response.context?.code !== 200\n ) {\n return {\n error: {\n code:\n response.context.code === 429\n ? RpcErrorCode.ACCESS_DENIED\n : RpcErrorCode.MISC_ERROR,\n message: response.context?.error,\n },\n }\n }\n\n return {\n result: BigInt(response.data[address]),\n }\n}\n"],"mappings":";;;AAQA,MAAa,aAA6C,OACxD,QACA,EAAE,SAAS,UACX,EAAE,cACC;CACH,MAAM,SAAS,cAAc,GAAG,QAAQ,sBAAsB;EAC5D,KAAK;EACL,WAAW;
|
|
1
|
+
{"version":3,"file":"getBalance.js","names":[],"sources":["../../../../src/transports/blockchair/getBalance.ts"],"sourcesContent":["import { RpcErrorCode } from '../../errors/rpc.js'\nimport { urlWithParams } from '../../utils/url.js'\nimport type { RpcMethodHandler } from '../types.js'\nimport type {\n BlockchairAddressBalanceData,\n BlockchairResponse,\n} from './blockchair.types.js'\n\nexport const getBalance: RpcMethodHandler<'getBalance'> = async (\n client,\n { baseUrl, apiKey },\n { address }\n) => {\n const apiUrl = urlWithParams(`${baseUrl}/addresses/balances`, {\n key: apiKey,\n addresses: address,\n })\n const response = (await client.request({\n url: apiUrl,\n fetchOptions: { method: 'GET' },\n })) as unknown as BlockchairResponse<BlockchairAddressBalanceData>\n\n if (\n response.data[address] === undefined ||\n response.context.error ||\n response.context?.code !== 200\n ) {\n return {\n error: {\n code:\n response.context.code === 429\n ? RpcErrorCode.ACCESS_DENIED\n : RpcErrorCode.MISC_ERROR,\n message: response.context?.error,\n },\n }\n }\n\n return {\n result: BigInt(response.data[address]),\n }\n}\n"],"mappings":";;;AAQA,MAAa,aAA6C,OACxD,QACA,EAAE,SAAS,UACX,EAAE,cACC;CACH,MAAM,SAAS,cAAc,GAAG,QAAQ,sBAAsB;EAC5D,KAAK;EACL,WAAW;CACb,CAAC;CACD,MAAM,WAAY,MAAM,OAAO,QAAQ;EACrC,KAAK;EACL,cAAc,EAAE,QAAQ,MAAM;CAChC,CAAC;CAED,IACE,SAAS,KAAK,aAAa,KAAA,KAC3B,SAAS,QAAQ,SACjB,SAAS,SAAS,SAAS,KAE3B,OAAO,EACL,OAAO;EACL,MACE,SAAS,QAAQ,SAAS,MAAA,SAAA;EAG5B,SAAS,SAAS,SAAS;CAC7B,EACF;CAGF,OAAO,EACL,QAAQ,OAAO,SAAS,KAAK,QAAQ,EACvC;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "../../errors/rpc.js";
|
|
2
2
|
import { urlWithParams } from "../../utils/url.js";
|
|
3
3
|
//#region src/transports/blockchair/getTransactionFee.ts
|
|
4
4
|
const getTransactionFee = async (client, { baseUrl, apiKey }, { txId }) => {
|
|
@@ -8,7 +8,7 @@ const getTransactionFee = async (client, { baseUrl, apiKey }, { txId }) => {
|
|
|
8
8
|
fetchOptions: { method: "GET" }
|
|
9
9
|
});
|
|
10
10
|
if (!response.data[txId] || response.context.error || response.context?.code !== 200) return { error: {
|
|
11
|
-
code: response.context.code === 429 ?
|
|
11
|
+
code: response.context.code === 429 ? -32002 : -1,
|
|
12
12
|
message: response.context?.error
|
|
13
13
|
} };
|
|
14
14
|
return { result: BigInt(response.data[txId].transaction.fee) };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTransactionFee.js","names":[],"sources":["../../../../src/transports/blockchair/getTransactionFee.ts"],"sourcesContent":["import { RpcErrorCode } from '../../errors/rpc.js'\nimport { urlWithParams } from '../../utils/url.js'\nimport type { RpcMethodHandler } from '../types.js'\nimport type { BlockchairTransactionResponse } from './blockchair.types.js'\n\nexport const getTransactionFee: RpcMethodHandler<'getTransactionFee'> = async (\n client,\n { baseUrl, apiKey },\n { txId }\n) => {\n const apiUrl = urlWithParams(`${baseUrl}/dashboards/transaction/${txId}`, {\n key: apiKey,\n })\n const response = (await client.request({\n url: apiUrl,\n fetchOptions: {\n method: 'GET',\n },\n })) as unknown as BlockchairTransactionResponse\n\n if (\n !response.data[txId] ||\n response.context.error ||\n response.context?.code !== 200\n ) {\n return {\n error: {\n code:\n response.context.code === 429\n ? RpcErrorCode.ACCESS_DENIED\n : RpcErrorCode.MISC_ERROR,\n message: response.context?.error,\n },\n }\n }\n\n return {\n result: BigInt(response.data[txId].transaction.fee),\n }\n}\n"],"mappings":";;;AAKA,MAAa,oBAA2D,OACtE,QACA,EAAE,SAAS,UACX,EAAE,WACC;CACH,MAAM,SAAS,cAAc,GAAG,QAAQ,0BAA0B,QAAQ,EACxE,KAAK,
|
|
1
|
+
{"version":3,"file":"getTransactionFee.js","names":[],"sources":["../../../../src/transports/blockchair/getTransactionFee.ts"],"sourcesContent":["import { RpcErrorCode } from '../../errors/rpc.js'\nimport { urlWithParams } from '../../utils/url.js'\nimport type { RpcMethodHandler } from '../types.js'\nimport type { BlockchairTransactionResponse } from './blockchair.types.js'\n\nexport const getTransactionFee: RpcMethodHandler<'getTransactionFee'> = async (\n client,\n { baseUrl, apiKey },\n { txId }\n) => {\n const apiUrl = urlWithParams(`${baseUrl}/dashboards/transaction/${txId}`, {\n key: apiKey,\n })\n const response = (await client.request({\n url: apiUrl,\n fetchOptions: {\n method: 'GET',\n },\n })) as unknown as BlockchairTransactionResponse\n\n if (\n !response.data[txId] ||\n response.context.error ||\n response.context?.code !== 200\n ) {\n return {\n error: {\n code:\n response.context.code === 429\n ? RpcErrorCode.ACCESS_DENIED\n : RpcErrorCode.MISC_ERROR,\n message: response.context?.error,\n },\n }\n }\n\n return {\n result: BigInt(response.data[txId].transaction.fee),\n }\n}\n"],"mappings":";;;AAKA,MAAa,oBAA2D,OACtE,QACA,EAAE,SAAS,UACX,EAAE,WACC;CACH,MAAM,SAAS,cAAc,GAAG,QAAQ,0BAA0B,QAAQ,EACxE,KAAK,OACP,CAAC;CACD,MAAM,WAAY,MAAM,OAAO,QAAQ;EACrC,KAAK;EACL,cAAc,EACZ,QAAQ,MACV;CACF,CAAC;CAED,IACE,CAAC,SAAS,KAAK,SACf,SAAS,QAAQ,SACjB,SAAS,SAAS,SAAS,KAE3B,OAAO,EACL,OAAO;EACL,MACE,SAAS,QAAQ,SAAS,MAAA,SAAA;EAG5B,SAAS,SAAS,SAAS;CAC7B,EACF;CAGF,OAAO,EACL,QAAQ,OAAO,SAAS,KAAK,MAAM,YAAY,GAAG,EACpD;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseError } from "../../errors/base.js";
|
|
2
2
|
import { RpcRequestError } from "../../errors/request.js";
|
|
3
|
-
import
|
|
3
|
+
import "../../errors/rpc.js";
|
|
4
4
|
import { InsufficientUTXOBalanceError } from "../../errors/utxo.js";
|
|
5
5
|
import { urlWithParams } from "../../utils/url.js";
|
|
6
6
|
import { getBalance } from "./getBalance.js";
|
|
@@ -37,7 +37,7 @@ const getUTXOs = async (client, { baseUrl, apiKey }, { address, minValue }) => {
|
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
error: {
|
|
40
|
-
code: response.context.code === 429 ?
|
|
40
|
+
code: response.context.code === 429 ? -32002 : -1,
|
|
41
41
|
message: response.context.error || "Error fetching utxos"
|
|
42
42
|
}
|
|
43
43
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getUTXOs.js","names":[],"sources":["../../../../src/transports/blockchair/getUTXOs.ts"],"sourcesContent":["import { BaseError } from '../../errors/base.js'\nimport { RpcRequestError } from '../../errors/request.js'\nimport { RpcErrorCode } from '../../errors/rpc.js'\nimport { InsufficientUTXOBalanceError } from '../../errors/utxo.js'\nimport type { UTXO } from '../../types/transaction.js'\n\nimport { urlWithParams } from '../../utils/url.js'\nimport type { RpcMethodHandler } from '../types.js'\nimport type {\n BlockChairDashboardAddressResponse,\n BlockchairResponse,\n BlockchairUTXO,\n} from './blockchair.types.js'\nimport { getBalance } from './getBalance.js'\n\nconst blockChairUTXOTransformer =\n (scriptHex: string) =>\n (data: BlockchairUTXO): UTXO => ({\n blockHeight: data.block_id,\n scriptHex,\n txId: data.transaction_hash,\n value: data.value,\n vout: data.index,\n })\n\nconst MAX_API_LIMIT = '100,100'\n\nexport const getUTXOs: RpcMethodHandler<'getUTXOs'> = async (\n client,\n { baseUrl, apiKey },\n { address, minValue }\n) => {\n async function* fetchUTXOs() {\n let offset = 0\n let hasMore = true\n\n while (hasMore) {\n const apiUrl = urlWithParams(\n `${baseUrl}/dashboards/addresses/${address}`,\n {\n key: apiKey,\n offset: `0,${offset}`,\n limit: MAX_API_LIMIT,\n }\n )\n const response = (await client.request({\n url: apiUrl,\n fetchOptions: { method: 'GET' },\n })) as unknown as BlockchairResponse<BlockChairDashboardAddressResponse>\n\n if (response.context?.code !== 200 && response.context?.code !== 404) {\n throw new RpcRequestError({\n url: apiUrl,\n body: {\n method: 'fetchUTXOs',\n params: {\n address,\n minValue,\n },\n },\n error: {\n code:\n response.context.code === 429\n ? RpcErrorCode.ACCESS_DENIED\n : RpcErrorCode.MISC_ERROR,\n message: response.context.error || 'Error fetching utxos',\n },\n })\n }\n\n if (!response.data || response.data.utxo.length === 0) {\n hasMore = false\n continue\n }\n\n const { limit } = response.context\n const totalRows = response.data.addresses[address].unspent_output_count\n if (limit && totalRows) {\n const [, utxoLimit] = String(limit)\n .split(',')\n .map((val) => Number(val))\n hasMore = offset + utxoLimit < totalRows\n offset += utxoLimit\n } else {\n hasMore = false\n offset += 0\n }\n\n yield response.data\n }\n }\n\n if (minValue) {\n const { error, result: balance } = await getBalance(\n client,\n { baseUrl, apiKey },\n { address }\n )\n\n if (error) {\n throw new BaseError('Error fetching balance', {\n cause: error,\n })\n }\n\n if (balance === undefined) {\n throw new BaseError('Balance is undefined', {\n cause: new Error('Unable to determine balance'),\n })\n }\n\n if (minValue > Number(balance)) {\n throw new InsufficientUTXOBalanceError({\n minValue,\n address,\n balance: Number(balance),\n })\n }\n }\n const utxos: UTXO[] = []\n let valueCount = 0\n\n for await (const batch of fetchUTXOs()) {\n const addressScriptHex = batch.addresses[address].script_hex\n const utxoBatch = batch.utxo.map(\n blockChairUTXOTransformer(addressScriptHex)\n )\n utxos.push(...utxoBatch)\n\n if (minValue) {\n valueCount += utxoBatch.reduce((sum, utxo) => sum + utxo.value, 0)\n if (valueCount >= minValue) {\n break\n }\n }\n }\n\n return { result: utxos }\n}\n"],"mappings":";;;;;;;AAeA,MAAM,6BACH,eACA,UAAgC;CAC/B,aAAa,KAAK;CAClB;CACA,MAAM,KAAK;CACX,OAAO,KAAK;CACZ,MAAM,KAAK;
|
|
1
|
+
{"version":3,"file":"getUTXOs.js","names":[],"sources":["../../../../src/transports/blockchair/getUTXOs.ts"],"sourcesContent":["import { BaseError } from '../../errors/base.js'\nimport { RpcRequestError } from '../../errors/request.js'\nimport { RpcErrorCode } from '../../errors/rpc.js'\nimport { InsufficientUTXOBalanceError } from '../../errors/utxo.js'\nimport type { UTXO } from '../../types/transaction.js'\n\nimport { urlWithParams } from '../../utils/url.js'\nimport type { RpcMethodHandler } from '../types.js'\nimport type {\n BlockChairDashboardAddressResponse,\n BlockchairResponse,\n BlockchairUTXO,\n} from './blockchair.types.js'\nimport { getBalance } from './getBalance.js'\n\nconst blockChairUTXOTransformer =\n (scriptHex: string) =>\n (data: BlockchairUTXO): UTXO => ({\n blockHeight: data.block_id,\n scriptHex,\n txId: data.transaction_hash,\n value: data.value,\n vout: data.index,\n })\n\nconst MAX_API_LIMIT = '100,100'\n\nexport const getUTXOs: RpcMethodHandler<'getUTXOs'> = async (\n client,\n { baseUrl, apiKey },\n { address, minValue }\n) => {\n async function* fetchUTXOs() {\n let offset = 0\n let hasMore = true\n\n while (hasMore) {\n const apiUrl = urlWithParams(\n `${baseUrl}/dashboards/addresses/${address}`,\n {\n key: apiKey,\n offset: `0,${offset}`,\n limit: MAX_API_LIMIT,\n }\n )\n const response = (await client.request({\n url: apiUrl,\n fetchOptions: { method: 'GET' },\n })) as unknown as BlockchairResponse<BlockChairDashboardAddressResponse>\n\n if (response.context?.code !== 200 && response.context?.code !== 404) {\n throw new RpcRequestError({\n url: apiUrl,\n body: {\n method: 'fetchUTXOs',\n params: {\n address,\n minValue,\n },\n },\n error: {\n code:\n response.context.code === 429\n ? RpcErrorCode.ACCESS_DENIED\n : RpcErrorCode.MISC_ERROR,\n message: response.context.error || 'Error fetching utxos',\n },\n })\n }\n\n if (!response.data || response.data.utxo.length === 0) {\n hasMore = false\n continue\n }\n\n const { limit } = response.context\n const totalRows = response.data.addresses[address].unspent_output_count\n if (limit && totalRows) {\n const [, utxoLimit] = String(limit)\n .split(',')\n .map((val) => Number(val))\n hasMore = offset + utxoLimit < totalRows\n offset += utxoLimit\n } else {\n hasMore = false\n offset += 0\n }\n\n yield response.data\n }\n }\n\n if (minValue) {\n const { error, result: balance } = await getBalance(\n client,\n { baseUrl, apiKey },\n { address }\n )\n\n if (error) {\n throw new BaseError('Error fetching balance', {\n cause: error,\n })\n }\n\n if (balance === undefined) {\n throw new BaseError('Balance is undefined', {\n cause: new Error('Unable to determine balance'),\n })\n }\n\n if (minValue > Number(balance)) {\n throw new InsufficientUTXOBalanceError({\n minValue,\n address,\n balance: Number(balance),\n })\n }\n }\n const utxos: UTXO[] = []\n let valueCount = 0\n\n for await (const batch of fetchUTXOs()) {\n const addressScriptHex = batch.addresses[address].script_hex\n const utxoBatch = batch.utxo.map(\n blockChairUTXOTransformer(addressScriptHex)\n )\n utxos.push(...utxoBatch)\n\n if (minValue) {\n valueCount += utxoBatch.reduce((sum, utxo) => sum + utxo.value, 0)\n if (valueCount >= minValue) {\n break\n }\n }\n }\n\n return { result: utxos }\n}\n"],"mappings":";;;;;;;AAeA,MAAM,6BACH,eACA,UAAgC;CAC/B,aAAa,KAAK;CAClB;CACA,MAAM,KAAK;CACX,OAAO,KAAK;CACZ,MAAM,KAAK;AACb;AAEF,MAAM,gBAAgB;AAEtB,MAAa,WAAyC,OACpD,QACA,EAAE,SAAS,UACX,EAAE,SAAS,eACR;CACH,gBAAgB,aAAa;EAC3B,IAAI,SAAS;EACb,IAAI,UAAU;EAEd,OAAO,SAAS;GACd,MAAM,SAAS,cACb,GAAG,QAAQ,wBAAwB,WACnC;IACE,KAAK;IACL,QAAQ,KAAK;IACb,OAAO;GACT,CACF;GACA,MAAM,WAAY,MAAM,OAAO,QAAQ;IACrC,KAAK;IACL,cAAc,EAAE,QAAQ,MAAM;GAChC,CAAC;GAED,IAAI,SAAS,SAAS,SAAS,OAAO,SAAS,SAAS,SAAS,KAC/D,MAAM,IAAI,gBAAgB;IACxB,KAAK;IACL,MAAM;KACJ,QAAQ;KACR,QAAQ;MACN;MACA;KACF;IACF;IACA,OAAO;KACL,MACE,SAAS,QAAQ,SAAS,MAAA,SAAA;KAG5B,SAAS,SAAS,QAAQ,SAAS;IACrC;GACF,CAAC;GAGH,IAAI,CAAC,SAAS,QAAQ,SAAS,KAAK,KAAK,WAAW,GAAG;IACrD,UAAU;IACV;GACF;GAEA,MAAM,EAAE,UAAU,SAAS;GAC3B,MAAM,YAAY,SAAS,KAAK,UAAU,SAAS;GACnD,IAAI,SAAS,WAAW;IACtB,MAAM,GAAG,aAAa,OAAO,KAAK,EAC/B,MAAM,GAAG,EACT,KAAK,QAAQ,OAAO,GAAG,CAAC;IAC3B,UAAU,SAAS,YAAY;IAC/B,UAAU;GACZ,OAAO;IACL,UAAU;IACV,UAAU;GACZ;GAEA,MAAM,SAAS;EACjB;CACF;CAEA,IAAI,UAAU;EACZ,MAAM,EAAE,OAAO,QAAQ,YAAY,MAAM,WACvC,QACA;GAAE;GAAS;EAAO,GAClB,EAAE,QAAQ,CACZ;EAEA,IAAI,OACF,MAAM,IAAI,UAAU,0BAA0B,EAC5C,OAAO,MACT,CAAC;EAGH,IAAI,YAAY,KAAA,GACd,MAAM,IAAI,UAAU,wBAAwB,EAC1C,uBAAO,IAAI,MAAM,6BAA6B,EAChD,CAAC;EAGH,IAAI,WAAW,OAAO,OAAO,GAC3B,MAAM,IAAI,6BAA6B;GACrC;GACA;GACA,SAAS,OAAO,OAAO;EACzB,CAAC;CAEL;CACA,MAAM,QAAgB,CAAC;CACvB,IAAI,aAAa;CAEjB,WAAW,MAAM,SAAS,WAAW,GAAG;EACtC,MAAM,mBAAmB,MAAM,UAAU,SAAS;EAClD,MAAM,YAAY,MAAM,KAAK,IAC3B,0BAA0B,gBAAgB,CAC5C;EACA,MAAM,KAAK,GAAG,SAAS;EAEvB,IAAI,UAAU;GACZ,cAAc,UAAU,QAAQ,KAAK,SAAS,MAAM,KAAK,OAAO,CAAC;GACjE,IAAI,cAAc,UAChB;EAEJ;CACF;CAEA,OAAO,EAAE,QAAQ,MAAM;AACzB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "../../errors/rpc.js";
|
|
2
2
|
import { urlWithParams } from "../../utils/url.js";
|
|
3
3
|
//#region src/transports/blockchair/getXPubAddresses.ts
|
|
4
4
|
const getXPubAddresses = async (client, { baseUrl, apiKey }, { xPubKey }) => {
|
|
@@ -8,7 +8,7 @@ const getXPubAddresses = async (client, { baseUrl, apiKey }, { xPubKey }) => {
|
|
|
8
8
|
fetchOptions: { method: "GET" }
|
|
9
9
|
});
|
|
10
10
|
if (response.context.error || response.context?.code !== 200) return { error: {
|
|
11
|
-
code: response.context.code === 429 ?
|
|
11
|
+
code: response.context.code === 429 ? -32002 : -1,
|
|
12
12
|
message: response.context?.error
|
|
13
13
|
} };
|
|
14
14
|
if (response.data[xPubKey] === void 0) return { result: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getXPubAddresses.js","names":[],"sources":["../../../../src/transports/blockchair/getXPubAddresses.ts"],"sourcesContent":["import { RpcErrorCode } from '../../errors/rpc.js'\nimport { urlWithParams } from '../../utils/url.js'\nimport type { RpcMethodHandler } from '../types.js'\nimport type {\n BlockchairResponse,\n BlockchairXpubResponse,\n} from './blockchair.types.js'\n\nexport const getXPubAddresses: RpcMethodHandler<'getXPubAddresses'> = async (\n client,\n { baseUrl, apiKey },\n { xPubKey }\n) => {\n const apiUrl = urlWithParams(`${baseUrl}/dashboards/xpub/${xPubKey}`, {\n key: apiKey,\n })\n const response = (await client.request({\n url: apiUrl,\n fetchOptions: { method: 'GET' },\n })) as unknown as BlockchairResponse<BlockchairXpubResponse>\n\n if (response.context.error || response.context?.code !== 200) {\n return {\n error: {\n code:\n response.context.code === 429\n ? RpcErrorCode.ACCESS_DENIED\n : RpcErrorCode.MISC_ERROR,\n message: response.context?.error,\n },\n }\n }\n\n if (response.data[xPubKey] === undefined) {\n return {\n result: {\n balance: 0n,\n addresses: [],\n },\n }\n }\n\n const xpubData = response.data[xPubKey]\n\n const result = {\n balance: BigInt(xpubData.xpub.balance),\n addresses: Object.entries(xpubData.addresses).map(([address, data]) => ({\n address,\n balance: BigInt(data.balance),\n path: data.path,\n scriptHex: data.script_hex,\n })),\n }\n\n return {\n result,\n }\n}\n"],"mappings":";;;AAQA,MAAa,mBAAyD,OACpE,QACA,EAAE,SAAS,UACX,EAAE,cACC;CACH,MAAM,SAAS,cAAc,GAAG,QAAQ,mBAAmB,WAAW,EACpE,KAAK,
|
|
1
|
+
{"version":3,"file":"getXPubAddresses.js","names":[],"sources":["../../../../src/transports/blockchair/getXPubAddresses.ts"],"sourcesContent":["import { RpcErrorCode } from '../../errors/rpc.js'\nimport { urlWithParams } from '../../utils/url.js'\nimport type { RpcMethodHandler } from '../types.js'\nimport type {\n BlockchairResponse,\n BlockchairXpubResponse,\n} from './blockchair.types.js'\n\nexport const getXPubAddresses: RpcMethodHandler<'getXPubAddresses'> = async (\n client,\n { baseUrl, apiKey },\n { xPubKey }\n) => {\n const apiUrl = urlWithParams(`${baseUrl}/dashboards/xpub/${xPubKey}`, {\n key: apiKey,\n })\n const response = (await client.request({\n url: apiUrl,\n fetchOptions: { method: 'GET' },\n })) as unknown as BlockchairResponse<BlockchairXpubResponse>\n\n if (response.context.error || response.context?.code !== 200) {\n return {\n error: {\n code:\n response.context.code === 429\n ? RpcErrorCode.ACCESS_DENIED\n : RpcErrorCode.MISC_ERROR,\n message: response.context?.error,\n },\n }\n }\n\n if (response.data[xPubKey] === undefined) {\n return {\n result: {\n balance: 0n,\n addresses: [],\n },\n }\n }\n\n const xpubData = response.data[xPubKey]\n\n const result = {\n balance: BigInt(xpubData.xpub.balance),\n addresses: Object.entries(xpubData.addresses).map(([address, data]) => ({\n address,\n balance: BigInt(data.balance),\n path: data.path,\n scriptHex: data.script_hex,\n })),\n }\n\n return {\n result,\n }\n}\n"],"mappings":";;;AAQA,MAAa,mBAAyD,OACpE,QACA,EAAE,SAAS,UACX,EAAE,cACC;CACH,MAAM,SAAS,cAAc,GAAG,QAAQ,mBAAmB,WAAW,EACpE,KAAK,OACP,CAAC;CACD,MAAM,WAAY,MAAM,OAAO,QAAQ;EACrC,KAAK;EACL,cAAc,EAAE,QAAQ,MAAM;CAChC,CAAC;CAED,IAAI,SAAS,QAAQ,SAAS,SAAS,SAAS,SAAS,KACvD,OAAO,EACL,OAAO;EACL,MACE,SAAS,QAAQ,SAAS,MAAA,SAAA;EAG5B,SAAS,SAAS,SAAS;CAC7B,EACF;CAGF,IAAI,SAAS,KAAK,aAAa,KAAA,GAC7B,OAAO,EACL,QAAQ;EACN,SAAS;EACT,WAAW,CAAC;CACd,EACF;CAGF,MAAM,WAAW,SAAS,KAAK;CAY/B,OAAO,EACL,QAAA;EAVA,SAAS,OAAO,SAAS,KAAK,OAAO;EACrC,WAAW,OAAO,QAAQ,SAAS,SAAS,EAAE,KAAK,CAAC,SAAS,WAAW;GACtE;GACA,SAAS,OAAO,KAAK,OAAO;GAC5B,MAAM,KAAK;GACX,WAAW,KAAK;EAClB,EAAE;CAIG,EACP;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"methods.js","names":[],"sources":["../../../../src/transports/blockchair/methods.ts"],"sourcesContent":["import type { RpcMethods } from '../types.js'\nimport { getBalance } from './getBalance.js'\nimport { getTransactionFee } from './getTransactionFee.js'\nimport { getUTXOs } from './getUTXOs.js'\nimport { getXPubAddresses } from './getXPubAddresses.js'\n\nexport const blockchairMethods: RpcMethods = {\n getBalance,\n getUTXOs,\n getTransactionFee,\n getXPubAddresses,\n}\n"],"mappings":";;;;;AAMA,MAAa,oBAAgC;CAC3C;CACA;CACA;CACA;
|
|
1
|
+
{"version":3,"file":"methods.js","names":[],"sources":["../../../../src/transports/blockchair/methods.ts"],"sourcesContent":["import type { RpcMethods } from '../types.js'\nimport { getBalance } from './getBalance.js'\nimport { getTransactionFee } from './getTransactionFee.js'\nimport { getUTXOs } from './getUTXOs.js'\nimport { getXPubAddresses } from './getXPubAddresses.js'\n\nexport const blockchairMethods: RpcMethods = {\n getBalance,\n getUTXOs,\n getTransactionFee,\n getXPubAddresses,\n}\n"],"mappings":";;;;;AAMA,MAAa,oBAAgC;CAC3C;CACA;CACA;CACA;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blockcypher.js","names":[],"sources":["../../../../src/transports/blockcypher/blockcypher.ts"],"sourcesContent":["import type { HttpTransport, HttpTransportConfig } from '../http.js'\nimport type { UTXOMethod } from '../types.js'\nimport { utxo } from '../utxo.js'\nimport { blockcypherMethods } from './methods.js'\n\ntype BlockcypherConfig = {\n baseUrl?: string\n apiKey?: string\n} & HttpTransportConfig\n\nexport const blockcypher = (config?: BlockcypherConfig): HttpTransport =>\n utxo(config?.baseUrl || 'https://api.blockcypher.com/v1/btc/main', {\n name: 'Blockcypher API',\n key: 'blockcypher',\n methods: {\n include: Object.keys(blockcypherMethods) as UTXOMethod[],\n },\n ...config,\n })\n"],"mappings":";;;AAUA,MAAa,eAAe,WAC1B,KAAK,QAAQ,WAAW,2CAA2C;CACjE,MAAM;CACN,KAAK;CACL,SAAS,EACP,SAAS,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"blockcypher.js","names":[],"sources":["../../../../src/transports/blockcypher/blockcypher.ts"],"sourcesContent":["import type { HttpTransport, HttpTransportConfig } from '../http.js'\nimport type { UTXOMethod } from '../types.js'\nimport { utxo } from '../utxo.js'\nimport { blockcypherMethods } from './methods.js'\n\ntype BlockcypherConfig = {\n baseUrl?: string\n apiKey?: string\n} & HttpTransportConfig\n\nexport const blockcypher = (config?: BlockcypherConfig): HttpTransport =>\n utxo(config?.baseUrl || 'https://api.blockcypher.com/v1/btc/main', {\n name: 'Blockcypher API',\n key: 'blockcypher',\n methods: {\n include: Object.keys(blockcypherMethods) as UTXOMethod[],\n },\n ...config,\n })\n"],"mappings":";;;AAUA,MAAa,eAAe,WAC1B,KAAK,QAAQ,WAAW,2CAA2C;CACjE,MAAM;CACN,KAAK;CACL,SAAS,EACP,SAAS,OAAO,KAAK,kBAAkB,EACzC;CACA,GAAG;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBalance.js","names":[],"sources":["../../../../src/transports/blockcypher/getBalance.ts"],"sourcesContent":["import { urlWithParams } from '../../utils/url.js'\nimport type { RpcMethodHandler } from '../types.js'\nimport type { BlockcypherBalanceResponse } from './blockcypher.types.js'\nimport { getRpcErrorCode } from './utils.js'\n\nexport const getBalance: RpcMethodHandler<'getBalance'> = async (\n client,\n { baseUrl, apiKey },\n { address }\n) => {\n const apiUrl = urlWithParams(`${baseUrl}/addrs/${address}`, {\n token: apiKey,\n })\n const response = (await client.request({\n url: apiUrl,\n fetchOptions: { method: 'GET' },\n })) as unknown as BlockcypherBalanceResponse\n if (response.error) {\n return {\n error: {\n code: getRpcErrorCode(response.error),\n message: response.error,\n },\n }\n }\n return {\n result: BigInt(response.balance),\n }\n}\n"],"mappings":";;;AAKA,MAAa,aAA6C,OACxD,QACA,EAAE,SAAS,UACX,EAAE,cACC;CACH,MAAM,SAAS,cAAc,GAAG,QAAQ,SAAS,WAAW,EAC1D,OAAO,
|
|
1
|
+
{"version":3,"file":"getBalance.js","names":[],"sources":["../../../../src/transports/blockcypher/getBalance.ts"],"sourcesContent":["import { urlWithParams } from '../../utils/url.js'\nimport type { RpcMethodHandler } from '../types.js'\nimport type { BlockcypherBalanceResponse } from './blockcypher.types.js'\nimport { getRpcErrorCode } from './utils.js'\n\nexport const getBalance: RpcMethodHandler<'getBalance'> = async (\n client,\n { baseUrl, apiKey },\n { address }\n) => {\n const apiUrl = urlWithParams(`${baseUrl}/addrs/${address}`, {\n token: apiKey,\n })\n const response = (await client.request({\n url: apiUrl,\n fetchOptions: { method: 'GET' },\n })) as unknown as BlockcypherBalanceResponse\n if (response.error) {\n return {\n error: {\n code: getRpcErrorCode(response.error),\n message: response.error,\n },\n }\n }\n return {\n result: BigInt(response.balance),\n }\n}\n"],"mappings":";;;AAKA,MAAa,aAA6C,OACxD,QACA,EAAE,SAAS,UACX,EAAE,cACC;CACH,MAAM,SAAS,cAAc,GAAG,QAAQ,SAAS,WAAW,EAC1D,OAAO,OACT,CAAC;CACD,MAAM,WAAY,MAAM,OAAO,QAAQ;EACrC,KAAK;EACL,cAAc,EAAE,QAAQ,MAAM;CAChC,CAAC;CACD,IAAI,SAAS,OACX,OAAO,EACL,OAAO;EACL,MAAM,gBAAgB,SAAS,KAAK;EACpC,SAAS,SAAS;CACpB,EACF;CAEF,OAAO,EACL,QAAQ,OAAO,SAAS,OAAO,EACjC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTransactionFee.js","names":[],"sources":["../../../../src/transports/blockcypher/getTransactionFee.ts"],"sourcesContent":["import { urlWithParams } from '../../utils/url.js'\nimport type { RpcMethodHandler } from '../types.js'\nimport type { BlockcypherTransactionReponse } from './blockcypher.types.js'\nimport { getRpcErrorCode } from './utils.js'\n\nexport const getTransactionFee: RpcMethodHandler<'getTransactionFee'> = async (\n client,\n { baseUrl, apiKey },\n { txId }\n) => {\n const apiUrl = urlWithParams(`${baseUrl}/txs/${txId}`, {\n token: apiKey,\n })\n\n const response = (await client.request({\n url: apiUrl,\n fetchOptions: { method: 'GET' },\n })) as unknown as BlockcypherTransactionReponse\n\n if (response.error) {\n return {\n error: { code: getRpcErrorCode(response.error), message: response.error },\n }\n }\n\n return {\n result: BigInt(response.fees),\n }\n}\n"],"mappings":";;;AAKA,MAAa,oBAA2D,OACtE,QACA,EAAE,SAAS,UACX,EAAE,WACC;CACH,MAAM,SAAS,cAAc,GAAG,QAAQ,OAAO,QAAQ,EACrD,OAAO,
|
|
1
|
+
{"version":3,"file":"getTransactionFee.js","names":[],"sources":["../../../../src/transports/blockcypher/getTransactionFee.ts"],"sourcesContent":["import { urlWithParams } from '../../utils/url.js'\nimport type { RpcMethodHandler } from '../types.js'\nimport type { BlockcypherTransactionReponse } from './blockcypher.types.js'\nimport { getRpcErrorCode } from './utils.js'\n\nexport const getTransactionFee: RpcMethodHandler<'getTransactionFee'> = async (\n client,\n { baseUrl, apiKey },\n { txId }\n) => {\n const apiUrl = urlWithParams(`${baseUrl}/txs/${txId}`, {\n token: apiKey,\n })\n\n const response = (await client.request({\n url: apiUrl,\n fetchOptions: { method: 'GET' },\n })) as unknown as BlockcypherTransactionReponse\n\n if (response.error) {\n return {\n error: { code: getRpcErrorCode(response.error), message: response.error },\n }\n }\n\n return {\n result: BigInt(response.fees),\n }\n}\n"],"mappings":";;;AAKA,MAAa,oBAA2D,OACtE,QACA,EAAE,SAAS,UACX,EAAE,WACC;CACH,MAAM,SAAS,cAAc,GAAG,QAAQ,OAAO,QAAQ,EACrD,OAAO,OACT,CAAC;CAED,MAAM,WAAY,MAAM,OAAO,QAAQ;EACrC,KAAK;EACL,cAAc,EAAE,QAAQ,MAAM;CAChC,CAAC;CAED,IAAI,SAAS,OACX,OAAO,EACL,OAAO;EAAE,MAAM,gBAAgB,SAAS,KAAK;EAAG,SAAS,SAAS;CAAM,EAC1E;CAGF,OAAO,EACL,QAAQ,OAAO,SAAS,IAAI,EAC9B;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getUTXOs.js","names":[],"sources":["../../../../src/transports/blockcypher/getUTXOs.ts"],"sourcesContent":["import { RpcRequestError } from '../../errors/request.js'\nimport { InsufficientUTXOBalanceError } from '../../errors/utxo.js'\nimport type { UTXO } from '../../types/transaction.js'\nimport { urlWithParams } from '../../utils/url.js'\nimport type { RpcMethodHandler } from '../types.js'\nimport type {\n BlockcypherUTXO,\n BlockcypherUTXOsResponse,\n} from './blockcypher.types.js'\nimport { getRpcErrorCode } from './utils.js'\n\nconst blockcypherUTXOTransformer = (utxo: BlockcypherUTXO): UTXO => ({\n blockHeight: utxo.block_height,\n isConfirmed: Boolean(utxo.confirmations),\n confirmations: utxo.confirmations,\n value: utxo.value,\n vout: utxo.tx_output_n,\n txId: utxo.tx_hash,\n scriptHex: utxo.script,\n})\n\nconst MAX_API_LIMIT = 2000\n\nexport const getUTXOs: RpcMethodHandler<'getUTXOs'> = async (\n client,\n { baseUrl, apiKey },\n { address, minValue }\n) => {\n async function* fetchUTXOs() {\n let hasMore = true\n let beforeBlock: number | undefined\n\n while (hasMore) {\n const apiUrl = urlWithParams(`${baseUrl}/addrs/${address}`, {\n token: apiKey,\n unspentOnly: 'true',\n includeScript: 'true',\n before: beforeBlock,\n limit: MAX_API_LIMIT,\n })\n const response = (await client.request({\n url: apiUrl,\n fetchOptions: { method: 'GET' },\n })) as unknown as BlockcypherUTXOsResponse\n\n if (response.error) {\n throw new RpcRequestError({\n url: apiUrl,\n body: {\n method: 'fetchUTXOs',\n params: {\n address,\n minValue,\n },\n },\n error: {\n code: getRpcErrorCode(response.error),\n message: response.error,\n },\n })\n }\n\n if (minValue && minValue > response.final_balance) {\n throw new InsufficientUTXOBalanceError({\n minValue,\n address,\n balance: response.final_balance,\n })\n }\n\n if (!response.txrefs || response.txrefs.length === 0) {\n hasMore = false\n continue\n }\n\n const { hasMore: apiHasMore } = response\n\n hasMore = Boolean(apiHasMore)\n beforeBlock = response.txrefs[response.txrefs.length - 1].block_height\n\n yield response.txrefs\n }\n }\n\n const utxos: UTXO[] = []\n let valueCount = 0\n\n for await (const batch of fetchUTXOs()) {\n const utxoBatch = batch.map(blockcypherUTXOTransformer)\n utxos.push(...utxoBatch)\n\n if (minValue) {\n valueCount += utxoBatch.reduce((sum, utxo) => sum + utxo.value, 0)\n if (valueCount >= minValue) {\n break\n }\n }\n }\n\n return { result: utxos }\n}\n"],"mappings":";;;;;AAWA,MAAM,8BAA8B,UAAiC;CACnE,aAAa,KAAK;CAClB,aAAa,QAAQ,KAAK,
|
|
1
|
+
{"version":3,"file":"getUTXOs.js","names":[],"sources":["../../../../src/transports/blockcypher/getUTXOs.ts"],"sourcesContent":["import { RpcRequestError } from '../../errors/request.js'\nimport { InsufficientUTXOBalanceError } from '../../errors/utxo.js'\nimport type { UTXO } from '../../types/transaction.js'\nimport { urlWithParams } from '../../utils/url.js'\nimport type { RpcMethodHandler } from '../types.js'\nimport type {\n BlockcypherUTXO,\n BlockcypherUTXOsResponse,\n} from './blockcypher.types.js'\nimport { getRpcErrorCode } from './utils.js'\n\nconst blockcypherUTXOTransformer = (utxo: BlockcypherUTXO): UTXO => ({\n blockHeight: utxo.block_height,\n isConfirmed: Boolean(utxo.confirmations),\n confirmations: utxo.confirmations,\n value: utxo.value,\n vout: utxo.tx_output_n,\n txId: utxo.tx_hash,\n scriptHex: utxo.script,\n})\n\nconst MAX_API_LIMIT = 2000\n\nexport const getUTXOs: RpcMethodHandler<'getUTXOs'> = async (\n client,\n { baseUrl, apiKey },\n { address, minValue }\n) => {\n async function* fetchUTXOs() {\n let hasMore = true\n let beforeBlock: number | undefined\n\n while (hasMore) {\n const apiUrl = urlWithParams(`${baseUrl}/addrs/${address}`, {\n token: apiKey,\n unspentOnly: 'true',\n includeScript: 'true',\n before: beforeBlock,\n limit: MAX_API_LIMIT,\n })\n const response = (await client.request({\n url: apiUrl,\n fetchOptions: { method: 'GET' },\n })) as unknown as BlockcypherUTXOsResponse\n\n if (response.error) {\n throw new RpcRequestError({\n url: apiUrl,\n body: {\n method: 'fetchUTXOs',\n params: {\n address,\n minValue,\n },\n },\n error: {\n code: getRpcErrorCode(response.error),\n message: response.error,\n },\n })\n }\n\n if (minValue && minValue > response.final_balance) {\n throw new InsufficientUTXOBalanceError({\n minValue,\n address,\n balance: response.final_balance,\n })\n }\n\n if (!response.txrefs || response.txrefs.length === 0) {\n hasMore = false\n continue\n }\n\n const { hasMore: apiHasMore } = response\n\n hasMore = Boolean(apiHasMore)\n beforeBlock = response.txrefs[response.txrefs.length - 1].block_height\n\n yield response.txrefs\n }\n }\n\n const utxos: UTXO[] = []\n let valueCount = 0\n\n for await (const batch of fetchUTXOs()) {\n const utxoBatch = batch.map(blockcypherUTXOTransformer)\n utxos.push(...utxoBatch)\n\n if (minValue) {\n valueCount += utxoBatch.reduce((sum, utxo) => sum + utxo.value, 0)\n if (valueCount >= minValue) {\n break\n }\n }\n }\n\n return { result: utxos }\n}\n"],"mappings":";;;;;AAWA,MAAM,8BAA8B,UAAiC;CACnE,aAAa,KAAK;CAClB,aAAa,QAAQ,KAAK,aAAa;CACvC,eAAe,KAAK;CACpB,OAAO,KAAK;CACZ,MAAM,KAAK;CACX,MAAM,KAAK;CACX,WAAW,KAAK;AAClB;AAEA,MAAM,gBAAgB;AAEtB,MAAa,WAAyC,OACpD,QACA,EAAE,SAAS,UACX,EAAE,SAAS,eACR;CACH,gBAAgB,aAAa;EAC3B,IAAI,UAAU;EACd,IAAI;EAEJ,OAAO,SAAS;GACd,MAAM,SAAS,cAAc,GAAG,QAAQ,SAAS,WAAW;IAC1D,OAAO;IACP,aAAa;IACb,eAAe;IACf,QAAQ;IACR,OAAO;GACT,CAAC;GACD,MAAM,WAAY,MAAM,OAAO,QAAQ;IACrC,KAAK;IACL,cAAc,EAAE,QAAQ,MAAM;GAChC,CAAC;GAED,IAAI,SAAS,OACX,MAAM,IAAI,gBAAgB;IACxB,KAAK;IACL,MAAM;KACJ,QAAQ;KACR,QAAQ;MACN;MACA;KACF;IACF;IACA,OAAO;KACL,MAAM,gBAAgB,SAAS,KAAK;KACpC,SAAS,SAAS;IACpB;GACF,CAAC;GAGH,IAAI,YAAY,WAAW,SAAS,eAClC,MAAM,IAAI,6BAA6B;IACrC;IACA;IACA,SAAS,SAAS;GACpB,CAAC;GAGH,IAAI,CAAC,SAAS,UAAU,SAAS,OAAO,WAAW,GAAG;IACpD,UAAU;IACV;GACF;GAEA,MAAM,EAAE,SAAS,eAAe;GAEhC,UAAU,QAAQ,UAAU;GAC5B,cAAc,SAAS,OAAO,SAAS,OAAO,SAAS,GAAG;GAE1D,MAAM,SAAS;EACjB;CACF;CAEA,MAAM,QAAgB,CAAC;CACvB,IAAI,aAAa;CAEjB,WAAW,MAAM,SAAS,WAAW,GAAG;EACtC,MAAM,YAAY,MAAM,IAAI,0BAA0B;EACtD,MAAM,KAAK,GAAG,SAAS;EAEvB,IAAI,UAAU;GACZ,cAAc,UAAU,QAAQ,KAAK,SAAS,MAAM,KAAK,OAAO,CAAC;GACjE,IAAI,cAAc,UAChB;EAEJ;CACF;CAEA,OAAO,EAAE,QAAQ,MAAM;AACzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"methods.js","names":[],"sources":["../../../../src/transports/blockcypher/methods.ts"],"sourcesContent":["import type { RpcMethods } from '../types.js'\nimport { getBalance } from './getBalance.js'\nimport { getTransactionFee } from './getTransactionFee.js'\nimport { getUTXOs } from './getUTXOs.js'\n\nexport const blockcypherMethods: RpcMethods = {\n getBalance,\n getUTXOs,\n getTransactionFee,\n}\n"],"mappings":";;;;AAKA,MAAa,qBAAiC;CAC5C;CACA;CACA;
|
|
1
|
+
{"version":3,"file":"methods.js","names":[],"sources":["../../../../src/transports/blockcypher/methods.ts"],"sourcesContent":["import type { RpcMethods } from '../types.js'\nimport { getBalance } from './getBalance.js'\nimport { getTransactionFee } from './getTransactionFee.js'\nimport { getUTXOs } from './getUTXOs.js'\n\nexport const blockcypherMethods: RpcMethods = {\n getBalance,\n getUTXOs,\n getTransactionFee,\n}\n"],"mappings":";;;;AAKA,MAAa,qBAAiC;CAC5C;CACA;CACA;AACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "../../errors/rpc.js";
|
|
2
2
|
//#region src/transports/blockcypher/utils.ts
|
|
3
3
|
function getRpcErrorCode(error) {
|
|
4
|
-
if (error.toLowerCase().startsWith("rate limit exceeded")) return
|
|
5
|
-
return
|
|
4
|
+
if (error.toLowerCase().startsWith("rate limit exceeded")) return -32002;
|
|
5
|
+
return -1;
|
|
6
6
|
}
|
|
7
7
|
//#endregion
|
|
8
8
|
export { getRpcErrorCode };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../../../../src/transports/blockcypher/utils.ts"],"sourcesContent":["import { RpcErrorCode } from '../../errors/rpc.js'\n\nexport function getRpcErrorCode(error: string): RpcErrorCode {\n if (error.toLowerCase().startsWith('rate limit exceeded')) {\n return RpcErrorCode.ACCESS_DENIED\n }\n return RpcErrorCode.MISC_ERROR\n}\n"],"mappings":";;AAEA,SAAgB,gBAAgB,OAA6B;
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../../../src/transports/blockcypher/utils.ts"],"sourcesContent":["import { RpcErrorCode } from '../../errors/rpc.js'\n\nexport function getRpcErrorCode(error: string): RpcErrorCode {\n if (error.toLowerCase().startsWith('rate limit exceeded')) {\n return RpcErrorCode.ACCESS_DENIED\n }\n return RpcErrorCode.MISC_ERROR\n}\n"],"mappings":";;AAEA,SAAgB,gBAAgB,OAA6B;CAC3D,IAAI,MAAM,YAAY,EAAE,WAAW,qBAAqB,GACtD,OAAA;CAEF,OAAA;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom.d.ts","names":[],"sources":["../../../src/transports/custom.ts"],"mappings":";;;;KAQK,eAAA;EAAoB,OAAA,IAAW,IAAA,QAAY,OAAA;AAAA;AAAA,KAEpC,qBAAA;kCAEV,GAAA,GAAM,eAAA;EAEN,OAAA,GAAU,eAAA;EAEV,IAAA,GAAO,eAAA,sBARuC;EAU9C,UAAA,GAAa,eAAA,4BARH;EAUV,UAAA,GAAa,eAAA;AAAA;AAAA,KAGH,eAAA,GAAkB,SAAA,eAI5B,eAAA;AAAA,KAGU,wBAAA,GAA2B,wBAAA,GAA2B,SAAA;;;;iBAKlD,MAAA,kBAAwB,eAAA,
|
|
1
|
+
{"version":3,"file":"custom.d.ts","names":[],"sources":["../../../src/transports/custom.ts"],"mappings":";;;;KAQK,eAAA;EAAoB,OAAA,IAAW,IAAA,QAAY,OAAA;AAAA;AAAA,KAEpC,qBAAA;kCAEV,GAAA,GAAM,eAAA;EAEN,OAAA,GAAU,eAAA;EAEV,IAAA,GAAO,eAAA,sBARuC;EAU9C,UAAA,GAAa,eAAA,4BARH;EAUV,UAAA,GAAa,eAAA;AAAA;AAAA,KAGH,eAAA,GAAkB,SAAA,eAI5B,eAAA;AAAA,KAGU,wBAAA,GAA2B,wBAAA,GAA2B,SAAA;;;;iBAKlD,MAAA,kBAAwB,eAAA,EACtC,QAAA,EAAU,QAAA,EACV,MAAA,GAAQ,qBAAA,GACP,eAAA"}
|