From fee5a2c413d99a571f7af58e01610b9cdfe76c62 Mon Sep 17 00:00:00 2001 From: Jongsun Suh Date: Mon, 1 Jul 2024 12:54:30 -0400 Subject: [PATCH 1/3] Replace `superstruct` `^1.0.3` with `@metamask/superstruct` `3.1.0`, bump `@metamask/utils` to `^9.0.0` --- package.json | 7 ++----- yarn.lock | 28 ++++++++++++++-------------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index 2e265a9..4836d6c 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/yarn.lock b/yarn.lock index 2c6d3db..f0c8ca5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" @@ -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" @@ -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 @@ -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" From 6cde75fbf0e520b6fec4a0d38820cdd1d5bc8752 Mon Sep 17 00:00:00 2001 From: Jongsun Suh Date: Mon, 1 Jul 2024 12:54:49 -0400 Subject: [PATCH 2/3] Replace `superstruct` import statements with `@metamask/superstruct` --- src/caip-types.ts | 4 ++-- src/rpc-handler.ts | 2 +- src/rpc-types.ts | 4 ++-- src/superstruct.ts | 4 ++-- src/types.test.ts | 2 +- src/types.ts | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/caip-types.ts b/src/caip-types.ts index fff63df..63fa6ad 100644 --- a/src/caip-types.ts +++ b/src/caip-types.ts @@ -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 = /^(?(?[-a-z0-9]{3,8}):(?[-_a-zA-Z0-9]{1,32}))\/(?[-a-z0-9]{3,8}):(?[-.%a-zA-Z0-9]{1,128})$/u; diff --git a/src/rpc-handler.ts b/src/rpc-handler.ts index 66f8fc2..433bdad 100644 --- a/src/rpc-handler.ts +++ b/src/rpc-handler.ts @@ -1,6 +1,6 @@ import { JsonRpcRequestStruct } from '@metamask/utils'; import type { Json, JsonRpcRequest, CaipChainId } from '@metamask/utils'; -import { assert } from 'superstruct'; +import { assert } from '@metamask/superstruct'; import type { Chain } from './api'; import { GetBalancesRequestStruct } from './rpc-types'; diff --git a/src/rpc-types.ts b/src/rpc-types.ts index 258a556..7cffae3 100644 --- a/src/rpc-types.ts +++ b/src/rpc-types.ts @@ -1,5 +1,5 @@ import { CaipChainIdStruct } from '@metamask/utils'; -import type { Infer } from 'superstruct'; +import type { Infer } from '@metamask/superstruct'; import { record, array, @@ -8,7 +8,7 @@ import { number, object, literal, -} from 'superstruct'; +} from '@metamask/superstruct'; import { CaipAssetTypeOrIdStruct } from './caip-types'; import { StringNumberStruct } from './types'; diff --git a/src/superstruct.ts b/src/superstruct.ts index 4dceb32..ae29aac 100644 --- a/src/superstruct.ts +++ b/src/superstruct.ts @@ -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. diff --git a/src/types.test.ts b/src/types.test.ts index 7267a37..915c9d6 100644 --- a/src/types.test.ts +++ b/src/types.test.ts @@ -1,4 +1,4 @@ -import { is } from 'superstruct'; +import { is } from '@metamask/superstruct'; import { StringNumberStruct } from './types'; diff --git a/src/types.ts b/src/types.ts index 61a4337..04bab6c 100644 --- a/src/types.ts +++ b/src/types.ts @@ -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'; From bdb5eb674f1ceeac9a24314c07763b8c57784108 Mon Sep 17 00:00:00 2001 From: Jongsun Suh Date: Mon, 1 Jul 2024 13:11:35 -0400 Subject: [PATCH 3/3] Linter fixes --- src/rpc-handler.ts | 2 +- src/rpc-types.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpc-handler.ts b/src/rpc-handler.ts index 433bdad..3c4f51c 100644 --- a/src/rpc-handler.ts +++ b/src/rpc-handler.ts @@ -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 '@metamask/superstruct'; import type { Chain } from './api'; import { GetBalancesRequestStruct } from './rpc-types'; diff --git a/src/rpc-types.ts b/src/rpc-types.ts index 7cffae3..7912863 100644 --- a/src/rpc-types.ts +++ b/src/rpc-types.ts @@ -1,4 +1,3 @@ -import { CaipChainIdStruct } from '@metamask/utils'; import type { Infer } from '@metamask/superstruct'; import { record, @@ -9,6 +8,7 @@ import { object, literal, } from '@metamask/superstruct'; +import { CaipChainIdStruct } from '@metamask/utils'; import { CaipAssetTypeOrIdStruct } from './caip-types'; import { StringNumberStruct } from './types';