Skip to content

Commit 2000b7c

Browse files
committed
Fix linting errors, and remove lint suppressions
1 parent a60ce58 commit 2000b7c

6 files changed

Lines changed: 42 additions & 56 deletions

File tree

eslint-suppressions.json

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,32 +1091,6 @@
10911091
"count": 1
10921092
}
10931093
},
1094-
"packages/gator-permissions-controller/src/GatorPermissionsController.test.ts": {
1095-
"id-denylist": {
1096-
"count": 2
1097-
}
1098-
},
1099-
"packages/gator-permissions-controller/src/GatorPermissionsController.ts": {
1100-
"@typescript-eslint/explicit-function-return-type": {
1101-
"count": 8
1102-
}
1103-
},
1104-
"packages/gator-permissions-controller/src/decodePermission/utils.test.ts": {
1105-
"id-length": {
1106-
"count": 1
1107-
}
1108-
},
1109-
"packages/gator-permissions-controller/src/decodePermission/utils.ts": {
1110-
"@typescript-eslint/explicit-function-return-type": {
1111-
"count": 2
1112-
},
1113-
"@typescript-eslint/naming-convention": {
1114-
"count": 1
1115-
},
1116-
"id-length": {
1117-
"count": 1
1118-
}
1119-
},
11201094
"packages/logging-controller/src/LoggingController.test.ts": {
11211095
"@typescript-eslint/explicit-function-return-type": {
11221096
"count": 1
@@ -2060,4 +2034,4 @@
20602034
"count": 1
20612035
}
20622036
}
2063-
}
2037+
}

packages/gator-permissions-controller/src/GatorPermissionsController.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ describe('GatorPermissionsController', () => {
197197
isAdjustmentAllowed: false,
198198
data: {
199199
target: '0x1234567890123456789012345678901234567890',
200-
sig: '0xabcd',
200+
signature: '0xabcd',
201201
expiry: 1735689600, // Example expiry timestamp
202202
},
203203
},
@@ -275,7 +275,7 @@ describe('GatorPermissionsController', () => {
275275
isAdjustmentAllowed: false,
276276
data: {
277277
target: '0x1234567890123456789012345678901234567890',
278-
sig: '0xabcd',
278+
signature: '0xabcd',
279279
expiry: 1735689600,
280280
},
281281
},

packages/gator-permissions-controller/src/GatorPermissionsController.ts

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ import type { Messenger } from '@metamask/messenger';
99
import type { HandleSnapRequest, HasSnap } from '@metamask/snaps-controllers';
1010
import type { SnapId } from '@metamask/snaps-sdk';
1111
import { HandlerType } from '@metamask/snaps-utils';
12-
import {
13-
TransactionStatus,
14-
type TransactionControllerTransactionApprovedEvent,
15-
type TransactionControllerTransactionConfirmedEvent,
16-
type TransactionControllerTransactionDroppedEvent,
17-
type TransactionControllerTransactionFailedEvent,
18-
type TransactionControllerTransactionRejectedEvent,
12+
import { TransactionStatus } from '@metamask/transaction-controller';
13+
import type {
14+
TransactionControllerTransactionApprovedEvent,
15+
TransactionControllerTransactionConfirmedEvent,
16+
TransactionControllerTransactionDroppedEvent,
17+
TransactionControllerTransactionFailedEvent,
18+
TransactionControllerTransactionRejectedEvent,
1919
} from '@metamask/transaction-controller';
2020
import type { Hex, Json } from '@metamask/utils';
2121

@@ -35,9 +35,7 @@ import {
3535
} from './errors';
3636
import { controllerLog } from './logger';
3737
import { GatorPermissionsSnapRpcMethod } from './types';
38-
import type {
39-
StoredGatorPermissionSanitized,
40-
} from './types';
38+
import type { StoredGatorPermissionSanitized } from './types';
4139
import type {
4240
GatorPermissionsMap,
4341
PermissionTypesWithCustom,
@@ -849,7 +847,7 @@ export default class GatorPermissionsController extends BaseController<
849847
};
850848

851849
// Helper to refresh permissions after transaction state change
852-
const refreshPermissions = (context: string) => {
850+
const refreshPermissions = (context: string): void => {
853851
this.fetchAndUpdateGatorPermissions({ isRevoked: false }).catch(
854852
(error) => {
855853
controllerLog(`Failed to refresh permissions after ${context}`, {
@@ -862,7 +860,7 @@ export default class GatorPermissionsController extends BaseController<
862860
};
863861

864862
// Helper to unsubscribe from approval/rejection events after decision is made
865-
const cleanupApprovalHandlers = () => {
863+
const cleanupApprovalHandlers = (): void => {
866864
if (handlers.approved) {
867865
this.messenger.unsubscribe(
868866
'TransactionController:transactionApproved',
@@ -880,7 +878,7 @@ export default class GatorPermissionsController extends BaseController<
880878
};
881879

882880
// Cleanup function to unsubscribe from all events and clear timeout
883-
const cleanup = (txIdToRemove: string, removeFromState = true) => {
881+
const cleanup = (txIdToRemove: string, removeFromState = true): void => {
884882
cleanupApprovalHandlers();
885883
if (handlers.confirmed) {
886884
this.messenger.unsubscribe(
@@ -911,7 +909,7 @@ export default class GatorPermissionsController extends BaseController<
911909
};
912910

913911
// Handle approved transaction - add to pending revocations state
914-
handlers.approved = (payload) => {
912+
handlers.approved = (payload): void => {
915913
if (payload.transactionMeta.id === txId) {
916914
controllerLog(
917915
'Transaction approved by user, adding to pending revocations',
@@ -929,7 +927,7 @@ export default class GatorPermissionsController extends BaseController<
929927
};
930928

931929
// Handle rejected transaction - cleanup without adding to state
932-
handlers.rejected = (payload) => {
930+
handlers.rejected = (payload): void => {
933931
if (payload.transactionMeta.id === txId) {
934932
controllerLog('Transaction rejected by user, cleaning up listeners', {
935933
txId,
@@ -942,15 +940,14 @@ export default class GatorPermissionsController extends BaseController<
942940
};
943941

944942
// Handle confirmed transaction - submit revocation
945-
handlers.confirmed = (transactionMeta) => {
943+
handlers.confirmed = (transactionMeta): void => {
946944
if (transactionMeta.id === txId) {
947945
controllerLog('Transaction confirmed, submitting revocation', {
948946
txId,
949947
permissionContext,
950948
txHash: transactionMeta.hash,
951949
});
952950

953-
954951
if (transactionMeta.status !== TransactionStatus.confirmed) {
955952
controllerLog('Transaction not confirmed, skipping revocation', {
956953
txId,
@@ -960,7 +957,7 @@ export default class GatorPermissionsController extends BaseController<
960957
cleanup(transactionMeta.id);
961958
refreshPermissions('transaction not confirmed');
962959
return;
963-
}
960+
}
964961

965962
const txHash = transactionMeta.hash as Hex | undefined;
966963

@@ -995,7 +992,7 @@ export default class GatorPermissionsController extends BaseController<
995992
};
996993

997994
// Handle failed transaction - cleanup without submitting revocation
998-
handlers.failed = (payload) => {
995+
handlers.failed = (payload): void => {
999996
if (payload.transactionMeta.id === txId) {
1000997
controllerLog('Transaction failed, cleaning up revocation listener', {
1001998
txId,
@@ -1010,7 +1007,7 @@ export default class GatorPermissionsController extends BaseController<
10101007
};
10111008

10121009
// Handle dropped transaction - cleanup without submitting revocation
1013-
handlers.dropped = (payload) => {
1010+
handlers.dropped = (payload): void => {
10141011
if (payload.transactionMeta.id === txId) {
10151012
controllerLog('Transaction dropped, cleaning up revocation listener', {
10161013
txId,

packages/gator-permissions-controller/src/decodePermission/utils.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ describe('createPermissionRulesForChainId', () => {
8888
const rules = createPermissionRulesForChainId(contracts);
8989
expect(rules).toHaveLength(permissionTypeCount);
9090

91-
const byType = Object.fromEntries(rules.map((r) => [r.permissionType, r]));
91+
const byType = Object.fromEntries(
92+
rules.map((rule) => [rule.permissionType, rule]),
93+
);
9294

9395
// native-token-stream
9496
expect(byType['native-token-stream']).toBeDefined();

packages/gator-permissions-controller/src/decodePermission/utils.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,18 @@ const ENFORCER_CONTRACT_NAMES = {
3838
*/
3939
export const getChecksumEnforcersByChainId = (
4040
contracts: DeployedContractsByName,
41-
) => {
42-
const getChecksumContractAddress = (contractName: string) => {
41+
): {
42+
erc20StreamingEnforcer: Hex;
43+
erc20PeriodicEnforcer: Hex;
44+
nativeTokenStreamingEnforcer: Hex;
45+
nativeTokenPeriodicEnforcer: Hex;
46+
exactCalldataEnforcer: Hex;
47+
valueLteEnforcer: Hex;
48+
timestampEnforcer: Hex;
49+
nonceEnforcer: Hex;
50+
allowedCalldataEnforcer: Hex;
51+
} => {
52+
const getChecksumContractAddress = (contractName: string): Hex => {
4353
const address = contracts[contractName];
4454

4555
if (!address) {
@@ -181,9 +191,12 @@ export const createPermissionRulesForChainId: (
181191
* @param superset - The set expected to contain all elements of `subset`.
182192
* @returns `true` if `subset` ⊆ `superset`, otherwise `false`.
183193
*/
184-
export const isSubset = <T>(subset: Set<T>, superset: Set<T>): boolean => {
185-
for (const x of subset) {
186-
if (!superset.has(x)) {
194+
export const isSubset = <TElement>(
195+
subset: Set<TElement>,
196+
superset: Set<TElement>,
197+
): boolean => {
198+
for (const element of subset) {
199+
if (!superset.has(element)) {
187200
return false;
188201
}
189202
}

packages/gator-permissions-controller/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ export type RevocationParams = {
233233
/**
234234
* The hash of the transaction that was used to revoke the permission. Optional because we might not have submitted the transaction ourselves.
235235
*/
236-
txHash : Hex | undefined;
236+
txHash: Hex | undefined;
237237
};
238238

239239
/**

0 commit comments

Comments
 (0)