Skip to content

Commit f4c1fe2

Browse files
refactor: rename NetworkWithRpcUrls as NetworkConfig
1 parent 3ed42ec commit f4c1fe2

4 files changed

Lines changed: 15 additions & 14 deletions

File tree

packages/snap/snap.manifest.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"url": "https://github.com/MetaMask/snap-solana-wallet.git"
88
},
99
"source": {
10-
"shasum": "g/jfpUCvmwu6piUwA21tuyxrmaZZnZl3JdLeVJysYFM=",
10+
"shasum": "cXuI2V4c1TpiEXZ3o44HV+qoSEGR4pz1DvHCxTtz9xo=",
1111
"location": {
1212
"npm": {
1313
"filePath": "dist/bundle.js",
@@ -19,15 +19,19 @@
1919
"locales": ["locales/en.json"]
2020
},
2121
"initialConnections": {
22-
"https://portfolio.metamask.io": {}
22+
"https://portfolio.metamask.io": {},
23+
"http://localhost:3000": {}
2324
},
2425
"initialPermissions": {
2526
"endowment:rpc": {
2627
"dapps": true,
2728
"snaps": false
2829
},
2930
"endowment:keyring": {
30-
"allowedOrigins": ["https://portfolio.metamask.io"]
31+
"allowedOrigins": [
32+
"https://portfolio.metamask.io",
33+
"http://localhost:3000"
34+
]
3135
},
3236
"snap_getBip32Entropy": [
3337
{

packages/snap/src/core/services/config/ConfigProvider.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ const EnvStruct = object({
5050

5151
export type Env = Infer<typeof EnvStruct>;
5252

53-
export type NetworkWithRpcUrls = (typeof Networks)[Network] & {
53+
export type NetworkConfig = (typeof Networks)[Network] & {
5454
rpcUrls: string[];
5555
webSocketUrl: string;
5656
};
5757

5858
export type Config = {
5959
environment: string;
60-
networks: NetworkWithRpcUrls[];
60+
networks: NetworkConfig[];
6161
activeNetworks: Network[];
6262
explorerBaseUrl: string;
6363
priceApi: {
@@ -188,10 +188,7 @@ export class ConfigProvider {
188188
return this.#config;
189189
}
190190

191-
public getNetworkBy(
192-
key: keyof NetworkWithRpcUrls,
193-
value: string,
194-
): NetworkWithRpcUrls {
191+
public getNetworkBy(key: keyof NetworkConfig, value: string): NetworkConfig {
195192
const network = this.get().networks.find((item) => item[key] === value);
196193
if (!network) {
197194
throw new Error(`Network ${key} not found`);

packages/snap/src/core/services/subscriptions/WebSocketConnectionService.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { WebSocketConnection } from '../../../entities';
22
import { EventEmitter } from '../../../infrastructure';
33
import { Network } from '../../constants/solana';
44
import type { ConfigProvider } from '../config';
5-
import type { Config, NetworkWithRpcUrls } from '../config/ConfigProvider';
5+
import type { Config, NetworkConfig } from '../config/ConfigProvider';
66
import { mockLogger } from '../mocks/logger';
77
import type { WebSocketConnectionRepository } from './WebSocketConnectionRepository';
88
import { WebSocketConnectionService } from './WebSocketConnectionService';
@@ -42,7 +42,7 @@ describe('WebSocketConnectionService', () => {
4242
caip2Id: Network.Localnet,
4343
webSocketUrl: 'wss://some-mock-url4.com/ws/v3/some-id',
4444
},
45-
] as NetworkWithRpcUrls[];
45+
] as NetworkConfig[];
4646

4747
beforeEach(() => {
4848
jest.clearAllMocks();
@@ -67,7 +67,7 @@ describe('WebSocketConnectionService', () => {
6767
}),
6868
getNetworkBy: jest.fn().mockImplementation((key, value) => {
6969
return mockNetworksConfig.find(
70-
(item) => item[key as keyof NetworkWithRpcUrls] === value,
70+
(item) => item[key as keyof NetworkConfig] === value,
7171
);
7272
}),
7373
} as unknown as ConfigProvider;

packages/snap/src/core/services/subscriptions/WebSocketConnectionService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { EventEmitter } from '../../../infrastructure';
55
import { Network } from '../../constants/solana';
66
import type { ILogger } from '../../utils/logger';
77
import type { ConfigProvider } from '../config';
8-
import type { NetworkWithRpcUrls } from '../config/ConfigProvider';
8+
import type { NetworkConfig } from '../config/ConfigProvider';
99
import type { WebSocketConnectionRepository } from './WebSocketConnectionRepository';
1010

1111
/**
@@ -331,7 +331,7 @@ export class WebSocketConnectionService {
331331
* @param webSocketUrl - The WebSocket URL to get the network for.
332332
* @returns The network, or null if no network is associated with the connection ID.
333333
*/
334-
#findNetworkByWebSocketUrl(webSocketUrl: string): NetworkWithRpcUrls | null {
334+
#findNetworkByWebSocketUrl(webSocketUrl: string): NetworkConfig | null {
335335
return this.#configProvider.getNetworkBy('webSocketUrl', webSocketUrl);
336336
}
337337
}

0 commit comments

Comments
 (0)