Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Commit

Permalink
chore: migrate to @metamask/superstruct and update required depende…
Browse files Browse the repository at this point in the history
…ncies (#355)

* chore(deps): bump @metamask/utils from 8.4.0 to 9.0.0

Bumps [@metamask/utils](https://github.com/MetaMask/utils) from 8.4.0 to 9.0.0.
- [Release notes](https://github.com/MetaMask/utils/releases)
- [Changelog](https://github.com/MetaMask/utils/blob/main/CHANGELOG.md)
- [Commits](MetaMask/utils@v8.4.0...v9.0.0)

---
updated-dependencies:
- dependency-name: "@metamask/utils"
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore: migrate to '@metamask/superstruct'

* chore(deps): bump @metamask/rpc-errors from 6.3.0 to 6.3.1 (#350)

Bumps [@metamask/rpc-errors](https://github.com/MetaMask/rpc-errors) from 6.3.0 to 6.3.1.
- [Release notes](https://github.com/MetaMask/rpc-errors/releases)
- [Changelog](https://github.com/MetaMask/rpc-errors/blob/main/CHANGELOG.md)
- [Commits](MetaMask/rpc-errors@v6.3.0...v6.3.1)

---
updated-dependencies:
- dependency-name: "@metamask/rpc-errors"
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: update `yarn.lock`

* chore: update dependencies

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
danroc and dependabot[bot] authored Jul 16, 2024
1 parent bf23e8d commit 4b1d9dc
Show file tree
Hide file tree
Showing 27 changed files with 71 additions and 51 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
},
"dependencies": {
"@metamask/snaps-sdk": "^6.0.0",
"@metamask/utils": "^8.4.0",
"@metamask/superstruct": "^3.1.0",
"@metamask/utils": "^9.1.0",
"@types/uuid": "^9.0.8",
"bech32": "^2.0.0",
"superstruct": "^1.0.3",
"uuid": "^9.0.1"
},
"devDependencies": {
Expand All @@ -53,7 +53,7 @@
"@metamask/eslint-config-jest": "^12.1.0",
"@metamask/eslint-config-nodejs": "^12.1.0",
"@metamask/eslint-config-typescript": "^12.1.0",
"@metamask/providers": "^17.0.0",
"@metamask/providers": "^17.1.1",
"@types/jest": "^29.5.12",
"@types/node": "^20.12.12",
"@typescript-eslint/eslint-plugin": "^5.62.0",
Expand Down
2 changes: 1 addition & 1 deletion src/JsonRpcRequest.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 { JsonRpcRequestStruct } from './JsonRpcRequest';

Expand Down
11 changes: 9 additions & 2 deletions src/JsonRpcRequest.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import {
array,
literal,
number,
record,
string,
union,
} from '@metamask/superstruct';
import type { Infer } from '@metamask/superstruct';
import { JsonStruct } from '@metamask/utils';
import type { Infer } from 'superstruct';
import { array, literal, number, record, string, union } from 'superstruct';

import { exactOptional, object } from './superstruct';

Expand Down
2 changes: 1 addition & 1 deletion src/KeyringClient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert } from '@metamask/superstruct';
import type { Json } from '@metamask/utils';
import { assert } from 'superstruct';
import { v4 as uuid } from 'uuid';

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

import { KeyringAccountStruct } from './account';

Expand Down
4 changes: 2 additions & 2 deletions src/api/account.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Infer } from '@metamask/superstruct';
import { array, enums, record, string } from '@metamask/superstruct';
import { JsonStruct } from '@metamask/utils';
import type { Infer } from 'superstruct';
import { array, enums, record, string } from 'superstruct';

import { object } from '../superstruct';
import { UuidStruct } from '../utils';
Expand Down
4 changes: 2 additions & 2 deletions src/api/balance.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Infer } from 'superstruct';
import { string } from 'superstruct';
import type { Infer } from '@metamask/superstruct';
import { string } from '@metamask/superstruct';

import { object } from '../superstruct';
import { StringNumberStruct } from '../utils';
Expand Down
2 changes: 1 addition & 1 deletion src/api/caip.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { is, type Infer } from 'superstruct';
import { is, type Infer } from '@metamask/superstruct';

import { definePattern } from '../superstruct';

Expand Down
4 changes: 2 additions & 2 deletions src/api/export.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Infer } from '@metamask/superstruct';
import { record, string } from '@metamask/superstruct';
import { JsonStruct } from '@metamask/utils';
import type { Infer } from 'superstruct';
import { record, string } from 'superstruct';

export const KeyringAccountDataStruct = record(string(), JsonStruct);

Expand Down
4 changes: 2 additions & 2 deletions src/api/request.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Infer } from '@metamask/superstruct';
import { array, record, string, union } from '@metamask/superstruct';
import { JsonStruct } from '@metamask/utils';
import type { Infer } from 'superstruct';
import { array, record, string, union } from 'superstruct';

import { exactOptional, object } from '../superstruct';
import { UuidStruct } from '../utils';
Expand Down
4 changes: 2 additions & 2 deletions src/api/response.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Infer } from '@metamask/superstruct';
import { literal, string, union } from '@metamask/superstruct';
import { JsonStruct } from '@metamask/utils';
import type { Infer } from 'superstruct';
import { literal, string, union } from 'superstruct';

import { exactOptional, object } from '../superstruct';

Expand Down
4 changes: 2 additions & 2 deletions src/btc/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Infer } from '@metamask/superstruct';
import { string, array, enums, refine, literal } from '@metamask/superstruct';
import { bech32 } from 'bech32';
import type { Infer } from 'superstruct';
import { string, array, enums, refine, literal } from 'superstruct';

import { KeyringAccountStruct, BtcAccountType } from '../api';
import { object } from '../superstruct';
Expand Down
2 changes: 1 addition & 1 deletion src/eth/erc4337/types.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assert } from 'superstruct';
import { assert } from '@metamask/superstruct';

import { EthUserOperationStruct, EthBaseUserOperationStruct } from './types';

Expand Down
2 changes: 1 addition & 1 deletion src/eth/erc4337/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 { exactOptional, object } from '../../superstruct';
import { UrlStruct } from '../../utils';
Expand Down
4 changes: 2 additions & 2 deletions src/eth/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Infer } from 'superstruct';
import { array, enums, literal } from 'superstruct';
import type { Infer } from '@metamask/superstruct';
import { array, enums, literal } from '@metamask/superstruct';

import { EthAccountType, KeyringAccountStruct } from '../api';
import { object, definePattern } from '../superstruct';
Expand Down
11 changes: 9 additions & 2 deletions src/internal/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import type { Infer } from '@metamask/superstruct';
import {
array,
literal,
number,
record,
string,
union,
} from '@metamask/superstruct';
import { JsonStruct } from '@metamask/utils';
import type { Infer } from 'superstruct';
import { array, literal, number, record, string, union } from 'superstruct';

import {
BalanceStruct,
Expand Down
2 changes: 1 addition & 1 deletion src/internal/events.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 { EthAccountType } from '../api';
import { KeyringEvent } from '../events';
Expand Down
2 changes: 1 addition & 1 deletion src/internal/events.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { boolean, literal, string } from '@metamask/superstruct';
import { JsonStruct } from '@metamask/utils';
import { boolean, literal, string } from 'superstruct';

import { KeyringAccountStruct } from '../api';
import { KeyringEvent } from '../events';
Expand Down
2 changes: 1 addition & 1 deletion src/internal/types.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assert } from 'superstruct';
import { assert } from '@metamask/superstruct';

import { InternalAccountStruct } from '.';

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

import { BtcAccountType, EthAccountType, KeyringAccountStruct } from '../api';
import { BtcP2wpkhAccountStruct } from '../btc/types';
Expand Down
2 changes: 1 addition & 1 deletion src/rpc-handler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert } from '@metamask/superstruct';
import type { Json } from '@metamask/utils';
import { assert } from 'superstruct';

import type { Keyring } from './api';
import {
Expand Down
4 changes: 2 additions & 2 deletions src/superstruct.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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 { exactOptional, object } from '.';
Expand Down
4 changes: 2 additions & 2 deletions src/superstruct.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { is, literal, max, number, string, union } from 'superstruct';
import { is, literal, max, number, string, union } from '@metamask/superstruct';

import { exactOptional, object } from '.';

describe('superstruct', () => {
describe('@metamask/superstruct', () => {
describe('exactOptional', () => {
const simpleStruct = object({
foo: exactOptional(string()),
Expand Down
12 changes: 9 additions & 3 deletions src/superstruct.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import type { Infer, Context } from 'superstruct';
import { Struct, assert, define, object as stObject } from 'superstruct';
import {
Struct,
assert,
define,
object as stObject,
} from '@metamask/superstruct';
import type {
Infer,
Context,
ObjectSchema,
OmitBy,
Optionalize,
PickBy,
Simplify,
} from 'superstruct/dist/utils';
} from '@metamask/superstruct';

declare const ExactOptionalSymbol: unique symbol;

Expand Down
2 changes: 1 addition & 1 deletion src/utils/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/utils/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { define, type Infer } from 'superstruct';
import { define, type Infer } from '@metamask/superstruct';

import { definePattern } from '../superstruct';

Expand Down
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1061,9 +1061,10 @@ __metadata:
"@metamask/eslint-config-jest": ^12.1.0
"@metamask/eslint-config-nodejs": ^12.1.0
"@metamask/eslint-config-typescript": ^12.1.0
"@metamask/providers": ^17.0.0
"@metamask/providers": ^17.1.1
"@metamask/snaps-sdk": ^6.0.0
"@metamask/utils": ^8.4.0
"@metamask/superstruct": ^3.1.0
"@metamask/utils": ^9.1.0
"@types/jest": ^29.5.12
"@types/node": ^20.12.12
"@types/uuid": ^9.0.8
Expand All @@ -1084,7 +1085,6 @@ __metadata:
prettier: ^2.8.8
prettier-plugin-packagejson: ^2.5.0
rimraf: ^5.0.7
superstruct: ^1.0.3
ts-jest: ^28.0.8
ts-node: ^10.9.2
tsd: ^0.31.0
Expand All @@ -1106,7 +1106,7 @@ __metadata:
languageName: node
linkType: hard

"@metamask/providers@npm:^17.0.0":
"@metamask/providers@npm:^17.0.0, @metamask/providers@npm:^17.1.1":
version: 17.1.1
resolution: "@metamask/providers@npm:17.1.1"
dependencies:
Expand Down Expand Up @@ -1174,7 +1174,7 @@ __metadata:
languageName: node
linkType: hard

"@metamask/utils@npm:^8.3.0, @metamask/utils@npm:^8.4.0":
"@metamask/utils@npm:^8.3.0":
version: 8.4.0
resolution: "@metamask/utils@npm:8.4.0"
dependencies:
Expand All @@ -1191,9 +1191,9 @@ __metadata:
languageName: node
linkType: hard

"@metamask/utils@npm:^9.0.0":
version: 9.0.0
resolution: "@metamask/utils@npm:9.0.0"
"@metamask/utils@npm:^9.0.0, @metamask/utils@npm:^9.1.0":
version: 9.1.0
resolution: "@metamask/utils@npm:9.1.0"
dependencies:
"@ethereumjs/tx": ^4.2.0
"@metamask/superstruct": ^3.1.0
Expand All @@ -1204,7 +1204,7 @@ __metadata:
pony-cause: ^2.1.10
semver: ^7.5.4
uuid: ^9.0.1
checksum: 5dcb9d47c4768c33d451cc74c83207726c68b1340be1d091ca44105564f0ba0703026d357de7996de4459ac41cd420a0eb1f06db32f5ebbeeee581393f45fd44
checksum: 01f2c71a8f06158d5335bfe96bfd2f3aa39ec6b2323c5d0ff1d3136071a3e8ff7c1804d640ba1d4e07f96f3e68a95ff7729ddfcd34b373e5fefd86d6ef12d034
languageName: node
linkType: hard

Expand Down

0 comments on commit 4b1d9dc

Please sign in to comment.