Skip to content

Commit 256472d

Browse files
committed
feat(connect): use network shortcut not just symbol for identification
1 parent 3e4df52 commit 256472d

File tree

11 files changed

+14
-1
lines changed

11 files changed

+14
-1
lines changed

packages/blockchain-link-types/src/blockbook-api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ export interface WsInfoRes {
357357
bestHeight: number;
358358
bestHash: string;
359359
block0Hash: string;
360+
network: string;
360361
testnet: boolean;
361362
backend: WsBackendInfo;
362363
}

packages/blockchain-link-types/src/common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export interface ServerInfo {
3232
blockHeight: number;
3333
blockHash: string;
3434
consensusBranchId?: number; // zcash current branch id
35+
network?: string; // old Blockbooks do not have network set
3536
}
3637

3738
export type TokenStandard = 'ERC20' | 'ERC1155' | 'ERC721' | 'SPL';

packages/blockchain-link-utils/src/blockbook.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { Addresses, filterTargets, enhanceVinVout, sumVinVout, transformTarget }
2222
export const transformServerInfo = (payload: ServerInfo) => ({
2323
name: payload.name,
2424
shortcut: payload.shortcut,
25+
network: payload.network,
2526
testnet: payload.testnet,
2627
version: payload.version,
2728
decimals: payload.decimals,

packages/blockchain-link-utils/src/ripple.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { Transaction } from '@trezor/blockchain-link-types';
44
export const transformServerInfo = (payload: any) => ({
55
name: 'Ripple',
66
shortcut: 'xrp',
7+
network: 'xrp',
78
testnet: false,
89
version: payload.buildVersion,
910
decimals: 6,

packages/blockchain-link/src/workers/blockfrost/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const getInfo = async (request: Request<MessageTypes.GetInfo>) => {
2626
type: RESPONSES.GET_INFO,
2727
payload: {
2828
url: api.options.url,
29+
network: info.shortcut,
2930
...info,
3031
},
3132
} as const;

packages/blockchain-link/src/workers/solana/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ const getInfo = async (request: Request<MessageTypes.GetInfo>) => {
244244
blockHeight,
245245
blockHash,
246246
shortcut: isTestnet ? 'dsol' : 'sol',
247+
network: isTestnet ? 'dsol' : 'sol',
247248
url: api.rpcEndpoint,
248249
name: 'Solana',
249250
version: (await api.getVersion())['solana-core'],

packages/connect/e2e/__wscache__/blockbook.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const blockbookFixtures = {
1010
bestHeight: 7000000, // high block to make sure that utxos have enough confirmations (composeTransaction test)
1111
bestHash: '',
1212
block0Hash: '',
13+
network: params.shortcut,
1314
testnet: true,
1415
version: '0.0.0-mocked',
1516
},

packages/connect/src/backend/Blockchain.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,10 @@ export class Blockchain {
130130

131131
const shortcut = getNormalizedShortcut(this.coinInfo.shortcut);
132132

133-
if (info.shortcut.toLowerCase() !== shortcut.toLowerCase()) {
133+
if (
134+
info.network?.toLowerCase() !== shortcut.toLowerCase() &&
135+
info.shortcut.toLowerCase() !== shortcut.toLowerCase()
136+
) {
134137
throw ERRORS.TypedError('Backend_Invalid');
135138
}
136139

packages/suite-web/e2e/fixtures/eth-account.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ export const fixtures = [
103103
bestHeight: 19960825,
104104
bestHash: '0x8339e411cd2f62b9493e36c444f7bd11ec716ceaa94f491e9726233d22abc024',
105105
block0Hash: '0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3',
106+
network: 'ETH',
106107
testnet: false,
107108
backend: {
108109
version: 'erigon/2.59.3/linux-amd64/go1.21.6',

packages/suite-web/e2e/fixtures/send-form-doge.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ export const fixtures = [
131131
bestHeight: 4484566,
132132
bestHash: '38fbb073e7eb4bfac9ed485dd0b3212247fb2a3d8b509dc9738c01a86ede33b3',
133133
block0Hash: '1a91e3dace36e2be3bf030a65679fe821aa1d6ef92e7c9902eb318182c355691',
134+
network: 'DOGE',
134135
testnet: false,
135136
backend: { version: '1140600', subversion: '/Shibetoshi:1.14.6/' },
136137
},

0 commit comments

Comments
 (0)