Skip to content

Commit afb168f

Browse files
chore(deps): bump @xchainjs/* packages to latest (#1140)
* chore(deps): bump @xchainjs/* packages to latest Upgrades 32 @xchainjs packages (all minor/patch bumps, no majors): xchain-aggregator 2.4.0→2.5.0, xchain-arbitrum 2.1.5→2.1.6, xchain-avax 2.0.19→2.0.20, xchain-base 1.0.19→1.0.20, xchain-bitcoin 2.2.7→2.3.0, xchain-bitcoincash 2.2.8→2.3.0, xchain-bsc 2.0.20→2.0.21, xchain-cardano 1.2.2→1.2.3, xchain-client 2.0.15→2.0.16, xchain-cosmos 3.0.15→3.0.16, xchain-crypto 1.0.7→1.0.8, xchain-dash 2.2.7→2.2.8, xchain-doge 2.2.7→2.3.0, xchain-ethereum 2.0.20→2.0.21, xchain-evm 2.0.19→2.0.20, xchain-evm-providers 2.0.18→2.0.19, xchain-kujira 2.0.15→2.0.16, xchain-litecoin 2.3.4→2.4.0, xchain-mayachain 4.1.6→4.1.7, xchain-mayachain-query 2.2.1→2.2.2, xchain-radix 2.0.16→2.0.17, xchain-ripple 1.0.17→1.0.18, xchain-solana 1.1.7→1.1.8, xchain-sui 0.1.4→0.1.5, xchain-thorchain 3.0.19→3.0.20, xchain-thorchain-query 3.1.1→3.1.2, xchain-thornode 1.2.1→1.2.2, xchain-tron 3.0.8→3.0.9, xchain-utxo 2.2.7→2.2.8, xchain-utxo-providers 2.0.17→2.1.0, xchain-wallet 2.0.30→2.0.31, xchain-zcash 1.3.8→1.3.9. No application code changes were required — TypeScript compiled clean with zero errors after the upgrade. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(renderer): drop crypto-shim; rely on xchain-crypto 1.0.8 timingSafeEqual fallback The `crypto` alias pointed at src/shims/crypto-shim.js, which wrapped crypto-browserify to add `timingSafeEqual` (#1115) so xchain-crypto keystore decrypt worked in the renderer. xchain-crypto 1.0.8 (this bump) now ships `constantTimeEqual` with its own constant-time fallback when the crypto polyfill lacks `timingSafeEqual`, so the shim is redundant. The shim also caused a production-only blank renderer after this bump: its `export *` + `export default` compiled to a namespace getter (`get default(){ return cryptoBrowserify }`) that was invoked during chunk init before the `cryptoBrowserify` const initialized — a temporal-dead-zone ReferenceError that aborted the renderer bundle (window opened, blank white). Deleting the shim and restoring the direct `crypto: 'crypto-browserify'` alias resolves it. Verified: production build renders (MPC SDK init + renderer IPC), zero TDZ; lint + wallet tests pass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * feat(swap): route quotes through Liquify primary, public nodes as fallback The public THORChain/MAYAChain endpoints (thornode/midgard.thorchain.network, mayanode/midgard.mayachain.info) are frequently slow or unresolvable. xchainjs lists them FIRST and only falls back to Liquify, so every request storms the dead host (console-error spam) and the methods that don't fail over break. Configure the swap Aggregator (new in xchain-aggregator 2.5.0) with explicit Liquify-primary endpoints for both protocols — thornodeConfig, midgardConfig, mayanodeConfig, mayaMidgardConfig — at both config sites (initial `new Aggregator` in slice.ts and runtime `setConfiguration` in actions.ts). Shared helper in helpers/liquifyEndpoints.ts; mainnet only (other networks keep xchainjs defaults). ThorchainQueryContext reuses the same LIQUIFY_THORNODE_URLS so both quote paths behave consistently. Depends on the aggregator 2.5.0 bump in this PR (the *Config hooks don't exist in 2.4.0). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix trunk issue * fix(thorchain): init ThorchainQuery from active network, not hardcoded mainnet Addresses CodeRabbit review on #1140: the initial useState hardcoded Network.Mainnet, so a persisted Stagenet session could issue an initial query against Mainnet before the network subscription replaced the cache. Use getCurrentNetworkState() to match the aggregator slice. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent fa14704 commit afb168f

8 files changed

Lines changed: 410 additions & 384 deletions

File tree

electron.vite.config.mjs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,7 @@ export default defineConfig(async ({ mode }) => {
8383
alias: {
8484
process: 'process/browser',
8585
stream: 'stream-browserify',
86-
// Shim wraps crypto-browserify and adds `timingSafeEqual` (missing in
87-
// the browser polyfill) so xchain-crypto >= 1.0.7 keystore decrypt works.
88-
crypto: path.resolve(__dirname, 'src/shims/crypto-shim.js'),
86+
crypto: 'crypto-browserify',
8987
assert: 'assert',
9088
path: path.resolve(__dirname, 'empty.js'),
9189
url: path.resolve(__dirname, 'empty.js'),

package.json

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -80,42 +80,42 @@
8080
"@reduxjs/toolkit": "^2.3.0",
8181
"@tanstack/react-table": "^8.21.3",
8282
"@vultisig/sdk": "0.22.5",
83-
"@xchainjs/xchain-aggregator": "2.4.0",
84-
"@xchainjs/xchain-arbitrum": "2.1.5",
85-
"@xchainjs/xchain-avax": "2.0.19",
86-
"@xchainjs/xchain-base": "1.0.19",
87-
"@xchainjs/xchain-bitcoin": "2.2.7",
88-
"@xchainjs/xchain-bitcoincash": "2.2.8",
89-
"@xchainjs/xchain-bsc": "2.0.20",
90-
"@xchainjs/xchain-cardano": "1.2.2",
91-
"@xchainjs/xchain-client": "2.0.15",
92-
"@xchainjs/xchain-cosmos": "3.0.15",
93-
"@xchainjs/xchain-crypto": "1.0.7",
94-
"@xchainjs/xchain-dash": "2.2.7",
95-
"@xchainjs/xchain-doge": "2.2.7",
96-
"@xchainjs/xchain-ethereum": "2.0.20",
97-
"@xchainjs/xchain-evm": "2.0.19",
98-
"@xchainjs/xchain-evm-providers": "2.0.18",
99-
"@xchainjs/xchain-kujira": "2.0.15",
100-
"@xchainjs/xchain-litecoin": "2.3.4",
101-
"@xchainjs/xchain-mayachain": "4.1.6",
102-
"@xchainjs/xchain-mayachain-query": "2.2.1",
83+
"@xchainjs/xchain-aggregator": "2.5.0",
84+
"@xchainjs/xchain-arbitrum": "2.1.6",
85+
"@xchainjs/xchain-avax": "2.0.20",
86+
"@xchainjs/xchain-base": "1.0.20",
87+
"@xchainjs/xchain-bitcoin": "2.3.0",
88+
"@xchainjs/xchain-bitcoincash": "2.3.0",
89+
"@xchainjs/xchain-bsc": "2.0.21",
90+
"@xchainjs/xchain-cardano": "1.2.3",
91+
"@xchainjs/xchain-client": "2.0.16",
92+
"@xchainjs/xchain-cosmos": "3.0.16",
93+
"@xchainjs/xchain-crypto": "1.0.8",
94+
"@xchainjs/xchain-dash": "2.2.8",
95+
"@xchainjs/xchain-doge": "2.3.0",
96+
"@xchainjs/xchain-ethereum": "2.0.21",
97+
"@xchainjs/xchain-evm": "2.0.20",
98+
"@xchainjs/xchain-evm-providers": "2.0.19",
99+
"@xchainjs/xchain-kujira": "2.0.16",
100+
"@xchainjs/xchain-litecoin": "2.4.0",
101+
"@xchainjs/xchain-mayachain": "4.1.7",
102+
"@xchainjs/xchain-mayachain-query": "2.2.2",
103103
"@xchainjs/xchain-mayamidgard": "1.1.3",
104104
"@xchainjs/xchain-mayanode": "1.2.3",
105105
"@xchainjs/xchain-midgard": "1.1.3",
106-
"@xchainjs/xchain-radix": "2.0.16",
107-
"@xchainjs/xchain-ripple": "1.0.17",
108-
"@xchainjs/xchain-solana": "1.1.7",
109-
"@xchainjs/xchain-sui": "0.1.4",
110-
"@xchainjs/xchain-thorchain": "3.0.19",
111-
"@xchainjs/xchain-thorchain-query": "3.1.1",
112-
"@xchainjs/xchain-thornode": "1.2.1",
113-
"@xchainjs/xchain-tron": "3.0.8",
106+
"@xchainjs/xchain-radix": "2.0.17",
107+
"@xchainjs/xchain-ripple": "1.0.18",
108+
"@xchainjs/xchain-solana": "1.1.8",
109+
"@xchainjs/xchain-sui": "0.1.5",
110+
"@xchainjs/xchain-thorchain": "3.0.20",
111+
"@xchainjs/xchain-thorchain-query": "3.1.2",
112+
"@xchainjs/xchain-thornode": "1.2.2",
113+
"@xchainjs/xchain-tron": "3.0.9",
114114
"@xchainjs/xchain-util": "2.0.7",
115-
"@xchainjs/xchain-utxo": "2.2.7",
116-
"@xchainjs/xchain-utxo-providers": "2.0.17",
117-
"@xchainjs/xchain-wallet": "2.0.30",
118-
"@xchainjs/xchain-zcash": "1.3.8",
115+
"@xchainjs/xchain-utxo": "2.2.8",
116+
"@xchainjs/xchain-utxo-providers": "2.1.0",
117+
"@xchainjs/xchain-wallet": "2.0.31",
118+
"@xchainjs/xchain-zcash": "1.3.9",
119119
"axios": "1.16.1",
120120
"bignumber.js": "^10.0.1",
121121
"clsx": "^2.1.1",

src/renderer/contexts/ThorchainQueryContext.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
import React, { createContext, useContext, useEffect, useState } from 'react'
22

3+
import { Network } from '@xchainjs/xchain-client'
34
import { ThorchainCache, ThorchainQuery, Thornode } from '@xchainjs/xchain-thorchain-query'
45

5-
import { clientNetwork$ } from '../services/app/service'
6+
import { LIQUIFY_THORNODE_URLS } from '../helpers/liquifyEndpoints'
7+
import { clientNetwork$, getCurrentNetworkState } from '../services/app/service'
8+
9+
// Prefer the Liquify gateway over the public THORNode for mainnet quotes — the
10+
// xchainjs default lists `thornode.thorchain.network` first and only falls back
11+
// to Liquify. Keeps the same "Liquify primary" behaviour as the swap aggregator
12+
// (see helpers/liquifyEndpoints). Other networks keep the library defaults
13+
// (stagenet has no URLs, testnet is deprecated).
14+
const createThornode = (network: Network): Thornode =>
15+
network === Network.Mainnet
16+
? new Thornode(network, { apiRetries: 3, thornodeBaseUrls: LIQUIFY_THORNODE_URLS })
17+
: new Thornode(network)
618

719
// Define the type of the context value here
820
interface ThorchainQueryContextValue {
@@ -14,13 +26,15 @@ const ThorchainQueryContext = createContext<ThorchainQueryContextValue | null>(n
1426

1527
// Provider component
1628
export const ThorchainQueryProvider = ({ children }: { children: React.ReactNode }) => {
17-
const [thorchainQuery, setThorchainQuery] = useState<ThorchainQuery>(new ThorchainQuery())
29+
const [thorchainQuery, setThorchainQuery] = useState<ThorchainQuery>(
30+
() => new ThorchainQuery(new ThorchainCache(createThornode(getCurrentNetworkState())))
31+
)
1832

1933
useEffect(() => {
2034
// Subscribe to network$ observable
2135
const subscription = clientNetwork$.subscribe((network) => {
2236
// Create a new ThorchainQuery with the updated network
23-
const thorchainCache = new ThorchainCache(new Thornode(network))
37+
const thorchainCache = new ThorchainCache(createThornode(network))
2438
setThorchainQuery(new ThorchainQuery(thorchainCache))
2539
})
2640

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { Network } from '@xchainjs/xchain-client'
2+
3+
// Prefer the Liquify gateway over the public THORChain / MAYAChain endpoints.
4+
//
5+
// The xchainjs defaults list the public nodes (thornode.thorchain.network,
6+
// midgard.thorchain.network, mayanode.mayachain.info, midgard.mayachain.info)
7+
// FIRST and only fall back to Liquify. When the public nodes are slow or down —
8+
// as they regularly are — every request storms the dead host first (a wall of
9+
// console errors), and the methods that don't fail over (e.g. getQueue) break
10+
// outright. Making Liquify primary avoids that while keeping the public nodes as
11+
// a fallback.
12+
//
13+
// Mainnet only: stagenet/testnet keep the xchainjs network defaults.
14+
export const LIQUIFY_THORNODE_URLS = [
15+
'https://gateway.liquify.com/chain/thorchain_api',
16+
'https://thornode.thorchain.network'
17+
]
18+
const LIQUIFY_MIDGARD_URLS = [
19+
'https://gateway.liquify.com/chain/thorchain_midgard',
20+
'https://midgard.thorchain.network'
21+
]
22+
const LIQUIFY_MAYANODE_URLS = ['https://api-maya.liquify.com', 'https://mayanode.mayachain.info']
23+
const LIQUIFY_MAYA_MIDGARD_URLS = ['https://midgard-maya.liquify.com', 'https://midgard.mayachain.info']
24+
25+
const API_RETRIES = 3
26+
27+
/**
28+
* Endpoint overrides for `@xchainjs/xchain-aggregator` — Liquify primary, public
29+
* node fallback — covering both the Thorchain (thornode + midgard) and Mayachain
30+
* (mayanode + maya midgard) protocols. Returns `{}` for non-mainnet networks so
31+
* the aggregator keeps its own network defaults.
32+
*/
33+
export const liquifyAggregatorConfig = (network: Network) =>
34+
network === Network.Mainnet
35+
? {
36+
thornodeConfig: { apiRetries: API_RETRIES, thornodeBaseUrls: LIQUIFY_THORNODE_URLS },
37+
midgardConfig: { apiRetries: API_RETRIES, midgardBaseUrls: LIQUIFY_MIDGARD_URLS },
38+
mayanodeConfig: { apiRetries: API_RETRIES, mayanodeBaseUrls: LIQUIFY_MAYANODE_URLS },
39+
mayaMidgardConfig: { apiRetries: API_RETRIES, midgardBaseUrls: LIQUIFY_MAYA_MIDGARD_URLS }
40+
}
41+
: {}

src/renderer/store/aggregator/actions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
ASGARDEX_ONECLICK_API_KEY
2323
} from '../../../shared/const'
2424
import { defaultEthParams } from '../../../shared/ethereum/const'
25+
import { liquifyAggregatorConfig } from '../../helpers/liquifyEndpoints'
2526
import { logger } from '../../helpers/logger'
2627

2728
export const getEstimate = createAsyncThunk(
@@ -104,6 +105,7 @@ export const getEstimate = createAsyncThunk(
104105
wallet,
105106
network,
106107
affiliateBrokers,
108+
...liquifyAggregatorConfig(network),
107109
...(brokerUrl && { brokerUrl }), // Only include brokerUrl if it's non-empty
108110
...(ASGARDEX_ONECLICK_API_KEY && { oneClickApiKey: ASGARDEX_ONECLICK_API_KEY })
109111
}

src/renderer/store/aggregator/slice.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
ASGARDEX_ONECLICK_API_KEY
2121
} from '../../../shared/const'
2222
import { defaultEthParams } from '../../../shared/ethereum/const'
23+
import { liquifyAggregatorConfig } from '../../helpers/liquifyEndpoints'
2324
import { logger } from '../../helpers/logger'
2425
import { getProtocolFromStorage, setValueToStorage, StorageKey } from '../../helpers/storage'
2526
import { getCurrentNetworkState } from '../../services/app/service'
@@ -87,6 +88,7 @@ const initialState: State = {
8788
network: getCurrentNetworkState(),
8889
brokerUrl: getBrokerUrl(),
8990
affiliateBrokers: getAffiliateBrokers(),
91+
...liquifyAggregatorConfig(getCurrentNetworkState()),
9092
...(ASGARDEX_ONECLICK_API_KEY && { oneClickApiKey: ASGARDEX_ONECLICK_API_KEY })
9193
}),
9294
quoteSwap: null

src/shims/crypto-shim.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)