Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
3 changes: 2 additions & 1 deletion src/utils/network/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export const networks = [
'local',
'mainnet',
'pol',
'matic',
'maticmum',
'amoy',
Expand All @@ -17,4 +18,4 @@ export type networkName = (typeof networks)[number];

export type networkType = 'production' | 'test' | 'development';

export type networkCurrency = 'ETH' | 'MATIC' | 'XDC' | 'FREE' | 'ASTRON';
export type networkCurrency = 'ETH' | 'MATIC' | 'POL' | 'XDC' | 'FREE' | 'ASTRON';
18 changes: 10 additions & 8 deletions src/utils/supportedChains/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import { networkCurrency, networkName, networkType } from './../network';
export enum CHAIN_ID {
local = '1337',
mainnet = '1',
matic = '137',
pol = '137',
// eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
matic = '137', // backward-compat alias for chain 137 (Polygon PoS)
amoy = '80002',
sepolia = '11155111',
xdc = '50',
Expand Down Expand Up @@ -58,19 +60,19 @@ export const SUPPORTED_CHAINS: supportedChains = {
explorerUrl: 'https://etherscan.io',
rpcUrl: `https://mainnet.infura.io/v3/${process.env.INFURA_API_KEY}`,
},
[CHAIN_ID.matic]: {
id: CHAIN_ID.matic,
label: 'Polygon',
name: 'matic',
[CHAIN_ID.pol]: {
id: CHAIN_ID.pol,
label: 'Polygon (POL)',
name: 'pol',
type: 'production',
currency: 'MATIC',
currency: 'POL',
iconImage: iconPolygon,
explorerUrl: 'https://polygonscan.com',
rpcUrl: `https://polygon-mainnet.infura.io/v3/${process.env.INFURA_API_KEY}`,
gasStation: gasStation('https://gasstation.polygon.technology/v2'),
nativeCurrency: {
name: 'MATIC',
symbol: 'MATIC',
name: 'POL',
symbol: 'POL',
decimals: 18,
},
},
Expand Down
23 changes: 19 additions & 4 deletions src/utils/supportedChains/supportedChains.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,31 @@ describe('supportedChains', () => {
expect(explorerUrl).toBe('https://etherscan.io');
});

it('should matic chain info correctly', () => {
it('should return pol chain info for CHAIN_ID.pol (Polygon PoS mainnet)', () => {
const { id, name, type, currency, explorerUrl } = SUPPORTED_CHAINS[CHAIN_ID.pol];

expect(id).toBe(CHAIN_ID.pol);
expect(name).toBe('pol');
expect(type).toBe('production');
expect(currency).toBe('POL');
expect(explorerUrl).toBe('https://polygonscan.com');
});

it('should return pol chain info when accessing via CHAIN_ID.matic (backward-compat alias for chain 137)', () => {
const { id, name, type, currency, explorerUrl } = SUPPORTED_CHAINS[CHAIN_ID.matic];

expect(id).toBe(CHAIN_ID.matic);
expect(name).toBe('matic');
expect(id).toBe(CHAIN_ID.pol);
expect(name).toBe('pol');
expect(type).toBe('production');
expect(currency).toBe('MATIC');
expect(currency).toBe('POL');
expect(explorerUrl).toBe('https://polygonscan.com');
});

it('CHAIN_ID.pol and CHAIN_ID.matic should be the same chain ID value', () => {
expect(CHAIN_ID.pol).toBe(CHAIN_ID.matic);
expect(SUPPORTED_CHAINS[CHAIN_ID.pol]).toBe(SUPPORTED_CHAINS[CHAIN_ID.matic]);
});

it('should get polygon amoy chain info correctly', () => {
const { id, name, type, currency, explorerUrl, rpcUrl } = SUPPORTED_CHAINS[CHAIN_ID.amoy];

Expand Down
Loading