Skip to content

Commit

Permalink
Linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MajorLift committed Jun 7, 2024
1 parent 17efcd2 commit 11a910a
Show file tree
Hide file tree
Showing 27 changed files with 57 additions and 59 deletions.
2 changes: 1 addition & 1 deletion packages/snaps-cli/src/structs.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { resolve } from 'path/posix';
import { create, is } from '@metamask/superstruct';
import { resolve } from 'path/posix';

import { file } from './structs';

Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-cli/src/structs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { resolve } from 'path';
import { coerce, string } from '@metamask/superstruct';
import { resolve } from 'path';

/**
* A wrapper of `superstruct`'s `string` struct that coerces a value to a string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,8 @@ export abstract class AbstractExecutionService<WorkerType>
}

log('Parent: Sending Command', message);
const response: PendingJsonRpcResponse<Json> = await job.rpcEngine.handle(
message,
);
const response: PendingJsonRpcResponse<Json> =
job.rpcEngine.handle(message);

if (response.error) {
throw new JsonRpcError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
unwrapError,
logInfo,
} from '@metamask/snaps-utils';
import { validate, is } from '@metamask/superstruct';
import type {
JsonRpcNotification,
JsonRpcId,
Expand All @@ -33,7 +34,6 @@ import {
JsonRpcIdStruct,
} from '@metamask/utils';
import type { Duplex } from 'readable-stream';
import { validate, is } from '@metamask/superstruct';

import { log } from '../logging';
import type { CommandMethodsMapping } from './commands';
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-jest/src/internals/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import {
} from '@metamask/snaps-sdk';
import type { HandlerType } from '@metamask/snaps-utils';
import { unwrapError } from '@metamask/snaps-utils';
import { is } from '@metamask/superstruct';
import {
assert,
getSafeJson,
hasProperty,
isPlainObject,
} from '@metamask/utils';
import { nanoid } from '@reduxjs/toolkit';
import { is } from '@metamask/superstruct';

import type {
RequestOptions,
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-jest/src/internals/simulation/options.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { JsonStruct } from '@metamask/utils';
import type { Infer } from '@metamask/superstruct';
import {
create,
Expand All @@ -9,6 +8,7 @@ import {
record,
string,
} from '@metamask/superstruct';
import { JsonStruct } from '@metamask/utils';

import { DEFAULT_LOCALE, DEFAULT_SRP } from './constants';

Expand Down
14 changes: 7 additions & 7 deletions packages/snaps-jest/src/internals/structs.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import { NotificationType, enumValue } from '@metamask/snaps-sdk';
import { JSXElementStruct } from '@metamask/snaps-sdk/jsx';
import {
bytesToHex,
JsonStruct,
StrictHexStruct,
valueToBytes,
} from '@metamask/utils';
import { randomBytes } from 'crypto';
import {
array,
assign,
Expand All @@ -25,6 +18,13 @@ import {
func,
type,
} from '@metamask/superstruct';
import {
bytesToHex,
JsonStruct,
StrictHexStruct,
valueToBytes,
} from '@metamask/utils';
import { randomBytes } from 'crypto';

// TODO: Export this from `@metamask/utils` instead.
const BytesLikeStruct = union([
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-jest/src/matchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type {
import type { JSXElement, SnapNode } from '@metamask/snaps-sdk/jsx';
import { isJSXElementUnsafe } from '@metamask/snaps-sdk/jsx';
import { getJsxElementFromComponent } from '@metamask/snaps-utils';
import { is } from '@metamask/superstruct';
import type { Json } from '@metamask/utils';
import { hasProperty } from '@metamask/utils';
import type { MatcherHintOptions } from 'jest-matcher-utils';
Expand All @@ -26,7 +27,6 @@ import {
printWithType,
RECEIVED_COLOR,
} from 'jest-matcher-utils';
import { is } from '@metamask/superstruct';

import { InterfaceStruct, SnapResponseStruct } from './internals';
import type { SnapResponse } from './types';
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-jest/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { NotificationType, EnumToUnion } from '@metamask/snaps-sdk';
import type { JSXElement } from '@metamask/snaps-sdk/jsx';
import type { InferMatching } from '@metamask/snaps-utils';
import type { Json, JsonRpcId, JsonRpcParams } from '@metamask/utils';
import type { Infer } from '@metamask/superstruct';
import type { Json, JsonRpcId, JsonRpcParams } from '@metamask/utils';

import type {
SignatureOptionsStruct,
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-rpc-methods/src/permitted/getFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { rpcErrors } from '@metamask/rpc-errors';
import type { GetFileParams, GetFileResult } from '@metamask/snaps-sdk';
import { AuxiliaryFileEncoding, enumValue } from '@metamask/snaps-sdk';
import type { InferMatching } from '@metamask/snaps-utils';
import { object, optional, string, union } from '@metamask/superstruct';
import type { PendingJsonRpcResponse, JsonRpcRequest } from '@metamask/utils';
import { assertStruct } from '@metamask/utils';
import { object, optional, string, union } from '@metamask/superstruct';

import type { MethodHooksObject } from '../utils';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import type {
JsonRpcRequest,
} from '@metamask/snaps-sdk';
import { type InferMatching } from '@metamask/snaps-utils';
import type { PendingJsonRpcResponse } from '@metamask/utils';
import { StructError, create, object, string } from '@metamask/superstruct';
import type { PendingJsonRpcResponse } from '@metamask/utils';

import type { MethodHooksObject } from '../utils';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import type {
} from '@metamask/snaps-sdk';
import { ComponentOrElementStruct } from '@metamask/snaps-sdk';
import { type InferMatching } from '@metamask/snaps-utils';
import type { PendingJsonRpcResponse } from '@metamask/utils';
import { StructError, create, object, string } from '@metamask/superstruct';
import type { PendingJsonRpcResponse } from '@metamask/utils';

import type { MethodHooksObject } from '../utils';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import {
Bip32EntropyStruct,
isEqual,
} from '@metamask/snaps-utils';
import { array, size, type } from '@metamask/superstruct';
import type { Json } from '@metamask/utils';
import { assertStruct } from '@metamask/utils';
import { array, size, type } from '@metamask/superstruct';

/**
* Map a raw value from the `initialPermissions` to a caveat specification.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import type {
import { rpcErrors } from '@metamask/rpc-errors';
import type { SnapIds } from '@metamask/snaps-utils';
import { SnapCaveatType, SnapIdsStruct } from '@metamask/snaps-utils';
import { type } from '@metamask/superstruct';
import type { Json } from '@metamask/utils';
import { hasProperty, assertStruct } from '@metamask/utils';
import { type } from '@metamask/superstruct';

import type { InvokeSnapParams } from '../invokeSnap';

Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-rpc-methods/src/restricted/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import type {
} from '@metamask/snaps-sdk';
import { createUnion } from '@metamask/snaps-utils';
import type { InferMatching } from '@metamask/snaps-utils';
import { hasProperty, type NonEmptyArray } from '@metamask/utils';
import type { Infer, Struct } from '@metamask/superstruct';
import {
create,
Expand All @@ -32,6 +31,7 @@ import {
string,
type,
} from '@metamask/superstruct';
import { hasProperty, type NonEmptyArray } from '@metamask/utils';

import { type MethodHooksObject } from '../utils';

Expand Down
4 changes: 2 additions & 2 deletions packages/snaps-rpc-methods/src/restricted/getEntropy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { PermissionType, SubjectType } from '@metamask/permission-controller';
import { rpcErrors } from '@metamask/rpc-errors';
import type { GetEntropyParams, GetEntropyResult } from '@metamask/snaps-sdk';
import { SIP_6_MAGIC_VALUE } from '@metamask/snaps-utils';
import type { NonEmptyArray } from '@metamask/utils';
import { assertStruct } from '@metamask/utils';
import type { Infer } from '@metamask/superstruct';
import { literal, object, optional, string } from '@metamask/superstruct';
import type { NonEmptyArray } from '@metamask/utils';
import { assertStruct } from '@metamask/utils';

import type { MethodHooksObject } from '../utils';
import { deriveEntropy } from '../utils';
Expand Down
4 changes: 2 additions & 2 deletions packages/snaps-rpc-methods/src/restricted/manageAccounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import type {
ManageAccountsResult,
} from '@metamask/snaps-sdk';
import type { InferMatching } from '@metamask/snaps-utils';
import type { Json, NonEmptyArray } from '@metamask/utils';
import { JsonStruct } from '@metamask/utils';
import {
assert,
string,
Expand All @@ -19,6 +17,8 @@ import {
array,
record,
} from '@metamask/superstruct';
import type { Json, NonEmptyArray } from '@metamask/utils';
import { JsonStruct } from '@metamask/utils';

const SnapMessageStruct = union([
object({
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-sdk/src/ui/builder.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assertStruct, isPlainObject } from '@metamask/utils';
import type { Struct } from '@metamask/superstruct';
import { assertStruct, isPlainObject } from '@metamask/utils';

import type { Component } from './components';
import type { NodeType } from './nodes';
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-sdk/src/ui/component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assertStruct } from '@metamask/utils';
import { is } from '@metamask/superstruct';
import { assertStruct } from '@metamask/utils';

import { ComponentStruct } from './components';
import type { Component } from './components';
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-sdk/src/ui/components/address.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HexChecksumAddressStruct } from '@metamask/utils';
import type { Infer } from '@metamask/superstruct';
import { assign, literal, object } from '@metamask/superstruct';
import { HexChecksumAddressStruct } from '@metamask/utils';

import { createBuilder } from '../builder';
import { LiteralStruct, NodeType } from '../nodes';
Expand Down
12 changes: 6 additions & 6 deletions packages/snaps-utils/src/cronjob.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
import {
JsonRpcIdStruct,
JsonRpcParamsStruct,
JsonRpcVersionStruct,
} from '@metamask/utils';
import { parseExpression } from 'cron-parser';
import type { Infer } from '@metamask/superstruct';
import {
array,
Expand All @@ -13,6 +7,12 @@ import {
refine,
string,
} from '@metamask/superstruct';
import {
JsonRpcIdStruct,
JsonRpcParamsStruct,
JsonRpcVersionStruct,
} from '@metamask/utils';
import { parseExpression } from 'cron-parser';

export const CronjobRpcRequestStruct = object({
jsonrpc: optional(JsonRpcVersionStruct),
Expand Down
18 changes: 9 additions & 9 deletions packages/snaps-utils/src/json-rpc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
import { SubjectType } from '@metamask/permission-controller';
import type { Infer } from '@metamask/superstruct';
import {
array,
boolean,
object,
optional,
refine,
string,
} from '@metamask/superstruct';
import type {
AssertionErrorConstructor,
Json,
Expand All @@ -9,15 +18,6 @@ import {
isJsonRpcFailure,
isJsonRpcSuccess,
} from '@metamask/utils';
import type { Infer } from '@metamask/superstruct';
import {
array,
boolean,
object,
optional,
refine,
string,
} from '@metamask/superstruct';

const AllowedOriginsStruct = array(
refine(string(), 'Allowed origin', (value) => {
Expand Down
8 changes: 4 additions & 4 deletions packages/snaps-utils/src/snaps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ import type {
} from '@metamask/permission-controller';
import type { BlockReason } from '@metamask/snaps-registry';
import type { SnapId, Snap as TruncatedSnap } from '@metamask/snaps-sdk';
import type { Json } from '@metamask/utils';
import { assert, isObject, assertStruct } from '@metamask/utils';
import { base64 } from '@scure/base';
import stableStringify from 'fast-json-stable-stringify';
import type { Struct } from '@metamask/superstruct';
import {
empty,
Expand All @@ -21,6 +17,10 @@ import {
union,
validate,
} from '@metamask/superstruct';
import type { Json } from '@metamask/utils';
import { assert, isObject, assertStruct } from '@metamask/utils';
import { base64 } from '@scure/base';
import stableStringify from 'fast-json-stable-stringify';
import validateNPMPackage from 'validate-npm-package-name';

import { SnapCaveatType } from './caveats';
Expand Down
4 changes: 2 additions & 2 deletions packages/snaps-utils/src/structs.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { union, literal } from '@metamask/snaps-sdk';
import { assert } from '@metamask/utils';
import { bold, green, red } from 'chalk';
import type { Struct } from '@metamask/superstruct';
import superstruct, {
size,
Expand All @@ -12,6 +10,8 @@ import superstruct, {
union as superstructUnion,
array,
} from '@metamask/superstruct';
import { assert } from '@metamask/utils';
import { bold, green, red } from 'chalk';

import {
arrayToGenerator,
Expand Down
9 changes: 4 additions & 5 deletions packages/snaps-utils/src/structs.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import { union } from '@metamask/snaps-sdk';
import type { NonEmptyArray } from '@metamask/utils';
import { assert, isObject } from '@metamask/utils';
import { bold, green, red } from 'chalk';
import type { Failure } from '@metamask/superstruct';
import {
is,
validate,
Expand All @@ -11,7 +7,10 @@ import {
StructError,
create,
} from '@metamask/superstruct';
import type { AnyStruct } from '@metamask/superstruct';
import type { Failure, AnyStruct } from '@metamask/superstruct';
import type { NonEmptyArray } from '@metamask/utils';
import { assert, isObject } from '@metamask/utils';
import { bold, green, red } from 'chalk';

import { indent } from './strings';

Expand Down
4 changes: 2 additions & 2 deletions packages/snaps-utils/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import type { Json } from '@metamask/utils';
import { assertStruct, VersionStruct } from '@metamask/utils';
import type { Infer, Struct } from '@metamask/superstruct';
import {
instance,
Expand All @@ -14,6 +12,8 @@ import {
union,
assert as assertSuperstruct,
} from '@metamask/superstruct';
import type { Json } from '@metamask/utils';
import { assertStruct, VersionStruct } from '@metamask/utils';

import type { SnapCaveatType } from './caveats';
import type { SnapFunctionExports, SnapRpcHookArgs } from './handlers';
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-utils/src/versions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { validate } from '@metamask/superstruct';
import type { Json, SemVerVersion, SemVerRange } from '@metamask/utils';
import { VersionRangeStruct } from '@metamask/utils';
import { maxSatisfying as maxSatisfyingSemver } from 'semver';
import { validate } from '@metamask/superstruct';

export const DEFAULT_REQUESTED_SNAP_VERSION = '*' as SemVerRange;

Expand Down

0 comments on commit 11a910a

Please sign in to comment.