@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":"mempool.js","names":["utxo","mempoolMethods"],"sources":["../../../../src/transports/mempool/mempool.ts"],"sourcesContent":["import type { HttpTransport, HttpTransportConfig } from '../http.js'\nimport type { UTXOMethod } from '../types.js'\nimport { utxo } from '../utxo.js'\nimport { mempoolMethods } from './methods.js'\n\ntype MempoolConfig = {\n baseUrl?: string\n} & HttpTransportConfig\n\nexport const mempool = (config?: MempoolConfig): HttpTransport =>\n utxo(config?.baseUrl || 'https://mempool.space/api', {\n name: 'Mempool.space API',\n key: 'mempool',\n methods: {\n include: Object.keys(mempoolMethods) as UTXOMethod[],\n },\n ...config,\n })\n"],"mappings":";;;;AASA,MAAa,WAAW,WACtBA,wBAAAA,KAAK,QAAQ,WAAW,6BAA6B;CACnD,MAAM;CACN,KAAK;CACL,SAAS,EACP,SAAS,OAAO,KAAKC,mCAAAA,
|
|
1
|
+
{"version":3,"file":"mempool.js","names":["utxo","mempoolMethods"],"sources":["../../../../src/transports/mempool/mempool.ts"],"sourcesContent":["import type { HttpTransport, HttpTransportConfig } from '../http.js'\nimport type { UTXOMethod } from '../types.js'\nimport { utxo } from '../utxo.js'\nimport { mempoolMethods } from './methods.js'\n\ntype MempoolConfig = {\n baseUrl?: string\n} & HttpTransportConfig\n\nexport const mempool = (config?: MempoolConfig): HttpTransport =>\n utxo(config?.baseUrl || 'https://mempool.space/api', {\n name: 'Mempool.space API',\n key: 'mempool',\n methods: {\n include: Object.keys(mempoolMethods) as UTXOMethod[],\n },\n ...config,\n })\n"],"mappings":";;;;AASA,MAAa,WAAW,WACtBA,wBAAAA,KAAK,QAAQ,WAAW,6BAA6B;CACnD,MAAM;CACN,KAAK;CACL,SAAS,EACP,SAAS,OAAO,KAAKC,mCAAAA,cAAc,EACrC;CACA,GAAG;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"methods.js","names":[],"sources":["../../../../src/transports/mempool/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 mempoolMethods: RpcMethods = {\n getBalance,\n getTransactions,\n getTransactionFee,\n}\n"],"mappings":";;;;;AAKA,MAAa,iBAA6B;CACxC,YAAA,sCAAA;CACA,iBAAA,2CAAA;CACA,mBAAA,6CAAA;
|
|
1
|
+
{"version":3,"file":"methods.js","names":[],"sources":["../../../../src/transports/mempool/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 mempoolMethods: RpcMethods = {\n getBalance,\n getTransactions,\n getTransactionFee,\n}\n"],"mappings":";;;;;AAKA,MAAa,iBAA6B;CACxC,YAAA,sCAAA;CACA,iBAAA,2CAAA;CACA,mBAAA,6CAAA;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../../../../src/transports/mempool/utils.ts"],"sourcesContent":["import type { UTXOTransaction } from '../../types/transaction.js'\nimport type { MempoolTransaction } from './mempool.types.js'\n\nexport const mempoolTransactionTransformer = (\n txn: MempoolTransaction\n): Partial<UTXOTransaction> => ({\n hash: txn.txid,\n txid: txn.txid,\n vout: txn.vout.map((vout, index) => ({\n n: index,\n scriptPubKey: {\n address: vout.scriptpubkey_address,\n asm: vout.scriptpubkey_asm,\n type: vout.scriptpubkey_type,\n desc: vout.scriptpubkey,\n hex: vout.scriptpubkey,\n },\n value: vout.value,\n })),\n vin: txn.vin.map((vin) => ({\n scriptSig: {\n asm: vin.scriptsig_asm,\n hex: vin.scriptsig,\n },\n sequence: vin.sequence,\n txinwitness: vin.witness,\n txid: vin.txid,\n vout: vin.vout,\n })),\n})\n"],"mappings":";;AAGA,MAAa,iCACX,SAC8B;CAC9B,MAAM,IAAI;CACV,MAAM,IAAI;CACV,MAAM,IAAI,KAAK,KAAK,MAAM,WAAW;EACnC,GAAG;EACH,cAAc;GACZ,SAAS,KAAK;GACd,KAAK,KAAK;GACV,MAAM,KAAK;GACX,MAAM,KAAK;GACX,KAAK,KAAK;
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../../../src/transports/mempool/utils.ts"],"sourcesContent":["import type { UTXOTransaction } from '../../types/transaction.js'\nimport type { MempoolTransaction } from './mempool.types.js'\n\nexport const mempoolTransactionTransformer = (\n txn: MempoolTransaction\n): Partial<UTXOTransaction> => ({\n hash: txn.txid,\n txid: txn.txid,\n vout: txn.vout.map((vout, index) => ({\n n: index,\n scriptPubKey: {\n address: vout.scriptpubkey_address,\n asm: vout.scriptpubkey_asm,\n type: vout.scriptpubkey_type,\n desc: vout.scriptpubkey,\n hex: vout.scriptpubkey,\n },\n value: vout.value,\n })),\n vin: txn.vin.map((vin) => ({\n scriptSig: {\n asm: vin.scriptsig_asm,\n hex: vin.scriptsig,\n },\n sequence: vin.sequence,\n txinwitness: vin.witness,\n txid: vin.txid,\n vout: vin.vout,\n })),\n})\n"],"mappings":";;AAGA,MAAa,iCACX,SAC8B;CAC9B,MAAM,IAAI;CACV,MAAM,IAAI;CACV,MAAM,IAAI,KAAK,KAAK,MAAM,WAAW;EACnC,GAAG;EACH,cAAc;GACZ,SAAS,KAAK;GACd,KAAK,KAAK;GACV,MAAM,KAAK;GACX,MAAM,KAAK;GACX,KAAK,KAAK;EACZ;EACA,OAAO,KAAK;CACd,EAAE;CACF,KAAK,IAAI,IAAI,KAAK,SAAS;EACzB,WAAW;GACT,KAAK,IAAI;GACT,KAAK,IAAI;EACX;EACA,UAAU,IAAI;EACd,aAAa,IAAI;EACjB,MAAM,IAAI;EACV,MAAM,IAAI;CACZ,EAAE;AACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../src/transports/types.ts"],"sourcesContent":["import type { BlockStats, BlockStatsKeys } from '../types/blockStats.js'\nimport type { UTXO, UTXOTransaction } from '../types/transaction.js'\nimport type { xPubAccount } from '../types/xpub.js'\nimport type { HttpRpcClient } from './getHttpRpcClient.js'\n\nexport const UTXOAPISchemaMethods: UTXOMethod[] = [\n 'getBalance',\n 'getTransactions',\n 'getUTXOs',\n 'getTransactionFee',\n 'getXPubAddresses',\n]\n\nexport type UTXOAPISchema = [\n {\n Method: 'getBalance'\n Parameters: { address: string }\n ReturnType: bigint\n },\n {\n Method: 'getTransactions'\n Parameters: {\n address: string\n offset?: number\n limit?: number\n lastBlock?: string\n afterTxId?: string\n }\n ReturnType: {\n transactions: Array<Partial<UTXOTransaction>>\n total: number\n hasMore?: boolean\n }\n },\n {\n Method: 'getTransactionFee'\n Parameters: {\n txId: string\n }\n ReturnType: bigint\n },\n {\n Method: 'getUTXOs'\n Parameters: {\n address: string\n minValue?: number\n }\n ReturnType: Array<UTXO>\n },\n {\n Method: 'getXPubAddresses'\n Parameters: {\n xPubKey: string\n }\n ReturnType: xPubAccount\n },\n]\n\nexport type UTXOSchema = [\n {\n Method: 'getblockcount'\n Parameters: []\n ReturnType: number\n },\n {\n Method: 'getblockhash'\n Parameters: [number]\n ReturnType: string\n },\n {\n Method: 'getblock'\n Parameters: [string, number]\n ReturnType: string\n },\n {\n Method: 'getblockstats'\n Parameters: [string | number, Array<BlockStatsKeys>?]\n ReturnType: BlockStats\n },\n {\n Method: 'sendrawtransaction'\n Parameters: [string, number?]\n ReturnType: string\n },\n {\n Method: 'getrawtransaction'\n Parameters: [string, boolean, string?]\n ReturnType: UTXOTransaction\n },\n ...UTXOAPISchema,\n]\n\nexport type UTXOMethod = UTXOSchema[number]['Method']\n\nexport type SignPsbtParameters = {\n /** The PSBT encoded as a hexadecimal string */\n psbt: string\n /**\n * Array of objects specifying details about the inputs to be signed\n */\n inputsToSign: {\n /**\n * The SigHash type to use for signing (e.g., SIGHASH_ALL).\n * If not specified, a default value is used.\n */\n sigHash?: number\n /** The Bitcoin address associated with the input that will be signed */\n address: string\n /** An array of indexes in the PSBT corresponding to the inputs that need to be signed */\n signingIndexes: number[]\n }[]\n /**\n * Whether to finalize the PSBT after signing.\n * If `true`, the PSBT will be completed and ready for broadcasting.\n * If `false` or omitted, the PSBT remains partially signed.\n * Some wallets does not support it.\n */\n finalize?: boolean\n}\n\nexport type SignPsbtReturnType = string\n\nexport type UTXOWalletSchema = readonly [\n {\n Method: 'signPsbt'\n Parameters: SignPsbtParameters\n ReturnType: SignPsbtReturnType\n },\n]\n\nexport type SuccessResult<result> = {\n method?: undefined\n result: result\n error?: undefined\n}\nexport type ErrorResult<error> = {\n method?: undefined\n result?: undefined\n error: error\n}\n\nexport type RpcResponse<result = any, error = any> =\n | SuccessResult<result>\n | ErrorResult<error>\n\nexport type RpcMethodHandler<M extends UTXOMethod = UTXOMethod> = (\n client: HttpRpcClient,\n config: { baseUrl: string; apiKey?: string },\n params: Extract<UTXOSchema[number], { Method: M }>['Parameters']\n) => Promise<\n RpcResponse<Extract<UTXOSchema[number], { Method: M }>['ReturnType']>\n>\n\nexport type RpcMethods = {\n [key in UTXOMethod]?: RpcMethodHandler<key>\n}\n"],"mappings":";;AAKA,MAAa,uBAAqC;CAChD;CACA;CACA;CACA;CACA;
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/transports/types.ts"],"sourcesContent":["import type { BlockStats, BlockStatsKeys } from '../types/blockStats.js'\nimport type { UTXO, UTXOTransaction } from '../types/transaction.js'\nimport type { xPubAccount } from '../types/xpub.js'\nimport type { HttpRpcClient } from './getHttpRpcClient.js'\n\nexport const UTXOAPISchemaMethods: UTXOMethod[] = [\n 'getBalance',\n 'getTransactions',\n 'getUTXOs',\n 'getTransactionFee',\n 'getXPubAddresses',\n]\n\nexport type UTXOAPISchema = [\n {\n Method: 'getBalance'\n Parameters: { address: string }\n ReturnType: bigint\n },\n {\n Method: 'getTransactions'\n Parameters: {\n address: string\n offset?: number\n limit?: number\n lastBlock?: string\n afterTxId?: string\n }\n ReturnType: {\n transactions: Array<Partial<UTXOTransaction>>\n total: number\n hasMore?: boolean\n }\n },\n {\n Method: 'getTransactionFee'\n Parameters: {\n txId: string\n }\n ReturnType: bigint\n },\n {\n Method: 'getUTXOs'\n Parameters: {\n address: string\n minValue?: number\n }\n ReturnType: Array<UTXO>\n },\n {\n Method: 'getXPubAddresses'\n Parameters: {\n xPubKey: string\n }\n ReturnType: xPubAccount\n },\n]\n\nexport type UTXOSchema = [\n {\n Method: 'getblockcount'\n Parameters: []\n ReturnType: number\n },\n {\n Method: 'getblockhash'\n Parameters: [number]\n ReturnType: string\n },\n {\n Method: 'getblock'\n Parameters: [string, number]\n ReturnType: string\n },\n {\n Method: 'getblockstats'\n Parameters: [string | number, Array<BlockStatsKeys>?]\n ReturnType: BlockStats\n },\n {\n Method: 'sendrawtransaction'\n Parameters: [string, number?]\n ReturnType: string\n },\n {\n Method: 'getrawtransaction'\n Parameters: [string, boolean, string?]\n ReturnType: UTXOTransaction\n },\n ...UTXOAPISchema,\n]\n\nexport type UTXOMethod = UTXOSchema[number]['Method']\n\nexport type SignPsbtParameters = {\n /** The PSBT encoded as a hexadecimal string */\n psbt: string\n /**\n * Array of objects specifying details about the inputs to be signed\n */\n inputsToSign: {\n /**\n * The SigHash type to use for signing (e.g., SIGHASH_ALL).\n * If not specified, a default value is used.\n */\n sigHash?: number\n /** The Bitcoin address associated with the input that will be signed */\n address: string\n /** An array of indexes in the PSBT corresponding to the inputs that need to be signed */\n signingIndexes: number[]\n }[]\n /**\n * Whether to finalize the PSBT after signing.\n * If `true`, the PSBT will be completed and ready for broadcasting.\n * If `false` or omitted, the PSBT remains partially signed.\n * Some wallets does not support it.\n */\n finalize?: boolean\n}\n\nexport type SignPsbtReturnType = string\n\nexport type UTXOWalletSchema = readonly [\n {\n Method: 'signPsbt'\n Parameters: SignPsbtParameters\n ReturnType: SignPsbtReturnType\n },\n]\n\nexport type SuccessResult<result> = {\n method?: undefined\n result: result\n error?: undefined\n}\nexport type ErrorResult<error> = {\n method?: undefined\n result?: undefined\n error: error\n}\n\nexport type RpcResponse<result = any, error = any> =\n | SuccessResult<result>\n | ErrorResult<error>\n\nexport type RpcMethodHandler<M extends UTXOMethod = UTXOMethod> = (\n client: HttpRpcClient,\n config: { baseUrl: string; apiKey?: string },\n params: Extract<UTXOSchema[number], { Method: M }>['Parameters']\n) => Promise<\n RpcResponse<Extract<UTXOSchema[number], { Method: M }>['ReturnType']>\n>\n\nexport type RpcMethods = {\n [key in UTXOMethod]?: RpcMethodHandler<key>\n}\n"],"mappings":";;AAKA,MAAa,uBAAqC;CAChD;CACA;CACA;CACA;CACA;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utxo.js","names":["UrlRequiredError","getHttpRpcClient","getRpcProviderMethods","createTransport","idCache","RpcRequestError"],"sources":["../../../src/transports/utxo.ts"],"sourcesContent":["import { RpcRequestError } from '../errors/request.js'\nimport { UrlRequiredError } from '../errors/transport.js'\nimport { createTransport } from '../factories/createTransport.js'\nimport { idCache } from '../utils/idCache.js'\nimport { getHttpRpcClient } from './getHttpRpcClient.js'\nimport { getRpcProviderMethods } from './getRpcProviderMethods.js'\nimport type { HttpTransport, HttpTransportConfig } from './http.js'\nimport type { UTXOMethod } from './types.js'\n\ntype UTXOHttpTransportConfig = HttpTransportConfig & {\n includeChainToURL?: boolean\n apiKey?: string\n}\n\nexport function utxo(\n url?: string,\n config: UTXOHttpTransportConfig = {}\n): HttpTransport {\n const {\n fetchOptions,\n key = 'utxo',\n name = 'UTXO HTTP API',\n onFetchRequest,\n onFetchResponse,\n retryDelay,\n apiKey,\n methods,\n } = config\n\n return ({ chain, retryCount: retryCount_, timeout: timeout_ }) => {\n const retryCount = config.retryCount ?? retryCount_\n const timeout = timeout_ ?? config.timeout ?? 10_000\n let url_ = url\n if (config.includeChainToURL) {\n const chainName = chain?.name.replace(' ', '-').toLowerCase()\n url_ = `${url}${chainName ? `/${chainName}` : ''}`\n }\n if (!url_) {\n throw new UrlRequiredError()\n }\n\n const client = getHttpRpcClient(url_, {\n fetchOptions,\n onRequest: onFetchRequest,\n onResponse: onFetchResponse,\n timeout,\n })\n\n const rpcMethods = getRpcProviderMethods(key)\n\n return createTransport(\n {\n key,\n name,\n methods,\n async request({ method, params }) {\n const body = {\n jsonrpc: '2.0' as const,\n id: idCache.take(),\n method,\n params,\n }\n const methodHandler = rpcMethods?.[method as UTXOMethod]\n const { error, result } = await (methodHandler?.(\n client,\n { baseUrl: url_, apiKey },\n params\n ) ??\n client.request({\n body,\n }))\n if (error) {\n throw new RpcRequestError({\n body,\n error,\n url: url_,\n })\n }\n return result\n },\n retryCount,\n retryDelay,\n timeout,\n type: 'http',\n },\n {\n fetchOptions,\n url: url_,\n }\n )\n }\n}\n"],"mappings":";;;;;;;;AAcA,SAAgB,KACd,KACA,SAAkC,
|
|
1
|
+
{"version":3,"file":"utxo.js","names":["UrlRequiredError","getHttpRpcClient","getRpcProviderMethods","createTransport","idCache","RpcRequestError"],"sources":["../../../src/transports/utxo.ts"],"sourcesContent":["import { RpcRequestError } from '../errors/request.js'\nimport { UrlRequiredError } from '../errors/transport.js'\nimport { createTransport } from '../factories/createTransport.js'\nimport { idCache } from '../utils/idCache.js'\nimport { getHttpRpcClient } from './getHttpRpcClient.js'\nimport { getRpcProviderMethods } from './getRpcProviderMethods.js'\nimport type { HttpTransport, HttpTransportConfig } from './http.js'\nimport type { UTXOMethod } from './types.js'\n\ntype UTXOHttpTransportConfig = HttpTransportConfig & {\n includeChainToURL?: boolean\n apiKey?: string\n}\n\nexport function utxo(\n url?: string,\n config: UTXOHttpTransportConfig = {}\n): HttpTransport {\n const {\n fetchOptions,\n key = 'utxo',\n name = 'UTXO HTTP API',\n onFetchRequest,\n onFetchResponse,\n retryDelay,\n apiKey,\n methods,\n } = config\n\n return ({ chain, retryCount: retryCount_, timeout: timeout_ }) => {\n const retryCount = config.retryCount ?? retryCount_\n const timeout = timeout_ ?? config.timeout ?? 10_000\n let url_ = url\n if (config.includeChainToURL) {\n const chainName = chain?.name.replace(' ', '-').toLowerCase()\n url_ = `${url}${chainName ? `/${chainName}` : ''}`\n }\n if (!url_) {\n throw new UrlRequiredError()\n }\n\n const client = getHttpRpcClient(url_, {\n fetchOptions,\n onRequest: onFetchRequest,\n onResponse: onFetchResponse,\n timeout,\n })\n\n const rpcMethods = getRpcProviderMethods(key)\n\n return createTransport(\n {\n key,\n name,\n methods,\n async request({ method, params }) {\n const body = {\n jsonrpc: '2.0' as const,\n id: idCache.take(),\n method,\n params,\n }\n const methodHandler = rpcMethods?.[method as UTXOMethod]\n const { error, result } = await (methodHandler?.(\n client,\n { baseUrl: url_, apiKey },\n params\n ) ??\n client.request({\n body,\n }))\n if (error) {\n throw new RpcRequestError({\n body,\n error,\n url: url_,\n })\n }\n return result\n },\n retryCount,\n retryDelay,\n timeout,\n type: 'http',\n },\n {\n fetchOptions,\n url: url_,\n }\n )\n }\n}\n"],"mappings":";;;;;;;;AAcA,SAAgB,KACd,KACA,SAAkC,CAAC,GACpB;CACf,MAAM,EACJ,cACA,MAAM,QACN,OAAO,iBACP,gBACA,iBACA,YACA,QACA,YACE;CAEJ,QAAQ,EAAE,OAAO,YAAY,aAAa,SAAS,eAAe;EAChE,MAAM,aAAa,OAAO,cAAc;EACxC,MAAM,UAAU,YAAY,OAAO,WAAW;EAC9C,IAAI,OAAO;EACX,IAAI,OAAO,mBAAmB;GAC5B,MAAM,YAAY,OAAO,KAAK,QAAQ,KAAK,GAAG,EAAE,YAAY;GAC5D,OAAO,GAAG,MAAM,YAAY,IAAI,cAAc;EAChD;EACA,IAAI,CAAC,MACH,MAAM,IAAIA,yBAAAA,iBAAiB;EAG7B,MAAM,SAASC,oCAAAA,iBAAiB,MAAM;GACpC;GACA,WAAW;GACX,YAAY;GACZ;EACF,CAAC;EAED,MAAM,aAAaC,yCAAAA,sBAAsB,GAAG;EAE5C,OAAOC,kCAAAA,gBACL;GACE;GACA;GACA;GACA,MAAM,QAAQ,EAAE,QAAQ,UAAU;IAChC,MAAM,OAAO;KACX,SAAS;KACT,IAAIC,sBAAAA,QAAQ,KAAK;KACjB;KACA;IACF;IACA,MAAM,gBAAgB,aAAa;IACnC,MAAM,EAAE,OAAO,WAAW,OAAO,gBAC/B,QACA;KAAE,SAAS;KAAM;IAAO,GACxB,MACF,KACE,OAAO,QAAQ,EACb,KACF,CAAC;IACH,IAAI,OACF,MAAM,IAAIC,uBAAAA,gBAAgB;KACxB;KACA;KACA,KAAK;IACP,CAAC;IAEH,OAAO;GACT;GACA;GACA;GACA;GACA,MAAM;EACR,GACA;GACE;GACA,KAAK;EACP,CACF;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address.js","names":[],"sources":["../../../src/types/address.ts"],"sourcesContent":["import type { Network } from './chain.js'\n\nexport type Address = string\n\nexport type AddressPurpose = 'payment' | 'ordinals' | 'stacks'\n\nexport enum AddressType {\n p2pkh = 'p2pkh',\n p2sh = 'p2sh',\n p2wpkh = 'p2wpkh',\n p2wsh = 'p2wsh',\n p2tr = 'p2tr',\n}\n\nexport type AddressInfo = {\n bech32: boolean\n network: Network\n address: Address\n type: AddressType\n purpose: AddressPurpose\n}\n"],"mappings":";;AAMA,IAAY,cAAL,yBAAA,aAAA;
|
|
1
|
+
{"version":3,"file":"address.js","names":[],"sources":["../../../src/types/address.ts"],"sourcesContent":["import type { Network } from './chain.js'\n\nexport type Address = string\n\nexport type AddressPurpose = 'payment' | 'ordinals' | 'stacks'\n\nexport enum AddressType {\n p2pkh = 'p2pkh',\n p2sh = 'p2sh',\n p2wpkh = 'p2wpkh',\n p2wsh = 'p2wsh',\n p2tr = 'p2tr',\n}\n\nexport type AddressInfo = {\n bech32: boolean\n network: Network\n address: Address\n type: AddressType\n purpose: AddressPurpose\n}\n"],"mappings":";;AAMA,IAAY,cAAL,yBAAA,aAAA;CACL,YAAA,WAAA;CACA,YAAA,UAAA;CACA,YAAA,YAAA;CACA,YAAA,WAAA;CACA,YAAA,UAAA;;AACF,EAAA,CAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain.js","names":[],"sources":["../../../src/types/chain.ts"],"sourcesContent":["export enum ChainId {\n BITCOIN_MAINNET = 'bitcoin:mainnet',\n BITCOIN_TESTNET = 'bitcoin:testnet',\n BITCOIN_TESTNET4 = 'bitcoin:testnet4',\n BITCOIN_SIGNET = 'bitcoin:signet',\n FRACTAL_BITCOIN_MAINNET = 'fractal:mainnet',\n FRACTAL_BITCOIN_TESTNET = 'fractal:testnet',\n STACKS_MAINNET = 'stacks:mainnet',\n STACKS_TESTNET = 'stacks:testnet',\n}\n\nexport enum Network {\n Mainnet = 'mainnet',\n Testnet = 'testnet',\n Regtest = 'regtest',\n}\n\nexport type Chain<\n formatters extends ChainFormatters | undefined = ChainFormatters | undefined,\n custom extends Record<string, unknown> | undefined =\n | Record<string, unknown>\n | undefined,\n> = {\n /** Collection of block explorers */\n blockExplorers?:\n | {\n [key: string]: ChainBlockExplorer\n default: ChainBlockExplorer\n }\n | undefined\n /** ID in number form */\n id: ChainId\n /** Human-readable name */\n name: string\n /** Collection of RPC endpoints */\n rpcUrls: {\n [key: string]: ChainRpcUrls\n default: ChainRpcUrls\n }\n /** Flag for test networks */\n testnet?: boolean | undefined\n} & ChainConfig<formatters, custom>\n\nexport type ChainConfig<\n formatters extends ChainFormatters | undefined = ChainFormatters | undefined,\n custom extends Record<string, unknown> | undefined =\n | Record<string, unknown>\n | undefined,\n> = {\n /** Custom chain data. */\n custom?: custom | undefined\n /** Modifies how data is formatted and typed (e.g. blocks and transactions) */\n formatters?: formatters | undefined\n}\n\n/////////////////////////////////////////////////////////////////////\n// Formatters\n/////////////////////////////////////////////////////////////////////\n\nexport type ChainFormatters = {\n /** Modifies how the Block structure is formatted & typed. */\n block?: ChainFormatter<'block'> | undefined\n /** Modifies how the Transaction structure is formatted & typed. */\n transaction?: ChainFormatter<'transaction'> | undefined\n /** Modifies how the TransactionReceipt structure is formatted & typed. */\n transactionReceipt?: ChainFormatter<'transactionReceipt'> | undefined\n /** Modifies how the TransactionRequest structure is formatted & typed. */\n transactionRequest?: ChainFormatter<'transactionRequest'> | undefined\n}\n\nexport type ChainFormatter<type extends string = string> = {\n format: (args: any) => any\n type: type\n}\n\n/////////////////////////////////////////////////////////////////////\n// Constants\n/////////////////////////////////////////////////////////////////////\n\ntype ChainBlockExplorer = {\n name: string\n url: string\n apiUrl?: string | undefined\n}\n\ntype ChainRpcUrls = {\n http: readonly string[]\n webSocket?: readonly string[] | undefined\n}\n"],"mappings":";;AAAA,IAAY,UAAL,yBAAA,SAAA;
|
|
1
|
+
{"version":3,"file":"chain.js","names":[],"sources":["../../../src/types/chain.ts"],"sourcesContent":["export enum ChainId {\n BITCOIN_MAINNET = 'bitcoin:mainnet',\n BITCOIN_TESTNET = 'bitcoin:testnet',\n BITCOIN_TESTNET4 = 'bitcoin:testnet4',\n BITCOIN_SIGNET = 'bitcoin:signet',\n FRACTAL_BITCOIN_MAINNET = 'fractal:mainnet',\n FRACTAL_BITCOIN_TESTNET = 'fractal:testnet',\n STACKS_MAINNET = 'stacks:mainnet',\n STACKS_TESTNET = 'stacks:testnet',\n}\n\nexport enum Network {\n Mainnet = 'mainnet',\n Testnet = 'testnet',\n Regtest = 'regtest',\n}\n\nexport type Chain<\n formatters extends ChainFormatters | undefined = ChainFormatters | undefined,\n custom extends Record<string, unknown> | undefined =\n | Record<string, unknown>\n | undefined,\n> = {\n /** Collection of block explorers */\n blockExplorers?:\n | {\n [key: string]: ChainBlockExplorer\n default: ChainBlockExplorer\n }\n | undefined\n /** ID in number form */\n id: ChainId\n /** Human-readable name */\n name: string\n /** Collection of RPC endpoints */\n rpcUrls: {\n [key: string]: ChainRpcUrls\n default: ChainRpcUrls\n }\n /** Flag for test networks */\n testnet?: boolean | undefined\n} & ChainConfig<formatters, custom>\n\nexport type ChainConfig<\n formatters extends ChainFormatters | undefined = ChainFormatters | undefined,\n custom extends Record<string, unknown> | undefined =\n | Record<string, unknown>\n | undefined,\n> = {\n /** Custom chain data. */\n custom?: custom | undefined\n /** Modifies how data is formatted and typed (e.g. blocks and transactions) */\n formatters?: formatters | undefined\n}\n\n/////////////////////////////////////////////////////////////////////\n// Formatters\n/////////////////////////////////////////////////////////////////////\n\nexport type ChainFormatters = {\n /** Modifies how the Block structure is formatted & typed. */\n block?: ChainFormatter<'block'> | undefined\n /** Modifies how the Transaction structure is formatted & typed. */\n transaction?: ChainFormatter<'transaction'> | undefined\n /** Modifies how the TransactionReceipt structure is formatted & typed. */\n transactionReceipt?: ChainFormatter<'transactionReceipt'> | undefined\n /** Modifies how the TransactionRequest structure is formatted & typed. */\n transactionRequest?: ChainFormatter<'transactionRequest'> | undefined\n}\n\nexport type ChainFormatter<type extends string = string> = {\n format: (args: any) => any\n type: type\n}\n\n/////////////////////////////////////////////////////////////////////\n// Constants\n/////////////////////////////////////////////////////////////////////\n\ntype ChainBlockExplorer = {\n name: string\n url: string\n apiUrl?: string | undefined\n}\n\ntype ChainRpcUrls = {\n http: readonly string[]\n webSocket?: readonly string[] | undefined\n}\n"],"mappings":";;AAAA,IAAY,UAAL,yBAAA,SAAA;CACL,QAAA,qBAAA;CACA,QAAA,qBAAA;CACA,QAAA,sBAAA;CACA,QAAA,oBAAA;CACA,QAAA,6BAAA;CACA,QAAA,6BAAA;CACA,QAAA,oBAAA;CACA,QAAA,oBAAA;;AACF,EAAA,CAAA,CAAA;AAEA,IAAY,UAAL,yBAAA,SAAA;CACL,QAAA,aAAA;CACA,QAAA,aAAA;CACA,QAAA,aAAA;;AACF,EAAA,CAAA,CAAA"}
|
|
@@ -22,8 +22,8 @@ function buildRequest(request, options = {}) {
|
|
|
22
22
|
} catch (err_) {
|
|
23
23
|
const err = err_;
|
|
24
24
|
switch (err.code) {
|
|
25
|
-
case
|
|
26
|
-
case
|
|
25
|
+
case -32001: throw new require_errors_rpc.MethodNotSupportedRpcError(method);
|
|
26
|
+
case -32e3: throw new require_errors_rpc.UserRejectedRequestError(err.message);
|
|
27
27
|
case 5e3: throw new require_errors_rpc.UserRejectedRequestError(err.message);
|
|
28
28
|
default:
|
|
29
29
|
if (err_ instanceof require_errors_base.BaseError) throw err_;
|
|
@@ -50,7 +50,7 @@ function buildRequest(request, options = {}) {
|
|
|
50
50
|
function shouldRetry(error) {
|
|
51
51
|
if ("code" in error && typeof error.code === "number") {
|
|
52
52
|
if (error.code === -1) return true;
|
|
53
|
-
if (error.code ===
|
|
53
|
+
if (error.code === -32603) return true;
|
|
54
54
|
return false;
|
|
55
55
|
}
|
|
56
56
|
if (error instanceof require_errors_request.HttpRequestError && error.status) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildRequest.js","names":["MethodNotSupportedRpcError","withDedupe","withRetry","
|
|
1
|
+
{"version":3,"file":"buildRequest.js","names":["MethodNotSupportedRpcError","withDedupe","withRetry","UserRejectedRequestError","BaseError","HttpRequestError","stringToHex","stringify"],"sources":["../../../src/utils/buildRequest.ts"],"sourcesContent":["import { BaseError } from '../errors/base.js'\nimport { HttpRequestError } from '../errors/request.js'\nimport {\n MethodNotSupportedRpcError,\n RpcErrorCode,\n UserRejectedRequestError,\n} from '../errors/rpc.js'\nimport type { ErrorType } from '../errors/utils.js'\nimport type {\n BtcRpcRequestFn,\n BtcRpcRequestOptions,\n RpcSchema,\n} from '../types/request.js'\nimport { stringToHex } from './converter.js'\nimport { stringify } from './stringify.js'\nimport { withDedupe } from './withDedupe.js'\nimport { withRetry } from './withRetry.js'\n\nexport type RequestErrorType = ErrorType\n\nexport function buildRequest<request extends BtcRpcRequestFn<RpcSchema>>(\n request: request,\n options: BtcRpcRequestOptions = {}\n): BtcRpcRequestFn {\n return async (args, overrideOptions = {}) => {\n const {\n dedupe = false,\n methods,\n retryDelay = 150,\n retryCount = 3,\n uid,\n } = {\n ...options,\n ...overrideOptions,\n }\n\n const { method } = args\n if (methods?.exclude?.includes(method)) {\n throw new MethodNotSupportedRpcError(method)\n }\n if (methods?.include && !methods.include.includes(method)) {\n throw new MethodNotSupportedRpcError(method)\n }\n\n const requestId = dedupe\n ? stringToHex(`${uid}.${stringify(args)}`)\n : undefined\n return withDedupe(\n () =>\n withRetry(\n async () => {\n try {\n return await request(args)\n } catch (err_) {\n const err = err_ as unknown as BaseError\n switch (err.code) {\n case RpcErrorCode.METHOD_NOT_SUPPORTED:\n throw new MethodNotSupportedRpcError(method)\n\n case RpcErrorCode.USER_REJECTION:\n throw new UserRejectedRequestError(err.message)\n\n // CAIP-25: User Rejected Error\n // https://docs.walletconnect.com/2.0/specs/clients/sign/error-codes#rejected-caip-25\n case 5000:\n throw new UserRejectedRequestError(err.message)\n\n default:\n if (err_ instanceof BaseError) {\n throw err_\n }\n throw new BaseError('Unknown Error', { cause: err_ as Error })\n }\n }\n },\n {\n delay: ({ count, error }) => {\n // If we find a Retry-After header, let's retry after the given time.\n if (error && error instanceof HttpRequestError) {\n const retryAfter = error?.headers?.get('Retry-After')\n if (retryAfter?.match(/\\d/)) {\n return Number.parseInt(retryAfter, 10) * 1000\n }\n }\n\n // Otherwise, let's retry with an exponential backoff.\n return ~~(1 << count) * retryDelay\n },\n retryCount,\n shouldRetry: ({ error }) => shouldRetry(error),\n }\n ),\n { enabled: dedupe, id: requestId }\n )\n }\n}\n\n/** @internal */\nexport function shouldRetry(error: Error): boolean {\n if ('code' in error && typeof error.code === 'number') {\n if (error.code === -1) {\n return true // Unknown error\n }\n if (error.code === RpcErrorCode.INTERNAL_ERROR) {\n return true\n }\n return false\n }\n if (error instanceof HttpRequestError && error.status) {\n // Forbidden\n if (error.status === 403) {\n return true\n }\n // Request Timeout\n if (error.status === 408) {\n return true\n }\n // Request Entity Too Large\n if (error.status === 413) {\n return true\n }\n // Too Many Requests\n if (error.status === 429) {\n return true\n }\n // Internal Server Error\n if (error.status === 500) {\n return true\n }\n // Bad Gateway\n if (error.status === 502) {\n return true\n }\n // Service Unavailable\n if (error.status === 503) {\n return true\n }\n // Gateway Timeout\n if (error.status === 504) {\n return true\n }\n return false\n }\n return true\n}\n"],"mappings":";;;;;;;;;AAoBA,SAAgB,aACd,SACA,UAAgC,CAAC,GAChB;CACjB,OAAO,OAAO,MAAM,kBAAkB,CAAC,MAAM;EAC3C,MAAM,EACJ,SAAS,OACT,SACA,aAAa,KACb,aAAa,GACb,QACE;GACF,GAAG;GACH,GAAG;EACL;EAEA,MAAM,EAAE,WAAW;EACnB,IAAI,SAAS,SAAS,SAAS,MAAM,GACnC,MAAM,IAAIA,mBAAAA,2BAA2B,MAAM;EAE7C,IAAI,SAAS,WAAW,CAAC,QAAQ,QAAQ,SAAS,MAAM,GACtD,MAAM,IAAIA,mBAAAA,2BAA2B,MAAM;EAM7C,OAAOC,yBAAAA,iBAEHC,wBAAAA,UACE,YAAY;GACV,IAAI;IACF,OAAO,MAAM,QAAQ,IAAI;GAC3B,SAAS,MAAM;IACb,MAAM,MAAM;IACZ,QAAQ,IAAI,MAAZ;KACE,KAAA,QACE,MAAM,IAAIF,mBAAAA,2BAA2B,MAAM;KAE7C,KAAA,OACE,MAAM,IAAIG,mBAAAA,yBAAyB,IAAI,OAAO;KAIhD,KAAK,KACH,MAAM,IAAIA,mBAAAA,yBAAyB,IAAI,OAAO;KAEhD;MACE,IAAI,gBAAgBC,oBAAAA,WAClB,MAAM;MAER,MAAM,IAAIA,oBAAAA,UAAU,iBAAiB,EAAE,OAAO,KAAc,CAAC;IACjE;GACF;EACF,GACA;GACE,QAAQ,EAAE,OAAO,YAAY;IAE3B,IAAI,SAAS,iBAAiBC,uBAAAA,kBAAkB;KAC9C,MAAM,aAAa,OAAO,SAAS,IAAI,aAAa;KACpD,IAAI,YAAY,MAAM,IAAI,GACxB,OAAO,OAAO,SAAS,YAAY,EAAE,IAAI;IAE7C;IAGA,OAAO,CAAC,EAAE,KAAK,SAAS;GAC1B;GACA;GACA,cAAc,EAAE,YAAY,YAAY,KAAK;EAC/C,CACF,GACF;GAAE,SAAS;GAAQ,IAhDH,SACdC,wBAAAA,YAAY,GAAG,IAAI,GAAGC,wBAAAA,UAAU,IAAI,GAAG,IACvC,KAAA;EA8C+B,CACnC;CACF;AACF;;AAGA,SAAgB,YAAY,OAAuB;CACjD,IAAI,UAAU,SAAS,OAAO,MAAM,SAAS,UAAU;EACrD,IAAI,MAAM,SAAS,IACjB,OAAO;EAET,IAAI,MAAM,SAAA,QACR,OAAO;EAET,OAAO;CACT;CACA,IAAI,iBAAiBF,uBAAAA,oBAAoB,MAAM,QAAQ;EAErD,IAAI,MAAM,WAAW,KACnB,OAAO;EAGT,IAAI,MAAM,WAAW,KACnB,OAAO;EAGT,IAAI,MAAM,WAAW,KACnB,OAAO;EAGT,IAAI,MAAM,WAAW,KACnB,OAAO;EAGT,IAAI,MAAM,WAAW,KACnB,OAAO;EAGT,IAAI,MAAM,WAAW,KACnB,OAAO;EAGT,IAAI,MAAM,WAAW,KACnB,OAAO;EAGT,IAAI,MAAM,WAAW,KACnB,OAAO;EAET,OAAO;CACT;CACA,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cancelTransaction.js","names":["Psbt","address"],"sources":["../../../src/utils/cancelTransaction.ts"],"sourcesContent":["import { address, Psbt } from 'bitcoinjs-lib'\n\ninterface InputData {\n hash: Uint8Array\n index: number\n nonWitnessUtxo?: Uint8Array\n witnessUtxo?: {\n script: Uint8Array\n value: bigint\n }\n redeemScript?: Uint8Array\n witnessScript?: Uint8Array\n}\n\nexport function cancelTransaction(psbt: Psbt, accountAddress: string): Psbt {\n const newPsbt = new Psbt()\n const inputs = psbt.data.inputs\n const txInputs = psbt.txInputs\n\n // Add inputs to the new PSBT\n for (let i = 0; i < inputs.length; i++) {\n const input = inputs[i]\n const txInput = txInputs[i]\n const inputData: InputData = {\n hash: txInput.hash,\n index: txInput.index,\n }\n\n // Include UTXO information\n if (input.nonWitnessUtxo) {\n inputData.nonWitnessUtxo = input.nonWitnessUtxo\n } else if (input.witnessUtxo) {\n inputData.witnessUtxo = input.witnessUtxo\n } else {\n throw new Error('Input UTXO information is missing')\n }\n\n // Include scripts if necessary\n if (input.redeemScript) {\n inputData.redeemScript = input.redeemScript\n }\n if (input.witnessScript) {\n inputData.witnessScript = input.witnessScript\n }\n\n newPsbt.addInput(inputData)\n }\n\n // Compute total output amount from the original transaction\n const outputs = psbt.txOutputs\n let totalOutputValue = BigInt(0)\n\n for (const output of outputs) {\n totalOutputValue += output.value\n }\n\n if (totalOutputValue <= BigInt(0)) {\n throw new Error('Total output value must be greater than zero')\n }\n\n // Create the output to send funds back to sender's address\n const outputScript = address.toOutputScript(accountAddress)\n newPsbt.addOutput({\n script: outputScript,\n value: totalOutputValue,\n })\n\n // Modify the input sequence number to enable RBF\n newPsbt.txInputs.forEach((_, index) => {\n // Set sequence number to less than 0xfffffffe, e.g., 0xfffffffd\n newPsbt.setInputSequence(index, 0xfffffffd)\n })\n\n return newPsbt\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"cancelTransaction.js","names":["Psbt","address"],"sources":["../../../src/utils/cancelTransaction.ts"],"sourcesContent":["import { address, Psbt } from 'bitcoinjs-lib'\n\ninterface InputData {\n hash: Uint8Array\n index: number\n nonWitnessUtxo?: Uint8Array\n witnessUtxo?: {\n script: Uint8Array\n value: bigint\n }\n redeemScript?: Uint8Array\n witnessScript?: Uint8Array\n}\n\nexport function cancelTransaction(psbt: Psbt, accountAddress: string): Psbt {\n const newPsbt = new Psbt()\n const inputs = psbt.data.inputs\n const txInputs = psbt.txInputs\n\n // Add inputs to the new PSBT\n for (let i = 0; i < inputs.length; i++) {\n const input = inputs[i]\n const txInput = txInputs[i]\n const inputData: InputData = {\n hash: txInput.hash,\n index: txInput.index,\n }\n\n // Include UTXO information\n if (input.nonWitnessUtxo) {\n inputData.nonWitnessUtxo = input.nonWitnessUtxo\n } else if (input.witnessUtxo) {\n inputData.witnessUtxo = input.witnessUtxo\n } else {\n throw new Error('Input UTXO information is missing')\n }\n\n // Include scripts if necessary\n if (input.redeemScript) {\n inputData.redeemScript = input.redeemScript\n }\n if (input.witnessScript) {\n inputData.witnessScript = input.witnessScript\n }\n\n newPsbt.addInput(inputData)\n }\n\n // Compute total output amount from the original transaction\n const outputs = psbt.txOutputs\n let totalOutputValue = BigInt(0)\n\n for (const output of outputs) {\n totalOutputValue += output.value\n }\n\n if (totalOutputValue <= BigInt(0)) {\n throw new Error('Total output value must be greater than zero')\n }\n\n // Create the output to send funds back to sender's address\n const outputScript = address.toOutputScript(accountAddress)\n newPsbt.addOutput({\n script: outputScript,\n value: totalOutputValue,\n })\n\n // Modify the input sequence number to enable RBF\n newPsbt.txInputs.forEach((_, index) => {\n // Set sequence number to less than 0xfffffffe, e.g., 0xfffffffd\n newPsbt.setInputSequence(index, 0xfffffffd)\n })\n\n return newPsbt\n}\n"],"mappings":";;;AAcA,SAAgB,kBAAkB,MAAY,gBAA8B;CAC1E,MAAM,UAAU,IAAIA,cAAAA,KAAK;CACzB,MAAM,SAAS,KAAK,KAAK;CACzB,MAAM,WAAW,KAAK;CAGtB,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;EACtC,MAAM,QAAQ,OAAO;EACrB,MAAM,UAAU,SAAS;EACzB,MAAM,YAAuB;GAC3B,MAAM,QAAQ;GACd,OAAO,QAAQ;EACjB;EAGA,IAAI,MAAM,gBACR,UAAU,iBAAiB,MAAM;OAC5B,IAAI,MAAM,aACf,UAAU,cAAc,MAAM;OAE9B,MAAM,IAAI,MAAM,mCAAmC;EAIrD,IAAI,MAAM,cACR,UAAU,eAAe,MAAM;EAEjC,IAAI,MAAM,eACR,UAAU,gBAAgB,MAAM;EAGlC,QAAQ,SAAS,SAAS;CAC5B;CAGA,MAAM,UAAU,KAAK;CACrB,IAAI,mBAAmB,OAAO,CAAC;CAE/B,KAAK,MAAM,UAAU,SACnB,oBAAoB,OAAO;CAG7B,IAAI,oBAAoB,OAAO,CAAC,GAC9B,MAAM,IAAI,MAAM,8CAA8C;CAIhE,MAAM,eAAeC,cAAAA,QAAQ,eAAe,cAAc;CAC1D,QAAQ,UAAU;EAChB,QAAQ;EACR,OAAO;CACT,CAAC;CAGD,QAAQ,SAAS,SAAS,GAAG,UAAU;EAErC,QAAQ,iBAAiB,OAAO,UAAU;CAC5C,CAAC;CAED,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"converter.js","names":[],"sources":["../../../src/utils/converter.ts"],"sourcesContent":["export function hexToBase64(hex: string): string {\n const raw = hex\n .match(/.{1,2}/g)!\n .map((byte: string) => String.fromCharCode(Number.parseInt(byte, 16)))\n .join('')\n return btoa(raw)\n}\n\nexport function base64ToHex(base64: string): string {\n const raw = atob(base64)\n let hex = ''\n for (let i = 0; i < raw.length; i++) {\n const hexByte = raw.charCodeAt(i).toString(16)\n hex += hexByte.length === 2 ? hexByte : `0${hexByte}`\n }\n return hex\n}\n\nexport function base64urlEncode(str: string): string {\n const bytes = new TextEncoder().encode(str)\n const encodedString = btoa(String.fromCharCode(...bytes))\n return encodedString\n .replace(/\\+/g, '-')\n .replace(/\\//g, '_')\n .replace(/=+$/, '')\n}\n\nexport function stringToHex(value: string): string {\n const hex = Array.from(value)\n .map((char: string) => char.charCodeAt(0).toString(16).padStart(2, '0'))\n .join('')\n\n return `0x${hex}`\n}\n\nexport function hexToUnit8Array(value: string): Uint8Array {\n return new Uint8Array(\n value.match(/.{1,2}/g)?.map((byte) => Number.parseInt(byte, 16)) || []\n )\n}\n"],"mappings":";;AAAA,SAAgB,YAAY,KAAqB;CAC/C,MAAM,MAAM,IACT,MAAM,
|
|
1
|
+
{"version":3,"file":"converter.js","names":[],"sources":["../../../src/utils/converter.ts"],"sourcesContent":["export function hexToBase64(hex: string): string {\n const raw = hex\n .match(/.{1,2}/g)!\n .map((byte: string) => String.fromCharCode(Number.parseInt(byte, 16)))\n .join('')\n return btoa(raw)\n}\n\nexport function base64ToHex(base64: string): string {\n const raw = atob(base64)\n let hex = ''\n for (let i = 0; i < raw.length; i++) {\n const hexByte = raw.charCodeAt(i).toString(16)\n hex += hexByte.length === 2 ? hexByte : `0${hexByte}`\n }\n return hex\n}\n\nexport function base64urlEncode(str: string): string {\n const bytes = new TextEncoder().encode(str)\n const encodedString = btoa(String.fromCharCode(...bytes))\n return encodedString\n .replace(/\\+/g, '-')\n .replace(/\\//g, '_')\n .replace(/=+$/, '')\n}\n\nexport function stringToHex(value: string): string {\n const hex = Array.from(value)\n .map((char: string) => char.charCodeAt(0).toString(16).padStart(2, '0'))\n .join('')\n\n return `0x${hex}`\n}\n\nexport function hexToUnit8Array(value: string): Uint8Array {\n return new Uint8Array(\n value.match(/.{1,2}/g)?.map((byte) => Number.parseInt(byte, 16)) || []\n )\n}\n"],"mappings":";;AAAA,SAAgB,YAAY,KAAqB;CAC/C,MAAM,MAAM,IACT,MAAM,SAAS,EACf,KAAK,SAAiB,OAAO,aAAa,OAAO,SAAS,MAAM,EAAE,CAAC,CAAC,EACpE,KAAK,EAAE;CACV,OAAO,KAAK,GAAG;AACjB;AAEA,SAAgB,YAAY,QAAwB;CAClD,MAAM,MAAM,KAAK,MAAM;CACvB,IAAI,MAAM;CACV,KAAK,IAAI,IAAI,GAAG,IAAI,IAAI,QAAQ,KAAK;EACnC,MAAM,UAAU,IAAI,WAAW,CAAC,EAAE,SAAS,EAAE;EAC7C,OAAO,QAAQ,WAAW,IAAI,UAAU,IAAI;CAC9C;CACA,OAAO;AACT;AAEA,SAAgB,gBAAgB,KAAqB;CACnD,MAAM,QAAQ,IAAI,YAAY,EAAE,OAAO,GAAG;CAE1C,OADsB,KAAK,OAAO,aAAa,GAAG,KAAK,CACpC,EAChB,QAAQ,OAAO,GAAG,EAClB,QAAQ,OAAO,GAAG,EAClB,QAAQ,OAAO,EAAE;AACtB;AAEA,SAAgB,YAAY,OAAuB;CAKjD,OAAO,KAJK,MAAM,KAAK,KAAK,EACzB,KAAK,SAAiB,KAAK,WAAW,CAAC,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EACtE,KAAK,EAEM;AAChB;AAEA,SAAgB,gBAAgB,OAA2B;CACzD,OAAO,IAAI,WACT,MAAM,MAAM,SAAS,GAAG,KAAK,SAAS,OAAO,SAAS,MAAM,EAAE,CAAC,KAAK,CAAC,CACvE;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_utils_withResolvers = require("./withResolvers.js");
|
|
3
3
|
//#region src/utils/createBatchScheduler.ts
|
|
4
|
-
const schedulerCache =
|
|
4
|
+
const schedulerCache = /*#__PURE__*/ new Map();
|
|
5
5
|
/** @internal */
|
|
6
6
|
function createBatchScheduler({ fn, id, shouldSplitBatch, wait = 0, sort }) {
|
|
7
7
|
const exec = async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBatchScheduler.js","names":["withResolvers"],"sources":["../../../src/utils/createBatchScheduler.ts"],"sourcesContent":["import type { ErrorType } from '../errors/utils.js'\nimport { withResolvers } from './withResolvers.js'\n\ntype Resolved<returnType extends readonly unknown[] = any> = [\n result: returnType[number],\n results: returnType,\n]\n\ntype SchedulerItem = {\n args: unknown\n resolve: PromiseWithResolvers<unknown>['resolve']\n reject: PromiseWithResolvers<unknown>['reject']\n}\n\ntype BatchResultsCompareFn<result = unknown> = (a: result, b: result) => number\n\ntype CreateBatchSchedulerArguments<\n parameters = unknown,\n returnType extends readonly unknown[] = readonly unknown[],\n> = {\n fn: (args: parameters[]) => Promise<returnType>\n id: number | string\n shouldSplitBatch?: ((args: parameters[]) => boolean) | undefined\n wait?: number | undefined\n sort?: BatchResultsCompareFn<returnType[number]> | undefined\n}\n\ntype CreateBatchSchedulerReturnType<\n parameters = unknown,\n returnType extends readonly unknown[] = readonly unknown[],\n> = {\n flush: () => void\n schedule: parameters extends undefined\n ? (args?: parameters | undefined) => Promise<Resolved<returnType>>\n : (args: parameters) => Promise<Resolved<returnType>>\n}\n\nexport type CreateBatchSchedulerErrorType = ErrorType\n\nconst schedulerCache = /*#__PURE__*/ new Map<number | string, SchedulerItem[]>()\n\n/** @internal */\nexport function createBatchScheduler<\n parameters,\n returnType extends readonly unknown[],\n>({\n fn,\n id,\n shouldSplitBatch,\n wait = 0,\n sort,\n}: CreateBatchSchedulerArguments<\n parameters,\n returnType\n>): CreateBatchSchedulerReturnType<parameters, returnType> {\n const exec = async () => {\n const scheduler = getScheduler()\n flush()\n\n const args = scheduler.map(({ args }) => args)\n\n if (args.length === 0) {\n return\n }\n\n fn(args as parameters[])\n .then((data) => {\n if (sort && Array.isArray(data)) {\n data.sort(sort)\n }\n for (let i = 0; i < scheduler.length; i++) {\n const { resolve } = scheduler[i]\n resolve?.([data[i], data])\n }\n })\n .catch((err) => {\n for (let i = 0; i < scheduler.length; i++) {\n const { reject } = scheduler[i]\n reject?.(err)\n }\n })\n }\n\n const flush = () => schedulerCache.delete(id)\n\n const getBatchedArgs = () =>\n getScheduler().map(({ args }) => args) as parameters[]\n\n const getScheduler = () => schedulerCache.get(id) || []\n\n const setScheduler = (item: SchedulerItem) =>\n schedulerCache.set(id, [...getScheduler(), item])\n\n return {\n flush,\n async schedule(args: parameters) {\n const { promise, resolve, reject } = withResolvers()\n\n const split = shouldSplitBatch?.([...getBatchedArgs(), args])\n\n if (split) {\n exec()\n }\n\n const hasActiveScheduler = getScheduler().length > 0\n if (hasActiveScheduler) {\n setScheduler({ args, resolve, reject })\n return promise\n }\n\n setScheduler({ args, resolve, reject })\n setTimeout(exec, wait)\n return promise\n },\n } as unknown as CreateBatchSchedulerReturnType<parameters, returnType>\n}\n"],"mappings":";;;AAuCA,MAAM
|
|
1
|
+
{"version":3,"file":"createBatchScheduler.js","names":["withResolvers"],"sources":["../../../src/utils/createBatchScheduler.ts"],"sourcesContent":["import type { ErrorType } from '../errors/utils.js'\nimport { withResolvers } from './withResolvers.js'\n\ntype Resolved<returnType extends readonly unknown[] = any> = [\n result: returnType[number],\n results: returnType,\n]\n\ntype SchedulerItem = {\n args: unknown\n resolve: PromiseWithResolvers<unknown>['resolve']\n reject: PromiseWithResolvers<unknown>['reject']\n}\n\ntype BatchResultsCompareFn<result = unknown> = (a: result, b: result) => number\n\ntype CreateBatchSchedulerArguments<\n parameters = unknown,\n returnType extends readonly unknown[] = readonly unknown[],\n> = {\n fn: (args: parameters[]) => Promise<returnType>\n id: number | string\n shouldSplitBatch?: ((args: parameters[]) => boolean) | undefined\n wait?: number | undefined\n sort?: BatchResultsCompareFn<returnType[number]> | undefined\n}\n\ntype CreateBatchSchedulerReturnType<\n parameters = unknown,\n returnType extends readonly unknown[] = readonly unknown[],\n> = {\n flush: () => void\n schedule: parameters extends undefined\n ? (args?: parameters | undefined) => Promise<Resolved<returnType>>\n : (args: parameters) => Promise<Resolved<returnType>>\n}\n\nexport type CreateBatchSchedulerErrorType = ErrorType\n\nconst schedulerCache = /*#__PURE__*/ new Map<number | string, SchedulerItem[]>()\n\n/** @internal */\nexport function createBatchScheduler<\n parameters,\n returnType extends readonly unknown[],\n>({\n fn,\n id,\n shouldSplitBatch,\n wait = 0,\n sort,\n}: CreateBatchSchedulerArguments<\n parameters,\n returnType\n>): CreateBatchSchedulerReturnType<parameters, returnType> {\n const exec = async () => {\n const scheduler = getScheduler()\n flush()\n\n const args = scheduler.map(({ args }) => args)\n\n if (args.length === 0) {\n return\n }\n\n fn(args as parameters[])\n .then((data) => {\n if (sort && Array.isArray(data)) {\n data.sort(sort)\n }\n for (let i = 0; i < scheduler.length; i++) {\n const { resolve } = scheduler[i]\n resolve?.([data[i], data])\n }\n })\n .catch((err) => {\n for (let i = 0; i < scheduler.length; i++) {\n const { reject } = scheduler[i]\n reject?.(err)\n }\n })\n }\n\n const flush = () => schedulerCache.delete(id)\n\n const getBatchedArgs = () =>\n getScheduler().map(({ args }) => args) as parameters[]\n\n const getScheduler = () => schedulerCache.get(id) || []\n\n const setScheduler = (item: SchedulerItem) =>\n schedulerCache.set(id, [...getScheduler(), item])\n\n return {\n flush,\n async schedule(args: parameters) {\n const { promise, resolve, reject } = withResolvers()\n\n const split = shouldSplitBatch?.([...getBatchedArgs(), args])\n\n if (split) {\n exec()\n }\n\n const hasActiveScheduler = getScheduler().length > 0\n if (hasActiveScheduler) {\n setScheduler({ args, resolve, reject })\n return promise\n }\n\n setScheduler({ args, resolve, reject })\n setTimeout(exec, wait)\n return promise\n },\n } as unknown as CreateBatchSchedulerReturnType<parameters, returnType>\n}\n"],"mappings":";;;AAuCA,MAAM,+BAA+B,IAAI,IAAsC;;AAG/E,SAAgB,qBAGd,EACA,IACA,IACA,kBACA,OAAO,GACP,QAIyD;CACzD,MAAM,OAAO,YAAY;EACvB,MAAM,YAAY,aAAa;EAC/B,MAAM;EAEN,MAAM,OAAO,UAAU,KAAK,EAAE,WAAW,IAAI;EAE7C,IAAI,KAAK,WAAW,GAClB;EAGF,GAAG,IAAoB,EACpB,MAAM,SAAS;GACd,IAAI,QAAQ,MAAM,QAAQ,IAAI,GAC5B,KAAK,KAAK,IAAI;GAEhB,KAAK,IAAI,IAAI,GAAG,IAAI,UAAU,QAAQ,KAAK;IACzC,MAAM,EAAE,YAAY,UAAU;IAC9B,UAAU,CAAC,KAAK,IAAI,IAAI,CAAC;GAC3B;EACF,CAAC,EACA,OAAO,QAAQ;GACd,KAAK,IAAI,IAAI,GAAG,IAAI,UAAU,QAAQ,KAAK;IACzC,MAAM,EAAE,WAAW,UAAU;IAC7B,SAAS,GAAG;GACd;EACF,CAAC;CACL;CAEA,MAAM,cAAc,eAAe,OAAO,EAAE;CAE5C,MAAM,uBACJ,aAAa,EAAE,KAAK,EAAE,WAAW,IAAI;CAEvC,MAAM,qBAAqB,eAAe,IAAI,EAAE,KAAK,CAAC;CAEtD,MAAM,gBAAgB,SACpB,eAAe,IAAI,IAAI,CAAC,GAAG,aAAa,GAAG,IAAI,CAAC;CAElD,OAAO;EACL;EACA,MAAM,SAAS,MAAkB;GAC/B,MAAM,EAAE,SAAS,SAAS,WAAWA,4BAAAA,cAAc;GAInD,IAFc,mBAAmB,CAAC,GAAG,eAAe,GAAG,IAAI,CAAC,GAG1D,KAAK;GAIP,IAD2B,aAAa,EAAE,SAAS,GAC3B;IACtB,aAAa;KAAE;KAAM;KAAS;IAAO,CAAC;IACtC,OAAO;GACT;GAEA,aAAa;IAAE;IAAM;IAAS;GAAO,CAAC;GACtC,WAAW,MAAM,IAAI;GACrB,OAAO;EACT;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deepEqual.js","names":[],"sources":["../../../src/utils/deepEqual.ts"],"sourcesContent":["/** Forked from https://github.com/epoberezkin/fast-deep-equal */\n\nexport function deepEqual(a: any, b: any): boolean {\n if (a === b) {\n return true\n }\n\n if (a && b && typeof a === 'object' && typeof b === 'object') {\n if (a.constructor !== b.constructor) {\n return false\n }\n\n let length: number\n let i: number\n\n if (Array.isArray(a) && Array.isArray(b)) {\n length = a.length\n if (length !== b.length) {\n return false\n }\n for (i = length; i-- !== 0; ) {\n if (!deepEqual(a[i], b[i])) {\n return false\n }\n }\n return true\n }\n\n if (a.valueOf !== Object.prototype.valueOf) {\n return a.valueOf() === b.valueOf()\n }\n if (a.toString !== Object.prototype.toString) {\n return a.toString() === b.toString()\n }\n\n const keys = Object.keys(a)\n length = keys.length\n if (length !== Object.keys(b).length) {\n return false\n }\n\n for (i = length; i-- !== 0; ) {\n if (!Object.hasOwn(b, keys[i]!)) {\n return false\n }\n }\n\n for (i = length; i-- !== 0; ) {\n const key = keys[i]\n\n if (key && !deepEqual(a[key], b[key])) {\n return false\n }\n }\n\n return true\n }\n\n // true if both NaN, false otherwise\n // biome-ignore lint/suspicious/noSelfCompare: allowed in utils\n return a !== a && b !== b\n}\n"],"mappings":";;;AAEA,SAAgB,UAAU,GAAQ,GAAiB;
|
|
1
|
+
{"version":3,"file":"deepEqual.js","names":[],"sources":["../../../src/utils/deepEqual.ts"],"sourcesContent":["/** Forked from https://github.com/epoberezkin/fast-deep-equal */\n\nexport function deepEqual(a: any, b: any): boolean {\n if (a === b) {\n return true\n }\n\n if (a && b && typeof a === 'object' && typeof b === 'object') {\n if (a.constructor !== b.constructor) {\n return false\n }\n\n let length: number\n let i: number\n\n if (Array.isArray(a) && Array.isArray(b)) {\n length = a.length\n if (length !== b.length) {\n return false\n }\n for (i = length; i-- !== 0; ) {\n if (!deepEqual(a[i], b[i])) {\n return false\n }\n }\n return true\n }\n\n if (a.valueOf !== Object.prototype.valueOf) {\n return a.valueOf() === b.valueOf()\n }\n if (a.toString !== Object.prototype.toString) {\n return a.toString() === b.toString()\n }\n\n const keys = Object.keys(a)\n length = keys.length\n if (length !== Object.keys(b).length) {\n return false\n }\n\n for (i = length; i-- !== 0; ) {\n if (!Object.hasOwn(b, keys[i]!)) {\n return false\n }\n }\n\n for (i = length; i-- !== 0; ) {\n const key = keys[i]\n\n if (key && !deepEqual(a[key], b[key])) {\n return false\n }\n }\n\n return true\n }\n\n // true if both NaN, false otherwise\n // biome-ignore lint/suspicious/noSelfCompare: allowed in utils\n return a !== a && b !== b\n}\n"],"mappings":";;;AAEA,SAAgB,UAAU,GAAQ,GAAiB;CACjD,IAAI,MAAM,GACR,OAAO;CAGT,IAAI,KAAK,KAAK,OAAO,MAAM,YAAY,OAAO,MAAM,UAAU;EAC5D,IAAI,EAAE,gBAAgB,EAAE,aACtB,OAAO;EAGT,IAAI;EACJ,IAAI;EAEJ,IAAI,MAAM,QAAQ,CAAC,KAAK,MAAM,QAAQ,CAAC,GAAG;GACxC,SAAS,EAAE;GACX,IAAI,WAAW,EAAE,QACf,OAAO;GAET,KAAK,IAAI,QAAQ,QAAQ,IACvB,IAAI,CAAC,UAAU,EAAE,IAAI,EAAE,EAAE,GACvB,OAAO;GAGX,OAAO;EACT;EAEA,IAAI,EAAE,YAAY,OAAO,UAAU,SACjC,OAAO,EAAE,QAAQ,MAAM,EAAE,QAAQ;EAEnC,IAAI,EAAE,aAAa,OAAO,UAAU,UAClC,OAAO,EAAE,SAAS,MAAM,EAAE,SAAS;EAGrC,MAAM,OAAO,OAAO,KAAK,CAAC;EAC1B,SAAS,KAAK;EACd,IAAI,WAAW,OAAO,KAAK,CAAC,EAAE,QAC5B,OAAO;EAGT,KAAK,IAAI,QAAQ,QAAQ,IACvB,IAAI,CAAC,OAAO,OAAO,GAAG,KAAK,EAAG,GAC5B,OAAO;EAIX,KAAK,IAAI,QAAQ,QAAQ,IAAK;GAC5B,MAAM,MAAM,KAAK;GAEjB,IAAI,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,GAClC,OAAO;EAEX;EAEA,OAAO;CACT;CAIA,OAAO,MAAM,KAAK,MAAM;AAC1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAction.js","names":[],"sources":["../../../src/utils/getAction.ts"],"sourcesContent":["import type { PublicActions } from '../clients/decorators/public.js'\nimport type { WalletActions } from '../clients/decorators/wallet.js'\nimport type { UTXOSchema } from '../transports/types.js'\nimport type { Account } from '../types/account.js'\nimport type { Chain } from '../types/chain.js'\nimport type { Client } from '../types/client.js'\nimport type { Transport } from '../types/transport.js'\n\n/**\n * Retrieves and returns an action from the client (if exists), and falls\n * back to the tree-shakable action.\n *\n * Useful for extracting overridden actions from a client (ie. if a consumer\n * wants to override the `sendTransaction` implementation).\n */\nexport function getAction<\n transport extends Transport,\n chain extends Chain | undefined,\n account extends Account | undefined,\n rpcSchema extends UTXOSchema | undefined,\n extended extends { [key: string]: unknown },\n client extends Client<transport, chain, account, rpcSchema, extended>,\n parameters,\n returnType,\n>(\n client: client,\n actionFn: (_: any, parameters: parameters) => returnType,\n // Some minifiers drop `Function.prototype.name`, or replace it with short letters,\n // meaning that `actionFn.name` will not always work. For that case, the consumer\n // needs to pass the name explicitly.\n name: keyof PublicActions | keyof WalletActions | (string & {})\n): (parameters: parameters) => returnType {\n const action_implicit = client[actionFn.name]\n if (typeof action_implicit === 'function') {\n return action_implicit as (params: parameters) => returnType\n }\n\n const action_explicit = client[name]\n if (typeof action_explicit === 'function') {\n return action_explicit as (params: parameters) => returnType\n }\n\n return (params) => actionFn(client, params)\n}\n"],"mappings":";;;;;;;;;AAeA,SAAgB,UAUd,QACA,UAIA,MACwC;CACxC,MAAM,kBAAkB,OAAO,SAAS;
|
|
1
|
+
{"version":3,"file":"getAction.js","names":[],"sources":["../../../src/utils/getAction.ts"],"sourcesContent":["import type { PublicActions } from '../clients/decorators/public.js'\nimport type { WalletActions } from '../clients/decorators/wallet.js'\nimport type { UTXOSchema } from '../transports/types.js'\nimport type { Account } from '../types/account.js'\nimport type { Chain } from '../types/chain.js'\nimport type { Client } from '../types/client.js'\nimport type { Transport } from '../types/transport.js'\n\n/**\n * Retrieves and returns an action from the client (if exists), and falls\n * back to the tree-shakable action.\n *\n * Useful for extracting overridden actions from a client (ie. if a consumer\n * wants to override the `sendTransaction` implementation).\n */\nexport function getAction<\n transport extends Transport,\n chain extends Chain | undefined,\n account extends Account | undefined,\n rpcSchema extends UTXOSchema | undefined,\n extended extends { [key: string]: unknown },\n client extends Client<transport, chain, account, rpcSchema, extended>,\n parameters,\n returnType,\n>(\n client: client,\n actionFn: (_: any, parameters: parameters) => returnType,\n // Some minifiers drop `Function.prototype.name`, or replace it with short letters,\n // meaning that `actionFn.name` will not always work. For that case, the consumer\n // needs to pass the name explicitly.\n name: keyof PublicActions | keyof WalletActions | (string & {})\n): (parameters: parameters) => returnType {\n const action_implicit = client[actionFn.name]\n if (typeof action_implicit === 'function') {\n return action_implicit as (params: parameters) => returnType\n }\n\n const action_explicit = client[name]\n if (typeof action_explicit === 'function') {\n return action_explicit as (params: parameters) => returnType\n }\n\n return (params) => actionFn(client, params)\n}\n"],"mappings":";;;;;;;;;AAeA,SAAgB,UAUd,QACA,UAIA,MACwC;CACxC,MAAM,kBAAkB,OAAO,SAAS;CACxC,IAAI,OAAO,oBAAoB,YAC7B,OAAO;CAGT,MAAM,kBAAkB,OAAO;CAC/B,IAAI,OAAO,oBAAoB,YAC7B,OAAO;CAGT,QAAQ,WAAW,SAAS,QAAQ,MAAM;AAC5C"}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_runtime = require("../_virtual/_rolldown/runtime.js");
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
require("../types/chain.js");
|
|
4
|
+
require("../types/address.js");
|
|
5
5
|
let _noble_hashes_sha256 = require("@noble/hashes/sha256");
|
|
6
6
|
let bech32 = require("bech32");
|
|
7
7
|
let bs58 = require("bs58");
|
|
8
|
-
bs58 = require_runtime.__toESM(bs58);
|
|
8
|
+
bs58 = require_runtime.__toESM(bs58, 1);
|
|
9
9
|
//#region src/utils/getAddressInfo.ts
|
|
10
10
|
const addressTypes = {
|
|
11
11
|
0: {
|
|
12
|
-
type:
|
|
13
|
-
network:
|
|
12
|
+
type: "p2pkh",
|
|
13
|
+
network: "mainnet"
|
|
14
14
|
},
|
|
15
15
|
111: {
|
|
16
|
-
type:
|
|
17
|
-
network:
|
|
16
|
+
type: "p2pkh",
|
|
17
|
+
network: "testnet"
|
|
18
18
|
},
|
|
19
19
|
5: {
|
|
20
|
-
type:
|
|
21
|
-
network:
|
|
20
|
+
type: "p2sh",
|
|
21
|
+
network: "mainnet"
|
|
22
22
|
},
|
|
23
23
|
196: {
|
|
24
|
-
type:
|
|
25
|
-
network:
|
|
24
|
+
type: "p2sh",
|
|
25
|
+
network: "testnet"
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
const parseBech32 = (address) => {
|
|
@@ -34,18 +34,18 @@ const parseBech32 = (address) => {
|
|
|
34
34
|
throw new Error("Invalid address");
|
|
35
35
|
}
|
|
36
36
|
const network = {
|
|
37
|
-
bc:
|
|
38
|
-
tb:
|
|
39
|
-
bcrt:
|
|
37
|
+
bc: "mainnet",
|
|
38
|
+
tb: "testnet",
|
|
39
|
+
bcrt: "regtest"
|
|
40
40
|
}[decoded.prefix];
|
|
41
41
|
if (network === void 0) throw new Error("Invalid address");
|
|
42
42
|
const witnessVersion = decoded.words[0];
|
|
43
43
|
if (witnessVersion < 0 || witnessVersion > 16) throw new Error("Invalid address");
|
|
44
44
|
const data = bech32.bech32.fromWords(decoded.words.slice(1));
|
|
45
45
|
let type;
|
|
46
|
-
if (data.length === 20) type =
|
|
47
|
-
else if (witnessVersion === 1) type =
|
|
48
|
-
else type =
|
|
46
|
+
if (data.length === 20) type = "p2wpkh";
|
|
47
|
+
else if (witnessVersion === 1) type = "p2tr";
|
|
48
|
+
else type = "p2wsh";
|
|
49
49
|
const purpose = getAddressPurpose(type);
|
|
50
50
|
return {
|
|
51
51
|
bech32: true,
|
|
@@ -81,20 +81,20 @@ const getAddressInfo = (address) => {
|
|
|
81
81
|
};
|
|
82
82
|
const getAddressPurpose = (type) => {
|
|
83
83
|
switch (type) {
|
|
84
|
-
case
|
|
85
|
-
case
|
|
86
|
-
case
|
|
87
|
-
case
|
|
88
|
-
case
|
|
84
|
+
case "p2tr": return "ordinals";
|
|
85
|
+
case "p2wsh": return "stacks";
|
|
86
|
+
case "p2wpkh":
|
|
87
|
+
case "p2sh":
|
|
88
|
+
case "p2pkh": return "payment";
|
|
89
89
|
default: throw new Error("Invalid address type");
|
|
90
90
|
}
|
|
91
91
|
};
|
|
92
92
|
const getAddressChainId = (address) => {
|
|
93
93
|
switch (getAddressInfo(address).network) {
|
|
94
|
-
case
|
|
95
|
-
case
|
|
96
|
-
case
|
|
97
|
-
default: return
|
|
94
|
+
case "mainnet": return "bitcoin:mainnet";
|
|
95
|
+
case "testnet": return "bitcoin:testnet";
|
|
96
|
+
case "regtest": return "bitcoin:signet";
|
|
97
|
+
default: return "bitcoin:mainnet";
|
|
98
98
|
}
|
|
99
99
|
};
|
|
100
100
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAddressInfo.js","names":["
|
|
1
|
+
{"version":3,"file":"getAddressInfo.js","names":["bech32m"],"sources":["../../../src/utils/getAddressInfo.ts"],"sourcesContent":["import { sha256 } from '@noble/hashes/sha256'\nimport { bech32, bech32m, type Decoded } from 'bech32'\nimport bs58 from 'bs58'\n\nimport {\n type Address,\n type AddressInfo,\n type AddressPurpose,\n AddressType,\n} from '../types/address.js'\nimport { ChainId, Network } from '../types/chain.js'\n\nconst addressTypes: {\n [key: number]: { type: AddressType; network: Network }\n} = {\n 0: {\n type: AddressType.p2pkh,\n network: Network.Mainnet,\n },\n 111: {\n type: AddressType.p2pkh,\n network: Network.Testnet,\n },\n 5: {\n type: AddressType.p2sh,\n network: Network.Mainnet,\n },\n 196: {\n type: AddressType.p2sh,\n network: Network.Testnet,\n },\n}\n\nconst parseBech32 = (address: Address): AddressInfo => {\n let decoded: Decoded\n\n try {\n if (\n address.startsWith('bc1p') ||\n address.startsWith('tb1p') ||\n address.startsWith('bcrt1p')\n ) {\n decoded = bech32m.decode(address)\n } else {\n decoded = bech32.decode(address)\n }\n } catch (_error) {\n throw new Error('Invalid address')\n }\n\n const mapPrefixToNetwork: { [key: string]: Network } = {\n bc: Network.Mainnet,\n tb: Network.Testnet,\n bcrt: Network.Regtest,\n }\n\n const network: Network = mapPrefixToNetwork[decoded.prefix]\n\n if (network === undefined) {\n throw new Error('Invalid address')\n }\n\n const witnessVersion = decoded.words[0]\n\n if (witnessVersion < 0 || witnessVersion > 16) {\n throw new Error('Invalid address')\n }\n const data = bech32.fromWords(decoded.words.slice(1))\n\n let type: AddressType\n if (data.length === 20) {\n type = AddressType.p2wpkh\n } else if (witnessVersion === 1) {\n type = AddressType.p2tr\n } else {\n type = AddressType.p2wsh\n }\n\n const purpose = getAddressPurpose(type)\n\n return {\n bech32: true,\n network,\n address,\n type,\n purpose,\n }\n}\n\nexport const getAddressInfo = (address: Address): AddressInfo => {\n let decoded: Uint8Array\n const prefix = address.substring(0, 2).toLowerCase()\n\n if (prefix === 'bc' || prefix === 'tb') {\n return parseBech32(address)\n }\n\n try {\n decoded = bs58.decode(address)\n } catch (_error) {\n throw new Error('Invalid address')\n }\n\n const { length } = decoded\n\n if (length !== 25) {\n throw new Error('Invalid address')\n }\n\n const version = decoded[0]\n\n const checksum = decoded.slice(length - 4, length)\n const body = decoded.slice(0, length - 4)\n\n const expectedChecksum = sha256(sha256(body)).slice(0, 4)\n\n if (\n checksum.some(\n (value: number, index: number) => value !== expectedChecksum[index]\n )\n ) {\n throw new Error('Invalid address')\n }\n\n const validVersions = Object.keys(addressTypes).map(Number)\n\n if (!validVersions.includes(version)) {\n throw new Error('Invalid address')\n }\n\n const addressType = addressTypes[version]\n\n return {\n ...addressType,\n address,\n bech32: false,\n purpose: getAddressPurpose(addressType.type),\n }\n}\n\nconst getAddressPurpose = (type: AddressType): AddressPurpose => {\n switch (type) {\n case AddressType.p2tr:\n return 'ordinals'\n case AddressType.p2wsh:\n return 'stacks'\n case AddressType.p2wpkh:\n case AddressType.p2sh:\n case AddressType.p2pkh:\n return 'payment'\n default:\n throw new Error('Invalid address type')\n }\n}\n\nexport const getAddressChainId = (address: Address): ChainId => {\n const addressInfo = getAddressInfo(address)\n\n switch (addressInfo.network) {\n case Network.Mainnet:\n return ChainId.BITCOIN_MAINNET\n case Network.Testnet:\n return ChainId.BITCOIN_TESTNET\n case Network.Regtest:\n return ChainId.BITCOIN_SIGNET\n default:\n return ChainId.BITCOIN_MAINNET\n }\n}\n"],"mappings":";;;;;;;;;AAYA,MAAM,eAEF;CACF,GAAG;EACD,MAAA;EACA,SAAA;CACF;CACA,KAAK;EACH,MAAA;EACA,SAAA;CACF;CACA,GAAG;EACD,MAAA;EACA,SAAA;CACF;CACA,KAAK;EACH,MAAA;EACA,SAAA;CACF;AACF;AAEA,MAAM,eAAe,YAAkC;CACrD,IAAI;CAEJ,IAAI;EACF,IACE,QAAQ,WAAW,MAAM,KACzB,QAAQ,WAAW,MAAM,KACzB,QAAQ,WAAW,QAAQ,GAE3B,UAAUA,OAAAA,QAAQ,OAAO,OAAO;OAEhC,UAAU,OAAA,OAAO,OAAO,OAAO;CAEnC,SAAS,QAAQ;EACf,MAAM,IAAI,MAAM,iBAAiB;CACnC;CAQA,MAAM,UAAmB;EALvB,IAAA;EACA,IAAA;EACA,MAAA;CAGwC,EAAE,QAAQ;CAEpD,IAAI,YAAY,KAAA,GACd,MAAM,IAAI,MAAM,iBAAiB;CAGnC,MAAM,iBAAiB,QAAQ,MAAM;CAErC,IAAI,iBAAiB,KAAK,iBAAiB,IACzC,MAAM,IAAI,MAAM,iBAAiB;CAEnC,MAAM,OAAO,OAAA,OAAO,UAAU,QAAQ,MAAM,MAAM,CAAC,CAAC;CAEpD,IAAI;CACJ,IAAI,KAAK,WAAW,IAClB,OAAA;MACK,IAAI,mBAAmB,GAC5B,OAAA;MAEA,OAAA;CAGF,MAAM,UAAU,kBAAkB,IAAI;CAEtC,OAAO;EACL,QAAQ;EACR;EACA;EACA;EACA;CACF;AACF;AAEA,MAAa,kBAAkB,YAAkC;CAC/D,IAAI;CACJ,MAAM,SAAS,QAAQ,UAAU,GAAG,CAAC,EAAE,YAAY;CAEnD,IAAI,WAAW,QAAQ,WAAW,MAChC,OAAO,YAAY,OAAO;CAG5B,IAAI;EACF,UAAU,KAAA,QAAK,OAAO,OAAO;CAC/B,SAAS,QAAQ;EACf,MAAM,IAAI,MAAM,iBAAiB;CACnC;CAEA,MAAM,EAAE,WAAW;CAEnB,IAAI,WAAW,IACb,MAAM,IAAI,MAAM,iBAAiB;CAGnC,MAAM,UAAU,QAAQ;CAExB,MAAM,WAAW,QAAQ,MAAM,SAAS,GAAG,MAAM;CAGjD,MAAM,oBAAA,GAAA,qBAAA,SAAA,GAAA,qBAAA,QAFO,QAAQ,MAAM,GAAG,SAAS,CAEG,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC;CAExD,IACE,SAAS,MACN,OAAe,UAAkB,UAAU,iBAAiB,MAC/D,GAEA,MAAM,IAAI,MAAM,iBAAiB;CAKnC,IAAI,CAFkB,OAAO,KAAK,YAAY,EAAE,IAAI,MAEnC,EAAE,SAAS,OAAO,GACjC,MAAM,IAAI,MAAM,iBAAiB;CAGnC,MAAM,cAAc,aAAa;CAEjC,OAAO;EACL,GAAG;EACH;EACA,QAAQ;EACR,SAAS,kBAAkB,YAAY,IAAI;CAC7C;AACF;AAEA,MAAM,qBAAqB,SAAsC;CAC/D,QAAQ,MAAR;EACE,KAAA,QACE,OAAO;EACT,KAAA,SACE,OAAO;EACT,KAAA;EACA,KAAA;EACA,KAAA,SACE,OAAO;EACT,SACE,MAAM,IAAI,MAAM,sBAAsB;CAC1C;AACF;AAEA,MAAa,qBAAqB,YAA8B;CAG9D,QAFoB,eAAe,OAEjB,EAAE,SAApB;EACE,KAAA,WACE,OAAA;EACF,KAAA,WACE,OAAA;EACF,KAAA,WACE,OAAA;EACF,SACE,OAAA;CACJ;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idCache.js","names":[],"sources":["../../../src/utils/idCache.ts"],"sourcesContent":["function createIdStore() {\n return {\n current: 0,\n take() {\n return this.current++\n },\n reset() {\n this.current = 0\n },\n }\n}\n\nexport const idCache: { current: number; take(): number; reset(): void } =\n createIdStore()\n"],"mappings":";;AAAA,SAAS,gBAAgB;
|
|
1
|
+
{"version":3,"file":"idCache.js","names":[],"sources":["../../../src/utils/idCache.ts"],"sourcesContent":["function createIdStore() {\n return {\n current: 0,\n take() {\n return this.current++\n },\n reset() {\n this.current = 0\n },\n }\n}\n\nexport const idCache: { current: number; take(): number; reset(): void } =\n createIdStore()\n"],"mappings":";;AAAA,SAAS,gBAAgB;CACvB,OAAO;EACL,SAAS;EACT,OAAO;GACL,OAAO,KAAK;EACd;EACA,QAAQ;GACN,KAAK,UAAU;EACjB;CACF;AACF;AAEA,MAAa,UACX,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isAddress.js","names":["getAddressInfo"],"sources":["../../../src/utils/isAddress.ts"],"sourcesContent":["import type { Address } from '../types/address.js'\nimport type { Network } from '../types/chain.js'\nimport { getAddressInfo } from './getAddressInfo.js'\n\nexport const isAddress = (address: string, network?: Network): boolean => {\n try {\n const addressInfo = getAddressInfo(address as Address)\n\n if (network) {\n return network === addressInfo.network\n }\n\n return true\n } catch (_error) {\n return false\n }\n}\n"],"mappings":";;;AAIA,MAAa,aAAa,SAAiB,YAA+B;
|
|
1
|
+
{"version":3,"file":"isAddress.js","names":["getAddressInfo"],"sources":["../../../src/utils/isAddress.ts"],"sourcesContent":["import type { Address } from '../types/address.js'\nimport type { Network } from '../types/chain.js'\nimport { getAddressInfo } from './getAddressInfo.js'\n\nexport const isAddress = (address: string, network?: Network): boolean => {\n try {\n const addressInfo = getAddressInfo(address as Address)\n\n if (network) {\n return network === addressInfo.network\n }\n\n return true\n } catch (_error) {\n return false\n }\n}\n"],"mappings":";;;AAIA,MAAa,aAAa,SAAiB,YAA+B;CACxE,IAAI;EACF,MAAM,cAAcA,6BAAAA,eAAe,OAAkB;EAErD,IAAI,SACF,OAAO,YAAY,YAAY;EAGjC,OAAO;CACT,SAAS,QAAQ;EACf,OAAO;CACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lru.js","names":[],"sources":["../../../src/utils/lru.ts"],"sourcesContent":["/**\n * Map with a LRU (Least recently used) policy.\n *\n * @link https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU\n */\nexport class LruMap<value = unknown> extends Map<string, value> {\n maxSize: number\n\n constructor(size: number) {\n super()\n this.maxSize = size\n }\n\n override get(key: string): value | undefined {\n const value = super.get(key)\n\n if (super.has(key) && value !== undefined) {\n this.delete(key)\n super.set(key, value)\n }\n\n return value\n }\n\n override set(key: string, value: value): this {\n super.set(key, value)\n if (this.maxSize && this.size > this.maxSize) {\n const firstKey = this.keys().next().value\n if (firstKey) {\n this.delete(firstKey)\n }\n }\n return this\n }\n}\n"],"mappings":";;;;;;;AAKA,IAAa,SAAb,cAA6C,IAAmB;CAG9D,YAAY,MAAc;
|
|
1
|
+
{"version":3,"file":"lru.js","names":[],"sources":["../../../src/utils/lru.ts"],"sourcesContent":["/**\n * Map with a LRU (Least recently used) policy.\n *\n * @link https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU\n */\nexport class LruMap<value = unknown> extends Map<string, value> {\n maxSize: number\n\n constructor(size: number) {\n super()\n this.maxSize = size\n }\n\n override get(key: string): value | undefined {\n const value = super.get(key)\n\n if (super.has(key) && value !== undefined) {\n this.delete(key)\n super.set(key, value)\n }\n\n return value\n }\n\n override set(key: string, value: value): this {\n super.set(key, value)\n if (this.maxSize && this.size > this.maxSize) {\n const firstKey = this.keys().next().value\n if (firstKey) {\n this.delete(firstKey)\n }\n }\n return this\n }\n}\n"],"mappings":";;;;;;;AAKA,IAAa,SAAb,cAA6C,IAAmB;CAG9D,YAAY,MAAc;EACxB,MAAM;EACN,KAAK,UAAU;CACjB;CAEA,IAAa,KAAgC;EAC3C,MAAM,QAAQ,MAAM,IAAI,GAAG;EAE3B,IAAI,MAAM,IAAI,GAAG,KAAK,UAAU,KAAA,GAAW;GACzC,KAAK,OAAO,GAAG;GACf,MAAM,IAAI,KAAK,KAAK;EACtB;EAEA,OAAO;CACT;CAEA,IAAa,KAAa,OAAoB;EAC5C,MAAM,IAAI,KAAK,KAAK;EACpB,IAAI,KAAK,WAAW,KAAK,OAAO,KAAK,SAAS;GAC5C,MAAM,WAAW,KAAK,KAAK,EAAE,KAAK,EAAE;GACpC,IAAI,UACF,KAAK,OAAO,QAAQ;EAExB;EACA,OAAO;CACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modifyFee.js","names":["Psbt","address"],"sources":["../../../src/utils/modifyFee.ts"],"sourcesContent":["import { address, Psbt } from 'bitcoinjs-lib'\n\ninterface InputData {\n hash: Uint8Array\n index: number\n nonWitnessUtxo?: Uint8Array\n witnessUtxo?: {\n script: Uint8Array\n value: bigint\n }\n redeemScript?: Uint8Array\n witnessScript?: Uint8Array\n}\n\nexport function modifyFee(\n psbt: Psbt,\n newFee: bigint,\n accountAddress: string\n): Psbt {\n const newPsbt = new Psbt()\n const inputs = psbt.data.inputs\n const outputs = psbt.txOutputs\n\n // Add inputs to the new PSBT\n for (let i = 0; i < inputs.length; i++) {\n const input = inputs[i]\n const inputData: InputData = {\n hash: psbt.txInputs[i].hash,\n index: psbt.txInputs[i].index,\n }\n\n // Include UTXO information\n if (input.nonWitnessUtxo) {\n inputData.nonWitnessUtxo = input.nonWitnessUtxo\n } else if (input.witnessUtxo) {\n inputData.witnessUtxo = input.witnessUtxo\n }\n\n // Include scripts if necessary\n if (input.redeemScript) {\n inputData.redeemScript = input.redeemScript\n }\n if (input.witnessScript) {\n inputData.witnessScript = input.witnessScript\n }\n\n newPsbt.addInput(inputData)\n }\n\n const changeOutputScript = address.toOutputScript(accountAddress)\n\n // Add outputs to the new PSBT\n for (const output of outputs) {\n const outputData = {\n script: output.script,\n value: output.value,\n }\n\n const scriptsAreEqual =\n output.script.length === changeOutputScript.length &&\n output.script.every((value, index) => value === changeOutputScript[index])\n\n if (scriptsAreEqual) {\n outputData.value = output.value - newFee\n if (outputData.value < 0) {\n throw new Error(\n 'Insufficient funds to adjust the fee by the specified amount.'\n )\n }\n }\n\n newPsbt.addOutput(outputData)\n }\n\n // Modify the input sequence number to enable RBF\n newPsbt.txInputs.forEach((_, index) => {\n // Set sequence number to less than 0xfffffffe, e.g., 0xfffffffd\n newPsbt.setInputSequence(index, 0xfffffffd)\n })\n\n return newPsbt\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"modifyFee.js","names":["Psbt","address"],"sources":["../../../src/utils/modifyFee.ts"],"sourcesContent":["import { address, Psbt } from 'bitcoinjs-lib'\n\ninterface InputData {\n hash: Uint8Array\n index: number\n nonWitnessUtxo?: Uint8Array\n witnessUtxo?: {\n script: Uint8Array\n value: bigint\n }\n redeemScript?: Uint8Array\n witnessScript?: Uint8Array\n}\n\nexport function modifyFee(\n psbt: Psbt,\n newFee: bigint,\n accountAddress: string\n): Psbt {\n const newPsbt = new Psbt()\n const inputs = psbt.data.inputs\n const outputs = psbt.txOutputs\n\n // Add inputs to the new PSBT\n for (let i = 0; i < inputs.length; i++) {\n const input = inputs[i]\n const inputData: InputData = {\n hash: psbt.txInputs[i].hash,\n index: psbt.txInputs[i].index,\n }\n\n // Include UTXO information\n if (input.nonWitnessUtxo) {\n inputData.nonWitnessUtxo = input.nonWitnessUtxo\n } else if (input.witnessUtxo) {\n inputData.witnessUtxo = input.witnessUtxo\n }\n\n // Include scripts if necessary\n if (input.redeemScript) {\n inputData.redeemScript = input.redeemScript\n }\n if (input.witnessScript) {\n inputData.witnessScript = input.witnessScript\n }\n\n newPsbt.addInput(inputData)\n }\n\n const changeOutputScript = address.toOutputScript(accountAddress)\n\n // Add outputs to the new PSBT\n for (const output of outputs) {\n const outputData = {\n script: output.script,\n value: output.value,\n }\n\n const scriptsAreEqual =\n output.script.length === changeOutputScript.length &&\n output.script.every((value, index) => value === changeOutputScript[index])\n\n if (scriptsAreEqual) {\n outputData.value = output.value - newFee\n if (outputData.value < 0) {\n throw new Error(\n 'Insufficient funds to adjust the fee by the specified amount.'\n )\n }\n }\n\n newPsbt.addOutput(outputData)\n }\n\n // Modify the input sequence number to enable RBF\n newPsbt.txInputs.forEach((_, index) => {\n // Set sequence number to less than 0xfffffffe, e.g., 0xfffffffd\n newPsbt.setInputSequence(index, 0xfffffffd)\n })\n\n return newPsbt\n}\n"],"mappings":";;;AAcA,SAAgB,UACd,MACA,QACA,gBACM;CACN,MAAM,UAAU,IAAIA,cAAAA,KAAK;CACzB,MAAM,SAAS,KAAK,KAAK;CACzB,MAAM,UAAU,KAAK;CAGrB,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;EACtC,MAAM,QAAQ,OAAO;EACrB,MAAM,YAAuB;GAC3B,MAAM,KAAK,SAAS,GAAG;GACvB,OAAO,KAAK,SAAS,GAAG;EAC1B;EAGA,IAAI,MAAM,gBACR,UAAU,iBAAiB,MAAM;OAC5B,IAAI,MAAM,aACf,UAAU,cAAc,MAAM;EAIhC,IAAI,MAAM,cACR,UAAU,eAAe,MAAM;EAEjC,IAAI,MAAM,eACR,UAAU,gBAAgB,MAAM;EAGlC,QAAQ,SAAS,SAAS;CAC5B;CAEA,MAAM,qBAAqBC,cAAAA,QAAQ,eAAe,cAAc;CAGhE,KAAK,MAAM,UAAU,SAAS;EAC5B,MAAM,aAAa;GACjB,QAAQ,OAAO;GACf,OAAO,OAAO;EAChB;EAMA,IAHE,OAAO,OAAO,WAAW,mBAAmB,UAC5C,OAAO,OAAO,OAAO,OAAO,UAAU,UAAU,mBAAmB,MAAM,GAEtD;GACnB,WAAW,QAAQ,OAAO,QAAQ;GAClC,IAAI,WAAW,QAAQ,GACrB,MAAM,IAAI,MACR,+DACF;EAEJ;EAEA,QAAQ,UAAU,UAAU;CAC9B;CAGA,QAAQ,SAAS,SAAS,GAAG,UAAU;EAErC,QAAQ,iBAAiB,OAAO,UAAU;CAC5C,CAAC;CAED,OAAO;AACT"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
//#region src/utils/observe.ts
|
|
3
3
|
/** @internal */
|
|
4
|
-
const listenersCache =
|
|
4
|
+
const listenersCache = /*#__PURE__*/ new Map();
|
|
5
5
|
/** @internal */
|
|
6
|
-
const cleanupCache =
|
|
6
|
+
const cleanupCache = /*#__PURE__*/ new Map();
|
|
7
7
|
let callbackCount = 0;
|
|
8
8
|
/**
|
|
9
9
|
* @description Sets up an observer for a given function. If another function
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observe.js","names":[],"sources":["../../../src/utils/observe.ts"],"sourcesContent":["import type { MaybePromise } from '../types/utils.js'\n\ntype Callback = ((...args: any[]) => any) | undefined\ntype Callbacks = Record<string, Callback>\n\n/** @internal */\nexport const listenersCache: Map<string, { id: number; fns: Callbacks }[]> =\n /*#__PURE__*/ new Map()\n/** @internal */\nexport const cleanupCache: Map<string, () => void> = /*#__PURE__*/ new Map()\n\ntype EmitFunction<callbacks extends Callbacks> = (\n emit: callbacks\n) => MaybePromise<void | (() => void)>\n\nlet callbackCount = 0\n\n/**\n * @description Sets up an observer for a given function. If another function\n * is set up under the same observer id, the function will only be called once\n * for both instances of the observer.\n */\nexport function observe<callbacks extends Callbacks>(\n observerId: string,\n callbacks: callbacks,\n fn: EmitFunction<callbacks>\n): () => void {\n const callbackId = ++callbackCount\n\n const getListeners = () => listenersCache.get(observerId) || []\n\n const unsubscribe = () => {\n const listeners = getListeners()\n listenersCache.set(\n observerId,\n listeners.filter((cb: any) => cb.id !== callbackId)\n )\n }\n\n const unwatch = () => {\n const cleanup = cleanupCache.get(observerId)\n if (getListeners().length === 1 && cleanup) {\n cleanup()\n }\n unsubscribe()\n }\n\n const listeners = getListeners()\n listenersCache.set(observerId, [\n ...listeners,\n { id: callbackId, fns: callbacks },\n ])\n\n if (listeners && listeners.length > 0) {\n return unwatch\n }\n\n const emit: callbacks = {} as callbacks\n for (const key in callbacks) {\n emit[key] = ((\n ...args: Parameters<NonNullable<callbacks[keyof callbacks]>>\n ) => {\n const listeners = getListeners()\n if (listeners.length === 0) {\n return\n }\n for (const listener of listeners) {\n listener.fns[key]?.(...args)\n }\n }) as callbacks[Extract<keyof callbacks, string>]\n }\n\n const cleanup = fn(emit)\n if (typeof cleanup === 'function') {\n cleanupCache.set(observerId, cleanup)\n }\n\n return unwatch\n}\n"],"mappings":";;;AAMA,MAAa,
|
|
1
|
+
{"version":3,"file":"observe.js","names":[],"sources":["../../../src/utils/observe.ts"],"sourcesContent":["import type { MaybePromise } from '../types/utils.js'\n\ntype Callback = ((...args: any[]) => any) | undefined\ntype Callbacks = Record<string, Callback>\n\n/** @internal */\nexport const listenersCache: Map<string, { id: number; fns: Callbacks }[]> =\n /*#__PURE__*/ new Map()\n/** @internal */\nexport const cleanupCache: Map<string, () => void> = /*#__PURE__*/ new Map()\n\ntype EmitFunction<callbacks extends Callbacks> = (\n emit: callbacks\n) => MaybePromise<void | (() => void)>\n\nlet callbackCount = 0\n\n/**\n * @description Sets up an observer for a given function. If another function\n * is set up under the same observer id, the function will only be called once\n * for both instances of the observer.\n */\nexport function observe<callbacks extends Callbacks>(\n observerId: string,\n callbacks: callbacks,\n fn: EmitFunction<callbacks>\n): () => void {\n const callbackId = ++callbackCount\n\n const getListeners = () => listenersCache.get(observerId) || []\n\n const unsubscribe = () => {\n const listeners = getListeners()\n listenersCache.set(\n observerId,\n listeners.filter((cb: any) => cb.id !== callbackId)\n )\n }\n\n const unwatch = () => {\n const cleanup = cleanupCache.get(observerId)\n if (getListeners().length === 1 && cleanup) {\n cleanup()\n }\n unsubscribe()\n }\n\n const listeners = getListeners()\n listenersCache.set(observerId, [\n ...listeners,\n { id: callbackId, fns: callbacks },\n ])\n\n if (listeners && listeners.length > 0) {\n return unwatch\n }\n\n const emit: callbacks = {} as callbacks\n for (const key in callbacks) {\n emit[key] = ((\n ...args: Parameters<NonNullable<callbacks[keyof callbacks]>>\n ) => {\n const listeners = getListeners()\n if (listeners.length === 0) {\n return\n }\n for (const listener of listeners) {\n listener.fns[key]?.(...args)\n }\n }) as callbacks[Extract<keyof callbacks, string>]\n }\n\n const cleanup = fn(emit)\n if (typeof cleanup === 'function') {\n cleanupCache.set(observerId, cleanup)\n }\n\n return unwatch\n}\n"],"mappings":";;;AAMA,MAAa,+BACG,IAAI,IAAI;;AAExB,MAAa,6BAAsD,IAAI,IAAI;AAM3E,IAAI,gBAAgB;;;;;;AAOpB,SAAgB,QACd,YACA,WACA,IACY;CACZ,MAAM,aAAa,EAAE;CAErB,MAAM,qBAAqB,eAAe,IAAI,UAAU,KAAK,CAAC;CAE9D,MAAM,oBAAoB;EACxB,MAAM,YAAY,aAAa;EAC/B,eAAe,IACb,YACA,UAAU,QAAQ,OAAY,GAAG,OAAO,UAAU,CACpD;CACF;CAEA,MAAM,gBAAgB;EACpB,MAAM,UAAU,aAAa,IAAI,UAAU;EAC3C,IAAI,aAAa,EAAE,WAAW,KAAK,SACjC,QAAQ;EAEV,YAAY;CACd;CAEA,MAAM,YAAY,aAAa;CAC/B,eAAe,IAAI,YAAY,CAC7B,GAAG,WACH;EAAE,IAAI;EAAY,KAAK;CAAU,CACnC,CAAC;CAED,IAAI,aAAa,UAAU,SAAS,GAClC,OAAO;CAGT,MAAM,OAAkB,CAAC;CACzB,KAAK,MAAM,OAAO,WAChB,KAAK,SACH,GAAG,SACA;EACH,MAAM,YAAY,aAAa;EAC/B,IAAI,UAAU,WAAW,GACvB;EAEF,KAAK,MAAM,YAAY,WACrB,SAAS,IAAI,OAAO,GAAG,IAAI;CAE/B;CAGF,MAAM,UAAU,GAAG,IAAI;CACvB,IAAI,OAAO,YAAY,YACrB,aAAa,IAAI,YAAY,OAAO;CAGtC,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseAccount.js","names":[],"sources":["../../../src/utils/parseAccount.ts"],"sourcesContent":["import type { ErrorType } from '../errors/utils.js'\nimport type { Account } from '../types/account.js'\nimport type { Address } from '../types/address.js'\n\nexport type ParseAccountErrorType = ErrorType\n\nexport function parseAccount<accountOrAddress extends Address | Account>(\n account: accountOrAddress\n): accountOrAddress extends Address ? Account : accountOrAddress {\n if (typeof account === 'string') {\n return { address: account, type: 'json-rpc' } as any\n }\n return account as any\n}\n"],"mappings":";;AAMA,SAAgB,aACd,SAC+D;
|
|
1
|
+
{"version":3,"file":"parseAccount.js","names":[],"sources":["../../../src/utils/parseAccount.ts"],"sourcesContent":["import type { ErrorType } from '../errors/utils.js'\nimport type { Account } from '../types/account.js'\nimport type { Address } from '../types/address.js'\n\nexport type ParseAccountErrorType = ErrorType\n\nexport function parseAccount<accountOrAddress extends Address | Account>(\n account: accountOrAddress\n): accountOrAddress extends Address ? Account : accountOrAddress {\n if (typeof account === 'string') {\n return { address: account, type: 'json-rpc' } as any\n }\n return account as any\n}\n"],"mappings":";;AAMA,SAAgB,aACd,SAC+D;CAC/D,IAAI,OAAO,YAAY,UACrB,OAAO;EAAE,SAAS;EAAS,MAAM;CAAW;CAE9C,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poll.js","names":["sleep"],"sources":["../../../src/utils/poll.ts"],"sourcesContent":["import { sleep } from './sleep.js'\n\ntype PollOptions<T> = {\n // Whether or not to emit when the polling starts.\n emitOnBegin?: boolean | undefined\n // The initial wait time (in ms) before polling.\n initialWaitTime?: ((data: T | undefined) => Promise<number>) | undefined\n // The interval (in ms).\n interval: number\n}\n\n/**\n * @description Polls a function at a specified interval.\n */\nexport function poll<T>(\n fn: ({ unpoll }: { unpoll: () => void }) => Promise<T | undefined>,\n { emitOnBegin, initialWaitTime, interval }: PollOptions<T>\n): () => void {\n let active = true\n\n const unwatch = () => {\n active = false\n }\n\n const watch = async () => {\n let data: T | undefined\n if (emitOnBegin) {\n data = await fn({ unpoll: unwatch })\n }\n\n const initialWait = (await initialWaitTime?.(data)) ?? interval\n await sleep(initialWait)\n\n const poll = async () => {\n if (!active) {\n return\n }\n await fn({ unpoll: unwatch })\n await sleep(interval)\n poll()\n }\n\n poll()\n }\n watch()\n\n return unwatch\n}\n"],"mappings":";;;;;;AAcA,SAAgB,KACd,IACA,EAAE,aAAa,iBAAiB,YACpB;CACZ,IAAI,SAAS;CAEb,MAAM,gBAAgB;
|
|
1
|
+
{"version":3,"file":"poll.js","names":["sleep"],"sources":["../../../src/utils/poll.ts"],"sourcesContent":["import { sleep } from './sleep.js'\n\ntype PollOptions<T> = {\n // Whether or not to emit when the polling starts.\n emitOnBegin?: boolean | undefined\n // The initial wait time (in ms) before polling.\n initialWaitTime?: ((data: T | undefined) => Promise<number>) | undefined\n // The interval (in ms).\n interval: number\n}\n\n/**\n * @description Polls a function at a specified interval.\n */\nexport function poll<T>(\n fn: ({ unpoll }: { unpoll: () => void }) => Promise<T | undefined>,\n { emitOnBegin, initialWaitTime, interval }: PollOptions<T>\n): () => void {\n let active = true\n\n const unwatch = () => {\n active = false\n }\n\n const watch = async () => {\n let data: T | undefined\n if (emitOnBegin) {\n data = await fn({ unpoll: unwatch })\n }\n\n const initialWait = (await initialWaitTime?.(data)) ?? interval\n await sleep(initialWait)\n\n const poll = async () => {\n if (!active) {\n return\n }\n await fn({ unpoll: unwatch })\n await sleep(interval)\n poll()\n }\n\n poll()\n }\n watch()\n\n return unwatch\n}\n"],"mappings":";;;;;;AAcA,SAAgB,KACd,IACA,EAAE,aAAa,iBAAiB,YACpB;CACZ,IAAI,SAAS;CAEb,MAAM,gBAAgB;EACpB,SAAS;CACX;CAEA,MAAM,QAAQ,YAAY;EACxB,IAAI;EACJ,IAAI,aACF,OAAO,MAAM,GAAG,EAAE,QAAQ,QAAQ,CAAC;EAIrC,MAAMA,oBAAAA,MADe,MAAM,kBAAkB,IAAI,KAAM,QAChC;EAEvB,MAAM,OAAO,YAAY;GACvB,IAAI,CAAC,QACH;GAEF,MAAM,GAAG,EAAE,QAAQ,QAAQ,CAAC;GAC5B,MAAMA,oBAAAA,MAAM,QAAQ;GACpB,KAAK;EACP;EAEA,KAAK;CACP;CACA,MAAM;CAEN,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retryUntil.js","names":["withRetry"],"sources":["../../../src/utils/retryUntil.ts"],"sourcesContent":["import { withRetry } from './withRetry.js'\n\n/**\n * Retries a condition until it's met or timeout is reached.\n * Polls the condition function at regular intervals.\n *\n * @param condition - Function that returns a truthy value when condition is met\n * @param options - Configuration options for retry behavior\n * @returns Promise that resolves to the condition result or undefined if timeout\n *\n * @example\n * // Wait for a value to become available\n * const value = await retryUntil(\n * async () => await checkCondition(),\n * { timeout: 5000, interval: 100 }\n * )\n */\nexport async function retryUntil<T>(\n condition: () => Promise<T | undefined | null | false>,\n options: {\n /** Maximum time to wait in milliseconds (default: 5000ms) */\n timeout?: number\n /** Interval between checks in milliseconds (default: 100ms) */\n interval?: number\n } = {}\n): Promise<T | undefined> {\n const { timeout = 5000, interval = 100 } = options\n const retryCount = Math.ceil(timeout / interval) - 1 // -1 because first attempt is immediate\n\n return Promise.race([\n // The retry logic\n withRetry(\n async () => {\n const result = await condition()\n if (!result) {\n throw new Error('Condition not met')\n }\n return result\n },\n {\n delay: interval,\n retryCount,\n shouldRetry: ({ error }) => error.message === 'Condition not met',\n }\n ).catch(() => undefined),\n\n // Timeout fallback\n new Promise<undefined>((resolve) => {\n setTimeout(() => resolve(undefined), timeout)\n }),\n ])\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,eAAsB,WACpB,WACA,UAKI,
|
|
1
|
+
{"version":3,"file":"retryUntil.js","names":["withRetry"],"sources":["../../../src/utils/retryUntil.ts"],"sourcesContent":["import { withRetry } from './withRetry.js'\n\n/**\n * Retries a condition until it's met or timeout is reached.\n * Polls the condition function at regular intervals.\n *\n * @param condition - Function that returns a truthy value when condition is met\n * @param options - Configuration options for retry behavior\n * @returns Promise that resolves to the condition result or undefined if timeout\n *\n * @example\n * // Wait for a value to become available\n * const value = await retryUntil(\n * async () => await checkCondition(),\n * { timeout: 5000, interval: 100 }\n * )\n */\nexport async function retryUntil<T>(\n condition: () => Promise<T | undefined | null | false>,\n options: {\n /** Maximum time to wait in milliseconds (default: 5000ms) */\n timeout?: number\n /** Interval between checks in milliseconds (default: 100ms) */\n interval?: number\n } = {}\n): Promise<T | undefined> {\n const { timeout = 5000, interval = 100 } = options\n const retryCount = Math.ceil(timeout / interval) - 1 // -1 because first attempt is immediate\n\n return Promise.race([\n // The retry logic\n withRetry(\n async () => {\n const result = await condition()\n if (!result) {\n throw new Error('Condition not met')\n }\n return result\n },\n {\n delay: interval,\n retryCount,\n shouldRetry: ({ error }) => error.message === 'Condition not met',\n }\n ).catch(() => undefined),\n\n // Timeout fallback\n new Promise<undefined>((resolve) => {\n setTimeout(() => resolve(undefined), timeout)\n }),\n ])\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,eAAsB,WACpB,WACA,UAKI,CAAC,GACmB;CACxB,MAAM,EAAE,UAAU,KAAM,WAAW,QAAQ;CAC3C,MAAM,aAAa,KAAK,KAAK,UAAU,QAAQ,IAAI;CAEnD,OAAO,QAAQ,KAAK,CAElBA,wBAAAA,UACE,YAAY;EACV,MAAM,SAAS,MAAM,UAAU;EAC/B,IAAI,CAAC,QACH,MAAM,IAAI,MAAM,mBAAmB;EAErC,OAAO;CACT,GACA;EACE,OAAO;EACP;EACA,cAAc,EAAE,YAAY,MAAM,YAAY;CAChD,CACF,EAAE,YAAY,KAAA,CAAS,GAGvB,IAAI,SAAoB,YAAY;EAClC,iBAAiB,QAAQ,KAAA,CAAS,GAAG,OAAO;CAC9C,CAAC,CACH,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sleep.js","names":[],"sources":["../../../src/utils/sleep.ts"],"sourcesContent":["export function sleep(ms: number): Promise<null> {\n return new Promise((resolve) => {\n setTimeout(() => resolve(null), ms)\n })\n}\n"],"mappings":";;AAAA,SAAgB,MAAM,IAA2B;
|
|
1
|
+
{"version":3,"file":"sleep.js","names":[],"sources":["../../../src/utils/sleep.ts"],"sourcesContent":["export function sleep(ms: number): Promise<null> {\n return new Promise((resolve) => {\n setTimeout(() => resolve(null), ms)\n })\n}\n"],"mappings":";;AAAA,SAAgB,MAAM,IAA2B;CAC/C,OAAO,IAAI,SAAS,YAAY;EAC9B,iBAAiB,QAAQ,IAAI,GAAG,EAAE;CACpC,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stringify.js","names":[],"sources":["../../../src/utils/stringify.ts"],"sourcesContent":["import type { ErrorType } from '../errors/utils.js'\n\nexport type StringifyErrorType = ErrorType\n\nexport const stringify: typeof JSON.stringify = (value, replacer, space) =>\n JSON.stringify(\n value,\n (key, value_) => {\n const value = typeof value_ === 'bigint' ? value_.toString() : value_\n return typeof replacer === 'function' ? replacer(key, value) : value\n },\n space\n )\n"],"mappings":";;AAIA,MAAa,aAAoC,OAAO,UAAU,UAChE,KAAK,UACH,QACC,KAAK,WAAW;CACf,MAAM,QAAQ,OAAO,WAAW,WAAW,OAAO,
|
|
1
|
+
{"version":3,"file":"stringify.js","names":[],"sources":["../../../src/utils/stringify.ts"],"sourcesContent":["import type { ErrorType } from '../errors/utils.js'\n\nexport type StringifyErrorType = ErrorType\n\nexport const stringify: typeof JSON.stringify = (value, replacer, space) =>\n JSON.stringify(\n value,\n (key, value_) => {\n const value = typeof value_ === 'bigint' ? value_.toString() : value_\n return typeof replacer === 'function' ? replacer(key, value) : value\n },\n space\n )\n"],"mappings":";;AAIA,MAAa,aAAoC,OAAO,UAAU,UAChE,KAAK,UACH,QACC,KAAK,WAAW;CACf,MAAM,QAAQ,OAAO,WAAW,WAAW,OAAO,SAAS,IAAI;CAC/D,OAAO,OAAO,aAAa,aAAa,SAAS,KAAK,KAAK,IAAI;AACjE,GACA,KACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uid.js","names":[],"sources":["../../../src/utils/uid.ts"],"sourcesContent":["const size = 256\nlet index = size\nlet buffer: string\n\nexport function uid(length = 11): string {\n if (!buffer || index + length > size * 2) {\n buffer = ''\n index = 0\n for (let i = 0; i < size; i++) {\n buffer += ((256 + Math.random() * 256) | 0).toString(16).substring(1)\n }\n }\n return buffer.substring(index, index++ + length)\n}\n"],"mappings":";;AAAA,MAAM,OAAO;AACb,IAAI,QAAQ;AACZ,IAAI;AAEJ,SAAgB,IAAI,SAAS,IAAY;
|
|
1
|
+
{"version":3,"file":"uid.js","names":[],"sources":["../../../src/utils/uid.ts"],"sourcesContent":["const size = 256\nlet index = size\nlet buffer: string\n\nexport function uid(length = 11): string {\n if (!buffer || index + length > size * 2) {\n buffer = ''\n index = 0\n for (let i = 0; i < size; i++) {\n buffer += ((256 + Math.random() * 256) | 0).toString(16).substring(1)\n }\n }\n return buffer.substring(index, index++ + length)\n}\n"],"mappings":";;AAAA,MAAM,OAAO;AACb,IAAI,QAAQ;AACZ,IAAI;AAEJ,SAAgB,IAAI,SAAS,IAAY;CACvC,IAAI,CAAC,UAAU,QAAQ,SAAS,OAAO,GAAG;EACxC,SAAS;EACT,QAAQ;EACR,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,KACxB,WAAY,MAAM,KAAK,OAAO,IAAI,MAAO,GAAG,SAAS,EAAE,EAAE,UAAU,CAAC;CAExE;CACA,OAAO,OAAO,UAAU,OAAO,UAAU,MAAM;AACjD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.js","names":[],"sources":["../../../src/utils/url.ts"],"sourcesContent":["export const urlWithParams = (\n url: string,\n params: Record<string, string | number | undefined>\n): string => {\n const _url = new URL(url)\n Object.entries(params).forEach(([key, value]) => {\n if (value !== undefined) {\n _url.searchParams.set(key, String(value))\n }\n })\n return decodeURIComponent(_url.toString())\n}\n"],"mappings":";;AAAA,MAAa,iBACX,KACA,WACW;CACX,MAAM,OAAO,IAAI,IAAI,
|
|
1
|
+
{"version":3,"file":"url.js","names":[],"sources":["../../../src/utils/url.ts"],"sourcesContent":["export const urlWithParams = (\n url: string,\n params: Record<string, string | number | undefined>\n): string => {\n const _url = new URL(url)\n Object.entries(params).forEach(([key, value]) => {\n if (value !== undefined) {\n _url.searchParams.set(key, String(value))\n }\n })\n return decodeURIComponent(_url.toString())\n}\n"],"mappings":";;AAAA,MAAa,iBACX,KACA,WACW;CACX,MAAM,OAAO,IAAI,IAAI,GAAG;CACxB,OAAO,QAAQ,MAAM,EAAE,SAAS,CAAC,KAAK,WAAW;EAC/C,IAAI,UAAU,KAAA,GACZ,KAAK,aAAa,IAAI,KAAK,OAAO,KAAK,CAAC;CAE5C,CAAC;CACD,OAAO,mBAAmB,KAAK,SAAS,CAAC;AAC3C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wait.js","names":[],"sources":["../../../src/utils/wait.ts"],"sourcesContent":["export async function wait(time: number): Promise<void> {\n return new Promise((res) => setTimeout(res, time))\n}\n"],"mappings":";;AAAA,eAAsB,KAAK,MAA6B;
|
|
1
|
+
{"version":3,"file":"wait.js","names":[],"sources":["../../../src/utils/wait.ts"],"sourcesContent":["export async function wait(time: number): Promise<void> {\n return new Promise((res) => setTimeout(res, time))\n}\n"],"mappings":";;AAAA,eAAsB,KAAK,MAA6B;CACtD,OAAO,IAAI,SAAS,QAAQ,WAAW,KAAK,IAAI,CAAC;AACnD"}
|