Skip to content

Commit acdfdfd

Browse files
committed
Fix linting errors - we just upgraded linting rules in main
1 parent 64a0abe commit acdfdfd

File tree

5 files changed

+75
-70
lines changed

5 files changed

+75
-70
lines changed

packages/gator-permissions-snap/src/clients/blockchainClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import {
44
ChainDisconnectedError,
55
InvalidInputError,
66
ResourceUnavailableError,
7-
type SnapsEthereumProvider,
87
} from '@metamask/snaps-sdk';
8+
import type { SnapsEthereumProvider } from '@metamask/snaps-sdk';
99

1010
import type { RetryOptions } from './types';
1111
import {

packages/gator-permissions-snap/src/profileSync/profileSync.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable @typescript-eslint/naming-convention */
2-
31
import type { PermissionResponse } from '@metamask/7715-permissions-shared/types';
42
import {
53
zHexStr,
@@ -42,7 +40,7 @@ const zStoredGrantedPermission = z.object({
4240
revocationMetadata: z
4341
.object({
4442
txHash: zHexStr.optional(),
45-
recordedAt: zTimestamp
43+
recordedAt: zTimestamp,
4644
})
4745
.optional(),
4846
});
@@ -65,8 +63,8 @@ function safeDeserializeStoredGrantedPermission(
6563
if (parsed.isRevoked && validated.revocationMetadata === undefined) {
6664
validated.revocationMetadata = {
6765
recordedAt: 0,
68-
}
69-
};
66+
};
67+
}
7068

7169
return validated;
7270
} catch (error) {
@@ -413,17 +411,14 @@ export function createProfileSyncManager(
413411

414412
const updatedPermission: StoredGrantedPermission = {
415413
...existingPermission,
416-
revocationMetadata
414+
revocationMetadata,
417415
};
418416

419417
await storeGrantedPermission(updatedPermission);
420418

421419
logger.debug('Profile Sync: Successfully stored updated permission');
422420
} catch (error) {
423-
logger.error(
424-
'Error marking permission as revoked',
425-
error,
426-
);
421+
logger.error('Error marking permission as revoked', error);
427422
throw error;
428423
}
429424
}

packages/gator-permissions-snap/src/rpc/rpcHandler.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ export function createRpcHandler({
172172
filteredPermissions = filteredPermissions.filter(
173173
// if isRevoked is true, include only permissions that have a revocation metadata
174174
// if isRevoked is false, include only permissions that do not have a revocation metadata
175-
(permission) => (permission.revocationMetadata === undefined) !== isRevoked,
175+
(permission) =>
176+
(permission.revocationMetadata === undefined) !== isRevoked,
176177
);
177178
}
178179

@@ -207,8 +208,7 @@ export function createRpcHandler({
207208
const submitRevocation = async (params: Json): Promise<Json> => {
208209
logger.debug('submitRevocation() called with params:', params);
209210

210-
const { permissionContext, txHash } =
211-
validateRevocationParams(params);
211+
const { permissionContext, txHash } = validateRevocationParams(params);
212212

213213
// First, get the existing permission to validate it exists
214214
logger.debug(

packages/gator-permissions-snap/test/profileSync/profileSync.test.ts

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -142,58 +142,64 @@ describe('profileSync', () => {
142142
});
143143

144144
it('parses stored permission with isRevoked set (legacy storage - instead of revocationMetadata)', async () => {
145-
userStorageMock.getAllFeatureItems.mockResolvedValueOnce(
146-
[JSON.stringify({
145+
userStorageMock.getAllFeatureItems.mockResolvedValueOnce([
146+
JSON.stringify({
147147
...mockStoredGrantedPermission,
148148
isRevoked: true,
149149
}),
150150
]);
151151
mockPassAuth();
152152

153153
const permissions = await profileSyncManager.getAllGrantedPermissions();
154-
expect(permissions).toStrictEqual([{
155-
...mockStoredGrantedPermission,
156-
revocationMetadata: {
157-
recordedAt: 0,
154+
expect(permissions).toStrictEqual([
155+
{
156+
...mockStoredGrantedPermission,
157+
revocationMetadata: {
158+
recordedAt: 0,
159+
},
158160
},
159-
}]);
161+
]);
160162
});
161163

162164
it('parses stored permission with isRevoked set to false (legacy storage - instead of revocationMetadata)', async () => {
163-
userStorageMock.getAllFeatureItems.mockResolvedValueOnce(
164-
[JSON.stringify({
165+
userStorageMock.getAllFeatureItems.mockResolvedValueOnce([
166+
JSON.stringify({
165167
...mockStoredGrantedPermission,
166168
isRevoked: false,
167169
}),
168170
]);
169171
mockPassAuth();
170172

171173
const permissions = await profileSyncManager.getAllGrantedPermissions();
172-
expect(permissions).toStrictEqual([{
173-
mockStoredGrantedPermission,
174-
}]);
174+
expect(permissions).toStrictEqual([
175+
{
176+
mockStoredGrantedPermission,
177+
},
178+
]);
175179
});
176180

177181
it('parses stored permission with isRevoked set, without overwriting revocationMetadata', async () => {
178-
userStorageMock.getAllFeatureItems.mockResolvedValueOnce(
179-
[JSON.stringify({
182+
userStorageMock.getAllFeatureItems.mockResolvedValueOnce([
183+
JSON.stringify({
180184
...mockStoredGrantedPermission,
181185
isRevoked: true,
182186
revocationMetadata: {
183187
recordedAt: 123456,
184-
}
188+
},
185189
}),
186190
]);
187191

188192
mockPassAuth();
189193

190194
const permissions = await profileSyncManager.getAllGrantedPermissions();
191-
expect(permissions).toStrictEqual([{
192-
...mockStoredGrantedPermission,
193-
revocationMetadata: {
194-
recordedAt: 123456,
195+
expect(permissions).toStrictEqual([
196+
{
197+
...mockStoredGrantedPermission,
198+
revocationMetadata: {
199+
recordedAt: 123456,
200+
},
195201
},
196-
}]);
202+
]);
197203
});
198204

199205
it('should return empty array when storage throws error', async () => {
@@ -415,11 +421,10 @@ describe('profileSync', () => {
415421

416422
describe('setPermissionRevoked()', () => {
417423
const mockTxHash =
418-
'0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890';
424+
'0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890';
419425
const mockRecordedAt = 123456;
420426

421427
it('sets permission as revoked successfully', async () => {
422-
423428
userStorageMock.getItem.mockResolvedValueOnce(
424429
JSON.stringify(mockStoredGrantedPermission),
425430
);
@@ -429,20 +434,19 @@ describe('profileSync', () => {
429434
mockStoredGrantedPermission.permissionResponse.context,
430435
{
431436
txHash: mockTxHash,
432-
recordedAt: mockRecordedAt
437+
recordedAt: mockRecordedAt,
433438
},
434439
);
435440

436441
expect(userStorageMock.getItem).toHaveBeenCalledWith(
437442
`gator_7715_permissions.${mockDelegationHash}`,
438443
);
439444

440-
441445
const expectedRevocationMetadata = `"revocationMetadata":{"txHash":"${mockTxHash}","recordedAt":${mockRecordedAt}}`;
442446

443447
expect(userStorageMock.setItem).toHaveBeenCalledWith(
444448
`gator_7715_permissions.${mockDelegationHash}`,
445-
expect.stringContaining(expectedRevocationMetadata)
449+
expect.stringContaining(expectedRevocationMetadata),
446450
);
447451

448452
const storedData = userStorageMock.setItem.mock.calls[0]?.[1];
@@ -467,13 +471,10 @@ describe('profileSync', () => {
467471
mockPassAuth();
468472

469473
await expect(
470-
profileSyncManager.markPermissionRevoked(
471-
nonExistentDelegationHash,
472-
{
473-
txHash: '0xMocked-tx-hash',
474-
recordedAt: 123456
475-
},
476-
),
474+
profileSyncManager.markPermissionRevoked(nonExistentDelegationHash, {
475+
txHash: '0xMocked-tx-hash',
476+
recordedAt: 123456,
477+
}),
477478
).rejects.toThrow(
478479
`Permission not found for permission context: ${nonExistentDelegationHash}`,
479480
);
@@ -491,7 +492,10 @@ describe('profileSync', () => {
491492
userStorageMock.getItem.mockResolvedValueOnce(
492493
JSON.stringify({
493494
...mockStoredGrantedPermission,
494-
revocationMetadata: { txHash: mockTxHash, recordedAt: mockRecordedAt },
495+
revocationMetadata: {
496+
txHash: mockTxHash,
497+
recordedAt: mockRecordedAt,
498+
},
495499
}),
496500
);
497501
mockPassAuth();
@@ -514,7 +518,7 @@ describe('profileSync', () => {
514518
mockStoredGrantedPermission.permissionResponse.context,
515519
{
516520
txHash: '0xMocked-tx-hash',
517-
recordedAt: 123456
521+
recordedAt: 123456,
518522
},
519523
),
520524
).rejects.toThrow('Auth failed');

packages/gator-permissions-snap/test/rpc/rpcHandler.test.ts

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@ import type {
33
PermissionRequest,
44
PermissionResponse,
55
} from '@metamask/7715-permissions-shared/types';
6-
import {
7-
decodeDelegations,
8-
hashDelegation,
9-
type Hex,
10-
} from '@metamask/delegation-core';
6+
import { decodeDelegations, hashDelegation } from '@metamask/delegation-core';
7+
import type { Hex } from '@metamask/delegation-core';
118
import {
129
ChainDisconnectedError,
1310
InvalidInputError,
@@ -18,7 +15,10 @@ import type { Json } from '@metamask/snaps-sdk';
1815
import type { BlockchainClient } from '../../src/clients/blockchainClient';
1916
import type { PermissionHandlerFactory } from '../../src/core/permissionHandlerFactory';
2017
import type { PermissionHandlerType } from '../../src/core/types';
21-
import type { ProfileSyncManager,StoredGrantedPermission } from '../../src/profileSync';
18+
import type {
19+
ProfileSyncManager,
20+
StoredGrantedPermission,
21+
} from '../../src/profileSync';
2222
import { createRpcHandler } from '../../src/rpc/rpcHandler';
2323
import type { RpcHandler } from '../../src/rpc/rpcHandler';
2424

@@ -618,7 +618,6 @@ describe('RpcHandler', () => {
618618
delegationManager: TEST_ADDRESS,
619619
},
620620
siteOrigin: TEST_SITE_ORIGIN,
621-
622621
},
623622
{
624623
permissionResponse: {
@@ -733,7 +732,7 @@ describe('RpcHandler', () => {
733732
siteOrigin: 'https://another-example.com',
734733
revocationMetadata: {
735734
txHash: TEST_VALID_TX_HASH,
736-
recordedAt: 123456
735+
recordedAt: 123456,
737736
},
738737
},
739738
{
@@ -775,7 +774,9 @@ describe('RpcHandler', () => {
775774
mockProfileSyncManager.getAllGrantedPermissions,
776775
).toHaveBeenCalledTimes(1);
777776
expect(result).toHaveLength(1);
778-
expect((result as [StoredGrantedPermission])[0].revocationMetadata).toBeDefined();
777+
expect(
778+
(result as [StoredGrantedPermission])[0].revocationMetadata,
779+
).toBeDefined();
779780
});
780781

781782
it('should filter by isRevoked=false', async () => {
@@ -852,9 +853,9 @@ describe('RpcHandler', () => {
852853
expect(
853854
mockProfileSyncManager.getAllGrantedPermissions,
854855
).toHaveBeenCalledTimes(1);
855-
856+
856857
expect(result).toHaveLength(1);
857-
858+
858859
const permission = (result as [StoredGrantedPermission])[0];
859860
expect(permission.revocationMetadata).toBeUndefined();
860861
expect(permission.siteOrigin).toBe(TEST_SITE_ORIGIN);
@@ -1031,9 +1032,10 @@ describe('RpcHandler', () => {
10311032
expect(
10321033
mockBlockchainClient.checkDelegationDisabledOnChain,
10331034
).toHaveBeenCalled();
1034-
expect(
1035-
mockProfileSyncManager.markPermissionRevoked,
1036-
).toHaveBeenCalledWith(TEST_CONTEXT, { txHash: TEST_VALID_TX_HASH, recordedAt: expect.any(Number) });
1035+
expect(mockProfileSyncManager.markPermissionRevoked).toHaveBeenCalledWith(
1036+
TEST_CONTEXT,
1037+
{ txHash: TEST_VALID_TX_HASH, recordedAt: expect.any(Number) },
1038+
);
10371039
});
10381040

10391041
it('throws an error when transaction hash was unsuccessful', async () => {
@@ -1087,11 +1089,14 @@ describe('RpcHandler', () => {
10871089
);
10881090
});
10891091

1090-
it.each([null, undefined, 'invalid'])('throws InvalidInputError when params is %s', async (params) => {
1091-
await expect(handler.submitRevocation(params as any)).rejects.toThrow(
1092-
'Parameters are required',
1093-
);
1094-
});
1092+
it.each([null, undefined, 'invalid'])(
1093+
'throws InvalidInputError when params is %s',
1094+
async (params) => {
1095+
await expect(handler.submitRevocation(params as any)).rejects.toThrow(
1096+
'Parameters are required',
1097+
);
1098+
},
1099+
);
10951100

10961101
it('throws InvalidInputError when permissionContext is missing', async () => {
10971102
const invalidParams = {};
@@ -1142,9 +1147,10 @@ describe('RpcHandler', () => {
11421147
handler.submitRevocation(validRevocationParams),
11431148
).rejects.toThrow('Update failed');
11441149

1145-
expect(
1146-
mockProfileSyncManager.markPermissionRevoked,
1147-
).toHaveBeenCalledWith(TEST_CONTEXT, { txHash: TEST_VALID_TX_HASH, recordedAt: expect.any(Number) });
1150+
expect(mockProfileSyncManager.markPermissionRevoked).toHaveBeenCalledWith(
1151+
TEST_CONTEXT,
1152+
{ txHash: TEST_VALID_TX_HASH, recordedAt: expect.any(Number) },
1153+
);
11481154
});
11491155

11501156
it('handles hex values with uppercase letters', async () => {

0 commit comments

Comments
 (0)