@bigmi/core 0.3.0-beta.2 → 0.3.0-beta.4
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/dist/cjs/actions/getBalance.d.ts +1 -1
- package/dist/cjs/actions/getBlock.d.ts +1 -1
- package/dist/cjs/actions/getBlock.js.map +1 -1
- package/dist/cjs/actions/getBlockCount.d.ts +1 -1
- package/dist/cjs/actions/getBlockStats.d.ts +1 -1
- package/dist/cjs/actions/getUTXOTransaction.d.ts +1 -1
- package/dist/cjs/actions/sendUTXOTransaction.d.ts +1 -1
- package/dist/cjs/actions/signPsbt.d.ts +1 -1
- package/dist/cjs/actions/waitForTransaction.d.ts +1 -1
- package/dist/cjs/actions/waitForTransaction.js.map +1 -1
- package/dist/cjs/actions/watchBlockNumber.d.ts +1 -1
- package/dist/cjs/clients/decorators/public.d.ts +1 -1
- package/dist/cjs/clients/decorators/wallet.d.ts +3 -3
- package/dist/cjs/clients/decorators/wallet.js.map +1 -1
- package/dist/cjs/factories/createClient.d.ts +1 -1
- package/dist/cjs/factories/createTransport.d.ts +1 -30
- package/dist/cjs/factories/createTransport.js.map +1 -1
- package/dist/cjs/transports/ankr/ankr.js +6 -1
- package/dist/cjs/transports/ankr/ankr.js.map +1 -1
- package/dist/cjs/transports/blockchair/blockchair.js +4 -0
- package/dist/cjs/transports/blockchair/blockchair.js.map +1 -1
- package/dist/cjs/transports/blockcypher/blockcypher.js +4 -0
- package/dist/cjs/transports/blockcypher/blockcypher.js.map +1 -1
- package/dist/cjs/transports/custom.d.ts +1 -1
- package/dist/cjs/transports/custom.js.map +1 -1
- package/dist/cjs/transports/fallback.js +21 -13
- package/dist/cjs/transports/fallback.js.map +1 -1
- package/dist/cjs/transports/http.d.ts +1 -1
- package/dist/cjs/transports/http.js.map +1 -1
- package/dist/cjs/transports/mempool/mempool.js +4 -0
- package/dist/cjs/transports/mempool/mempool.js.map +1 -1
- package/dist/cjs/transports/types.d.ts +1 -1
- package/dist/cjs/transports/types.js.map +1 -1
- package/dist/cjs/transports/utxo.js +2 -5
- package/dist/cjs/transports/utxo.js.map +1 -1
- package/dist/cjs/types/request.d.ts +3 -2
- package/dist/cjs/types/transport.d.ts +3 -2
- package/dist/cjs/utils/getAction.d.ts +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/actions/getBalance.d.ts +1 -1
- package/dist/esm/actions/getBlock.d.ts +1 -1
- package/dist/esm/actions/getBlock.js.map +1 -1
- package/dist/esm/actions/getBlockCount.d.ts +1 -1
- package/dist/esm/actions/getBlockStats.d.ts +1 -1
- package/dist/esm/actions/getUTXOTransaction.d.ts +1 -1
- package/dist/esm/actions/sendUTXOTransaction.d.ts +1 -1
- package/dist/esm/actions/signPsbt.d.ts +1 -1
- package/dist/esm/actions/waitForTransaction.d.ts +1 -1
- package/dist/esm/actions/waitForTransaction.js.map +1 -1
- package/dist/esm/actions/watchBlockNumber.d.ts +1 -1
- package/dist/esm/clients/decorators/public.d.ts +1 -1
- package/dist/esm/clients/decorators/wallet.d.ts +3 -3
- package/dist/esm/clients/decorators/wallet.js.map +1 -1
- package/dist/esm/factories/createClient.d.ts +1 -1
- package/dist/esm/factories/createTransport.d.ts +1 -38
- package/dist/esm/factories/createTransport.js.map +1 -1
- package/dist/esm/transports/ankr/ankr.js +6 -1
- package/dist/esm/transports/ankr/ankr.js.map +1 -1
- package/dist/esm/transports/blockchair/blockchair.js +4 -0
- package/dist/esm/transports/blockchair/blockchair.js.map +1 -1
- package/dist/esm/transports/blockcypher/blockcypher.js +4 -0
- package/dist/esm/transports/blockcypher/blockcypher.js.map +1 -1
- package/dist/esm/transports/custom.d.ts +1 -1
- package/dist/esm/transports/custom.js +1 -1
- package/dist/esm/transports/custom.js.map +1 -1
- package/dist/esm/transports/fallback.js +21 -13
- package/dist/esm/transports/fallback.js.map +1 -1
- package/dist/esm/transports/http.d.ts +1 -1
- package/dist/esm/transports/http.js +1 -1
- package/dist/esm/transports/http.js.map +1 -1
- package/dist/esm/transports/mempool/mempool.js +4 -0
- package/dist/esm/transports/mempool/mempool.js.map +1 -1
- package/dist/esm/transports/types.d.ts +1 -1
- package/dist/esm/transports/types.js.map +1 -1
- package/dist/esm/transports/utxo.js +2 -5
- package/dist/esm/transports/utxo.js.map +1 -1
- package/dist/esm/types/request.d.ts +3 -2
- package/dist/esm/types/transport.d.ts +3 -2
- package/dist/esm/utils/getAction.d.ts +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/actions/getBalance.d.ts +1 -1
- package/dist/types/actions/getBalance.d.ts.map +1 -1
- package/dist/types/actions/getBlock.d.ts +1 -1
- package/dist/types/actions/getBlock.d.ts.map +1 -1
- package/dist/types/actions/getBlockCount.d.ts +1 -1
- package/dist/types/actions/getBlockCount.d.ts.map +1 -1
- package/dist/types/actions/getBlockStats.d.ts +1 -1
- package/dist/types/actions/getBlockStats.d.ts.map +1 -1
- package/dist/types/actions/getUTXOTransaction.d.ts +1 -1
- package/dist/types/actions/getUTXOTransaction.d.ts.map +1 -1
- package/dist/types/actions/sendUTXOTransaction.d.ts +1 -1
- package/dist/types/actions/sendUTXOTransaction.d.ts.map +1 -1
- package/dist/types/actions/signPsbt.d.ts +1 -1
- package/dist/types/actions/signPsbt.d.ts.map +1 -1
- package/dist/types/actions/waitForTransaction.d.ts +1 -1
- package/dist/types/actions/waitForTransaction.d.ts.map +1 -1
- package/dist/types/actions/watchBlockNumber.d.ts +1 -1
- package/dist/types/actions/watchBlockNumber.d.ts.map +1 -1
- package/dist/types/clients/decorators/public.d.ts +1 -1
- package/dist/types/clients/decorators/public.d.ts.map +1 -1
- package/dist/types/clients/decorators/wallet.d.ts +3 -3
- package/dist/types/clients/decorators/wallet.d.ts.map +1 -1
- package/dist/types/factories/createClient.d.ts +1 -1
- package/dist/types/factories/createClient.d.ts.map +1 -1
- package/dist/types/factories/createTransport.d.ts +1 -38
- package/dist/types/factories/createTransport.d.ts.map +1 -1
- package/dist/types/transports/ankr/ankr.d.ts.map +1 -1
- package/dist/types/transports/blockchair/blockchair.d.ts.map +1 -1
- package/dist/types/transports/blockcypher/blockcypher.d.ts.map +1 -1
- package/dist/types/transports/custom.d.ts +1 -1
- package/dist/types/transports/custom.d.ts.map +1 -1
- package/dist/types/transports/fallback.d.ts.map +1 -1
- package/dist/types/transports/http.d.ts +1 -1
- package/dist/types/transports/http.d.ts.map +1 -1
- package/dist/types/transports/mempool/mempool.d.ts.map +1 -1
- package/dist/types/transports/types.d.ts +1 -1
- package/dist/types/transports/types.d.ts.map +1 -1
- package/dist/types/transports/utxo.d.ts.map +1 -1
- package/dist/types/types/request.d.ts +3 -2
- package/dist/types/types/request.d.ts.map +1 -1
- package/dist/types/types/transport.d.ts +3 -2
- package/dist/types/types/transport.d.ts.map +1 -1
- package/dist/types/utils/getAction.d.ts +1 -1
- package/dist/types/utils/getAction.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
- package/package.json.tmp +1 -1
- package/src/actions/getBalance.ts +1 -1
- package/src/actions/getBlock.ts +1 -3
- package/src/actions/getBlockCount.ts +1 -1
- package/src/actions/getBlockStats.ts +1 -1
- package/src/actions/getUTXOTransaction.ts +1 -1
- package/src/actions/sendUTXOTransaction.ts +1 -1
- package/src/actions/signPsbt.ts +1 -1
- package/src/actions/waitForTransaction.ts +1 -3
- package/src/actions/watchBlockNumber.ts +1 -1
- package/src/clients/decorators/public.ts +1 -1
- package/src/clients/decorators/wallet.ts +3 -4
- package/src/factories/createClient.ts +1 -1
- package/src/factories/createTransport.ts +1 -55
- package/src/transports/ankr/ankr.ts +8 -1
- package/src/transports/blockchair/blockchair.ts +6 -0
- package/src/transports/blockcypher/blockcypher.ts +5 -0
- package/src/transports/custom.ts +6 -6
- package/src/transports/fallback.ts +23 -14
- package/src/transports/http.ts +6 -6
- package/src/transports/mempool/mempool.ts +5 -0
- package/src/transports/types.ts +1 -1
- package/src/transports/utxo.ts +3 -4
- package/src/types/request.ts +3 -2
- package/src/types/transport.ts +3 -2
- package/src/utils/getAction.ts +1 -1
- package/src/version.ts +1 -1
|
@@ -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 {
|
|
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
|
})
|
package/src/transports/custom.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { ErrorType } from '../errors/utils.js'
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from '../
|
|
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
|
|
|
@@ -123,29 +123,38 @@ export function fallback<const transports extends readonly Transport[]>(
|
|
|
123
123
|
name,
|
|
124
124
|
async request({ method, params }) {
|
|
125
125
|
// Filter transports to only those that support the requested method
|
|
126
|
-
const supportedTransports = transports.
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
const supportedTransports = transports.reduce<
|
|
127
|
+
ReturnType<Transport>[]
|
|
128
|
+
>((supportedTransports, transport) => {
|
|
129
|
+
const instance = transport({
|
|
130
|
+
...rest,
|
|
131
|
+
chain,
|
|
132
|
+
retryCount: 0,
|
|
133
|
+
timeout,
|
|
134
|
+
})
|
|
135
|
+
const { include, exclude } = instance.config.methods || {}
|
|
129
136
|
if (include) {
|
|
130
|
-
|
|
137
|
+
if (include.includes(method)) {
|
|
138
|
+
supportedTransports.push(instance)
|
|
139
|
+
}
|
|
140
|
+
return supportedTransports
|
|
131
141
|
}
|
|
132
142
|
if (exclude) {
|
|
133
|
-
|
|
143
|
+
if (!exclude.includes(method)) {
|
|
144
|
+
supportedTransports.push(instance)
|
|
145
|
+
}
|
|
146
|
+
return supportedTransports
|
|
134
147
|
}
|
|
135
|
-
|
|
136
|
-
|
|
148
|
+
supportedTransports.push(instance)
|
|
149
|
+
return supportedTransports
|
|
150
|
+
}, [])
|
|
137
151
|
|
|
138
152
|
if (!supportedTransports.length) {
|
|
139
153
|
throw new TransportMethodNotSupportedError({ method })
|
|
140
154
|
}
|
|
141
155
|
|
|
142
156
|
const fetch = async (i = 0): Promise<any> => {
|
|
143
|
-
const transport = supportedTransports[i]
|
|
144
|
-
...rest,
|
|
145
|
-
chain,
|
|
146
|
-
retryCount: 0,
|
|
147
|
-
timeout,
|
|
148
|
-
})
|
|
157
|
+
const transport = supportedTransports[i]
|
|
149
158
|
try {
|
|
150
159
|
const response = await transport.request({
|
|
151
160
|
method,
|
|
@@ -175,7 +184,7 @@ export function fallback<const transports extends readonly Transport[]>(
|
|
|
175
184
|
}
|
|
176
185
|
|
|
177
186
|
// If we've reached the end of the fallbacks, throw the error.
|
|
178
|
-
if (i ===
|
|
187
|
+
if (i === supportedTransports.length - 1) {
|
|
179
188
|
throw err
|
|
180
189
|
}
|
|
181
190
|
|
package/src/transports/http.ts
CHANGED
|
@@ -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
|
})
|
package/src/transports/types.ts
CHANGED
|
@@ -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',
|
package/src/transports/utxo.ts
CHANGED
|
@@ -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 {
|
|
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]
|
package/src/types/request.ts
CHANGED
|
@@ -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?:
|
|
38
|
+
include?: UTXOMethod[] | undefined
|
|
38
39
|
}
|
|
39
40
|
| {
|
|
40
|
-
exclude?:
|
|
41
|
+
exclude?: UTXOMethod[] | undefined
|
|
41
42
|
}
|
|
42
43
|
>
|
|
43
44
|
| undefined
|
package/src/types/transport.ts
CHANGED
|
@@ -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?:
|
|
19
|
+
include?: UTXOMethod[] | undefined
|
|
19
20
|
}
|
|
20
21
|
| {
|
|
21
|
-
exclude?:
|
|
22
|
+
exclude?: UTXOMethod[] | undefined
|
|
22
23
|
}
|
|
23
24
|
>
|
|
24
25
|
| undefined
|
package/src/utils/getAction.ts
CHANGED
|
@@ -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.
|
|
2
|
+
export const version = '0.3.0-beta.4'
|