@bigmi/core 0.3.0-beta.3 → 0.3.0-beta.5

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.
Files changed (160) hide show
  1. package/dist/cjs/actions/getBalance.d.ts +1 -1
  2. package/dist/cjs/actions/getBlock.d.ts +1 -1
  3. package/dist/cjs/actions/getBlock.js.map +1 -1
  4. package/dist/cjs/actions/getBlockCount.d.ts +1 -1
  5. package/dist/cjs/actions/getBlockStats.d.ts +1 -1
  6. package/dist/cjs/actions/getUTXOTransaction.d.ts +1 -1
  7. package/dist/cjs/actions/sendUTXOTransaction.d.ts +1 -1
  8. package/dist/cjs/actions/signPsbt.d.ts +1 -1
  9. package/dist/cjs/actions/waitForTransaction.d.ts +1 -1
  10. package/dist/cjs/actions/waitForTransaction.js.map +1 -1
  11. package/dist/cjs/actions/watchBlockNumber.d.ts +1 -1
  12. package/dist/cjs/clients/decorators/public.d.ts +1 -1
  13. package/dist/cjs/clients/decorators/wallet.d.ts +3 -3
  14. package/dist/cjs/clients/decorators/wallet.js.map +1 -1
  15. package/dist/cjs/factories/createClient.d.ts +1 -1
  16. package/dist/cjs/factories/createTransport.d.ts +1 -30
  17. package/dist/cjs/factories/createTransport.js.map +1 -1
  18. package/dist/cjs/transports/ankr/ankr.js +6 -1
  19. package/dist/cjs/transports/ankr/ankr.js.map +1 -1
  20. package/dist/cjs/transports/blockchair/blockchair.js +4 -0
  21. package/dist/cjs/transports/blockchair/blockchair.js.map +1 -1
  22. package/dist/cjs/transports/blockcypher/blockcypher.js +4 -0
  23. package/dist/cjs/transports/blockcypher/blockcypher.js.map +1 -1
  24. package/dist/cjs/transports/blockcypher/getUTXOs.js +2 -2
  25. package/dist/cjs/transports/blockcypher/getUTXOs.js.map +1 -1
  26. package/dist/cjs/transports/custom.d.ts +1 -1
  27. package/dist/cjs/transports/custom.js.map +1 -1
  28. package/dist/cjs/transports/fallback.js +10 -8
  29. package/dist/cjs/transports/fallback.js.map +1 -1
  30. package/dist/cjs/transports/http.d.ts +1 -1
  31. package/dist/cjs/transports/http.js.map +1 -1
  32. package/dist/cjs/transports/mempool/mempool.js +4 -0
  33. package/dist/cjs/transports/mempool/mempool.js.map +1 -1
  34. package/dist/cjs/transports/types.d.ts +1 -1
  35. package/dist/cjs/transports/types.js.map +1 -1
  36. package/dist/cjs/transports/utxo.js +2 -5
  37. package/dist/cjs/transports/utxo.js.map +1 -1
  38. package/dist/cjs/types/request.d.ts +3 -2
  39. package/dist/cjs/types/transport.d.ts +3 -2
  40. package/dist/cjs/utils/getAction.d.ts +1 -1
  41. package/dist/cjs/version.d.ts +1 -1
  42. package/dist/cjs/version.js +1 -1
  43. package/dist/esm/actions/getBalance.d.ts +1 -1
  44. package/dist/esm/actions/getBlock.d.ts +1 -1
  45. package/dist/esm/actions/getBlock.js.map +1 -1
  46. package/dist/esm/actions/getBlockCount.d.ts +1 -1
  47. package/dist/esm/actions/getBlockStats.d.ts +1 -1
  48. package/dist/esm/actions/getUTXOTransaction.d.ts +1 -1
  49. package/dist/esm/actions/sendUTXOTransaction.d.ts +1 -1
  50. package/dist/esm/actions/signPsbt.d.ts +1 -1
  51. package/dist/esm/actions/waitForTransaction.d.ts +1 -1
  52. package/dist/esm/actions/waitForTransaction.js.map +1 -1
  53. package/dist/esm/actions/watchBlockNumber.d.ts +1 -1
  54. package/dist/esm/clients/decorators/public.d.ts +1 -1
  55. package/dist/esm/clients/decorators/wallet.d.ts +3 -3
  56. package/dist/esm/clients/decorators/wallet.js.map +1 -1
  57. package/dist/esm/factories/createClient.d.ts +1 -1
  58. package/dist/esm/factories/createTransport.d.ts +1 -38
  59. package/dist/esm/factories/createTransport.js.map +1 -1
  60. package/dist/esm/transports/ankr/ankr.js +6 -1
  61. package/dist/esm/transports/ankr/ankr.js.map +1 -1
  62. package/dist/esm/transports/blockchair/blockchair.js +4 -0
  63. package/dist/esm/transports/blockchair/blockchair.js.map +1 -1
  64. package/dist/esm/transports/blockcypher/blockcypher.js +4 -0
  65. package/dist/esm/transports/blockcypher/blockcypher.js.map +1 -1
  66. package/dist/esm/transports/blockcypher/getUTXOs.js +2 -2
  67. package/dist/esm/transports/blockcypher/getUTXOs.js.map +1 -1
  68. package/dist/esm/transports/custom.d.ts +1 -1
  69. package/dist/esm/transports/custom.js +1 -1
  70. package/dist/esm/transports/custom.js.map +1 -1
  71. package/dist/esm/transports/fallback.js +10 -9
  72. package/dist/esm/transports/fallback.js.map +1 -1
  73. package/dist/esm/transports/http.d.ts +1 -1
  74. package/dist/esm/transports/http.js +1 -1
  75. package/dist/esm/transports/http.js.map +1 -1
  76. package/dist/esm/transports/mempool/mempool.js +4 -0
  77. package/dist/esm/transports/mempool/mempool.js.map +1 -1
  78. package/dist/esm/transports/types.d.ts +1 -1
  79. package/dist/esm/transports/types.js.map +1 -1
  80. package/dist/esm/transports/utxo.js +2 -5
  81. package/dist/esm/transports/utxo.js.map +1 -1
  82. package/dist/esm/types/request.d.ts +3 -2
  83. package/dist/esm/types/transport.d.ts +3 -2
  84. package/dist/esm/utils/getAction.d.ts +1 -1
  85. package/dist/esm/version.d.ts +1 -1
  86. package/dist/esm/version.js +1 -1
  87. package/dist/types/actions/getBalance.d.ts +1 -1
  88. package/dist/types/actions/getBalance.d.ts.map +1 -1
  89. package/dist/types/actions/getBlock.d.ts +1 -1
  90. package/dist/types/actions/getBlock.d.ts.map +1 -1
  91. package/dist/types/actions/getBlockCount.d.ts +1 -1
  92. package/dist/types/actions/getBlockCount.d.ts.map +1 -1
  93. package/dist/types/actions/getBlockStats.d.ts +1 -1
  94. package/dist/types/actions/getBlockStats.d.ts.map +1 -1
  95. package/dist/types/actions/getUTXOTransaction.d.ts +1 -1
  96. package/dist/types/actions/getUTXOTransaction.d.ts.map +1 -1
  97. package/dist/types/actions/sendUTXOTransaction.d.ts +1 -1
  98. package/dist/types/actions/sendUTXOTransaction.d.ts.map +1 -1
  99. package/dist/types/actions/signPsbt.d.ts +1 -1
  100. package/dist/types/actions/signPsbt.d.ts.map +1 -1
  101. package/dist/types/actions/waitForTransaction.d.ts +1 -1
  102. package/dist/types/actions/waitForTransaction.d.ts.map +1 -1
  103. package/dist/types/actions/watchBlockNumber.d.ts +1 -1
  104. package/dist/types/actions/watchBlockNumber.d.ts.map +1 -1
  105. package/dist/types/clients/decorators/public.d.ts +1 -1
  106. package/dist/types/clients/decorators/public.d.ts.map +1 -1
  107. package/dist/types/clients/decorators/wallet.d.ts +3 -3
  108. package/dist/types/clients/decorators/wallet.d.ts.map +1 -1
  109. package/dist/types/factories/createClient.d.ts +1 -1
  110. package/dist/types/factories/createClient.d.ts.map +1 -1
  111. package/dist/types/factories/createTransport.d.ts +1 -38
  112. package/dist/types/factories/createTransport.d.ts.map +1 -1
  113. package/dist/types/transports/ankr/ankr.d.ts.map +1 -1
  114. package/dist/types/transports/blockchair/blockchair.d.ts.map +1 -1
  115. package/dist/types/transports/blockcypher/blockcypher.d.ts.map +1 -1
  116. package/dist/types/transports/custom.d.ts +1 -1
  117. package/dist/types/transports/custom.d.ts.map +1 -1
  118. package/dist/types/transports/fallback.d.ts.map +1 -1
  119. package/dist/types/transports/http.d.ts +1 -1
  120. package/dist/types/transports/http.d.ts.map +1 -1
  121. package/dist/types/transports/mempool/mempool.d.ts.map +1 -1
  122. package/dist/types/transports/types.d.ts +1 -1
  123. package/dist/types/transports/types.d.ts.map +1 -1
  124. package/dist/types/transports/utxo.d.ts.map +1 -1
  125. package/dist/types/types/request.d.ts +3 -2
  126. package/dist/types/types/request.d.ts.map +1 -1
  127. package/dist/types/types/transport.d.ts +3 -2
  128. package/dist/types/types/transport.d.ts.map +1 -1
  129. package/dist/types/utils/getAction.d.ts +1 -1
  130. package/dist/types/utils/getAction.d.ts.map +1 -1
  131. package/dist/types/version.d.ts +1 -1
  132. package/package.json +1 -1
  133. package/package.json.tmp +1 -1
  134. package/src/actions/getBalance.ts +1 -1
  135. package/src/actions/getBlock.ts +1 -3
  136. package/src/actions/getBlockCount.ts +1 -1
  137. package/src/actions/getBlockStats.ts +1 -1
  138. package/src/actions/getUTXOTransaction.ts +1 -1
  139. package/src/actions/sendUTXOTransaction.ts +1 -1
  140. package/src/actions/signPsbt.ts +1 -1
  141. package/src/actions/waitForTransaction.ts +1 -3
  142. package/src/actions/watchBlockNumber.ts +1 -1
  143. package/src/clients/decorators/public.ts +1 -1
  144. package/src/clients/decorators/wallet.ts +3 -4
  145. package/src/factories/createClient.ts +1 -1
  146. package/src/factories/createTransport.ts +1 -55
  147. package/src/transports/ankr/ankr.ts +8 -1
  148. package/src/transports/blockchair/blockchair.ts +6 -0
  149. package/src/transports/blockcypher/blockcypher.ts +5 -0
  150. package/src/transports/blockcypher/getUTXOs.ts +2 -2
  151. package/src/transports/custom.ts +6 -6
  152. package/src/transports/fallback.ts +10 -8
  153. package/src/transports/http.ts +6 -6
  154. package/src/transports/mempool/mempool.ts +5 -0
  155. package/src/transports/types.ts +1 -1
  156. package/src/transports/utxo.ts +3 -4
  157. package/src/types/request.ts +3 -2
  158. package/src/types/transport.ts +3 -2
  159. package/src/utils/getAction.ts +1 -1
  160. package/src/version.ts +1 -1
@@ -1,4 +1,3 @@
1
- import type { Transport } from '../factories/createTransport.js'
2
1
  import type {
3
2
  SignPsbtParameters,
4
3
  SignPsbtReturnType,
@@ -7,6 +6,7 @@ import type {
7
6
  import type { Account } from '../types/account.js'
8
7
  import type { Chain } from '../types/chain.js'
9
8
  import type { Client } from '../types/client.js'
9
+ import type { Transport } from '../types/transport.js'
10
10
 
11
11
  export async function signPsbt<
12
12
  C extends Chain | undefined,
@@ -1,15 +1,13 @@
1
1
  import { Transaction, address } from 'bitcoinjs-lib'
2
-
3
2
  import {
4
3
  TransactionNotFoundError,
5
4
  TransactionReceiptNotFoundError,
6
5
  WaitForTransactionReceiptTimeoutError,
7
6
  } from '../errors/transaction.js'
8
-
9
- import type { Transport } from '../factories/createTransport.js'
10
7
  import type { Chain } from '../types/chain.js'
11
8
  import type { Client } from '../types/client.js'
12
9
  import type { UTXOTransaction } from '../types/transaction.js'
10
+ import type { Transport } from '../types/transport.js'
13
11
  import { getAction } from '../utils/getAction.js'
14
12
  import { observe } from '../utils/observe.js'
15
13
  import { stringify } from '../utils/stringify.js'
@@ -1,6 +1,6 @@
1
- import type { Transport } from '../factories/createTransport.js'
2
1
  import type { Chain } from '../types/chain.js'
3
2
  import type { Client } from '../types/client.js'
3
+ import type { Transport } from '../types/transport.js'
4
4
  import { getAction } from '../utils/getAction.js'
5
5
  import { observe } from '../utils/observe.js'
6
6
  import { poll } from '../utils/poll.js'
@@ -34,9 +34,9 @@ import {
34
34
  } from '../../actions/getUTXOs.js'
35
35
 
36
36
  import type { Client } from '../../factories/createClient.js'
37
- import type { Transport } from '../../factories/createTransport.js'
38
37
  import type { UTXOSchema } from '../../transports/types.js'
39
38
  import type { Account } from '../../types/account.js'
39
+ import type { Transport } from '../../types/transport.js'
40
40
 
41
41
  import type { Chain } from '../../types/chain.js'
42
42
 
@@ -4,15 +4,14 @@ import {
4
4
  sendUTXOTransaction,
5
5
  } from '../../actions/sendUTXOTransaction.js'
6
6
  import { signPsbt } from '../../actions/signPsbt.js'
7
- import type { Transport } from '../../factories/createTransport.js'
8
- import type { Account } from '../../types/account.js'
9
- import type { Client } from '../../types/client.js'
10
-
11
7
  import type {
12
8
  SignPsbtParameters,
13
9
  SignPsbtReturnType,
14
10
  } from '../../transports/types.js'
11
+ import type { Account } from '../../types/account.js'
15
12
  import type { Chain } from '../../types/chain.js'
13
+ import type { Client } from '../../types/client.js'
14
+ import type { Transport } from '../../types/transport.js'
16
15
 
17
16
  export type WalletActions = {
18
17
  /**
@@ -1,9 +1,9 @@
1
1
  import type { Address } from '../types/address.js'
2
2
 
3
3
  import type { ErrorType } from '../errors/utils.js'
4
- import type { Transport } from '../factories/createTransport.js'
5
4
  import type { Account } from '../types/account.js'
6
5
  import type { Chain } from '../types/chain.js'
6
+ import type { Transport } from '../types/transport.js'
7
7
 
8
8
  import type { BtcRpcRequestFn, RpcSchema } from '../types/request.js'
9
9
  import type { BitcoinRpcMethods } from '../types/rpc.js'
@@ -1,61 +1,7 @@
1
- import type { ErrorType } from '../errors/utils.js'
2
- import type { Chain } from '../types/chain.js'
3
- import type { ClientConfig } from '../types/client.js'
4
- import type { BtcRpcRequestFn } from '../types/request.js'
5
- import type { OneOf } from '../types/utils.js'
1
+ import type { Transport, TransportConfig } from '../types/transport.js'
6
2
  import { buildRequest } from '../utils/buildRequest.js'
7
3
  import { uid as uid_ } from '../utils/uid.js'
8
4
 
9
- export type TransportConfig<
10
- type extends string = string,
11
- rpcRequestFn extends BtcRpcRequestFn = BtcRpcRequestFn,
12
- > = {
13
- /** The name of the transport. */
14
- name: string
15
- /** The key of the transport. */
16
- key: string
17
- /** Methods to include or exclude from executing RPC requests. */
18
- methods?:
19
- | OneOf<
20
- | {
21
- include?: string[] | undefined
22
- }
23
- | {
24
- exclude?: string[] | undefined
25
- }
26
- >
27
- | undefined
28
- /** The JSON-RPC request function that matches the EIP-1193 request spec. */
29
- request: rpcRequestFn
30
- /** The base delay (in ms) between retries. */
31
- retryDelay?: number | undefined
32
- /** The max number of times to retry. */
33
- retryCount?: number | undefined
34
- /** The timeout (in ms) for requests. */
35
- timeout?: number | undefined
36
- /** The type of the transport. */
37
- type: type
38
- }
39
-
40
- export type Transport<
41
- type extends string = string,
42
- rpcAttributes = Record<string, any>,
43
- rpcRequestFn extends BtcRpcRequestFn = BtcRpcRequestFn,
44
- > = <chain extends Chain | undefined = Chain>({
45
- chain,
46
- }: {
47
- chain?: chain | undefined
48
- pollingInterval?: ClientConfig['pollingInterval'] | undefined
49
- retryCount?: TransportConfig['retryCount'] | undefined
50
- timeout?: TransportConfig['timeout'] | undefined
51
- }) => {
52
- config: TransportConfig<type>
53
- request: rpcRequestFn
54
- value?: rpcAttributes | undefined
55
- }
56
-
57
- export type CreateTransportErrorType = ErrorType
58
-
59
5
  /**
60
6
  * @description Creates an transport intended to be used with a client.
61
7
  */
@@ -1,11 +1,17 @@
1
+ import type { TransportConfig } from '../../types/transport.js'
1
2
  import type { HttpTransportConfig } from '../http.js'
3
+ import type { UTXOAPISchema, UTXOMethod } from '../types.js'
2
4
  import { utxo } from '../utxo.js'
5
+ import { ankrMethods } from './methods.js'
3
6
 
4
7
  type AnkrConfig = { baseUrl?: string; apiKey?: string } & HttpTransportConfig
5
8
 
6
9
  export const ankr = (config?: AnkrConfig) => {
10
+ const methods: TransportConfig['methods'] = {
11
+ include: Object.keys(ankrMethods) as UTXOMethod[],
12
+ }
7
13
  if (config?.baseUrl) {
8
- return utxo(config.baseUrl, { key: 'ankr', ...config })
14
+ return utxo(config.baseUrl, { key: 'ankr', ...config, methods })
9
15
  }
10
16
 
11
17
  if (!config?.apiKey) {
@@ -15,6 +21,7 @@ export const ankr = (config?: AnkrConfig) => {
15
21
  `https://rpc.ankr.com/premium-http/btc_blockbook/${config.apiKey}/api/v2`,
16
22
  {
17
23
  key: 'ankr',
24
+ methods,
18
25
  ...config,
19
26
  }
20
27
  )
@@ -1,5 +1,8 @@
1
+ import type { TransportConfig } from '../../types/transport.js'
1
2
  import type { HttpTransportConfig } from '../http.js'
3
+ import type { UTXOMethod } from '../types.js'
2
4
  import { utxo } from '../utxo.js'
5
+ import { blockchairMethods } from './methods.js'
3
6
 
4
7
  type BlockchairConfig = {
5
8
  baseUrl?: string
@@ -10,5 +13,8 @@ export const blockchair = (config?: BlockchairConfig) =>
10
13
  utxo(config?.baseUrl || 'https://api.blockchair.com', {
11
14
  key: 'blockchair',
12
15
  includeChainToURL: true,
16
+ methods: {
17
+ include: Object.keys(blockchairMethods) as UTXOMethod[],
18
+ },
13
19
  ...config,
14
20
  })
@@ -1,5 +1,7 @@
1
1
  import type { HttpTransportConfig } from '../http.js'
2
+ import type { UTXOMethod } from '../types.js'
2
3
  import { utxo } from '../utxo.js'
4
+ import { blockcypherMethods } from './methods.js'
3
5
 
4
6
  type BlockcypherConfig = {
5
7
  baseUrl?: string
@@ -9,5 +11,8 @@ type BlockcypherConfig = {
9
11
  export const blockcypher = (config?: BlockcypherConfig) =>
10
12
  utxo(config?.baseUrl || 'https://api.blockcypher.com/v1/btc/main', {
11
13
  key: 'blockcypher',
14
+ methods: {
15
+ include: Object.keys(blockcypherMethods) as UTXOMethod[],
16
+ },
12
17
  ...config,
13
18
  })
@@ -8,7 +8,7 @@ import type {
8
8
  BlockcypherUTXOsResponse,
9
9
  } from './blockcypher.types.js'
10
10
 
11
- const blockchairUTXOTransformer = (utxo: BlockcypherUTXO): UTXO => ({
11
+ const blockcypherUTXOTransformer = (utxo: BlockcypherUTXO): UTXO => ({
12
12
  blockHeight: utxo.block_height,
13
13
  isConfirmed: Boolean(utxo.confirmations),
14
14
  confirmations: utxo.confirmations,
@@ -85,7 +85,7 @@ export const getUTXOs: RpcMethodHandler<'getUTXOs'> = async (
85
85
  let valueCount = 0
86
86
 
87
87
  for await (const batch of fetchUTXOs()) {
88
- const utxoBatch = batch.map(blockchairUTXOTransformer)
88
+ const utxoBatch = batch.map(blockcypherUTXOTransformer)
89
89
  utxos.push(...utxoBatch)
90
90
 
91
91
  if (minValue) {
@@ -1,10 +1,10 @@
1
1
  import type { ErrorType } from '../errors/utils.js'
2
- import {
3
- type CreateTransportErrorType,
4
- type Transport,
5
- type TransportConfig,
6
- createTransport,
7
- } from '../factories/createTransport.js'
2
+ import { createTransport } from '../factories/createTransport.js'
3
+ import type {
4
+ CreateTransportErrorType,
5
+ Transport,
6
+ TransportConfig,
7
+ } from '../types/transport.js'
8
8
 
9
9
  type BitcoinProvider = { request(...args: any): Promise<any> }
10
10
 
@@ -1,6 +1,7 @@
1
1
  import { RpcErrorCode } from '../errors/rpc.js'
2
2
  import { TransportMethodNotSupportedError } from '../errors/transport.js'
3
3
  import type { ErrorType } from '../errors/utils.js'
4
+ import { InsufficientUTXOBalanceError } from '../errors/utxo.js'
4
5
  import { createTransport } from '../factories/createTransport.js'
5
6
  import type { Chain } from '../types/chain.js'
6
7
  import type {
@@ -125,7 +126,7 @@ export function fallback<const transports extends readonly Transport[]>(
125
126
  // Filter transports to only those that support the requested method
126
127
  const supportedTransports = transports.reduce<
127
128
  ReturnType<Transport>[]
128
- >((acc, transport) => {
129
+ >((supportedTransports, transport) => {
129
130
  const instance = transport({
130
131
  ...rest,
131
132
  chain,
@@ -135,18 +136,18 @@ export function fallback<const transports extends readonly Transport[]>(
135
136
  const { include, exclude } = instance.config.methods || {}
136
137
  if (include) {
137
138
  if (include.includes(method)) {
138
- acc.push(instance)
139
+ supportedTransports.push(instance)
139
140
  }
140
- return acc
141
+ return supportedTransports
141
142
  }
142
143
  if (exclude) {
143
144
  if (!exclude.includes(method)) {
144
- acc.push(instance)
145
+ supportedTransports.push(instance)
145
146
  }
146
- return acc
147
+ return supportedTransports
147
148
  }
148
- acc.push(instance)
149
- return acc
149
+ supportedTransports.push(instance)
150
+ return supportedTransports
150
151
  }, [])
151
152
 
152
153
  if (!supportedTransports.length) {
@@ -230,7 +231,8 @@ export function shouldThrow(error: Error) {
230
231
  if (
231
232
  error.code === RpcErrorCode.INTERNAL_ERROR ||
232
233
  error.code === RpcErrorCode.USER_REJECTION ||
233
- error.code === 5000 // CAIP UserRejectedRequestError
234
+ error.code === 5000 || // CAIP UserRejectedRequestError
235
+ error instanceof InsufficientUTXOBalanceError
234
236
  ) {
235
237
  return true
236
238
  }
@@ -4,13 +4,13 @@ import {
4
4
  type UrlRequiredErrorType,
5
5
  } from '../errors/transport.js'
6
6
  import type { ErrorType } from '../errors/utils.js'
7
- import {
8
- type CreateTransportErrorType,
9
- type Transport,
10
- type TransportConfig,
11
- createTransport,
12
- } from '../factories/createTransport.js'
7
+ import { createTransport } from '../factories/createTransport.js'
13
8
  import type { BtcRpcRequestFn, RpcSchema } from '../types/request.js'
9
+ import type {
10
+ CreateTransportErrorType,
11
+ Transport,
12
+ TransportConfig,
13
+ } from '../types/transport.js'
14
14
  import { createBatchScheduler } from '../utils/createBatchScheduler.js'
15
15
  import {
16
16
  type HttpRpcClientOptions,
@@ -1,5 +1,7 @@
1
1
  import type { HttpTransportConfig } from '../http.js'
2
+ import type { UTXOMethod } from '../types.js'
2
3
  import { utxo } from '../utxo.js'
4
+ import { mempoolMethods } from './methods.js'
3
5
 
4
6
  type MempoolConfig = {
5
7
  baseUrl?: string
@@ -8,5 +10,8 @@ type MempoolConfig = {
8
10
  export const mempool = (config?: MempoolConfig) =>
9
11
  utxo(config?.baseUrl || 'https://mempool.space/api', {
10
12
  key: 'mempool',
13
+ methods: {
14
+ include: Object.keys(mempoolMethods) as UTXOMethod[],
15
+ },
11
16
  ...config,
12
17
  })
@@ -2,7 +2,7 @@ import type { BlockStats, BlockStatsKeys } from '../types/blockStats.js'
2
2
  import type { UTXO, UTXOTransaction } from '../types/transaction.js'
3
3
  import type { HttpRpcClient } from './getHttpRpcClient.js'
4
4
 
5
- export const UTXOAPISchemaMethods = [
5
+ export const UTXOAPISchemaMethods: UTXOMethod[] = [
6
6
  'getBalance',
7
7
  'getTransactions',
8
8
  'getUTXOs',
@@ -4,7 +4,7 @@ import { createTransport } from '../factories/createTransport.js'
4
4
  import { getHttpRpcClient } from './getHttpRpcClient.js'
5
5
  import { getRpcProviderMethods } from './getRpcProviderMethods.js'
6
6
  import type { HttpTransport, HttpTransportConfig } from './http.js'
7
- import { UTXOAPISchemaMethods, type UTXOMethod } from './types.js'
7
+ import type { UTXOMethod } from './types.js'
8
8
 
9
9
  type UTXOHttpTransportConfig = HttpTransportConfig & {
10
10
  includeChainToURL?: boolean
@@ -23,6 +23,7 @@ export function utxo(
23
23
  onFetchResponse,
24
24
  retryDelay,
25
25
  apiKey,
26
+ methods,
26
27
  } = config
27
28
 
28
29
  return ({ chain, retryCount: retryCount_, timeout: timeout_ }) => {
@@ -50,9 +51,7 @@ export function utxo(
50
51
  {
51
52
  key,
52
53
  name,
53
- methods: {
54
- include: UTXOAPISchemaMethods,
55
- },
54
+ methods,
56
55
  async request({ method, params }) {
57
56
  const body = { method, params }
58
57
  const methodHandler = rpcMethods?.[method as UTXOMethod]
@@ -1,4 +1,5 @@
1
1
  import type { ErrorType } from '../errors/utils.js'
2
+ import type { UTXOMethod } from '../transports/types.js'
2
3
  import type { OneOf } from './utils.js'
3
4
 
4
5
  export type RpcSchema = readonly {
@@ -34,10 +35,10 @@ export type BtcRpcRequestOptions = {
34
35
  methods?:
35
36
  | OneOf<
36
37
  | {
37
- include?: string[] | undefined
38
+ include?: UTXOMethod[] | undefined
38
39
  }
39
40
  | {
40
- exclude?: string[] | undefined
41
+ exclude?: UTXOMethod[] | undefined
41
42
  }
42
43
  >
43
44
  | undefined
@@ -1,4 +1,5 @@
1
1
  import type { ErrorType } from '../errors/utils.js'
2
+ import type { UTXOMethod } from '../transports/types.js'
2
3
  import type { Chain } from './chain.js'
3
4
  import type { BtcRpcRequestFn, RpcSchema } from './request.js'
4
5
  import type { OneOf } from './utils.js'
@@ -15,10 +16,10 @@ export type TransportConfig<
15
16
  methods?:
16
17
  | OneOf<
17
18
  | {
18
- include?: string[] | undefined
19
+ include?: UTXOMethod[] | undefined
19
20
  }
20
21
  | {
21
- exclude?: string[] | undefined
22
+ exclude?: UTXOMethod[] | undefined
22
23
  }
23
24
  >
24
25
  | undefined
@@ -1,8 +1,8 @@
1
1
  import type { PublicActions } from '../clients/decorators/public.js'
2
2
  import type { WalletActions } from '../clients/decorators/wallet.js'
3
- import type { Transport } from '../factories/createTransport.js'
4
3
  import type { UTXOSchema } from '../transports/types.js'
5
4
  import type { Client } from '../types/client.js'
5
+ import type { Transport } from '../types/transport.js'
6
6
 
7
7
  import type { Account } from '../types/account.js'
8
8
  import type { Chain } from '../types/chain.js'
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@bigmi/core'
2
- export const version = '0.3.0-beta.3'
2
+ export const version = '0.3.0-beta.5'