forked from Txio-labs/txio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.explorer.test.ts
More file actions
90 lines (80 loc) · 2.81 KB
/
Copy pathutils.explorer.test.ts
File metadata and controls
90 lines (80 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import { describe, it, expect } from 'vitest';
import { getWalletExplorerUrl } from './utils';
import type { ConnectedWallet } from './types';
const suiWallet = {
family: 'sui',
address: '0xabc',
chain: { network: 'mainnet' }
} as unknown as ConnectedWallet;
const evmWallet = {
family: 'evm',
address: '0xdead',
chain: { id: 'eip155:1' }
} as unknown as ConnectedWallet;
const stellarWallet = {
family: 'stellar',
address: 'GABC',
chain: { network: 'public' }
} as unknown as ConnectedWallet;
describe('getWalletExplorerUrl', () => {
it('uses preferred Sui explorer', () => {
const url = getWalletExplorerUrl(suiWallet, {
explorer: 'suivision',
evmExplorer: 'family',
stellarExplorer: 'stellarexpert'
});
expect(url).toContain('suivision');
expect(url).toContain('0xabc');
});
it('uses chain-native EVM explorer by default', () => {
const url = getWalletExplorerUrl(evmWallet, {
explorer: 'suiscan',
evmExplorer: 'family',
stellarExplorer: 'stellarexpert'
});
expect(url).toBe('https://etherscan.io/address/0xdead');
});
it('honors EVM Blockscout preference when available', () => {
const url = getWalletExplorerUrl(evmWallet, {
explorer: 'suiscan',
evmExplorer: 'blockscout',
stellarExplorer: 'stellarexpert'
});
expect(url).toBe('https://eth.blockscout.com/address/0xdead');
});
it('falls back to family EVM explorer when Blockscout has no entry', () => {
const zora = {
family: 'evm',
address: '0xzz',
chain: { id: 'eip155:7777777' }
} as unknown as ConnectedWallet;
const url = getWalletExplorerUrl(zora, {
explorer: 'suiscan',
evmExplorer: 'blockscout',
stellarExplorer: 'stellarexpert'
});
expect(url).toBe('https://explorer.zora.energy/address/0xzz');
});
it('uses StellarExpert by default', () => {
const url = getWalletExplorerUrl(stellarWallet, {
explorer: 'suiscan',
evmExplorer: 'family',
stellarExplorer: 'stellarexpert'
});
expect(url).toBe(
'https://stellar.expert/explorer/public/account/GABC'
);
});
it('honors StellarChain preference', () => {
const url = getWalletExplorerUrl(stellarWallet, {
explorer: 'suiscan',
evmExplorer: 'family',
stellarExplorer: 'stellarchain'
});
expect(url).toBe('https://stellarchain.io/accounts/GABC');
});
it('accepts legacy Sui-only explorer string arg', () => {
const url = getWalletExplorerUrl(suiWallet, 'suiexplorer');
expect(url).toContain('suiexplorer');
});
});