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

Use @metamask/superstruct, set moduleResolution to NodeNext #185

Merged
merged 6 commits into from
Jun 4, 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
8 changes: 4 additions & 4 deletions src/assert.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { string, assert as superstructAssert } from 'superstruct';
import { string, assert as superstructAssert } from '@metamask/superstruct';

import {
assert,
Expand All @@ -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(),
}));

Expand Down Expand Up @@ -50,7 +50,7 @@ describe('assertExhaustive', () => {

describe('assertStruct', () => {
beforeEach(() => {
const actual = jest.requireActual('superstruct');
const actual = jest.requireActual('@metamask/superstruct');
(
superstructAssert as jest.MockedFunction<typeof superstructAssert>
).mockImplementation(actual.assert);
Expand Down
4 changes: 2 additions & 2 deletions src/assert.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion src/base64.test.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
4 changes: 2 additions & 2 deletions src/base64.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
4 changes: 2 additions & 2 deletions src/caip-types.ts
Original file line number Diff line number Diff line change
@@ -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 =
/^(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32})$/u;
Expand Down
2 changes: 1 addition & 1 deletion src/checksum.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { is } from 'superstruct';
import { is } from '@metamask/superstruct';

import { ChecksumStruct } from './checksum';

Expand Down
2 changes: 1 addition & 1 deletion src/checksum.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { size, string } from 'superstruct';
import { size, string } from '@metamask/superstruct';

import { base64 } from './base64';

Expand Down
4 changes: 2 additions & 2 deletions src/coercers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Infer } from 'superstruct';
import type { Infer } from '@metamask/superstruct';
import {
bigint,
coerce,
Expand All @@ -8,7 +8,7 @@ import {
string,
StructError,
union,
} from 'superstruct';
} from '@metamask/superstruct';

import { assert } from './assert';
import { bytesToHex, hexToBytes } from './bytes';
Expand Down
4 changes: 2 additions & 2 deletions src/hex.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
4 changes: 2 additions & 2 deletions src/json.test-d.ts
Original file line number Diff line number Diff line change
@@ -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 '.';
Expand Down
8 changes: 4 additions & 4 deletions src/json.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
max,
number,
optional,
} from 'superstruct';
} from '@metamask/superstruct';

import {
assert,
Expand Down Expand Up @@ -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(),
}));

Expand Down Expand Up @@ -225,7 +225,7 @@ describe('exactOptional', () => {

describe('json', () => {
beforeEach(() => {
const actual = jest.requireActual('superstruct');
const actual = jest.requireActual('@metamask/superstruct');
(
superstructAssert as jest.MockedFunction<typeof superstructAssert>
).mockImplementation(actual.assert);
Expand Down
9 changes: 5 additions & 4 deletions src/json.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { Context, Infer } from 'superstruct';
import {
any,
array,
Expand All @@ -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';
Expand Down
4 changes: 2 additions & 2 deletions src/versions.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { Struct } from '@metamask/superstruct';
import { is, refine, string } from '@metamask/superstruct';
import {
gt as gtSemver,
gtr as gtrSemver,
satisfies as satisfiesSemver,
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';
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
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:."
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
Loading