@injectivelabs/wallet-evm 1.16.32 → 1.16.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,18 +3,7 @@ import type { EvmChainId } from '@injectivelabs/ts-types';
3
3
  import type { BrowserEip1993Provider } from '@injectivelabs/wallet-base';
4
4
  export declare const getEvmProvider: (wallet: Wallet) => Promise<BrowserEip1993Provider>;
5
5
  export declare const updateEvmNetwork: (wallet: Wallet, chainId: EvmChainId) => Promise<unknown>;
6
- export declare const addEvmNetworkToWallet: ({ wallet, chainId, params, }: {
6
+ export declare const addEvmNetworkToWallet: ({ wallet, chainId, }: {
7
7
  wallet: Wallet;
8
8
  chainId: EvmChainId;
9
- params: {
10
- rpcUrls: string[];
11
- chainName: string;
12
- blockExplorerUrls: string[];
13
- chainId: string;
14
- nativeCurrency: {
15
- name: string;
16
- symbol: string;
17
- decimals: number;
18
- };
19
- };
20
9
  }) => Promise<void>;
@@ -71,7 +71,7 @@ const updateEvmNetwork = async (wallet, chainId) => {
71
71
  }
72
72
  };
73
73
  exports.updateEvmNetwork = updateEvmNetwork;
74
- const addEvmNetworkToWallet = async ({ wallet, chainId, params, }) => {
74
+ const addEvmNetworkToWallet = async ({ wallet, chainId, }) => {
75
75
  if (!(0, wallet_base_1.isEvmBrowserWallet)(wallet)) {
76
76
  throw new exceptions_1.WalletException(new Error(`Evm Wallet for ${(0, utils_1.capitalize)(wallet)} is not supported.`));
77
77
  }
@@ -80,6 +80,16 @@ const addEvmNetworkToWallet = async ({ wallet, chainId, params, }) => {
80
80
  throw new exceptions_1.WalletException(new Error(`Please install ${(0, utils_1.capitalize)(wallet)} Extension`));
81
81
  }
82
82
  const chainIdToHex = chainId.toString(16);
83
+ const chain = (0, wallet_base_1.getEvmChainConfig)(chainId);
84
+ const params = {
85
+ chainId: `0x${chain.id.toString(16)}`,
86
+ chainName: chain.name,
87
+ rpcUrls: [...(chain.rpcUrls?.default?.http || [])],
88
+ blockExplorerUrls: chain.blockExplorers?.default?.url
89
+ ? [chain.blockExplorers.default.url]
90
+ : [],
91
+ nativeCurrency: chain.nativeCurrency,
92
+ };
83
93
  try {
84
94
  await Promise.race([
85
95
  provider.request({
@@ -99,6 +109,7 @@ const addEvmNetworkToWallet = async ({ wallet, chainId, params, }) => {
99
109
  method: 'wallet_addEthereumChain',
100
110
  params: [params],
101
111
  });
112
+ return;
102
113
  }
103
114
  throw new exceptions_1.WalletException(new Error(`Something went wrong while adding ${(0, utils_1.capitalize)(wallet)} network`));
104
115
  }
@@ -3,18 +3,7 @@ import type { EvmChainId } from '@injectivelabs/ts-types';
3
3
  import type { BrowserEip1993Provider } from '@injectivelabs/wallet-base';
4
4
  export declare const getEvmProvider: (wallet: Wallet) => Promise<BrowserEip1993Provider>;
5
5
  export declare const updateEvmNetwork: (wallet: Wallet, chainId: EvmChainId) => Promise<unknown>;
6
- export declare const addEvmNetworkToWallet: ({ wallet, chainId, params, }: {
6
+ export declare const addEvmNetworkToWallet: ({ wallet, chainId, }: {
7
7
  wallet: Wallet;
8
8
  chainId: EvmChainId;
9
- params: {
10
- rpcUrls: string[];
11
- chainName: string;
12
- blockExplorerUrls: string[];
13
- chainId: string;
14
- nativeCurrency: {
15
- name: string;
16
- symbol: string;
17
- decimals: number;
18
- };
19
- };
20
9
  }) => Promise<void>;
@@ -1,6 +1,6 @@
1
1
  import { capitalize } from '@injectivelabs/utils';
2
2
  import { WalletException } from '@injectivelabs/exceptions';
3
- import { Wallet, isEvmBrowserWallet } from '@injectivelabs/wallet-base';
3
+ import { Wallet, getEvmChainConfig, isEvmBrowserWallet, } from '@injectivelabs/wallet-base';
4
4
  import { getRabbyProvider } from '../strategy/utils/rabby.js';
5
5
  import { getOkxWalletProvider } from '../strategy/utils/Okx.js';
6
6
  import { getBitGetProvider } from '../strategy/utils/bitget.js';
@@ -66,7 +66,7 @@ export const updateEvmNetwork = async (wallet, chainId) => {
66
66
  throw new WalletException(new Error(`Please update your ${capitalize(wallet)} network`));
67
67
  }
68
68
  };
69
- export const addEvmNetworkToWallet = async ({ wallet, chainId, params, }) => {
69
+ export const addEvmNetworkToWallet = async ({ wallet, chainId, }) => {
70
70
  if (!isEvmBrowserWallet(wallet)) {
71
71
  throw new WalletException(new Error(`Evm Wallet for ${capitalize(wallet)} is not supported.`));
72
72
  }
@@ -75,6 +75,16 @@ export const addEvmNetworkToWallet = async ({ wallet, chainId, params, }) => {
75
75
  throw new WalletException(new Error(`Please install ${capitalize(wallet)} Extension`));
76
76
  }
77
77
  const chainIdToHex = chainId.toString(16);
78
+ const chain = getEvmChainConfig(chainId);
79
+ const params = {
80
+ chainId: `0x${chain.id.toString(16)}`,
81
+ chainName: chain.name,
82
+ rpcUrls: [...(chain.rpcUrls?.default?.http || [])],
83
+ blockExplorerUrls: chain.blockExplorers?.default?.url
84
+ ? [chain.blockExplorers.default.url]
85
+ : [],
86
+ nativeCurrency: chain.nativeCurrency,
87
+ };
78
88
  try {
79
89
  await Promise.race([
80
90
  provider.request({
@@ -94,6 +104,7 @@ export const addEvmNetworkToWallet = async ({ wallet, chainId, params, }) => {
94
104
  method: 'wallet_addEthereumChain',
95
105
  params: [params],
96
106
  });
107
+ return;
97
108
  }
98
109
  throw new WalletException(new Error(`Something went wrong while adding ${capitalize(wallet)} network`));
99
110
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@injectivelabs/wallet-evm",
3
3
  "description": "EVM wallet strategies for use with @injectivelabs/wallet-core.",
4
- "version": "1.16.32",
4
+ "version": "1.16.33",
5
5
  "sideEffects": false,
6
6
  "type": "module",
7
7
  "author": {
@@ -56,17 +56,17 @@
56
56
  "start": "node dist/index.js"
57
57
  },
58
58
  "dependencies": {
59
- "@injectivelabs/exceptions": "1.16.32",
60
- "@injectivelabs/networks": "1.16.32",
61
- "@injectivelabs/sdk-ts": "1.16.32",
62
- "@injectivelabs/ts-types": "1.16.32",
63
- "@injectivelabs/utils": "1.16.32",
64
- "@injectivelabs/wallet-base": "1.16.32"
59
+ "@injectivelabs/exceptions": "1.16.33",
60
+ "@injectivelabs/networks": "1.16.33",
61
+ "@injectivelabs/sdk-ts": "1.16.33",
62
+ "@injectivelabs/ts-types": "1.16.33",
63
+ "@injectivelabs/utils": "1.16.33",
64
+ "@injectivelabs/wallet-base": "1.16.33"
65
65
  },
66
66
  "devDependencies": {
67
67
  "shx": "^0.3.3"
68
68
  },
69
- "gitHead": "e4461cec60f6f1255f5cb63194ce855520cbeb2e",
69
+ "gitHead": "7e822b65b56c486c03bede8c0eb024fd34a7657b",
70
70
  "typedoc": {
71
71
  "entryPoint": "./src/index.ts",
72
72
  "readmeFile": "./README.md",