Skip to content

Commit a5533a7

Browse files
committed
Lint
1 parent f507a68 commit a5533a7

8 files changed

Lines changed: 36 additions & 36 deletions

File tree

packages/gator-permissions-snap/snap.manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"url": "https://github.com/MetaMask/snap-7715-permissions.git"
88
},
99
"source": {
10-
"shasum": "PoFMZl7wTNzoiX+wVkMk8Gwmhxd4el+wY1HHBX0XjGs=",
10+
"shasum": "rNRclGmH8r9z7JF1tMzA9Hfqu1ZO5ZghIAw2Es9bg1U=",
1111
"location": {
1212
"npm": {
1313
"filePath": "dist/bundle.js",

packages/gator-permissions-snap/src/core/permissionRequestLifecycleOrchestrator.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ export class PermissionRequestLifecycleOrchestrator {
234234
validBefore,
235235
);
236236

237+
// eslint-disable-next-line no-restricted-globals
237238
const saltBytes = crypto.getRandomValues(new Uint8Array(32));
238239
const salt = bytesToHex(saltBytes);
239240

packages/gator-permissions-snap/src/core/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import type {
66
import type { CoreCaveatBuilder } from '@metamask/delegation-toolkit';
77
import type { SnapsProvider } from '@metamask/snaps-sdk';
88
import type { GenericSnapElement } from '@metamask/snaps-sdk/jsx';
9+
import type { Hex } from 'viem';
910

1011
import type { AccountController } from '../accountController';
1112
import type { TokenMetadataService } from '../services/tokenMetadataService';
1213
import type { TokenPricesService } from '../services/tokenPricesService';
1314
import type { UserEventDispatcher } from '../userEventDispatcher';
1415
import type { PermissionRequestLifecycleOrchestrator } from './permissionRequestLifecycleOrchestrator';
15-
import { Hex } from 'viem';
1616

1717
/**
1818
* Represents the result of a permission request.

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

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
import { parseUnits, formatUnits } from 'viem';
2+
3+
import type { TimePeriod } from '../core/types';
24
import {
35
convertReadableDateToTimestamp,
46
getStartOfTodayUTC,
57
TIME_PERIOD_TO_SECONDS,
68
} from '../utils/time';
7-
import { TimePeriod } from '../core/types';
89

9-
export interface ValidationErrors {
10+
export type ValidationErrors = {
1011
[key: string]: string;
11-
}
12+
};
1213

1314
/**
14-
* Validates and parses a token amount string to BigInt
15-
* @param amount - The amount string to validate
16-
* @param decimals - Token decimals
17-
* @param fieldName - Name of the field for error messages
18-
* @param allowZero - Whether zero values are allowed (default: false)
19-
* @returns Object containing the parsed amount and any validation error
15+
* Validates and parses a token amount string to BigInt.
16+
* @param amount - The amount string to validate.
17+
* @param decimals - Token decimals.
18+
* @param fieldName - Name of the field for error messages.
19+
* @param allowZero - Whether zero values are allowed (default: false).
20+
* @returns Object containing the parsed amount and any validation error.
2021
*/
2122
export function validateAndParseAmount(
2223
amount: string | undefined,
@@ -49,9 +50,9 @@ export function validateAndParseAmount(
4950
}
5051

5152
/**
52-
* Validates a start time to ensure it's today or later
53-
* @param startTime - The start time string to validate
54-
* @returns Validation error message or undefined if valid
53+
* Validates a start time to ensure it's today or later.
54+
* @param startTime - The start time string to validate.
55+
* @returns Validation error message or undefined if valid.
5556
*/
5657
export function validateStartTime(startTime: string): string | undefined {
5758
try {
@@ -66,9 +67,9 @@ export function validateStartTime(startTime: string): string | undefined {
6667
}
6768

6869
/**
69-
* Validates an expiry time to ensure it's in the future
70-
* @param expiry - The expiry time string to validate
71-
* @returns Validation error message or undefined if valid
70+
* Validates an expiry time to ensure it's in the future.
71+
* @param expiry - The expiry time string to validate.
72+
* @returns Validation error message or undefined if valid.
7273
*/
7374
export function validateExpiry(expiry: string): string | undefined {
7475
try {
@@ -84,10 +85,10 @@ export function validateExpiry(expiry: string): string | undefined {
8485
}
8586

8687
/**
87-
* Validates that max amount is greater than initial amount
88-
* @param maxAmount - The maximum amount as BigInt
89-
* @param initialAmount - The initial amount as BigInt
90-
* @returns Validation error message or undefined if valid
88+
* Validates that max amount is greater than initial amount.
89+
* @param maxAmount - The maximum amount as BigInt.
90+
* @param initialAmount - The initial amount as BigInt.
91+
* @returns Validation error message or undefined if valid.
9192
*/
9293
export function validateMaxAmountVsInitialAmount(
9394
maxAmount: bigint | undefined,
@@ -104,11 +105,11 @@ export function validateMaxAmountVsInitialAmount(
104105
}
105106

106107
/**
107-
* Calculates amount per second from amount per period
108-
* @param amountPerPeriod - The amount per period as BigInt
109-
* @param timePeriod - The time period
110-
* @param decimals - Token decimals
111-
* @returns Formatted amount per second string
108+
* Calculates amount per second from amount per period.
109+
* @param amountPerPeriod - The amount per period as BigInt.
110+
* @param timePeriod - The time period.
111+
* @param decimals - Token decimals.
112+
* @returns Formatted amount per second string.
112113
*/
113114
export function calculateAmountPerSecond(
114115
amountPerPeriod: bigint,
@@ -122,9 +123,9 @@ export function calculateAmountPerSecond(
122123
}
123124

124125
/**
125-
* Validates a period duration (for periodic permissions)
126-
* @param periodDuration - The period duration string to validate
127-
* @returns Object containing parsed duration and any validation error
126+
* Validates a period duration (for periodic permissions).
127+
* @param periodDuration - The period duration string to validate.
128+
* @returns Object containing parsed duration and any validation error.
128129
*/
129130
export function validatePeriodDuration(periodDuration: string): {
130131
duration: number | undefined;

packages/gator-permissions-snap/src/permissions/erc20TokenStream/validation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { PermissionRequest } from '@metamask/7715-permissions-shared/types';
22
import { extractZodError } from '@metamask/7715-permissions-shared/utils';
3-
import { validateHexInteger } from '../validation';
43

4+
import { validateHexInteger } from '../validation';
55
import type {
66
Erc20TokenStreamPermission,
77
Erc20TokenStreamPermissionRequest,

packages/gator-permissions-snap/src/permissions/nativeTokenPeriodic/validation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { PermissionRequest } from '@metamask/7715-permissions-shared/types';
22
import { extractZodError } from '@metamask/7715-permissions-shared/utils';
3-
import { validateHexInteger } from '../validation';
43

4+
import { validateHexInteger } from '../validation';
55
import type {
66
NativeTokenPeriodicPermission,
77
NativeTokenPeriodicPermissionRequest,

packages/gator-permissions-snap/src/permissions/nativeTokenStream/validation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { PermissionRequest } from '@metamask/7715-permissions-shared/types';
22
import { extractZodError } from '@metamask/7715-permissions-shared/utils';
3-
import { validateHexInteger } from '../validation';
43

4+
import { validateHexInteger } from '../validation';
55
import type {
66
NativeTokenStreamPermission,
77
NativeTokenStreamPermissionRequest,

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Hex } from 'viem';
1+
import type { Hex } from 'viem';
22

33
/**
44
* Validates a hex integer value with configurable constraints.
@@ -8,7 +8,7 @@ import { Hex } from 'viem';
88
* @param params.value - The hex value to validate.
99
* @param params.allowZero - Whether zero values are allowed.
1010
* @param params.required - Whether the value is required (must be defined).
11-
* @throws {Error} If the value fails validation.
11+
* @throws {Error} If the value fails validation
1212
*/
1313
export function validateHexInteger({
1414
name,
@@ -39,6 +39,4 @@ export function validateHexInteger({
3939
if (parsedValue === 0n && !allowZero) {
4040
throw new Error(`Invalid ${name}: must be greater than 0`);
4141
}
42-
43-
return parsedValue;
4442
}

0 commit comments

Comments
 (0)