Skip to content

Commit b227748

Browse files
committed
chore: update package-lock.json and CLI options for Polygon network naming
- Bump version to 1.0.1 in package-lock.json. - Update CLI options to rename 'Matic' to 'Pol' for the Polygon Mainnet, while maintaining 'Matic' as a backward-compatible alias. - Adjust network currency type to include 'POL' and update related network handling logic.
1 parent f1dae3a commit b227748

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

src/utils/cli-options.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export const promptNetworkSelection = async (): Promise<string> => {
163163
{ name: 'Local', value: NetworkCmdName.Local },
164164
{ name: 'Ethereum Mainnet', value: NetworkCmdName.Mainnet },
165165
{ name: 'Sepolia Testnet', value: NetworkCmdName.Sepolia },
166-
{ name: 'Polygon Mainnet', value: NetworkCmdName.Matic },
166+
{ name: 'Polygon Mainnet (POL)', value: NetworkCmdName.Pol },
167167
{ name: 'Polygon Amoy Testnet', value: NetworkCmdName.Amoy },
168168
{ name: 'XDC Network', value: NetworkCmdName.XDC },
169169
{ name: 'XDC Apothem Testnet', value: NetworkCmdName.XDCApothem },
@@ -293,7 +293,7 @@ export const getNetworkFromChainId = (chainId: number): string => {
293293
const chainIdMap: Record<number, string> = {
294294
1: 'mainnet',
295295
11155111: 'sepolia',
296-
137: 'matic',
296+
137: 'pol', // Polygon PoS — canonical name is now 'pol' (POL token)
297297
80002: 'amoy',
298298
101010: 'stability',
299299
20180427: 'stabilitytestnet',
@@ -526,7 +526,8 @@ export const shouldRunDryRun = (network: string): boolean => {
526526
const dryRunNetworks = [
527527
NetworkCmdName.Mainnet, // Ethereum Mainnet
528528
NetworkCmdName.Sepolia, // Ethereum Sepolia Testnet
529-
NetworkCmdName.Matic, // Polygon Mainnet
529+
NetworkCmdName.Pol, // Polygon Mainnet (POL)
530+
NetworkCmdName.Matic, // Polygon Mainnet — backward-compat alias for pol
530531
NetworkCmdName.Amoy, // Polygon Amoy Testnet
531532
];
532533
return dryRunNetworks.includes(network as NetworkCmdName);

src/utils/networks.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { SUPPORTED_CHAINS, CHAIN_ID } from '@trustvc/trustvc';
55
// Re-export for use in other modules
66
export { SUPPORTED_CHAINS, CHAIN_ID };
77

8-
export type networkCurrency = 'ETH' | 'MATIC' | 'XDC' | 'FREE' | 'ASTRON';
8+
export type networkCurrency = 'ETH' | 'MATIC' | 'POL' | 'XDC' | 'FREE' | 'ASTRON';
99

1010
type SupportedNetwork = {
1111
explorer: string;
@@ -20,6 +20,7 @@ export enum NetworkCmdName {
2020
Local = 'local',
2121
Mainnet = 'mainnet',
2222
Sepolia = 'sepolia',
23+
Pol = 'pol',
2324
Matic = 'matic',
2425
Amoy = 'amoy',
2526
XDC = 'xdc',
@@ -64,7 +65,8 @@ const rpcUrls: { [key in NetworkCmdName]: string } = {
6465
[NetworkCmdName.Local]: 'http://127.0.0.1:8545',
6566
[NetworkCmdName.Mainnet]: 'homestead', // Special case for Infura
6667
[NetworkCmdName.Sepolia]: 'sepolia', // Special case for Infura
67-
[NetworkCmdName.Matic]: 'matic',
68+
[NetworkCmdName.Pol]: 'matic', // Infura network name for Polygon PoS
69+
[NetworkCmdName.Matic]: 'matic', // backward-compat alias — same provider as pol
6870
[NetworkCmdName.Amoy]: 'matic-amoy',
6971
[NetworkCmdName.XDC]: 'https://rpc.ankr.com/xdc',
7072
[NetworkCmdName.XDCApothem]: 'https://rpc.apothem.network',
@@ -78,10 +80,11 @@ const rpcUrls: { [key in NetworkCmdName]: string } = {
7880
const createProvider = (networkName: NetworkCmdName): (() => Provider) => {
7981
const rpcUrl = rpcUrls[networkName];
8082

81-
// Use Infura provider for mainnet and sepolia
83+
// Use Infura provider for mainnet, sepolia, and Polygon networks
8284
if (
8385
networkName === NetworkCmdName.Mainnet ||
8486
networkName === NetworkCmdName.Sepolia ||
87+
networkName === NetworkCmdName.Pol ||
8588
networkName === NetworkCmdName.Matic ||
8689
networkName === NetworkCmdName.Amoy
8790
) {
@@ -113,6 +116,11 @@ const buildSupportedNetwork = (): { [key in NetworkCmdName]: SupportedNetwork }
113116
}
114117
});
115118

119+
// Register 'matic' as a backward-compat alias for pol
120+
if (networks[NetworkCmdName.Pol] && !networks[NetworkCmdName.Matic]) {
121+
networks[NetworkCmdName.Matic] = networks[NetworkCmdName.Pol];
122+
}
123+
116124
return networks as { [key in NetworkCmdName]: SupportedNetwork };
117125
};
118126

0 commit comments

Comments
 (0)