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

refactor: replace superstruct with @metamask/superstruct + bump @metamask/utils #5

Merged
merged 3 commits into from
Jul 3, 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
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,9 @@
"test": "jest && jest-it-up",
"test:watch": "jest --watch"
},
"resolutions": {
"superstruct@^1.0.3": "1.0.3"
},
"dependencies": {
"@metamask/utils": "^8.4.0",
"superstruct": "1.0.3"
"@metamask/superstruct": "^3.1.0",
"@metamask/utils": "^9.0.0"
},
"devDependencies": {
"@lavamoat/allow-scripts": "^3.0.0",
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, string, pattern } from 'superstruct';
import type { Infer } from '@metamask/superstruct';
import { is, string, pattern } from '@metamask/superstruct';

export const CAIP_ASSET_TYPE_REGEX =
/^(?<chainId>(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32}))\/(?<assetNamespace>[-a-z0-9]{3,8}):(?<assetReference>[-.%a-zA-Z0-9]{1,128})$/u;
Expand Down
2 changes: 1 addition & 1 deletion src/rpc-handler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { assert } from '@metamask/superstruct';
import { JsonRpcRequestStruct } from '@metamask/utils';
import type { Json, JsonRpcRequest, CaipChainId } from '@metamask/utils';
import { assert } from 'superstruct';

import type { Chain } from './api';
import { GetBalancesRequestStruct } from './rpc-types';
Expand Down
6 changes: 3 additions & 3 deletions src/rpc-types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { CaipChainIdStruct } from '@metamask/utils';
import type { Infer } from 'superstruct';
import type { Infer } from '@metamask/superstruct';
import {
record,
array,
Expand All @@ -8,7 +7,8 @@ import {
number,
object,
literal,
} from 'superstruct';
} from '@metamask/superstruct';
import { CaipChainIdStruct } from '@metamask/utils';

import { CaipAssetTypeOrIdStruct } from './caip-types';
import { StringNumberStruct } from './types';
Expand Down
4 changes: 2 additions & 2 deletions src/superstruct.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Struct } from 'superstruct';
import { define } from 'superstruct';
import type { Struct } from '@metamask/superstruct';
import { define } from '@metamask/superstruct';

/**
* Defines a new string-struct matching a regular expression.
Expand Down
2 changes: 1 addition & 1 deletion src/types.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 { StringNumberStruct } from './types';

Expand Down
2 changes: 1 addition & 1 deletion src/types.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 type { CaipAssetType } from './caip-types';
import { definePattern } from './superstruct';
Expand Down
28 changes: 14 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,8 @@ __metadata:
"@metamask/eslint-config-jest": "npm:^12.1.0"
"@metamask/eslint-config-nodejs": "npm:^12.1.0"
"@metamask/eslint-config-typescript": "npm:^12.1.0"
"@metamask/utils": "npm:^8.4.0"
"@metamask/superstruct": "npm:^3.1.0"
"@metamask/utils": "npm:^9.0.0"
"@types/jest": "npm:^28.1.6"
"@types/node": "npm:^16"
"@typescript-eslint/eslint-plugin": "npm:^5.43.0"
Expand All @@ -1119,7 +1120,6 @@ __metadata:
jest-it-up: "npm:^2.0.2"
prettier: "npm:^2.7.1"
prettier-plugin-packagejson: "npm:^2.3.0"
superstruct: "npm:1.0.3"
ts-jest: "npm:^28.0.7"
ts-node: "npm:^10.7.0"
tsup: "npm:^7.2.0"
Expand Down Expand Up @@ -1178,20 +1178,27 @@ __metadata:
languageName: node
linkType: hard

"@metamask/utils@npm:^8.4.0":
version: 8.4.0
resolution: "@metamask/utils@npm:8.4.0"
"@metamask/superstruct@npm:^3.1.0":
version: 3.1.0
resolution: "@metamask/superstruct@npm:3.1.0"
checksum: 10/5066fe228d5f11da387606d7f9545de2b473ab5a9e0f1bb8aea2f52d3e2c9d25e427151acde61f4a2de80a07a9871fe9505ad06abca6a61b7c3b54ed5c403b01
languageName: node
linkType: hard

"@metamask/utils@npm:^9.0.0":
version: 9.0.0
resolution: "@metamask/utils@npm:9.0.0"
dependencies:
"@ethereumjs/tx": "npm:^4.2.0"
"@metamask/superstruct": "npm:^3.1.0"
"@noble/hashes": "npm:^1.3.1"
"@scure/base": "npm:^1.1.3"
"@types/debug": "npm:^4.1.7"
debug: "npm:^4.3.4"
pony-cause: "npm:^2.1.10"
semver: "npm:^7.5.4"
superstruct: "npm:^1.0.3"
uuid: "npm:^9.0.1"
checksum: 10/5ce14d4e1630bf9269ab3b5cf3e05f393776b806c5be10a503128a3bc1d3aee891465d1f3937f537fdecec355a202a99ab70ae74f9bd37d51d3730c98c8f3dfc
checksum: 10/04a4eaba79e166fc6d23ecdba8b60625235a3a8c81fa615de64b845e74fa099ea7afd031060206c24809cfa161e7bca5aeb0bfd26079c5cbb82cb37f6a55ddb2
languageName: node
linkType: hard

Expand Down Expand Up @@ -6328,13 +6335,6 @@ __metadata:
languageName: node
linkType: hard

"superstruct@npm:1.0.3":
version: 1.0.3
resolution: "superstruct@npm:1.0.3"
checksum: 10/632b6171ac136b6750e62a55f806cc949b3dbf2b4a7dc70cc85f54adcdf19d21eab9711f04e8a643b7dd622bbd8658366ead924f467adaccb2c8005c133b7976
languageName: node
linkType: hard

"supports-color@npm:^5.3.0":
version: 5.5.0
resolution: "supports-color@npm:5.5.0"
Expand Down