Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace 'superstruct' imports with '@metamask/superstruct' #613

Merged
merged 6 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
"verify-snaps": "ts-node scripts/verify-snaps.ts"
},
"dependencies": {
"@metamask/utils": "^8.3.0",
"@metamask/superstruct": "^3.0.0",
"@metamask/utils": "^8.5.0",
"@noble/curves": "^1.2.0",
"@noble/hashes": "^1.3.2",
"superstruct": "^1.0.3"
"@noble/hashes": "^1.3.2"
},
"devDependencies": {
"@lavamoat/allow-scripts": "^2.3.1",
Expand Down
2 changes: 1 addition & 1 deletion scripts/verify-snaps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import {
getLocalizedSnapManifest,
getSnapChecksum,
} from '@metamask/snaps-utils';
import type { Infer } from '@metamask/superstruct';
import { assertIsSemVerVersion, getErrorMessage } from '@metamask/utils';
import deepEqual from 'fast-deep-equal';
import { imageSize as imageSizeSync } from 'image-size';
import { resolve } from 'path';
import semver from 'semver/preload';
import type { Infer } from 'superstruct';
import { promisify } from 'util';

import type { VerifiedSnapStruct } from '../src';
Expand Down
14 changes: 7 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
VersionStruct,
VersionRangeStruct,
ChecksumStruct,
} from '@metamask/utils';
import type { Infer } from 'superstruct';
import type { Infer } from '@metamask/superstruct';
import {
pattern,
size,
Expand All @@ -16,7 +11,12 @@ import {
enums,
refine,
boolean,
} from 'superstruct';
} from '@metamask/superstruct';
import {
VersionStruct,
VersionRangeStruct,
ChecksumStruct,
} from '@metamask/utils';

// For now, validate that each snap is using an NPM id.
const NpmIdStruct = refine(string(), 'Npm ID', (value) =>
Expand Down
2 changes: 1 addition & 1 deletion src/registry.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert } from '@metamask/superstruct';
import type { SemVerRange, SemVerVersion } from '@metamask/utils';
import { assert } from 'superstruct';

import type { SnapsRegistryDatabase } from '.';
import { SnapsRegistryDatabaseStruct } from '.';
Expand Down
4 changes: 2 additions & 2 deletions src/verify.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { Infer } from '@metamask/superstruct';
import { literal, object } from '@metamask/superstruct';
import type { Hex } from '@metamask/utils';
import {
StrictHexStruct,
Expand All @@ -8,8 +10,6 @@ import {
} from '@metamask/utils';
import { secp256k1 } from '@noble/curves/secp256k1';
import { sha256 } from '@noble/hashes/sha256';
import type { Infer } from 'superstruct';
import { literal, object } from 'superstruct';

export const SignatureStruct = object({
signature: StrictHexStruct,
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"exactOptionalPropertyTypes": true,
"forceConsistentCasingInFileNames": true,
"lib": ["ES2020", "DOM"],
"module": "CommonJS",
"moduleResolution": "node",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"noEmit": true,
"noErrorTruncation": true,
"noUncheckedIndexedAccess": true,
Expand Down
Loading
Loading