Skip to content

Commit cb10ee6

Browse files
ccharlydanroc
andauthored
chore: update lint tools versions + use ts 5 (#55)
Updating `eslint` and other similar packages. --------- Co-authored-by: Daniel Rocha <[email protected]>
1 parent c843ccf commit cb10ee6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+869
-1222
lines changed

jest.config.packages.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ module.exports = {
141141
// runner: "jest-runner",
142142

143143
// The paths to modules that run some code to configure or set up the testing environment before each test
144-
setupFiles: ['../../tests/setup.ts'],
144+
// setupFiles: ['../../tests/setup.ts'],
145145

146146
// A list of paths to modules that run some code to configure or set up the testing framework before each test
147147
// setupFilesAfterEnv: ['../../tests/setupAfterEnv/index.ts'],

package.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,36 +48,36 @@
4848
"@lavamoat/allow-scripts": "^3.2.1",
4949
"@lavamoat/preinstall-always-fail": "^2.1.0",
5050
"@metamask/create-release-branch": "^3.0.1",
51-
"@metamask/eslint-config": "^12.2.0",
52-
"@metamask/eslint-config-jest": "^12.1.0",
53-
"@metamask/eslint-config-nodejs": "^12.1.0",
54-
"@metamask/eslint-config-typescript": "^12.1.0",
51+
"@metamask/eslint-config": "^13.0.0",
52+
"@metamask/eslint-config-jest": "^13.0.0",
53+
"@metamask/eslint-config-nodejs": "^13.0.0",
54+
"@metamask/eslint-config-typescript": "^13.0.0",
5555
"@npmcli/package-json": "^5.0.0",
5656
"@types/jest": "^29.5.12",
5757
"@types/node": "^20.12.12",
58-
"@typescript-eslint/eslint-plugin": "^5.43.0",
59-
"@typescript-eslint/parser": "^5.43.0",
58+
"@typescript-eslint/eslint-plugin": "^8.5.0",
59+
"@typescript-eslint/parser": "^8.5.0",
6060
"depcheck": "^1.4.7",
61-
"eslint": "^8.44.0",
61+
"eslint": "^8.55.0",
6262
"eslint-config-prettier": "^8.8.0",
63-
"eslint-plugin-import": "~2.26.0",
64-
"eslint-plugin-jest": "^27.2.2",
65-
"eslint-plugin-jsdoc": "^39.9.1",
66-
"eslint-plugin-n": "^15.7.0",
63+
"eslint-plugin-import-x": "^0.5.3",
64+
"eslint-plugin-jest": "^27.9.0",
65+
"eslint-plugin-jsdoc": "^47.0.2",
66+
"eslint-plugin-n": "^16.6.2",
6767
"eslint-plugin-prettier": "^4.2.1",
68-
"eslint-plugin-promise": "^6.1.1",
68+
"eslint-plugin-promise": "^6.6.0",
6969
"execa": "^5.0.0",
7070
"jest": "^29.5.0",
7171
"jest-it-up": "^3.1.0",
7272
"jest-silent-reporter": "^0.5.0",
7373
"prettier": "^2.8.8",
74-
"prettier-plugin-packagejson": "^2.3.0",
75-
"rimraf": "^5.0.7",
74+
"prettier-plugin-packagejson": "^2.5.2",
75+
"rimraf": "^5.0.10",
7676
"syncpack": "^13.0.0",
7777
"ts-jest": "^29.0.5",
7878
"ts-node": "^10.9.2",
7979
"typedoc": "^0.25.13",
80-
"typescript": "~4.8.4"
80+
"typescript": "~5.4.5"
8181
},
8282
"packageManager": "[email protected]",
8383
"engines": {

packages/keyring-api/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@
5656
"depcheck": "^1.4.7",
5757
"jest": "^29.5.0",
5858
"jest-it-up": "^3.1.0",
59-
"rimraf": "^5.0.7",
59+
"rimraf": "^5.0.10",
6060
"ts-jest": "^29.0.5",
6161
"ts-node": "^10.9.2",
6262
"tsd": "^0.31.0",
6363
"typedoc": "^0.25.13",
64-
"typescript": "~4.8.4"
64+
"typescript": "~5.4.5"
6565
},
6666
"peerDependencies": {
6767
"@metamask/providers": "^17.2.0"

packages/keyring-api/src/KeyringClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export type Sender = {
3535
};
3636

3737
export class KeyringClient implements Keyring {
38-
#sender: Sender;
38+
readonly #sender: Sender;
3939

4040
/**
4141
* Create a new instance of `KeyringClient`.

packages/keyring-api/src/KeyringSnapRpcClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import { KeyringClient } from './KeyringClient';
1010
* to a snap through the snap JSON-RPC API.
1111
*/
1212
export class SnapRpcSender implements Sender {
13-
#origin: string;
13+
readonly #origin: string;
1414

15-
#provider: MetaMaskInpageProvider;
15+
readonly #provider: MetaMaskInpageProvider;
1616

1717
/**
1818
* Create a new instance of `SnapRpcSender`.

packages/keyring-api/src/api/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ export * from './account';
22
export * from './balance';
33
export * from './caip';
44
export * from './export';
5-
export * from './keyring';
5+
export type * from './keyring';
66
export * from './request';
77
export * from './response';
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import type { BtcP2wpkhAccount } from './types';
12
import type { KeyringAccount } from '../api';
23
import type { Extends } from '../utils';
34
import { expectTrue } from '../utils';
4-
import type { BtcP2wpkhAccount } from './types';
55

66
// `BtcP2wpkhAccount` extends `KeyringAccount`
77
expectTrue<Extends<BtcP2wpkhAccount, KeyringAccount>>();

packages/keyring-api/src/eth/erc4337/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { EthAddressStruct, EthBytesStruct, EthUint256Struct } from '../types';
66

77
/**
88
* Struct of a UserOperation as defined by ERC-4337.
9+
*
910
* @see https://eips.ethereum.org/EIPS/eip-4337#definitions
1011
*/
1112
export const EthUserOperationStruct = object({

packages/keyring-api/src/eth/types.test-d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { expectAssignable, expectNotAssignable } from 'tsd';
22

3+
import type { EthEoaAccount, EthErc4337Account } from './types';
4+
import { EthMethod } from './types';
35
import type { KeyringAccount } from '../api';
46
import { EthAccountType } from '../api';
57
import type { Extends } from '../utils';
68
import { expectTrue } from '../utils';
7-
import type { EthEoaAccount, EthErc4337Account } from './types';
8-
import { EthMethod } from './types';
99

1010
const id = '606a7759-b0fb-48e4-9874-bab62ff8e7eb';
1111
const address = '0x000';

packages/keyring-api/src/eth/utils.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { BtcAccountType, EthAccountType } from '../api';
21
import { isEvmAccountType } from './utils';
2+
import { BtcAccountType, EthAccountType } from '../api';
33

44
describe('isEvmAccountType', () => {
55
it.each([

packages/keyring-api/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export * from './api';
22
export * from './btc';
3-
export * from './contexts';
3+
export type * from './contexts';
44
export * from './eth';
55
export * from './events';
66
export * from './internal';

packages/keyring-api/src/internal/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
} from '@metamask/superstruct';
1010
import { JsonStruct } from '@metamask/utils';
1111

12+
import { KeyringRpcMethod } from './rpc';
1213
import {
1314
BalanceStruct,
1415
CaipAssetTypeStruct,
@@ -19,7 +20,6 @@ import {
1920
} from '../api';
2021
import { object } from '../superstruct';
2122
import { UuidStruct } from '../utils';
22-
import { KeyringRpcMethod } from './rpc';
2323

2424
const CommonHeader = {
2525
jsonrpc: literal('2.0'),
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from './EthKeyring';
1+
export type * from './EthKeyring';

packages/keyring-api/src/internal/events.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { is } from '@metamask/superstruct';
22

3-
import { EthAccountType } from '../api';
4-
import { KeyringEvent } from '../events';
53
import {
64
AccountCreatedEventStruct,
75
AccountDeletedEventStruct,
86
AccountUpdatedEventStruct,
97
RequestApprovedEventStruct,
108
RequestRejectedEventStruct,
119
} from './events';
10+
import { EthAccountType } from '../api';
11+
import { KeyringEvent } from '../events';
1212

1313
describe('events', () => {
1414
describe('AccountCreatedEventStruct', () => {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export * from './api';
2-
export * from './eth';
2+
export type * from './eth';
33
export * from './events';
44
export * from './rpc';
55
export * from './types';

packages/keyring-api/src/internal/types.ts

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,31 +27,20 @@ export const InternalAccountMetadataStruct = object({
2727
}),
2828
});
2929

30-
/**
31-
* Creates an `InternalAccount` from an existing account `superstruct` object.
32-
*
33-
* @param accountStruct - An account `superstruct` object.
34-
* @returns The `InternalAccount` associated to `accountStruct`.
35-
*/
36-
function asInternalAccountStruct<Account, AccountSchema>(
37-
accountStruct: Struct<Account, AccountSchema>,
38-
) {
39-
return object({
40-
...accountStruct.schema,
41-
...InternalAccountMetadataStruct.schema,
42-
});
43-
}
44-
45-
export const InternalEthEoaAccountStruct =
46-
asInternalAccountStruct(EthEoaAccountStruct);
30+
export const InternalEthEoaAccountStruct = object({
31+
...EthEoaAccountStruct.schema,
32+
...InternalAccountMetadataStruct.schema,
33+
});
4734

48-
export const InternalEthErc4337AccountStruct = asInternalAccountStruct(
49-
EthErc4337AccountStruct,
50-
);
35+
export const InternalEthErc4337AccountStruct = object({
36+
...EthErc4337AccountStruct.schema,
37+
...InternalAccountMetadataStruct.schema,
38+
});
5139

52-
export const InternalBtcP2wpkhAccountStruct = asInternalAccountStruct(
53-
BtcP2wpkhAccountStruct,
54-
);
40+
export const InternalBtcP2wpkhAccountStruct = object({
41+
...BtcP2wpkhAccountStruct.schema,
42+
...InternalAccountMetadataStruct.schema,
43+
});
5544

5645
export type InternalEthEoaAccount = Infer<typeof InternalEthEoaAccountStruct>;
5746

packages/keyring-api/src/rpc-handler.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,22 @@ async function dispatchRequest(
4747
assert(request, JsonRpcRequestStruct);
4848

4949
switch (request.method) {
50-
case KeyringRpcMethod.ListAccounts: {
50+
case `${KeyringRpcMethod.ListAccounts}`: {
5151
assert(request, ListAccountsRequestStruct);
5252
return keyring.listAccounts();
5353
}
5454

55-
case KeyringRpcMethod.GetAccount: {
55+
case `${KeyringRpcMethod.GetAccount}`: {
5656
assert(request, GetAccountRequestStruct);
5757
return keyring.getAccount(request.params.id);
5858
}
5959

60-
case KeyringRpcMethod.CreateAccount: {
60+
case `${KeyringRpcMethod.CreateAccount}`: {
6161
assert(request, CreateAccountRequestStruct);
6262
return keyring.createAccount(request.params.options);
6363
}
6464

65-
case KeyringRpcMethod.GetAccountBalances: {
65+
case `${KeyringRpcMethod.GetAccountBalances}`: {
6666
if (keyring.getAccountBalances === undefined) {
6767
throw new MethodNotSupportedError(request.method);
6868
}
@@ -73,62 +73,62 @@ async function dispatchRequest(
7373
);
7474
}
7575

76-
case KeyringRpcMethod.FilterAccountChains: {
76+
case `${KeyringRpcMethod.FilterAccountChains}`: {
7777
assert(request, FilterAccountChainsStruct);
7878
return keyring.filterAccountChains(
7979
request.params.id,
8080
request.params.chains,
8181
);
8282
}
8383

84-
case KeyringRpcMethod.UpdateAccount: {
84+
case `${KeyringRpcMethod.UpdateAccount}`: {
8585
assert(request, UpdateAccountRequestStruct);
8686
return keyring.updateAccount(request.params.account);
8787
}
8888

89-
case KeyringRpcMethod.DeleteAccount: {
89+
case `${KeyringRpcMethod.DeleteAccount}`: {
9090
assert(request, DeleteAccountRequestStruct);
9191
return keyring.deleteAccount(request.params.id);
9292
}
9393

94-
case KeyringRpcMethod.ExportAccount: {
94+
case `${KeyringRpcMethod.ExportAccount}`: {
9595
if (keyring.exportAccount === undefined) {
9696
throw new MethodNotSupportedError(request.method);
9797
}
9898
assert(request, ExportAccountRequestStruct);
9999
return keyring.exportAccount(request.params.id);
100100
}
101101

102-
case KeyringRpcMethod.ListRequests: {
102+
case `${KeyringRpcMethod.ListRequests}`: {
103103
if (keyring.listRequests === undefined) {
104104
throw new MethodNotSupportedError(request.method);
105105
}
106106
assert(request, ListRequestsRequestStruct);
107107
return keyring.listRequests();
108108
}
109109

110-
case KeyringRpcMethod.GetRequest: {
110+
case `${KeyringRpcMethod.GetRequest}`: {
111111
if (keyring.getRequest === undefined) {
112112
throw new MethodNotSupportedError(request.method);
113113
}
114114
assert(request, GetRequestRequestStruct);
115115
return keyring.getRequest(request.params.id);
116116
}
117117

118-
case KeyringRpcMethod.SubmitRequest: {
118+
case `${KeyringRpcMethod.SubmitRequest}`: {
119119
assert(request, SubmitRequestRequestStruct);
120120
return keyring.submitRequest(request.params);
121121
}
122122

123-
case KeyringRpcMethod.ApproveRequest: {
123+
case `${KeyringRpcMethod.ApproveRequest}`: {
124124
if (keyring.approveRequest === undefined) {
125125
throw new MethodNotSupportedError(request.method);
126126
}
127127
assert(request, ApproveRequestRequestStruct);
128128
return keyring.approveRequest(request.params.id, request.params.data);
129129
}
130130

131-
case KeyringRpcMethod.RejectRequest: {
131+
case `${KeyringRpcMethod.RejectRequest}`: {
132132
if (keyring.rejectRequest === undefined) {
133133
throw new MethodNotSupportedError(request.method);
134134
}

packages/keyring-api/src/superstruct.test-d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { expectAssignable, expectNotAssignable } from 'tsd';
44

55
import { exactOptional, object } from '.';
66

7+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
78
const exactOptionalObject = object({
89
a: number(),
910
b: optional(string()),

packages/keyring-api/src/superstruct.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import type {
1414
Simplify,
1515
} from '@metamask/superstruct';
1616

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

1920
export type ExactOptionalTag = {

packages/keyring-api/src/utils/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const UrlStruct = define<string>('Url', (value: unknown) => {
2020
try {
2121
const url = new URL(value as string);
2222
return url.protocol === 'http:' || url.protocol === 'https:';
23-
} catch (_) {
23+
} catch {
2424
return false;
2525
}
2626
});

packages/keyring-eth-hd/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
const { HDKey } = require('ethereum-cryptography/hdkey');
2-
const { keccak256 } = require('ethereum-cryptography/keccak');
3-
const { bytesToHex } = require('ethereum-cryptography/utils');
41
const {
52
privateToPublic,
63
publicToAddress,
74
ecsign,
85
arrToBufArr,
96
bufferToHex,
107
} = require('@ethereumjs/util');
11-
const bip39 = require('@metamask/scure-bip39');
12-
const { wordlist } = require('@metamask/scure-bip39/dist/wordlists/english');
138
const {
149
concatSig,
1510
decrypt,
@@ -19,7 +14,12 @@ const {
1914
signTypedData,
2015
SignTypedDataVersion,
2116
} = require('@metamask/eth-sig-util');
17+
const bip39 = require('@metamask/scure-bip39');
18+
const { wordlist } = require('@metamask/scure-bip39/dist/wordlists/english');
2219
const { assertIsHexString, remove0x } = require('@metamask/utils');
20+
const { HDKey } = require('ethereum-cryptography/hdkey');
21+
const { keccak256 } = require('ethereum-cryptography/keccak');
22+
const { bytesToHex } = require('ethereum-cryptography/utils');
2323

2424
// Options:
2525
const hdPathString = `m/44'/60'/0'/0`;

0 commit comments

Comments
 (0)