Skip to content

Commit 6453f80

Browse files
committed
Fix lint issues
1 parent 7f2494b commit 6453f80

File tree

2 files changed

+129
-86
lines changed

2 files changed

+129
-86
lines changed

app/scripts/migrations/126.test.ts

+65-57
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { migrate, version } from './126';
21
import { SnapEndowments } from '@metamask/snaps-rpc-methods';
32
import { CaveatFactories, PermissionNames } from '../controllers/permissions';
4-
import { CaveatTypes } from '../../../shared/constants/permissions.ts';
5-
import { CHAIN_IDS, NETWORK_TYPES } from '../../../shared/constants/network.ts';
3+
import { CaveatTypes } from '../../../shared/constants/permissions';
4+
import { CHAIN_IDS, NETWORK_TYPES } from '../../../shared/constants/network';
5+
import { migrate, version } from './126';
66

77
const oldVersion = 125;
88
const newVersion = 126;
@@ -13,7 +13,10 @@ const MOCK_SNAP_ID = 'npm:foo-snap';
1313
jest.useFakeTimers();
1414
jest.setSystemTime(1723635247705);
1515

16-
function getMockState(selectedNetworkClientId: string = NETWORK_TYPES.MAINNET, networkConfigurations = {}) {
16+
function getMockState(
17+
selectedNetworkClientId: string = NETWORK_TYPES.MAINNET,
18+
networkConfigurations = {},
19+
) {
1720
return {
1821
meta: { version: oldVersion },
1922
data: {
@@ -35,12 +38,12 @@ function getMockState(selectedNetworkClientId: string = NETWORK_TYPES.MAINNET, n
3538
},
3639
},
3740
},
38-
}
41+
},
3942
},
4043

4144
SelectedNetworkController: {
42-
domains: {}
43-
}
45+
domains: {},
46+
},
4447
},
4548
};
4649
}
@@ -75,24 +78,24 @@ describe('migration #126', () => {
7578
},
7679
[PermissionNames.permittedChains]: {
7780
caveats: [
78-
CaveatFactories[CaveatTypes.restrictNetworkSwitching](
79-
[CHAIN_IDS.MAINNET],
80-
)
81+
CaveatFactories[CaveatTypes.restrictNetworkSwitching]([
82+
CHAIN_IDS.MAINNET,
83+
]),
8184
],
8285
date: 1723635247705,
8386
id: expect.any(String),
8487
invoker: MOCK_SNAP_ID,
8588
parentCapability: PermissionNames.permittedChains,
86-
}
89+
},
8790
},
8891
},
89-
}
92+
},
9093
});
9194

9295
expect(newStorage.data.SelectedNetworkController).toStrictEqual({
9396
domains: {
94-
[MOCK_SNAP_ID]: NETWORK_TYPES.MAINNET
95-
}
97+
[MOCK_SNAP_ID]: NETWORK_TYPES.MAINNET,
98+
},
9699
});
97100
});
98101

@@ -113,24 +116,24 @@ describe('migration #126', () => {
113116
},
114117
[PermissionNames.permittedChains]: {
115118
caveats: [
116-
CaveatFactories[CaveatTypes.restrictNetworkSwitching](
117-
[CHAIN_IDS.SEPOLIA],
118-
)
119+
CaveatFactories[CaveatTypes.restrictNetworkSwitching]([
120+
CHAIN_IDS.SEPOLIA,
121+
]),
119122
],
120123
date: 1723635247705,
121124
id: expect.any(String),
122125
invoker: MOCK_SNAP_ID,
123126
parentCapability: PermissionNames.permittedChains,
124-
}
127+
},
125128
},
126129
},
127-
}
130+
},
128131
});
129132

130133
expect(newStorage.data.SelectedNetworkController).toStrictEqual({
131134
domains: {
132-
[MOCK_SNAP_ID]: NETWORK_TYPES.SEPOLIA
133-
}
135+
[MOCK_SNAP_ID]: NETWORK_TYPES.SEPOLIA,
136+
},
134137
});
135138
});
136139

@@ -142,6 +145,8 @@ describe('migration #126', () => {
142145
});
143146

144147
const newStorage = await migrate(oldStorage);
148+
console.log(JSON.stringify(newStorage.data.PermissionController, null, 2));
149+
145150
expect(newStorage.data.PermissionController).toStrictEqual({
146151
subjects: {
147152
[MOCK_SNAP_ID]: {
@@ -155,24 +160,24 @@ describe('migration #126', () => {
155160
},
156161
[PermissionNames.permittedChains]: {
157162
caveats: [
158-
CaveatFactories[CaveatTypes.restrictNetworkSwitching](
159-
[CHAIN_IDS.LINEA_SEPOLIA],
160-
)
163+
CaveatFactories[CaveatTypes.restrictNetworkSwitching]([
164+
CHAIN_IDS.LINEA_SEPOLIA,
165+
]),
161166
],
162167
date: 1723635247705,
163168
id: expect.any(String),
164169
invoker: MOCK_SNAP_ID,
165170
parentCapability: PermissionNames.permittedChains,
166-
}
171+
},
167172
},
168173
},
169-
}
174+
},
170175
});
171176

172177
expect(newStorage.data.SelectedNetworkController).toStrictEqual({
173178
domains: {
174-
[MOCK_SNAP_ID]: NETWORK_TYPES.SEPOLIA
175-
}
179+
[MOCK_SNAP_ID]: NETWORK_TYPES.SEPOLIA,
180+
},
176181
});
177182
});
178183

@@ -194,21 +199,21 @@ describe('migration #126', () => {
194199
},
195200
[PermissionNames.permittedChains]: {
196201
caveats: [
197-
CaveatFactories[CaveatTypes.restrictNetworkSwitching](
198-
[CHAIN_IDS.SEPOLIA],
199-
)
202+
CaveatFactories[CaveatTypes.restrictNetworkSwitching]([
203+
CHAIN_IDS.SEPOLIA,
204+
]),
200205
],
201206
date: 1723635247705,
202207
id: expect.any(String),
203208
invoker: MOCK_SNAP_ID,
204209
parentCapability: PermissionNames.permittedChains,
205-
}
210+
},
206211
},
207212
},
208-
}
213+
},
209214
},
210215
selectedNetworkControllerState: {
211-
domains: {}
216+
domains: {},
212217
},
213218
},
214219
{
@@ -217,7 +222,7 @@ describe('migration #126', () => {
217222
},
218223
permissionControllerState: [],
219224
selectedNetworkControllerState: {
220-
domains: {}
225+
domains: {},
221226
},
222227
},
223228
{
@@ -237,18 +242,18 @@ describe('migration #126', () => {
237242
},
238243
[PermissionNames.permittedChains]: {
239244
caveats: [
240-
CaveatFactories[CaveatTypes.restrictNetworkSwitching](
241-
[CHAIN_IDS.SEPOLIA],
242-
)
245+
CaveatFactories[CaveatTypes.restrictNetworkSwitching]([
246+
CHAIN_IDS.SEPOLIA,
247+
]),
243248
],
244249
date: 1723635247705,
245250
id: expect.any(String),
246251
invoker: MOCK_SNAP_ID,
247252
parentCapability: PermissionNames.permittedChains,
248-
}
253+
},
249254
},
250255
},
251-
}
256+
},
252257
},
253258
selectedNetworkControllerState: [],
254259
},
@@ -269,33 +274,36 @@ describe('migration #126', () => {
269274
},
270275
[PermissionNames.permittedChains]: {
271276
caveats: [
272-
CaveatFactories[CaveatTypes.restrictNetworkSwitching](
273-
[CHAIN_IDS.SEPOLIA],
274-
)
277+
CaveatFactories[CaveatTypes.restrictNetworkSwitching]([
278+
CHAIN_IDS.SEPOLIA,
279+
]),
275280
],
276281
date: 1723635247705,
277282
id: expect.any(String),
278283
invoker: MOCK_SNAP_ID,
279284
parentCapability: PermissionNames.permittedChains,
280-
}
285+
},
281286
},
282287
},
283-
}
288+
},
284289
},
285290
selectedNetworkControllerState: {
286-
domains: {}
291+
domains: {},
287292
},
288293
},
289-
])('does not update the state if the state is invalid (#%#)', async (data: Record<string, unknown>) => {
290-
const oldStorage = {
291-
meta: { version: oldVersion },
292-
data,
293-
};
294+
])(
295+
'does not update the state if the state is invalid (#%#)',
296+
async (data: Record<string, unknown>) => {
297+
const oldStorage = {
298+
meta: { version: oldVersion },
299+
data,
300+
};
294301

295-
const newStorage = await migrate(oldStorage);
296-
expect(newStorage).toStrictEqual({
297-
meta: { version: newVersion },
298-
data
299-
});
300-
})
302+
const newStorage = await migrate(oldStorage);
303+
expect(newStorage).toStrictEqual({
304+
meta: { version: newVersion },
305+
data,
306+
});
307+
},
308+
);
301309
});

0 commit comments

Comments
 (0)