Skip to content
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
4cc61a5
feat(lib/nodes/abstract.node.ts): request a node by IP if domain is n…
graycraft Apr 20, 2025
64e79a0
feat(lib/nodes/): request a node by IP if domain is not available
graycraft Apr 20, 2025
3828ade
feat(lib/nodes/eth/EthNode.ts): request a node by IP if domain is not…
graycraft Apr 21, 2025
4ce93cb
chore(src/lib/nodes/): import `NodeInfo` interface instead of explici…
graycraft Apr 22, 2025
259d74c
chore(src/lib/nodes/): rename `this.alt_ip` to `this.altIp`
graycraft Apr 22, 2025
9a5e3af
refactor(src/lib/nodes/): remove mapping of endpoint properties
graycraft May 12, 2025
8b50ec2
fix(src/lib/nodes/): add `baseURL` detection for `get` requests
graycraft May 13, 2025
32674e8
chore(src/lib/nodes/): add `console.info` for debugging domain-IP swi…
graycraft Jun 7, 2025
df7ac0d
refactor(src/lib/nodes/eth/Eth{Client,Node}.ts): create 2 clients in …
graycraft Jun 11, 2025
086cec5
refactor(src/lib/nodes/): split Eth node clients to main and alt
graycraft Jun 11, 2025
f3578ad
refactor(src/lib/nodes/): move base URL detection logic to `getBaseUR…
graycraft Jun 11, 2025
1ab8aa2
refactor(src/lib/nodes/abstract.node.ts): simplify domain-IP switch l…
graycraft Jun 17, 2025
c94387c
refactor(src/lib/nodes/): rename property to `preferDomain` and inver…
graycraft Jun 17, 2025
8010ea0
refactor(src/lib/nodes/abstract.node.ts): rename property to `availab…
graycraft Jun 17, 2025
1a78ec5
fix(src/{lib/nodes/,store/modules/{erc20,eth}}): create a new client …
graycraft Jun 17, 2025
4be85c4
perf(src/lib/nodes/eth/EthNode.ts): return cached clients
graycraft Jun 18, 2025
9f6bc2e
refactor(src/lib/nodes/eth/EthNode.ts): return main client if `altIp`…
graycraft Jun 20, 2025
2e7236e
refactor(src/lib/nodes/eth/EthClient.ts): rename `getClientInstance` …
graycraft Jun 20, 2025
c011741
refactor(src/lib/nodes): do not check node URL on client initialization
graycraft Jun 20, 2025
b574708
refactor(src/lib/nodes/eth-indexer/EthIndexer.ts): do not check node …
graycraft Jun 20, 2025
d24aa2b
chore(src/lib/nodes): remove type definition of `baseURL`
graycraft Jun 20, 2025
69e7556
refactor(src/lib/nodes): move `getBaseURL` method to the abstract nod…
graycraft Jun 20, 2025
d4e96b0
refactor(src/lib/nodes/{abstract.client.ts,eth/EthClient.ts}): move `…
graycraft Jun 21, 2025
9d7df2b
chore(src/lib/nodes/abstract.node.ts): return `this` context of node …
graycraft Jun 22, 2025
caa984f
test(src/lib/nodes/__tests__/): add tests for Ethereum nodes
graycraft Jun 22, 2025
7527cee
Merge branch 'dev' into feature/alternative-ip
graycraft Jun 29, 2025
463d175
Merge branch 'dev' into feature/alternative-ip
graycraft Aug 5, 2025
417afe1
feat(src/lib/nodes/abstract.node.ts): update URL components of a node…
graycraft Aug 18, 2025
7fbe7a0
chore(src/lib/nodes/abstract.node.ts): debug additional parameters fo…
graycraft Aug 18, 2025
abedafd
chore(src/lib/nodes/abstract.node.ts): debug messages for `startHealt…
graycraft Aug 18, 2025
b63eb13
docs(src/lib/nodes/abstract.node.ts): do not return node instance
graycraft Aug 19, 2025
ce031ae
fix(src/lib/nodes/abstract.node.ts): satisfy URL constructor requirem…
graycraft Aug 24, 2025
ae08a9d
fix(src/lib/nodes/abstract.node.ts): update health check logic in acc…
graycraft Aug 28, 2025
4afc731
chore(src/lib/nodes/abstract.node.ts): print healthcheck messages ver…
graycraft Aug 28, 2025
c16535e
fix(src/lib/nodes/abstract.node.ts): healthcheck messages text
graycraft Aug 28, 2025
0cbb116
fix(src/lib/nodes/abstract.node.ts): `firstDomainAttempt` property sw…
graycraft Aug 28, 2025
85fb7a1
fix(src/lib/nodes/abstract.node.ts): perform healthcheck only if a no…
graycraft Aug 28, 2025
a777fb3
fix(src/lib/nodes/abstract.node.ts): update `hasSupportedProtocol` af…
graycraft Aug 28, 2025
49b06ff
fix(src/lib/nodes/abstract.node.ts): enable `hasSupportedProtocol` if…
graycraft Aug 28, 2025
c9f1239
Merge branch 'dev' into feature/alternative-ip
graycraft Sep 1, 2025
0c6d1c4
chore(release-notes.md): add entry with PR #768 to improvements
graycraft Sep 1, 2025
da80374
fix(src/lib/nodes/abstract.node.ts): count connections and check prot…
graycraft Sep 2, 2025
68051ec
fix(src/lib/nodes/abstract.node.ts): check alt IP if defined and prot…
graycraft Sep 2, 2025
f7edc8c
fix(src/lib/nodes/abstract.node.ts): `connectionCount` and `preferDom…
graycraft Sep 2, 2025
d95c97d
fix(src/lib/nodes/abstract.node.ts): `this.altIp` instead of `checkAl…
graycraft Sep 2, 2025
3d54318
Merge remote-tracking branch 'origin/dev' into feature/alternative-ip
S-FrontendDev Sep 5, 2025
ee29448
feat(src/lib/nodes/abstract.node.ts): reset HealthCheck status if a n…
graycraft Sep 6, 2025
aed69d5
refactor(src/lib/nodes/abstract.node.ts): rename `connectionCount` to…
graycraft Sep 6, 2025
c989b17
fix(src/lib/nodes/abstract.node.ts): increment `healthcheckCount` if …
graycraft Sep 6, 2025
1b771fe
chore(src/lib/nodes/abstract.node.ts): output alternative IP and URL …
graycraft Sep 6, 2025
56fc4c6
chore(src/lib/nodes/abstract.node.ts): remove debugging message from …
graycraft Sep 6, 2025
4b29aa7
fix(src/lib/nodes/abstract.node.ts): reset `healthcheckInProgress` af…
graycraft Sep 6, 2025
baab6f5
fix(src/lib/nodes/abstract.node.ts): reset `height` and `outOfSync` a…
graycraft Sep 7, 2025
37528e3
fix(src/lib/nodes/abstract.node.ts): set `outOfSync` to `false`, not …
graycraft Sep 7, 2025
49e04b8
fix(src/lib/nodes/abstract.node.ts): not reset `healthcheckInProgress…
graycraft Sep 7, 2025
49d9756
fix(src/lib/nodes/abstract.node.ts): check health if a node is online…
graycraft Sep 9, 2025
2fb2dce
fix(src/lib/nodes/abstract.node.ts): behavior according to the revise…
graycraft Sep 14, 2025
d166a47
fix(src/lib/nodes/abstract.node.ts): detecting insecure requests supp…
graycraft Sep 14, 2025
c32fb90
feat(src/lib/nodes/abstract.node.ts): mark a blocked HTTP node as off…
graycraft Sep 14, 2025
8622105
fix(src/lib/nodes/abstract.node.ts): invert logic of `isHttpBlocked` …
graycraft Sep 15, 2025
aea613c
Merge remote-tracking branch 'origin/dev' into feature/alternative-ip
S-FrontendDev Sep 15, 2025
ad6abeb
style(src/lib/nodes/abstract.node.ts): add trailing commas
graycraft Sep 18, 2025
bdda8b5
feat(src/lib/nodes/abstract.node.ts): if connection lost repeat URL/I…
graycraft Sep 18, 2025
eee2431
chore(src/lib/nodes/abstract.node.ts): log message about successful c…
graycraft Sep 27, 2025
100cc3f
fix(src/lib/nodes/abstract.node.ts): persistently save connection typ…
graycraft Sep 28, 2025
8993697
fix(src/lib/nodes/abstract.node.ts): temporaly consider node offline …
graycraft Oct 8, 2025
1c3ec3d
feat(store/modules/dev-tools): add Vuex store for ADAMANT Development…
graycraft Oct 25, 2025
6571301
feat(store): add Vuex store for ADAMANT Development Tools
graycraft Oct 25, 2025
57b56e3
feat(store/types/root-state): define `devTools` in root state
graycraft Oct 25, 2025
edcaed8
feat(store/plugins/localStorage): save `devTools` state to local storage
graycraft Oct 25, 2025
06e400a
feat(src/locales/{en,ru}.json): add translation for `dev_screens.logg…
graycraft Oct 25, 2025
d855d1f
feat(views/devScreens/DevScreens): add dropdown for verbose logging
graycraft Oct 25, 2025
d36c88e
Merge branch 'feat/log-verbosity' into feature/alternative-ip
graycraft Oct 27, 2025
4f50736
test(abstract.node.ts): output status update messages at debug level,…
graycraft Oct 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/config/utils/nodes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NodeInfo } from '@/types/wallets'
import type { NodeInfo } from '@/types/wallets'
import { BlockchainSymbol } from './types'
import config from '../index'

Expand Down
6 changes: 5 additions & 1 deletion src/lib/nodes/abstract.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ export abstract class Client<N extends Node> {
// This method can throw an error if there are no online nodes.
// Better use "useClient()" method.
getClient(): N['client'] {
return this.getNode().client
const node = this.getNode()

// Ethereum nodes return a new client every time depending on `preferDomain` property.
if (node.type === 'eth') return (node.client as () => N['client'])()
else return node.client
}

/**
Expand Down
54 changes: 50 additions & 4 deletions src/lib/nodes/abstract.node.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getHealthCheckInterval } from './utils/getHealthcheckConfig'
import type { NodeInfo } from '@/types/wallets/index.ts'
import { getBaseURL, getHealthCheckInterval } from './utils/getHealthcheckConfig'
import { TNodeLabel } from './constants'
import { HealthcheckInterval, HealthcheckResult, NodeKind, NodeStatus, NodeType } from './types'
import { nodesStorage } from './storage'
Expand Down Expand Up @@ -29,6 +30,10 @@ export abstract class Node<C = unknown> {
*/
wsPort = '36668'

/**
* Node alternative IP
*/
altIp?: string
/**
* Node base URL
*/
Expand Down Expand Up @@ -56,10 +61,22 @@ export abstract class Node<C = unknown> {
hasSupportedProtocol = true

// Healthcheck related params
/**
* Indicates whether a node with alternative IP is available
*/
altIpAvailable = false
/**
* Indicates whether a node with main URL is available
*/
availableByDomain = true
/**
* Indicates whether node is available.
*/
online = true
/**
* Indicates whether prefer a node with alternative IP or not
*/
preferDomain = true
/**
* Node ping estimation
*/
Expand Down Expand Up @@ -97,13 +114,16 @@ export abstract class Node<C = unknown> {
healthcheckInProgress = false

constructor(
url: string,
endpoint: NodeInfo,
type: NodeType,
kind: NodeKind,
label: TNodeLabel,
version = '',
minNodeVersion = ''
) {
const { alt_ip, url } = endpoint

this.altIp = alt_ip
this.url = url
this.type = type
this.label = label
Expand Down Expand Up @@ -134,8 +154,31 @@ export abstract class Node<C = unknown> {
this.height = health.height
this.ping = health.ping
this.online = true

if (this.preferDomain) {
console.info(
`Attempt to use domain ${this.url} performed successfully, using domain by default.`
)
this.availableByDomain = true
} else {
console.info(
`There was a failed attempt to use domain ${this.url}, using IP ${this.altIp} by default.`
)
}
} catch {
this.online = false
if (this.preferDomain && this.availableByDomain) {
console.info(
`There was a failed attempt to use domain ${this.url}, trying to use IP ${this.altIp} in the next attempt.`
)
this.availableByDomain = false
this.preferDomain = false
} else {
console.info(
`There was failed attempts to use domain ${this.url} and IP ${this.altIp}, assume node is offline.`
)
this.online = false
this.preferDomain = true
}
} finally {
this.healthcheckInProgress = false
}
Expand Down Expand Up @@ -164,6 +207,7 @@ export abstract class Node<C = unknown> {

getStatus() {
return {
alt_ip: this.altIp,
url: this.url,
port: this.port,
hostname: this.hostname,
Expand Down Expand Up @@ -224,9 +268,11 @@ export abstract class Node<C = unknown> {
* Enables/disables a node.
*/
toggleNode(active: boolean) {
const baseURL = getBaseURL(this)

this.active = active

nodesStorage.saveActive(this.url, active)
nodesStorage.saveActive(baseURL, active)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this will work as expected, considering that the URL passed can now be not only a domain but also an IP address?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good question, I did not investigate into nodes storage yet

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


return this.getStatus()
}
Expand Down
7 changes: 5 additions & 2 deletions src/lib/nodes/adm/AdmClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
RegisterChatMessageTransaction
} from '@/lib/schema/client'
import { NODE_LABELS } from '@/lib/nodes/constants'
import type { NodeInfo } from '@/types/wallets'
import { AdmNode, Payload, RequestConfig } from './AdmNode'
import { Client } from '../abstract.client'

Expand All @@ -16,7 +17,7 @@ import { Client } from '../abstract.client'
* is not available at the moment.
*/
export class AdmClient extends Client<AdmNode> {
constructor(endpoints: string[] = [], minNodeVersion = '0.0.0') {
constructor(endpoints: NodeInfo[] = [], minNodeVersion = '0.0.0') {
super('adm', 'node', NODE_LABELS.AdmNode)
this.nodes = endpoints.map((endpoint) => new AdmNode(endpoint, minNodeVersion))
this.minNodeVersion = minNodeVersion
Expand Down Expand Up @@ -75,7 +76,9 @@ export class AdmClient extends Client<AdmNode> {
return this.getNode().timeDelta
}

async sendChatTransaction(transaction: RegisterChatMessageTransaction): Promise<CreateNewChatMessageResponseDto> {
async sendChatTransaction(
transaction: RegisterChatMessageTransaction
): Promise<CreateNewChatMessageResponseDto> {
return this.post('/api/chats/process', () => ({ transaction }))
}
}
16 changes: 10 additions & 6 deletions src/lib/nodes/adm/AdmNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { GetNodeStatusResponseDto } from '@/lib/schema/client'
import axios, { AxiosInstance, AxiosRequestConfig } from 'axios'
import { Node } from '@/lib/nodes/abstract.node'
import { NODE_LABELS } from '@/lib/nodes/constants'
import { getBaseURL } from '@/lib/nodes/utils/getHealthcheckConfig'
import type { NodeInfo } from '@/types/wallets'

type FetchNodeInfoResult = {
socketSupport: boolean
Expand All @@ -18,6 +20,7 @@ export type Payload =
(ctx: AdmNode): Record<string, any>
}
export type RequestConfig<P extends Payload> = {
baseURL?: string
url: string
method?: string
payload?: P
Expand All @@ -28,18 +31,18 @@ export type RequestConfig<P extends Payload> = {
* to the node and verify is status (online/offline, version, ping, etc.)
*/
export class AdmNode extends Node<AxiosInstance> {
constructor(url: string, minNodeVersion = '0.0.0') {
super(url, 'adm', 'node', NODE_LABELS.AdmNode, '', minNodeVersion)
constructor(endpoint: NodeInfo, minNodeVersion = '0.0.0') {
super(endpoint, 'adm', 'node', NODE_LABELS.AdmNode, '', minNodeVersion)

this.wsPort = '36668' // default wsPort
this.wsProtocol = this.protocol === 'https:' ? 'wss:' : 'ws:'
this.wsPortNeeded = this.wsProtocol === 'ws:' && !this.hostname.includes('.onion')
}

protected buildClient(): AxiosInstance {
return axios.create({
baseURL: this.url
})
const baseURL = getBaseURL(this)

return axios.create({ baseURL })
}

/**
Expand All @@ -50,8 +53,10 @@ export class AdmNode extends Node<AxiosInstance> {
*/
request<P extends Payload = Payload, R = any>(cfg: RequestConfig<P>): Promise<R> {
const { url, method = 'get', payload } = cfg
const baseURL = getBaseURL(this)

const config: AxiosRequestConfig = {
baseURL,
url,
method: method.toLowerCase(),
[method === 'get' ? 'params' : 'data']:
Expand All @@ -72,7 +77,6 @@ export class AdmNode extends Node<AxiosInstance> {
// According to https://github.com/axios/axios#handling-errors this means, that request was sent,
// but server could not respond.
if (!error.response && error.request) {
this.online = false
throw new NodeOfflineError()
}
throw error
Expand Down
5 changes: 3 additions & 2 deletions src/lib/nodes/adm/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import config from '@/config'
import { NodeInfo } from '@/types/wallets'
import type { NodeInfo } from '@/types/wallets'
import { AdmClient } from './AdmClient'

const endpoints = (config.adm.nodes.list as NodeInfo[]).map((endpoint) => endpoint.url)
const endpoints = config.adm.nodes.list as NodeInfo[]

export const adm = new AdmClient(endpoints, config.adm.nodes.minVersion)

export default adm
25 changes: 19 additions & 6 deletions src/lib/nodes/btc-indexer/BtcIndexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,35 @@ import { createBtcLikeClient } from '../utils/createBtcLikeClient'
import { AxiosInstance, AxiosRequestConfig } from 'axios'
import { Node } from '@/lib/nodes/abstract.node'
import { NODE_LABELS } from '@/lib/nodes/constants'
import { getBaseURL } from '@/lib/nodes/utils/getHealthcheckConfig'
import type { NodeInfo } from '@/types/wallets'

/**
* Encapsulates a node. Provides methods to send API-requests
* to the node and verify is status (online/offline, version, ping, etc.)
*/
export class BtcIndexer extends Node<AxiosInstance> {
constructor(url: string) {
super(url, 'btc', 'service', NODE_LABELS.BtcIndexer)
constructor(endpoint: NodeInfo) {
super(endpoint, 'btc', 'service', NODE_LABELS.BtcIndexer)
}

protected buildClient(): AxiosInstance {
return createBtcLikeClient(this.url)
const baseURL = getBaseURL(this)

return createBtcLikeClient(baseURL)
}

protected async checkHealth() {
const time = Date.now()
const blockNumber = await this.client.get('/blocks/tip/height').then((res) => {
return Number(res.data) || 0
})
const baseURL = getBaseURL(this)

const blockNumber = await this.client
.get('/blocks/tip/height', {
baseURL
})
.then((res) => {
return Number(res.data) || 0
})

return {
height: Number(blockNumber),
Expand All @@ -37,9 +47,12 @@ export class BtcIndexer extends Node<AxiosInstance> {
params?: Params,
requestConfig?: AxiosRequestConfig
): Promise<Response> {
const baseURL = getBaseURL(this)

return this.client
.request({
...requestConfig,
baseURL,
url: path,
method,
params: method === 'GET' ? params : undefined,
Expand Down
3 changes: 2 additions & 1 deletion src/lib/nodes/btc-indexer/BtcIndexerClient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { AxiosRequestConfig } from 'axios'
import { NODE_LABELS } from '@/lib/nodes/constants'
import type { NodeInfo } from '@/types/wallets'
import { Client } from '../abstract.client'
import { BtcIndexer } from './BtcIndexer'
import { MULTIPLIER, normalizeTransaction } from './utils'
Expand All @@ -17,7 +18,7 @@ import { GetUnspentsParams } from './types/api/get-unspents/get-unspents-params'
* is not available at the moment.
*/
export class BtcIndexerClient extends Client<BtcIndexer> {
constructor(endpoints: string[] = [], minNodeVersion = '0.0.0') {
constructor(endpoints: NodeInfo[] = [], minNodeVersion = '0.0.0') {
super('btc', 'service', NODE_LABELS.BtcIndexer)
this.nodes = endpoints.map((endpoint) => new BtcIndexer(endpoint))
this.minNodeVersion = minNodeVersion
Expand Down
5 changes: 3 additions & 2 deletions src/lib/nodes/btc-indexer/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import config from '@/config'
import { NodeInfo } from '@/types/wallets'
import type { NodeInfo } from '@/types/wallets'
import { BtcIndexerClient } from './BtcIndexerClient'

const endpoints = (config.btc.services.btcIndexer.list as NodeInfo[]).map((endpoint) => endpoint.url)
const endpoints = config.btc.services.btcIndexer.list as NodeInfo[]

export const btcIndexer = new BtcIndexerClient(endpoints)

export default btcIndexer
3 changes: 2 additions & 1 deletion src/lib/nodes/btc/BtcClient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { AxiosRequestConfig } from 'axios'
import { NODE_LABELS } from '@/lib/nodes/constants'
import type { NodeInfo } from '@/types/wallets'
import { BtcNode } from './BtcNode'
import { Client } from '../abstract.client'
import { RpcRequest } from './types/api/common'
Expand All @@ -12,7 +13,7 @@ import { RpcRequest } from './types/api/common'
* is not available at the moment.
*/
export class BtcClient extends Client<BtcNode> {
constructor(endpoints: string[] = [], minNodeVersion = '0.0.0') {
constructor(endpoints: NodeInfo[] = [], minNodeVersion = '0.0.0') {
super('btc', 'node', NODE_LABELS.BtcNode)
this.nodes = endpoints.map((endpoint) => new BtcNode(endpoint))
this.minNodeVersion = minNodeVersion
Expand Down
13 changes: 10 additions & 3 deletions src/lib/nodes/btc/BtcNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import { AxiosInstance, AxiosRequestConfig } from 'axios'
import { createBtcLikeClient } from '../utils/createBtcLikeClient'
import { Node } from '@/lib/nodes/abstract.node'
import { NODE_LABELS } from '@/lib/nodes/constants'
import { getBaseURL } from '@/lib/nodes/utils/getHealthcheckConfig'
import { formatBtcVersion } from '@/lib/nodes/utils/nodeVersionFormatters'
import type { NodeInfo } from '@/types/wallets'
import { RpcRequest, RpcResponse } from './types/api/common'
import { NetworkInfo } from './types/api/network-info'
import { BlockchainInfo } from './types/api/blockchain-info'
Expand All @@ -12,12 +14,14 @@ import { BlockchainInfo } from './types/api/blockchain-info'
* to the node and verify is status (online/offline, version, ping, etc.)
*/
export class BtcNode extends Node<AxiosInstance> {
constructor(url: string) {
super(url, 'btc', 'node', NODE_LABELS.BtcNode)
constructor(endpoint: NodeInfo) {
super(endpoint, 'btc', 'node', NODE_LABELS.BtcNode)
}

protected buildClient(): AxiosInstance {
return createBtcLikeClient(this.url)
const baseURL = getBaseURL(this)

return createBtcLikeClient(baseURL)
}

protected async checkHealth() {
Expand Down Expand Up @@ -50,9 +54,12 @@ export class BtcNode extends Node<AxiosInstance> {
params?: Params,
requestConfig?: AxiosRequestConfig
): Promise<Result> {
const baseURL = getBaseURL(this)

return this.client
.request<RpcResponse<Result>>({
...requestConfig,
baseURL,
method: 'POST',
data: params
})
Expand Down
5 changes: 3 additions & 2 deletions src/lib/nodes/btc/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import config from '@/config'
import { NodeInfo } from '@/types/wallets'
import type { NodeInfo } from '@/types/wallets'
import { BtcClient } from './BtcClient'

const endpoints = (config.btc.nodes.list as NodeInfo[]).map((endpoint) => endpoint.url)
const endpoints = config.btc.nodes.list as NodeInfo[]

export const btc = new BtcClient(endpoints)

export default btc
1 change: 1 addition & 0 deletions src/lib/nodes/btc/types/api/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Method =
| 'getaddressbalance'

export type RpcRequest<P = any, M extends Method | string = string> = {
baseURL?: string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove it. Axios already contains this property.

image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point is to update URL here before request

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm referring to baseURL you added to RpcRequest. This property has no effect and isn't used anywhere. It compiles fine without it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

method: M
params?: P
}
Loading