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

chore(deps): bump '@metamask/*' and peer dependencies #382

Merged
merged 5 commits into from
Sep 12, 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
1 change: 1 addition & 0 deletions .depcheckrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"ignores": [
"@lavamoat/allow-scripts",
"@lavamoat/preinstall-always-fail",
"@types/eslint",
"@types/jest",
"@types/node",
"prettier-plugin-packagejson",
Expand Down
546 changes: 546 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ plugins:
spec: "https://raw.githubusercontent.com/LavaMoat/LavaMoat/main/packages/yarn-plugin-allow-scripts/bundles/@yarnpkg/plugin-allow-scripts.js"
- path: .yarn/plugins/@yarnpkg/plugin-constraints.cjs
spec: "@yarnpkg/plugin-constraints"
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"

yarnPath: .yarn/releases/yarn-3.2.1.cjs
46 changes: 24 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,45 +38,47 @@
"test:watch": "jest --watch"
},
"dependencies": {
"@metamask/snaps-sdk": "^6.1.0",
"@metamask/snaps-sdk": "^6.3.0",
"@metamask/superstruct": "^3.1.0",
"@metamask/utils": "^9.1.0",
"@types/uuid": "^9.0.8",
"@metamask/utils": "^9.2.1",
"bech32": "^2.0.0",
"uuid": "^9.0.1"
"uuid": "^10.0.0"
},
"devDependencies": {
"@lavamoat/allow-scripts": "^3.0.4",
"@lavamoat/preinstall-always-fail": "^2.0.0",
"@lavamoat/allow-scripts": "^3.2.1",
"@lavamoat/preinstall-always-fail": "^2.1.0",
"@metamask/auto-changelog": "^3.4.4",
"@metamask/eslint-config": "^12.2.0",
"@metamask/eslint-config-jest": "^12.1.0",
"@metamask/eslint-config": "^13.0.0",
"@metamask/eslint-config-jest": "^13.0.0",
"@metamask/eslint-config-nodejs": "^13.0.0",
"@metamask/eslint-config-typescript": "^12.1.0",
"@metamask/providers": "^17.1.1",
"@metamask/eslint-config-typescript": "^13.0.0",
"@metamask/providers": "^17.2.0",
"@types/eslint": "^8.56.12",
"@types/jest": "^29.5.12",
"@types/node": "^20.12.12",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"@types/node": "^20.16.5",
"@types/uuid": "^10.0.0",
"@typescript-eslint/eslint-plugin": "^8.5.0",
"@typescript-eslint/parser": "^8.5.0",
"depcheck": "^1.4.7",
"eslint": "^8.57.0",
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-import": "~2.26.0",
"eslint-plugin-import-x": "^0.5.3",
"eslint-plugin-jest": "^27.9.0",
"eslint-plugin-jsdoc": "^39.9.1",
"eslint-plugin-n": "^15.7.0",
"eslint-plugin-jsdoc": "^47.0.2",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-promise": "^6.6.0",
"jest": "^28.1.3",
"jest-it-up": "^3.1.0",
"jest-it-up": "^3.2.0",
"prettier": "^2.8.8",
"prettier-plugin-packagejson": "^2.5.0",
"rimraf": "^5.0.7",
"prettier-plugin-packagejson": "^2.5.2",
"rimraf": "^5.0.10",
"ts-jest": "^28.0.8",
"ts-node": "^10.9.2",
"tsd": "^0.31.0",
"tsd": "^0.31.2",
"typedoc": "^0.25.13",
"typescript": "~4.8.4"
"typescript": "~4.8.4",
"webextension-polyfill": "^0.12.0"
},
"peerDependencies": {
"@metamask/providers": ">=15 <18"
Expand Down
2 changes: 1 addition & 1 deletion src/KeyringClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export type Sender = {
};

export class KeyringClient implements Keyring {
#sender: Sender;
readonly #sender: Sender;

/**
* Create a new instance of `KeyringClient`.
Expand Down
4 changes: 2 additions & 2 deletions src/KeyringSnapRpcClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import { KeyringClient } from './KeyringClient';
* to a snap through the snap JSON-RPC API.
*/
export class SnapRpcSender implements Sender {
#origin: string;
readonly #origin: string;

#provider: MetaMaskInpageProvider;
readonly #provider: MetaMaskInpageProvider;

/**
* Create a new instance of `SnapRpcSender`.
Expand Down
2 changes: 1 addition & 1 deletion src/btc/types.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { BtcP2wpkhAccount } from './types';
import type { KeyringAccount } from '../api';
import type { Extends } from '../utils';
import { expectTrue } from '../utils';
import type { BtcP2wpkhAccount } from './types';

// `BtcP2wpkhAccount` extends `KeyringAccount`
expectTrue<Extends<BtcP2wpkhAccount, KeyringAccount>>();
1 change: 1 addition & 0 deletions src/eth/erc4337/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { EthAddressStruct, EthBytesStruct, EthUint256Struct } from '../types';

/**
* Struct of a UserOperation as defined by ERC-4337.
*
* @see https://eips.ethereum.org/EIPS/eip-4337#definitions
*/
export const EthUserOperationStruct = object({
Expand Down
4 changes: 2 additions & 2 deletions src/eth/types.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { expectAssignable, expectNotAssignable } from 'tsd';

import type { EthEoaAccount, EthErc4337Account } from './types';
import { EthMethod } from './types';
import type { KeyringAccount } from '../api';
import { EthAccountType } from '../api';
import type { Extends } from '../utils';
import { expectTrue } from '../utils';
import type { EthEoaAccount, EthErc4337Account } from './types';
import { EthMethod } from './types';

const id = '606a7759-b0fb-48e4-9874-bab62ff8e7eb';
const address = '0x000';
Expand Down
2 changes: 1 addition & 1 deletion src/eth/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BtcAccountType, EthAccountType } from '../api';
import { isEvmAccountType } from './utils';
import { BtcAccountType, EthAccountType } from '../api';

describe('isEvmAccountType', () => {
it.each([
Expand Down
2 changes: 1 addition & 1 deletion src/internal/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from '@metamask/superstruct';
import { JsonStruct } from '@metamask/utils';

import { KeyringRpcMethod } from './rpc';
import {
BalanceStruct,
CaipAssetTypeStruct,
Expand All @@ -19,7 +20,6 @@ import {
} from '../api';
import { object } from '../superstruct';
import { UuidStruct } from '../utils';
import { KeyringRpcMethod } from './rpc';

const CommonHeader = {
jsonrpc: literal('2.0'),
Expand Down
4 changes: 2 additions & 2 deletions src/internal/events.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { is } from '@metamask/superstruct';

import { EthAccountType } from '../api';
import { KeyringEvent } from '../events';
import {
AccountCreatedEventStruct,
AccountDeletedEventStruct,
AccountUpdatedEventStruct,
RequestApprovedEventStruct,
RequestRejectedEventStruct,
} from './events';
import { EthAccountType } from '../api';
import { KeyringEvent } from '../events';

describe('events', () => {
describe('AccountCreatedEventStruct', () => {
Expand Down
35 changes: 12 additions & 23 deletions src/internal/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,20 @@ export const InternalAccountMetadataStruct = object({
}),
});

/**
* Creates an `InternalAccount` from an existing account `superstruct` object.
*
* @param accountStruct - An account `superstruct` object.
* @returns The `InternalAccount` associated to `accountStruct`.
*/
function asInternalAccountStruct<Account, AccountSchema>(
accountStruct: Struct<Account, AccountSchema>,
) {
return object({
...accountStruct.schema,
...InternalAccountMetadataStruct.schema,
});
}

export const InternalEthEoaAccountStruct =
asInternalAccountStruct(EthEoaAccountStruct);
export const InternalEthEoaAccountStruct = object({
...EthEoaAccountStruct.schema,
...InternalAccountMetadataStruct.schema,
});

export const InternalEthErc4337AccountStruct = asInternalAccountStruct(
EthErc4337AccountStruct,
);
export const InternalEthErc4337AccountStruct = object({
...EthErc4337AccountStruct.schema,
...InternalAccountMetadataStruct.schema,
});

export const InternalBtcP2wpkhAccountStruct = asInternalAccountStruct(
BtcP2wpkhAccountStruct,
);
export const InternalBtcP2wpkhAccountStruct = object({
...BtcP2wpkhAccountStruct.schema,
...InternalAccountMetadataStruct.schema,
});

export type InternalEthEoaAccount = Infer<typeof InternalEthEoaAccountStruct>;

Expand Down
26 changes: 13 additions & 13 deletions src/rpc-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,22 @@ async function dispatchRequest(
assert(request, JsonRpcRequestStruct);

switch (request.method) {
case KeyringRpcMethod.ListAccounts: {
case `${KeyringRpcMethod.ListAccounts}`: {
assert(request, ListAccountsRequestStruct);
return keyring.listAccounts();
}

case KeyringRpcMethod.GetAccount: {
case `${KeyringRpcMethod.GetAccount}`: {
assert(request, GetAccountRequestStruct);
return keyring.getAccount(request.params.id);
}

case KeyringRpcMethod.CreateAccount: {
case `${KeyringRpcMethod.CreateAccount}`: {
assert(request, CreateAccountRequestStruct);
return keyring.createAccount(request.params.options);
}

case KeyringRpcMethod.GetAccountBalances: {
case `${KeyringRpcMethod.GetAccountBalances}`: {
if (keyring.getAccountBalances === undefined) {
throw new MethodNotSupportedError(request.method);
}
Expand All @@ -73,62 +73,62 @@ async function dispatchRequest(
);
}

case KeyringRpcMethod.FilterAccountChains: {
case `${KeyringRpcMethod.FilterAccountChains}`: {
assert(request, FilterAccountChainsStruct);
return keyring.filterAccountChains(
request.params.id,
request.params.chains,
);
}

case KeyringRpcMethod.UpdateAccount: {
case `${KeyringRpcMethod.UpdateAccount}`: {
assert(request, UpdateAccountRequestStruct);
return keyring.updateAccount(request.params.account);
}

case KeyringRpcMethod.DeleteAccount: {
case `${KeyringRpcMethod.DeleteAccount}`: {
assert(request, DeleteAccountRequestStruct);
return keyring.deleteAccount(request.params.id);
}

case KeyringRpcMethod.ExportAccount: {
case `${KeyringRpcMethod.ExportAccount}`: {
if (keyring.exportAccount === undefined) {
throw new MethodNotSupportedError(request.method);
}
assert(request, ExportAccountRequestStruct);
return keyring.exportAccount(request.params.id);
}

case KeyringRpcMethod.ListRequests: {
case `${KeyringRpcMethod.ListRequests}`: {
if (keyring.listRequests === undefined) {
throw new MethodNotSupportedError(request.method);
}
assert(request, ListRequestsRequestStruct);
return keyring.listRequests();
}

case KeyringRpcMethod.GetRequest: {
case `${KeyringRpcMethod.GetRequest}`: {
if (keyring.getRequest === undefined) {
throw new MethodNotSupportedError(request.method);
}
assert(request, GetRequestRequestStruct);
return keyring.getRequest(request.params.id);
}

case KeyringRpcMethod.SubmitRequest: {
case `${KeyringRpcMethod.SubmitRequest}`: {
assert(request, SubmitRequestRequestStruct);
return keyring.submitRequest(request.params);
}

case KeyringRpcMethod.ApproveRequest: {
case `${KeyringRpcMethod.ApproveRequest}`: {
if (keyring.approveRequest === undefined) {
throw new MethodNotSupportedError(request.method);
}
assert(request, ApproveRequestRequestStruct);
return keyring.approveRequest(request.params.id, request.params.data);
}

case KeyringRpcMethod.RejectRequest: {
case `${KeyringRpcMethod.RejectRequest}`: {
if (keyring.rejectRequest === undefined) {
throw new MethodNotSupportedError(request.method);
}
Expand Down
1 change: 1 addition & 0 deletions src/superstruct.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { expectAssignable, expectNotAssignable } from 'tsd';

import { exactOptional, object } from '.';

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const exactOptionalObject = object({
a: number(),
b: optional(string()),
Expand Down
1 change: 1 addition & 0 deletions src/superstruct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type {
Simplify,
} from '@metamask/superstruct';

// eslint-disable-next-line @typescript-eslint/no-unused-vars
declare const ExactOptionalSymbol: unique symbol;

export type ExactOptionalTag = {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const UrlStruct = define<string>('Url', (value: unknown) => {
try {
const url = new URL(value as string);
return url.protocol === 'http:' || url.protocol === 'https:';
} catch (_) {
} catch {
return false;
}
});
Expand Down
Loading
Loading