Skip to content

Commit 14fae53

Browse files
authored
fix(assets): Solana testnet and devent browser URL is incorrect (#1262)
* fix(solana): testnet and devent browser address is incorrect * changeset * test case
1 parent 892a44e commit 14fae53

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

.changeset/happy-camels-speak.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@ant-design/web3-assets': patch
3+
---
4+
5+
fix(assets): Solana testnet and devent browser URL is incorrect
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { describe, expect, it } from 'vitest';
2+
3+
import { Solana, SolanaDevnet, SolanaTestnet } from '../chains';
4+
5+
describe('Solana browser link', () => {
6+
it('url is correct', () => {
7+
const pk = '4wztJ4CAH4GbAUopZrVk7nLvoAC3KAF6ttMMWfnBRG1t';
8+
const tx =
9+
'48yFNeh7dfX2rVb3KzYWgNR8r9RKttAGbwpw4ZLypHnQ3qaT8dGDA8KvTEorYx6GBBiCGsVYkhyECiyn7XqYwQyu';
10+
11+
// devnet
12+
let getLink = SolanaDevnet.browser!.getBrowserLink!;
13+
14+
expect(getLink(pk, 'address')).toBe(`https://explorer.solana.com/address/${pk}?cluster=devnet`);
15+
expect(getLink(tx, 'transaction')).toBe(`https://explorer.solana.com/tx/${tx}?cluster=devnet`);
16+
17+
// testnet
18+
getLink = SolanaTestnet.browser!.getBrowserLink!;
19+
20+
expect(getLink(pk, 'address')).toBe(
21+
`https://explorer.solana.com/address/${pk}?cluster=testnet`,
22+
);
23+
expect(getLink(tx, 'transaction')).toBe(`https://explorer.solana.com/tx/${tx}?cluster=testnet`);
24+
25+
// mainnet
26+
getLink = Solana.browser!.getBrowserLink!;
27+
28+
expect(getLink(pk, 'address')).toBe(`https://explorer.solana.com/address/${pk}`);
29+
expect(getLink(tx, 'transaction')).toBe(`https://explorer.solana.com/tx/${tx}`);
30+
});
31+
});

packages/assets/src/solana/chains.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ export const SolanaDevnet: SolanaChain = {
2222
icon: <SolanaColorful />,
2323
browser: {
2424
icon: <SolanaColorful />,
25-
getBrowserLink: createGetBrowserLink('https://explorer.solana.com/?cluster=devnet'),
25+
getBrowserLink: (address, type) =>
26+
createGetBrowserLink('https://explorer.solana.com')(address, type) + '?cluster=devnet',
2627
},
2728
nativeCurrency: { name: 'Solana', symbol: 'SOL', decimals: 9 },
2829
};
@@ -33,7 +34,8 @@ export const SolanaTestnet: SolanaChain = {
3334
icon: <SolanaColorful />,
3435
browser: {
3536
icon: <SolanaColorful />,
36-
getBrowserLink: createGetBrowserLink('https://explorer.solana.com/?cluster=testnet'),
37+
getBrowserLink: (address, type) =>
38+
createGetBrowserLink('https://explorer.solana.com')(address, type) + '?cluster=testnet',
3739
},
3840
nativeCurrency: { name: 'Solana', symbol: 'SOL', decimals: 9 },
3941
};

0 commit comments

Comments
 (0)