diff --git a/package.json b/package.json index 9552a176d..3851b7126 100644 --- a/package.json +++ b/package.json @@ -62,13 +62,13 @@ }, "dependencies": { "@ethereumjs/tx": "^4.2.0", + "@metamask/superstruct": "^3.0.0", "@noble/hashes": "^1.3.1", "@scure/base": "^1.1.3", "@types/debug": "^4.1.7", "debug": "^4.3.4", "pony-cause": "^2.1.10", "semver": "^7.5.4", - "superstruct": "^1.0.3", "uuid": "^9.0.1" }, "devDependencies": { diff --git a/src/assert.test.ts b/src/assert.test.ts index 200da4818..787288e9c 100644 --- a/src/assert.test.ts +++ b/src/assert.test.ts @@ -1,4 +1,4 @@ -import { string, assert as superstructAssert } from 'superstruct'; +import { string, assert as superstructAssert } from '@metamask/superstruct'; import { assert, @@ -7,8 +7,8 @@ import { assertStruct, } from './assert'; -jest.mock('superstruct', () => ({ - ...jest.requireActual('superstruct'), +jest.mock('@metamask/superstruct', () => ({ + ...jest.requireActual('@metamask/superstruct'), assert: jest.fn(), })); @@ -50,7 +50,7 @@ describe('assertExhaustive', () => { describe('assertStruct', () => { beforeEach(() => { - const actual = jest.requireActual('superstruct'); + const actual = jest.requireActual('@metamask/superstruct'); ( superstructAssert as jest.MockedFunction ).mockImplementation(actual.assert); diff --git a/src/assert.ts b/src/assert.ts index 5892ebbfc..e25516d5e 100644 --- a/src/assert.ts +++ b/src/assert.ts @@ -1,5 +1,5 @@ -import type { Struct } from 'superstruct'; -import { assert as assertSuperstruct } from 'superstruct'; +import type { Struct } from '@metamask/superstruct'; +import { assert as assertSuperstruct } from '@metamask/superstruct'; import { getErrorMessage } from './errors'; diff --git a/src/base64.test.ts b/src/base64.test.ts index 79522b4f2..8499e606c 100644 --- a/src/base64.test.ts +++ b/src/base64.test.ts @@ -1,4 +1,4 @@ -import { is, size, string } from 'superstruct'; +import { is, size, string } from '@metamask/superstruct'; import type { Base64Options } from './base64'; import { base64 } from './base64'; diff --git a/src/base64.ts b/src/base64.ts index 8106e5963..1f6f71d7e 100644 --- a/src/base64.ts +++ b/src/base64.ts @@ -1,5 +1,5 @@ -import type { Struct } from 'superstruct'; -import { pattern } from 'superstruct'; +import type { Struct } from '@metamask/superstruct'; +import { pattern } from '@metamask/superstruct'; import { assert } from './assert'; diff --git a/src/caip-types.ts b/src/caip-types.ts index 416babf46..e19639735 100644 --- a/src/caip-types.ts +++ b/src/caip-types.ts @@ -1,5 +1,5 @@ -import type { Infer } from 'superstruct'; -import { is, pattern, string } from 'superstruct'; +import type { Infer } from '@metamask/superstruct'; +import { is, pattern, string } from '@metamask/superstruct'; export const CAIP_CHAIN_ID_REGEX = /^(?[-a-z0-9]{3,8}):(?[-_a-zA-Z0-9]{1,32})$/u; diff --git a/src/checksum.test.ts b/src/checksum.test.ts index 28bfe63b3..4a5c90a37 100644 --- a/src/checksum.test.ts +++ b/src/checksum.test.ts @@ -1,4 +1,4 @@ -import { is } from 'superstruct'; +import { is } from '@metamask/superstruct'; import { ChecksumStruct } from './checksum'; diff --git a/src/checksum.ts b/src/checksum.ts index ffe6f92bb..fe42dfc36 100644 --- a/src/checksum.ts +++ b/src/checksum.ts @@ -1,4 +1,4 @@ -import { size, string } from 'superstruct'; +import { size, string } from '@metamask/superstruct'; import { base64 } from './base64'; diff --git a/src/coercers.ts b/src/coercers.ts index ce8d7c82f..6f02ac224 100644 --- a/src/coercers.ts +++ b/src/coercers.ts @@ -1,4 +1,4 @@ -import type { Infer } from 'superstruct'; +import type { Infer } from '@metamask/superstruct'; import { bigint, coerce, @@ -8,7 +8,7 @@ import { string, StructError, union, -} from 'superstruct'; +} from '@metamask/superstruct'; import { assert } from './assert'; import { bytesToHex, hexToBytes } from './bytes'; diff --git a/src/hex.ts b/src/hex.ts index 07a92103e..66dd6da6e 100644 --- a/src/hex.ts +++ b/src/hex.ts @@ -1,6 +1,6 @@ +import type { Struct } from '@metamask/superstruct'; +import { is, pattern, string } from '@metamask/superstruct'; import { keccak_256 as keccak256 } from '@noble/hashes/sha3'; -import type { Struct } from 'superstruct'; -import { is, pattern, string } from 'superstruct'; import { assert } from './assert'; import { bytesToHex } from './bytes'; diff --git a/src/json.test-d.ts b/src/json.test-d.ts index b25b780d3..e2066807b 100644 --- a/src/json.test-d.ts +++ b/src/json.test-d.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/consistent-type-definitions */ -import type { Infer } from 'superstruct'; -import { boolean, number, optional, string } from 'superstruct'; +import type { Infer } from '@metamask/superstruct'; +import { boolean, number, optional, string } from '@metamask/superstruct'; import { expectAssignable, expectNotAssignable } from 'tsd'; import type { Json } from '.'; diff --git a/src/json.test.ts b/src/json.test.ts index ab0325433..2b92d895c 100644 --- a/src/json.test.ts +++ b/src/json.test.ts @@ -8,7 +8,7 @@ import { max, number, optional, -} from 'superstruct'; +} from '@metamask/superstruct'; import { assert, @@ -46,8 +46,8 @@ import { JSON_VALIDATION_FIXTURES, } from './__fixtures__'; -jest.mock('superstruct', () => ({ - ...jest.requireActual('superstruct'), +jest.mock('@metamask/superstruct', () => ({ + ...jest.requireActual('@metamask/superstruct'), assert: jest.fn(), })); @@ -225,7 +225,7 @@ describe('exactOptional', () => { describe('json', () => { beforeEach(() => { - const actual = jest.requireActual('superstruct'); + const actual = jest.requireActual('@metamask/superstruct'); ( superstructAssert as jest.MockedFunction ).mockImplementation(actual.assert); diff --git a/src/json.ts b/src/json.ts index ff6a5dc8e..988114eea 100644 --- a/src/json.ts +++ b/src/json.ts @@ -1,4 +1,3 @@ -import type { Context, Infer } from 'superstruct'; import { any, array, @@ -19,12 +18,14 @@ import { union, unknown, Struct, -} from 'superstruct'; +} from '@metamask/superstruct'; import type { + Context, + Infer, ObjectSchema, - Optionalize, Simplify, -} from 'superstruct/dist/utils'; + Optionalize, +} from '@metamask/superstruct'; import type { AssertionErrorConstructor } from './assert'; import { assertStruct } from './assert'; diff --git a/src/versions.ts b/src/versions.ts index ad0bc2b2c..99ee6e75d 100644 --- a/src/versions.ts +++ b/src/versions.ts @@ -1,3 +1,5 @@ +import type { Struct } from '@metamask/superstruct'; +import { is, refine, string } from '@metamask/superstruct'; import { gt as gtSemver, gtr as gtrSemver, @@ -5,8 +7,6 @@ import { valid as validSemVerVersion, validRange as validSemVerRange, } from 'semver'; -import type { Struct } from 'superstruct'; -import { is, refine, string } from 'superstruct'; import { assertStruct } from './assert'; import type { Opaque } from './opaque'; diff --git a/tsconfig.json b/tsconfig.json index ffd391d27..01e09f861 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -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, diff --git a/yarn.lock b/yarn.lock index a48c43f3d..467dba608 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1054,6 +1054,13 @@ __metadata: languageName: node linkType: hard +"@metamask/superstruct@npm:^3.0.0": + version: 3.0.0 + resolution: "@metamask/superstruct@npm:3.0.0" + checksum: 667f8f2947186972516bb72b4ba215eaeede257c8beb0450583dd4c8b00c28729ff938267ca8804a3a351277fd627b8607cafeb71eb7045a2b6930639bb6a341 + languageName: node + linkType: hard + "@metamask/utils@workspace:.": version: 0.0.0-use.local resolution: "@metamask/utils@workspace:." @@ -1066,6 +1073,7 @@ __metadata: "@metamask/eslint-config-jest": ^12.0.0 "@metamask/eslint-config-nodejs": ^12.0.0 "@metamask/eslint-config-typescript": ^12.0.0 + "@metamask/superstruct": ^3.0.0 "@noble/hashes": ^1.3.1 "@scure/base": ^1.1.3 "@ts-bridge/cli": ^0.1.2 @@ -1095,7 +1103,6 @@ __metadata: prettier-plugin-packagejson: ^2.3.0 semver: ^7.5.4 stdio-mock: ^1.2.0 - superstruct: ^1.0.3 ts-jest: ^29.0.3 ts-node: ^10.7.0 tsd: ^0.29.0 @@ -6753,13 +6760,6 @@ __metadata: languageName: node linkType: hard -"superstruct@npm:^1.0.3": - version: 1.0.3 - resolution: "superstruct@npm:1.0.3" - checksum: 761790bb111e6e21ddd608299c252f3be35df543263a7ebbc004e840d01fcf8046794c274bcb351bdf3eae4600f79d317d085cdbb19ca05803a4361840cc9bb1 - languageName: node - linkType: hard - "supports-color@npm:^5.3.0": version: 5.5.0 resolution: "supports-color@npm:5.5.0"