From aa6526d68a49f264feb6e003daa515cc59614cbd Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed, 22 Feb 2023 11:36:38 -0300 Subject: [PATCH 001/109] Refactor to TS --- index.js => index.ts | 259 ++++++++++++++++++++++++++----------------- package.json | 1 + yarn.lock | 36 ++++++ 3 files changed, 192 insertions(+), 104 deletions(-) rename index.js => index.ts (74%) diff --git a/index.js b/index.ts similarity index 74% rename from index.js rename to index.ts index eeb23c72..817d3ee2 100644 --- a/index.js +++ b/index.ts @@ -1,3 +1,5 @@ +import { Hex, Keyring, Transaction, SignedTransaction, Eip1024EncryptedData } from '@metamask/utils'; + const encryptor = require('@metamask/browser-passworder'); const HdKeyring = require('@metamask/eth-hd-keyring'); const { normalize: normalizeAddress } = require('@metamask/eth-sig-util'); @@ -7,23 +9,28 @@ const SimpleKeyring = require('@metamask/eth-simple-keyring'); const { EventEmitter } = require('events'); const ObservableStore = require('obs-store'); +type State = any; +type ExtendedKeyring = Keyring & { + generateRandomMnemonic: () => string; +} + const defaultKeyringBuilders = [ keyringBuilderFactory(SimpleKeyring), keyringBuilderFactory(HdKeyring), ]; -const KEYRINGS_TYPE_MAP = { - HD_KEYRING: 'HD Key Tree', - SIMPLE_KEYRING: 'Simple Key Pair', +const enum KEYRINGS_TYPE_MAP { + HD_KEYRING = 'HD Key Tree', + SIMPLE_KEYRING = 'Simple Key Pair', }; /** * Strip the hex prefix from an address, if present. * - * @param {string} address - The address that might be hex prefixed. - * @returns {string} The address without a hex prefix. + * @param address - The address that might be hex prefixed. + * @returns The address without a hex prefix. */ -function stripHexPrefix(address) { +function stripHexPrefix(address: Hex | string): string { if (address.startsWith('0x')) { return address.slice(2); } @@ -89,7 +96,7 @@ class KeyringController extends EventEmitter { * @param {string} password - The password to encrypt the vault with. * @returns {Promise} A Promise that resolves to the state. */ - async createNewVaultAndKeychain(password) { + async createNewVaultAndKeychain(password: string): Promise { this.password = password; await this.createFirstKeyTree(); @@ -110,7 +117,7 @@ class KeyringController extends EventEmitter { * either as a string or Uint8Array. * @returns {Promise} A Promise that resolves to the state. */ - async createNewVaultAndRestore(password, seedPhrase) { + async createNewVaultAndRestore(password: string, seedPhrase: Uint8Array | string): Promise { if (typeof password !== 'string') { throw new Error('Password must be text.'); } @@ -121,6 +128,11 @@ class KeyringController extends EventEmitter { mnemonic: seedPhrase, numberOfAccounts: 1, }); + + if (!keyring) { + throw new Error('KeyringController - No keyring found'); + } + const [firstAccount] = await keyring.getAccounts(); if (!firstAccount) { @@ -137,7 +149,7 @@ class KeyringController extends EventEmitter { * @fires KeyringController#lock * @returns {Promise} A Promise that resolves to the state. */ - async setLocked() { + async setLocked(): Promise { delete this.password; // set locked @@ -167,7 +179,7 @@ class KeyringController extends EventEmitter { * @param {string} password - The keyring controller password. * @returns {Promise} A Promise that resolves to the state. */ - async submitPassword(password) { + async submitPassword(password: string): Promise { this.keyrings = await this.unlockKeyrings(password); this.setUnlocked(); @@ -185,7 +197,7 @@ class KeyringController extends EventEmitter { * @param {string} encryptionSalt - The salt used to generate the last key. * @returns {Promise} A Promise that resolves to the state. */ - async submitEncryptionKey(encryptionKey, encryptionSalt) { + async submitEncryptionKey(encryptionKey: string, encryptionSalt: string): Promise { this.keyrings = await this.unlockKeyrings( undefined, encryptionKey, @@ -203,7 +215,7 @@ class KeyringController extends EventEmitter { * * @param {string} password - The vault password. */ - async verifyPassword(password) { + async verifyPassword(password: string): Promise { const encryptedVault = this.store.getState().vault; if (!encryptedVault) { throw new Error('Cannot unlock without a previous vault.'); @@ -220,16 +232,20 @@ class KeyringController extends EventEmitter { * All Keyring classes implement a unique `type` string, * and this is used to retrieve them from the keyringBuilders array. * - * @param {string} type - The type of keyring to add. - * @param {object} opts - The constructor options for the keyring. - * @returns {Promise} The new keyring. + * @param type - The type of keyring to add. + * @param opts - The constructor options for the keyring. + * @returns The new keyring. */ - async addNewKeyring(type, opts) { - const keyring = await this._newKeyring(type, opts); + async addNewKeyring(type: string, opts?: Record): Promise { + const keyring = await this.#newKeyring(type, opts); + + if (!keyring) { + throw new Error('KeyringController - No keyring found'); + } if ((!opts || !opts.mnemonic) && type === KEYRINGS_TYPE_MAP.HD_KEYRING) { keyring.generateRandomMnemonic(); - await keyring.addAccounts(); + await keyring.addAccounts(1); } const accounts = await keyring.getAccounts(); @@ -249,15 +265,15 @@ class KeyringController extends EventEmitter { * Loops through the keyrings and removes the ones with empty accounts * (usually after removing the last / only account) from a keyring. */ - async removeEmptyKeyrings() { - const validKeyrings = []; + async removeEmptyKeyrings(): Promise { + const validKeyrings: ExtendedKeyring[] = []; // Since getAccounts returns a Promise // We need to wait to hear back form each keyring // in order to decide which ones are now valid (accounts.length > 0) await Promise.all( - this.keyrings.map(async (keyring) => { + this.keyrings.map(async (keyring: ExtendedKeyring) => { const accounts = await keyring.getAccounts(); if (accounts.length > 0) { validKeyrings.push(keyring); @@ -273,18 +289,18 @@ class KeyringController extends EventEmitter { * * Only supports 'Simple Key Pair'. * - * @param {string} type - The key pair type to check for. - * @param {Array} newAccountArray - Array of new accounts. - * @returns {Promise>} The account, if no duplicate is found. + * @param type - The key pair type to check for. + * @param newAccountArray - Array of new accounts. + * @returns The account, if no duplicate is found. */ - async checkForDuplicate(type, newAccountArray) { + async checkForDuplicate(type: string, newAccountArray: string[]): Promise { const accounts = await this.getAccounts(); switch (type) { case KEYRINGS_TYPE_MAP.SIMPLE_KEYRING: { const isIncluded = Boolean( accounts.find( - (key) => + (key: string) => key === newAccountArray[0] || key === stripHexPrefix(newAccountArray[0]), ), @@ -310,12 +326,12 @@ class KeyringController extends EventEmitter { * Calls the `addAccounts` method on the given keyring, * and then saves those changes. * - * @param {Keyring} selectedKeyring - The currently selected keyring. - * @returns {Promise} A Promise that resolves to the state. + * @param selectedKeyring - The currently selected keyring. + * @returns A Promise that resolves to the state. */ - async addNewAccount(selectedKeyring) { + async addNewAccount(selectedKeyring: ExtendedKeyring): Promise { const accounts = await selectedKeyring.addAccounts(1); - accounts.forEach((hexAccount) => { + accounts.forEach((hexAccount: string) => { this.emit('newAccount', hexAccount); }); @@ -331,11 +347,15 @@ class KeyringController extends EventEmitter { * * Returns a Promise that may resolve with the private key string. * - * @param {string} address - The address of the account to export. - * @returns {Promise} The private key of the account. + * @param address - The address of the account to export. + * @returns The private key of the account. */ - async exportAccount(address) { + async exportAccount(address: string): Promise { const keyring = await this.getKeyringForAccount(address); + if (!keyring.exportAccount) { + throw new Error(`The keyring for address ${address} does not support the method exportAccount.`); + } + return await keyring.exportAccount(normalizeAddress(address)); } @@ -345,10 +365,10 @@ class KeyringController extends EventEmitter { * Removes a specific account from a keyring * If the account is the last/only one then it also removes the keyring. * - * @param {string} address - The address of the account to remove. - * @returns {Promise} A Promise that resolves if the operation was successful. + * @param address - The address of the account to remove. + * @returns A promise that resolves if the operation was successful. */ - async removeAccount(address) { + async removeAccount(address: Hex): Promise { const keyring = await this.getKeyringForAccount(address); // Not all the keyrings support this, so we have to check @@ -380,15 +400,19 @@ class KeyringController extends EventEmitter { * * Signs an Ethereum transaction object. * - * @param {object} ethTx - The transaction to sign. - * @param {string} _fromAddress - The transaction 'from' address. - * @param {object} opts - Signing options. - * @returns {Promise} The signed transaction object. + * @param ethTx - The transaction to sign. + * @param inputFromAddress - The transaction 'from' address. + * @param opts - Signing options. + * @returns The signed transaction object. */ - async signTransaction(ethTx, _fromAddress, opts = {}) { - const fromAddress = normalizeAddress(_fromAddress); - const keyring = await this.getKeyringForAccount(fromAddress); - return await keyring.signTransaction(fromAddress, ethTx, opts); + async signTransaction(ethTx: Transaction, _address: string | Hex, opts: Record = {}): Promise { + const address = normalizeAddress(_address); + const keyring = await this.getKeyringForAccount(address); + if (!keyring.signTransaction) { + throw new Error(`The keyring for address ${address} does not support the method signTransaction.`); + } + + return await keyring.signTransaction(address, ethTx, opts); } /** @@ -396,13 +420,17 @@ class KeyringController extends EventEmitter { * * Attempts to sign the provided message parameters. * - * @param {object} msgParams - The message parameters to sign. - * @param {object} opts - Additional signing options. - * @returns {Promise} The raw signature. + * @param msgParams - The message parameters to sign. + * @param opts - Additional signing options. + * @returns The raw signature. */ - async signMessage(msgParams, opts = {}) { + async signMessage(msgParams: { from: Hex | string; data: string }, opts: Record = {}) { const address = normalizeAddress(msgParams.from); const keyring = await this.getKeyringForAccount(address); + if (!keyring.signMessage) { + throw new Error(`The keyring for address ${address} does not support the method signMessage.`); + } + return await keyring.signMessage(address, msgParams.data, opts); } @@ -412,13 +440,17 @@ class KeyringController extends EventEmitter { * Attempts to sign the provided message parameters. * Prefixes the hash before signing per the personal sign expectation. * - * @param {object} msgParams - The message parameters to sign. - * @param {object} opts - Additional signing options. - * @returns {Promise} The raw signature. + * @param msgParams - The message parameters to sign. + * @param opts - Additional signing options. + * @returns The raw signature. */ - async signPersonalMessage(msgParams, opts = {}) { + async signPersonalMessage(msgParams: { from: Hex | string; data: Hex }, opts: Record = {}): Promise { const address = normalizeAddress(msgParams.from); const keyring = await this.getKeyringForAccount(address); + if (!keyring.signPersonalMessage) { + throw new Error(`The keyring for address ${address} does not support the method signPersonalMessage.`); + } + return await keyring.signPersonalMessage(address, msgParams.data, opts); } @@ -427,13 +459,17 @@ class KeyringController extends EventEmitter { * * Get encryption public key for using in encrypt/decrypt process. * - * @param {object} address - The address to get the encryption public key for. - * @param {object} opts - Additional encryption options. - * @returns {Promise} The public key. + * @param address - The address to get the encryption public key for. + * @param opts - Additional encryption options. + * @returns The public key. */ - async getEncryptionPublicKey(address, opts = {}) { + async getEncryptionPublicKey(address: string | Hex, opts: Record = {}): Promise { const normalizedAddress = normalizeAddress(address); const keyring = await this.getKeyringForAccount(address); + if (!keyring.getEncryptionPublicKey) { + throw new Error(`The keyring for address ${address} does not support the method getEncryptionPublicKey.`); + } + return await keyring.getEncryptionPublicKey(normalizedAddress, opts); } @@ -442,27 +478,35 @@ class KeyringController extends EventEmitter { * * Attempts to decrypt the provided message parameters. * - * @param {object} msgParams - The decryption message parameters. - * @param {object} opts - Additional decryption options. - * @returns {Promise} The raw decryption result. + * @param msgParams - The decryption message parameters. + * @param opts - Additional decryption options. + * @returns The raw decryption result. */ - async decryptMessage(msgParams, opts = {}) { + async decryptMessage(msgParams: { from: Hex | string; data: Eip1024EncryptedData }): Promise { const address = normalizeAddress(msgParams.from); const keyring = await this.getKeyringForAccount(address); - return keyring.decryptMessage(address, msgParams.data, opts); + if (!keyring.decryptMessage) { + throw new Error(`The keyring for address ${address} does not support the method decryptMessage.`); + } + + return keyring.decryptMessage(address, msgParams.data); } /** * Sign Typed Data. * * @see {@link https://github.com/ethereum/EIPs/pull/712#issuecomment-329988454|EIP712}. - * @param {object} msgParams - The message parameters to sign. + * @param msgParams - The message parameters to sign. * @param {object} opts - Additional signing options. * @returns {Promise} The raw signature. */ - async signTypedMessage(msgParams, opts = { version: 'V1' }) { + async signTypedMessage(msgParams: { from: Hex | string; data: Eip1024EncryptedData }, opts = { version: 'V1' }): Promise { const address = normalizeAddress(msgParams.from); const keyring = await this.getKeyringForAccount(address); + if (!keyring.signTypedData) { + throw new Error(`The keyring for address ${address} does not support the method signTypedData.`); + } + return keyring.signTypedData(address, msgParams.data, opts); } @@ -473,9 +517,13 @@ class KeyringController extends EventEmitter { * @param {string} origin - The origin for the app key. * @returns {string} The app key address. */ - async getAppKeyAddress(_address, origin) { + async getAppKeyAddress(_address: string, origin: string): Promise { const address = normalizeAddress(_address); const keyring = await this.getKeyringForAccount(address); + if (!keyring.getAppKeyAddress) { + throw new Error(`The keyring for address ${_address} does not support the method getAppKeyAddress.`); + } + return keyring.getAppKeyAddress(address, origin); } @@ -486,14 +534,14 @@ class KeyringController extends EventEmitter { * @param {string} origin - The origin for the app key. * @returns {string} The app key private key. */ - async exportAppKeyForAddress(_address, origin) { + async exportAppKeyForAddress(_address: string, origin: string): Promise { const address = normalizeAddress(_address); const keyring = await this.getKeyringForAccount(address); // The "in" operator is typically restricted because it also checks inherited properties, // which can be unexpected for plain objects. We're allowing it here because `keyring` is not // a plain object, and we explicitly want to include inherited methods in this check. // eslint-disable-next-line no-restricted-syntax - if (!('exportAccount' in keyring)) { + if (!keyring.exportAccount) { throw new Error( `The keyring for address ${_address} does not support exporting.`, ); @@ -517,10 +565,14 @@ class KeyringController extends EventEmitter { * * @returns {Promise} A promise that resolves if the operation was successful. */ - async createFirstKeyTree() { + async createFirstKeyTree(): Promise { this.clearKeyrings(); const keyring = await this.addNewKeyring(KEYRINGS_TYPE_MAP.HD_KEYRING); + if (!keyring) { + throw new Error('KeyringController - No keyring found'); + } + const [firstAccount] = await keyring.getAccounts(); if (!firstAccount) { throw new Error('KeyringController - No account found on keychain.'); @@ -612,12 +664,12 @@ class KeyringController extends EventEmitter { * Attempts to unlock the persisted encrypted storage, * initializing the persisted keyrings to RAM. * - * @param {string} password - The keyring controller password. - * @param {string} encryptionKey - An exported key string to unlock keyrings with. - * @param {string} encryptionSalt - The salt used to encrypt the vault. - * @returns {Promise>} The keyrings. + * @param password - The keyring controller password. + * @param encryptionKey - An exported key string to unlock keyrings with. + * @param encryptionSalt - The salt used to encrypt the vault. + * @returns The keyrings array. */ - async unlockKeyrings(password, encryptionKey, encryptionSalt) { + async unlockKeyrings(password: string | undefined, encryptionKey?: string, encryptionSalt?: string): Promise { const encryptedVault = this.store.getState().vault; if (!encryptedVault) { throw new Error('Cannot unlock without a previous vault.'); @@ -674,10 +726,10 @@ class KeyringController extends EventEmitter { * On success, updates the memStore keyrings and returns the resulting * keyring instance. * - * @param {object} serialized - The serialized keyring. - * @returns {Promise} The deserialized keyring. + * @param serialized - The serialized keyring. + * @returns The deserialized keyring. */ - async restoreKeyring(serialized) { + async restoreKeyring(serialized): Promise { const keyring = await this._restoreKeyring(serialized); if (keyring) { await this._updateMemStoreKeyrings(); @@ -691,13 +743,13 @@ class KeyringController extends EventEmitter { * Attempts to initialize a new keyring from the provided serialized payload. * On success, returns the resulting keyring instance. * - * @param {object} serialized - The serialized keyring. - * @returns {Promise} The deserialized keyring or undefined if the keyring type is unsupported. + * @param serialized - The serialized keyring. + * @returns The deserialized keyring or undefined if the keyring type is unsupported. */ - async _restoreKeyring(serialized) { + async _restoreKeyring(serialized): Promise { const { type, data } = serialized; - const keyring = await this._newKeyring(type, data); + const keyring = await this.#newKeyring(type, data); if (!keyring) { this._unsupportedKeyrings.push(serialized); return undefined; @@ -717,10 +769,10 @@ class KeyringController extends EventEmitter { * matches the provided `type`, * returning it if it exists. * - * @param {string} type - The type whose class to get. - * @returns {Keyring|undefined} The class, if it exists. + * @param type - The type whose class to get. + * @returns The class, if it exists. */ - getKeyringBuilderForType(type) { + getKeyringBuilderForType(type: string): any { return this.keyringBuilders.find( (keyringBuilder) => keyringBuilder.type === type, ); @@ -731,10 +783,10 @@ class KeyringController extends EventEmitter { * * Gets all keyrings of the given type. * - * @param {string} type - The keyring types to retrieve. - * @returns {Array} The keyrings. + * @param type - The keyring types to retrieve. + * @returns Keyrings matching the specified type. */ - getKeyringsByType(type) { + getKeyringsByType(type: string): ExtendedKeyring[] { return this.keyrings.filter((keyring) => keyring.type === type); } @@ -744,9 +796,9 @@ class KeyringController extends EventEmitter { * Returns the public addresses of all current accounts * managed by all currently unlocked keyrings. * - * @returns {Promise>} The array of accounts. + * @returns The array of accounts. */ - async getAccounts() { + async getAccounts(): Promise { const keyrings = this.keyrings || []; const keyringArrays = await Promise.all( @@ -765,10 +817,10 @@ class KeyringController extends EventEmitter { * Returns the currently initialized keyring that manages * the specified `address` if one exists. * - * @param {string} address - An account address. - * @returns {Promise} The keyring of the account, if it exists. + * @param address - An account address. + * @returns The keyring of the account, if it exists. */ - async getKeyringForAccount(address) { + async getKeyringForAccount(address: string): Promise { const hexed = normalizeAddress(address); const candidates = await Promise.all( @@ -781,6 +833,7 @@ class KeyringController extends EventEmitter { const accounts = candidate[1].map(normalizeAddress); return accounts.includes(hexed); }); + if (winners && winners.length > 0) { return winners[0][0]; } @@ -807,7 +860,7 @@ class KeyringController extends EventEmitter { * @param {Keyring} keyring - The keyring to display. * @returns {Promise} A keyring display object, with type and accounts properties. */ - async displayForKeyring(keyring) { + async displayForKeyring(keyring): Promise<{ type: string, accounts: string[]}> { const accounts = await keyring.getAccounts(); return { @@ -822,9 +875,7 @@ class KeyringController extends EventEmitter { * Deallocates all currently managed keyrings and accounts. * Used before initializing a new vault. */ - - /* eslint-disable require-await */ - async clearKeyrings() { + async clearKeyrings(): Promise { // clear keyrings from memory this.keyrings = []; this.memStore.updateState({ @@ -837,7 +888,7 @@ class KeyringController extends EventEmitter { * * Updates the in-memory keyrings, without persisting. */ - async _updateMemStoreKeyrings() { + async _updateMemStoreKeyrings(): Promise { const keyrings = await Promise.all( this.keyrings.map(this.displayForKeyring), ); @@ -851,7 +902,7 @@ class KeyringController extends EventEmitter { * * @fires KeyringController#unlock */ - setUnlocked() { + setUnlocked(): void { this.memStore.updateState({ isUnlocked: true }); this.emit('unlock'); } @@ -861,9 +912,9 @@ class KeyringController extends EventEmitter { * * Forget hardware and update memorized state. * - * @param {Keyring} keyring - The keyring to forget. + * @param keyring - The keyring to forget. */ - forgetKeyring(keyring) { + forgetKeyring(keyring: ExtendedKeyring & { forgetDevice?: () => void}) { if (keyring.forgetDevice) { keyring.forgetDevice(); this.persistAllKeyrings(); @@ -879,11 +930,11 @@ class KeyringController extends EventEmitter { * * The keyring instantiated is of the given `type`. * - * @param {string} type - The type of keyring to add. - * @param {object} data - The data to restore a previously serialized keyring. - * @returns {Promise} The new keyring. + * @param type - The type of keyring to add. + * @param data - The data to restore a previously serialized keyring. + * @returns The new keyring. */ - async _newKeyring(type, data) { + async #newKeyring(type: string, data): Promise { const keyringBuilder = this.getKeyringBuilderForType(type); if (!keyringBuilder) { @@ -907,8 +958,8 @@ class KeyringController extends EventEmitter { * * Returns a builder function for `Keyring` with a `type` property. * - * @param {Keyring} Keyring - The Keyring class for the builder. - * @returns {Function} A builder function for the given Keyring. + * @param Keyring - The Keyring class for the builder. + * @returns A builder function for the given Keyring. */ function keyringBuilderFactory(Keyring) { const builder = () => new Keyring(); diff --git a/package.json b/package.json index 020af9d9..80ea3869 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "@metamask/eth-hd-keyring": "^6.0.0", "@metamask/eth-sig-util": "5.0.2", "@metamask/eth-simple-keyring": "^5.0.0", + "@metamask/utils": "4.0.0", "obs-store": "^4.0.3" }, "devDependencies": { diff --git a/yarn.lock b/yarn.lock index ad53bf56..3a751edb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -841,6 +841,7 @@ __metadata: "@metamask/eth-hd-keyring": ^6.0.0 "@metamask/eth-sig-util": 5.0.2 "@metamask/eth-simple-keyring": ^5.0.0 + "@metamask/utils": 4.0.0 eslint: ^8.29.0 eslint-config-prettier: ^8.5.0 eslint-plugin-import: ^2.26.0 @@ -893,6 +894,18 @@ __metadata: languageName: node linkType: hard +"@metamask/utils@npm:4.0.0": + version: 4.0.0 + resolution: "@metamask/utils@npm:4.0.0" + dependencies: + "@types/debug": ^4.1.7 + debug: ^4.3.4 + semver: ^7.3.8 + superstruct: ^1.0.3 + checksum: 6d4edca78fe1f66504ed5e5ca021a67f4b4e0893e86484c746b87039c2161c39d3b8bd8e4b9235ddfd023b2d76dd54210af94ec5550e27bc4ad9c0d7d5f3f231 + languageName: node + linkType: hard + "@noble/hashes@npm:1.1.2": version: 1.1.2 resolution: "@noble/hashes@npm:1.1.2" @@ -1118,6 +1131,15 @@ __metadata: languageName: node linkType: hard +"@types/debug@npm:^4.1.7": + version: 4.1.7 + resolution: "@types/debug@npm:4.1.7" + dependencies: + "@types/ms": "*" + checksum: 0a7b89d8ed72526858f0b61c6fd81f477853e8c4415bb97f48b1b5545248d2ae389931680b94b393b993a7cfe893537a200647d93defe6d87159b96812305adc + languageName: node + linkType: hard + "@types/glob@npm:^7.1.1": version: 7.1.3 resolution: "@types/glob@npm:7.1.3" @@ -1183,6 +1205,13 @@ __metadata: languageName: node linkType: hard +"@types/ms@npm:*": + version: 0.7.31 + resolution: "@types/ms@npm:0.7.31" + checksum: daadd354aedde024cce6f5aa873fefe7b71b22cd0e28632a69e8b677aeb48ae8caa1c60e5919bb781df040d116b01cb4316335167a3fc0ef6a63fa3614c0f6da + languageName: node + linkType: hard + "@types/node@npm:*": version: 13.9.1 resolution: "@types/node@npm:13.9.1" @@ -6208,6 +6237,13 @@ __metadata: languageName: node linkType: hard +"superstruct@npm:^1.0.3": + version: 1.0.3 + resolution: "superstruct@npm:1.0.3" + checksum: 761790bb111e6e21ddd608299c252f3be35df543263a7ebbc004e840d01fcf8046794c274bcb351bdf3eae4600f79d317d085cdbb19ca05803a4361840cc9bb1 + languageName: node + linkType: hard + "supports-color@npm:^5.3.0": version: 5.5.0 resolution: "supports-color@npm:5.5.0" From 192c48a4ea97a05468ec2b7b3bc6cdd604a47907 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 23 Feb 2023 11:11:10 -0300 Subject: [PATCH 002/109] Move files and update structure --- index.ts => src/KeyringController.ts | 227 ++++++++++++----------- src/index.ts | 1 + {test => src/test}/index.js | 0 {test => src/test}/lib/mock-encryptor.js | 0 {test => src/test}/lib/mock-keyring.js | 0 5 files changed, 115 insertions(+), 113 deletions(-) rename index.ts => src/KeyringController.ts (89%) create mode 100644 src/index.ts rename {test => src/test}/index.js (100%) rename {test => src/test}/lib/mock-encryptor.js (100%) rename {test => src/test}/lib/mock-keyring.js (100%) diff --git a/index.ts b/src/KeyringController.ts similarity index 89% rename from index.ts rename to src/KeyringController.ts index 817d3ee2..fff64ec3 100644 --- a/index.ts +++ b/src/KeyringController.ts @@ -12,7 +12,7 @@ const ObservableStore = require('obs-store'); type State = any; type ExtendedKeyring = Keyring & { generateRandomMnemonic: () => string; -} +}; const defaultKeyringBuilders = [ keyringBuilderFactory(SimpleKeyring), @@ -93,14 +93,14 @@ class KeyringController extends EventEmitter { * faucets that account on the testnet. * * @fires KeyringController#unlock - * @param {string} password - The password to encrypt the vault with. - * @returns {Promise} A Promise that resolves to the state. + * @param password - The password to encrypt the vault with. + * @returns A promise that resolves to the state. */ async createNewVaultAndKeychain(password: string): Promise { this.password = password; - await this.createFirstKeyTree(); - this.setUnlocked(); + await this.#createFirstKeyTree(); + this.#setUnlocked(); return this.fullUpdate(); } @@ -112,10 +112,10 @@ class KeyringController extends EventEmitter { * creates a new HD wallet from the given seed with 1 account. * * @fires KeyringController#unlock - * @param {string} password - The password to encrypt the vault with. - * @param {Uint8Array | string} seedPhrase - The BIP39-compliant seed phrase, + * @param password - The password to encrypt the vault with. + * @param seedPhrase - The BIP39-compliant seed phrase, * either as a string or Uint8Array. - * @returns {Promise} A Promise that resolves to the state. + * @returns A promise that resolves to the state. */ async createNewVaultAndRestore(password: string, seedPhrase: Uint8Array | string): Promise { if (typeof password !== 'string') { @@ -123,7 +123,7 @@ class KeyringController extends EventEmitter { } this.password = password; - await this.clearKeyrings(); + await this.#clearKeyrings(); const keyring = await this.addNewKeyring(KEYRINGS_TYPE_MAP.HD_KEYRING, { mnemonic: seedPhrase, numberOfAccounts: 1, @@ -138,7 +138,7 @@ class KeyringController extends EventEmitter { if (!firstAccount) { throw new Error('KeyringController - First Account not found.'); } - this.setUnlocked(); + this.#setUnlocked(); return this.fullUpdate(); } @@ -147,7 +147,7 @@ class KeyringController extends EventEmitter { * This method deallocates all secrets, and effectively locks MetaMask. * * @fires KeyringController#lock - * @returns {Promise} A Promise that resolves to the state. + * @returns A promise that resolves to the state. */ async setLocked(): Promise { delete this.password; @@ -176,13 +176,13 @@ class KeyringController extends EventEmitter { * (Pre MetaMask 3.0.0). * * @fires KeyringController#unlock - * @param {string} password - The keyring controller password. - * @returns {Promise} A Promise that resolves to the state. + * @param password - The keyring controller password. + * @returns A promise that resolves to the state. */ async submitPassword(password: string): Promise { - this.keyrings = await this.unlockKeyrings(password); + this.keyrings = await this.#unlockKeyrings(password); - this.setUnlocked(); + this.#setUnlocked(); return this.fullUpdate(); } @@ -193,17 +193,17 @@ class KeyringController extends EventEmitter { * into memory based on the vault and CryptoKey information. * * @fires KeyringController#unlock - * @param {string} encryptionKey - The encrypted key information used to decrypt the vault. - * @param {string} encryptionSalt - The salt used to generate the last key. - * @returns {Promise} A Promise that resolves to the state. + * @param encryptionKey - The encrypted key information used to decrypt the vault. + * @param encryptionSalt - The salt used to generate the last key. + * @returns A promise that resolves to the state. */ async submitEncryptionKey(encryptionKey: string, encryptionSalt: string): Promise { - this.keyrings = await this.unlockKeyrings( + this.keyrings = await this.#unlockKeyrings( undefined, encryptionKey, encryptionSalt, ); - this.setUnlocked(); + this.#setUnlocked(); return this.fullUpdate(); } @@ -252,7 +252,7 @@ class KeyringController extends EventEmitter { await this.checkForDuplicate(type, accounts); this.keyrings.push(keyring); - await this.persistAllKeyrings(); + await this.#persistAllKeyrings(); this.fullUpdate(); @@ -294,7 +294,7 @@ class KeyringController extends EventEmitter { * @returns The account, if no duplicate is found. */ async checkForDuplicate(type: string, newAccountArray: string[]): Promise { - const accounts = await this.getAccounts(); + const accounts = await this.#getAccounts(); switch (type) { case KEYRINGS_TYPE_MAP.SIMPLE_KEYRING: { @@ -335,7 +335,7 @@ class KeyringController extends EventEmitter { this.emit('newAccount', hexAccount); }); - await this.persistAllKeyrings(); + await this.#persistAllKeyrings(); return this.fullUpdate(); } @@ -387,7 +387,7 @@ class KeyringController extends EventEmitter { await this.removeEmptyKeyrings(); } - await this.persistAllKeyrings(); + await this.#persistAllKeyrings(); return this.fullUpdate(); } @@ -407,7 +407,7 @@ class KeyringController extends EventEmitter { */ async signTransaction(ethTx: Transaction, _address: string | Hex, opts: Record = {}): Promise { const address = normalizeAddress(_address); - const keyring = await this.getKeyringForAccount(address); + const keyring = await this.getKeyringForAccountgetKeyringForAccount(address); if (!keyring.signTransaction) { throw new Error(`The keyring for address ${address} does not support the method signTransaction.`); } @@ -497,8 +497,8 @@ class KeyringController extends EventEmitter { * * @see {@link https://github.com/ethereum/EIPs/pull/712#issuecomment-329988454|EIP712}. * @param msgParams - The message parameters to sign. - * @param {object} opts - Additional signing options. - * @returns {Promise} The raw signature. + * @param opts - Additional signing options. + * @returns The raw signature. */ async signTypedMessage(msgParams: { from: Hex | string; data: Eip1024EncryptedData }, opts = { version: 'V1' }): Promise { const address = normalizeAddress(msgParams.from); @@ -513,9 +513,9 @@ class KeyringController extends EventEmitter { /** * Gets the app key address for the given Ethereum address and origin. * - * @param {string} _address - The Ethereum address for the app key. - * @param {string} origin - The origin for the app key. - * @returns {string} The app key address. + * @param _address - The Ethereum address for the app key. + * @param origin - The origin for the app key. + * @returns The app key address. */ async getAppKeyAddress(_address: string, origin: string): Promise { const address = normalizeAddress(_address); @@ -530,9 +530,9 @@ class KeyringController extends EventEmitter { /** * Exports an app key private key for the given Ethereum address and origin. * - * @param {string} _address - The Ethereum address for the app key. - * @param {string} origin - The origin for the app key. - * @returns {string} The app key private key. + * @param _address - The Ethereum address for the app key. + * @param origin - The origin for the app key. + * @returns The app key private key. */ async exportAppKeyForAddress(_address: string, origin: string): Promise { const address = normalizeAddress(_address); @@ -549,9 +549,70 @@ class KeyringController extends EventEmitter { return keyring.exportAccount(address, { withAppKeyOrigin: origin }); } - // - // PRIVATE METHODS - // + /** + * Forget hardware keyring. + * + * Forget hardware and update memorized state. + * + * @param keyring - The keyring to forget. + */ + forgetKeyring(keyring: ExtendedKeyring & { forgetDevice?: () => void}) { + if (keyring.forgetDevice) { + keyring.forgetDevice(); + this.#persistAllKeyrings(); + } else { + throw new Error( + `KeyringController - keyring does not have method "forgetDevice", keyring type: ${keyring.type}`, + ); + } + } + + + /** + * Restore Keyring + * + * Attempts to initialize a new keyring from the provided serialized payload. + * On success, updates the memStore keyrings and returns the resulting + * keyring instance. + * + * @param serialized - The serialized keyring. + * @returns The deserialized keyring. + */ + async restoreKeyring(serialized): Promise { + const keyring = await this.#restoreKeyring(serialized); + if (keyring) { + await this._updateMemStoreKeyrings(); + } + return keyring; + } + + /** + * Get Keyrings by Type + * + * Gets all keyrings of the given type. + * + * @param type - The keyring types to retrieve. + * @returns Keyrings matching the specified type. + */ + getKeyringsByType(type: string): ExtendedKeyring[] { + return this.keyrings.filter((keyring) => keyring.type === type); + } + + /** + * Update memStore Keyrings + * + * Updates the in-memory keyrings, without persisting. + */ + async updateMemStoreKeyrings(): Promise { + const keyrings = await Promise.all( + this.keyrings.map(this.#displayForKeyring), + ); + return this.memStore.updateState({ keyrings }); + } + + // ======================= + // === Private Methods === + // ======================= /** * Create First Key Tree. @@ -563,10 +624,10 @@ class KeyringController extends EventEmitter { * - Faucets that account on testnet. * - Puts the current seed words into the state tree. * - * @returns {Promise} A promise that resolves if the operation was successful. + * @returns A promise that resolves if the operation was successful. */ - async createFirstKeyTree(): Promise { - this.clearKeyrings(); + async #createFirstKeyTree(): Promise { + this.#clearKeyrings(); const keyring = await this.addNewKeyring(KEYRINGS_TYPE_MAP.HD_KEYRING); if (!keyring) { @@ -591,9 +652,9 @@ class KeyringController extends EventEmitter { * encrypts that array with the provided `password`, * and persists that encrypted string to storage. * - * @returns {Promise} Resolves to true once keyrings are persisted. + * @returns Resolves to true once keyrings are persisted. */ - async persistAllKeyrings() { + async #persistAllKeyrings() { const { encryptionKey, encryptionSalt } = this.memStore.getState(); if (!this.password && !encryptionKey) { @@ -669,13 +730,13 @@ class KeyringController extends EventEmitter { * @param encryptionSalt - The salt used to encrypt the vault. * @returns The keyrings array. */ - async unlockKeyrings(password: string | undefined, encryptionKey?: string, encryptionSalt?: string): Promise { + async #unlockKeyrings(password: string | undefined, encryptionKey?: string, encryptionSalt?: string): Promise { const encryptedVault = this.store.getState().vault; if (!encryptedVault) { throw new Error('Cannot unlock without a previous vault.'); } - await this.clearKeyrings(); + await this.#clearKeyrings(); let vault; @@ -714,29 +775,11 @@ class KeyringController extends EventEmitter { this.password = password; } - await Promise.all(vault.map(this._restoreKeyring.bind(this))); + await Promise.all(vault.map(this.#restoreKeyring.bind(this))); await this._updateMemStoreKeyrings(); return this.keyrings; } - /** - * Restore Keyring - * - * Attempts to initialize a new keyring from the provided serialized payload. - * On success, updates the memStore keyrings and returns the resulting - * keyring instance. - * - * @param serialized - The serialized keyring. - * @returns The deserialized keyring. - */ - async restoreKeyring(serialized): Promise { - const keyring = await this._restoreKeyring(serialized); - if (keyring) { - await this._updateMemStoreKeyrings(); - } - return keyring; - } - /** * Restore Keyring Helper * @@ -746,7 +789,7 @@ class KeyringController extends EventEmitter { * @param serialized - The serialized keyring. * @returns The deserialized keyring or undefined if the keyring type is unsupported. */ - async _restoreKeyring(serialized): Promise { + async #restoreKeyring(serialized): Promise { const { type, data } = serialized; const keyring = await this.#newKeyring(type, data); @@ -772,24 +815,12 @@ class KeyringController extends EventEmitter { * @param type - The type whose class to get. * @returns The class, if it exists. */ - getKeyringBuilderForType(type: string): any { + #getKeyringBuilderForType(type: string): any { return this.keyringBuilders.find( (keyringBuilder) => keyringBuilder.type === type, ); } - /** - * Get Keyrings by Type - * - * Gets all keyrings of the given type. - * - * @param type - The keyring types to retrieve. - * @returns Keyrings matching the specified type. - */ - getKeyringsByType(type: string): ExtendedKeyring[] { - return this.keyrings.filter((keyring) => keyring.type === type); - } - /** * Get Accounts * @@ -798,7 +829,7 @@ class KeyringController extends EventEmitter { * * @returns The array of accounts. */ - async getAccounts(): Promise { + async #getAccounts(): Promise { const keyrings = this.keyrings || []; const keyringArrays = await Promise.all( @@ -858,9 +889,9 @@ class KeyringController extends EventEmitter { * Is used for adding the current keyrings to the state object. * * @param {Keyring} keyring - The keyring to display. - * @returns {Promise} A keyring display object, with type and accounts properties. + * @returns A keyring display object, with type and accounts properties. */ - async displayForKeyring(keyring): Promise<{ type: string, accounts: string[]}> { + async #displayForKeyring(keyring): Promise<{ type: string, accounts: string[]}> { const accounts = await keyring.getAccounts(); return { @@ -875,7 +906,7 @@ class KeyringController extends EventEmitter { * Deallocates all currently managed keyrings and accounts. * Used before initializing a new vault. */ - async clearKeyrings(): Promise { + async #clearKeyrings(): Promise { // clear keyrings from memory this.keyrings = []; this.memStore.updateState({ @@ -883,18 +914,6 @@ class KeyringController extends EventEmitter { }); } - /** - * Update memStore Keyrings - * - * Updates the in-memory keyrings, without persisting. - */ - async _updateMemStoreKeyrings(): Promise { - const keyrings = await Promise.all( - this.keyrings.map(this.displayForKeyring), - ); - return this.memStore.updateState({ keyrings }); - } - /** * Unlock Keyrings * @@ -902,29 +921,11 @@ class KeyringController extends EventEmitter { * * @fires KeyringController#unlock */ - setUnlocked(): void { + #setUnlocked(): void { this.memStore.updateState({ isUnlocked: true }); this.emit('unlock'); } - /** - * Forget hardware keyring. - * - * Forget hardware and update memorized state. - * - * @param keyring - The keyring to forget. - */ - forgetKeyring(keyring: ExtendedKeyring & { forgetDevice?: () => void}) { - if (keyring.forgetDevice) { - keyring.forgetDevice(); - this.persistAllKeyrings(); - } else { - throw new Error( - `KeyringController - keyring does not have method "forgetDevice", keyring type: ${keyring.type}`, - ); - } - } - /** * Instantiate, initialize and return a new keyring * @@ -935,7 +936,7 @@ class KeyringController extends EventEmitter { * @returns The new keyring. */ async #newKeyring(type: string, data): Promise { - const keyringBuilder = this.getKeyringBuilderForType(type); + const keyringBuilder = this.#getKeyringBuilderForType(type); if (!keyringBuilder) { return undefined; @@ -969,7 +970,7 @@ function keyringBuilderFactory(Keyring) { return builder; } -module.exports = { +export { KeyringController, keyringBuilderFactory, }; diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 00000000..059d3504 --- /dev/null +++ b/src/index.ts @@ -0,0 +1 @@ +export * from './KeyringController'; \ No newline at end of file diff --git a/test/index.js b/src/test/index.js similarity index 100% rename from test/index.js rename to src/test/index.js diff --git a/test/lib/mock-encryptor.js b/src/test/lib/mock-encryptor.js similarity index 100% rename from test/lib/mock-encryptor.js rename to src/test/lib/mock-encryptor.js diff --git a/test/lib/mock-keyring.js b/src/test/lib/mock-keyring.js similarity index 100% rename from test/lib/mock-keyring.js rename to src/test/lib/mock-keyring.js From ae34346281694718434da2bafadeb75fbeb87c29 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 23 Feb 2023 11:11:29 -0300 Subject: [PATCH 003/109] Update dependencies and configuration --- .eslintrc.js | 20 +++- jest.config.js | 4 +- package.json | 10 +- yarn.lock | 261 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 288 insertions(+), 7 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 0bc115e9..16916914 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,13 +1,27 @@ module.exports = { root: true, - extends: ['@metamask/eslint-config', '@metamask/eslint-config-commonjs'], + extends: ['@metamask/eslint-config'], overrides: [ { - files: ['test/**/*.js'], + files: ['*.ts'], extends: [ '@metamask/eslint-config-jest', - '@metamask/eslint-config-nodejs', + '@metamask/eslint-config-typescript', ], }, + { + files: ['*.js'], + parserOptions: { + sourceType: 'script', + }, + extends: ['@metamask/eslint-config-nodejs'], + }, + ], + ignorePatterns: [ + '!.eslintrc.js', + '!.prettierrc.js', + 'dist/', + 'docs/', + '.yarn/', ], }; diff --git a/jest.config.js b/jest.config.js index 11c59ca1..be2f35fb 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,4 +1,4 @@ -module.exports = { +const config = { collectCoverage: true, // Ensures that we collect coverage from all source files, not just tested // ones. @@ -24,3 +24,5 @@ module.exports = { testMatch: ['**/test/index.js'], testTimeout: 2500, }; + +export default config; diff --git a/package.json b/package.json index 80ea3869..4f7c7239 100644 --- a/package.json +++ b/package.json @@ -18,9 +18,10 @@ }, "license": "ISC", "author": "Dan Finlay ", - "main": "index.js", + "main": "dist/index.js", + "types": "dist/index.d.ts", "files": [ - "index.js" + "dist/" ], "scripts": { "lint": "yarn lint:eslint && yarn lint:misc --check", @@ -55,7 +56,10 @@ "jest": "^27.0.6", "prettier": "^2.8.1", "prettier-plugin-packagejson": "^2.3.0", - "sinon": "^11.1.1" + "sinon": "^11.1.1", + "ts-node": "^10.7.0", + "typedoc": "^0.23.15", + "typescript": "~4.8.4" }, "packageManager": "yarn@3.2.4", "engines": { diff --git a/yarn.lock b/yarn.lock index 3a751edb..33a38154 100644 --- a/yarn.lock +++ b/yarn.lock @@ -419,6 +419,15 @@ __metadata: languageName: node linkType: hard +"@cspotcode/source-map-support@npm:^0.8.0": + version: 0.8.1 + resolution: "@cspotcode/source-map-support@npm:0.8.1" + dependencies: + "@jridgewell/trace-mapping": 0.3.9 + checksum: 5718f267085ed8edb3e7ef210137241775e607ee18b77d95aa5bd7514f47f5019aa2d82d96b3bf342ef7aa890a346fa1044532ff7cc3009e7d24fce3ce6200fa + languageName: node + linkType: hard + "@es-joy/jsdoccomment@npm:~0.36.1": version: 0.36.1 resolution: "@es-joy/jsdoccomment@npm:0.36.1" @@ -720,6 +729,30 @@ __metadata: languageName: node linkType: hard +"@jridgewell/resolve-uri@npm:^3.0.3": + version: 3.1.0 + resolution: "@jridgewell/resolve-uri@npm:3.1.0" + checksum: b5ceaaf9a110fcb2780d1d8f8d4a0bfd216702f31c988d8042e5f8fbe353c55d9b0f55a1733afdc64806f8e79c485d2464680ac48a0d9fcadb9548ee6b81d267 + languageName: node + linkType: hard + +"@jridgewell/sourcemap-codec@npm:^1.4.10": + version: 1.4.14 + resolution: "@jridgewell/sourcemap-codec@npm:1.4.14" + checksum: 61100637b6d173d3ba786a5dff019e1a74b1f394f323c1fee337ff390239f053b87266c7a948777f4b1ee68c01a8ad0ab61e5ff4abb5a012a0b091bec391ab97 + languageName: node + linkType: hard + +"@jridgewell/trace-mapping@npm:0.3.9": + version: 0.3.9 + resolution: "@jridgewell/trace-mapping@npm:0.3.9" + dependencies: + "@jridgewell/resolve-uri": ^3.0.3 + "@jridgewell/sourcemap-codec": ^1.4.10 + checksum: d89597752fd88d3f3480845691a05a44bd21faac18e2185b6f436c3b0fd0c5a859fbbd9aaa92050c4052caf325ad3e10e2e1d1b64327517471b7d51babc0ddef + languageName: node + linkType: hard + "@lavamoat/aa@npm:^3.1.0": version: 3.1.0 resolution: "@lavamoat/aa@npm:3.1.0" @@ -855,6 +888,9 @@ __metadata: prettier: ^2.8.1 prettier-plugin-packagejson: ^2.3.0 sinon: ^11.1.1 + ts-node: ^10.7.0 + typedoc: ^0.23.15 + typescript: ~4.8.4 languageName: unknown linkType: soft @@ -1081,6 +1117,34 @@ __metadata: languageName: node linkType: hard +"@tsconfig/node10@npm:^1.0.7": + version: 1.0.9 + resolution: "@tsconfig/node10@npm:1.0.9" + checksum: a33ae4dc2a621c0678ac8ac4bceb8e512ae75dac65417a2ad9b022d9b5411e863c4c198b6ba9ef659e14b9fb609bbec680841a2e84c1172df7a5ffcf076539df + languageName: node + linkType: hard + +"@tsconfig/node12@npm:^1.0.7": + version: 1.0.11 + resolution: "@tsconfig/node12@npm:1.0.11" + checksum: 5ce29a41b13e7897a58b8e2df11269c5395999e588b9a467386f99d1d26f6c77d1af2719e407621412520ea30517d718d5192a32403b8dfcc163bf33e40a338a + languageName: node + linkType: hard + +"@tsconfig/node14@npm:^1.0.0": + version: 1.0.3 + resolution: "@tsconfig/node14@npm:1.0.3" + checksum: 19275fe80c4c8d0ad0abed6a96dbf00642e88b220b090418609c4376e1cef81bf16237bf170ad1b341452feddb8115d8dd2e5acdfdea1b27422071163dc9ba9d + languageName: node + linkType: hard + +"@tsconfig/node16@npm:^1.0.2": + version: 1.0.3 + resolution: "@tsconfig/node16@npm:1.0.3" + checksum: 3a8b657dd047495b7ad23437d6afd20297ce90380ff0bdee93fc7d39a900dbd8d9e26e53ff6b465e7967ce2adf0b218782590ce9013285121e6a5928fbd6819f + languageName: node + linkType: hard + "@types/babel__core@npm:^7.0.0, @types/babel__core@npm:^7.1.14": version: 7.1.14 resolution: "@types/babel__core@npm:7.1.14" @@ -1377,6 +1441,13 @@ __metadata: languageName: node linkType: hard +"acorn-walk@npm:^8.1.1": + version: 8.2.0 + resolution: "acorn-walk@npm:8.2.0" + checksum: 1715e76c01dd7b2d4ca472f9c58968516a4899378a63ad5b6c2d668bba8da21a71976c14ec5f5b75f887b6317c4ae0b897ab141c831d741dc76024d8745f1ad1 + languageName: node + linkType: hard + "acorn@npm:^7.1.1": version: 7.4.1 resolution: "acorn@npm:7.4.1" @@ -1395,6 +1466,15 @@ __metadata: languageName: node linkType: hard +"acorn@npm:^8.4.1": + version: 8.8.2 + resolution: "acorn@npm:8.8.2" + bin: + acorn: bin/acorn + checksum: f790b99a1bf63ef160c967e23c46feea7787e531292bb827126334612c234ed489a0dc2c7ba33156416f0ffa8d25bf2b0fdb7f35c2ba60eb3e960572bece4001 + languageName: node + linkType: hard + "aes-js@npm:^3.1.1": version: 3.1.2 resolution: "aes-js@npm:3.1.2" @@ -1467,6 +1547,13 @@ __metadata: languageName: node linkType: hard +"ansi-sequence-parser@npm:^1.1.0": + version: 1.1.0 + resolution: "ansi-sequence-parser@npm:1.1.0" + checksum: 75f4d3a4c555655a698aec05b5763cbddcd16ccccdbfd178fb0aa471ab74fdf98e031b875ef26e64be6a95cf970c89238744b26de6e34af97f316d5186b1df53 + languageName: node + linkType: hard + "ansi-styles@npm:^3.2.1": version: 3.2.1 resolution: "ansi-styles@npm:3.2.1" @@ -1536,6 +1623,13 @@ __metadata: languageName: node linkType: hard +"arg@npm:^4.1.0": + version: 4.1.3 + resolution: "arg@npm:4.1.3" + checksum: 544af8dd3f60546d3e4aff084d451b96961d2267d668670199692f8d054f0415d86fc5497d0e641e91546f0aa920e7c29e5250e99fc89f5552a34b5d93b77f43 + languageName: node + linkType: hard + "argparse@npm:^1.0.7": version: 1.0.10 resolution: "argparse@npm:1.0.10" @@ -2155,6 +2249,13 @@ __metadata: languageName: node linkType: hard +"create-require@npm:^1.1.0": + version: 1.1.1 + resolution: "create-require@npm:1.1.1" + checksum: a9a1503d4390d8b59ad86f4607de7870b39cad43d929813599a23714831e81c520bddf61bcdd1f8e30f05fd3a2b71ae8538e946eb2786dc65c2bbc520f692eff + languageName: node + linkType: hard + "cross-spawn@npm:^7.0.2, cross-spawn@npm:^7.0.3": version: 7.0.3 resolution: "cross-spawn@npm:7.0.3" @@ -2319,6 +2420,13 @@ __metadata: languageName: node linkType: hard +"diff@npm:^4.0.1": + version: 4.0.2 + resolution: "diff@npm:4.0.2" + checksum: f2c09b0ce4e6b301c221addd83bf3f454c0bc00caa3dd837cf6c127d6edf7223aa2bbe3b688feea110b7f262adbfc845b757c44c8a9f8c0c5b15d8fa9ce9d20d + languageName: node + linkType: hard + "diff@npm:^5.0.0": version: 5.0.0 resolution: "diff@npm:5.0.0" @@ -4630,6 +4738,13 @@ __metadata: languageName: node linkType: hard +"jsonc-parser@npm:^3.2.0": + version: 3.2.0 + resolution: "jsonc-parser@npm:3.2.0" + checksum: 946dd9a5f326b745aa326d48a7257e3f4a4b62c5e98ec8e49fa2bdd8d96cef7e6febf1399f5c7016114fd1f68a1c62c6138826d5d90bc650448e3cf0951c53c7 + languageName: node + linkType: hard + "jsprim@npm:^1.2.2": version: 1.4.1 resolution: "jsprim@npm:1.4.1" @@ -4749,6 +4864,13 @@ __metadata: languageName: node linkType: hard +"lunr@npm:^2.3.9": + version: 2.3.9 + resolution: "lunr@npm:2.3.9" + checksum: 176719e24fcce7d3cf1baccce9dd5633cd8bdc1f41ebe6a180112e5ee99d80373fe2454f5d4624d437e5a8319698ca6837b9950566e15d2cae5f2a543a3db4b8 + languageName: node + linkType: hard + "make-dir@npm:^3.0.0": version: 3.1.0 resolution: "make-dir@npm:3.1.0" @@ -4758,6 +4880,13 @@ __metadata: languageName: node linkType: hard +"make-error@npm:^1.1.1": + version: 1.3.6 + resolution: "make-error@npm:1.3.6" + checksum: b86e5e0e25f7f777b77fabd8e2cbf15737972869d852a22b7e73c17623928fccb826d8e46b9951501d3f20e51ad74ba8c59ed584f610526a48f8ccf88aaec402 + languageName: node + linkType: hard + "make-fetch-happen@npm:^10.0.3": version: 10.2.1 resolution: "make-fetch-happen@npm:10.2.1" @@ -4791,6 +4920,15 @@ __metadata: languageName: node linkType: hard +"marked@npm:^4.2.12": + version: 4.2.12 + resolution: "marked@npm:4.2.12" + bin: + marked: bin/marked.js + checksum: bd551cd61028ee639d4ca2ccdfcc5a6ba4227c1b143c4538f3cde27f569dcb57df8e6313560394645b418b84a7336c07ab1e438b89b6324c29d7d8cdd3102d63 + languageName: node + linkType: hard + "md5.js@npm:^1.3.4": version: 1.3.5 resolution: "md5.js@npm:1.3.5" @@ -4881,6 +5019,15 @@ __metadata: languageName: node linkType: hard +"minimatch@npm:^6.1.6": + version: 6.2.0 + resolution: "minimatch@npm:6.2.0" + dependencies: + brace-expansion: ^2.0.1 + checksum: 0ffb77d05bd483fcc344ba3e64a501d569e658fa6c592d94e9716ffc7925de7a8c2ac294cafa822b160bd8b2cbf7e01012917e06ffb9a85cfa9604629b3f2c04 + languageName: node + linkType: hard + "minimist@npm:^1.2.0, minimist@npm:^1.2.5, minimist@npm:^1.2.6": version: 1.2.7 resolution: "minimist@npm:1.2.7" @@ -5912,6 +6059,18 @@ __metadata: languageName: node linkType: hard +"shiki@npm:^0.14.1": + version: 0.14.1 + resolution: "shiki@npm:0.14.1" + dependencies: + ansi-sequence-parser: ^1.1.0 + jsonc-parser: ^3.2.0 + vscode-oniguruma: ^1.7.0 + vscode-textmate: ^8.0.0 + checksum: b19ea337cc84da69d99ca39d109f82946e0c56c11cc4c67b3b91cc14a9479203365fd0c9e0dd87e908f493ab409dc6f1849175384b6ca593ce7da884ae1edca2 + languageName: node + linkType: hard + "side-channel@npm:^1.0.4": version: 1.0.4 resolution: "side-channel@npm:1.0.4" @@ -6407,6 +6566,44 @@ __metadata: languageName: node linkType: hard +"ts-node@npm:^10.7.0": + version: 10.9.1 + resolution: "ts-node@npm:10.9.1" + dependencies: + "@cspotcode/source-map-support": ^0.8.0 + "@tsconfig/node10": ^1.0.7 + "@tsconfig/node12": ^1.0.7 + "@tsconfig/node14": ^1.0.0 + "@tsconfig/node16": ^1.0.2 + acorn: ^8.4.1 + acorn-walk: ^8.1.1 + arg: ^4.1.0 + create-require: ^1.1.0 + diff: ^4.0.1 + make-error: ^1.1.1 + v8-compile-cache-lib: ^3.0.1 + yn: 3.1.1 + peerDependencies: + "@swc/core": ">=1.2.50" + "@swc/wasm": ">=1.2.50" + "@types/node": "*" + typescript: ">=2.7" + peerDependenciesMeta: + "@swc/core": + optional: true + "@swc/wasm": + optional: true + bin: + ts-node: dist/bin.js + ts-node-cwd: dist/bin-cwd.js + ts-node-esm: dist/bin-esm.js + ts-node-script: dist/bin-script.js + ts-node-transpile-only: dist/bin-transpile.js + ts-script: dist/bin-script-deprecated.js + checksum: 090adff1302ab20bd3486e6b4799e90f97726ed39e02b39e566f8ab674fd5bd5f727f43615debbfc580d33c6d9d1c6b1b3ce7d8e3cca3e20530a145ffa232c35 + languageName: node + linkType: hard + "tsconfig-paths@npm:^3.14.1": version: 3.14.1 resolution: "tsconfig-paths@npm:3.14.1" @@ -6515,6 +6712,42 @@ __metadata: languageName: node linkType: hard +"typedoc@npm:^0.23.15": + version: 0.23.25 + resolution: "typedoc@npm:0.23.25" + dependencies: + lunr: ^2.3.9 + marked: ^4.2.12 + minimatch: ^6.1.6 + shiki: ^0.14.1 + peerDependencies: + typescript: 4.6.x || 4.7.x || 4.8.x || 4.9.x + bin: + typedoc: bin/typedoc + checksum: 2089d6da0293e63f6d3fac9460e9427fb6bfd56ddf669f2f13bef9435aa69ca7e72a8754e8951788db69432356e419c48b811105c8a74a47cab1f92a0bdad75b + languageName: node + linkType: hard + +"typescript@npm:~4.8.4": + version: 4.8.4 + resolution: "typescript@npm:4.8.4" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: 3e4f061658e0c8f36c820802fa809e0fd812b85687a9a2f5430bc3d0368e37d1c9605c3ce9b39df9a05af2ece67b1d844f9f6ea8ff42819f13bcb80f85629af0 + languageName: node + linkType: hard + +"typescript@patch:typescript@~4.8.4#~builtin": + version: 4.8.4 + resolution: "typescript@patch:typescript@npm%3A4.8.4#~builtin::version=4.8.4&hash=701156" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: 301459fc3eb3b1a38fe91bf96d98eb55da88a9cb17b4ef80b4d105d620f4d547ba776cc27b44cc2ef58b66eda23fe0a74142feb5e79a6fb99f54fc018a696afa + languageName: node + linkType: hard + "unbox-primitive@npm:^1.0.2": version: 1.0.2 resolution: "unbox-primitive@npm:1.0.2" @@ -6584,6 +6817,13 @@ __metadata: languageName: node linkType: hard +"v8-compile-cache-lib@npm:^3.0.1": + version: 3.0.1 + resolution: "v8-compile-cache-lib@npm:3.0.1" + checksum: 78089ad549e21bcdbfca10c08850022b22024cdcc2da9b168bcf5a73a6ed7bf01a9cebb9eac28e03cd23a684d81e0502797e88f3ccd27a32aeab1cfc44c39da0 + languageName: node + linkType: hard + "v8-to-istanbul@npm:^8.0.0": version: 8.0.0 resolution: "v8-to-istanbul@npm:8.0.0" @@ -6606,6 +6846,20 @@ __metadata: languageName: node linkType: hard +"vscode-oniguruma@npm:^1.7.0": + version: 1.7.0 + resolution: "vscode-oniguruma@npm:1.7.0" + checksum: 53519d91d90593e6fb080260892e87d447e9b200c4964d766772b5053f5699066539d92100f77f1302c91e8fc5d9c772fbe40fe4c90f3d411a96d5a9b1e63f42 + languageName: node + linkType: hard + +"vscode-textmate@npm:^8.0.0": + version: 8.0.0 + resolution: "vscode-textmate@npm:8.0.0" + checksum: 127780dfea89559d70b8326df6ec344cfd701312dd7f3f591a718693812b7852c30b6715e3cfc8b3200a4e2515b4c96f0843c0eacc0a3020969b5de262c2a4bb + languageName: node + linkType: hard + "w3c-hr-time@npm:^1.0.2": version: 1.0.2 resolution: "w3c-hr-time@npm:1.0.2" @@ -6831,6 +7085,13 @@ __metadata: languageName: node linkType: hard +"yn@npm:3.1.1": + version: 3.1.1 + resolution: "yn@npm:3.1.1" + checksum: 2c487b0e149e746ef48cda9f8bad10fc83693cd69d7f9dcd8be4214e985de33a29c9e24f3c0d6bcf2288427040a8947406ab27f7af67ee9456e6b84854f02dd6 + languageName: node + linkType: hard + "yocto-queue@npm:^0.1.0": version: 0.1.0 resolution: "yocto-queue@npm:0.1.0" From 4d8cf0d1b7dacac765edbd5f58480cf057059768 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 23 Feb 2023 16:51:50 -0300 Subject: [PATCH 004/109] Update test and mock files --- .../index.js => KeyringController.test.ts} | 65 ++++++++++--------- .../mock-encryptor.ts} | 18 ++--- .../mock-keyring.js => mocks/mock-keyring.ts} | 12 ++-- 3 files changed, 50 insertions(+), 45 deletions(-) rename src/{test/index.js => KeyringController.test.ts} (95%) rename src/{test/lib/mock-encryptor.js => mocks/mock-encryptor.ts} (86%) rename src/{test/lib/mock-keyring.js => mocks/mock-keyring.ts} (64%) diff --git a/src/test/index.js b/src/KeyringController.test.ts similarity index 95% rename from src/test/index.js rename to src/KeyringController.test.ts index dd589301..b431714a 100644 --- a/src/test/index.js +++ b/src/KeyringController.test.ts @@ -1,12 +1,12 @@ -const HdKeyring = require('@metamask/eth-hd-keyring'); -const { normalize: normalizeAddress } = require('@metamask/eth-sig-util'); -const { strict: assert } = require('assert'); -const Wallet = require('ethereumjs-wallet').default; -const sinon = require('sinon'); +import HdKeyring from '@metamask/eth-hd-keyring'; +import { normalize as normalizeAddress } from '@metamask/eth-sig-util'; +import { strict as assert } from 'assert'; +import Wallet from 'ethereumjs-wallet'; +import { restore, spy, stub, assert as sinonAssert } from 'sinon'; -const { KeyringController, keyringBuilderFactory } = require('..'); -const mockEncryptor = require('./lib/mock-encryptor'); -const { KeyringMockWithInit } = require('./lib/mock-keyring'); +import { KeyringController, keyringBuilderFactory } from '.'; +import mockEncryptor from './mocks/mock-encryptor'; +import KeyringMockWithInit from './mocks/mock-keyring'; const password = 'password123'; @@ -44,7 +44,7 @@ describe('KeyringController', function () { }); afterEach(function () { - sinon.restore(); + restore(); }); describe('setLocked', function () { @@ -63,12 +63,12 @@ describe('KeyringController', function () { }); it('emits "lock" event', async function () { - const spy = sinon.spy(); - keyringController.on('lock', spy); + const lockSpy = spy(); + keyringController.on('lock', lockSpy); await keyringController.setLocked(); - expect(spy.calledOnce).toBe(true); + expect(lockSpy.calledOnce).toBe(true); }); }); @@ -90,11 +90,11 @@ describe('KeyringController', function () { it('emits "unlock" event', async function () { await keyringController.setLocked(); - const spy = sinon.spy(); - keyringController.on('unlock', spy); + const unlockSpy = spy(); + keyringController.on('unlock', unlockSpy); await keyringController.submitPassword(password); - expect(spy.calledOnce).toBe(true); + expect(unlockSpy.calledOnce).toBe(true); }); }); @@ -149,7 +149,7 @@ describe('KeyringController', function () { it('should throw error if accounts are not generated correctly', async () => { jest .spyOn(HdKeyring.prototype, 'getAccounts') - .mockImplementation(() => Promise.resolve([])); + .mockImplementation(async () => Promise.resolve([])); await expect(() => keyringController.createNewVaultAndKeychain(password), @@ -219,7 +219,7 @@ describe('KeyringController', function () { it('throws error if accounts are not created properly', async () => { jest .spyOn(HdKeyring.prototype, 'getAccounts') - .mockImplementation(() => Promise.resolve([])); + .mockImplementation(async () => Promise.resolve([])); await expect(() => keyringController.createNewVaultAndRestore( @@ -277,7 +277,7 @@ describe('KeyringController', function () { }); it('should call init method if available', async function () { - const initSpy = sinon.spy(KeyringMockWithInit.prototype, 'init'); + const initSpy = spy(KeyringMockWithInit.prototype, 'init'); const keyring = await keyringController.addNewKeyring( 'Keyring Mock With Init', @@ -285,12 +285,12 @@ describe('KeyringController', function () { expect(keyring).toBeInstanceOf(KeyringMockWithInit); - sinon.assert.calledOnce(initSpy); + sinonAssert.calledOnce(initSpy); }); it('should add HD Key Tree when addAccounts is asynchronous', async function () { const originalAccAccounts = HdKeyring.prototype.addAccounts; - sinon.stub(HdKeyring.prototype, 'addAccounts').callsFake(function () { + stub(HdKeyring.prototype, 'addAccounts').callsFake(async function () { return new Promise((resolve) => { setImmediate(() => { resolve(originalAccAccounts.bind(this)()); @@ -336,12 +336,12 @@ describe('KeyringController', function () { it('returns the result of getAccounts for each keyring', async function () { keyringController.keyrings = [ { - getAccounts() { + async getAccounts() { return Promise.resolve([1, 2, 3]); }, }, { - getAccounts() { + async getAccounts() { return Promise.resolve([4, 5, 6]); }, }, @@ -470,7 +470,7 @@ describe('KeyringController', function () { walletOneSeedWords, ); - await expect(() => + expect(() => keyringController.verifyPassword(password), ).not.toThrow(); }); @@ -499,11 +499,11 @@ describe('KeyringController', function () { const keyring = await keyringController.addNewKeyring('Simple Key Pair', [ privateKey, ]); - keyring.getAppKeyAddress = sinon.spy(); + keyring.getAppKeyAddress = spy(); /* eslint-disable-next-line require-atomic-updates */ - keyringController.getKeyringForAccount = sinon - .stub() - .returns(Promise.resolve(keyring)); + keyringController.getKeyringForAccount = stub().returns( + Promise.resolve(keyring), + ); await keyringController.getAppKeyAddress(address, 'someapp.origin.io'); @@ -560,7 +560,7 @@ describe('KeyringController', function () { it('forget hardware device', async function () { const hdKeyring = keyringController.getKeyringsByType('HD Key Tree'); - hdKeyring.forgetDevice = sinon.spy(); + hdKeyring.forgetDevice = spy(); keyringController.forgetKeyring(hdKeyring); expect(hdKeyring.forgetDevice.calledOnce).toBe(true); }); @@ -591,7 +591,7 @@ describe('KeyringController', function () { it('throws error when there are no matching keyrings', async function () { keyringController.keyrings = [ { - getAccounts() { + async getAccounts() { return Promise.resolve([1, 2, 3]); }, }, @@ -622,8 +622,11 @@ describe('KeyringController', function () { it('unlocks the keyrings with valid information', async function () { keyringController.cacheEncryptionKey = true; const returnValue = await keyringController.encryptor.decryptWithKey(); - const stub = sinon.stub(keyringController.encryptor, 'decryptWithKey'); - stub.resolves(Promise.resolve(returnValue)); + const decryptWithKeyStub = stub( + keyringController.encryptor, + 'decryptWithKey', + ); + decryptWithKeyStub.resolves(Promise.resolve(returnValue)); keyringController.store.updateState({ vault: MOCK_ENCRYPTION_DATA }); diff --git a/src/test/lib/mock-encryptor.js b/src/mocks/mock-encryptor.ts similarity index 86% rename from src/test/lib/mock-encryptor.js rename to src/mocks/mock-encryptor.ts index a319b39d..d59e1185 100644 --- a/src/test/lib/mock-encryptor.js +++ b/src/mocks/mock-encryptor.ts @@ -1,4 +1,4 @@ -const sinon = require('sinon'); +import { stub } from 'sinon'; const PASSWORD = 'password123'; const MOCK_ENCRYPTION_KEY = @@ -12,14 +12,14 @@ const MOCK_HEX = '0xabcdef0123456789'; const MOCK_KEY = Buffer.alloc(32); let cacheVal; -module.exports = { - encrypt: sinon.stub().callsFake(function (_password, dataObj) { +const mockEncryptor = { + encrypt: stub().callsFake(async function (_password, dataObj) { cacheVal = dataObj; return Promise.resolve(MOCK_HEX); }), - encryptWithDetail: sinon.stub().callsFake(function (_password, dataObj) { + encryptWithDetail: stub().callsFake(async function (_password, dataObj) { cacheVal = dataObj; return Promise.resolve({ vault: MOCK_HEX, exportedKeyString: '' }); @@ -38,7 +38,7 @@ module.exports = { return vault; }, - decryptWithDetail(_password, _text) { + async decryptWithDetail(_password: string, _text: string) { if (_password && _password !== PASSWORD) { throw new Error(INVALID_PASSWORD_ERROR); } @@ -53,7 +53,7 @@ module.exports = { return Promise.resolve(result); }, - importKey(keyString) { + importKey(keyString: string) { if (keyString === '{}') { throw new TypeError( `Failed to execute 'importKey' on 'SubtleCrypto': The provided value is not of type '(ArrayBuffer or ArrayBufferView or JsonWebKey)'.`, @@ -69,11 +69,11 @@ module.exports = { return data; }, - decryptWithKey(key, text) { + async decryptWithKey(key: string, text: string) { return this.decrypt(key, text); }, - keyFromPassword(_password) { + async keyFromPassword(_password: string) { return Promise.resolve(MOCK_KEY); }, @@ -81,3 +81,5 @@ module.exports = { return 'WHADDASALT!'; }, }; + +export default mockEncryptor; diff --git a/src/test/lib/mock-keyring.js b/src/mocks/mock-keyring.ts similarity index 64% rename from src/test/lib/mock-keyring.js rename to src/mocks/mock-keyring.ts index cd57b9ae..a520d131 100644 --- a/src/test/lib/mock-keyring.js +++ b/src/mocks/mock-keyring.ts @@ -1,5 +1,7 @@ class KeyringMockWithInit { - init() { + static type: string; + + async init() { return Promise.resolve(); } @@ -7,17 +9,15 @@ class KeyringMockWithInit { return []; } - serialize() { + async serialize() { return Promise.resolve({}); } - deserialize(_) { + async deserialize(_) { return Promise.resolve(); } } KeyringMockWithInit.type = 'Keyring Mock With Init'; -module.exports = { - KeyringMockWithInit, -}; +export default KeyringMockWithInit; From b7cc77cff6dcb4901429ab7cd22e7a424e8194dc Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 23 Feb 2023 16:52:11 -0300 Subject: [PATCH 005/109] Solve yarn issues --- src/KeyringController.ts | 253 ++++++++++++++++++++++++++------------- src/index.ts | 2 +- 2 files changed, 170 insertions(+), 85 deletions(-) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index fff64ec3..2613e7b0 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -1,13 +1,22 @@ -import { Hex, Keyring, Transaction, SignedTransaction, Eip1024EncryptedData } from '@metamask/utils'; - -const encryptor = require('@metamask/browser-passworder'); -const HdKeyring = require('@metamask/eth-hd-keyring'); -const { normalize: normalizeAddress } = require('@metamask/eth-sig-util'); -const SimpleKeyring = require('@metamask/eth-simple-keyring'); +import encryptor from '@metamask/browser-passworder'; +// @ts-ignore +import HdKeyring from '@metamask/eth-hd-keyring'; +// @ts-ignore +import SimpleKeyring from '@metamask/eth-simple-keyring'; +import { normalize as normalizeAddress } from '@metamask/eth-sig-util'; +import { + Hex, + Keyring, + KeyringClass, + Transaction, + SignedTransaction, + Eip1024EncryptedData, +} from '@metamask/utils'; // TODO: Stop using `events`, and remove the notice about this from the README // eslint-disable-next-line import/no-nodejs-modules -const { EventEmitter } = require('events'); -const ObservableStore = require('obs-store'); +import { EventEmitter } from 'events'; +// @ts-ignore +import ObservableStore from 'obs-store'; type State = any; type ExtendedKeyring = Keyring & { @@ -19,10 +28,10 @@ const defaultKeyringBuilders = [ keyringBuilderFactory(HdKeyring), ]; -const enum KEYRINGS_TYPE_MAP { - HD_KEYRING = 'HD Key Tree', - SIMPLE_KEYRING = 'Simple Key Pair', -}; +const enum KeyringType { + HDKeyring = 'HD Key Tree', + SimpleKeyring = 'Simple Key Pair', +} /** * Strip the hex prefix from an address, if present. @@ -38,11 +47,27 @@ function stripHexPrefix(address: Hex | string): string { } class KeyringController extends EventEmitter { + keyringBuilders: { (): any; type: any }[]; + + store: any; + + memStore: any; + + encryptor: any; + + keyrings: ExtendedKeyring[]; + + cacheEncryptionKey: boolean; + + #unsupportedKeyrings: any[]; + + password?: string; + // // PUBLIC METHODS // - constructor(opts) { + constructor(opts: any) { super(); const initState = opts.initState || {}; this.keyringBuilders = opts.keyringBuilders @@ -60,7 +85,7 @@ class KeyringController extends EventEmitter { this.encryptor = opts.encryptor || encryptor; this.keyrings = []; - this._unsupportedKeyrings = []; + this.#unsupportedKeyrings = []; // This option allows the controller to cache an exported key // for use in decrypting and encrypting data without password @@ -77,7 +102,7 @@ class KeyringController extends EventEmitter { * indicating consumers can often either listen for updates, * or accept a state-resolving promise to consume their results. * - * @returns {object} The controller state. + * @returns The controller state. */ fullUpdate() { this.emit('update', this.memStore.getState()); @@ -117,14 +142,17 @@ class KeyringController extends EventEmitter { * either as a string or Uint8Array. * @returns A promise that resolves to the state. */ - async createNewVaultAndRestore(password: string, seedPhrase: Uint8Array | string): Promise { + async createNewVaultAndRestore( + password: string, + seedPhrase: Uint8Array | string, + ): Promise { if (typeof password !== 'string') { throw new Error('Password must be text.'); } this.password = password; await this.#clearKeyrings(); - const keyring = await this.addNewKeyring(KEYRINGS_TYPE_MAP.HD_KEYRING, { + const keyring = await this.addNewKeyring(KeyringType.HDKeyring, { mnemonic: seedPhrase, numberOfAccounts: 1, }); @@ -161,7 +189,7 @@ class KeyringController extends EventEmitter { // remove keyrings this.keyrings = []; - await this._updateMemStoreKeyrings(); + await this.#updateMemStoreKeyrings(); this.emit('lock'); return this.fullUpdate(); } @@ -197,7 +225,10 @@ class KeyringController extends EventEmitter { * @param encryptionSalt - The salt used to generate the last key. * @returns A promise that resolves to the state. */ - async submitEncryptionKey(encryptionKey: string, encryptionSalt: string): Promise { + async submitEncryptionKey( + encryptionKey: string, + encryptionSalt: string, + ): Promise { this.keyrings = await this.#unlockKeyrings( undefined, encryptionKey, @@ -213,7 +244,7 @@ class KeyringController extends EventEmitter { * Attempts to decrypt the current vault with a given password * to verify its validity. * - * @param {string} password - The vault password. + * @param password - The vault password. */ async verifyPassword(password: string): Promise { const encryptedVault = this.store.getState().vault; @@ -236,14 +267,17 @@ class KeyringController extends EventEmitter { * @param opts - The constructor options for the keyring. * @returns The new keyring. */ - async addNewKeyring(type: string, opts?: Record): Promise { + async addNewKeyring( + type: string, + opts?: Record, + ): Promise { const keyring = await this.#newKeyring(type, opts); if (!keyring) { throw new Error('KeyringController - No keyring found'); } - if ((!opts || !opts.mnemonic) && type === KEYRINGS_TYPE_MAP.HD_KEYRING) { + if ((!opts || !opts.mnemonic) && type === KeyringType.HDKeyring) { keyring.generateRandomMnemonic(); await keyring.addAccounts(1); } @@ -293,11 +327,14 @@ class KeyringController extends EventEmitter { * @param newAccountArray - Array of new accounts. * @returns The account, if no duplicate is found. */ - async checkForDuplicate(type: string, newAccountArray: string[]): Promise { + async checkForDuplicate( + type: string, + newAccountArray: string[], + ): Promise { const accounts = await this.#getAccounts(); switch (type) { - case KEYRINGS_TYPE_MAP.SIMPLE_KEYRING: { + case KeyringType.SimpleKeyring: { const isIncluded = Boolean( accounts.find( (key: string) => @@ -350,13 +387,15 @@ class KeyringController extends EventEmitter { * @param address - The address of the account to export. * @returns The private key of the account. */ - async exportAccount(address: string): Promise { + async exportAccount(address: Hex): Promise { const keyring = await this.getKeyringForAccount(address); if (!keyring.exportAccount) { - throw new Error(`The keyring for address ${address} does not support the method exportAccount.`); + throw new Error( + `The keyring for address ${address} does not support the method exportAccount.`, + ); } - return await keyring.exportAccount(normalizeAddress(address)); + return await keyring.exportAccount(normalizeAddress(address) as Hex); } /** @@ -401,15 +440,21 @@ class KeyringController extends EventEmitter { * Signs an Ethereum transaction object. * * @param ethTx - The transaction to sign. - * @param inputFromAddress - The transaction 'from' address. + * @param _address - The transaction 'from' address. * @param opts - Signing options. * @returns The signed transaction object. */ - async signTransaction(ethTx: Transaction, _address: string | Hex, opts: Record = {}): Promise { - const address = normalizeAddress(_address); - const keyring = await this.getKeyringForAccountgetKeyringForAccount(address); + async signTransaction( + ethTx: Transaction, + _address: string | Hex, + opts: Record = {}, + ): Promise { + const address = normalizeAddress(_address) as Hex; + const keyring = await this.getKeyringForAccount(address); if (!keyring.signTransaction) { - throw new Error(`The keyring for address ${address} does not support the method signTransaction.`); + throw new Error( + `The keyring for address ${address} does not support the method signTransaction.`, + ); } return await keyring.signTransaction(address, ethTx, opts); @@ -421,14 +466,21 @@ class KeyringController extends EventEmitter { * Attempts to sign the provided message parameters. * * @param msgParams - The message parameters to sign. + * @param msgParams.from + * @param msgParams.data * @param opts - Additional signing options. * @returns The raw signature. */ - async signMessage(msgParams: { from: Hex | string; data: string }, opts: Record = {}) { - const address = normalizeAddress(msgParams.from); + async signMessage( + msgParams: { from: Hex | string; data: string }, + opts: Record = {}, + ) { + const address = normalizeAddress(msgParams.from) as Hex; const keyring = await this.getKeyringForAccount(address); if (!keyring.signMessage) { - throw new Error(`The keyring for address ${address} does not support the method signMessage.`); + throw new Error( + `The keyring for address ${address} does not support the method signMessage.`, + ); } return await keyring.signMessage(address, msgParams.data, opts); @@ -441,14 +493,21 @@ class KeyringController extends EventEmitter { * Prefixes the hash before signing per the personal sign expectation. * * @param msgParams - The message parameters to sign. + * @param msgParams.from * @param opts - Additional signing options. + * @param msgParams.data * @returns The raw signature. */ - async signPersonalMessage(msgParams: { from: Hex | string; data: Hex }, opts: Record = {}): Promise { - const address = normalizeAddress(msgParams.from); + async signPersonalMessage( + msgParams: { from: Hex | string; data: Hex }, + opts: Record = {}, + ): Promise { + const address = normalizeAddress(msgParams.from) as Hex; const keyring = await this.getKeyringForAccount(address); if (!keyring.signPersonalMessage) { - throw new Error(`The keyring for address ${address} does not support the method signPersonalMessage.`); + throw new Error( + `The keyring for address ${address} does not support the method signPersonalMessage.`, + ); } return await keyring.signPersonalMessage(address, msgParams.data, opts); @@ -463,11 +522,16 @@ class KeyringController extends EventEmitter { * @param opts - Additional encryption options. * @returns The public key. */ - async getEncryptionPublicKey(address: string | Hex, opts: Record = {}): Promise { - const normalizedAddress = normalizeAddress(address); + async getEncryptionPublicKey( + address: string | Hex, + opts: Record = {}, + ): Promise { + const normalizedAddress = normalizeAddress(address) as Hex; const keyring = await this.getKeyringForAccount(address); if (!keyring.getEncryptionPublicKey) { - throw new Error(`The keyring for address ${address} does not support the method getEncryptionPublicKey.`); + throw new Error( + `The keyring for address ${address} does not support the method getEncryptionPublicKey.`, + ); } return await keyring.getEncryptionPublicKey(normalizedAddress, opts); @@ -480,13 +544,20 @@ class KeyringController extends EventEmitter { * * @param msgParams - The decryption message parameters. * @param opts - Additional decryption options. + * @param msgParams.from + * @param msgParams.data * @returns The raw decryption result. */ - async decryptMessage(msgParams: { from: Hex | string; data: Eip1024EncryptedData }): Promise { - const address = normalizeAddress(msgParams.from); + async decryptMessage(msgParams: { + from: Hex | string; + data: Eip1024EncryptedData; + }): Promise { + const address = normalizeAddress(msgParams.from) as Hex; const keyring = await this.getKeyringForAccount(address); if (!keyring.decryptMessage) { - throw new Error(`The keyring for address ${address} does not support the method decryptMessage.`); + throw new Error( + `The keyring for address ${address} does not support the method decryptMessage.`, + ); } return keyring.decryptMessage(address, msgParams.data); @@ -497,14 +568,21 @@ class KeyringController extends EventEmitter { * * @see {@link https://github.com/ethereum/EIPs/pull/712#issuecomment-329988454|EIP712}. * @param msgParams - The message parameters to sign. + * @param msgParams.from + * @param msgParams.data * @param opts - Additional signing options. * @returns The raw signature. */ - async signTypedMessage(msgParams: { from: Hex | string; data: Eip1024EncryptedData }, opts = { version: 'V1' }): Promise { - const address = normalizeAddress(msgParams.from); + async signTypedMessage( + msgParams: { from: Hex | string; data: Eip1024EncryptedData }, + opts = { version: 'V1' }, + ): Promise { + const address = normalizeAddress(msgParams.from) as Hex; const keyring = await this.getKeyringForAccount(address); if (!keyring.signTypedData) { - throw new Error(`The keyring for address ${address} does not support the method signTypedData.`); + throw new Error( + `The keyring for address ${address} does not support the method signTypedData.`, + ); } return keyring.signTypedData(address, msgParams.data, opts); @@ -518,10 +596,12 @@ class KeyringController extends EventEmitter { * @returns The app key address. */ async getAppKeyAddress(_address: string, origin: string): Promise { - const address = normalizeAddress(_address); + const address = normalizeAddress(_address) as Hex; const keyring = await this.getKeyringForAccount(address); if (!keyring.getAppKeyAddress) { - throw new Error(`The keyring for address ${_address} does not support the method getAppKeyAddress.`); + throw new Error( + `The keyring for address ${_address} does not support the method getAppKeyAddress.`, + ); } return keyring.getAppKeyAddress(address, origin); @@ -534,8 +614,11 @@ class KeyringController extends EventEmitter { * @param origin - The origin for the app key. * @returns The app key private key. */ - async exportAppKeyForAddress(_address: string, origin: string): Promise { - const address = normalizeAddress(_address); + async exportAppKeyForAddress( + _address: string, + origin: string, + ): Promise { + const address = normalizeAddress(_address) as Hex; const keyring = await this.getKeyringForAccount(address); // The "in" operator is typically restricted because it also checks inherited properties, // which can be unexpected for plain objects. We're allowing it here because `keyring` is not @@ -556,17 +639,16 @@ class KeyringController extends EventEmitter { * * @param keyring - The keyring to forget. */ - forgetKeyring(keyring: ExtendedKeyring & { forgetDevice?: () => void}) { - if (keyring.forgetDevice) { - keyring.forgetDevice(); - this.#persistAllKeyrings(); - } else { - throw new Error( - `KeyringController - keyring does not have method "forgetDevice", keyring type: ${keyring.type}`, - ); - } + forgetKeyring(keyring: ExtendedKeyring & { forgetDevice?: () => void }) { + if (keyring.forgetDevice) { + keyring.forgetDevice(); + this.#persistAllKeyrings(); + } else { + throw new Error( + `KeyringController - keyring does not have method "forgetDevice", keyring type: ${keyring.type}`, + ); } - + } /** * Restore Keyring @@ -578,10 +660,10 @@ class KeyringController extends EventEmitter { * @param serialized - The serialized keyring. * @returns The deserialized keyring. */ - async restoreKeyring(serialized): Promise { + async restoreKeyring(serialized: any): Promise { const keyring = await this.#restoreKeyring(serialized); if (keyring) { - await this._updateMemStoreKeyrings(); + await this.#updateMemStoreKeyrings(); } return keyring; } @@ -603,7 +685,7 @@ class KeyringController extends EventEmitter { * * Updates the in-memory keyrings, without persisting. */ - async updateMemStoreKeyrings(): Promise { + async #updateMemStoreKeyrings(): Promise { const keyrings = await Promise.all( this.keyrings.map(this.#displayForKeyring), ); @@ -629,11 +711,11 @@ class KeyringController extends EventEmitter { async #createFirstKeyTree(): Promise { this.#clearKeyrings(); - const keyring = await this.addNewKeyring(KEYRINGS_TYPE_MAP.HD_KEYRING); + const keyring = await this.addNewKeyring(KeyringType.HDKeyring); if (!keyring) { throw new Error('KeyringController - No keyring found'); } - + const [firstAccount] = await keyring.getAccounts(); if (!firstAccount) { throw new Error('KeyringController - No account found on keychain.'); @@ -673,7 +755,7 @@ class KeyringController extends EventEmitter { }), ); - serializedKeyrings.push(...this._unsupportedKeyrings); + serializedKeyrings.push(...this.#unsupportedKeyrings); let vault; let newEncryptionKey; @@ -709,9 +791,9 @@ class KeyringController extends EventEmitter { // The keyring updates need to be announced before updating the encryptionKey // so that the updated keyring gets propagated to the extension first. - // Not calling _updateMemStoreKeyrings results in the wrong account being selected + // Not calling {@link #updateMemStoreKeyrings} results in the wrong account being selected // in the extension. - await this._updateMemStoreKeyrings(); + await this.#updateMemStoreKeyrings(); if (newEncryptionKey) { this.memStore.updateState({ encryptionKey: newEncryptionKey }); } @@ -730,7 +812,11 @@ class KeyringController extends EventEmitter { * @param encryptionSalt - The salt used to encrypt the vault. * @returns The keyrings array. */ - async #unlockKeyrings(password: string | undefined, encryptionKey?: string, encryptionSalt?: string): Promise { + async #unlockKeyrings( + password: string | undefined, + encryptionKey?: string, + encryptionSalt?: string, + ): Promise { const encryptedVault = this.store.getState().vault; if (!encryptedVault) { throw new Error('Cannot unlock without a previous vault.'); @@ -776,7 +862,7 @@ class KeyringController extends EventEmitter { } await Promise.all(vault.map(this.#restoreKeyring.bind(this))); - await this._updateMemStoreKeyrings(); + await this.#updateMemStoreKeyrings(); return this.keyrings; } @@ -789,12 +875,12 @@ class KeyringController extends EventEmitter { * @param serialized - The serialized keyring. * @returns The deserialized keyring or undefined if the keyring type is unsupported. */ - async #restoreKeyring(serialized): Promise { + async #restoreKeyring(serialized: any): Promise { const { type, data } = serialized; const keyring = await this.#newKeyring(type, data); if (!keyring) { - this._unsupportedKeyrings.push(serialized); + this.#unsupportedKeyrings.push(serialized); return undefined; } @@ -833,7 +919,7 @@ class KeyringController extends EventEmitter { const keyrings = this.keyrings || []; const keyringArrays = await Promise.all( - keyrings.map((keyring) => keyring.getAccounts()), + keyrings.map(async (keyring) => keyring.getAccounts()), ); const addresses = keyringArrays.reduce((res, arr) => { return res.concat(arr); @@ -855,7 +941,7 @@ class KeyringController extends EventEmitter { const hexed = normalizeAddress(address); const candidates = await Promise.all( - this.keyrings.map((keyring) => { + this.keyrings.map(async (keyring) => { return Promise.all([keyring, keyring.getAccounts()]); }), ); @@ -865,7 +951,7 @@ class KeyringController extends EventEmitter { return accounts.includes(hexed); }); - if (winners && winners.length > 0) { + if (winners && winners.length > 0 && winners[0].length > 0) { return winners[0][0]; } @@ -888,10 +974,12 @@ class KeyringController extends EventEmitter { * * Is used for adding the current keyrings to the state object. * - * @param {Keyring} keyring - The keyring to display. - * @returns A keyring display object, with type and accounts properties. + * @param keyring - The keyring to display. + * @returns A keyring display object, with type and accounts properties. */ - async #displayForKeyring(keyring): Promise<{ type: string, accounts: string[]}> { + async #displayForKeyring( + keyring: ExtendedKeyring, + ): Promise<{ type: string; accounts: string[] }> { const accounts = await keyring.getAccounts(); return { @@ -962,7 +1050,7 @@ class KeyringController extends EventEmitter { * @param Keyring - The Keyring class for the builder. * @returns A builder function for the given Keyring. */ -function keyringBuilderFactory(Keyring) { +function keyringBuilderFactory(Keyring: KeyringClass) { const builder = () => new Keyring(); builder.type = Keyring.type; @@ -970,7 +1058,4 @@ function keyringBuilderFactory(Keyring) { return builder; } -export { - KeyringController, - keyringBuilderFactory, -}; +export { KeyringController, keyringBuilderFactory }; diff --git a/src/index.ts b/src/index.ts index 059d3504..9b98ad6f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1 +1 @@ -export * from './KeyringController'; \ No newline at end of file +export * from './KeyringController'; From 7eae2b337ec7783857f3d9b0291e2936f420c016 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 23 Feb 2023 16:52:37 -0300 Subject: [PATCH 006/109] Update configuration and dependencies --- .eslintrc.js | 20 ++- jest.config.js | 9 +- package.json | 7 + tsconfig.json | 17 ++ typedoc.json | 6 + yarn.lock | 427 +++++++++++++++++++++++++++++++++++++++++++++++-- 6 files changed, 464 insertions(+), 22 deletions(-) create mode 100644 tsconfig.json create mode 100644 typedoc.json diff --git a/.eslintrc.js b/.eslintrc.js index 16916914..e5fa88e8 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,14 +1,17 @@ module.exports = { root: true, + extends: ['@metamask/eslint-config'], + overrides: [ { files: ['*.ts'], - extends: [ - '@metamask/eslint-config-jest', - '@metamask/eslint-config-typescript', - ], + extends: ['@metamask/eslint-config-typescript'], + rules: { + '@typescript-eslint/consistent-type-definitions': ['error', 'type'], + }, }, + { files: ['*.js'], parserOptions: { @@ -16,7 +19,16 @@ module.exports = { }, extends: ['@metamask/eslint-config-nodejs'], }, + + { + files: ['*.test.ts', '*.test.js'], + extends: [ + '@metamask/eslint-config-jest', + '@metamask/eslint-config-nodejs', + ], + }, ], + ignorePatterns: [ '!.eslintrc.js', '!.prettierrc.js', diff --git a/jest.config.js b/jest.config.js index be2f35fb..d131340e 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,8 +1,8 @@ -const config = { +module.exports = { collectCoverage: true, // Ensures that we collect coverage from all source files, not just tested // ones. - collectCoverageFrom: ['./index.js'], + collectCoverageFrom: ['./src/**/*.ts'], coverageReporters: ['text', 'html'], coverageThreshold: { global: { @@ -13,6 +13,7 @@ const config = { }, }, moduleFileExtensions: ['js', 'json', 'jsx', 'ts', 'tsx', 'node'], + preset: 'ts-jest', // "resetMocks" resets all mocks, including mocked modules, to jest.fn(), // between each test case. resetMocks: true, @@ -21,8 +22,6 @@ const config = { // modules. restoreMocks: true, testEnvironment: 'node', - testMatch: ['**/test/index.js'], + testRegex: ['\\.test\\.(ts|js)$'], testTimeout: 2500, }; - -export default config; diff --git a/package.json b/package.json index 4f7c7239..40c0ae37 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,12 @@ "@metamask/eslint-config-commonjs": "^11.1.0", "@metamask/eslint-config-jest": "^11.1.0", "@metamask/eslint-config-nodejs": "^11.1.0", + "@metamask/eslint-config-typescript": "^11.1.0", + "@types/jest": "^29.4.0", + "@types/mocha": "^5.0.0", + "@types/sinon": "^10.0.13", + "@typescript-eslint/eslint-plugin": "^5.53.0", + "@typescript-eslint/parser": "^5.53.0", "eslint": "^8.29.0", "eslint-config-prettier": "^8.5.0", "eslint-plugin-import": "^2.26.0", @@ -57,6 +63,7 @@ "prettier": "^2.8.1", "prettier-plugin-packagejson": "^2.3.0", "sinon": "^11.1.1", + "ts-jest": "^29.0.3", "ts-node": "^10.7.0", "typedoc": "^0.23.15", "typescript": "~4.8.4" diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..1fe94d7c --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "esModuleInterop": true, + "exactOptionalPropertyTypes": true, + "forceConsistentCasingInFileNames": true, + "lib": ["ES2020", "dom"], + "module": "CommonJS", + "moduleResolution": "node", + "noEmit": true, + "noErrorTruncation": true, + "noUncheckedIndexedAccess": true, + "strict": true, + "target": "ES2017" + }, + "exclude": ["./dist/**/*"] + } + \ No newline at end of file diff --git a/typedoc.json b/typedoc.json new file mode 100644 index 00000000..b527b625 --- /dev/null +++ b/typedoc.json @@ -0,0 +1,6 @@ +{ + "entryPoints": ["./src/index.ts"], + "excludePrivate": true, + "hideGenerator": true, + "out": "docs" +} diff --git a/yarn.lock b/yarn.lock index 33a38154..b1d540cc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -596,6 +596,15 @@ __metadata: languageName: node linkType: hard +"@jest/expect-utils@npm:^29.4.3": + version: 29.4.3 + resolution: "@jest/expect-utils@npm:29.4.3" + dependencies: + jest-get-type: ^29.4.3 + checksum: 2bbed39ff2fb59f5acac465a1ce7303e3b4b62b479e4f386261986c9827f7f799ea912761e22629c5daf10addf8513f16733c14a29c2647bb66d4ee625e9ff92 + languageName: node + linkType: hard + "@jest/fake-timers@npm:^27.0.6": version: 27.0.6 resolution: "@jest/fake-timers@npm:27.0.6" @@ -658,6 +667,15 @@ __metadata: languageName: node linkType: hard +"@jest/schemas@npm:^29.4.3": + version: 29.4.3 + resolution: "@jest/schemas@npm:29.4.3" + dependencies: + "@sinclair/typebox": ^0.25.16 + checksum: ac754e245c19dc39e10ebd41dce09040214c96a4cd8efa143b82148e383e45128f24599195ab4f01433adae4ccfbe2db6574c90db2862ccd8551a86704b5bebd + languageName: node + linkType: hard + "@jest/source-map@npm:^27.0.6": version: 27.0.6 resolution: "@jest/source-map@npm:27.0.6" @@ -729,6 +747,20 @@ __metadata: languageName: node linkType: hard +"@jest/types@npm:^29.4.3": + version: 29.4.3 + resolution: "@jest/types@npm:29.4.3" + dependencies: + "@jest/schemas": ^29.4.3 + "@types/istanbul-lib-coverage": ^2.0.0 + "@types/istanbul-reports": ^3.0.0 + "@types/node": "*" + "@types/yargs": ^17.0.8 + chalk: ^4.0.0 + checksum: 1756f4149d360f98567f56f434144f7af23ed49a2c42889261a314df6b6654c2de70af618fb2ee0ee39cadaf10835b885845557184509503646c9cb9dcc02bac + languageName: node + linkType: hard + "@jridgewell/resolve-uri@npm:^3.0.3": version: 3.1.0 resolution: "@jridgewell/resolve-uri@npm:3.1.0" @@ -834,6 +866,19 @@ __metadata: languageName: node linkType: hard +"@metamask/eslint-config-typescript@npm:^11.1.0": + version: 11.1.0 + resolution: "@metamask/eslint-config-typescript@npm:11.1.0" + peerDependencies: + "@metamask/eslint-config": ^11.0.0 + "@typescript-eslint/eslint-plugin": ^5.42.1 + "@typescript-eslint/parser": ^5.42.1 + eslint: ^8.27.0 + typescript: ~4.8.4 + checksum: 86f20303730fce7a2d6944d133e3d4cf745816bdc202fd17ebd341e4937777c662e80b3c1496a8da7d5e06e39518dec3206c4a4e872d9491f423e792bcdf56db + languageName: node + linkType: hard + "@metamask/eslint-config@npm:^11.1.0": version: 11.1.0 resolution: "@metamask/eslint-config@npm:11.1.0" @@ -871,10 +916,16 @@ __metadata: "@metamask/eslint-config-commonjs": ^11.1.0 "@metamask/eslint-config-jest": ^11.1.0 "@metamask/eslint-config-nodejs": ^11.1.0 + "@metamask/eslint-config-typescript": ^11.1.0 "@metamask/eth-hd-keyring": ^6.0.0 "@metamask/eth-sig-util": 5.0.2 "@metamask/eth-simple-keyring": ^5.0.0 "@metamask/utils": 4.0.0 + "@types/jest": ^29.4.0 + "@types/mocha": ^5.0.0 + "@types/sinon": ^10.0.13 + "@typescript-eslint/eslint-plugin": ^5.53.0 + "@typescript-eslint/parser": ^5.53.0 eslint: ^8.29.0 eslint-config-prettier: ^8.5.0 eslint-plugin-import: ^2.26.0 @@ -888,6 +939,7 @@ __metadata: prettier: ^2.8.1 prettier-plugin-packagejson: ^2.3.0 sinon: ^11.1.1 + ts-jest: ^29.0.3 ts-node: ^10.7.0 typedoc: ^0.23.15 typescript: ~4.8.4 @@ -1067,6 +1119,13 @@ __metadata: languageName: node linkType: hard +"@sinclair/typebox@npm:^0.25.16": + version: 0.25.24 + resolution: "@sinclair/typebox@npm:0.25.24" + checksum: 10219c58f40b8414c50b483b0550445e9710d4fe7b2c4dccb9b66533dd90ba8e024acc776026cebe81e87f06fa24b07fdd7bc30dd277eb9cc386ec50151a3026 + languageName: node + linkType: hard + "@sinonjs/commons@npm:^1.6.0, @sinonjs/commons@npm:^1.7.0, @sinonjs/commons@npm:^1.8.3": version: 1.8.3 resolution: "@sinonjs/commons@npm:1.8.3" @@ -1248,6 +1307,16 @@ __metadata: languageName: node linkType: hard +"@types/jest@npm:^29.4.0": + version: 29.4.0 + resolution: "@types/jest@npm:29.4.0" + dependencies: + expect: ^29.0.0 + pretty-format: ^29.0.0 + checksum: 23760282362a252e6690314584d83a47512d4cd61663e957ed3398ecf98195fe931c45606ee2f9def12f8ed7d8aa102d492ec42d26facdaf8b78094a31e6568e + languageName: node + linkType: hard + "@types/json-schema@npm:^7.0.9": version: 7.0.11 resolution: "@types/json-schema@npm:7.0.11" @@ -1269,6 +1338,13 @@ __metadata: languageName: node linkType: hard +"@types/mocha@npm:^5.0.0": + version: 5.2.7 + resolution: "@types/mocha@npm:5.2.7" + checksum: 446e64292f37f4eac9221161f4c1026dd4a0dbeea0f16c4617227fcf5a1286b53d97e36a32ff7cb3a0435ab78791dd43e9ac1006f92abedb47d7d1d7636cb55c + languageName: node + linkType: hard + "@types/ms@npm:*": version: 0.7.31 resolution: "@types/ms@npm:0.7.31" @@ -1315,6 +1391,22 @@ __metadata: languageName: node linkType: hard +"@types/sinon@npm:^10.0.13": + version: 10.0.13 + resolution: "@types/sinon@npm:10.0.13" + dependencies: + "@types/sinonjs__fake-timers": "*" + checksum: 46a14c888db50f0098ec53d451877e0111d878ec4a653b9e9ed7f8e54de386d6beb0e528ddc3e95cd3361a8ab9ad54e4cca33cd88d45b9227b83e9fc8fb6688a + languageName: node + linkType: hard + +"@types/sinonjs__fake-timers@npm:*": + version: 8.1.2 + resolution: "@types/sinonjs__fake-timers@npm:8.1.2" + checksum: bbc73a5ab6c0ec974929392f3d6e1e8db4ebad97ec506d785301e1c3d8a4f98a35b1aa95b97035daef02886fd8efd7788a2fa3ced2ec7105988bfd8dce61eedd + languageName: node + linkType: hard + "@types/stack-utils@npm:^2.0.0": version: 2.0.0 resolution: "@types/stack-utils@npm:2.0.0" @@ -1338,6 +1430,56 @@ __metadata: languageName: node linkType: hard +"@types/yargs@npm:^17.0.8": + version: 17.0.22 + resolution: "@types/yargs@npm:17.0.22" + dependencies: + "@types/yargs-parser": "*" + checksum: 0773523fda71bafdc52f13f5970039e535a353665a60ba9261149a5c9c2b908242e6e77fbb7a8c06931ec78ce889d64d09673c68ba23eb5f5742d5385d0d1982 + languageName: node + linkType: hard + +"@typescript-eslint/eslint-plugin@npm:^5.53.0": + version: 5.53.0 + resolution: "@typescript-eslint/eslint-plugin@npm:5.53.0" + dependencies: + "@typescript-eslint/scope-manager": 5.53.0 + "@typescript-eslint/type-utils": 5.53.0 + "@typescript-eslint/utils": 5.53.0 + debug: ^4.3.4 + grapheme-splitter: ^1.0.4 + ignore: ^5.2.0 + natural-compare-lite: ^1.4.0 + regexpp: ^3.2.0 + semver: ^7.3.7 + tsutils: ^3.21.0 + peerDependencies: + "@typescript-eslint/parser": ^5.0.0 + eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 + peerDependenciesMeta: + typescript: + optional: true + checksum: 12dffe65969d8e5248c86a700fe46a737e55ecafb276933e747b4731eab6266fe55e2d43a34b8b340179fe248e127d861cd016a7614b1b9804cd0687c99616d1 + languageName: node + linkType: hard + +"@typescript-eslint/parser@npm:^5.53.0": + version: 5.53.0 + resolution: "@typescript-eslint/parser@npm:5.53.0" + dependencies: + "@typescript-eslint/scope-manager": 5.53.0 + "@typescript-eslint/types": 5.53.0 + "@typescript-eslint/typescript-estree": 5.53.0 + debug: ^4.3.4 + peerDependencies: + eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 + peerDependenciesMeta: + typescript: + optional: true + checksum: 979e5d63793a9e64998b1f956ba0f00f8a2674db3a664fafce7b2433323f5248bd776af8305e2419d73a9d94c55176fee099abc5c153b4cc52e5765c725c1edd + languageName: node + linkType: hard + "@typescript-eslint/scope-manager@npm:5.46.0": version: 5.46.0 resolution: "@typescript-eslint/scope-manager@npm:5.46.0" @@ -1348,6 +1490,33 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/scope-manager@npm:5.53.0": + version: 5.53.0 + resolution: "@typescript-eslint/scope-manager@npm:5.53.0" + dependencies: + "@typescript-eslint/types": 5.53.0 + "@typescript-eslint/visitor-keys": 5.53.0 + checksum: 51f31dc01e95908611f402441f58404da80a338c0237b2b82f4a7b0b2e8868c4bfe8f7cf44b2567dd56533de609156a5d4ac54bb1f9f09c7014b99428aef2543 + languageName: node + linkType: hard + +"@typescript-eslint/type-utils@npm:5.53.0": + version: 5.53.0 + resolution: "@typescript-eslint/type-utils@npm:5.53.0" + dependencies: + "@typescript-eslint/typescript-estree": 5.53.0 + "@typescript-eslint/utils": 5.53.0 + debug: ^4.3.4 + tsutils: ^3.21.0 + peerDependencies: + eslint: "*" + peerDependenciesMeta: + typescript: + optional: true + checksum: 52c40967c5fabd58c2ae8bf519ef89e4feb511e4df630aeaeac8335661a79b6b3a32d30a61a5f1d8acc703f21c4d90751a5d41cda1b35d08867524da11bc2e1d + languageName: node + linkType: hard + "@typescript-eslint/types@npm:5.46.0": version: 5.46.0 resolution: "@typescript-eslint/types@npm:5.46.0" @@ -1355,6 +1524,13 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/types@npm:5.53.0": + version: 5.53.0 + resolution: "@typescript-eslint/types@npm:5.53.0" + checksum: b0eaf23de4ab13697d4d2095838c959a3f410c30f0d19091e5ca08e62320c3cc3c72bcb631823fb6a4fbb31db0a059e386a0801244930d0a88a6a698e5f46548 + languageName: node + linkType: hard + "@typescript-eslint/typescript-estree@npm:5.46.0": version: 5.46.0 resolution: "@typescript-eslint/typescript-estree@npm:5.46.0" @@ -1373,6 +1549,42 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/typescript-estree@npm:5.53.0": + version: 5.53.0 + resolution: "@typescript-eslint/typescript-estree@npm:5.53.0" + dependencies: + "@typescript-eslint/types": 5.53.0 + "@typescript-eslint/visitor-keys": 5.53.0 + debug: ^4.3.4 + globby: ^11.1.0 + is-glob: ^4.0.3 + semver: ^7.3.7 + tsutils: ^3.21.0 + peerDependenciesMeta: + typescript: + optional: true + checksum: 6e119c8e4167c8495d728c5556a834545a9c064918dd5e7b79b0d836726f4f8e2a0297b0ac82bf2b71f1e5427552217d0b59d8fb1406fd79bd3bf91b75dca873 + languageName: node + linkType: hard + +"@typescript-eslint/utils@npm:5.53.0": + version: 5.53.0 + resolution: "@typescript-eslint/utils@npm:5.53.0" + dependencies: + "@types/json-schema": ^7.0.9 + "@types/semver": ^7.3.12 + "@typescript-eslint/scope-manager": 5.53.0 + "@typescript-eslint/types": 5.53.0 + "@typescript-eslint/typescript-estree": 5.53.0 + eslint-scope: ^5.1.1 + eslint-utils: ^3.0.0 + semver: ^7.3.7 + peerDependencies: + eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 + checksum: 18e6bac14ae853385a74123759850bca367904723e170c37416fc014673eb714afb6bb090367bff61494a8387e941b6af65ee5f4f845f7177fabb4df85e01643 + languageName: node + linkType: hard + "@typescript-eslint/utils@npm:^5.10.0": version: 5.46.0 resolution: "@typescript-eslint/utils@npm:5.46.0" @@ -1401,6 +1613,16 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/visitor-keys@npm:5.53.0": + version: 5.53.0 + resolution: "@typescript-eslint/visitor-keys@npm:5.53.0" + dependencies: + "@typescript-eslint/types": 5.53.0 + eslint-visitor-keys: ^3.3.0 + checksum: 090695883c15364c6f401e97f56b13db0f31c1114f3bd22562bd41734864d27f6a3c80de33957e9dedab2d5f94b0f4480ba3fde1d4574e74dca4593917b7b54a + languageName: node + linkType: hard + "abab@npm:^2.0.3, abab@npm:^2.0.5": version: 2.0.5 resolution: "abab@npm:2.0.5" @@ -1916,6 +2138,15 @@ __metadata: languageName: node linkType: hard +"bs-logger@npm:0.x": + version: 0.2.6 + resolution: "bs-logger@npm:0.2.6" + dependencies: + fast-json-stable-stringify: 2.x + checksum: d34bdaf68c64bd099ab97c3ea608c9ae7d3f5faa1178b3f3f345acd94e852e608b2d4f9103fb2e503f5e69780e98293df41691b84be909b41cf5045374d54606 + languageName: node + linkType: hard + "bs58@npm:^4.0.0": version: 4.0.1 resolution: "bs58@npm:4.0.1" @@ -2072,6 +2303,13 @@ __metadata: languageName: node linkType: hard +"ci-info@npm:^3.2.0": + version: 3.8.0 + resolution: "ci-info@npm:3.8.0" + checksum: d0a4d3160497cae54294974a7246202244fff031b0a6ea20dd57b10ec510aa17399c41a1b0982142c105f3255aff2173e5c0dd7302ee1b2f28ba3debda375098 + languageName: node + linkType: hard + "cipher-base@npm:^1.0.0, cipher-base@npm:^1.0.1, cipher-base@npm:^1.0.3": version: 1.0.4 resolution: "cipher-base@npm:1.0.4" @@ -2420,6 +2658,13 @@ __metadata: languageName: node linkType: hard +"diff-sequences@npm:^29.4.3": + version: 29.4.3 + resolution: "diff-sequences@npm:29.4.3" + checksum: 28b265e04fdddcf7f9f814effe102cc95a9dec0564a579b5aed140edb24fc345c611ca52d76d725a3cab55d3888b915b5e8a4702e0f6058968a90fa5f41fcde7 + languageName: node + linkType: hard + "diff@npm:^4.0.1": version: 4.0.2 resolution: "diff@npm:4.0.2" @@ -3073,6 +3318,19 @@ __metadata: languageName: node linkType: hard +"expect@npm:^29.0.0": + version: 29.4.3 + resolution: "expect@npm:29.4.3" + dependencies: + "@jest/expect-utils": ^29.4.3 + jest-get-type: ^29.4.3 + jest-matcher-utils: ^29.4.3 + jest-message-util: ^29.4.3 + jest-util: ^29.4.3 + checksum: ff9dd8c50c0c6fd4b2b00f6dbd7ab0e2063fe1953be81a8c10ae1c005c7f5667ba452918e2efb055504b72b701a4f82575a081a0a7158efb16d87991b0366feb + languageName: node + linkType: hard + "extend@npm:~3.0.2": version: 3.0.2 resolution: "extend@npm:3.0.2" @@ -3121,7 +3379,7 @@ __metadata: languageName: node linkType: hard -"fast-json-stable-stringify@npm:^2.0.0": +"fast-json-stable-stringify@npm:2.x, fast-json-stable-stringify@npm:^2.0.0": version: 2.1.0 resolution: "fast-json-stable-stringify@npm:2.1.0" checksum: b191531e36c607977e5b1c47811158733c34ccb3bfde92c44798929e9b4154884378536d26ad90dfecd32e1ffc09c545d23535ad91b3161a27ddbb8ebe0cbecb @@ -3495,7 +3753,7 @@ __metadata: languageName: node linkType: hard -"graceful-fs@npm:^4.2.3, graceful-fs@npm:^4.2.4, graceful-fs@npm:^4.2.6": +"graceful-fs@npm:^4.2.3, graceful-fs@npm:^4.2.4, graceful-fs@npm:^4.2.6, graceful-fs@npm:^4.2.9": version: 4.2.10 resolution: "graceful-fs@npm:4.2.10" checksum: 3f109d70ae123951905d85032ebeae3c2a5a7a997430df00ea30df0e3a6c60cf6689b109654d6fdacd28810a053348c4d14642da1d075049e6be1ba5216218da @@ -4199,6 +4457,18 @@ __metadata: languageName: node linkType: hard +"jest-diff@npm:^29.4.3": + version: 29.4.3 + resolution: "jest-diff@npm:29.4.3" + dependencies: + chalk: ^4.0.0 + diff-sequences: ^29.4.3 + jest-get-type: ^29.4.3 + pretty-format: ^29.4.3 + checksum: 877fd1edffef6b319688c27b152e5b28e2bc4bcda5ce0ca90d7e137f9fafda4280bae25403d4c0bfd9806c2c0b15d966aa2dfaf5f9928ec8f1ccea7fa1d08ed6 + languageName: node + linkType: hard + "jest-docblock@npm:^27.0.6": version: 27.0.6 resolution: "jest-docblock@npm:27.0.6" @@ -4257,6 +4527,13 @@ __metadata: languageName: node linkType: hard +"jest-get-type@npm:^29.4.3": + version: 29.4.3 + resolution: "jest-get-type@npm:29.4.3" + checksum: 6ac7f2dde1c65e292e4355b6c63b3a4897d7e92cb4c8afcf6d397f2682f8080e094c8b0b68205a74d269882ec06bf696a9de6cd3e1b7333531e5ed7b112605ce + languageName: node + linkType: hard + "jest-haste-map@npm:^27.0.6": version: 27.0.6 resolution: "jest-haste-map@npm:27.0.6" @@ -4329,6 +4606,18 @@ __metadata: languageName: node linkType: hard +"jest-matcher-utils@npm:^29.4.3": + version: 29.4.3 + resolution: "jest-matcher-utils@npm:29.4.3" + dependencies: + chalk: ^4.0.0 + jest-diff: ^29.4.3 + jest-get-type: ^29.4.3 + pretty-format: ^29.4.3 + checksum: 9e13cbe42d2113bab2691110c7c3ba5cec3b94abad2727e1de90929d0f67da444e9b2066da3b476b5bf788df53a8ede0e0a950cfb06a04e4d6d566d115ee4f1d + languageName: node + linkType: hard + "jest-message-util@npm:^27.0.6": version: 27.0.6 resolution: "jest-message-util@npm:27.0.6" @@ -4346,6 +4635,23 @@ __metadata: languageName: node linkType: hard +"jest-message-util@npm:^29.4.3": + version: 29.4.3 + resolution: "jest-message-util@npm:29.4.3" + dependencies: + "@babel/code-frame": ^7.12.13 + "@jest/types": ^29.4.3 + "@types/stack-utils": ^2.0.0 + chalk: ^4.0.0 + graceful-fs: ^4.2.9 + micromatch: ^4.0.4 + pretty-format: ^29.4.3 + slash: ^3.0.0 + stack-utils: ^2.0.3 + checksum: 64f06b9550021e68da0059020bea8691283cf818918810bb67192d7b7fb9b691c7eadf55c2ca3cd04df5394918f2327245077095cdc0d6b04be3532d2c7d0ced + languageName: node + linkType: hard + "jest-mock@npm:^27.0.6": version: 27.0.6 resolution: "jest-mock@npm:27.0.6" @@ -4523,6 +4829,20 @@ __metadata: languageName: node linkType: hard +"jest-util@npm:^29.0.0, jest-util@npm:^29.4.3": + version: 29.4.3 + resolution: "jest-util@npm:29.4.3" + dependencies: + "@jest/types": ^29.4.3 + "@types/node": "*" + chalk: ^4.0.0 + ci-info: ^3.2.0 + graceful-fs: ^4.2.9 + picomatch: ^2.2.3 + checksum: 606b3e6077895baf8fb4ad4d08c134f37a6b81d5ba77ae654c942b1ae4b7294ab3b5a0eb93db34f129407b367970cf3b76bf5c80897b30f215f2bc8bf20a5f3f + languageName: node + linkType: hard + "jest-validate@npm:^27.0.6": version: 27.0.6 resolution: "jest-validate@npm:27.0.6" @@ -4738,6 +5058,15 @@ __metadata: languageName: node linkType: hard +"json5@npm:^2.2.3": + version: 2.2.3 + resolution: "json5@npm:2.2.3" + bin: + json5: lib/cli.js + checksum: 2a7436a93393830bce797d4626275152e37e877b265e94ca69c99e3d20c2b9dab021279146a39cdb700e71b2dd32a4cebd1514cd57cee102b1af906ce5040349 + languageName: node + linkType: hard + "jsonc-parser@npm:^3.2.0": version: 3.2.0 resolution: "jsonc-parser@npm:3.2.0" @@ -4834,6 +5163,13 @@ __metadata: languageName: node linkType: hard +"lodash.memoize@npm:4.x": + version: 4.1.2 + resolution: "lodash.memoize@npm:4.1.2" + checksum: 9ff3942feeccffa4f1fafa88d32f0d24fdc62fd15ded5a74a5f950ff5f0c6f61916157246744c620173dddf38d37095a92327d5fd3861e2063e736a5c207d089 + languageName: node + linkType: hard + "lodash.merge@npm:^4.6.2": version: 4.6.2 resolution: "lodash.merge@npm:4.6.2" @@ -4880,7 +5216,7 @@ __metadata: languageName: node linkType: hard -"make-error@npm:^1.1.1": +"make-error@npm:1.x, make-error@npm:^1.1.1": version: 1.3.6 resolution: "make-error@npm:1.3.6" checksum: b86e5e0e25f7f777b77fabd8e2cbf15737972869d852a22b7e73c17623928fccb826d8e46b9951501d3f20e51ad74ba8c59ed584f610526a48f8ccf88aaec402 @@ -5135,6 +5471,13 @@ __metadata: languageName: node linkType: hard +"natural-compare-lite@npm:^1.4.0": + version: 1.4.0 + resolution: "natural-compare-lite@npm:1.4.0" + checksum: 5222ac3986a2b78dd6069ac62cbb52a7bf8ffc90d972ab76dfe7b01892485d229530ed20d0c62e79a6b363a663b273db3bde195a1358ce9e5f779d4453887225 + languageName: node + linkType: hard + "natural-compare@npm:^1.4.0": version: 1.4.0 resolution: "natural-compare@npm:1.4.0" @@ -5657,6 +6000,17 @@ __metadata: languageName: node linkType: hard +"pretty-format@npm:^29.0.0, pretty-format@npm:^29.4.3": + version: 29.4.3 + resolution: "pretty-format@npm:29.4.3" + dependencies: + "@jest/schemas": ^29.4.3 + ansi-styles: ^5.0.0 + react-is: ^18.0.0 + checksum: 3258b9a010bd79b3cf73783ad1e4592b6326fc981b6e31b742f316f14e7fbac09b48a9dbf274d092d9bde404db9fe16f518370e121837dc078a597392e6e5cc5 + languageName: node + linkType: hard + "process-nextick-args@npm:~2.0.0": version: 2.0.1 resolution: "process-nextick-args@npm:2.0.1" @@ -5735,6 +6089,13 @@ __metadata: languageName: node linkType: hard +"react-is@npm:^18.0.0": + version: 18.2.0 + resolution: "react-is@npm:18.2.0" + checksum: e72d0ba81b5922759e4aff17e0252bd29988f9642ed817f56b25a3e217e13eea8a7f2322af99a06edb779da12d5d636e9fda473d620df9a3da0df2a74141d53e + languageName: node + linkType: hard + "read-package-json-fast@npm:^2.0.1": version: 2.0.2 resolution: "read-package-json-fast@npm:2.0.2" @@ -5997,16 +6358,7 @@ __metadata: languageName: node linkType: hard -"semver@npm:^6.0.0, semver@npm:^6.1.0, semver@npm:^6.3.0": - version: 6.3.0 - resolution: "semver@npm:6.3.0" - bin: - semver: ./bin/semver.js - checksum: 1b26ecf6db9e8292dd90df4e781d91875c0dcc1b1909e70f5d12959a23c7eebb8f01ea581c00783bbee72ceeaad9505797c381756326073850dc36ed284b21b9 - languageName: node - linkType: hard - -"semver@npm:^7.3.2, semver@npm:^7.3.5, semver@npm:^7.3.7, semver@npm:^7.3.8": +"semver@npm:7.x, semver@npm:^7.3.2, semver@npm:^7.3.5, semver@npm:^7.3.7, semver@npm:^7.3.8": version: 7.3.8 resolution: "semver@npm:7.3.8" dependencies: @@ -6017,6 +6369,15 @@ __metadata: languageName: node linkType: hard +"semver@npm:^6.0.0, semver@npm:^6.1.0, semver@npm:^6.3.0": + version: 6.3.0 + resolution: "semver@npm:6.3.0" + bin: + semver: ./bin/semver.js + checksum: 1b26ecf6db9e8292dd90df4e781d91875c0dcc1b1909e70f5d12959a23c7eebb8f01ea581c00783bbee72ceeaad9505797c381756326073850dc36ed284b21b9 + languageName: node + linkType: hard + "set-blocking@npm:^2.0.0, set-blocking@npm:~2.0.0": version: 2.0.0 resolution: "set-blocking@npm:2.0.0" @@ -6566,6 +6927,39 @@ __metadata: languageName: node linkType: hard +"ts-jest@npm:^29.0.3": + version: 29.0.5 + resolution: "ts-jest@npm:29.0.5" + dependencies: + bs-logger: 0.x + fast-json-stable-stringify: 2.x + jest-util: ^29.0.0 + json5: ^2.2.3 + lodash.memoize: 4.x + make-error: 1.x + semver: 7.x + yargs-parser: ^21.0.1 + peerDependencies: + "@babel/core": ">=7.0.0-beta.0 <8" + "@jest/types": ^29.0.0 + babel-jest: ^29.0.0 + jest: ^29.0.0 + typescript: ">=4.3" + peerDependenciesMeta: + "@babel/core": + optional: true + "@jest/types": + optional: true + babel-jest: + optional: true + esbuild: + optional: true + bin: + ts-jest: cli.js + checksum: f60f129c2287f4c963d9ee2677132496c5c5a5d39c27ad234199a1140c26318a7d5bda34890ab0e30636ec42a8de28f84487c09e9dcec639c9c67812b3a38373 + languageName: node + linkType: hard + "ts-node@npm:^10.7.0": version: 10.9.1 resolution: "ts-node@npm:10.9.1" @@ -7055,6 +7449,13 @@ __metadata: languageName: node linkType: hard +"yargs-parser@npm:^21.0.1": + version: 21.1.1 + resolution: "yargs-parser@npm:21.1.1" + checksum: ed2d96a616a9e3e1cc7d204c62ecc61f7aaab633dcbfab2c6df50f7f87b393993fe6640d017759fe112d0cb1e0119f2b4150a87305cc873fd90831c6a58ccf1c + languageName: node + linkType: hard + "yargs@npm:^16.0.3, yargs@npm:^16.2.0": version: 16.2.0 resolution: "yargs@npm:16.2.0" From d014dbc187de6ee34c2afe80bba9c848aa225446 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 23 Feb 2023 18:03:05 -0300 Subject: [PATCH 007/109] Bump jest --- package.json | 2 +- yarn.lock | 2020 +++++++++++++++++++++----------------------------- 2 files changed, 827 insertions(+), 1195 deletions(-) diff --git a/package.json b/package.json index 40c0ae37..34e8f47a 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "eslint-plugin-node": "^11.1.0", "eslint-plugin-prettier": "^4.2.1", "ethereumjs-wallet": "^1.0.1", - "jest": "^27.0.6", + "jest": "^29.0.0", "prettier": "^2.8.1", "prettier-plugin-packagejson": "^2.3.0", "sinon": "^11.1.1", diff --git a/yarn.lock b/yarn.lock index b1d540cc..3f9608d6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5,6 +5,25 @@ __metadata: version: 6 cacheKey: 8 +"@ampproject/remapping@npm:^2.2.0": + version: 2.2.0 + resolution: "@ampproject/remapping@npm:2.2.0" + dependencies: + "@jridgewell/gen-mapping": ^0.1.0 + "@jridgewell/trace-mapping": ^0.3.9 + checksum: d74d170d06468913921d72430259424b7e4c826b5a7d39ff839a29d547efb97dc577caa8ba3fb5cf023624e9af9d09651afc3d4112a45e2050328abc9b3a2292 + languageName: node + linkType: hard + +"@babel/code-frame@npm:^7.0.0, @babel/code-frame@npm:^7.18.6": + version: 7.18.6 + resolution: "@babel/code-frame@npm:7.18.6" + dependencies: + "@babel/highlight": ^7.18.6 + checksum: 195e2be3172d7684bf95cff69ae3b7a15a9841ea9d27d3c843662d50cdd7d6470fd9c8e64be84d031117e4a4083486effba39f9aef6bbb2c89f7f21bcfba33ba + languageName: node + linkType: hard + "@babel/code-frame@npm:^7.12.13, @babel/code-frame@npm:^7.14.5": version: 7.14.5 resolution: "@babel/code-frame@npm:7.14.5" @@ -14,33 +33,33 @@ __metadata: languageName: node linkType: hard -"@babel/compat-data@npm:^7.14.5": - version: 7.14.7 - resolution: "@babel/compat-data@npm:7.14.7" - checksum: dcf7a72cb650206857a98cce1ab0973e67689f19afc3b30cabff6dbddf563f188d54d3b3f92a70c6bc1feb9049d8b2e601540e1d435b6866c77bffad0a441c9f +"@babel/compat-data@npm:^7.20.5": + version: 7.21.0 + resolution: "@babel/compat-data@npm:7.21.0" + checksum: dbf632c532f9c75ba0be7d1dc9f6cd3582501af52f10a6b90415d634ec5878735bd46064c91673b10317af94d4cc99c4da5bd9d955978cdccb7905fc33291e4d languageName: node linkType: hard -"@babel/core@npm:^7.1.0, @babel/core@npm:^7.7.2, @babel/core@npm:^7.7.5": - version: 7.14.6 - resolution: "@babel/core@npm:7.14.6" +"@babel/core@npm:^7.11.6, @babel/core@npm:^7.12.3": + version: 7.21.0 + resolution: "@babel/core@npm:7.21.0" dependencies: - "@babel/code-frame": ^7.14.5 - "@babel/generator": ^7.14.5 - "@babel/helper-compilation-targets": ^7.14.5 - "@babel/helper-module-transforms": ^7.14.5 - "@babel/helpers": ^7.14.6 - "@babel/parser": ^7.14.6 - "@babel/template": ^7.14.5 - "@babel/traverse": ^7.14.5 - "@babel/types": ^7.14.5 + "@ampproject/remapping": ^2.2.0 + "@babel/code-frame": ^7.18.6 + "@babel/generator": ^7.21.0 + "@babel/helper-compilation-targets": ^7.20.7 + "@babel/helper-module-transforms": ^7.21.0 + "@babel/helpers": ^7.21.0 + "@babel/parser": ^7.21.0 + "@babel/template": ^7.20.7 + "@babel/traverse": ^7.21.0 + "@babel/types": ^7.21.0 convert-source-map: ^1.7.0 debug: ^4.1.0 gensync: ^1.0.0-beta.2 - json5: ^2.1.2 + json5: ^2.2.2 semver: ^6.3.0 - source-map: ^0.5.0 - checksum: 6ede604d8de7a103c087b96a58548a3d27efb9e53de6ecc84f4b4ca947cd91f02b0289fc04557b04eb6e31243dbeabdcdb8fd520a1780f284333f56eb1b58913 + checksum: 357f4dd3638861ceebf6d95ff49ad8b902065ee8b7b352621deed5666c2a6d702a48ca7254dba23ecae2a0afb67d20f90db7dd645c3b75e35e72ad9776c671aa languageName: node linkType: hard @@ -55,17 +74,37 @@ __metadata: languageName: node linkType: hard -"@babel/helper-compilation-targets@npm:^7.14.5": - version: 7.14.5 - resolution: "@babel/helper-compilation-targets@npm:7.14.5" +"@babel/generator@npm:^7.21.0, @babel/generator@npm:^7.21.1": + version: 7.21.1 + resolution: "@babel/generator@npm:7.21.1" dependencies: - "@babel/compat-data": ^7.14.5 - "@babel/helper-validator-option": ^7.14.5 - browserslist: ^4.16.6 + "@babel/types": ^7.21.0 + "@jridgewell/gen-mapping": ^0.3.2 + "@jridgewell/trace-mapping": ^0.3.17 + jsesc: ^2.5.1 + checksum: 69085a211ff91a7a608ee3f86e6fcb9cf5e724b756d792a713b0c328a671cd3e423e1ef1b12533f366baba0616caffe0a7ba9d328727eab484de5961badbef00 + languageName: node + linkType: hard + +"@babel/helper-compilation-targets@npm:^7.20.7": + version: 7.20.7 + resolution: "@babel/helper-compilation-targets@npm:7.20.7" + dependencies: + "@babel/compat-data": ^7.20.5 + "@babel/helper-validator-option": ^7.18.6 + browserslist: ^4.21.3 + lru-cache: ^5.1.1 semver: ^6.3.0 peerDependencies: "@babel/core": ^7.0.0 - checksum: 02df2c6d1bc5f2336f380945aa266a3a65d057c5eff6be667235a8005048b21f69e4aaebc8e43ccfc2fb406688383ae8e572f257413febf244772e5e7af5fd7f + checksum: 8c32c873ba86e2e1805b30e0807abd07188acbe00ebb97576f0b09061cc65007f1312b589eccb4349c5a8c7f8bb9f2ab199d41da7030bf103d9f347dcd3a3cf4 + languageName: node + linkType: hard + +"@babel/helper-environment-visitor@npm:^7.18.9": + version: 7.18.9 + resolution: "@babel/helper-environment-visitor@npm:7.18.9" + checksum: b25101f6162ddca2d12da73942c08ad203d7668e06663df685634a8fde54a98bc015f6f62938e8554457a592a024108d45b8f3e651fd6dcdb877275b73cc4420 languageName: node linkType: hard @@ -80,6 +119,16 @@ __metadata: languageName: node linkType: hard +"@babel/helper-function-name@npm:^7.21.0": + version: 7.21.0 + resolution: "@babel/helper-function-name@npm:7.21.0" + dependencies: + "@babel/template": ^7.20.7 + "@babel/types": ^7.21.0 + checksum: d63e63c3e0e3e8b3138fa47b0cd321148a300ef12b8ee951196994dcd2a492cc708aeda94c2c53759a5c9177fffaac0fd8778791286746f72a000976968daf4e + languageName: node + linkType: hard + "@babel/helper-get-function-arity@npm:^7.14.5": version: 7.14.5 resolution: "@babel/helper-get-function-arity@npm:7.14.5" @@ -98,46 +147,37 @@ __metadata: languageName: node linkType: hard -"@babel/helper-member-expression-to-functions@npm:^7.14.5": - version: 7.14.7 - resolution: "@babel/helper-member-expression-to-functions@npm:7.14.7" +"@babel/helper-hoist-variables@npm:^7.18.6": + version: 7.18.6 + resolution: "@babel/helper-hoist-variables@npm:7.18.6" dependencies: - "@babel/types": ^7.14.5 - checksum: 1768b849224002d7a8553226ad73e1e957fb6184b68234d5df7a45cf8e4453ed1208967c1cace1a4d973b223ddc881d105e372945ec688f09485dff0e8ed6180 + "@babel/types": ^7.18.6 + checksum: fd9c35bb435fda802bf9ff7b6f2df06308a21277c6dec2120a35b09f9de68f68a33972e2c15505c1a1a04b36ec64c9ace97d4a9e26d6097b76b4396b7c5fa20f languageName: node linkType: hard -"@babel/helper-module-imports@npm:^7.14.5": - version: 7.14.5 - resolution: "@babel/helper-module-imports@npm:7.14.5" +"@babel/helper-module-imports@npm:^7.18.6": + version: 7.18.6 + resolution: "@babel/helper-module-imports@npm:7.18.6" dependencies: - "@babel/types": ^7.14.5 - checksum: b98279908698a50a22634e683924cb25eb93edf1bf28ac65691dfa82d7a1a4dae4e6b12b8ef9f9a50171ca484620bce544f270873c53505d8a45364c5b665c0c + "@babel/types": ^7.18.6 + checksum: f393f8a3b3304b1b7a288a38c10989de754f01d29caf62ce7c4e5835daf0a27b81f3ac687d9d2780d39685aae7b55267324b512150e7b2be967b0c493b6a1def languageName: node linkType: hard -"@babel/helper-module-transforms@npm:^7.14.5": - version: 7.14.5 - resolution: "@babel/helper-module-transforms@npm:7.14.5" +"@babel/helper-module-transforms@npm:^7.21.0": + version: 7.21.2 + resolution: "@babel/helper-module-transforms@npm:7.21.2" dependencies: - "@babel/helper-module-imports": ^7.14.5 - "@babel/helper-replace-supers": ^7.14.5 - "@babel/helper-simple-access": ^7.14.5 - "@babel/helper-split-export-declaration": ^7.14.5 - "@babel/helper-validator-identifier": ^7.14.5 - "@babel/template": ^7.14.5 - "@babel/traverse": ^7.14.5 - "@babel/types": ^7.14.5 - checksum: f5d64c0242ec8949ee09069a634d28ae750ab22f9533ea90eab9eaf3405032a33b0b329a63fac0a7901482efb8a388a06279f7544225a0bc3c1b92b306ab2b6e - languageName: node - linkType: hard - -"@babel/helper-optimise-call-expression@npm:^7.14.5": - version: 7.14.5 - resolution: "@babel/helper-optimise-call-expression@npm:7.14.5" - dependencies: - "@babel/types": ^7.14.5 - checksum: c7af558c63eb5449bf2249f1236d892ed54a400cb6c721756cde573b996c12c64dee6b57fa18ad1a0025d152e6f689444f7ea32997a1d56e1af66c3eda18843d + "@babel/helper-environment-visitor": ^7.18.9 + "@babel/helper-module-imports": ^7.18.6 + "@babel/helper-simple-access": ^7.20.2 + "@babel/helper-split-export-declaration": ^7.18.6 + "@babel/helper-validator-identifier": ^7.19.1 + "@babel/template": ^7.20.7 + "@babel/traverse": ^7.21.2 + "@babel/types": ^7.21.2 + checksum: 8a1c129a4f90bdf97d8b6e7861732c9580f48f877aaaafbc376ce2482febebcb8daaa1de8bc91676d12886487603f8c62a44f9e90ee76d6cac7f9225b26a49e1 languageName: node linkType: hard @@ -148,24 +188,19 @@ __metadata: languageName: node linkType: hard -"@babel/helper-replace-supers@npm:^7.14.5": - version: 7.14.5 - resolution: "@babel/helper-replace-supers@npm:7.14.5" - dependencies: - "@babel/helper-member-expression-to-functions": ^7.14.5 - "@babel/helper-optimise-call-expression": ^7.14.5 - "@babel/traverse": ^7.14.5 - "@babel/types": ^7.14.5 - checksum: 35d33cfe473f9fb5cc1110ee259686179ecd07e00e07d9eb03de998e47f49d59fc2e183cf6be0793fd6bec24510b893415e52ace93ae940f94663c4a02c6fbd0 +"@babel/helper-plugin-utils@npm:^7.18.6": + version: 7.20.2 + resolution: "@babel/helper-plugin-utils@npm:7.20.2" + checksum: f6cae53b7fdb1bf3abd50fa61b10b4470985b400cc794d92635da1e7077bb19729f626adc0741b69403d9b6e411cddddb9c0157a709cc7c4eeb41e663be5d74b languageName: node linkType: hard -"@babel/helper-simple-access@npm:^7.14.5": - version: 7.14.5 - resolution: "@babel/helper-simple-access@npm:7.14.5" +"@babel/helper-simple-access@npm:^7.20.2": + version: 7.20.2 + resolution: "@babel/helper-simple-access@npm:7.20.2" dependencies: - "@babel/types": ^7.14.5 - checksum: cd795416bd10dd2f1bdebb36f1af08bf263024fdbf789cfda5dd1fbf4fea1fd0375e21d0bcb910a7d49b09b7480340797dcdfc888fbc895aeae45c145358ad75 + "@babel/types": ^7.20.2 + checksum: ad1e96ee2e5f654ffee2369a586e5e8d2722bf2d8b028a121b4c33ebae47253f64d420157b9f0a8927aea3a9e0f18c0103e74fdd531815cf3650a0a4adca11a1 languageName: node linkType: hard @@ -178,6 +213,15 @@ __metadata: languageName: node linkType: hard +"@babel/helper-split-export-declaration@npm:^7.18.6": + version: 7.18.6 + resolution: "@babel/helper-split-export-declaration@npm:7.18.6" + dependencies: + "@babel/types": ^7.18.6 + checksum: c6d3dede53878f6be1d869e03e9ffbbb36f4897c7cc1527dc96c56d127d834ffe4520a6f7e467f5b6f3c2843ea0e81a7819d66ae02f707f6ac057f3d57943a2b + languageName: node + linkType: hard + "@babel/helper-string-parser@npm:^7.19.4": version: 7.19.4 resolution: "@babel/helper-string-parser@npm:7.19.4" @@ -185,28 +229,28 @@ __metadata: languageName: node linkType: hard -"@babel/helper-validator-identifier@npm:^7.14.5, @babel/helper-validator-identifier@npm:^7.19.1": +"@babel/helper-validator-identifier@npm:^7.14.5, @babel/helper-validator-identifier@npm:^7.18.6, @babel/helper-validator-identifier@npm:^7.19.1": version: 7.19.1 resolution: "@babel/helper-validator-identifier@npm:7.19.1" checksum: 0eca5e86a729162af569b46c6c41a63e18b43dbe09fda1d2a3c8924f7d617116af39cac5e4cd5d431bb760b4dca3c0970e0c444789b1db42bcf1fa41fbad0a3a languageName: node linkType: hard -"@babel/helper-validator-option@npm:^7.14.5": - version: 7.14.5 - resolution: "@babel/helper-validator-option@npm:7.14.5" - checksum: 1b25c34a5cb3d8602280f33b9ab687d2a77895e3616458d0f70ddc450ada9b05e342c44f322bc741d51b252e84cff6ec44ae93d622a3354828579a643556b523 +"@babel/helper-validator-option@npm:^7.18.6": + version: 7.21.0 + resolution: "@babel/helper-validator-option@npm:7.21.0" + checksum: 8ece4c78ffa5461fd8ab6b6e57cc51afad59df08192ed5d84b475af4a7193fc1cb794b59e3e7be64f3cdc4df7ac78bf3dbb20c129d7757ae078e6279ff8c2f07 languageName: node linkType: hard -"@babel/helpers@npm:^7.14.6": - version: 7.14.6 - resolution: "@babel/helpers@npm:7.14.6" +"@babel/helpers@npm:^7.21.0": + version: 7.21.0 + resolution: "@babel/helpers@npm:7.21.0" dependencies: - "@babel/template": ^7.14.5 - "@babel/traverse": ^7.14.5 - "@babel/types": ^7.14.5 - checksum: fe4e73975b062a8b8b95f499f4ac1064c9a53d4ee83cc273c2420250f6a46b59f1f5e35050d41ebe04efd7885a28ceea6f4f16d8eb091e24622f2a4a5eb20f23 + "@babel/template": ^7.20.7 + "@babel/traverse": ^7.21.0 + "@babel/types": ^7.21.0 + checksum: 9370dad2bb665c551869a08ac87c8bdafad53dbcdce1f5c5d498f51811456a3c005d9857562715151a0f00b2e912ac8d89f56574f837b5689f5f5072221cdf54 languageName: node linkType: hard @@ -221,7 +265,18 @@ __metadata: languageName: node linkType: hard -"@babel/parser@npm:^7.1.0, @babel/parser@npm:^7.14.5, @babel/parser@npm:^7.14.6, @babel/parser@npm:^7.14.7, @babel/parser@npm:^7.7.2": +"@babel/highlight@npm:^7.18.6": + version: 7.18.6 + resolution: "@babel/highlight@npm:7.18.6" + dependencies: + "@babel/helper-validator-identifier": ^7.18.6 + chalk: ^2.0.0 + js-tokens: ^4.0.0 + checksum: 92d8ee61549de5ff5120e945e774728e5ccd57fd3b2ed6eace020ec744823d4a98e242be1453d21764a30a14769ecd62170fba28539b211799bbaf232bbb2789 + languageName: node + linkType: hard + +"@babel/parser@npm:^7.1.0, @babel/parser@npm:^7.14.5, @babel/parser@npm:^7.14.7": version: 7.14.7 resolution: "@babel/parser@npm:7.14.7" bin: @@ -230,6 +285,15 @@ __metadata: languageName: node linkType: hard +"@babel/parser@npm:^7.20.7, @babel/parser@npm:^7.21.0, @babel/parser@npm:^7.21.2": + version: 7.21.2 + resolution: "@babel/parser@npm:7.21.2" + bin: + parser: ./bin/babel-parser.js + checksum: e2b89de2c63d4cdd2cafeaea34f389bba729727eec7a8728f736bc472a59396059e3e9fe322c9bed8fd126d201fb609712949dc8783f4cae4806acd9a73da6ff + languageName: node + linkType: hard + "@babel/plugin-syntax-async-generators@npm:^7.8.4": version: 7.8.4 resolution: "@babel/plugin-syntax-async-generators@npm:7.8.4" @@ -285,6 +349,17 @@ __metadata: languageName: node linkType: hard +"@babel/plugin-syntax-jsx@npm:^7.7.2": + version: 7.18.6 + resolution: "@babel/plugin-syntax-jsx@npm:7.18.6" + dependencies: + "@babel/helper-plugin-utils": ^7.18.6 + peerDependencies: + "@babel/core": ^7.0.0-0 + checksum: 6d37ea972970195f1ffe1a54745ce2ae456e0ac6145fae9aa1480f297248b262ea6ebb93010eddb86ebfacb94f57c05a1fc5d232b9a67325b09060299d515c67 + languageName: node + linkType: hard + "@babel/plugin-syntax-logical-assignment-operators@npm:^7.8.3": version: 7.10.4 resolution: "@babel/plugin-syntax-logical-assignment-operators@npm:7.10.4" @@ -384,7 +459,36 @@ __metadata: languageName: node linkType: hard -"@babel/traverse@npm:^7.1.0, @babel/traverse@npm:^7.14.5, @babel/traverse@npm:^7.7.2": +"@babel/template@npm:^7.20.7": + version: 7.20.7 + resolution: "@babel/template@npm:7.20.7" + dependencies: + "@babel/code-frame": ^7.18.6 + "@babel/parser": ^7.20.7 + "@babel/types": ^7.20.7 + checksum: 2eb1a0ab8d415078776bceb3473d07ab746e6bb4c2f6ca46ee70efb284d75c4a32bb0cd6f4f4946dec9711f9c0780e8e5d64b743208deac6f8e9858afadc349e + languageName: node + linkType: hard + +"@babel/traverse@npm:^7.21.0, @babel/traverse@npm:^7.21.2": + version: 7.21.2 + resolution: "@babel/traverse@npm:7.21.2" + dependencies: + "@babel/code-frame": ^7.18.6 + "@babel/generator": ^7.21.1 + "@babel/helper-environment-visitor": ^7.18.9 + "@babel/helper-function-name": ^7.21.0 + "@babel/helper-hoist-variables": ^7.18.6 + "@babel/helper-split-export-declaration": ^7.18.6 + "@babel/parser": ^7.21.2 + "@babel/types": ^7.21.2 + debug: ^4.1.0 + globals: ^11.1.0 + checksum: d851e3f5cfbdc2fac037a014eae7b0707709de50f7d2fbb82ffbf932d3eeba90a77431529371d6e544f8faaf8c6540eeb18fdd8d1c6fa2b61acea0fb47e18d4b + languageName: node + linkType: hard + +"@babel/traverse@npm:^7.7.2": version: 7.14.7 resolution: "@babel/traverse@npm:7.14.7" dependencies: @@ -412,6 +516,17 @@ __metadata: languageName: node linkType: hard +"@babel/types@npm:^7.18.6, @babel/types@npm:^7.20.2, @babel/types@npm:^7.20.7, @babel/types@npm:^7.21.0, @babel/types@npm:^7.21.2": + version: 7.21.2 + resolution: "@babel/types@npm:7.21.2" + dependencies: + "@babel/helper-string-parser": ^7.19.4 + "@babel/helper-validator-identifier": ^7.19.1 + to-fast-properties: ^2.0.0 + checksum: a45a52acde139e575502c6de42c994bdbe262bafcb92ae9381fb54cdf1a3672149086843fda655c7683ce9806e998fd002bbe878fa44984498d0fdc7935ce7ff + languageName: node + linkType: hard + "@bcoe/v8-coverage@npm:^0.2.3": version: 0.2.3 resolution: "@bcoe/v8-coverage@npm:0.2.3" @@ -528,51 +643,50 @@ __metadata: languageName: node linkType: hard -"@jest/console@npm:^27.0.6": - version: 27.0.6 - resolution: "@jest/console@npm:27.0.6" +"@jest/console@npm:^29.4.3": + version: 29.4.3 + resolution: "@jest/console@npm:29.4.3" dependencies: - "@jest/types": ^27.0.6 + "@jest/types": ^29.4.3 "@types/node": "*" chalk: ^4.0.0 - jest-message-util: ^27.0.6 - jest-util: ^27.0.6 + jest-message-util: ^29.4.3 + jest-util: ^29.4.3 slash: ^3.0.0 - checksum: 7f46a0d0fc0cc5eacf39710f29f66693719b3bf6e2ece4a86f0b156e99999e5b6eb2b2b1f3c7922e2c17464ea7fd467b0a12f67a5b457935bce7e5d02ab22d0e + checksum: 8d9b163febe735153b523db527742309f4d598eda22f17f04e030060329bd3da4de7420fc1f7812f7a16f08273654a7de094c4b4e8b81a99dbfc17cfb1629008 languageName: node linkType: hard -"@jest/core@npm:^27.0.6": - version: 27.0.6 - resolution: "@jest/core@npm:27.0.6" +"@jest/core@npm:^29.4.3": + version: 29.4.3 + resolution: "@jest/core@npm:29.4.3" dependencies: - "@jest/console": ^27.0.6 - "@jest/reporters": ^27.0.6 - "@jest/test-result": ^27.0.6 - "@jest/transform": ^27.0.6 - "@jest/types": ^27.0.6 + "@jest/console": ^29.4.3 + "@jest/reporters": ^29.4.3 + "@jest/test-result": ^29.4.3 + "@jest/transform": ^29.4.3 + "@jest/types": ^29.4.3 "@types/node": "*" ansi-escapes: ^4.2.1 chalk: ^4.0.0 - emittery: ^0.8.1 + ci-info: ^3.2.0 exit: ^0.1.2 - graceful-fs: ^4.2.4 - jest-changed-files: ^27.0.6 - jest-config: ^27.0.6 - jest-haste-map: ^27.0.6 - jest-message-util: ^27.0.6 - jest-regex-util: ^27.0.6 - jest-resolve: ^27.0.6 - jest-resolve-dependencies: ^27.0.6 - jest-runner: ^27.0.6 - jest-runtime: ^27.0.6 - jest-snapshot: ^27.0.6 - jest-util: ^27.0.6 - jest-validate: ^27.0.6 - jest-watcher: ^27.0.6 + graceful-fs: ^4.2.9 + jest-changed-files: ^29.4.3 + jest-config: ^29.4.3 + jest-haste-map: ^29.4.3 + jest-message-util: ^29.4.3 + jest-regex-util: ^29.4.3 + jest-resolve: ^29.4.3 + jest-resolve-dependencies: ^29.4.3 + jest-runner: ^29.4.3 + jest-runtime: ^29.4.3 + jest-snapshot: ^29.4.3 + jest-util: ^29.4.3 + jest-validate: ^29.4.3 + jest-watcher: ^29.4.3 micromatch: ^4.0.4 - p-each-series: ^2.1.0 - rimraf: ^3.0.0 + pretty-format: ^29.4.3 slash: ^3.0.0 strip-ansi: ^6.0.0 peerDependencies: @@ -580,19 +694,19 @@ __metadata: peerDependenciesMeta: node-notifier: optional: true - checksum: 8b4e19f065ad8adaea8bda175dc48badeadd5a76f07c3b238cd393cbf4adc698b8dfd4ec33ff1f52acd8c1b199061094c4a12aa66bd546542999e4bdb7bd54b0 + checksum: 4aa10644d66f44f051d5dd9cdcedce27acc71216dbcc5e7adebdea458e27aefe27c78f457d7efd49f58b968c35f42de5a521590876e2013593e675120b9e6ab1 languageName: node linkType: hard -"@jest/environment@npm:^27.0.6": - version: 27.0.6 - resolution: "@jest/environment@npm:27.0.6" +"@jest/environment@npm:^29.4.3": + version: 29.4.3 + resolution: "@jest/environment@npm:29.4.3" dependencies: - "@jest/fake-timers": ^27.0.6 - "@jest/types": ^27.0.6 + "@jest/fake-timers": ^29.4.3 + "@jest/types": ^29.4.3 "@types/node": "*" - jest-mock: ^27.0.6 - checksum: 9332223c1f0c7118a2c0ee4321260316c5d84a489b916d2be18a20005851c0919716f7880aa48a86a89163defd1cb774d4ff9c50bcf1e91dd643b7fc1809cc95 + jest-mock: ^29.4.3 + checksum: 7c1b0cc4e84b90f8a3bbeca9bbf088882c88aee70a81b3b8e24265dcb1cbc302cd1eee3319089cf65bfd39adbaea344903c712afea106cb8da6c86088d99c5fb languageName: node linkType: hard @@ -605,65 +719,76 @@ __metadata: languageName: node linkType: hard -"@jest/fake-timers@npm:^27.0.6": - version: 27.0.6 - resolution: "@jest/fake-timers@npm:27.0.6" +"@jest/expect@npm:^29.4.3": + version: 29.4.3 + resolution: "@jest/expect@npm:29.4.3" dependencies: - "@jest/types": ^27.0.6 - "@sinonjs/fake-timers": ^7.0.2 + expect: ^29.4.3 + jest-snapshot: ^29.4.3 + checksum: 08d0d40077ec99a7491fe59d05821dbd31126cfba70875855d8a063698b7126b5f6c309c50811caacc6ae2f727c6e44f51bdcf1d6c1ea832b4f020045ef22d45 + languageName: node + linkType: hard + +"@jest/fake-timers@npm:^29.4.3": + version: 29.4.3 + resolution: "@jest/fake-timers@npm:29.4.3" + dependencies: + "@jest/types": ^29.4.3 + "@sinonjs/fake-timers": ^10.0.2 "@types/node": "*" - jest-message-util: ^27.0.6 - jest-mock: ^27.0.6 - jest-util: ^27.0.6 - checksum: 95de7a744c2494339303e2e41444332b647df66c26c2f27a6e6a8ba8e3aa53b2e574b42be5d5f99e0adcb6a6b71adbed854395431ce5e10b894dcf57d6280097 + jest-message-util: ^29.4.3 + jest-mock: ^29.4.3 + jest-util: ^29.4.3 + checksum: adaceb9143c395cccf3d7baa0e49b7042c3092a554e8283146df19926247e34c21b5bde5688bb90e9e87b4a02e4587926c5d858ee0a38d397a63175d0a127874 languageName: node linkType: hard -"@jest/globals@npm:^27.0.6": - version: 27.0.6 - resolution: "@jest/globals@npm:27.0.6" +"@jest/globals@npm:^29.4.3": + version: 29.4.3 + resolution: "@jest/globals@npm:29.4.3" dependencies: - "@jest/environment": ^27.0.6 - "@jest/types": ^27.0.6 - expect: ^27.0.6 - checksum: ceff33c0c7f6b285d7363acb681aef1fb079e8376a80fe50dfd5887ce74c86ca21fb17de07a629d028c8c80654eb9f1ab014df4a9999f0e5ee2ee11b10344dcf + "@jest/environment": ^29.4.3 + "@jest/expect": ^29.4.3 + "@jest/types": ^29.4.3 + jest-mock: ^29.4.3 + checksum: ea76b546ceb4aa5ce2bb3726df12f989b23150b51c9f7664790caa81b943012a657cf3a8525498af1c3518cdb387f54b816cfba1b0ddd22c7b20f03b1d7290b4 languageName: node linkType: hard -"@jest/reporters@npm:^27.0.6": - version: 27.0.6 - resolution: "@jest/reporters@npm:27.0.6" +"@jest/reporters@npm:^29.4.3": + version: 29.4.3 + resolution: "@jest/reporters@npm:29.4.3" dependencies: "@bcoe/v8-coverage": ^0.2.3 - "@jest/console": ^27.0.6 - "@jest/test-result": ^27.0.6 - "@jest/transform": ^27.0.6 - "@jest/types": ^27.0.6 + "@jest/console": ^29.4.3 + "@jest/test-result": ^29.4.3 + "@jest/transform": ^29.4.3 + "@jest/types": ^29.4.3 + "@jridgewell/trace-mapping": ^0.3.15 + "@types/node": "*" chalk: ^4.0.0 collect-v8-coverage: ^1.0.0 exit: ^0.1.2 - glob: ^7.1.2 - graceful-fs: ^4.2.4 + glob: ^7.1.3 + graceful-fs: ^4.2.9 istanbul-lib-coverage: ^3.0.0 - istanbul-lib-instrument: ^4.0.3 + istanbul-lib-instrument: ^5.1.0 istanbul-lib-report: ^3.0.0 istanbul-lib-source-maps: ^4.0.0 - istanbul-reports: ^3.0.2 - jest-haste-map: ^27.0.6 - jest-resolve: ^27.0.6 - jest-util: ^27.0.6 - jest-worker: ^27.0.6 + istanbul-reports: ^3.1.3 + jest-message-util: ^29.4.3 + jest-util: ^29.4.3 + jest-worker: ^29.4.3 slash: ^3.0.0 - source-map: ^0.6.0 string-length: ^4.0.1 - terminal-link: ^2.0.0 - v8-to-istanbul: ^8.0.0 + strip-ansi: ^6.0.0 + v8-to-istanbul: ^9.0.1 peerDependencies: node-notifier: ^8.0.1 || ^9.0.0 || ^10.0.0 peerDependenciesMeta: node-notifier: optional: true - checksum: 59beae74b007583f303c49f8ece8e2ba0ccb3f5d621df9c863219920171c2134d6926604afbebcac78b450576edb3a1935c85b7c8f94089191a7f40187a09ff9 + checksum: 7aa2e429c915bd96c3334962addd69d2bbf52065725757ddde26b293f8c4420a1e8c65363cc3e1e5ec89100a5273ccd3771bec58325a2cc0d97afdc81995073a languageName: node linkType: hard @@ -676,74 +801,61 @@ __metadata: languageName: node linkType: hard -"@jest/source-map@npm:^27.0.6": - version: 27.0.6 - resolution: "@jest/source-map@npm:27.0.6" +"@jest/source-map@npm:^29.4.3": + version: 29.4.3 + resolution: "@jest/source-map@npm:29.4.3" dependencies: + "@jridgewell/trace-mapping": ^0.3.15 callsites: ^3.0.0 - graceful-fs: ^4.2.4 - source-map: ^0.6.0 - checksum: b4c09a0392e58a970b1bede96cd995279d95254efc997acff7fb44ad52fd4e4a372ce955c32777d1eac2006c3869b7d97227126d45a28612a40815823e3cbdb0 + graceful-fs: ^4.2.9 + checksum: 2301d225145f8123540c0be073f35a80fd26a2f5e59550fd68525d8cea580fb896d12bf65106591ffb7366a8a19790076dbebc70e0f5e6ceb51f81827ed1f89c languageName: node linkType: hard -"@jest/test-result@npm:^27.0.6": - version: 27.0.6 - resolution: "@jest/test-result@npm:27.0.6" +"@jest/test-result@npm:^29.4.3": + version: 29.4.3 + resolution: "@jest/test-result@npm:29.4.3" dependencies: - "@jest/console": ^27.0.6 - "@jest/types": ^27.0.6 + "@jest/console": ^29.4.3 + "@jest/types": ^29.4.3 "@types/istanbul-lib-coverage": ^2.0.0 collect-v8-coverage: ^1.0.0 - checksum: 689e4a058000ab15394bb6b319be0ad6c85b0844dac47d6e178060b01c2a0effe172a3291c0db4fcf555ffd517182b8d4470e447c7c6cdb1dcfa80741039f75e + checksum: 164f102b96619ec283c2c39e208b8048e4674f75bf3c3a4f2e95048ae0f9226105add684b25f10d286d91c221625f877e2c1cfc3da46c42d7e1804da239318cb languageName: node linkType: hard -"@jest/test-sequencer@npm:^27.0.6": - version: 27.0.6 - resolution: "@jest/test-sequencer@npm:27.0.6" +"@jest/test-sequencer@npm:^29.4.3": + version: 29.4.3 + resolution: "@jest/test-sequencer@npm:29.4.3" dependencies: - "@jest/test-result": ^27.0.6 - graceful-fs: ^4.2.4 - jest-haste-map: ^27.0.6 - jest-runtime: ^27.0.6 - checksum: 7e0d972ff9e245de5ab45626f2a8cfe7617caea8e706a30a7bb950ff491a7fd83d7ac1139139254946bd88b0fda41becd36c24fa893e0e2671bcc5423092fb94 + "@jest/test-result": ^29.4.3 + graceful-fs: ^4.2.9 + jest-haste-map: ^29.4.3 + slash: ^3.0.0 + checksum: 145e1fa9379e5be3587bde6d585b8aee5cf4442b06926928a87e9aec7de5be91b581711d627c6ca13144d244fe05e5d248c13b366b51bedc404f9dcfbfd79e9e languageName: node linkType: hard -"@jest/transform@npm:^27.0.6": - version: 27.0.6 - resolution: "@jest/transform@npm:27.0.6" +"@jest/transform@npm:^29.4.3": + version: 29.4.3 + resolution: "@jest/transform@npm:29.4.3" dependencies: - "@babel/core": ^7.1.0 - "@jest/types": ^27.0.6 - babel-plugin-istanbul: ^6.0.0 + "@babel/core": ^7.11.6 + "@jest/types": ^29.4.3 + "@jridgewell/trace-mapping": ^0.3.15 + babel-plugin-istanbul: ^6.1.1 chalk: ^4.0.0 - convert-source-map: ^1.4.0 - fast-json-stable-stringify: ^2.0.0 - graceful-fs: ^4.2.4 - jest-haste-map: ^27.0.6 - jest-regex-util: ^27.0.6 - jest-util: ^27.0.6 + convert-source-map: ^2.0.0 + fast-json-stable-stringify: ^2.1.0 + graceful-fs: ^4.2.9 + jest-haste-map: ^29.4.3 + jest-regex-util: ^29.4.3 + jest-util: ^29.4.3 micromatch: ^4.0.4 - pirates: ^4.0.1 + pirates: ^4.0.4 slash: ^3.0.0 - source-map: ^0.6.1 - write-file-atomic: ^3.0.0 - checksum: 9faabd84c5e9468029578118f140d2e281ad8bb98c2d04fc33b9d300d04754c279d424499bc6e673de4a15d8630c4ef5426de7192f275e2e86162ebaf3d6b677 - languageName: node - linkType: hard - -"@jest/types@npm:^27.0.6": - version: 27.0.6 - resolution: "@jest/types@npm:27.0.6" - dependencies: - "@types/istanbul-lib-coverage": ^2.0.0 - "@types/istanbul-reports": ^3.0.0 - "@types/node": "*" - "@types/yargs": ^16.0.0 - chalk: ^4.0.0 - checksum: abe367b073d5b7396d7397620f57a24409551bb940761d78e6775f10aee68fb96eb80d7177824090ac811c7e7ba5d9cfce4cbdded86f3adef2abc291da28de77 + write-file-atomic: ^4.0.2 + checksum: 082d74e04044213aa7baa8de29f8383e5010034f867969c8602a2447a4ef2f484cfaf2491eba3179ce42f369f7a0af419cbd087910f7e5caf7aa5d1fe03f2ff9 languageName: node linkType: hard @@ -761,14 +873,42 @@ __metadata: languageName: node linkType: hard -"@jridgewell/resolve-uri@npm:^3.0.3": +"@jridgewell/gen-mapping@npm:^0.1.0": + version: 0.1.1 + resolution: "@jridgewell/gen-mapping@npm:0.1.1" + dependencies: + "@jridgewell/set-array": ^1.0.0 + "@jridgewell/sourcemap-codec": ^1.4.10 + checksum: 3bcc21fe786de6ffbf35c399a174faab05eb23ce6a03e8769569de28abbf4facc2db36a9ddb0150545ae23a8d35a7cf7237b2aa9e9356a7c626fb4698287d5cc + languageName: node + linkType: hard + +"@jridgewell/gen-mapping@npm:^0.3.2": + version: 0.3.2 + resolution: "@jridgewell/gen-mapping@npm:0.3.2" + dependencies: + "@jridgewell/set-array": ^1.0.1 + "@jridgewell/sourcemap-codec": ^1.4.10 + "@jridgewell/trace-mapping": ^0.3.9 + checksum: 1832707a1c476afebe4d0fbbd4b9434fdb51a4c3e009ab1e9938648e21b7a97049fa6009393bdf05cab7504108413441df26d8a3c12193996e65493a4efb6882 + languageName: node + linkType: hard + +"@jridgewell/resolve-uri@npm:3.1.0, @jridgewell/resolve-uri@npm:^3.0.3": version: 3.1.0 resolution: "@jridgewell/resolve-uri@npm:3.1.0" checksum: b5ceaaf9a110fcb2780d1d8f8d4a0bfd216702f31c988d8042e5f8fbe353c55d9b0f55a1733afdc64806f8e79c485d2464680ac48a0d9fcadb9548ee6b81d267 languageName: node linkType: hard -"@jridgewell/sourcemap-codec@npm:^1.4.10": +"@jridgewell/set-array@npm:^1.0.0, @jridgewell/set-array@npm:^1.0.1": + version: 1.1.2 + resolution: "@jridgewell/set-array@npm:1.1.2" + checksum: 69a84d5980385f396ff60a175f7177af0b8da4ddb81824cb7016a9ef914eee9806c72b6b65942003c63f7983d4f39a5c6c27185bbca88eb4690b62075602e28e + languageName: node + linkType: hard + +"@jridgewell/sourcemap-codec@npm:1.4.14, @jridgewell/sourcemap-codec@npm:^1.4.10": version: 1.4.14 resolution: "@jridgewell/sourcemap-codec@npm:1.4.14" checksum: 61100637b6d173d3ba786a5dff019e1a74b1f394f323c1fee337ff390239f053b87266c7a948777f4b1ee68c01a8ad0ab61e5ff4abb5a012a0b091bec391ab97 @@ -785,6 +925,16 @@ __metadata: languageName: node linkType: hard +"@jridgewell/trace-mapping@npm:^0.3.12, @jridgewell/trace-mapping@npm:^0.3.15, @jridgewell/trace-mapping@npm:^0.3.17, @jridgewell/trace-mapping@npm:^0.3.9": + version: 0.3.17 + resolution: "@jridgewell/trace-mapping@npm:0.3.17" + dependencies: + "@jridgewell/resolve-uri": 3.1.0 + "@jridgewell/sourcemap-codec": 1.4.14 + checksum: 9d703b859cff5cd83b7308fd457a431387db5db96bd781a63bf48e183418dd9d3d44e76b9e4ae13237f6abeeb25d739ec9215c1d5bfdd08f66f750a50074a339 + languageName: node + linkType: hard + "@lavamoat/aa@npm:^3.1.0": version: 3.1.0 resolution: "@lavamoat/aa@npm:3.1.0" @@ -934,7 +1084,7 @@ __metadata: eslint-plugin-node: ^11.1.0 eslint-plugin-prettier: ^4.2.1 ethereumjs-wallet: ^1.0.1 - jest: ^27.0.6 + jest: ^29.0.0 obs-store: ^4.0.3 prettier: ^2.8.1 prettier-plugin-packagejson: ^2.3.0 @@ -1135,7 +1285,25 @@ __metadata: languageName: node linkType: hard -"@sinonjs/fake-timers@npm:^7.0.2, @sinonjs/fake-timers@npm:^7.0.4, @sinonjs/fake-timers@npm:^7.1.0": +"@sinonjs/commons@npm:^2.0.0": + version: 2.0.0 + resolution: "@sinonjs/commons@npm:2.0.0" + dependencies: + type-detect: 4.0.8 + checksum: 5023ba17edf2b85ed58262313b8e9b59e23c6860681a9af0200f239fe939e2b79736d04a260e8270ddd57196851dde3ba754d7230be5c5234e777ae2ca8af137 + languageName: node + linkType: hard + +"@sinonjs/fake-timers@npm:^10.0.2": + version: 10.0.2 + resolution: "@sinonjs/fake-timers@npm:10.0.2" + dependencies: + "@sinonjs/commons": ^2.0.0 + checksum: c62aa98e7cefda8dedc101ce227abc888dc46b8ff9706c5f0a8dfd9c3ada97d0a5611384738d9ba0b26b59f99c2ba24efece8e779bb08329e9e87358fa309824 + languageName: node + linkType: hard + +"@sinonjs/fake-timers@npm:^7.0.4, @sinonjs/fake-timers@npm:^7.1.0": version: 7.1.2 resolution: "@sinonjs/fake-timers@npm:7.1.2" dependencies: @@ -1162,13 +1330,6 @@ __metadata: languageName: node linkType: hard -"@tootallnate/once@npm:1": - version: 1.1.2 - resolution: "@tootallnate/once@npm:1.1.2" - checksum: e1fb1bbbc12089a0cb9433dc290f97bddd062deadb6178ce9bcb93bb7c1aecde5e60184bc7065aec42fe1663622a213493c48bbd4972d931aae48315f18e1be9 - languageName: node - linkType: hard - "@tootallnate/once@npm:2": version: 2.0.0 resolution: "@tootallnate/once@npm:2.0.0" @@ -1204,7 +1365,7 @@ __metadata: languageName: node linkType: hard -"@types/babel__core@npm:^7.0.0, @types/babel__core@npm:^7.1.14": +"@types/babel__core@npm:^7.1.14": version: 7.1.14 resolution: "@types/babel__core@npm:7.1.14" dependencies: @@ -1236,7 +1397,7 @@ __metadata: languageName: node linkType: hard -"@types/babel__traverse@npm:*, @types/babel__traverse@npm:^7.0.4, @types/babel__traverse@npm:^7.0.6": +"@types/babel__traverse@npm:*, @types/babel__traverse@npm:^7.0.6": version: 7.14.0 resolution: "@types/babel__traverse@npm:7.14.0" dependencies: @@ -1273,12 +1434,12 @@ __metadata: languageName: node linkType: hard -"@types/graceful-fs@npm:^4.1.2": - version: 4.1.5 - resolution: "@types/graceful-fs@npm:4.1.5" +"@types/graceful-fs@npm:^4.1.3": + version: 4.1.6 + resolution: "@types/graceful-fs@npm:4.1.6" dependencies: "@types/node": "*" - checksum: d076bb61f45d0fc42dee496ef8b1c2f8742e15d5e47e90e20d0243386e426c04d4efd408a48875ab432f7960b4ce3414db20ed0fbbfc7bcc89d84e574f6e045a + checksum: c3070ccdc9ca0f40df747bced1c96c71a61992d6f7c767e8fd24bb6a3c2de26e8b84135ede000b7e79db530a23e7e88dcd9db60eee6395d0f4ce1dae91369dd4 languageName: node linkType: hard @@ -1421,15 +1582,6 @@ __metadata: languageName: node linkType: hard -"@types/yargs@npm:^16.0.0": - version: 16.0.3 - resolution: "@types/yargs@npm:16.0.3" - dependencies: - "@types/yargs-parser": "*" - checksum: 0968b06d2f6df764cb180a4089b293ae313a310b0c3524c296f93ac896ca1ed8d857b595db0388355f9f45772226d25d6a4f7df359302f245040a63ba057ae5a - languageName: node - linkType: hard - "@types/yargs@npm:^17.0.8": version: 17.0.22 resolution: "@types/yargs@npm:17.0.22" @@ -1623,13 +1775,6 @@ __metadata: languageName: node linkType: hard -"abab@npm:^2.0.3, abab@npm:^2.0.5": - version: 2.0.5 - resolution: "abab@npm:2.0.5" - checksum: 0ec951b46d5418c2c2f923021ec193eaebdb4e802ffd5506286781b454be722a13a8430f98085cd3e204918401d9130ec6cc8f5ae19be315b3a0e857d83196e1 - languageName: node - linkType: hard - "abbrev@npm:1, abbrev@npm:^1.0.0": version: 1.1.1 resolution: "abbrev@npm:1.1.1" @@ -1637,16 +1782,6 @@ __metadata: languageName: node linkType: hard -"acorn-globals@npm:^6.0.0": - version: 6.0.0 - resolution: "acorn-globals@npm:6.0.0" - dependencies: - acorn: ^7.1.1 - acorn-walk: ^7.1.1 - checksum: 72d95e5b5e585f9acd019b993ab8bbba68bb3cbc9d9b5c1ebb3c2f1fe5981f11deababfb4949f48e6262f9c57878837f5958c0cca396f81023814680ca878042 - languageName: node - linkType: hard - "acorn-jsx@npm:^5.3.2": version: 5.3.2 resolution: "acorn-jsx@npm:5.3.2" @@ -1656,13 +1791,6 @@ __metadata: languageName: node linkType: hard -"acorn-walk@npm:^7.1.1": - version: 7.2.0 - resolution: "acorn-walk@npm:7.2.0" - checksum: 9252158a79b9d92f1bc0dd6acc0fcfb87a67339e84bcc301bb33d6078936d27e35d606b4d35626d2962cd43c256d6f27717e70cbe15c04fff999ab0b2260b21f - languageName: node - linkType: hard - "acorn-walk@npm:^8.1.1": version: 8.2.0 resolution: "acorn-walk@npm:8.2.0" @@ -1670,16 +1798,16 @@ __metadata: languageName: node linkType: hard -"acorn@npm:^7.1.1": - version: 7.4.1 - resolution: "acorn@npm:7.4.1" +"acorn@npm:^8.4.1": + version: 8.8.2 + resolution: "acorn@npm:8.8.2" bin: acorn: bin/acorn - checksum: 1860f23c2107c910c6177b7b7be71be350db9e1080d814493fae143ae37605189504152d1ba8743ba3178d0b37269ce1ffc42b101547fdc1827078f82671e407 + checksum: f790b99a1bf63ef160c967e23c46feea7787e531292bb827126334612c234ed489a0dc2c7ba33156416f0ffa8d25bf2b0fdb7f35c2ba60eb3e960572bece4001 languageName: node linkType: hard -"acorn@npm:^8.2.4, acorn@npm:^8.8.0": +"acorn@npm:^8.8.0": version: 8.8.1 resolution: "acorn@npm:8.8.1" bin: @@ -1688,15 +1816,6 @@ __metadata: languageName: node linkType: hard -"acorn@npm:^8.4.1": - version: 8.8.2 - resolution: "acorn@npm:8.8.2" - bin: - acorn: bin/acorn - checksum: f790b99a1bf63ef160c967e23c46feea7787e531292bb827126334612c234ed489a0dc2c7ba33156416f0ffa8d25bf2b0fdb7f35c2ba60eb3e960572bece4001 - languageName: node - linkType: hard - "aes-js@npm:^3.1.1": version: 3.1.2 resolution: "aes-js@npm:3.1.2" @@ -1762,7 +1881,7 @@ __metadata: languageName: node linkType: hard -"ansi-regex@npm:^5.0.0, ansi-regex@npm:^5.0.1": +"ansi-regex@npm:^5.0.1": version: 5.0.1 resolution: "ansi-regex@npm:5.0.1" checksum: 2aa4bb54caf2d622f1afdad09441695af2a83aa3fe8b8afa581d205e57ed4261c183c4d3877cee25794443fde5876417d859c108078ab788d6af7e4fe52eb66b @@ -1944,46 +2063,45 @@ __metadata: languageName: node linkType: hard -"babel-jest@npm:^27.0.6": - version: 27.0.6 - resolution: "babel-jest@npm:27.0.6" +"babel-jest@npm:^29.4.3": + version: 29.4.3 + resolution: "babel-jest@npm:29.4.3" dependencies: - "@jest/transform": ^27.0.6 - "@jest/types": ^27.0.6 + "@jest/transform": ^29.4.3 "@types/babel__core": ^7.1.14 - babel-plugin-istanbul: ^6.0.0 - babel-preset-jest: ^27.0.6 + babel-plugin-istanbul: ^6.1.1 + babel-preset-jest: ^29.4.3 chalk: ^4.0.0 - graceful-fs: ^4.2.4 + graceful-fs: ^4.2.9 slash: ^3.0.0 peerDependencies: "@babel/core": ^7.8.0 - checksum: 1e79dd1d9e67eaf68e02295f8f873bbe999a7881f73f132e3533be29d6f2d165970554c46fbb417949db234528ced7e0a35aa328a85926a8b8e3a662f589c7bc + checksum: a1a95937adb5e717dbffc2eb9e583fa6d26c7e5d5b07bb492a2d7f68631510a363e9ff097eafb642ad642dfac9dc2b13872b584f680e166a4f0922c98ea95853 languageName: node linkType: hard -"babel-plugin-istanbul@npm:^6.0.0": - version: 6.0.0 - resolution: "babel-plugin-istanbul@npm:6.0.0" +"babel-plugin-istanbul@npm:^6.1.1": + version: 6.1.1 + resolution: "babel-plugin-istanbul@npm:6.1.1" dependencies: "@babel/helper-plugin-utils": ^7.0.0 "@istanbuljs/load-nyc-config": ^1.0.0 "@istanbuljs/schema": ^0.1.2 - istanbul-lib-instrument: ^4.0.0 + istanbul-lib-instrument: ^5.0.4 test-exclude: ^6.0.0 - checksum: bc586cf088ec471a98a474ef0e9361ace61947da2a3e54162f1e1ab712a1a81a88007639e8aff7db2fc8678ae7c671e696e6edd6ccf72db8e6af86f0628d5a08 + checksum: cb4fd95738219f232f0aece1116628cccff16db891713c4ccb501cddbbf9272951a5df81f2f2658dfdf4b3e7b236a9d5cbcf04d5d8c07dd5077297339598061a languageName: node linkType: hard -"babel-plugin-jest-hoist@npm:^27.0.6": - version: 27.0.6 - resolution: "babel-plugin-jest-hoist@npm:27.0.6" +"babel-plugin-jest-hoist@npm:^29.4.3": + version: 29.4.3 + resolution: "babel-plugin-jest-hoist@npm:29.4.3" dependencies: "@babel/template": ^7.3.3 "@babel/types": ^7.3.3 - "@types/babel__core": ^7.0.0 + "@types/babel__core": ^7.1.14 "@types/babel__traverse": ^7.0.6 - checksum: 0aa0798a56fbed3ed7892d94dfe2c72e26b923691704619a71bd5d1ec48a598e2e515a594f9ae818a5fde539c8fb2d3c890e1104701f00f4a85731e76c1981f6 + checksum: c8702a6db6b30ec39dfb9f8e72b501c13895231ed80b15ed2648448f9f0c7b7cc4b1529beac31802ae655f63479a05110ca612815aa25fb1b0e6c874e1589137 languageName: node linkType: hard @@ -2009,15 +2127,15 @@ __metadata: languageName: node linkType: hard -"babel-preset-jest@npm:^27.0.6": - version: 27.0.6 - resolution: "babel-preset-jest@npm:27.0.6" +"babel-preset-jest@npm:^29.4.3": + version: 29.4.3 + resolution: "babel-preset-jest@npm:29.4.3" dependencies: - babel-plugin-jest-hoist: ^27.0.6 + babel-plugin-jest-hoist: ^29.4.3 babel-preset-current-node-syntax: ^1.0.0 peerDependencies: "@babel/core": ^7.0.0 - checksum: 358e361c9ba823361fb191c1d7dddf8a1b455777bf657dbef18553d7c3b725b44822d63ecae77956e4e38fcec9147fd824d4bf5506765af54038d2e744d06c5a + checksum: a091721861ea2f8d969ace8fe06570cff8f2e847dbc6e4800abacbe63f72131abde615ce0a3b6648472c97e55a5be7f8bf7ae381e2b194ad2fa1737096febcf5 languageName: node linkType: hard @@ -2102,13 +2220,6 @@ __metadata: languageName: node linkType: hard -"browser-process-hrtime@npm:^1.0.0": - version: 1.0.0 - resolution: "browser-process-hrtime@npm:1.0.0" - checksum: e30f868cdb770b1201afb714ad1575dd86366b6e861900884665fb627109b3cc757c40067d3bfee1ff2a29c835257ea30725a8018a9afd02ac1c24b408b1e45f - languageName: node - linkType: hard - "browserify-aes@npm:^1.2.0": version: 1.2.0 resolution: "browserify-aes@npm:1.2.0" @@ -2123,18 +2234,17 @@ __metadata: languageName: node linkType: hard -"browserslist@npm:^4.16.6": - version: 4.16.6 - resolution: "browserslist@npm:4.16.6" +"browserslist@npm:^4.21.3": + version: 4.21.5 + resolution: "browserslist@npm:4.21.5" dependencies: - caniuse-lite: ^1.0.30001219 - colorette: ^1.2.2 - electron-to-chromium: ^1.3.723 - escalade: ^3.1.1 - node-releases: ^1.1.71 + caniuse-lite: ^1.0.30001449 + electron-to-chromium: ^1.4.284 + node-releases: ^2.0.8 + update-browserslist-db: ^1.0.10 bin: browserslist: cli.js - checksum: 3dffc86892d2dcfcfc66b52519b7e5698ae070b4fc92ab047e760efc4cae0474e9e70bbe10d769c8d3491b655ef3a2a885b88e7196c83cc5dc0a46dfdba8b70c + checksum: 9755986b22e73a6a1497fd8797aedd88e04270be33ce66ed5d85a1c8a798292a65e222b0f251bafa1c2522261e237d73b08b58689d4920a607e5a53d56dc4706 languageName: node linkType: hard @@ -2247,10 +2357,10 @@ __metadata: languageName: node linkType: hard -"caniuse-lite@npm:^1.0.30001219": - version: 1.0.30001241 - resolution: "caniuse-lite@npm:1.0.30001241" - checksum: 3478d31e0f12ddd577d7de436eb6f008803f15202368998b92c3bdb1cf023ce0cfcaaac94d2bba804227751b63a2b9afb9746fd67abab134f7b7e2d95e1e93a0 +"caniuse-lite@npm:^1.0.30001449": + version: 1.0.30001457 + resolution: "caniuse-lite@npm:1.0.30001457" + checksum: f311a7c5098681962402a86a0a367014ee91c3135395ee68bbfaf45caf0e36d581e42d7c5b1526ce99484a228e6cf5cf0e400678292c65f5a21512a3fc7a5fb6 languageName: node linkType: hard @@ -2296,13 +2406,6 @@ __metadata: languageName: node linkType: hard -"ci-info@npm:^3.1.1": - version: 3.2.0 - resolution: "ci-info@npm:3.2.0" - checksum: c68995a94e95ce3f233ff845e62dfc56f2e8ff1e3f5c1361bcdd520cbbc9726d8a54cbc1a685cb9ee19c3c5e71a1dade6dda23eb364b59b8e6c32508a9b761bc - languageName: node - linkType: hard - "ci-info@npm:^3.2.0": version: 3.8.0 resolution: "ci-info@npm:3.8.0" @@ -2345,6 +2448,17 @@ __metadata: languageName: node linkType: hard +"cliui@npm:^8.0.1": + version: 8.0.1 + resolution: "cliui@npm:8.0.1" + dependencies: + string-width: ^4.2.0 + strip-ansi: ^6.0.1 + wrap-ansi: ^7.0.0 + checksum: 79648b3b0045f2e285b76fb2e24e207c6db44323581e421c3acbd0e86454cba1b37aea976ab50195a49e7384b871e6dfb2247ad7dec53c02454ac6497394cb56 + languageName: node + linkType: hard + "co@npm:^4.6.0": version: 4.6.0 resolution: "co@npm:4.6.0" @@ -2407,14 +2521,7 @@ __metadata: languageName: node linkType: hard -"colorette@npm:^1.2.2": - version: 1.2.2 - resolution: "colorette@npm:1.2.2" - checksum: 69fec14ddaedd0f5b00e4bae40dc4bc61f7050ebdc82983a595d6fd64e650b9dc3c033fff378775683138e992e0ddd8717ac7c7cec4d089679dcfbe3cd921b04 - languageName: node - linkType: hard - -"combined-stream@npm:^1.0.6, combined-stream@npm:^1.0.8, combined-stream@npm:~1.0.6": +"combined-stream@npm:^1.0.6, combined-stream@npm:~1.0.6": version: 1.0.8 resolution: "combined-stream@npm:1.0.8" dependencies: @@ -2444,7 +2551,7 @@ __metadata: languageName: node linkType: hard -"convert-source-map@npm:^1.4.0, convert-source-map@npm:^1.6.0, convert-source-map@npm:^1.7.0": +"convert-source-map@npm:^1.6.0, convert-source-map@npm:^1.7.0": version: 1.8.0 resolution: "convert-source-map@npm:1.8.0" dependencies: @@ -2453,6 +2560,13 @@ __metadata: languageName: node linkType: hard +"convert-source-map@npm:^2.0.0": + version: 2.0.0 + resolution: "convert-source-map@npm:2.0.0" + checksum: 63ae9933be5a2b8d4509daca5124e20c14d023c820258e484e32dc324d34c2754e71297c94a05784064ad27615037ef677e3f0c00469fb55f409d2bb21261035 + languageName: node + linkType: hard + "core-util-is@npm:1.0.2, core-util-is@npm:~1.0.0": version: 1.0.2 resolution: "core-util-is@npm:1.0.2" @@ -2505,29 +2619,6 @@ __metadata: languageName: node linkType: hard -"cssom@npm:^0.4.4": - version: 0.4.4 - resolution: "cssom@npm:0.4.4" - checksum: e3bc1076e7ee4213d4fef05e7ae03bfa83dc05f32611d8edc341f4ecc3d9647b89c8245474c7dd2cdcdb797a27c462e99da7ad00a34399694559f763478ff53f - languageName: node - linkType: hard - -"cssom@npm:~0.3.6": - version: 0.3.8 - resolution: "cssom@npm:0.3.8" - checksum: 24beb3087c76c0d52dd458be9ee1fbc80ac771478a9baef35dd258cdeb527c68eb43204dd439692bb2b1ae5272fa5f2946d10946edab0d04f1078f85e06bc7f6 - languageName: node - linkType: hard - -"cssstyle@npm:^2.3.0": - version: 2.3.0 - resolution: "cssstyle@npm:2.3.0" - dependencies: - cssom: ~0.3.6 - checksum: 5f05e6fd2e3df0b44695c2f08b9ef38b011862b274e320665176467c0725e44a53e341bc4959a41176e83b66064ab786262e7380fd1cabeae6efee0d255bb4e3 - languageName: node - linkType: hard - "dashdash@npm:^1.12.0": version: 1.14.1 resolution: "dashdash@npm:1.14.1" @@ -2537,17 +2628,6 @@ __metadata: languageName: node linkType: hard -"data-urls@npm:^2.0.0": - version: 2.0.0 - resolution: "data-urls@npm:2.0.0" - dependencies: - abab: ^2.0.3 - whatwg-mimetype: ^2.3.0 - whatwg-url: ^8.0.0 - checksum: 97caf828aac25e25e04ba6869db0f99c75e6859bb5b424ada28d3e7841941ebf08ddff3c1b1bb4585986bd507a5d54c2a716853ea6cb98af877400e637393e71 - languageName: node - linkType: hard - "debug@npm:4, debug@npm:^4.1.0, debug@npm:^4.1.1, debug@npm:^4.3.2, debug@npm:^4.3.3, debug@npm:^4.3.4": version: 4.3.4 resolution: "debug@npm:4.3.4" @@ -2578,13 +2658,6 @@ __metadata: languageName: node linkType: hard -"decimal.js@npm:^10.2.1": - version: 10.3.1 - resolution: "decimal.js@npm:10.3.1" - checksum: 0351ac9f05fe050f23227aa6a4573bee2d58fa7378fcf28d969a8c789525032effb488a90320fd3fe86a66e17b4bc507d811b15eada5b7f0e7ec5d2af4c24a59 - languageName: node - linkType: hard - "dedent@npm:^0.7.0": version: 0.7.0 resolution: "dedent@npm:0.7.0" @@ -2592,7 +2665,7 @@ __metadata: languageName: node linkType: hard -"deep-is@npm:^0.1.3, deep-is@npm:~0.1.3": +"deep-is@npm:^0.1.3": version: 0.1.3 resolution: "deep-is@npm:0.1.3" checksum: c15b04c3848a89880c94e25b077c19b47d9a30dd99048e70e5f95d943e7b246bee1da0c1376b56b01bc045be2cae7d9b1c856e68e47e9805634327de7c6cb6d5 @@ -2651,13 +2724,6 @@ __metadata: languageName: node linkType: hard -"diff-sequences@npm:^27.0.6": - version: 27.0.6 - resolution: "diff-sequences@npm:27.0.6" - checksum: f35ad024d426cd1026d6c98a1f604c41966a0e89712b05a38812fc11e645ff0e915ec17bc8f4b6910fed6df0b309b255aa6c7c77728be452c6dbbfa30aa2067b - languageName: node - linkType: hard - "diff-sequences@npm:^29.4.3": version: 29.4.3 resolution: "diff-sequences@npm:29.4.3" @@ -2706,15 +2772,6 @@ __metadata: languageName: node linkType: hard -"domexception@npm:^2.0.1": - version: 2.0.1 - resolution: "domexception@npm:2.0.1" - dependencies: - webidl-conversions: ^5.0.0 - checksum: d638e9cb05c52999f1b2eb87c374b03311ea5b1d69c2f875bc92da73e17db60c12142b45c950228642ff7f845c536b65305483350d080df59003a653da80b691 - languageName: node - linkType: hard - "ecc-jsbn@npm:~0.1.1": version: 0.1.2 resolution: "ecc-jsbn@npm:0.1.2" @@ -2725,10 +2782,10 @@ __metadata: languageName: node linkType: hard -"electron-to-chromium@npm:^1.3.723": - version: 1.3.761 - resolution: "electron-to-chromium@npm:1.3.761" - checksum: c1c6928c554a23fa5ed53e5cef6e9ba6863dc4f72d712abb80bb53acb06c6dc251b288cbf8e0444866543ad1e9af7aeff81dc592829a3fde74a6fba885a182c5 +"electron-to-chromium@npm:^1.4.284": + version: 1.4.309 + resolution: "electron-to-chromium@npm:1.4.309" + checksum: 011410321d1e7abf9cb148eba1f7a68be65bab25ed8eaa3322ecc88930385ecf7bf5ab2afc55c51c4e2c8f07fc1b0eb9629821927ece65850b120a5613c341e1 languageName: node linkType: hard @@ -2747,10 +2804,10 @@ __metadata: languageName: node linkType: hard -"emittery@npm:^0.8.1": - version: 0.8.1 - resolution: "emittery@npm:0.8.1" - checksum: 2457e8c7b0688bb006126f2c025b2655abe682f66b184954122a8a065b5277f9813d49d627896a10b076b81c513ec5f491fd9c14fbd42c04b95ca3c9f3c365ee +"emittery@npm:^0.13.1": + version: 0.13.1 + resolution: "emittery@npm:0.13.1" + checksum: 2b089ab6306f38feaabf4f6f02792f9ec85fc054fda79f44f6790e61bbf6bc4e1616afb9b232e0c5ec5289a8a452f79bfa6d905a6fd64e94b49981f0934001c6 languageName: node linkType: hard @@ -2784,6 +2841,15 @@ __metadata: languageName: node linkType: hard +"error-ex@npm:^1.3.1": + version: 1.3.2 + resolution: "error-ex@npm:1.3.2" + dependencies: + is-arrayish: ^0.2.1 + checksum: c1c2b8b65f9c91b0f9d75f0debaa7ec5b35c266c2cac5de412c1a6de86d4cbae04ae44e510378cb14d032d0645a36925d0186f8bb7367bcc629db256b743a001 + languageName: node + linkType: hard + "es-abstract@npm:^1.19.0, es-abstract@npm:^1.20.4": version: 1.20.5 resolution: "es-abstract@npm:1.20.5" @@ -2865,25 +2931,6 @@ __metadata: languageName: node linkType: hard -"escodegen@npm:^2.0.0": - version: 2.0.0 - resolution: "escodegen@npm:2.0.0" - dependencies: - esprima: ^4.0.1 - estraverse: ^5.2.0 - esutils: ^2.0.2 - optionator: ^0.8.1 - source-map: ~0.6.1 - dependenciesMeta: - source-map: - optional: true - bin: - escodegen: bin/escodegen.js - esgenerate: bin/esgenerate.js - checksum: 5aa6b2966fafe0545e4e77936300cc94ad57cfe4dc4ebff9950492eaba83eef634503f12d7e3cbd644ecc1bab388ad0e92b06fd32222c9281a75d1cf02ec6cef - languageName: node - linkType: hard - "eslint-config-prettier@npm:^8.5.0": version: 8.5.0 resolution: "eslint-config-prettier@npm:8.5.0" @@ -3138,7 +3185,7 @@ __metadata: languageName: node linkType: hard -"esprima@npm:^4.0.0, esprima@npm:^4.0.1": +"esprima@npm:^4.0.0": version: 4.0.1 resolution: "esprima@npm:4.0.1" bin: @@ -3304,21 +3351,7 @@ __metadata: languageName: node linkType: hard -"expect@npm:^27.0.6": - version: 27.0.6 - resolution: "expect@npm:27.0.6" - dependencies: - "@jest/types": ^27.0.6 - ansi-styles: ^5.0.0 - jest-get-type: ^27.0.6 - jest-matcher-utils: ^27.0.6 - jest-message-util: ^27.0.6 - jest-regex-util: ^27.0.6 - checksum: 26e63420b00620dffd3a7e98db9e815a31b2787930823a89d01fcc008b9827bd734e8104c58b91493054636fbc3b123cbaa48da5dc24b16ebe641b7ee98adeab - languageName: node - linkType: hard - -"expect@npm:^29.0.0": +"expect@npm:^29.0.0, expect@npm:^29.4.3": version: 29.4.3 resolution: "expect@npm:29.4.3" dependencies: @@ -3379,14 +3412,14 @@ __metadata: languageName: node linkType: hard -"fast-json-stable-stringify@npm:2.x, fast-json-stable-stringify@npm:^2.0.0": +"fast-json-stable-stringify@npm:2.x, fast-json-stable-stringify@npm:^2.0.0, fast-json-stable-stringify@npm:^2.1.0": version: 2.1.0 resolution: "fast-json-stable-stringify@npm:2.1.0" checksum: b191531e36c607977e5b1c47811158733c34ccb3bfde92c44798929e9b4154884378536d26ad90dfecd32e1ffc09c545d23535ad91b3161a27ddbb8ebe0cbecb languageName: node linkType: hard -"fast-levenshtein@npm:^2.0.6, fast-levenshtein@npm:~2.0.6": +"fast-levenshtein@npm:^2.0.6": version: 2.0.6 resolution: "fast-levenshtein@npm:2.0.6" checksum: 92cfec0a8dfafd9c7a15fba8f2cc29cd0b62b85f056d99ce448bbcd9f708e18ab2764bda4dd5158364f4145a7c72788538994f0d1787b956ef0d1062b0f7c24c @@ -3473,17 +3506,6 @@ __metadata: languageName: node linkType: hard -"form-data@npm:^3.0.0": - version: 3.0.1 - resolution: "form-data@npm:3.0.1" - dependencies: - asynckit: ^0.4.0 - combined-stream: ^1.0.8 - mime-types: ^2.1.12 - checksum: b019e8d35c8afc14a2bd8a7a92fa4f525a4726b6d5a9740e8d2623c30e308fbb58dc8469f90415a856698933c8479b01646a9dff33c87cc4e76d72aedbbf860d - languageName: node - linkType: hard - "form-data@npm:~2.3.2": version: 2.3.3 resolution: "form-data@npm:2.3.3" @@ -3671,7 +3693,7 @@ __metadata: languageName: node linkType: hard -"glob@npm:^7.1.1, glob@npm:^7.1.2, glob@npm:^7.1.3, glob@npm:^7.1.4": +"glob@npm:^7.1.3, glob@npm:^7.1.4": version: 7.1.7 resolution: "glob@npm:7.1.7" dependencies: @@ -3753,7 +3775,7 @@ __metadata: languageName: node linkType: hard -"graceful-fs@npm:^4.2.3, graceful-fs@npm:^4.2.4, graceful-fs@npm:^4.2.6, graceful-fs@npm:^4.2.9": +"graceful-fs@npm:^4.2.3, graceful-fs@npm:^4.2.6, graceful-fs@npm:^4.2.9": version: 4.2.10 resolution: "graceful-fs@npm:4.2.10" checksum: 3f109d70ae123951905d85032ebeae3c2a5a7a997430df00ea30df0e3a6c60cf6689b109654d6fdacd28810a053348c4d14642da1d075049e6be1ba5216218da @@ -3877,15 +3899,6 @@ __metadata: languageName: node linkType: hard -"html-encoding-sniffer@npm:^2.0.1": - version: 2.0.1 - resolution: "html-encoding-sniffer@npm:2.0.1" - dependencies: - whatwg-encoding: ^1.0.5 - checksum: bf30cce461015ed7e365736fcd6a3063c7bc016a91f74398ef6158886970a96333938f7c02417ab3c12aa82e3e53b40822145facccb9ddfbcdc15a879ae4d7ba - languageName: node - linkType: hard - "html-escaper@npm:^2.0.0": version: 2.0.2 resolution: "html-escaper@npm:2.0.2" @@ -3900,17 +3913,6 @@ __metadata: languageName: node linkType: hard -"http-proxy-agent@npm:^4.0.1": - version: 4.0.1 - resolution: "http-proxy-agent@npm:4.0.1" - dependencies: - "@tootallnate/once": 1 - agent-base: 6 - debug: 4 - checksum: c6a5da5a1929416b6bbdf77b1aca13888013fe7eb9d59fc292e25d18e041bb154a8dfada58e223fc7b76b9b2d155a87e92e608235201f77d34aa258707963a82 - languageName: node - linkType: hard - "http-proxy-agent@npm:^5.0.0": version: 5.0.0 resolution: "http-proxy-agent@npm:5.0.0" @@ -3959,15 +3961,6 @@ __metadata: languageName: node linkType: hard -"iconv-lite@npm:0.4.24": - version: 0.4.24 - resolution: "iconv-lite@npm:0.4.24" - dependencies: - safer-buffer: ">= 2.1.2 < 3" - checksum: bd9f120f5a5b306f0bc0b9ae1edeb1577161503f5f8252a20f1a9e56ef8775c9959fd01c55f2d3a39d9a8abaf3e30c1abeb1895f367dcbbe0a8fd1c9ca01c4f6 - languageName: node - linkType: hard - "iconv-lite@npm:^0.6.2": version: 0.6.3 resolution: "iconv-lite@npm:0.6.3" @@ -4062,6 +4055,13 @@ __metadata: languageName: node linkType: hard +"is-arrayish@npm:^0.2.1": + version: 0.2.1 + resolution: "is-arrayish@npm:0.2.1" + checksum: eef4417e3c10e60e2c810b6084942b3ead455af16c4509959a27e490e7aee87cfb3f38e01bbde92220b528a0ee1a18d52b787e1458ee86174d8c7f0e58cd488f + languageName: node + linkType: hard + "is-bigint@npm:^1.0.1": version: 1.0.2 resolution: "is-bigint@npm:1.0.2" @@ -4085,17 +4085,6 @@ __metadata: languageName: node linkType: hard -"is-ci@npm:^3.0.0": - version: 3.0.0 - resolution: "is-ci@npm:3.0.0" - dependencies: - ci-info: ^3.1.1 - bin: - is-ci: bin.js - checksum: 4b45aef32dd42dcb1f6fb3cd4b3a7ee7e18ea47516d2129005f46c3f36983506bb471382bac890973cf48a2f60d926a24461674ca2d9dc10744d82d4a876c26b - languageName: node - linkType: hard - "is-core-module@npm:^2.8.1, is-core-module@npm:^2.9.0": version: 2.11.0 resolution: "is-core-module@npm:2.11.0" @@ -4200,13 +4189,6 @@ __metadata: languageName: node linkType: hard -"is-potential-custom-element-name@npm:^1.0.1": - version: 1.0.1 - resolution: "is-potential-custom-element-name@npm:1.0.1" - checksum: ced7bbbb6433a5b684af581872afe0e1767e2d1146b2207ca0068a648fb5cab9d898495d1ac0583524faaf24ca98176a7d9876363097c2d14fee6dd324f3a1ab - languageName: node - linkType: hard - "is-regex@npm:^1.1.4": version: 1.1.4 resolution: "is-regex@npm:1.1.4" @@ -4251,7 +4233,7 @@ __metadata: languageName: node linkType: hard -"is-typedarray@npm:^1.0.0, is-typedarray@npm:~1.0.0": +"is-typedarray@npm:~1.0.0": version: 1.0.0 resolution: "is-typedarray@npm:1.0.0" checksum: 3508c6cd0a9ee2e0df2fa2e9baabcdc89e911c7bd5cf64604586697212feec525aa21050e48affb5ffc3df20f0f5d2e2cf79b08caa64e1ccc9578e251763aef7 @@ -4302,15 +4284,23 @@ __metadata: languageName: node linkType: hard -"istanbul-lib-instrument@npm:^4.0.0, istanbul-lib-instrument@npm:^4.0.3": - version: 4.0.3 - resolution: "istanbul-lib-instrument@npm:4.0.3" +"istanbul-lib-coverage@npm:^3.2.0": + version: 3.2.0 + resolution: "istanbul-lib-coverage@npm:3.2.0" + checksum: a2a545033b9d56da04a8571ed05c8120bf10e9bce01cf8633a3a2b0d1d83dff4ac4fe78d6d5673c27fc29b7f21a41d75f83a36be09f82a61c367b56aa73c1ff9 + languageName: node + linkType: hard + +"istanbul-lib-instrument@npm:^5.0.4, istanbul-lib-instrument@npm:^5.1.0": + version: 5.2.1 + resolution: "istanbul-lib-instrument@npm:5.2.1" dependencies: - "@babel/core": ^7.7.5 + "@babel/core": ^7.12.3 + "@babel/parser": ^7.14.7 "@istanbuljs/schema": ^0.1.2 - istanbul-lib-coverage: ^3.0.0 + istanbul-lib-coverage: ^3.2.0 semver: ^6.3.0 - checksum: fa1171d3022b1bb8f6a734042620ac5d9ee7dc80f3065a0bb12863e9f0494d0eefa3d86608fcc0254ab2765d29d7dad8bdc42e5f8df2f9a1fbe85ccc59d76cb9 + checksum: bf16f1803ba5e51b28bbd49ed955a736488381e09375d830e42ddeb403855b2006f850711d95ad726f2ba3f1ae8e7366de7e51d2b9ac67dc4d80191ef7ddf272 languageName: node linkType: hard @@ -4336,70 +4326,69 @@ __metadata: languageName: node linkType: hard -"istanbul-reports@npm:^3.0.2": - version: 3.0.2 - resolution: "istanbul-reports@npm:3.0.2" +"istanbul-reports@npm:^3.1.3": + version: 3.1.5 + resolution: "istanbul-reports@npm:3.1.5" dependencies: html-escaper: ^2.0.0 istanbul-lib-report: ^3.0.0 - checksum: c5da63f1f4610f47f3015c525a3bc2fb4c87a8791ae452ee3983546d7a2873f0cf5d5fff7c3735ac52943c5b3506f49c294c92f1837df6ec03312625ccd176d7 + checksum: 7867228f83ed39477b188ea07e7ccb9b4f5320b6f73d1db93a0981b7414fa4ef72d3f80c4692c442f90fc250d9406e71d8d7ab65bb615cb334e6292b73192b89 languageName: node linkType: hard -"jest-changed-files@npm:^27.0.6": - version: 27.0.6 - resolution: "jest-changed-files@npm:27.0.6" +"jest-changed-files@npm:^29.4.3": + version: 29.4.3 + resolution: "jest-changed-files@npm:29.4.3" dependencies: - "@jest/types": ^27.0.6 execa: ^5.0.0 - throat: ^6.0.1 - checksum: e79547adb94505c346124220ff86e293e3ca8955c5ccec26be982a5d561a25af892c1129f07e34306b20317bba375e28393d00cc2c166742e3464cb7a28e4e7e + p-limit: ^3.1.0 + checksum: 9a70bd8e92b37e18ad26d8bea97c516f41119fb7046b4255a13c76d557b0e54fa0629726de5a093fadfd6a0a08ce45da65a57086664d505b8db4b3133133e141 languageName: node linkType: hard -"jest-circus@npm:^27.0.6": - version: 27.0.6 - resolution: "jest-circus@npm:27.0.6" +"jest-circus@npm:^29.4.3": + version: 29.4.3 + resolution: "jest-circus@npm:29.4.3" dependencies: - "@jest/environment": ^27.0.6 - "@jest/test-result": ^27.0.6 - "@jest/types": ^27.0.6 + "@jest/environment": ^29.4.3 + "@jest/expect": ^29.4.3 + "@jest/test-result": ^29.4.3 + "@jest/types": ^29.4.3 "@types/node": "*" chalk: ^4.0.0 co: ^4.6.0 dedent: ^0.7.0 - expect: ^27.0.6 is-generator-fn: ^2.0.0 - jest-each: ^27.0.6 - jest-matcher-utils: ^27.0.6 - jest-message-util: ^27.0.6 - jest-runtime: ^27.0.6 - jest-snapshot: ^27.0.6 - jest-util: ^27.0.6 - pretty-format: ^27.0.6 + jest-each: ^29.4.3 + jest-matcher-utils: ^29.4.3 + jest-message-util: ^29.4.3 + jest-runtime: ^29.4.3 + jest-snapshot: ^29.4.3 + jest-util: ^29.4.3 + p-limit: ^3.1.0 + pretty-format: ^29.4.3 slash: ^3.0.0 stack-utils: ^2.0.3 - throat: ^6.0.1 - checksum: baaebcdd93b65ceee351eee5cc3194cf0ff19549df5ca55dc75db3ffbfc22ac7e4bd00067c46ab65ed35f3c3581ce76aa9f75f9a0dc8713c5bcaf9c3fce3a54f + checksum: 2739bef9c888743b49ff3fe303131381618e5d2f250f613a91240d9c86e19e6874fc904cbd8bcb02ec9ec59a84e5dae4ffec929f0c6171e87ddbc05508a137f4 languageName: node linkType: hard -"jest-cli@npm:^27.0.6": - version: 27.0.6 - resolution: "jest-cli@npm:27.0.6" +"jest-cli@npm:^29.4.3": + version: 29.4.3 + resolution: "jest-cli@npm:29.4.3" dependencies: - "@jest/core": ^27.0.6 - "@jest/test-result": ^27.0.6 - "@jest/types": ^27.0.6 + "@jest/core": ^29.4.3 + "@jest/test-result": ^29.4.3 + "@jest/types": ^29.4.3 chalk: ^4.0.0 exit: ^0.1.2 - graceful-fs: ^4.2.4 + graceful-fs: ^4.2.9 import-local: ^3.0.2 - jest-config: ^27.0.6 - jest-util: ^27.0.6 - jest-validate: ^27.0.6 + jest-config: ^29.4.3 + jest-util: ^29.4.3 + jest-validate: ^29.4.3 prompts: ^2.0.1 - yargs: ^16.0.3 + yargs: ^17.3.1 peerDependencies: node-notifier: ^8.0.1 || ^9.0.0 || ^10.0.0 peerDependenciesMeta: @@ -4407,53 +4396,45 @@ __metadata: optional: true bin: jest: bin/jest.js - checksum: a9fbcde31563503c5e0e083eb96edd7241ac317e08f8efc2b18a14ae02bdaed3c5e5fa2b9730c97d4c20734de35233adb6cdcd742ba3a75dd7516282008b5bb8 + checksum: f4c9f6d76cde2c60a4169acbebb3f862728be03bcf3fe0077d2e55da7f9f3c3e9483cfa6e936832d35eabf96ee5ebf0300c4b0bd43cffff099801793466bfdd8 languageName: node linkType: hard -"jest-config@npm:^27.0.6": - version: 27.0.6 - resolution: "jest-config@npm:27.0.6" +"jest-config@npm:^29.4.3": + version: 29.4.3 + resolution: "jest-config@npm:29.4.3" dependencies: - "@babel/core": ^7.1.0 - "@jest/test-sequencer": ^27.0.6 - "@jest/types": ^27.0.6 - babel-jest: ^27.0.6 + "@babel/core": ^7.11.6 + "@jest/test-sequencer": ^29.4.3 + "@jest/types": ^29.4.3 + babel-jest: ^29.4.3 chalk: ^4.0.0 + ci-info: ^3.2.0 deepmerge: ^4.2.2 - glob: ^7.1.1 - graceful-fs: ^4.2.4 - is-ci: ^3.0.0 - jest-circus: ^27.0.6 - jest-environment-jsdom: ^27.0.6 - jest-environment-node: ^27.0.6 - jest-get-type: ^27.0.6 - jest-jasmine2: ^27.0.6 - jest-regex-util: ^27.0.6 - jest-resolve: ^27.0.6 - jest-runner: ^27.0.6 - jest-util: ^27.0.6 - jest-validate: ^27.0.6 + glob: ^7.1.3 + graceful-fs: ^4.2.9 + jest-circus: ^29.4.3 + jest-environment-node: ^29.4.3 + jest-get-type: ^29.4.3 + jest-regex-util: ^29.4.3 + jest-resolve: ^29.4.3 + jest-runner: ^29.4.3 + jest-util: ^29.4.3 + jest-validate: ^29.4.3 micromatch: ^4.0.4 - pretty-format: ^27.0.6 + parse-json: ^5.2.0 + pretty-format: ^29.4.3 + slash: ^3.0.0 + strip-json-comments: ^3.1.1 peerDependencies: + "@types/node": "*" ts-node: ">=9.0.0" peerDependenciesMeta: + "@types/node": + optional: true ts-node: optional: true - checksum: 629394069df2d79fe5b6abc13d53d030687ef35ff4713a8f55ff54d339cb6b41ba2ccb5f998b0321fbc1739452cb7dd821836714248bd37554b7eea35614d1b9 - languageName: node - linkType: hard - -"jest-diff@npm:^27.0.6": - version: 27.0.6 - resolution: "jest-diff@npm:27.0.6" - dependencies: - chalk: ^4.0.0 - diff-sequences: ^27.0.6 - jest-get-type: ^27.0.6 - pretty-format: ^27.0.6 - checksum: 387e3cdeb2c069dae7d6344b645d3b35153642a2455eb52a454d4432bc4c132c769616a764cbb4866e6ae036dc5a879717b47c7de4eb0f8ce68081731eb3e8ab + checksum: 92f9a9c6850b18682cb01892774a33967472af23a5844438d8c68077d5f2a29b15b665e4e4db7de3d74002a6dca158cd5b2cb9f5debfd2cce5e1aee6c74e3873 languageName: node linkType: hard @@ -4469,61 +4450,39 @@ __metadata: languageName: node linkType: hard -"jest-docblock@npm:^27.0.6": - version: 27.0.6 - resolution: "jest-docblock@npm:27.0.6" +"jest-docblock@npm:^29.4.3": + version: 29.4.3 + resolution: "jest-docblock@npm:29.4.3" dependencies: detect-newline: ^3.0.0 - checksum: 6d68b9f2bef76e0bde06a8e6d13a7e1d2fc67f61a8fa8a089727198e565510aef852a0a089c3c4157b00a82597f792fa83c8480499203978ef38d8cd6578bea0 + checksum: e0e9df1485bb8926e5b33478cdf84b3387d9caf3658e7dc1eaa6dc34cb93dea0d2d74797f6e940f0233a88f3dadd60957f2288eb8f95506361f85b84bf8661df languageName: node linkType: hard -"jest-each@npm:^27.0.6": - version: 27.0.6 - resolution: "jest-each@npm:27.0.6" +"jest-each@npm:^29.4.3": + version: 29.4.3 + resolution: "jest-each@npm:29.4.3" dependencies: - "@jest/types": ^27.0.6 + "@jest/types": ^29.4.3 chalk: ^4.0.0 - jest-get-type: ^27.0.6 - jest-util: ^27.0.6 - pretty-format: ^27.0.6 - checksum: 373a31fe58469fb56ba8d47897c556f9b347eabd70d5d8983051c6118dd3ac49a18156e0a9dedba68ef8b53017a6afa1cdb9fadcb843436381222901781c01cd - languageName: node - linkType: hard - -"jest-environment-jsdom@npm:^27.0.6": - version: 27.0.6 - resolution: "jest-environment-jsdom@npm:27.0.6" - dependencies: - "@jest/environment": ^27.0.6 - "@jest/fake-timers": ^27.0.6 - "@jest/types": ^27.0.6 - "@types/node": "*" - jest-mock: ^27.0.6 - jest-util: ^27.0.6 - jsdom: ^16.6.0 - checksum: 86c89e844032f9cf029f20ba12fe69ab489d363f362540dda5163a4e8c802ff1bb31569f5b779c31213e24d8be77bb898f66682819999e7051b3e5cc89260fea + jest-get-type: ^29.4.3 + jest-util: ^29.4.3 + pretty-format: ^29.4.3 + checksum: 1f72738338399efab0139eaea18bc198be0c6ed889770c8cbfa70bf9c724e8171fe1d3a29a94f9f39b8493ee6b2529bb350fb7c7c75e0d7eddfd28c253c79f9d languageName: node linkType: hard -"jest-environment-node@npm:^27.0.6": - version: 27.0.6 - resolution: "jest-environment-node@npm:27.0.6" +"jest-environment-node@npm:^29.4.3": + version: 29.4.3 + resolution: "jest-environment-node@npm:29.4.3" dependencies: - "@jest/environment": ^27.0.6 - "@jest/fake-timers": ^27.0.6 - "@jest/types": ^27.0.6 + "@jest/environment": ^29.4.3 + "@jest/fake-timers": ^29.4.3 + "@jest/types": ^29.4.3 "@types/node": "*" - jest-mock: ^27.0.6 - jest-util: ^27.0.6 - checksum: 910ced755557c4fbc134cf687d9c1571100dfb5d7e9691cdaa76dfcccd2bc97e62cec58e271e600757db94dc41612b3d97700fc3fd2439a298ce5f66e32da215 - languageName: node - linkType: hard - -"jest-get-type@npm:^27.0.6": - version: 27.0.6 - resolution: "jest-get-type@npm:27.0.6" - checksum: 2d4c1381bb5ddb212d80ad00497c7cbb3312358e10b62ac19f1fe5a28ae4af709202bfc235b77ec508970b83fd89945937652d636bcaf88614fa00028a6f3138 + jest-mock: ^29.4.3 + jest-util: ^29.4.3 + checksum: 3c7362edfdbd516e83af7367c95dde35761a482b174de9735c07633405486ec73e19624e9bea4333fca33c24e8d65eaa1aa6594e0cb6bfeeeb564ccc431ee61d languageName: node linkType: hard @@ -4534,75 +4493,36 @@ __metadata: languageName: node linkType: hard -"jest-haste-map@npm:^27.0.6": - version: 27.0.6 - resolution: "jest-haste-map@npm:27.0.6" +"jest-haste-map@npm:^29.4.3": + version: 29.4.3 + resolution: "jest-haste-map@npm:29.4.3" dependencies: - "@jest/types": ^27.0.6 - "@types/graceful-fs": ^4.1.2 + "@jest/types": ^29.4.3 + "@types/graceful-fs": ^4.1.3 "@types/node": "*" anymatch: ^3.0.3 fb-watchman: ^2.0.0 fsevents: ^2.3.2 - graceful-fs: ^4.2.4 - jest-regex-util: ^27.0.6 - jest-serializer: ^27.0.6 - jest-util: ^27.0.6 - jest-worker: ^27.0.6 + graceful-fs: ^4.2.9 + jest-regex-util: ^29.4.3 + jest-util: ^29.4.3 + jest-worker: ^29.4.3 micromatch: ^4.0.4 - walker: ^1.0.7 + walker: ^1.0.8 dependenciesMeta: fsevents: optional: true - checksum: aa458f5e0681f4d4515069c855219f69e2198177a0210d82d94d725bec72b855c5018feb4881abd603266197d57cce2b26ca7dae71342003f542ec6dd895a77c + checksum: c7a83ebe6008b3fe96a96235e8153092e54b14df68e0f4205faedec57450df26b658578495a71c6d82494c01fbb44bca98c1506a6b2b9c920696dcc5d2e2bc59 languageName: node linkType: hard -"jest-jasmine2@npm:^27.0.6": - version: 27.0.6 - resolution: "jest-jasmine2@npm:27.0.6" - dependencies: - "@babel/traverse": ^7.1.0 - "@jest/environment": ^27.0.6 - "@jest/source-map": ^27.0.6 - "@jest/test-result": ^27.0.6 - "@jest/types": ^27.0.6 - "@types/node": "*" - chalk: ^4.0.0 - co: ^4.6.0 - expect: ^27.0.6 - is-generator-fn: ^2.0.0 - jest-each: ^27.0.6 - jest-matcher-utils: ^27.0.6 - jest-message-util: ^27.0.6 - jest-runtime: ^27.0.6 - jest-snapshot: ^27.0.6 - jest-util: ^27.0.6 - pretty-format: ^27.0.6 - throat: ^6.0.1 - checksum: 0140ea1073c37e92ee37f5159d36b5021afac75efd6cefef34fe95101bc7b39e725562c7ee216ec3cb62958446e6ecd2a62139c31e32b7a20ef0c8aebc1f472f - languageName: node - linkType: hard - -"jest-leak-detector@npm:^27.0.6": - version: 27.0.6 - resolution: "jest-leak-detector@npm:27.0.6" - dependencies: - jest-get-type: ^27.0.6 - pretty-format: ^27.0.6 - checksum: 89349c6bc46529c2d3d3ac387d00bfcf12c80f355670995a3931fdef87dd7c5a92618c1a7b8e88513663a4f5f434429416e09670b3cd52397d2a78baef301239 - languageName: node - linkType: hard - -"jest-matcher-utils@npm:^27.0.6": - version: 27.0.6 - resolution: "jest-matcher-utils@npm:27.0.6" +"jest-leak-detector@npm:^29.4.3": + version: 29.4.3 + resolution: "jest-leak-detector@npm:29.4.3" dependencies: - chalk: ^4.0.0 - jest-diff: ^27.0.6 - jest-get-type: ^27.0.6 - pretty-format: ^27.0.6 - checksum: deaab742a1d6310dc3cecb8cca12806c2e90c87d15d1fee73d384a3518cdb14c3b4ad7b3f71820767164fe29ed0f6554629fc2d1e1707462b875a5a64b8e8ed8 + jest-get-type: ^29.4.3 + pretty-format: ^29.4.3 + checksum: ec2b45e6f0abce81bd0dd0f6fd06b433c24d1ec865267af7640fae540ec868b93752598e407a9184d9c7419cbf32e8789007cc8c1be1a84f8f7321a0f8ad01f1 languageName: node linkType: hard @@ -4618,23 +4538,6 @@ __metadata: languageName: node linkType: hard -"jest-message-util@npm:^27.0.6": - version: 27.0.6 - resolution: "jest-message-util@npm:27.0.6" - dependencies: - "@babel/code-frame": ^7.12.13 - "@jest/types": ^27.0.6 - "@types/stack-utils": ^2.0.0 - chalk: ^4.0.0 - graceful-fs: ^4.2.4 - micromatch: ^4.0.4 - pretty-format: ^27.0.6 - slash: ^3.0.0 - stack-utils: ^2.0.3 - checksum: ef35619ea72511216f285591878b06c6ca1fd885fbceaac91bed1e8f49a5198b08c7014f6fe2c772814107997e533ec9bd4e6fc3c1d8e3ec6c8e35151ee3e42a - languageName: node - linkType: hard - "jest-message-util@npm:^29.4.3": version: 29.4.3 resolution: "jest-message-util@npm:29.4.3" @@ -4652,13 +4555,14 @@ __metadata: languageName: node linkType: hard -"jest-mock@npm:^27.0.6": - version: 27.0.6 - resolution: "jest-mock@npm:27.0.6" +"jest-mock@npm:^29.4.3": + version: 29.4.3 + resolution: "jest-mock@npm:29.4.3" dependencies: - "@jest/types": ^27.0.6 + "@jest/types": ^29.4.3 "@types/node": "*" - checksum: 2a8b56abf4a8f920cce1cce6a679796965a74ae04c4abe37e51c1d01f6ecfaaa26bba79a431a6f631c327ec9c4f0fa38938697fae4c717fb00337da144a900c3 + jest-util: ^29.4.3 + checksum: 8eb4a29b02d2cd03faac0290b6df6d23b4ffa43f72b21c7fff3c7dd04a2797355b1e85862b70b15341dd33ee3a693b17db5520a6f6e6b81ee75601987de6a1a2 languageName: node linkType: hard @@ -4674,158 +4578,128 @@ __metadata: languageName: node linkType: hard -"jest-regex-util@npm:^27.0.6": - version: 27.0.6 - resolution: "jest-regex-util@npm:27.0.6" - checksum: 4d613b00f2076560e9d5e5674ec63a4130d7b1584dbbf25d84d3a455b0ff7a12d8f94eaa00facd7934d285330d370c270ca093667d537a5842e95457e8e1ecf4 +"jest-regex-util@npm:^29.4.3": + version: 29.4.3 + resolution: "jest-regex-util@npm:29.4.3" + checksum: 96fc7fc28cd4dd73a63c13a526202c4bd8b351d4e5b68b1a2a2c88da3308c2a16e26feaa593083eb0bac38cca1aa9dd05025412e7de013ba963fb8e66af22b8a languageName: node linkType: hard -"jest-resolve-dependencies@npm:^27.0.6": - version: 27.0.6 - resolution: "jest-resolve-dependencies@npm:27.0.6" +"jest-resolve-dependencies@npm:^29.4.3": + version: 29.4.3 + resolution: "jest-resolve-dependencies@npm:29.4.3" dependencies: - "@jest/types": ^27.0.6 - jest-regex-util: ^27.0.6 - jest-snapshot: ^27.0.6 - checksum: c1ffbb94794454822b1dd3183764044e3768598947fef0c592b08e5ee0494c26152154288dd81e45d4b56163a8005400ab590a2edd5b6a7b8c82b433a93ea3f7 + jest-regex-util: ^29.4.3 + jest-snapshot: ^29.4.3 + checksum: 3ad934cd2170c9658d8800f84a975dafc866ec85b7ce391c640c09c3744ced337787620d8667dc8d1fa5e0b1493f973caa1a1bb980e4e6a50b46a1720baf0bd1 languageName: node linkType: hard -"jest-resolve@npm:^27.0.6": - version: 27.0.6 - resolution: "jest-resolve@npm:27.0.6" +"jest-resolve@npm:^29.4.3": + version: 29.4.3 + resolution: "jest-resolve@npm:29.4.3" dependencies: - "@jest/types": ^27.0.6 chalk: ^4.0.0 - escalade: ^3.1.1 - graceful-fs: ^4.2.4 + graceful-fs: ^4.2.9 + jest-haste-map: ^29.4.3 jest-pnp-resolver: ^1.2.2 - jest-util: ^27.0.6 - jest-validate: ^27.0.6 + jest-util: ^29.4.3 + jest-validate: ^29.4.3 resolve: ^1.20.0 + resolve.exports: ^2.0.0 slash: ^3.0.0 - checksum: edfb7479a390b55da1ca4daf3e4c29c62ffd6178f74f92f4777a1b723670be20673296c9259fecc8b51dbfe1ba2202aa4e0c07757bc5e8709a726be7c000268b + checksum: 056a66beccf833f3c7e5a8fc9bfec218886e87b0b103decdbdf11893669539df489d1490cd6d5f0eea35731e8be0d2e955a6710498f970d2eae734da4df029dc languageName: node linkType: hard -"jest-runner@npm:^27.0.6": - version: 27.0.6 - resolution: "jest-runner@npm:27.0.6" +"jest-runner@npm:^29.4.3": + version: 29.4.3 + resolution: "jest-runner@npm:29.4.3" dependencies: - "@jest/console": ^27.0.6 - "@jest/environment": ^27.0.6 - "@jest/test-result": ^27.0.6 - "@jest/transform": ^27.0.6 - "@jest/types": ^27.0.6 + "@jest/console": ^29.4.3 + "@jest/environment": ^29.4.3 + "@jest/test-result": ^29.4.3 + "@jest/transform": ^29.4.3 + "@jest/types": ^29.4.3 "@types/node": "*" chalk: ^4.0.0 - emittery: ^0.8.1 - exit: ^0.1.2 - graceful-fs: ^4.2.4 - jest-docblock: ^27.0.6 - jest-environment-jsdom: ^27.0.6 - jest-environment-node: ^27.0.6 - jest-haste-map: ^27.0.6 - jest-leak-detector: ^27.0.6 - jest-message-util: ^27.0.6 - jest-resolve: ^27.0.6 - jest-runtime: ^27.0.6 - jest-util: ^27.0.6 - jest-worker: ^27.0.6 - source-map-support: ^0.5.6 - throat: ^6.0.1 - checksum: d97363932b3d169f6f9fb9200ab73bcc0ef56140896e82204ff7eceadb1aa4bf85b382161bededd775dded25f8787210244346dd5a8eec087a1acc508089da1f - languageName: node - linkType: hard - -"jest-runtime@npm:^27.0.6": - version: 27.0.6 - resolution: "jest-runtime@npm:27.0.6" - dependencies: - "@jest/console": ^27.0.6 - "@jest/environment": ^27.0.6 - "@jest/fake-timers": ^27.0.6 - "@jest/globals": ^27.0.6 - "@jest/source-map": ^27.0.6 - "@jest/test-result": ^27.0.6 - "@jest/transform": ^27.0.6 - "@jest/types": ^27.0.6 - "@types/yargs": ^16.0.0 + emittery: ^0.13.1 + graceful-fs: ^4.2.9 + jest-docblock: ^29.4.3 + jest-environment-node: ^29.4.3 + jest-haste-map: ^29.4.3 + jest-leak-detector: ^29.4.3 + jest-message-util: ^29.4.3 + jest-resolve: ^29.4.3 + jest-runtime: ^29.4.3 + jest-util: ^29.4.3 + jest-watcher: ^29.4.3 + jest-worker: ^29.4.3 + p-limit: ^3.1.0 + source-map-support: 0.5.13 + checksum: c41108e5da01e0b8fdc2a06c5042eb49bb1d8db0e0d4651769fd1b9fe84ab45188617c11a3a8e1c83748b29bfe57dd77001ec57e86e3e3c30f3534e0314f8882 + languageName: node + linkType: hard + +"jest-runtime@npm:^29.4.3": + version: 29.4.3 + resolution: "jest-runtime@npm:29.4.3" + dependencies: + "@jest/environment": ^29.4.3 + "@jest/fake-timers": ^29.4.3 + "@jest/globals": ^29.4.3 + "@jest/source-map": ^29.4.3 + "@jest/test-result": ^29.4.3 + "@jest/transform": ^29.4.3 + "@jest/types": ^29.4.3 + "@types/node": "*" chalk: ^4.0.0 cjs-module-lexer: ^1.0.0 collect-v8-coverage: ^1.0.0 - exit: ^0.1.2 glob: ^7.1.3 - graceful-fs: ^4.2.4 - jest-haste-map: ^27.0.6 - jest-message-util: ^27.0.6 - jest-mock: ^27.0.6 - jest-regex-util: ^27.0.6 - jest-resolve: ^27.0.6 - jest-snapshot: ^27.0.6 - jest-util: ^27.0.6 - jest-validate: ^27.0.6 + graceful-fs: ^4.2.9 + jest-haste-map: ^29.4.3 + jest-message-util: ^29.4.3 + jest-mock: ^29.4.3 + jest-regex-util: ^29.4.3 + jest-resolve: ^29.4.3 + jest-snapshot: ^29.4.3 + jest-util: ^29.4.3 slash: ^3.0.0 strip-bom: ^4.0.0 - yargs: ^16.0.3 - checksum: a94f7943eaf63b429626e9537508003ad44ee1687970ccc7696ec28d23fc99e84b7076b145a5cb8959d9bedc504611e4806112b09fb9dfbce1d0d0ce1c300f6c - languageName: node - linkType: hard - -"jest-serializer@npm:^27.0.6": - version: 27.0.6 - resolution: "jest-serializer@npm:27.0.6" - dependencies: - "@types/node": "*" - graceful-fs: ^4.2.4 - checksum: b0b8d97cb17ad4d1414769e4c81441c608cdfb7e3519afdcddc0f660dae4950cb30aad75a414dde97499c4830d961e8dff09d8683911295e299f0d86a104abdc + checksum: b99f8a910d1a38e7476058ba04ad44dfd3d93e837bb7c301d691e646a1085412fde87f06fbe271c9145f0e72d89400bfa7f6994bc30d456c7742269f37d0f570 languageName: node linkType: hard -"jest-snapshot@npm:^27.0.6": - version: 27.0.6 - resolution: "jest-snapshot@npm:27.0.6" +"jest-snapshot@npm:^29.4.3": + version: 29.4.3 + resolution: "jest-snapshot@npm:29.4.3" dependencies: - "@babel/core": ^7.7.2 + "@babel/core": ^7.11.6 "@babel/generator": ^7.7.2 - "@babel/parser": ^7.7.2 + "@babel/plugin-syntax-jsx": ^7.7.2 "@babel/plugin-syntax-typescript": ^7.7.2 "@babel/traverse": ^7.7.2 - "@babel/types": ^7.0.0 - "@jest/transform": ^27.0.6 - "@jest/types": ^27.0.6 - "@types/babel__traverse": ^7.0.4 + "@babel/types": ^7.3.3 + "@jest/expect-utils": ^29.4.3 + "@jest/transform": ^29.4.3 + "@jest/types": ^29.4.3 + "@types/babel__traverse": ^7.0.6 "@types/prettier": ^2.1.5 babel-preset-current-node-syntax: ^1.0.0 chalk: ^4.0.0 - expect: ^27.0.6 - graceful-fs: ^4.2.4 - jest-diff: ^27.0.6 - jest-get-type: ^27.0.6 - jest-haste-map: ^27.0.6 - jest-matcher-utils: ^27.0.6 - jest-message-util: ^27.0.6 - jest-resolve: ^27.0.6 - jest-util: ^27.0.6 + expect: ^29.4.3 + graceful-fs: ^4.2.9 + jest-diff: ^29.4.3 + jest-get-type: ^29.4.3 + jest-haste-map: ^29.4.3 + jest-matcher-utils: ^29.4.3 + jest-message-util: ^29.4.3 + jest-util: ^29.4.3 natural-compare: ^1.4.0 - pretty-format: ^27.0.6 - semver: ^7.3.2 - checksum: 3e5ef5c5bb6c8e59718f5969900d488003d97fba2a9337b2a62ad2620eb309a3df5f0170660737d5b0081493e2f447d48709727e3ffc3ba7ab106a025e18bfca - languageName: node - linkType: hard - -"jest-util@npm:^27.0.6": - version: 27.0.6 - resolution: "jest-util@npm:27.0.6" - dependencies: - "@jest/types": ^27.0.6 - "@types/node": "*" - chalk: ^4.0.0 - graceful-fs: ^4.2.4 - is-ci: ^3.0.0 - picomatch: ^2.2.3 - checksum: db1131e8b09e0397bf0b857da81f4def96a3877bcc6dc7f63fded6d9c5ab5ca8579465a8118b57647d106cf35452713e9e2de3b15eadfd654b800e75288a768e + pretty-format: ^29.4.3 + semver: ^7.3.5 + checksum: 79ba52f2435e23ce72b1309be4b17fdbcb299d1c2ce97ebb61df9a62711e9463035f63b4c849181b2fe5aa17b3e09d30ee4668cc25fb3c6f59511c010b4d9494 languageName: node linkType: hard @@ -4843,53 +4717,56 @@ __metadata: languageName: node linkType: hard -"jest-validate@npm:^27.0.6": - version: 27.0.6 - resolution: "jest-validate@npm:27.0.6" +"jest-validate@npm:^29.4.3": + version: 29.4.3 + resolution: "jest-validate@npm:29.4.3" dependencies: - "@jest/types": ^27.0.6 + "@jest/types": ^29.4.3 camelcase: ^6.2.0 chalk: ^4.0.0 - jest-get-type: ^27.0.6 + jest-get-type: ^29.4.3 leven: ^3.1.0 - pretty-format: ^27.0.6 - checksum: 6c05ff701176e2a12b7da35c92feeca752418167c0e427b6883a72c746d6a1498955c74474e28d463872c4cdf8cdaaaf03bf8d55bdc5811c660cee2ec0f7a6fd + pretty-format: ^29.4.3 + checksum: 983e56430d86bed238448cae031535c1d908f760aa312cd4a4ec0e92f3bc1b6675415ddf57cdeceedb8ad9c698e5bcd10f0a856dfc93a8923bdecc7733f4ba80 languageName: node linkType: hard -"jest-watcher@npm:^27.0.6": - version: 27.0.6 - resolution: "jest-watcher@npm:27.0.6" +"jest-watcher@npm:^29.4.3": + version: 29.4.3 + resolution: "jest-watcher@npm:29.4.3" dependencies: - "@jest/test-result": ^27.0.6 - "@jest/types": ^27.0.6 + "@jest/test-result": ^29.4.3 + "@jest/types": ^29.4.3 "@types/node": "*" ansi-escapes: ^4.2.1 chalk: ^4.0.0 - jest-util: ^27.0.6 + emittery: ^0.13.1 + jest-util: ^29.4.3 string-length: ^4.0.1 - checksum: f473f652bd07fc55105ab0a2de82073567c4e763084a84b31925c16b7b51d1e640ca25e3b442c3a06cc24d40c8af00fd9e1bc051bc4769b78d3aca0f00b1461d + checksum: 44b64991b3414db853c3756f14690028f4edef7aebfb204a4291cc1901c2239fa27a8687c5c5abbecc74bf613e0bb9b1378bf766430c9febcc71e9c0cb5ad8fc languageName: node linkType: hard -"jest-worker@npm:^27.0.6": - version: 27.0.6 - resolution: "jest-worker@npm:27.0.6" +"jest-worker@npm:^29.4.3": + version: 29.4.3 + resolution: "jest-worker@npm:29.4.3" dependencies: "@types/node": "*" + jest-util: ^29.4.3 merge-stream: ^2.0.0 supports-color: ^8.0.0 - checksum: cef42e551033839940ed26c121b7d19ff85316fb5e4b815e1fca28744c884173bb3a6be64729bc95c281902db5142685700fc0922628b646151b0f5dcabbeb37 + checksum: c99ae66f257564613e72c5797c3a68f21a22e1c1fb5f30d14695ff5b508a0d2405f22748f13a3df8d1015b5e16abb130170f81f047ff68f58b6b1d2ff6ebc51b languageName: node linkType: hard -"jest@npm:^27.0.6": - version: 27.0.6 - resolution: "jest@npm:27.0.6" +"jest@npm:^29.0.0": + version: 29.4.3 + resolution: "jest@npm:29.4.3" dependencies: - "@jest/core": ^27.0.6 + "@jest/core": ^29.4.3 + "@jest/types": ^29.4.3 import-local: ^3.0.2 - jest-cli: ^27.0.6 + jest-cli: ^29.4.3 peerDependencies: node-notifier: ^8.0.1 || ^9.0.0 || ^10.0.0 peerDependenciesMeta: @@ -4897,7 +4774,7 @@ __metadata: optional: true bin: jest: bin/jest.js - checksum: 60de979335cf28c03f8fdf8ba7aee240d72e11d2b918e50ed31a835b08debf593bca6ad058d3c323ffb670dcd8d5c060c22e0ec9a716fdb40ffa2134db7d6aca + checksum: 084d10d1ceaade3c40e6d3bbd71b9b71b8919ba6fbd6f1f6699bdc259a6ba2f7350c7ccbfa10c11f7e3e01662853650a6244210179542fe4ba87e77dc3f3109f languageName: node linkType: hard @@ -4952,46 +4829,6 @@ __metadata: languageName: node linkType: hard -"jsdom@npm:^16.6.0": - version: 16.6.0 - resolution: "jsdom@npm:16.6.0" - dependencies: - abab: ^2.0.5 - acorn: ^8.2.4 - acorn-globals: ^6.0.0 - cssom: ^0.4.4 - cssstyle: ^2.3.0 - data-urls: ^2.0.0 - decimal.js: ^10.2.1 - domexception: ^2.0.1 - escodegen: ^2.0.0 - form-data: ^3.0.0 - html-encoding-sniffer: ^2.0.1 - http-proxy-agent: ^4.0.1 - https-proxy-agent: ^5.0.0 - is-potential-custom-element-name: ^1.0.1 - nwsapi: ^2.2.0 - parse5: 6.0.1 - saxes: ^5.0.1 - symbol-tree: ^3.2.4 - tough-cookie: ^4.0.0 - w3c-hr-time: ^1.0.2 - w3c-xmlserializer: ^2.0.0 - webidl-conversions: ^6.1.0 - whatwg-encoding: ^1.0.5 - whatwg-mimetype: ^2.3.0 - whatwg-url: ^8.5.0 - ws: ^7.4.5 - xml-name-validator: ^3.0.0 - peerDependencies: - canvas: ^2.5.0 - peerDependenciesMeta: - canvas: - optional: true - checksum: 4abf126bba167f1cf123601232ceb3be0696a4370c8fa484a1a99d93926f251c372d84233b74aeede55909c3f30c350c646d27409f41353ea733c52e0243f49c - languageName: node - linkType: hard - "jsesc@npm:^2.5.1": version: 2.5.2 resolution: "jsesc@npm:2.5.2" @@ -5047,18 +4884,7 @@ __metadata: languageName: node linkType: hard -"json5@npm:^2.1.2": - version: 2.2.0 - resolution: "json5@npm:2.2.0" - dependencies: - minimist: ^1.2.5 - bin: - json5: lib/cli.js - checksum: e88fc5274bb58fc99547baa777886b069d2dd96d9cfc4490b305fd16d711dabd5979e35a4f90873cefbeb552e216b041a304fe56702bedba76e19bc7845f208d - languageName: node - linkType: hard - -"json5@npm:^2.2.3": +"json5@npm:^2.2.2, json5@npm:^2.2.3": version: 2.2.3 resolution: "json5@npm:2.2.3" bin: @@ -5128,13 +4954,10 @@ __metadata: languageName: node linkType: hard -"levn@npm:~0.3.0": - version: 0.3.0 - resolution: "levn@npm:0.3.0" - dependencies: - prelude-ls: ~1.1.2 - type-check: ~0.3.2 - checksum: 0d084a524231a8246bb10fec48cdbb35282099f6954838604f3c7fc66f2e16fa66fd9cc2f3f20a541a113c4dafdf181e822c887c8a319c9195444e6c64ac395e +"lines-and-columns@npm:^1.1.6": + version: 1.2.4 + resolution: "lines-and-columns@npm:1.2.4" + checksum: 0c37f9f7fa212b38912b7145e1cd16a5f3cd34d782441c3e6ca653485d326f58b3caccda66efce1c5812bde4961bbde3374fae4b0d11bf1226152337f3894aa5 languageName: node linkType: hard @@ -5177,10 +5000,12 @@ __metadata: languageName: node linkType: hard -"lodash@npm:^4.7.0": - version: 4.17.21 - resolution: "lodash@npm:4.17.21" - checksum: eb835a2e51d381e561e508ce932ea50a8e5a68f4ebdd771ea240d3048244a8d13658acbd502cd4829768c56f2e16bdd4340b9ea141297d472517b83868e677f7 +"lru-cache@npm:^5.1.1": + version: 5.1.1 + resolution: "lru-cache@npm:5.1.1" + dependencies: + yallist: ^3.0.2 + checksum: c154ae1cbb0c2206d1501a0e94df349653c92c8cbb25236d7e85190bcaf4567a03ac6eb43166fabfa36fd35623694da7233e88d9601fbf411a9a481d85dbd2cb languageName: node linkType: hard @@ -5247,12 +5072,12 @@ __metadata: languageName: node linkType: hard -"makeerror@npm:1.0.x": - version: 1.0.11 - resolution: "makeerror@npm:1.0.11" +"makeerror@npm:1.0.12": + version: 1.0.12 + resolution: "makeerror@npm:1.0.12" dependencies: - tmpl: 1.0.x - checksum: 9a62ec2d9648c5329fdc4bc7d779a7305f32b1e55422a4f14244bc890bb43287fe013eb8d965e92a0cf4c443f3e59265b1fc3125eaedb0c2361e28b1a8de565d + tmpl: 1.0.5 + checksum: b38a025a12c8146d6eeea5a7f2bf27d51d8ad6064da8ca9405fcf7bf9b54acd43e3b30ddd7abb9b1bfa4ddb266019133313482570ddb207de568f71ecfcf6060 languageName: node linkType: hard @@ -5364,7 +5189,7 @@ __metadata: languageName: node linkType: hard -"minimist@npm:^1.2.0, minimist@npm:^1.2.5, minimist@npm:^1.2.6": +"minimist@npm:^1.2.0, minimist@npm:^1.2.6": version: 1.2.7 resolution: "minimist@npm:1.2.7" checksum: 7346574a1038ca23c32e02252f603801f09384dd1d78b69a943a4e8c2c28730b80e96193882d3d3b22a063445f460e48316b29b8a25addca2d7e5e8f75478bec @@ -5572,17 +5397,10 @@ __metadata: languageName: node linkType: hard -"node-modules-regexp@npm:^1.0.0": - version: 1.0.0 - resolution: "node-modules-regexp@npm:1.0.0" - checksum: 99541903536c5ce552786f0fca7f06b88df595e62e423c21fa86a1674ee2363dad1f7482d1bec20b4bd9fa5f262f88e6e5cb788fc56411113f2fe2e97783a3a7 - languageName: node - linkType: hard - -"node-releases@npm:^1.1.71": - version: 1.1.73 - resolution: "node-releases@npm:1.1.73" - checksum: 44a6caec3330538a669c156fa84833725ae92b317585b106e08ab292c14da09f30cb913c10f1a7402180a51b10074832d4e045b6c3512d74c37d86b41a69e63b +"node-releases@npm:^2.0.8": + version: 2.0.10 + resolution: "node-releases@npm:2.0.10" + checksum: d784ecde25696a15d449c4433077f5cce620ed30a1656c4abf31282bfc691a70d9618bae6868d247a67914d1be5cc4fde22f65a05f4398cdfb92e0fc83cadfbc languageName: node linkType: hard @@ -5662,13 +5480,6 @@ __metadata: languageName: node linkType: hard -"nwsapi@npm:^2.2.0": - version: 2.2.0 - resolution: "nwsapi@npm:2.2.0" - checksum: 5ef4a9bc0c1a5b7f2e014aa6a4b359a257503b796618ed1ef0eb852098f77e772305bb0e92856e4bbfa3e6c75da48c0113505c76f144555ff38867229c2400a7 - languageName: node - linkType: hard - "oauth-sign@npm:~0.9.0": version: 0.9.0 resolution: "oauth-sign@npm:0.9.0" @@ -5750,20 +5561,6 @@ __metadata: languageName: node linkType: hard -"optionator@npm:^0.8.1": - version: 0.8.3 - resolution: "optionator@npm:0.8.3" - dependencies: - deep-is: ~0.1.3 - fast-levenshtein: ~2.0.6 - levn: ~0.3.0 - prelude-ls: ~1.1.2 - type-check: ~0.3.2 - word-wrap: ~1.2.3 - checksum: b8695ddf3d593203e25ab0900e265d860038486c943ff8b774f596a310f8ceebdb30c6832407a8198ba3ec9debe1abe1f51d4aad94843612db3b76d690c61d34 - languageName: node - linkType: hard - "optionator@npm:^0.9.1": version: 0.9.1 resolution: "optionator@npm:0.9.1" @@ -5778,13 +5575,6 @@ __metadata: languageName: node linkType: hard -"p-each-series@npm:^2.1.0": - version: 2.2.0 - resolution: "p-each-series@npm:2.2.0" - checksum: 5fbe2f1f1966f55833bd401fe36f7afe410707d5e9fb6032c6dde8aa716d50521c3bb201fdb584130569b5941d5e84993e09e0b3f76a474288e0ede8f632983c - languageName: node - linkType: hard - "p-limit@npm:^2.2.0": version: 2.3.0 resolution: "p-limit@npm:2.3.0" @@ -5794,7 +5584,7 @@ __metadata: languageName: node linkType: hard -"p-limit@npm:^3.0.2": +"p-limit@npm:^3.0.2, p-limit@npm:^3.1.0": version: 3.1.0 resolution: "p-limit@npm:3.1.0" dependencies: @@ -5846,10 +5636,15 @@ __metadata: languageName: node linkType: hard -"parse5@npm:6.0.1": - version: 6.0.1 - resolution: "parse5@npm:6.0.1" - checksum: 7d569a176c5460897f7c8f3377eff640d54132b9be51ae8a8fa4979af940830b2b0c296ce75e5bd8f4041520aadde13170dbdec44889975f906098ea0002f4bd +"parse-json@npm:^5.2.0": + version: 5.2.0 + resolution: "parse-json@npm:5.2.0" + dependencies: + "@babel/code-frame": ^7.0.0 + error-ex: ^1.3.1 + json-parse-even-better-errors: ^2.3.0 + lines-and-columns: ^1.1.6 + checksum: 62085b17d64da57f40f6afc2ac1f4d95def18c4323577e1eced571db75d9ab59b297d1d10582920f84b15985cbfc6b6d450ccbf317644cfa176f3ed982ad87e2 languageName: node linkType: hard @@ -5917,6 +5712,13 @@ __metadata: languageName: node linkType: hard +"picocolors@npm:^1.0.0": + version: 1.0.0 + resolution: "picocolors@npm:1.0.0" + checksum: a2e8092dd86c8396bdba9f2b5481032848525b3dc295ce9b57896f931e63fc16f79805144321f72976383fc249584672a75cc18d6777c6b757603f372f745981 + languageName: node + linkType: hard + "picomatch@npm:^2.0.4, picomatch@npm:^2.2.3": version: 2.3.0 resolution: "picomatch@npm:2.3.0" @@ -5924,12 +5726,10 @@ __metadata: languageName: node linkType: hard -"pirates@npm:^4.0.1": - version: 4.0.1 - resolution: "pirates@npm:4.0.1" - dependencies: - node-modules-regexp: ^1.0.0 - checksum: 091e232aac19f0049a681838fa9fcb4af824b5b1eb0e9325aa07b9d13245bfe3e4fa57a7766b9fdcd19cb89f2c15c688b46023be3047cb288023a0c079d3b2a3 +"pirates@npm:^4.0.4": + version: 4.0.5 + resolution: "pirates@npm:4.0.5" + checksum: c9994e61b85260bec6c4fc0307016340d9b0c4f4b6550a957afaaff0c9b1ad58fbbea5cfcf083860a25cb27a375442e2b0edf52e2e1e40e69934e08dcc52d227 languageName: node linkType: hard @@ -5949,13 +5749,6 @@ __metadata: languageName: node linkType: hard -"prelude-ls@npm:~1.1.2": - version: 1.1.2 - resolution: "prelude-ls@npm:1.1.2" - checksum: c4867c87488e4a0c233e158e4d0d5565b609b105d75e4c05dc760840475f06b731332eb93cc8c9cecb840aa8ec323ca3c9a56ad7820ad2e63f0261dadcb154e4 - languageName: node - linkType: hard - "prettier-linter-helpers@npm:^1.0.0": version: 1.0.0 resolution: "prettier-linter-helpers@npm:1.0.0" @@ -5988,18 +5781,6 @@ __metadata: languageName: node linkType: hard -"pretty-format@npm:^27.0.6": - version: 27.0.6 - resolution: "pretty-format@npm:27.0.6" - dependencies: - "@jest/types": ^27.0.6 - ansi-regex: ^5.0.0 - ansi-styles: ^5.0.0 - react-is: ^17.0.1 - checksum: 1584f7fe29da829e3cf5c9090b0a18300c4b7b81510047e1d4ba080f87e19b6ce07f191ecf2354d64c1cec4c331009bde255a272db2c8292657b6acc059e4864 - languageName: node - linkType: hard - "pretty-format@npm:^29.0.0, pretty-format@npm:^29.4.3": version: 29.4.3 resolution: "pretty-format@npm:29.4.3" @@ -6045,7 +5826,7 @@ __metadata: languageName: node linkType: hard -"psl@npm:^1.1.28, psl@npm:^1.1.33": +"psl@npm:^1.1.28": version: 1.8.0 resolution: "psl@npm:1.8.0" checksum: 6150048ed2da3f919478bee8a82f3828303bc0fc730fb015a48f83c9977682c7b28c60ab01425a72d82a2891a1681627aa530a991d50c086b48a3be27744bde7 @@ -6082,13 +5863,6 @@ __metadata: languageName: node linkType: hard -"react-is@npm:^17.0.1": - version: 17.0.2 - resolution: "react-is@npm:17.0.2" - checksum: 9d6d111d8990dc98bc5402c1266a808b0459b5d54830bbea24c12d908b536df7883f268a7868cfaedde3dd9d4e0d574db456f84d2e6df9c4526f99bb4b5344d8 - languageName: node - linkType: hard - "react-is@npm:^18.0.0": version: 18.2.0 resolution: "react-is@npm:18.2.0" @@ -6208,6 +5982,13 @@ __metadata: languageName: node linkType: hard +"resolve.exports@npm:^2.0.0": + version: 2.0.0 + resolution: "resolve.exports@npm:2.0.0" + checksum: d8bee3b0cc0a0ae6c8323710983505bc6a3a2574f718e96f01e048a0f0af035941434b386cc9efc7eededc5e1199726185c306ec6f6a1aa55d5fbad926fd0634 + languageName: node + linkType: hard + "resolve@npm:^1.10.1, resolve@npm:^1.20.0, resolve@npm:^1.22.0": version: 1.22.1 resolution: "resolve@npm:1.22.1" @@ -6248,7 +6029,7 @@ __metadata: languageName: node linkType: hard -"rimraf@npm:^3.0.0, rimraf@npm:^3.0.2": +"rimraf@npm:^3.0.2": version: 3.0.2 resolution: "rimraf@npm:3.0.2" dependencies: @@ -6323,22 +6104,13 @@ __metadata: languageName: node linkType: hard -"safer-buffer@npm:>= 2.1.2 < 3, safer-buffer@npm:>= 2.1.2 < 3.0.0, safer-buffer@npm:^2.0.2, safer-buffer@npm:^2.1.0, safer-buffer@npm:~2.1.0": +"safer-buffer@npm:>= 2.1.2 < 3.0.0, safer-buffer@npm:^2.0.2, safer-buffer@npm:^2.1.0, safer-buffer@npm:~2.1.0": version: 2.1.2 resolution: "safer-buffer@npm:2.1.2" checksum: cab8f25ae6f1434abee8d80023d7e72b598cf1327164ddab31003c51215526801e40b66c5e65d658a0af1e9d6478cadcb4c745f4bd6751f97d8644786c0978b0 languageName: node linkType: hard -"saxes@npm:^5.0.1": - version: 5.0.1 - resolution: "saxes@npm:5.0.1" - dependencies: - xmlchars: ^2.2.0 - checksum: 5636b55cf15f7cf0baa73f2797bf992bdcf75d1b39d82c0aa4608555c774368f6ac321cb641fd5f3d3ceb87805122cd47540da6a7b5960fe0dbdb8f8c263f000 - languageName: node - linkType: hard - "scrypt-js@npm:^3.0.0, scrypt-js@npm:^3.0.1": version: 3.0.1 resolution: "scrypt-js@npm:3.0.1" @@ -6443,7 +6215,7 @@ __metadata: languageName: node linkType: hard -"signal-exit@npm:^3.0.0, signal-exit@npm:^3.0.2, signal-exit@npm:^3.0.3, signal-exit@npm:^3.0.7": +"signal-exit@npm:^3.0.0, signal-exit@npm:^3.0.3, signal-exit@npm:^3.0.7": version: 3.0.7 resolution: "signal-exit@npm:3.0.7" checksum: a2f098f247adc367dffc27845853e9959b9e88b01cb301658cfe4194352d8d2bb32e18467c786a7fe15f1d44b233ea35633d076d5e737870b7139949d1ab6318 @@ -6529,13 +6301,13 @@ __metadata: languageName: node linkType: hard -"source-map-support@npm:^0.5.6": - version: 0.5.19 - resolution: "source-map-support@npm:0.5.19" +"source-map-support@npm:0.5.13": + version: 0.5.13 + resolution: "source-map-support@npm:0.5.13" dependencies: buffer-from: ^1.0.0 source-map: ^0.6.0 - checksum: c72802fdba9cb62b92baef18cc14cc4047608b77f0353e6c36dd993444149a466a2845332c5540d4a6630957254f0f68f4ef5a0120c33d2e83974c51a05afbac + checksum: 933550047b6c1a2328599a21d8b7666507427c0f5ef5eaadd56b5da0fd9505e239053c66fe181bf1df469a3b7af9d775778eee283cbb7ae16b902ddc09e93a97 languageName: node linkType: hard @@ -6546,20 +6318,13 @@ __metadata: languageName: node linkType: hard -"source-map@npm:^0.6.0, source-map@npm:^0.6.1, source-map@npm:~0.6.1": +"source-map@npm:^0.6.0, source-map@npm:^0.6.1": version: 0.6.1 resolution: "source-map@npm:0.6.1" checksum: 59ce8640cf3f3124f64ac289012c2b8bd377c238e316fb323ea22fbfe83da07d81e000071d7242cad7a23cd91c7de98e4df8830ec3f133cb6133a5f6e9f67bc2 languageName: node linkType: hard -"source-map@npm:^0.7.3": - version: 0.7.3 - resolution: "source-map@npm:0.7.3" - checksum: cd24efb3b8fa69b64bf28e3c1b1a500de77e84260c5b7f2b873f88284df17974157cc88d386ee9b6d081f08fdd8242f3fc05c953685a6ad81aad94c7393dedea - languageName: node - linkType: hard - "spdx-exceptions@npm:^2.1.0": version: 2.2.0 resolution: "spdx-exceptions@npm:2.2.0" @@ -6773,7 +6538,7 @@ __metadata: languageName: node linkType: hard -"supports-color@npm:^7.0.0, supports-color@npm:^7.1.0, supports-color@npm:^7.2.0": +"supports-color@npm:^7.1.0, supports-color@npm:^7.2.0": version: 7.2.0 resolution: "supports-color@npm:7.2.0" dependencies: @@ -6791,16 +6556,6 @@ __metadata: languageName: node linkType: hard -"supports-hyperlinks@npm:^2.0.0": - version: 2.2.0 - resolution: "supports-hyperlinks@npm:2.2.0" - dependencies: - has-flag: ^4.0.0 - supports-color: ^7.0.0 - checksum: aef04fb41f4a67f1bc128f7c3e88a81b6cf2794c800fccf137006efe5bafde281da3e42e72bf9206c2fcf42e6438f37e3a820a389214d0a88613ca1f2d36076a - languageName: node - linkType: hard - "supports-preserve-symlinks-flag@npm:^1.0.0": version: 1.0.0 resolution: "supports-preserve-symlinks-flag@npm:1.0.0" @@ -6808,13 +6563,6 @@ __metadata: languageName: node linkType: hard -"symbol-tree@npm:^3.2.4": - version: 3.2.4 - resolution: "symbol-tree@npm:3.2.4" - checksum: 6e8fc7e1486b8b54bea91199d9535bb72f10842e40c79e882fc94fb7b14b89866adf2fd79efa5ebb5b658bc07fb459ccce5ac0e99ef3d72f474e74aaf284029d - languageName: node - linkType: hard - "tar@npm:^6.0.2, tar@npm:^6.1.11, tar@npm:^6.1.2": version: 6.1.12 resolution: "tar@npm:6.1.12" @@ -6829,16 +6577,6 @@ __metadata: languageName: node linkType: hard -"terminal-link@npm:^2.0.0": - version: 2.1.1 - resolution: "terminal-link@npm:2.1.1" - dependencies: - ansi-escapes: ^4.2.1 - supports-hyperlinks: ^2.0.0 - checksum: ce3d2cd3a438c4a9453947aa664581519173ea40e77e2534d08c088ee6dda449eabdbe0a76d2a516b8b73c33262fedd10d5270ccf7576ae316e3db170ce6562f - languageName: node - linkType: hard - "test-exclude@npm:^6.0.0": version: 6.0.0 resolution: "test-exclude@npm:6.0.0" @@ -6857,13 +6595,6 @@ __metadata: languageName: node linkType: hard -"throat@npm:^6.0.1": - version: 6.0.1 - resolution: "throat@npm:6.0.1" - checksum: 782d4171ee4e3cf947483ed2ff1af3e17cc4354c693b9d339284f61f99fbc401d171e0b0d2db3295bb7d447630333e9319c174ebd7ef315c6fb791db9675369c - languageName: node - linkType: hard - "through2@npm:^2.0.3": version: 2.0.5 resolution: "through2@npm:2.0.5" @@ -6874,7 +6605,7 @@ __metadata: languageName: node linkType: hard -"tmpl@npm:1.0.x": +"tmpl@npm:1.0.5": version: 1.0.5 resolution: "tmpl@npm:1.0.5" checksum: cd922d9b853c00fe414c5a774817be65b058d54a2d01ebb415840960406c669a0fc632f66df885e24cb022ec812739199ccbdb8d1164c3e513f85bfca5ab2873 @@ -6897,17 +6628,6 @@ __metadata: languageName: node linkType: hard -"tough-cookie@npm:^4.0.0": - version: 4.0.0 - resolution: "tough-cookie@npm:4.0.0" - dependencies: - psl: ^1.1.33 - punycode: ^2.1.1 - universalify: ^0.1.2 - checksum: 0891b37eb7d17faa3479d47f0dce2e3007f2583094ad272f2670d120fbcc3df3b0b0a631ba96ecad49f9e2297d93ff8995ce0d3292d08dd7eabe162f5b224d69 - languageName: node - linkType: hard - "tough-cookie@npm:~2.5.0": version: 2.5.0 resolution: "tough-cookie@npm:2.5.0" @@ -6918,15 +6638,6 @@ __metadata: languageName: node linkType: hard -"tr46@npm:^2.1.0": - version: 2.1.0 - resolution: "tr46@npm:2.1.0" - dependencies: - punycode: ^2.1.1 - checksum: ffe6049b9dca3ae329b059aada7f515b0f0064c611b39b51ff6b53897e954650f6f63d9319c6c008d36ead477c7b55e5f64c9dc60588ddc91ff720d64eb710b3 - languageName: node - linkType: hard - "ts-jest@npm:^29.0.3": version: 29.0.5 resolution: "ts-jest@npm:29.0.5" @@ -7067,15 +6778,6 @@ __metadata: languageName: node linkType: hard -"type-check@npm:~0.3.2": - version: 0.3.2 - resolution: "type-check@npm:0.3.2" - dependencies: - prelude-ls: ~1.1.2 - checksum: dd3b1495642731bc0e1fc40abe5e977e0263005551ac83342ecb6f4f89551d106b368ec32ad3fb2da19b3bd7b2d1f64330da2ea9176d8ddbfe389fb286eb5124 - languageName: node - linkType: hard - "type-detect@npm:4.0.8, type-detect@npm:^4.0.8": version: 4.0.8 resolution: "type-detect@npm:4.0.8" @@ -7097,15 +6799,6 @@ __metadata: languageName: node linkType: hard -"typedarray-to-buffer@npm:^3.1.5": - version: 3.1.5 - resolution: "typedarray-to-buffer@npm:3.1.5" - dependencies: - is-typedarray: ^1.0.0 - checksum: 99c11aaa8f45189fcfba6b8a4825fd684a321caa9bd7a76a27cf0c7732c174d198b99f449c52c3818107430b5f41c0ccbbfb75cb2ee3ca4a9451710986d61a60 - languageName: node - linkType: hard - "typedoc@npm:^0.23.15": version: 0.23.25 resolution: "typedoc@npm:0.23.25" @@ -7172,10 +6865,17 @@ __metadata: languageName: node linkType: hard -"universalify@npm:^0.1.2": - version: 0.1.2 - resolution: "universalify@npm:0.1.2" - checksum: 40cdc60f6e61070fe658ca36016a8f4ec216b29bf04a55dce14e3710cc84c7448538ef4dad3728d0bfe29975ccd7bfb5f414c45e7b78883567fb31b246f02dff +"update-browserslist-db@npm:^1.0.10": + version: 1.0.10 + resolution: "update-browserslist-db@npm:1.0.10" + dependencies: + escalade: ^3.1.1 + picocolors: ^1.0.0 + peerDependencies: + browserslist: ">= 4.21.0" + bin: + browserslist-lint: cli.js + checksum: 12db73b4f63029ac407b153732e7cd69a1ea8206c9100b482b7d12859cd3cd0bc59c602d7ae31e652706189f1acb90d42c53ab24a5ba563ed13aebdddc5561a0 languageName: node linkType: hard @@ -7218,14 +6918,14 @@ __metadata: languageName: node linkType: hard -"v8-to-istanbul@npm:^8.0.0": - version: 8.0.0 - resolution: "v8-to-istanbul@npm:8.0.0" +"v8-to-istanbul@npm:^9.0.1": + version: 9.1.0 + resolution: "v8-to-istanbul@npm:9.1.0" dependencies: + "@jridgewell/trace-mapping": ^0.3.12 "@types/istanbul-lib-coverage": ^2.0.1 convert-source-map: ^1.6.0 - source-map: ^0.7.3 - checksum: 3e8be80b9967a18c2196b016b29a956ffddb8fd2f2abe5ae126a616209c2ed7ba3172a9630715b375c50f88dd1dea3c97ba3e2ebfaee902dc4cc6a177f31a039 + checksum: 2069d59ee46cf8d83b4adfd8a5c1a90834caffa9f675e4360f1157ffc8578ef0f763c8f32d128334424159bb6b01f3876acd39cd13297b2769405a9da241f8d1 languageName: node linkType: hard @@ -7254,71 +6954,12 @@ __metadata: languageName: node linkType: hard -"w3c-hr-time@npm:^1.0.2": - version: 1.0.2 - resolution: "w3c-hr-time@npm:1.0.2" - dependencies: - browser-process-hrtime: ^1.0.0 - checksum: ec3c2dacbf8050d917bbf89537a101a08c2e333b4c19155f7d3bedde43529d4339db6b3d049d9610789cb915f9515f8be037e0c54c079e9d4735c50b37ed52b9 - languageName: node - linkType: hard - -"w3c-xmlserializer@npm:^2.0.0": - version: 2.0.0 - resolution: "w3c-xmlserializer@npm:2.0.0" - dependencies: - xml-name-validator: ^3.0.0 - checksum: ae25c51cf71f1fb2516df1ab33a481f83461a117565b95e3d0927432522323f93b1b2846cbb60196d337970c421adb604fc2d0d180c6a47a839da01db5b9973b - languageName: node - linkType: hard - -"walker@npm:^1.0.7": - version: 1.0.7 - resolution: "walker@npm:1.0.7" - dependencies: - makeerror: 1.0.x - checksum: 4038fcf92f6ab0288267ad05008aec9e089a759f1bd32e1ea45cc2eb498eb12095ec43cf8ca2bf23a465f4580a0d33b25b89f450ba521dd27083cbc695ee6bf5 - languageName: node - linkType: hard - -"webidl-conversions@npm:^5.0.0": - version: 5.0.0 - resolution: "webidl-conversions@npm:5.0.0" - checksum: ccf1ec2ca7c0b5671e5440ace4a66806ae09c49016ab821481bec0c05b1b82695082dc0a27d1fe9d804d475a408ba0c691e6803fd21be608e710955d4589cd69 - languageName: node - linkType: hard - -"webidl-conversions@npm:^6.1.0": - version: 6.1.0 - resolution: "webidl-conversions@npm:6.1.0" - checksum: 1f526507aa491f972a0c1409d07f8444e1d28778dfa269a9971f2e157182f3d496dc33296e4ed45b157fdb3bf535bb90c90bf10c50dcf1dd6caacb2a34cc84fb - languageName: node - linkType: hard - -"whatwg-encoding@npm:^1.0.5": - version: 1.0.5 - resolution: "whatwg-encoding@npm:1.0.5" - dependencies: - iconv-lite: 0.4.24 - checksum: 5be4efe111dce29ddee3448d3915477fcc3b28f991d9cf1300b4e50d6d189010d47bca2f51140a844cf9b726e8f066f4aee72a04d687bfe4f2ee2767b2f5b1e6 - languageName: node - linkType: hard - -"whatwg-mimetype@npm:^2.3.0": - version: 2.3.0 - resolution: "whatwg-mimetype@npm:2.3.0" - checksum: 23eb885940bcbcca4ff841c40a78e9cbb893ec42743993a42bf7aed16085b048b44b06f3402018931687153550f9a32d259dfa524e4f03577ab898b6965e5383 - languageName: node - linkType: hard - -"whatwg-url@npm:^8.0.0, whatwg-url@npm:^8.5.0": - version: 8.7.0 - resolution: "whatwg-url@npm:8.7.0" +"walker@npm:^1.0.8": + version: 1.0.8 + resolution: "walker@npm:1.0.8" dependencies: - lodash: ^4.7.0 - tr46: ^2.1.0 - webidl-conversions: ^6.1.0 - checksum: a87abcc6cefcece5311eb642858c8fdb234e51ec74196bfacf8def2edae1bfbffdf6acb251646ed6301f8cee44262642d8769c707256125a91387e33f405dd1e + makeerror: 1.0.12 + checksum: ad7a257ea1e662e57ef2e018f97b3c02a7240ad5093c392186ce0bcf1f1a60bbadd520d073b9beb921ed99f64f065efb63dfc8eec689a80e569f93c1c5d5e16c languageName: node linkType: hard @@ -7355,7 +6996,7 @@ __metadata: languageName: node linkType: hard -"word-wrap@npm:^1.2.3, word-wrap@npm:~1.2.3": +"word-wrap@npm:^1.2.3": version: 1.2.3 resolution: "word-wrap@npm:1.2.3" checksum: 30b48f91fcf12106ed3186ae4fa86a6a1842416df425be7b60485de14bec665a54a68e4b5156647dec3a70f25e84d270ca8bc8cd23182ed095f5c7206a938c1f @@ -7380,44 +7021,13 @@ __metadata: languageName: node linkType: hard -"write-file-atomic@npm:^3.0.0": - version: 3.0.3 - resolution: "write-file-atomic@npm:3.0.3" +"write-file-atomic@npm:^4.0.2": + version: 4.0.2 + resolution: "write-file-atomic@npm:4.0.2" dependencies: imurmurhash: ^0.1.4 - is-typedarray: ^1.0.0 - signal-exit: ^3.0.2 - typedarray-to-buffer: ^3.1.5 - checksum: c55b24617cc61c3a4379f425fc62a386cc51916a9b9d993f39734d005a09d5a4bb748bc251f1304e7abd71d0a26d339996c275955f527a131b1dcded67878280 - languageName: node - linkType: hard - -"ws@npm:^7.4.5": - version: 7.5.1 - resolution: "ws@npm:7.5.1" - peerDependencies: - bufferutil: ^4.0.1 - utf-8-validate: ^5.0.2 - peerDependenciesMeta: - bufferutil: - optional: true - utf-8-validate: - optional: true - checksum: b9da1b5dc8cd57725453b7f2305e39e21ddcfb5d908cc8ae8b12112b955f50d0d4921009f0f9d587000b0c72cb3748db329b3ddbd98e86829ffcf7b9700a58bf - languageName: node - linkType: hard - -"xml-name-validator@npm:^3.0.0": - version: 3.0.0 - resolution: "xml-name-validator@npm:3.0.0" - checksum: b3ac459afed783c285bb98e4960bd1f3ba12754fd4f2320efa0f9181ca28928c53cc75ca660d15d205e81f92304419afe94c531c7cfb3e0649aa6d140d53ecb0 - languageName: node - linkType: hard - -"xmlchars@npm:^2.2.0": - version: 2.2.0 - resolution: "xmlchars@npm:2.2.0" - checksum: 8c70ac94070ccca03f47a81fcce3b271bd1f37a591bf5424e787ae313fcb9c212f5f6786e1fa82076a2c632c0141552babcd85698c437506dfa6ae2d58723062 + signal-exit: ^3.0.7 + checksum: 5da60bd4eeeb935eec97ead3df6e28e5917a6bd317478e4a85a5285e8480b8ed96032bbcc6ecd07b236142a24f3ca871c924ec4a6575e623ec1b11bf8c1c253c languageName: node linkType: hard @@ -7435,6 +7045,13 @@ __metadata: languageName: node linkType: hard +"yallist@npm:^3.0.2": + version: 3.1.1 + resolution: "yallist@npm:3.1.1" + checksum: 48f7bb00dc19fc635a13a39fe547f527b10c9290e7b3e836b9a8f1ca04d4d342e85714416b3c2ab74949c9c66f9cebb0473e6bc353b79035356103b47641285d + languageName: node + linkType: hard + "yallist@npm:^4.0.0": version: 4.0.0 resolution: "yallist@npm:4.0.0" @@ -7449,14 +7066,14 @@ __metadata: languageName: node linkType: hard -"yargs-parser@npm:^21.0.1": +"yargs-parser@npm:^21.0.1, yargs-parser@npm:^21.1.1": version: 21.1.1 resolution: "yargs-parser@npm:21.1.1" checksum: ed2d96a616a9e3e1cc7d204c62ecc61f7aaab633dcbfab2c6df50f7f87b393993fe6640d017759fe112d0cb1e0119f2b4150a87305cc873fd90831c6a58ccf1c languageName: node linkType: hard -"yargs@npm:^16.0.3, yargs@npm:^16.2.0": +"yargs@npm:^16.2.0": version: 16.2.0 resolution: "yargs@npm:16.2.0" dependencies: @@ -7486,6 +7103,21 @@ __metadata: languageName: node linkType: hard +"yargs@npm:^17.3.1": + version: 17.7.1 + resolution: "yargs@npm:17.7.1" + dependencies: + cliui: ^8.0.1 + escalade: ^3.1.1 + get-caller-file: ^2.0.5 + require-directory: ^2.1.1 + string-width: ^4.2.3 + y18n: ^5.0.5 + yargs-parser: ^21.1.1 + checksum: 3d8a43c336a4942bc68080768664aca85c7bd406f018bad362fd255c41c8f4e650277f42fd65d543fce99e084124ddafee7bbfc1a5c6a8fda4cec78609dcf8d4 + languageName: node + linkType: hard + "yn@npm:3.1.1": version: 3.1.1 resolution: "yn@npm:3.1.1" From 98769cd124414c3b4de7d125ff70601ee2d4d378 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 23 Feb 2023 18:03:17 -0300 Subject: [PATCH 008/109] Create types file --- src/types.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/types.ts diff --git a/src/types.ts b/src/types.ts new file mode 100644 index 00000000..7a0ad7d3 --- /dev/null +++ b/src/types.ts @@ -0,0 +1,20 @@ +import type { Hex, Eip1024EncryptedData, Keyring } from '@metamask/utils'; + +export interface IKeyringController { + +} + +export type MessageParams = { + from: Hex | string; + data: Hex | string | Eip1024EncryptedData; +}; + +export enum KeyringType { + HD = 'HD Key Tree', + Simple = 'Simple Key Pair', +} + +export type State = any; +export type ExtendedKeyring = Keyring & { + generateRandomMnemonic: () => string; +}; From a605febbc345960af4cac6f1ed2c9ed061d902ae Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 23 Feb 2023 18:04:14 -0300 Subject: [PATCH 009/109] Solve lint issues --- src/KeyringController.test.ts | 91 +++++++++++++++++---------------- src/KeyringController.ts | 95 +++++++++++++++++------------------ 2 files changed, 94 insertions(+), 92 deletions(-) diff --git a/src/KeyringController.test.ts b/src/KeyringController.test.ts index b431714a..f0fed9d5 100644 --- a/src/KeyringController.test.ts +++ b/src/KeyringController.test.ts @@ -1,5 +1,6 @@ import HdKeyring from '@metamask/eth-hd-keyring'; import { normalize as normalizeAddress } from '@metamask/eth-sig-util'; +import type { Hex } from '@metamask/utils'; import { strict as assert } from 'assert'; import Wallet from 'ethereumjs-wallet'; import { restore, spy, stub, assert as sinonAssert } from 'sinon'; @@ -7,6 +8,7 @@ import { restore, spy, stub, assert as sinonAssert } from 'sinon'; import { KeyringController, keyringBuilderFactory } from '.'; import mockEncryptor from './mocks/mock-encryptor'; import KeyringMockWithInit from './mocks/mock-keyring'; +import { ExtendedKeyring, KeyringType } from './types'; const password = 'password123'; @@ -31,7 +33,7 @@ const walletTwoAddresses = [ ]; describe('KeyringController', function () { - let keyringController; + let keyringController: KeyringController; beforeEach(async function () { keyringController = new KeyringController({ @@ -101,7 +103,7 @@ describe('KeyringController', function () { describe('persistAllKeyrings', function () { it('should persist keyrings in _unsupportedKeyrings array', async function () { const unsupportedKeyring = 'DUMMY_KEYRING'; - keyringController._unsupportedKeyrings = [unsupportedKeyring]; + keyringController.#unsupportedKeyrings = [unsupportedKeyring]; await keyringController.persistAllKeyrings(); const { vault } = keyringController.store.getState(); @@ -141,7 +143,7 @@ describe('KeyringController', function () { const { vault } = keyringController.store.getState(); // eslint-disable-next-line jest/no-restricted-matchers expect(vault).toBeTruthy(); - keyringController.encryptor.encrypt.args.forEach(([actualPassword]) => { + keyringController.encryptor.encrypt.args.forEach(([actualPassword]: string[]) => { expect(actualPassword).toBe(password); }); }); @@ -193,7 +195,7 @@ describe('KeyringController', function () { ); await expect(() => - keyringController.createNewVaultAndRestore(password, 1234), + keyringController.createNewVaultAndRestore(password, '1234'), ).rejects.toThrow( 'Eth-Hd-Keyring: Invalid secret recovery phrase provided', ); @@ -238,7 +240,7 @@ describe('KeyringController', function () { const keyring = await keyringController.addNewKeyring('Simple Key Pair', [ privateKey, ]); - const keyringAccounts = await keyring.getAccounts(); + const keyringAccounts = await keyring?.getAccounts(); const expectedKeyringAccounts = [ '0x627306090abab3a6e1400e9345bc60c78a8bef57', ]; @@ -255,7 +257,7 @@ describe('KeyringController', function () { const previousAllAccounts = await keyringController.getAccounts(); expect(previousAllAccounts).toHaveLength(1); const keyring = await keyringController.addNewKeyring('HD Key Tree'); - const keyringAccounts = await keyring.getAccounts(); + const keyringAccounts = await keyring?.getAccounts(); expect(keyringAccounts).toHaveLength(1); const allAccounts = await keyringController.getAccounts(); expect(allAccounts).toHaveLength(2); @@ -268,10 +270,10 @@ describe('KeyringController', function () { numberOfAccounts: 2, mnemonic: walletTwoSeedWords, }); - const keyringAccounts = await keyring.getAccounts(); + const keyringAccounts = await keyring?.getAccounts(); expect(keyringAccounts).toHaveLength(2); - expect(keyringAccounts[0]).toStrictEqual(walletTwoAddresses[0]); - expect(keyringAccounts[1]).toStrictEqual(walletTwoAddresses[1]); + expect(keyringAccounts![0]).toStrictEqual(walletTwoAddresses[0]); + expect(keyringAccounts![1]).toStrictEqual(walletTwoAddresses[1]); const allAccounts = await keyringController.getAccounts(); expect(allAccounts).toHaveLength(3); }); @@ -300,7 +302,7 @@ describe('KeyringController', function () { const keyring = await keyringController.addNewKeyring('HD Key Tree'); - const keyringAccounts = await keyring.getAccounts(); + const keyringAccounts = await keyring?.getAccounts(); expect(keyringAccounts).toHaveLength(1); }); }); @@ -316,11 +318,11 @@ describe('KeyringController', function () { }; const keyring = await keyringController.restoreKeyring(mockSerialized); - const wallet = await keyring.serialize(); + const wallet = await keyring?.serialize(); expect(wallet.numberOfAccounts).toBe(1); - const accounts = await keyring.getAccounts(); - expect(accounts[0]).toBe(walletOneAddresses[0]); + const accounts = await keyring?.getAccounts(); + expect(accounts![0]).toBe(walletOneAddresses[0]); }); it('should return undefined if keyring type is not supported.', async function () { @@ -376,7 +378,7 @@ describe('KeyringController', function () { expect(keyringController.keyrings).toHaveLength(2); // remove that account that we just added - await keyringController.removeAccount(account.publicKey); + await keyringController.removeAccount(account.publicKey as Hex); expect(keyringController.keyrings).toHaveLength(1); // fetch accounts after removal @@ -400,7 +402,7 @@ describe('KeyringController', function () { expect(keyringController.keyrings).toHaveLength(2); // remove that account that we just added - await keyringController.removeAccount(account.publicKey); + await keyringController.removeAccount(account.publicKey as Hex); // Check that the previous keyring with only one account // was also removed after removing the account @@ -418,7 +420,7 @@ describe('KeyringController', function () { expect(keyringController.keyrings).toHaveLength(2); // remove one account from the keyring we just added - await keyringController.removeAccount(walletTwoAddresses[0]); + await keyringController.removeAccount(walletTwoAddresses[0] as Hex); // Check that the newly added keyring was not removed after // removing the account since it still has an account left @@ -440,13 +442,13 @@ describe('KeyringController', function () { }); it('add serialized keyring to _unsupportedKeyrings array if keyring type is not known', async function () { - const _unsupportedKeyrings = [{ type: 'Ledger Keyring', data: 'DUMMY' }]; - mockEncryptor.encrypt(password, _unsupportedKeyrings); + const unsupportedKeyrings = [{ type: 'Ledger Keyring', data: 'DUMMY' }]; + mockEncryptor.encrypt(password, unsupportedKeyrings); await keyringController.setLocked(); const keyrings = await keyringController.unlockKeyrings(password); expect(keyrings).toHaveLength(0); - expect(keyringController._unsupportedKeyrings).toStrictEqual( - _unsupportedKeyrings, + expect(keyringController.unsupportedKeyrings).toStrictEqual( + unsupportedKeyrings, ); }); }); @@ -470,22 +472,20 @@ describe('KeyringController', function () { walletOneSeedWords, ); - expect(() => - keyringController.verifyPassword(password), - ).not.toThrow(); + expect(() => keyringController.verifyPassword(password)).not.toThrow(); }); }); describe('addNewAccount', function () { it('adds a new account to the keyring it receives as an argument', async function () { const [HDKeyring] = await keyringController.getKeyringsByType( - 'HD Key Tree', + KeyringType.HD ); - const initialAccounts = await HDKeyring.getAccounts(); + const initialAccounts = await HDKeyring?.getAccounts(); expect(initialAccounts).toHaveLength(1); - await keyringController.addNewAccount(HDKeyring); - const accountsAfterAdd = await HDKeyring.getAccounts(); + await keyringController.addNewAccount(HDKeyring!); + const accountsAfterAdd = await HDKeyring?.getAccounts(); expect(accountsAfterAdd).toHaveLength(2); }); }); @@ -496,10 +496,12 @@ describe('KeyringController', function () { const privateKey = '0xb8a9c05beeedb25df85f8d641538cbffedf67216048de9c678ee26260eb91952'; - const keyring = await keyringController.addNewKeyring('Simple Key Pair', [ + const keyring = await keyringController.addNewKeyring(KeyringType.Simple, [ privateKey, ]); - keyring.getAppKeyAddress = spy(); + + const getAppKeyAddressSpy = spy(); + keyringController.on('getAppKeyAddress', getAppKeyAddressSpy); /* eslint-disable-next-line require-atomic-updates */ keyringController.getKeyringForAccount = stub().returns( Promise.resolve(keyring), @@ -507,12 +509,12 @@ describe('KeyringController', function () { await keyringController.getAppKeyAddress(address, 'someapp.origin.io'); - expect(keyringController.getKeyringForAccount.calledOnce).toBe(true); - expect(keyringController.getKeyringForAccount.getCall(0).args[0]).toBe( + expect(getAppKeyAddressSpy.calledOnce).toBe(true); + expect(getAppKeyAddressSpy.getCall(0).args[0]).toBe( normalizeAddress(address), ); - expect(keyring.getAppKeyAddress.calledOnce).toBe(true); - expect(keyring.getAppKeyAddress.getCall(0).args).toStrictEqual([ + expect(getAppKeyAddressSpy.calledOnce).toBe(true); + expect(getAppKeyAddressSpy.getCall(0).args).toStrictEqual([ normalizeAddress(address), 'someapp.origin.io', ]); @@ -559,10 +561,11 @@ describe('KeyringController', function () { }); it('forget hardware device', async function () { - const hdKeyring = keyringController.getKeyringsByType('HD Key Tree'); - hdKeyring.forgetDevice = spy(); + const hdKeyring = keyringController.getKeyringsByType(KeyringType.HD); + const forgetDeviceSpy = spy(); + keyringController.on('forgetDevice', forgetDeviceSpy); keyringController.forgetKeyring(hdKeyring); - expect(hdKeyring.forgetDevice.calledOnce).toBe(true); + expect(forgetDeviceSpy.calledOnce).toBe(true); }); }); @@ -681,10 +684,10 @@ describe('KeyringController', function () { const [firstKeyring] = keyringController.keyrings; - await keyringController.addNewAccount(firstKeyring); + await keyringController.addNewAccount(firstKeyring as ExtendedKeyring); expect(await keyringController.getAccounts()).toHaveLength(2); - await keyringController.addNewAccount(firstKeyring); + await keyringController.addNewAccount(firstKeyring as ExtendedKeyring); expect(await keyringController.getAccounts()).toHaveLength(3); const account = { @@ -700,7 +703,7 @@ describe('KeyringController', function () { expect(await keyringController.getAccounts()).toHaveLength(4); // remove that account that we just added - await keyringController.removeAccount(account.publicKey); + await keyringController.removeAccount(account.publicKey as Hex); expect(await keyringController.getAccounts()).toHaveLength(3); }); @@ -738,7 +741,7 @@ describe('KeyringController', function () { walletOneSeedWords, ); const privateKey = await keyringController.exportAccount( - walletOneAddresses[0], + walletOneAddresses[0] as Hex, ); expect(privateKey).toStrictEqual(walletOnePrivateKey[0]); }); @@ -754,7 +757,7 @@ describe('KeyringController', function () { it('signMessage', async () => { const inputParams = { - from: walletOneAddresses[0], + from: walletOneAddresses[0] as Hex, data: '0x879a053d4800c6354e76c7985a865d2922c82fb5b3f4577b2fe08b998954f2e0', origin: 'https://metamask.github.io', }; @@ -766,7 +769,7 @@ describe('KeyringController', function () { it('signPersonalMessage', async () => { const inputParams = { - from: walletOneAddresses[0], + from: walletOneAddresses[0] as Hex, data: '0x4578616d706c652060706572736f6e616c5f7369676e60206d657373616765', origin: 'https://metamask.github.io', }; @@ -778,14 +781,14 @@ describe('KeyringController', function () { it('getEncryptionPublicKey', async () => { const result = await keyringController.getEncryptionPublicKey( - walletOneAddresses[0], + walletOneAddresses[0] as Hex, ); expect(result).toBe('SR6bQ1m3OTHvI1FLwcGzm+Uk6hffoFPxsQ0DTOeKMEc='); }); it('signTypedMessage', async () => { const inputParams = { - from: walletOneAddresses[0], + from: walletOneAddresses[0] as Hex, data: [ { type: 'string', diff --git a/src/KeyringController.ts b/src/KeyringController.ts index 2613e7b0..972666ab 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -1,10 +1,10 @@ import encryptor from '@metamask/browser-passworder'; // @ts-ignore -import HdKeyring from '@metamask/eth-hd-keyring'; +import HDKeyring from '@metamask/eth-hd-keyring'; +import { normalize as normalizeAddress } from '@metamask/eth-sig-util'; // @ts-ignore import SimpleKeyring from '@metamask/eth-simple-keyring'; -import { normalize as normalizeAddress } from '@metamask/eth-sig-util'; -import { +import type { Hex, Keyring, KeyringClass, @@ -18,21 +18,19 @@ import { EventEmitter } from 'events'; // @ts-ignore import ObservableStore from 'obs-store'; -type State = any; -type ExtendedKeyring = Keyring & { - generateRandomMnemonic: () => string; -}; +import { + MessageParams, + KeyringType, + State, + ExtendedKeyring, + IKeyringController, +} from './types'; const defaultKeyringBuilders = [ keyringBuilderFactory(SimpleKeyring), - keyringBuilderFactory(HdKeyring), + keyringBuilderFactory(HDKeyring), ]; -const enum KeyringType { - HDKeyring = 'HD Key Tree', - SimpleKeyring = 'Simple Key Pair', -} - /** * Strip the hex prefix from an address, if present. * @@ -152,7 +150,7 @@ class KeyringController extends EventEmitter { this.password = password; await this.#clearKeyrings(); - const keyring = await this.addNewKeyring(KeyringType.HDKeyring, { + const keyring = await this.addNewKeyring(KeyringType.HD, { mnemonic: seedPhrase, numberOfAccounts: 1, }); @@ -277,7 +275,7 @@ class KeyringController extends EventEmitter { throw new Error('KeyringController - No keyring found'); } - if ((!opts || !opts.mnemonic) && type === KeyringType.HDKeyring) { + if (!opts?.mnemonic && type === KeyringType.HD) { keyring.generateRandomMnemonic(); await keyring.addAccounts(1); } @@ -286,7 +284,7 @@ class KeyringController extends EventEmitter { await this.checkForDuplicate(type, accounts); this.keyrings.push(keyring); - await this.#persistAllKeyrings(); + await this.persistAllKeyrings(); this.fullUpdate(); @@ -331,10 +329,10 @@ class KeyringController extends EventEmitter { type: string, newAccountArray: string[], ): Promise { - const accounts = await this.#getAccounts(); + const accounts = await this.getAccounts(); switch (type) { - case KeyringType.SimpleKeyring: { + case KeyringType.Simple: { const isIncluded = Boolean( accounts.find( (key: string) => @@ -372,7 +370,7 @@ class KeyringController extends EventEmitter { this.emit('newAccount', hexAccount); }); - await this.#persistAllKeyrings(); + await this.persistAllKeyrings(); return this.fullUpdate(); } @@ -426,7 +424,7 @@ class KeyringController extends EventEmitter { await this.removeEmptyKeyrings(); } - await this.#persistAllKeyrings(); + await this.persistAllKeyrings(); return this.fullUpdate(); } @@ -466,13 +464,11 @@ class KeyringController extends EventEmitter { * Attempts to sign the provided message parameters. * * @param msgParams - The message parameters to sign. - * @param msgParams.from - * @param msgParams.data * @param opts - Additional signing options. * @returns The raw signature. */ async signMessage( - msgParams: { from: Hex | string; data: string }, + msgParams: MessageParams, opts: Record = {}, ) { const address = normalizeAddress(msgParams.from) as Hex; @@ -483,7 +479,7 @@ class KeyringController extends EventEmitter { ); } - return await keyring.signMessage(address, msgParams.data, opts); + return await keyring.signMessage(address, msgParams.data as string, opts); } /** @@ -493,13 +489,11 @@ class KeyringController extends EventEmitter { * Prefixes the hash before signing per the personal sign expectation. * * @param msgParams - The message parameters to sign. - * @param msgParams.from * @param opts - Additional signing options. - * @param msgParams.data * @returns The raw signature. */ async signPersonalMessage( - msgParams: { from: Hex | string; data: Hex }, + msgParams: MessageParams, opts: Record = {}, ): Promise { const address = normalizeAddress(msgParams.from) as Hex; @@ -510,7 +504,11 @@ class KeyringController extends EventEmitter { ); } - return await keyring.signPersonalMessage(address, msgParams.data, opts); + return await keyring.signPersonalMessage( + address, + msgParams.data as Hex, + opts, + ); } /** @@ -543,15 +541,9 @@ class KeyringController extends EventEmitter { * Attempts to decrypt the provided message parameters. * * @param msgParams - The decryption message parameters. - * @param opts - Additional decryption options. - * @param msgParams.from - * @param msgParams.data * @returns The raw decryption result. */ - async decryptMessage(msgParams: { - from: Hex | string; - data: Eip1024EncryptedData; - }): Promise { + async decryptMessage(msgParams: MessageParams): Promise { const address = normalizeAddress(msgParams.from) as Hex; const keyring = await this.getKeyringForAccount(address); if (!keyring.decryptMessage) { @@ -560,7 +552,10 @@ class KeyringController extends EventEmitter { ); } - return keyring.decryptMessage(address, msgParams.data); + return keyring.decryptMessage( + address, + msgParams.data as Eip1024EncryptedData, + ); } /** @@ -568,13 +563,11 @@ class KeyringController extends EventEmitter { * * @see {@link https://github.com/ethereum/EIPs/pull/712#issuecomment-329988454|EIP712}. * @param msgParams - The message parameters to sign. - * @param msgParams.from - * @param msgParams.data * @param opts - Additional signing options. * @returns The raw signature. */ async signTypedMessage( - msgParams: { from: Hex | string; data: Eip1024EncryptedData }, + msgParams: MessageParams, opts = { version: 'V1' }, ): Promise { const address = normalizeAddress(msgParams.from) as Hex; @@ -585,7 +578,11 @@ class KeyringController extends EventEmitter { ); } - return keyring.signTypedData(address, msgParams.data, opts); + return keyring.signTypedData( + address, + msgParams.data as Eip1024EncryptedData, + opts, + ); } /** @@ -639,10 +636,12 @@ class KeyringController extends EventEmitter { * * @param keyring - The keyring to forget. */ - forgetKeyring(keyring: ExtendedKeyring & { forgetDevice?: () => void }) { + async forgetKeyring( + keyring: ExtendedKeyring & { forgetDevice?: () => void }, + ): Promise { if (keyring.forgetDevice) { keyring.forgetDevice(); - this.#persistAllKeyrings(); + await this.persistAllKeyrings(); } else { throw new Error( `KeyringController - keyring does not have method "forgetDevice", keyring type: ${keyring.type}`, @@ -709,9 +708,9 @@ class KeyringController extends EventEmitter { * @returns A promise that resolves if the operation was successful. */ async #createFirstKeyTree(): Promise { - this.#clearKeyrings(); + await this.#clearKeyrings(); - const keyring = await this.addNewKeyring(KeyringType.HDKeyring); + const keyring = await this.addNewKeyring(KeyringType.HD); if (!keyring) { throw new Error('KeyringController - No keyring found'); } @@ -736,7 +735,7 @@ class KeyringController extends EventEmitter { * * @returns Resolves to true once keyrings are persisted. */ - async #persistAllKeyrings() { + async persistAllKeyrings() { const { encryptionKey, encryptionSalt } = this.memStore.getState(); if (!this.password && !encryptionKey) { @@ -915,7 +914,7 @@ class KeyringController extends EventEmitter { * * @returns The array of accounts. */ - async #getAccounts(): Promise { + async getAccounts(): Promise { const keyrings = this.keyrings || []; const keyringArrays = await Promise.all( @@ -959,9 +958,9 @@ class KeyringController extends EventEmitter { let errorInfo = ''; if (!address) { errorInfo = 'The address passed in is invalid/empty'; - } else if (!candidates || !candidates.length) { + } else if (!candidates?.length) { errorInfo = 'There are no keyrings'; - } else if (!winners || !winners.length) { + } else if (!winners?.length) { errorInfo = 'There are keyrings, but none match the address'; } throw new Error( From f51af43cc41eb89ea9fe172a0320960590b517d4 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 23 Feb 2023 18:48:32 -0300 Subject: [PATCH 010/109] Remove private member --- src/KeyringController.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index 972666ab..63ff95d2 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -57,7 +57,7 @@ class KeyringController extends EventEmitter { cacheEncryptionKey: boolean; - #unsupportedKeyrings: any[]; + unsupportedKeyrings: any[]; password?: string; @@ -83,7 +83,7 @@ class KeyringController extends EventEmitter { this.encryptor = opts.encryptor || encryptor; this.keyrings = []; - this.#unsupportedKeyrings = []; + this.unsupportedKeyrings = []; // This option allows the controller to cache an exported key // for use in decrypting and encrypting data without password @@ -206,7 +206,7 @@ class KeyringController extends EventEmitter { * @returns A promise that resolves to the state. */ async submitPassword(password: string): Promise { - this.keyrings = await this.#unlockKeyrings(password); + this.keyrings = await this.unlockKeyrings(password); this.#setUnlocked(); return this.fullUpdate(); @@ -227,7 +227,7 @@ class KeyringController extends EventEmitter { encryptionKey: string, encryptionSalt: string, ): Promise { - this.keyrings = await this.#unlockKeyrings( + this.keyrings = await this.unlockKeyrings( undefined, encryptionKey, encryptionSalt, @@ -337,7 +337,7 @@ class KeyringController extends EventEmitter { accounts.find( (key: string) => key === newAccountArray[0] || - key === stripHexPrefix(newAccountArray[0]), + key === stripHexPrefix(newAccountArray[0] as string), ), ); @@ -675,7 +675,7 @@ class KeyringController extends EventEmitter { * @param type - The keyring types to retrieve. * @returns Keyrings matching the specified type. */ - getKeyringsByType(type: string): ExtendedKeyring[] { + getKeyringsByType(type: KeyringType): ExtendedKeyring[] { return this.keyrings.filter((keyring) => keyring.type === type); } @@ -754,7 +754,7 @@ class KeyringController extends EventEmitter { }), ); - serializedKeyrings.push(...this.#unsupportedKeyrings); + serializedKeyrings.push(...this.unsupportedKeyrings); let vault; let newEncryptionKey; @@ -811,7 +811,7 @@ class KeyringController extends EventEmitter { * @param encryptionSalt - The salt used to encrypt the vault. * @returns The keyrings array. */ - async #unlockKeyrings( + async unlockKeyrings( password: string | undefined, encryptionKey?: string, encryptionSalt?: string, @@ -879,7 +879,7 @@ class KeyringController extends EventEmitter { const keyring = await this.#newKeyring(type, data); if (!keyring) { - this.#unsupportedKeyrings.push(serialized); + this.unsupportedKeyrings.push(serialized); return undefined; } From d9e1de5467e6e452130968f4af52583610457233 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 23 Feb 2023 23:55:47 -0300 Subject: [PATCH 011/109] Solve lint issues --- src/KeyringController.test.ts | 39 +++++++++++++++++++---------------- src/types.ts | 4 +--- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/KeyringController.test.ts b/src/KeyringController.test.ts index f0fed9d5..f6dd04d6 100644 --- a/src/KeyringController.test.ts +++ b/src/KeyringController.test.ts @@ -143,9 +143,11 @@ describe('KeyringController', function () { const { vault } = keyringController.store.getState(); // eslint-disable-next-line jest/no-restricted-matchers expect(vault).toBeTruthy(); - keyringController.encryptor.encrypt.args.forEach(([actualPassword]: string[]) => { - expect(actualPassword).toBe(password); - }); + keyringController.encryptor.encrypt.args.forEach( + ([actualPassword]: string[]) => { + expect(actualPassword).toBe(password); + }, + ); }); it('should throw error if accounts are not generated correctly', async () => { @@ -153,7 +155,7 @@ describe('KeyringController', function () { .spyOn(HdKeyring.prototype, 'getAccounts') .mockImplementation(async () => Promise.resolve([])); - await expect(() => + await expect(async () => keyringController.createNewVaultAndKeychain(password), ).rejects.toThrow('KeyringController - No account found on keychain.'); }); @@ -179,13 +181,13 @@ describe('KeyringController', function () { }); it('throws error if argument password is not a string', async function () { - await expect(() => + await expect(async () => keyringController.createNewVaultAndRestore(12, walletTwoSeedWords), ).rejects.toThrow('Password must be text.'); }); it('throws error if mnemonic passed is invalid', async function () { - await expect(() => + await expect(async () => keyringController.createNewVaultAndRestore( password, 'test test test palace city barely security section midnight wealth south deer', @@ -194,7 +196,7 @@ describe('KeyringController', function () { 'Eth-Hd-Keyring: Invalid secret recovery phrase provided', ); - await expect(() => + await expect(async () => keyringController.createNewVaultAndRestore(password, '1234'), ).rejects.toThrow( 'Eth-Hd-Keyring: Invalid secret recovery phrase provided', @@ -223,7 +225,7 @@ describe('KeyringController', function () { .spyOn(HdKeyring.prototype, 'getAccounts') .mockImplementation(async () => Promise.resolve([])); - await expect(() => + await expect(async () => keyringController.createNewVaultAndRestore( password, walletTwoSeedWords, @@ -461,7 +463,7 @@ describe('KeyringController', function () { }); it('throws an error if no encrypted vault is in controller state', async function () { - await expect(() => + await expect(async () => keyringController.verifyPassword('test'), ).rejects.toThrow('Cannot unlock without a previous vault.'); }); @@ -472,15 +474,15 @@ describe('KeyringController', function () { walletOneSeedWords, ); - expect(() => keyringController.verifyPassword(password)).not.toThrow(); + expect(async () => + keyringController.verifyPassword(password), + ).not.toThrow(); }); }); describe('addNewAccount', function () { it('adds a new account to the keyring it receives as an argument', async function () { - const [HDKeyring] = await keyringController.getKeyringsByType( - KeyringType.HD - ); + const [HDKeyring] = keyringController.getKeyringsByType(KeyringType.HD); const initialAccounts = await HDKeyring?.getAccounts(); expect(initialAccounts).toHaveLength(1); @@ -496,9 +498,10 @@ describe('KeyringController', function () { const privateKey = '0xb8a9c05beeedb25df85f8d641538cbffedf67216048de9c678ee26260eb91952'; - const keyring = await keyringController.addNewKeyring(KeyringType.Simple, [ - privateKey, - ]); + const keyring = await keyringController.addNewKeyring( + KeyringType.Simple, + [privateKey], + ); const getAppKeyAddressSpy = spy(); keyringController.on('getAppKeyAddress', getAppKeyAddressSpy); @@ -553,7 +556,7 @@ describe('KeyringController', function () { privateKey, ]); expect(keyringController.keyrings).toHaveLength(2); - expect(() => keyringController.forgetKeyring(keyring)).toThrow( + expect(async () => keyringController.forgetKeyring(keyring)).toThrow( new Error( 'KeyringController - keyring does not have method "forgetDevice", keyring type: Simple Key Pair', ), @@ -564,7 +567,7 @@ describe('KeyringController', function () { const hdKeyring = keyringController.getKeyringsByType(KeyringType.HD); const forgetDeviceSpy = spy(); keyringController.on('forgetDevice', forgetDeviceSpy); - keyringController.forgetKeyring(hdKeyring); + await keyringController.forgetKeyring(hdKeyring); expect(forgetDeviceSpy.calledOnce).toBe(true); }); }); diff --git a/src/types.ts b/src/types.ts index 7a0ad7d3..3ed394a6 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,8 +1,6 @@ import type { Hex, Eip1024EncryptedData, Keyring } from '@metamask/utils'; -export interface IKeyringController { - -} +export type IKeyringController = {}; export type MessageParams = { from: Hex | string; From 601cb3ca85ca6d8fda80583564a887f6f09ab6c1 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Mon, 27 Feb 2023 23:12:19 -0300 Subject: [PATCH 012/109] Add typings --- typings/index.d.ts | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 typings/index.d.ts diff --git a/typings/index.d.ts b/typings/index.d.ts new file mode 100644 index 00000000..8c9915ac --- /dev/null +++ b/typings/index.d.ts @@ -0,0 +1,4 @@ +// eslint-disable-next-line import/unambiguous +declare module '@metamask/eth-hd-keyring'; +declare module '@metamask/eth-simple-keyring'; +declare module 'obs-store'; From fd02507c659edcd3b096a4a0489b3e58afd63d8d Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Mon, 27 Feb 2023 23:12:54 -0300 Subject: [PATCH 013/109] Update mock-encryptor --- src/mocks/mock-encryptor.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mocks/mock-encryptor.ts b/src/mocks/mock-encryptor.ts index d59e1185..5e856116 100644 --- a/src/mocks/mock-encryptor.ts +++ b/src/mocks/mock-encryptor.ts @@ -9,6 +9,7 @@ const MOCK_ENCRYPTION_DATA = `{"data":"2fOOPRKClNrisB+tmqIcETyZvDuL2iIR1Hr1nO7XZ const INVALID_PASSWORD_ERROR = 'Incorrect password.'; const MOCK_HEX = '0xabcdef0123456789'; +// eslint-disable-next-line no-restricted-globals const MOCK_KEY = Buffer.alloc(32); let cacheVal; @@ -34,7 +35,7 @@ const mockEncryptor = { }, async decryptWithEncryptedKeyString(_keyStr) { - const { vault } = await this.decryptWithDetail(); + const { vault } = await this.decryptWithDetail(_keyStr, 'mock vault'); return vault; }, From 46bc491c5e565e1933477d15afcf00169d69c5b2 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Mon, 27 Feb 2023 23:13:08 -0300 Subject: [PATCH 014/109] Update types --- src/types.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/types.ts b/src/types.ts index 3ed394a6..9cbe6ad9 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,10 +1,10 @@ import type { Hex, Eip1024EncryptedData, Keyring } from '@metamask/utils'; -export type IKeyringController = {}; +export type IKeyringController = any; export type MessageParams = { from: Hex | string; - data: Hex | string | Eip1024EncryptedData; + data: Hex | string | Eip1024EncryptedData | Record[]; }; export enum KeyringType { From d1401a2fb7d091c4366b99c0c5ea924b76b80743 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Mon, 27 Feb 2023 23:13:38 -0300 Subject: [PATCH 015/109] Update .eslintrc.js --- .eslintrc.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index e5fa88e8..dc7fd432 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -7,9 +7,6 @@ module.exports = { { files: ['*.ts'], extends: ['@metamask/eslint-config-typescript'], - rules: { - '@typescript-eslint/consistent-type-definitions': ['error', 'type'], - }, }, { From 3ce7a6e365cb56ba25de3680002ead8741b3a4d9 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Mon, 27 Feb 2023 23:14:22 -0300 Subject: [PATCH 016/109] Update test --- src/KeyringController.test.ts | 99 ++++++++++++++++++++--------------- 1 file changed, 56 insertions(+), 43 deletions(-) diff --git a/src/KeyringController.test.ts b/src/KeyringController.test.ts index f6dd04d6..36baf200 100644 --- a/src/KeyringController.test.ts +++ b/src/KeyringController.test.ts @@ -1,6 +1,6 @@ import HdKeyring from '@metamask/eth-hd-keyring'; import { normalize as normalizeAddress } from '@metamask/eth-sig-util'; -import type { Hex } from '@metamask/utils'; +import type { Hex, KeyringClass } from '@metamask/utils'; import { strict as assert } from 'assert'; import Wallet from 'ethereumjs-wallet'; import { restore, spy, stub, assert as sinonAssert } from 'sinon'; @@ -32,13 +32,17 @@ const walletTwoAddresses = [ '0x49dd2653f38f75d40fdbd51e83b9c9724c87f7eb', ]; -describe('KeyringController', function () { +describe('KeyringController', () => { let keyringController: KeyringController; beforeEach(async function () { keyringController = new KeyringController({ encryptor: mockEncryptor, - keyringBuilders: [keyringBuilderFactory(KeyringMockWithInit)], + keyringBuilders: [ + keyringBuilderFactory( + KeyringMockWithInit as unknown as KeyringClass, + ), + ], }); await keyringController.createNewVaultAndKeychain(password); @@ -103,7 +107,7 @@ describe('KeyringController', function () { describe('persistAllKeyrings', function () { it('should persist keyrings in _unsupportedKeyrings array', async function () { const unsupportedKeyring = 'DUMMY_KEYRING'; - keyringController.#unsupportedKeyrings = [unsupportedKeyring]; + keyringController.unsupportedKeyrings = [unsupportedKeyring]; await keyringController.persistAllKeyrings(); const { vault } = keyringController.store.getState(); @@ -166,7 +170,7 @@ describe('KeyringController', function () { const initialAccounts = await keyringController.getAccounts(); expect(initialAccounts).toHaveLength(1); - await keyringController.addNewKeyring('HD Key Tree'); + await keyringController.addNewKeyring(KeyringType.HD); const allAccounts = await keyringController.getAccounts(); expect(allAccounts).toHaveLength(2); @@ -182,7 +186,10 @@ describe('KeyringController', function () { it('throws error if argument password is not a string', async function () { await expect(async () => - keyringController.createNewVaultAndRestore(12, walletTwoSeedWords), + keyringController.createNewVaultAndRestore( + 12 as any, + walletTwoSeedWords, + ), ).rejects.toThrow('Password must be text.'); }); @@ -234,14 +241,16 @@ describe('KeyringController', function () { }); }); - describe('addNewKeyring', function () { + describe('addNewKeyring', () => { it('should add simple key pair', async function () { const privateKey = 'c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3'; const previousAccounts = await keyringController.getAccounts(); - const keyring = await keyringController.addNewKeyring('Simple Key Pair', [ - privateKey, - ]); + const keyring = await keyringController.addNewKeyring( + KeyringType.Simple, + { privateKeyArray: [privateKey] }, + ); + const keyringAccounts = await keyring?.getAccounts(); const expectedKeyringAccounts = [ '0x627306090abab3a6e1400e9345bc60c78a8bef57', @@ -258,7 +267,7 @@ describe('KeyringController', function () { it('should add HD Key Tree without mnemonic passed as an argument', async function () { const previousAllAccounts = await keyringController.getAccounts(); expect(previousAllAccounts).toHaveLength(1); - const keyring = await keyringController.addNewKeyring('HD Key Tree'); + const keyring = await keyringController.addNewKeyring(KeyringType.HD); const keyringAccounts = await keyring?.getAccounts(); expect(keyringAccounts).toHaveLength(1); const allAccounts = await keyringController.getAccounts(); @@ -268,14 +277,14 @@ describe('KeyringController', function () { it('should add HD Key Tree with mnemonic passed as an argument', async function () { const previousAllAccounts = await keyringController.getAccounts(); expect(previousAllAccounts).toHaveLength(1); - const keyring = await keyringController.addNewKeyring('HD Key Tree', { + const keyring = await keyringController.addNewKeyring(KeyringType.HD, { numberOfAccounts: 2, mnemonic: walletTwoSeedWords, }); const keyringAccounts = await keyring?.getAccounts(); expect(keyringAccounts).toHaveLength(2); - expect(keyringAccounts![0]).toStrictEqual(walletTwoAddresses[0]); - expect(keyringAccounts![1]).toStrictEqual(walletTwoAddresses[1]); + expect(keyringAccounts?.[0]).toStrictEqual(walletTwoAddresses[0]); + expect(keyringAccounts?.[1]).toStrictEqual(walletTwoAddresses[1]); const allAccounts = await keyringController.getAccounts(); expect(allAccounts).toHaveLength(3); }); @@ -292,9 +301,9 @@ describe('KeyringController', function () { sinonAssert.calledOnce(initSpy); }); - it('should add HD Key Tree when addAccounts is asynchronous', async function () { + it('should add HD Key Tree when addAccounts is asynchronous', async () => { const originalAccAccounts = HdKeyring.prototype.addAccounts; - stub(HdKeyring.prototype, 'addAccounts').callsFake(async function () { + stub(HdKeyring.prototype, 'addAccounts').callsFake(async () => { return new Promise((resolve) => { setImmediate(() => { resolve(originalAccAccounts.bind(this)()); @@ -302,7 +311,7 @@ describe('KeyringController', function () { }); }); - const keyring = await keyringController.addNewKeyring('HD Key Tree'); + const keyring = await keyringController.addNewKeyring(KeyringType.HD); const keyringAccounts = await keyring?.getAccounts(); expect(keyringAccounts).toHaveLength(1); @@ -324,7 +333,7 @@ describe('KeyringController', function () { expect(wallet.numberOfAccounts).toBe(1); const accounts = await keyring?.getAccounts(); - expect(accounts![0]).toBe(walletOneAddresses[0]); + expect(accounts?.[0]).toBe(walletOneAddresses[0]); }); it('should return undefined if keyring type is not supported.', async function () { @@ -343,12 +352,12 @@ describe('KeyringController', function () { async getAccounts() { return Promise.resolve([1, 2, 3]); }, - }, + } as unknown as ExtendedKeyring, { async getAccounts() { return Promise.resolve([4, 5, 6]); }, - }, + } as unknown as ExtendedKeyring, ]; const result = await keyringController.getAccounts(); @@ -374,9 +383,9 @@ describe('KeyringController', function () { const accountsBeforeAdding = await keyringController.getAccounts(); // Add a new keyring with one account - await keyringController.addNewKeyring('Simple Key Pair', [ - account.privateKey, - ]); + await keyringController.addNewKeyring(KeyringType.Simple, { + privateKeyArray: [account.privateKey], + }); expect(keyringController.keyrings).toHaveLength(2); // remove that account that we just added @@ -396,9 +405,9 @@ describe('KeyringController', function () { }; // Add a new keyring with one account - await keyringController.addNewKeyring('Simple Key Pair', [ - account.privateKey, - ]); + await keyringController.addNewKeyring(KeyringType.Simple, { + privateKeyArray: [account.privateKey], + }); // We should have 2 keyrings expect(keyringController.keyrings).toHaveLength(2); @@ -413,7 +422,7 @@ describe('KeyringController', function () { it('does not remove the keyring if there are accounts remaining after removing one from the keyring', async function () { // Add a new keyring with two accounts - await keyringController.addNewKeyring('HD Key Tree', { + await keyringController.addNewKeyring(KeyringType.HD, { mnemonic: walletTwoSeedWords, numberOfAccounts: 2, }); @@ -486,7 +495,7 @@ describe('KeyringController', function () { const initialAccounts = await HDKeyring?.getAccounts(); expect(initialAccounts).toHaveLength(1); - await keyringController.addNewAccount(HDKeyring!); + await keyringController.addNewAccount(HDKeyring as ExtendedKeyring); const accountsAfterAdd = await HDKeyring?.getAccounts(); expect(accountsAfterAdd).toHaveLength(2); }); @@ -500,11 +509,10 @@ describe('KeyringController', function () { const keyring = await keyringController.addNewKeyring( KeyringType.Simple, - [privateKey], + { privateKeyArray: [privateKey] }, ); - const getAppKeyAddressSpy = spy(); - keyringController.on('getAppKeyAddress', getAppKeyAddressSpy); + const getAppKeyAddressSpy = spy(keyringController, 'getAppKeyAddress'); /* eslint-disable-next-line require-atomic-updates */ keyringController.getKeyringForAccount = stub().returns( Promise.resolve(keyring), @@ -529,7 +537,9 @@ describe('KeyringController', function () { const address = '0x01560cd3bac62cc6d7e6380600d9317363400896'; const privateKey = '0xb8a9c05beeedb25df85f8d641538cbffedf67216048de9c678ee26260eb91952'; - await keyringController.addNewKeyring('Simple Key Pair', [privateKey]); + await keyringController.addNewKeyring(KeyringType.Simple, { + privateKeyArray: [privateKey], + }); const appKeyAddress = await keyringController.getAppKeyAddress( address, 'someapp.origin.io', @@ -552,11 +562,14 @@ describe('KeyringController', function () { it('throw when keyring is not hardware device', async function () { const privateKey = '0xb8a9c05beeedb25df85f8d641538cbffedf67216048de9c678ee26260eb91952'; - const keyring = await keyringController.addNewKeyring('Simple Key Pair', [ - privateKey, - ]); + const keyring = await keyringController.addNewKeyring( + KeyringType.Simple, + { privateKeyArray: [privateKey] }, + ); expect(keyringController.keyrings).toHaveLength(2); - expect(async () => keyringController.forgetKeyring(keyring)).toThrow( + expect(async () => + keyringController.forgetKeyring(keyring as ExtendedKeyring), + ).toThrow( new Error( 'KeyringController - keyring does not have method "forgetDevice", keyring type: Simple Key Pair', ), @@ -564,10 +577,10 @@ describe('KeyringController', function () { }); it('forget hardware device', async function () { - const hdKeyring = keyringController.getKeyringsByType(KeyringType.HD); + const [hdKeyring] = keyringController.getKeyringsByType(KeyringType.HD); const forgetDeviceSpy = spy(); keyringController.on('forgetDevice', forgetDeviceSpy); - await keyringController.forgetKeyring(hdKeyring); + await keyringController.forgetKeyring(hdKeyring as ExtendedKeyring); expect(forgetDeviceSpy.calledOnce).toBe(true); }); }); @@ -575,7 +588,7 @@ describe('KeyringController', function () { describe('getKeyringForAccount', function () { it('throws error when address is not provided', async function () { await expect( - keyringController.getKeyringForAccount(undefined), + keyringController.getKeyringForAccount(undefined as any), ).rejects.toThrow( new Error( 'No keyring found for the requested account. Error info: The address passed in is invalid/empty', @@ -600,7 +613,7 @@ describe('KeyringController', function () { async getAccounts() { return Promise.resolve([1, 2, 3]); }, - }, + } as unknown as ExtendedKeyring, ]; await expect( @@ -700,9 +713,9 @@ describe('KeyringController', function () { }; // Add a new keyring with one account - await keyringController.addNewKeyring('Simple Key Pair', [ - account.privateKey, - ]); + await keyringController.addNewKeyring(KeyringType.Simple, { + privateKeyArray: [account.privateKey], + }); expect(await keyringController.getAccounts()).toHaveLength(4); // remove that account that we just added From 6933b78b42b228578699b60b44f1b889d23e892e Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Mon, 27 Feb 2023 23:14:50 -0300 Subject: [PATCH 017/109] Update KeyringController --- src/KeyringController.ts | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index 63ff95d2..c462101c 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -1,12 +1,10 @@ import encryptor from '@metamask/browser-passworder'; -// @ts-ignore import HDKeyring from '@metamask/eth-hd-keyring'; import { normalize as normalizeAddress } from '@metamask/eth-sig-util'; -// @ts-ignore import SimpleKeyring from '@metamask/eth-simple-keyring'; import type { Hex, - Keyring, + Bytes, KeyringClass, Transaction, SignedTransaction, @@ -15,16 +13,9 @@ import type { // TODO: Stop using `events`, and remove the notice about this from the README // eslint-disable-next-line import/no-nodejs-modules import { EventEmitter } from 'events'; -// @ts-ignore import ObservableStore from 'obs-store'; -import { - MessageParams, - KeyringType, - State, - ExtendedKeyring, - IKeyringController, -} from './types'; +import { MessageParams, KeyringType, State, ExtendedKeyring } from './types'; const defaultKeyringBuilders = [ keyringBuilderFactory(SimpleKeyring), @@ -59,7 +50,7 @@ class KeyringController extends EventEmitter { unsupportedKeyrings: any[]; - password?: string; + password?: string | undefined; // // PUBLIC METHODS @@ -142,7 +133,7 @@ class KeyringController extends EventEmitter { */ async createNewVaultAndRestore( password: string, - seedPhrase: Uint8Array | string, + seedPhrase: Uint8Array | string | number[], ): Promise { if (typeof password !== 'string') { throw new Error('Password must be text.'); @@ -269,7 +260,12 @@ class KeyringController extends EventEmitter { type: string, opts?: Record, ): Promise { - const keyring = await this.#newKeyring(type, opts); + const keyring = await this.#newKeyring( + type, + type === KeyringType.Simple && opts?.privateKeyArray + ? opts?.privateKeyArray + : opts, + ); if (!keyring) { throw new Error('KeyringController - No keyring found'); @@ -292,7 +288,7 @@ class KeyringController extends EventEmitter { } /** - * Remove Empty Keyrings. + * Remove empty keyrings. * * Loops through the keyrings and removes the ones with empty accounts * (usually after removing the last / only account) from a keyring. @@ -495,7 +491,7 @@ class KeyringController extends EventEmitter { async signPersonalMessage( msgParams: MessageParams, opts: Record = {}, - ): Promise { + ): Promise { const address = normalizeAddress(msgParams.from) as Hex; const keyring = await this.getKeyringForAccount(address); if (!keyring.signPersonalMessage) { @@ -523,7 +519,7 @@ class KeyringController extends EventEmitter { async getEncryptionPublicKey( address: string | Hex, opts: Record = {}, - ): Promise { + ): Promise { const normalizedAddress = normalizeAddress(address) as Hex; const keyring = await this.getKeyringForAccount(address); if (!keyring.getEncryptionPublicKey) { @@ -543,7 +539,7 @@ class KeyringController extends EventEmitter { * @param msgParams - The decryption message parameters. * @returns The raw decryption result. */ - async decryptMessage(msgParams: MessageParams): Promise { + async decryptMessage(msgParams: MessageParams): Promise { const address = normalizeAddress(msgParams.from) as Hex; const keyring = await this.getKeyringForAccount(address); if (!keyring.decryptMessage) { @@ -569,7 +565,7 @@ class KeyringController extends EventEmitter { async signTypedMessage( msgParams: MessageParams, opts = { version: 'V1' }, - ): Promise { + ): Promise { const address = normalizeAddress(msgParams.from) as Hex; const keyring = await this.getKeyringForAccount(address); if (!keyring.signTypedData) { @@ -950,7 +946,7 @@ class KeyringController extends EventEmitter { return accounts.includes(hexed); }); - if (winners && winners.length > 0 && winners[0].length > 0) { + if (winners?.length && winners?.[0]?.length) { return winners[0][0]; } @@ -1022,7 +1018,7 @@ class KeyringController extends EventEmitter { * @param data - The data to restore a previously serialized keyring. * @returns The new keyring. */ - async #newKeyring(type: string, data): Promise { + async #newKeyring(type: string, data: any): Promise { const keyringBuilder = this.#getKeyringBuilderForType(type); if (!keyringBuilder) { From 3b5ea22fdb174efc7c78076893caa943e15ed4c2 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed, 1 Mar 2023 15:22:02 -0300 Subject: [PATCH 018/109] Add build command (not working properly) --- .gitignore | 3 +++ package.json | 2 ++ tsconfig.build.json | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 tsconfig.build.json diff --git a/.gitignore b/.gitignore index 83b71513..fbee401d 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,6 @@ coverage !.yarn/releases !.yarn/sdks !.yarn/versions + +# distribution +dist diff --git a/package.json b/package.json index 34e8f47a..e13729fa 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,8 @@ "dist/" ], "scripts": { + "build": "tsc --project tsconfig.build.json", + "build:docs": "typedoc", "lint": "yarn lint:eslint && yarn lint:misc --check", "lint:eslint": "eslint . --cache --ext js,ts", "lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write", diff --git a/tsconfig.build.json b/tsconfig.build.json new file mode 100644 index 00000000..5acdd7ef --- /dev/null +++ b/tsconfig.build.json @@ -0,0 +1,18 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "declaration": true, + "inlineSources": true, + "noEmit": false, + "outDir": "dist", + "rootDir": "src", + "sourceMap": true + }, + "include": ["./src/**/*.ts"], + "exclude": [ + "./src/**/*.test.ts", + "./src/**/*.test-d.ts", + "./src/__fixtures__" + ] + } + \ No newline at end of file From fdff1ec87c1d22b6a38aff0dcc78ec0ab517a79b Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed, 1 Mar 2023 15:22:19 -0300 Subject: [PATCH 019/109] Move declarations to new file --- typings/index.d.ts => declarations.d.ts | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename typings/index.d.ts => declarations.d.ts (100%) diff --git a/typings/index.d.ts b/declarations.d.ts similarity index 100% rename from typings/index.d.ts rename to declarations.d.ts From ab03e0032673c1e5c5754f478cf2f6ed85883488 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed, 1 Mar 2023 15:22:39 -0300 Subject: [PATCH 020/109] Update jest.config --- jest.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jest.config.js b/jest.config.js index d131340e..408e18b9 100644 --- a/jest.config.js +++ b/jest.config.js @@ -2,7 +2,7 @@ module.exports = { collectCoverage: true, // Ensures that we collect coverage from all source files, not just tested // ones. - collectCoverageFrom: ['./src/**/*.ts'], + collectCoverageFrom: ['./src/*.ts'], coverageReporters: ['text', 'html'], coverageThreshold: { global: { From 734c7fbc4bb46b7db3ebe0a0ff87148a05bec163 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed, 1 Mar 2023 15:23:09 -0300 Subject: [PATCH 021/109] Update TS config --- tsconfig.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 1fe94d7c..6cfcf0f9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,8 +10,10 @@ "noErrorTruncation": true, "noUncheckedIndexedAccess": true, "strict": true, - "target": "ES2017" + "target": "ES2017", + "noImplicitAny": false + }, - "exclude": ["./dist/**/*"] + "exclude": ["./dist/**/*", "node_modules"] } \ No newline at end of file From b90bb016b8f8d7e11ce8d56b62bc7727427087cf Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed, 1 Mar 2023 15:23:50 -0300 Subject: [PATCH 022/109] Fix tests --- src/KeyringController.test.ts | 7 ++++--- src/KeyringController.ts | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/KeyringController.test.ts b/src/KeyringController.test.ts index 36baf200..93195173 100644 --- a/src/KeyringController.test.ts +++ b/src/KeyringController.test.ts @@ -566,12 +566,13 @@ describe('KeyringController', () => { KeyringType.Simple, { privateKeyArray: [privateKey] }, ); + expect(keyringController.keyrings).toHaveLength(2); - expect(async () => + await expect(async () => keyringController.forgetKeyring(keyring as ExtendedKeyring), - ).toThrow( + ).rejects.toThrow( new Error( - 'KeyringController - keyring does not have method "forgetDevice", keyring type: Simple Key Pair', + 'KeyringController - keyring does not have method forgetDevice, keyring type: Simple Key Pair', ), ); }); diff --git a/src/KeyringController.ts b/src/KeyringController.ts index c462101c..cf7f8deb 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -267,6 +267,8 @@ class KeyringController extends EventEmitter { : opts, ); + console.log('In the code', { keyring }); + if (!keyring) { throw new Error('KeyringController - No keyring found'); } @@ -640,7 +642,7 @@ class KeyringController extends EventEmitter { await this.persistAllKeyrings(); } else { throw new Error( - `KeyringController - keyring does not have method "forgetDevice", keyring type: ${keyring.type}`, + `KeyringController - keyring does not have method forgetDevice, keyring type: ${keyring.type}`, ); } } From 41f4045440bd7fdfbe0c746cc2215331378e2f0e Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed, 1 Mar 2023 17:00:08 -0300 Subject: [PATCH 023/109] Remove log --- src/KeyringController.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index cf7f8deb..afee0af7 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -267,8 +267,6 @@ class KeyringController extends EventEmitter { : opts, ); - console.log('In the code', { keyring }); - if (!keyring) { throw new Error('KeyringController - No keyring found'); } From c9d7857f02f5bba36f60435185140b981c09b002 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed, 1 Mar 2023 17:00:55 -0300 Subject: [PATCH 024/109] Disable TS warning --- src/KeyringController.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index afee0af7..728b4935 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -682,6 +682,7 @@ class KeyringController extends EventEmitter { */ async #updateMemStoreKeyrings(): Promise { const keyrings = await Promise.all( + // eslint-disable-next-line @typescript-eslint/unbound-method this.keyrings.map(this.#displayForKeyring), ); return this.memStore.updateState({ keyrings }); From c95429a829df40d6d5c3f3008e608048ec3edb51 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed, 1 Mar 2023 17:01:18 -0300 Subject: [PATCH 025/109] Remove forgetKeyring --- src/KeyringController.test.ts | 44 ++++++++++++----------------------- src/KeyringController.ts | 20 ---------------- 2 files changed, 15 insertions(+), 49 deletions(-) diff --git a/src/KeyringController.test.ts b/src/KeyringController.test.ts index 93195173..9fa58f9c 100644 --- a/src/KeyringController.test.ts +++ b/src/KeyringController.test.ts @@ -311,7 +311,21 @@ describe('KeyringController', () => { }); }); - const keyring = await keyringController.addNewKeyring(KeyringType.HD); + stub(HdKeyring.prototype, 'deserialize').callsFake(async () => { + return new Promise((resolve) => { + setImmediate(() => { + resolve(); + }); + }); + }); + + stub(HdKeyring.prototype, 'getAccounts').callsFake(() => [ + 'mock account', + ]); + + const keyring = await keyringController.addNewKeyring(KeyringType.HD, { + mnemonic: 'mock mnemonic', + }); const keyringAccounts = await keyring?.getAccounts(); expect(keyringAccounts).toHaveLength(1); @@ -558,34 +572,6 @@ describe('KeyringController', () => { }); }); - describe('forgetHardwareDevice', function () { - it('throw when keyring is not hardware device', async function () { - const privateKey = - '0xb8a9c05beeedb25df85f8d641538cbffedf67216048de9c678ee26260eb91952'; - const keyring = await keyringController.addNewKeyring( - KeyringType.Simple, - { privateKeyArray: [privateKey] }, - ); - - expect(keyringController.keyrings).toHaveLength(2); - await expect(async () => - keyringController.forgetKeyring(keyring as ExtendedKeyring), - ).rejects.toThrow( - new Error( - 'KeyringController - keyring does not have method forgetDevice, keyring type: Simple Key Pair', - ), - ); - }); - - it('forget hardware device', async function () { - const [hdKeyring] = keyringController.getKeyringsByType(KeyringType.HD); - const forgetDeviceSpy = spy(); - keyringController.on('forgetDevice', forgetDeviceSpy); - await keyringController.forgetKeyring(hdKeyring as ExtendedKeyring); - expect(forgetDeviceSpy.calledOnce).toBe(true); - }); - }); - describe('getKeyringForAccount', function () { it('throws error when address is not provided', async function () { await expect( diff --git a/src/KeyringController.ts b/src/KeyringController.ts index 728b4935..ef29d3e5 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -625,26 +625,6 @@ class KeyringController extends EventEmitter { return keyring.exportAccount(address, { withAppKeyOrigin: origin }); } - /** - * Forget hardware keyring. - * - * Forget hardware and update memorized state. - * - * @param keyring - The keyring to forget. - */ - async forgetKeyring( - keyring: ExtendedKeyring & { forgetDevice?: () => void }, - ): Promise { - if (keyring.forgetDevice) { - keyring.forgetDevice(); - await this.persistAllKeyrings(); - } else { - throw new Error( - `KeyringController - keyring does not have method forgetDevice, keyring type: ${keyring.type}`, - ); - } - } - /** * Restore Keyring * From c833be621807a6b33cc978b0f7c5d69a9f80c3e6 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed, 1 Mar 2023 17:17:47 -0300 Subject: [PATCH 026/109] Change type any to Json --- src/KeyringController.ts | 22 ++++++++++++---------- src/types.ts | 5 ++--- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index ef29d3e5..2f9f266c 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -4,6 +4,7 @@ import { normalize as normalizeAddress } from '@metamask/eth-sig-util'; import SimpleKeyring from '@metamask/eth-simple-keyring'; import type { Hex, + Json, Bytes, KeyringClass, Transaction, @@ -15,7 +16,7 @@ import type { import { EventEmitter } from 'events'; import ObservableStore from 'obs-store'; -import { MessageParams, KeyringType, State, ExtendedKeyring } from './types'; +import { MessageParams, KeyringType, ExtendedKeyring } from './types'; const defaultKeyringBuilders = [ keyringBuilderFactory(SimpleKeyring), @@ -95,6 +96,7 @@ class KeyringController extends EventEmitter { */ fullUpdate() { this.emit('update', this.memStore.getState()); + console.log(this.memStore.getState()); return this.memStore.getState(); } @@ -110,7 +112,7 @@ class KeyringController extends EventEmitter { * @param password - The password to encrypt the vault with. * @returns A promise that resolves to the state. */ - async createNewVaultAndKeychain(password: string): Promise { + async createNewVaultAndKeychain(password: string): Promise { this.password = password; await this.#createFirstKeyTree(); @@ -134,7 +136,7 @@ class KeyringController extends EventEmitter { async createNewVaultAndRestore( password: string, seedPhrase: Uint8Array | string | number[], - ): Promise { + ): Promise { if (typeof password !== 'string') { throw new Error('Password must be text.'); } @@ -166,7 +168,7 @@ class KeyringController extends EventEmitter { * @fires KeyringController#lock * @returns A promise that resolves to the state. */ - async setLocked(): Promise { + async setLocked(): Promise { delete this.password; // set locked @@ -196,7 +198,7 @@ class KeyringController extends EventEmitter { * @param password - The keyring controller password. * @returns A promise that resolves to the state. */ - async submitPassword(password: string): Promise { + async submitPassword(password: string): Promise { this.keyrings = await this.unlockKeyrings(password); this.#setUnlocked(); @@ -217,7 +219,7 @@ class KeyringController extends EventEmitter { async submitEncryptionKey( encryptionKey: string, encryptionSalt: string, - ): Promise { + ): Promise { this.keyrings = await this.unlockKeyrings( undefined, encryptionKey, @@ -360,7 +362,7 @@ class KeyringController extends EventEmitter { * @param selectedKeyring - The currently selected keyring. * @returns A Promise that resolves to the state. */ - async addNewAccount(selectedKeyring: ExtendedKeyring): Promise { + async addNewAccount(selectedKeyring: ExtendedKeyring): Promise { const accounts = await selectedKeyring.addAccounts(1); accounts.forEach((hexAccount: string) => { this.emit('newAccount', hexAccount); @@ -401,7 +403,7 @@ class KeyringController extends EventEmitter { * @param address - The address of the account to remove. * @returns A promise that resolves if the operation was successful. */ - async removeAccount(address: Hex): Promise { + async removeAccount(address: Hex): Promise { const keyring = await this.getKeyringForAccount(address); // Not all the keyrings support this, so we have to check @@ -660,7 +662,7 @@ class KeyringController extends EventEmitter { * * Updates the in-memory keyrings, without persisting. */ - async #updateMemStoreKeyrings(): Promise { + async #updateMemStoreKeyrings(): Promise { const keyrings = await Promise.all( // eslint-disable-next-line @typescript-eslint/unbound-method this.keyrings.map(this.#displayForKeyring), @@ -1026,7 +1028,7 @@ class KeyringController extends EventEmitter { * @param Keyring - The Keyring class for the builder. * @returns A builder function for the given Keyring. */ -function keyringBuilderFactory(Keyring: KeyringClass) { +function keyringBuilderFactory(Keyring: KeyringClass) { const builder = () => new Keyring(); builder.type = Keyring.type; diff --git a/src/types.ts b/src/types.ts index 9cbe6ad9..2356f8e1 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,4 +1,4 @@ -import type { Hex, Eip1024EncryptedData, Keyring } from '@metamask/utils'; +import type { Hex, Json, Keyring, Eip1024EncryptedData } from '@metamask/utils'; export type IKeyringController = any; @@ -12,7 +12,6 @@ export enum KeyringType { Simple = 'Simple Key Pair', } -export type State = any; -export type ExtendedKeyring = Keyring & { +export type ExtendedKeyring = Keyring & { generateRandomMnemonic: () => string; }; From e7b8a5f47ef29367fb973b5c2ceda1fd5c62881c Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed, 1 Mar 2023 17:19:34 -0300 Subject: [PATCH 027/109] Prettier --- .yarnrc.yml | 2 +- tsconfig.build.json | 33 ++++++++++++++++----------------- tsconfig.json | 34 ++++++++++++++++------------------ 3 files changed, 33 insertions(+), 36 deletions(-) diff --git a/.yarnrc.yml b/.yarnrc.yml index 8668abfb..bffaec46 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -10,6 +10,6 @@ nodeLinker: node-modules plugins: - path: .yarn/plugins/@yarnpkg/plugin-allow-scripts.cjs - spec: "https://raw.githubusercontent.com/LavaMoat/LavaMoat/main/packages/yarn-plugin-allow-scripts/bundles/@yarnpkg/plugin-allow-scripts.js" + spec: 'https://raw.githubusercontent.com/LavaMoat/LavaMoat/main/packages/yarn-plugin-allow-scripts/bundles/@yarnpkg/plugin-allow-scripts.js' yarnPath: .yarn/releases/yarn-3.2.4.cjs diff --git a/tsconfig.build.json b/tsconfig.build.json index 5acdd7ef..67ab8057 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -1,18 +1,17 @@ { - "extends": "./tsconfig.json", - "compilerOptions": { - "declaration": true, - "inlineSources": true, - "noEmit": false, - "outDir": "dist", - "rootDir": "src", - "sourceMap": true - }, - "include": ["./src/**/*.ts"], - "exclude": [ - "./src/**/*.test.ts", - "./src/**/*.test-d.ts", - "./src/__fixtures__" - ] - } - \ No newline at end of file + "extends": "./tsconfig.json", + "compilerOptions": { + "declaration": true, + "inlineSources": true, + "noEmit": false, + "outDir": "dist", + "rootDir": "src", + "sourceMap": true + }, + "include": ["./src/**/*.ts"], + "exclude": [ + "./src/**/*.test.ts", + "./src/**/*.test-d.ts", + "./src/__fixtures__" + ] +} diff --git a/tsconfig.json b/tsconfig.json index 6cfcf0f9..ab813717 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,19 +1,17 @@ { - "compilerOptions": { - "esModuleInterop": true, - "exactOptionalPropertyTypes": true, - "forceConsistentCasingInFileNames": true, - "lib": ["ES2020", "dom"], - "module": "CommonJS", - "moduleResolution": "node", - "noEmit": true, - "noErrorTruncation": true, - "noUncheckedIndexedAccess": true, - "strict": true, - "target": "ES2017", - "noImplicitAny": false - - }, - "exclude": ["./dist/**/*", "node_modules"] - } - \ No newline at end of file + "compilerOptions": { + "esModuleInterop": true, + "exactOptionalPropertyTypes": true, + "forceConsistentCasingInFileNames": true, + "lib": ["ES2020", "dom"], + "module": "CommonJS", + "moduleResolution": "node", + "noEmit": true, + "noErrorTruncation": true, + "noUncheckedIndexedAccess": true, + "strict": true, + "target": "ES2017", + "noImplicitAny": false + }, + "exclude": ["./dist/**/*", "node_modules"] +} From 473c047dbc232a7ab69fbca7fa8638542abdfa9f Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed, 1 Mar 2023 17:25:52 -0300 Subject: [PATCH 028/109] Remove log --- src/KeyringController.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index 2f9f266c..34f082b2 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -96,7 +96,6 @@ class KeyringController extends EventEmitter { */ fullUpdate() { this.emit('update', this.memStore.getState()); - console.log(this.memStore.getState()); return this.memStore.getState(); } From 258c3492f68f3148b962fd3e4db13491e29d9a78 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed, 1 Mar 2023 17:26:26 -0300 Subject: [PATCH 029/109] Typecast serialize result to any --- src/KeyringController.test.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/KeyringController.test.ts b/src/KeyringController.test.ts index 9fa58f9c..f340dfa8 100644 --- a/src/KeyringController.test.ts +++ b/src/KeyringController.test.ts @@ -1,6 +1,6 @@ import HdKeyring from '@metamask/eth-hd-keyring'; import { normalize as normalizeAddress } from '@metamask/eth-sig-util'; -import type { Hex, KeyringClass } from '@metamask/utils'; +import type { Hex, Json, KeyringClass } from '@metamask/utils'; import { strict as assert } from 'assert'; import Wallet from 'ethereumjs-wallet'; import { restore, spy, stub, assert as sinonAssert } from 'sinon'; @@ -343,8 +343,9 @@ describe('KeyringController', () => { }; const keyring = await keyringController.restoreKeyring(mockSerialized); - const wallet = await keyring?.serialize(); - expect(wallet.numberOfAccounts).toBe(1); + // eslint-disable-next-line no-unsafe-optional-chaining + const { numberOfAccounts } = (await keyring?.serialize()) as any; + expect(numberOfAccounts).toBe(1); const accounts = await keyring?.getAccounts(); expect(accounts?.[0]).toBe(walletOneAddresses[0]); @@ -460,8 +461,8 @@ describe('KeyringController', () => { expect(keyrings).toHaveLength(1); await Promise.all( keyrings.map(async (keyring) => { - const wallet = await keyring.serialize(); - expect(wallet.numberOfAccounts).toBe(1); + const { numberOfAccounts } = (await keyring.serialize()) as any; + expect(numberOfAccounts).toBe(1); }), ); }); From 6fa1e73e57fc48259998e0b1e3424add34df965a Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed, 1 Mar 2023 17:55:06 -0300 Subject: [PATCH 030/109] Remove Json --- src/KeyringController.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/KeyringController.test.ts b/src/KeyringController.test.ts index f340dfa8..05cc99fd 100644 --- a/src/KeyringController.test.ts +++ b/src/KeyringController.test.ts @@ -1,6 +1,6 @@ import HdKeyring from '@metamask/eth-hd-keyring'; import { normalize as normalizeAddress } from '@metamask/eth-sig-util'; -import type { Hex, Json, KeyringClass } from '@metamask/utils'; +import type { Hex, KeyringClass } from '@metamask/utils'; import { strict as assert } from 'assert'; import Wallet from 'ethereumjs-wallet'; import { restore, spy, stub, assert as sinonAssert } from 'sinon'; From a7905a794d75106d4992d7b40b0cf192dff6be5e Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed, 1 Mar 2023 18:00:56 -0300 Subject: [PATCH 031/109] Rename privateKeyArray to privateKeys --- src/KeyringController.test.ts | 12 ++++++------ src/KeyringController.ts | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/KeyringController.test.ts b/src/KeyringController.test.ts index 05cc99fd..bd8f9fcf 100644 --- a/src/KeyringController.test.ts +++ b/src/KeyringController.test.ts @@ -248,7 +248,7 @@ describe('KeyringController', () => { const previousAccounts = await keyringController.getAccounts(); const keyring = await keyringController.addNewKeyring( KeyringType.Simple, - { privateKeyArray: [privateKey] }, + { privateKeys: [privateKey] }, ); const keyringAccounts = await keyring?.getAccounts(); @@ -399,7 +399,7 @@ describe('KeyringController', () => { // Add a new keyring with one account await keyringController.addNewKeyring(KeyringType.Simple, { - privateKeyArray: [account.privateKey], + privateKeys: [account.privateKey], }); expect(keyringController.keyrings).toHaveLength(2); @@ -421,7 +421,7 @@ describe('KeyringController', () => { // Add a new keyring with one account await keyringController.addNewKeyring(KeyringType.Simple, { - privateKeyArray: [account.privateKey], + privateKeys: [account.privateKey], }); // We should have 2 keyrings @@ -524,7 +524,7 @@ describe('KeyringController', () => { const keyring = await keyringController.addNewKeyring( KeyringType.Simple, - { privateKeyArray: [privateKey] }, + { privateKeys: [privateKey] }, ); const getAppKeyAddressSpy = spy(keyringController, 'getAppKeyAddress'); @@ -553,7 +553,7 @@ describe('KeyringController', () => { const privateKey = '0xb8a9c05beeedb25df85f8d641538cbffedf67216048de9c678ee26260eb91952'; await keyringController.addNewKeyring(KeyringType.Simple, { - privateKeyArray: [privateKey], + privateKeys: [privateKey], }); const appKeyAddress = await keyringController.getAppKeyAddress( address, @@ -702,7 +702,7 @@ describe('KeyringController', () => { // Add a new keyring with one account await keyringController.addNewKeyring(KeyringType.Simple, { - privateKeyArray: [account.privateKey], + privateKeys: [account.privateKey], }); expect(await keyringController.getAccounts()).toHaveLength(4); diff --git a/src/KeyringController.ts b/src/KeyringController.ts index 34f082b2..d9fa9c76 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -263,8 +263,8 @@ class KeyringController extends EventEmitter { ): Promise { const keyring = await this.#newKeyring( type, - type === KeyringType.Simple && opts?.privateKeyArray - ? opts?.privateKeyArray + type === KeyringType.Simple && opts?.privateKeys + ? opts?.privateKeys : opts, ); From 37f0d372c22b5689ef757ee9e5a8285128605f41 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed, 1 Mar 2023 18:21:09 -0300 Subject: [PATCH 032/109] Update mocks dir structure --- src/KeyringController.test.ts | 3 +-- src/mocks/{mock-encryptor.ts => encryptor.mock.ts} | 0 src/mocks/index.ts | 4 ++++ src/mocks/{mock-keyring.ts => keyring.mock.ts} | 0 4 files changed, 5 insertions(+), 2 deletions(-) rename src/mocks/{mock-encryptor.ts => encryptor.mock.ts} (100%) create mode 100644 src/mocks/index.ts rename src/mocks/{mock-keyring.ts => keyring.mock.ts} (100%) diff --git a/src/KeyringController.test.ts b/src/KeyringController.test.ts index bd8f9fcf..0601e44e 100644 --- a/src/KeyringController.test.ts +++ b/src/KeyringController.test.ts @@ -6,8 +6,7 @@ import Wallet from 'ethereumjs-wallet'; import { restore, spy, stub, assert as sinonAssert } from 'sinon'; import { KeyringController, keyringBuilderFactory } from '.'; -import mockEncryptor from './mocks/mock-encryptor'; -import KeyringMockWithInit from './mocks/mock-keyring'; +import { mockEncryptor, KeyringMockWithInit } from './mocks'; import { ExtendedKeyring, KeyringType } from './types'; const password = 'password123'; diff --git a/src/mocks/mock-encryptor.ts b/src/mocks/encryptor.mock.ts similarity index 100% rename from src/mocks/mock-encryptor.ts rename to src/mocks/encryptor.mock.ts diff --git a/src/mocks/index.ts b/src/mocks/index.ts new file mode 100644 index 00000000..1c2bd455 --- /dev/null +++ b/src/mocks/index.ts @@ -0,0 +1,4 @@ +import mockEncryptor from './encryptor.mock'; +import KeyringMockWithInit from './keyring.mock'; + +export { mockEncryptor, KeyringMockWithInit }; diff --git a/src/mocks/mock-keyring.ts b/src/mocks/keyring.mock.ts similarity index 100% rename from src/mocks/mock-keyring.ts rename to src/mocks/keyring.mock.ts From 1ba064efdbab9bcf490f2d0b4cef478d512e5dae Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed, 1 Mar 2023 18:21:46 -0300 Subject: [PATCH 033/109] Install depcheck and rv @metamask/eslint-config-commonjs --- .depcheckrc.json | 10 ++ package.json | 5 +- yarn.lock | 448 +++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 430 insertions(+), 33 deletions(-) create mode 100644 .depcheckrc.json diff --git a/.depcheckrc.json b/.depcheckrc.json new file mode 100644 index 00000000..3897120c --- /dev/null +++ b/.depcheckrc.json @@ -0,0 +1,10 @@ +{ + "ignores": [ + "@lavamoat/allow-scripts", + "@metamask/auto-changelog", + "@types/*", + "prettier-plugin-packagejson", + "ts-node", + "typedoc" + ] +} diff --git a/package.json b/package.json index e13729fa..d94476a0 100644 --- a/package.json +++ b/package.json @@ -27,10 +27,11 @@ "build": "tsc --project tsconfig.build.json", "build:docs": "typedoc", "lint": "yarn lint:eslint && yarn lint:misc --check", + "lint:dependencies": "depcheck", "lint:eslint": "eslint . --cache --ext js,ts", "lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write", "lint:misc": "prettier '**/*.json' '**/*.md' '!CHANGELOG.md' '**/*.yml' '!.yarnrc.yml' --ignore-path .gitignore --no-error-on-unmatched-pattern", - "test": "jest" + "test": "jest && jest-it-up" }, "dependencies": { "@metamask/browser-passworder": "^4.0.2", @@ -44,7 +45,6 @@ "@lavamoat/allow-scripts": "^2.1.0", "@metamask/auto-changelog": "^3.0.0", "@metamask/eslint-config": "^11.1.0", - "@metamask/eslint-config-commonjs": "^11.1.0", "@metamask/eslint-config-jest": "^11.1.0", "@metamask/eslint-config-nodejs": "^11.1.0", "@metamask/eslint-config-typescript": "^11.1.0", @@ -53,6 +53,7 @@ "@types/sinon": "^10.0.13", "@typescript-eslint/eslint-plugin": "^5.53.0", "@typescript-eslint/parser": "^5.53.0", + "depcheck": "^1.4.3", "eslint": "^8.29.0", "eslint-config-prettier": "^8.5.0", "eslint-plugin-import": "^2.26.0", diff --git a/yarn.lock b/yarn.lock index 3f9608d6..b17a0c8f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -276,6 +276,15 @@ __metadata: languageName: node linkType: hard +"@babel/parser@npm:7.16.4": + version: 7.16.4 + resolution: "@babel/parser@npm:7.16.4" + bin: + parser: ./bin/babel-parser.js + checksum: ce0a8f92f440f2a12bc932f070a7b60c5133bf8a63f461841f9e39af0194f573707959d606c6fad1a2fd496a45148553afd9b74d3b8dd36cdb7861598d1f3e36 + languageName: node + linkType: hard + "@babel/parser@npm:^7.1.0, @babel/parser@npm:^7.14.5, @babel/parser@npm:^7.14.7": version: 7.14.7 resolution: "@babel/parser@npm:7.14.7" @@ -285,7 +294,7 @@ __metadata: languageName: node linkType: hard -"@babel/parser@npm:^7.20.7, @babel/parser@npm:^7.21.0, @babel/parser@npm:^7.21.2": +"@babel/parser@npm:^7.16.4, @babel/parser@npm:^7.20.7, @babel/parser@npm:^7.21.0, @babel/parser@npm:^7.21.2": version: 7.21.2 resolution: "@babel/parser@npm:7.21.2" bin: @@ -470,7 +479,7 @@ __metadata: languageName: node linkType: hard -"@babel/traverse@npm:^7.21.0, @babel/traverse@npm:^7.21.2": +"@babel/traverse@npm:^7.12.5, @babel/traverse@npm:^7.21.0, @babel/traverse@npm:^7.21.2": version: 7.21.2 resolution: "@babel/traverse@npm:7.21.2" dependencies: @@ -980,20 +989,6 @@ __metadata: languageName: node linkType: hard -"@metamask/eslint-config-commonjs@npm:^11.1.0": - version: 11.1.0 - resolution: "@metamask/eslint-config-commonjs@npm:11.1.0" - peerDependencies: - eslint: ^8.27.0 - eslint-config-prettier: ^8.5.0 - eslint-plugin-import: ^2.26.0 - eslint-plugin-jsdoc: ^39.6.2 - eslint-plugin-prettier: ^4.2.1 - prettier: ^2.7.1 - checksum: 287e4f0126ec63c266104395f937715241f320c4e0c2f4621d6c38312650ad66eaeb71027e7413e088eb6b7f4a1fd00d31a6eedbf3ea9cc35d817d734bfe1412 - languageName: node - linkType: hard - "@metamask/eslint-config-jest@npm:^11.1.0": version: 11.1.0 resolution: "@metamask/eslint-config-jest@npm:11.1.0" @@ -1063,7 +1058,6 @@ __metadata: "@metamask/auto-changelog": ^3.0.0 "@metamask/browser-passworder": ^4.0.2 "@metamask/eslint-config": ^11.1.0 - "@metamask/eslint-config-commonjs": ^11.1.0 "@metamask/eslint-config-jest": ^11.1.0 "@metamask/eslint-config-nodejs": ^11.1.0 "@metamask/eslint-config-typescript": ^11.1.0 @@ -1076,6 +1070,7 @@ __metadata: "@types/sinon": ^10.0.13 "@typescript-eslint/eslint-plugin": ^5.53.0 "@typescript-eslint/parser": ^5.53.0 + depcheck: ^1.4.3 eslint: ^8.29.0 eslint-config-prettier: ^8.5.0 eslint-plugin-import: ^2.26.0 @@ -1499,6 +1494,13 @@ __metadata: languageName: node linkType: hard +"@types/minimatch@npm:^3.0.3": + version: 3.0.5 + resolution: "@types/minimatch@npm:3.0.5" + checksum: c41d136f67231c3131cf1d4ca0b06687f4a322918a3a5adddc87ce90ed9dbd175a3610adee36b106ae68c0b92c637c35e02b58c8a56c424f71d30993ea220b92 + languageName: node + linkType: hard + "@types/mocha@npm:^5.0.0": version: 5.2.7 resolution: "@types/mocha@npm:5.2.7" @@ -1520,6 +1522,13 @@ __metadata: languageName: node linkType: hard +"@types/parse-json@npm:^4.0.0": + version: 4.0.0 + resolution: "@types/parse-json@npm:4.0.0" + checksum: fd6bce2b674b6efc3db4c7c3d336bd70c90838e8439de639b909ce22f3720d21344f52427f1d9e57b265fcb7f6c018699b99e5e0c208a1a4823014269a6bf35b + languageName: node + linkType: hard + "@types/pbkdf2@npm:^3.0.0": version: 3.1.0 resolution: "@types/pbkdf2@npm:3.1.0" @@ -1775,6 +1784,76 @@ __metadata: languageName: node linkType: hard +"@vue/compiler-core@npm:3.2.47": + version: 3.2.47 + resolution: "@vue/compiler-core@npm:3.2.47" + dependencies: + "@babel/parser": ^7.16.4 + "@vue/shared": 3.2.47 + estree-walker: ^2.0.2 + source-map: ^0.6.1 + checksum: 9ccc2a0b897b59eea56ca4f92ed29c14cd1184f68532edf5fb0fe5cb2833bcf9e4836029effb6eb9a7c872e9e0350fafdcd96ff00c0b5b79e17ded0c068b5f84 + languageName: node + linkType: hard + +"@vue/compiler-dom@npm:3.2.47": + version: 3.2.47 + resolution: "@vue/compiler-dom@npm:3.2.47" + dependencies: + "@vue/compiler-core": 3.2.47 + "@vue/shared": 3.2.47 + checksum: 1eced735f865e6df0c2d7fa041f9f27996ff4c0d4baf5fad0f67e65e623215f4394c49bba337b78427c6e71f2cc2db12b19ec6b865b4c057c0a15ccedeb20752 + languageName: node + linkType: hard + +"@vue/compiler-sfc@npm:^3.0.5": + version: 3.2.47 + resolution: "@vue/compiler-sfc@npm:3.2.47" + dependencies: + "@babel/parser": ^7.16.4 + "@vue/compiler-core": 3.2.47 + "@vue/compiler-dom": 3.2.47 + "@vue/compiler-ssr": 3.2.47 + "@vue/reactivity-transform": 3.2.47 + "@vue/shared": 3.2.47 + estree-walker: ^2.0.2 + magic-string: ^0.25.7 + postcss: ^8.1.10 + source-map: ^0.6.1 + checksum: 4588a513310b9319a00adfdbe789cfe60d5ec19c51e8f2098152b9e81f54be170e16c40463f6b5e4c7ab79796fc31e2de93587a9dd1af136023fa03712b62e68 + languageName: node + linkType: hard + +"@vue/compiler-ssr@npm:3.2.47": + version: 3.2.47 + resolution: "@vue/compiler-ssr@npm:3.2.47" + dependencies: + "@vue/compiler-dom": 3.2.47 + "@vue/shared": 3.2.47 + checksum: 91bc6e46744d5405713c08d8e576971aa6d13a0cde84ec592d3221bf6ee228e49ce12233af8c18dc39723455b420df2951f3616ceb99758eb432485475fa7bc2 + languageName: node + linkType: hard + +"@vue/reactivity-transform@npm:3.2.47": + version: 3.2.47 + resolution: "@vue/reactivity-transform@npm:3.2.47" + dependencies: + "@babel/parser": ^7.16.4 + "@vue/compiler-core": 3.2.47 + "@vue/shared": 3.2.47 + estree-walker: ^2.0.2 + magic-string: ^0.25.7 + checksum: 6fe54374aa8c080c0c421e18134e84e723e2d3e53178cf084c1cd75bc8b1ffaaf07756801f3aa4e1e7ad1ba76356c28bbab4bc1b676159db8fc10f10f2cbd405 + languageName: node + linkType: hard + +"@vue/shared@npm:3.2.47": + version: 3.2.47 + resolution: "@vue/shared@npm:3.2.47" + checksum: 0aa711dc9160fa0e476e6e94eea4e019398adf2211352d0e4a672cfb6b65b104bbd5d234807d1c091107bdc0f5d818d0f12378987eb7861d39be3aa9f6cd6e3e + languageName: node + linkType: hard + "abbrev@npm:1, abbrev@npm:^1.0.0": version: 1.1.1 resolution: "abbrev@npm:1.1.1" @@ -1930,6 +2009,16 @@ __metadata: languageName: node linkType: hard +"anymatch@npm:~3.1.2": + version: 3.1.3 + resolution: "anymatch@npm:3.1.3" + dependencies: + normalize-path: ^3.0.0 + picomatch: ^2.0.4 + checksum: 3e044fd6d1d26545f235a9fe4d7a534e2029d8e59fa7fd9f2a6eb21230f6b5380ea1eaf55136e60cbf8e613544b3b766e7a6fa2102e2a3a117505466e3025dc2 + languageName: node + linkType: hard + "aproba@npm:^1.0.3": version: 1.2.0 resolution: "aproba@npm:1.2.0" @@ -1987,6 +2076,13 @@ __metadata: languageName: node linkType: hard +"array-differ@npm:^3.0.0": + version: 3.0.0 + resolution: "array-differ@npm:3.0.0" + checksum: 117edd9df5c1530bd116c6e8eea891d4bd02850fd89b1b36e532b6540e47ca620a373b81feca1c62d1395d9ae601516ba538abe5e8172d41091da2c546b05fb7 + languageName: node + linkType: hard + "array-includes@npm:^3.1.4": version: 3.1.6 resolution: "array-includes@npm:3.1.6" @@ -2019,6 +2115,13 @@ __metadata: languageName: node linkType: hard +"arrify@npm:^2.0.1": + version: 2.0.1 + resolution: "arrify@npm:2.0.1" + checksum: 067c4c1afd182806a82e4c1cb8acee16ab8b5284fbca1ce29408e6e91281c36bb5b612f6ddfbd40a0f7a7e0c75bf2696eb94c027f6e328d6e9c52465c98e4209 + languageName: node + linkType: hard + "asn1@npm:~0.2.3": version: 0.2.4 resolution: "asn1@npm:0.2.4" @@ -2164,6 +2267,13 @@ __metadata: languageName: node linkType: hard +"binary-extensions@npm:^2.0.0": + version: 2.2.0 + resolution: "binary-extensions@npm:2.2.0" + checksum: ccd267956c58d2315f5d3ea6757cf09863c5fc703e50fbeb13a7dc849b812ef76e3cf9ca8f35a0c48498776a7478d7b4a0418e1e2b8cb9cb9731f2922aaad7f8 + languageName: node + linkType: hard + "blakejs@npm:^1.1.0": version: 1.1.0 resolution: "blakejs@npm:1.1.0" @@ -2204,7 +2314,7 @@ __metadata: languageName: node linkType: hard -"braces@npm:^3.0.1": +"braces@npm:^3.0.1, braces@npm:~3.0.2": version: 3.0.2 resolution: "braces@npm:3.0.2" dependencies: @@ -2399,6 +2509,25 @@ __metadata: languageName: node linkType: hard +"chokidar@npm:>=3.0.0 <4.0.0": + version: 3.5.3 + resolution: "chokidar@npm:3.5.3" + dependencies: + anymatch: ~3.1.2 + braces: ~3.0.2 + fsevents: ~2.3.2 + glob-parent: ~5.1.2 + is-binary-path: ~2.1.0 + is-glob: ~4.0.1 + normalize-path: ~3.0.0 + readdirp: ~3.6.0 + dependenciesMeta: + fsevents: + optional: true + checksum: b49fcde40176ba007ff361b198a2d35df60d9bb2a5aab228279eb810feae9294a6b4649ab15981304447afe1e6ffbf4788ad5db77235dc770ab777c6e771980c + languageName: node + linkType: hard + "chownr@npm:^2.0.0": version: 2.0.0 resolution: "chownr@npm:2.0.0" @@ -2574,6 +2703,19 @@ __metadata: languageName: node linkType: hard +"cosmiconfig@npm:^7.0.0": + version: 7.1.0 + resolution: "cosmiconfig@npm:7.1.0" + dependencies: + "@types/parse-json": ^4.0.0 + import-fresh: ^3.2.1 + parse-json: ^5.0.0 + path-type: ^4.0.0 + yaml: ^1.10.0 + checksum: c53bf7befc1591b2651a22414a5e786cd5f2eeaa87f3678a3d49d6069835a9d8d1aef223728e98aa8fec9a95bf831120d245096db12abe019fecb51f5696c96f + languageName: node + linkType: hard + "create-hash@npm:^1.1.0, create-hash@npm:^1.1.2, create-hash@npm:^1.2.0": version: 1.2.0 resolution: "create-hash@npm:1.2.0" @@ -2628,7 +2770,7 @@ __metadata: languageName: node linkType: hard -"debug@npm:4, debug@npm:^4.1.0, debug@npm:^4.1.1, debug@npm:^4.3.2, debug@npm:^4.3.3, debug@npm:^4.3.4": +"debug@npm:4, debug@npm:^4.1.0, debug@npm:^4.1.1, debug@npm:^4.2.0, debug@npm:^4.3.2, debug@npm:^4.3.3, debug@npm:^4.3.4": version: 4.3.4 resolution: "debug@npm:4.3.4" dependencies: @@ -2703,6 +2845,39 @@ __metadata: languageName: node linkType: hard +"depcheck@npm:^1.4.3": + version: 1.4.3 + resolution: "depcheck@npm:1.4.3" + dependencies: + "@babel/parser": 7.16.4 + "@babel/traverse": ^7.12.5 + "@vue/compiler-sfc": ^3.0.5 + camelcase: ^6.2.0 + cosmiconfig: ^7.0.0 + debug: ^4.2.0 + deps-regex: ^0.1.4 + ignore: ^5.1.8 + is-core-module: ^2.4.0 + js-yaml: ^3.14.0 + json5: ^2.1.3 + lodash: ^4.17.20 + minimatch: ^3.0.4 + multimatch: ^5.0.0 + please-upgrade-node: ^3.2.0 + query-ast: ^1.0.3 + readdirp: ^3.5.0 + require-package-name: ^2.0.1 + resolve: ^1.18.1 + sass: ^1.29.0 + scss-parser: ^1.0.4 + semver: ^7.3.2 + yargs: ^16.1.0 + bin: + depcheck: bin/depcheck.js + checksum: 122631cab325707a55e26a8b530eb72c893bd481194100b1853ac2bc944b61320eb0e1ea0ff7e71724009cdfbd4057381d7bf868b9c5aad0c4207ac0bdca5e48 + languageName: node + linkType: hard + "depd@npm:^1.1.2": version: 1.1.2 resolution: "depd@npm:1.1.2" @@ -2710,6 +2885,13 @@ __metadata: languageName: node linkType: hard +"deps-regex@npm:^0.1.4": + version: 0.1.4 + resolution: "deps-regex@npm:0.1.4" + checksum: 70c5e7fa887513bb8c55165c53e4ae511786ed7bf3d98d4dbef97a8879a808a5bc549034b1dfcdc7565c153e2fc2f7d8ee766eeb88156e78b2447dd75c1516e9 + languageName: node + linkType: hard + "detect-indent@npm:^6.0.0": version: 6.1.0 resolution: "detect-indent@npm:6.1.0" @@ -3227,6 +3409,13 @@ __metadata: languageName: node linkType: hard +"estree-walker@npm:^2.0.2": + version: 2.0.2 + resolution: "estree-walker@npm:2.0.2" + checksum: 6151e6f9828abe2259e57f5fd3761335bb0d2ebd76dc1a01048ccee22fabcfef3c0859300f6d83ff0d1927849368775ec5a6d265dde2f6de5a1be1721cd94efc + languageName: node + linkType: hard + "esutils@npm:^2.0.2": version: 2.0.3 resolution: "esutils@npm:2.0.3" @@ -3533,7 +3722,7 @@ __metadata: languageName: node linkType: hard -"fsevents@npm:^2.3.2": +"fsevents@npm:^2.3.2, fsevents@npm:~2.3.2": version: 2.3.2 resolution: "fsevents@npm:2.3.2" dependencies: @@ -3543,7 +3732,7 @@ __metadata: languageName: node linkType: hard -"fsevents@patch:fsevents@^2.3.2#~builtin": +"fsevents@patch:fsevents@^2.3.2#~builtin, fsevents@patch:fsevents@~2.3.2#~builtin": version: 2.3.2 resolution: "fsevents@patch:fsevents@npm%3A2.3.2#~builtin::version=2.3.2&hash=18f3a7" dependencies: @@ -3675,7 +3864,7 @@ __metadata: languageName: node linkType: hard -"glob-parent@npm:^5.1.2": +"glob-parent@npm:^5.1.2, glob-parent@npm:~5.1.2": version: 5.1.2 resolution: "glob-parent@npm:5.1.2" dependencies: @@ -3977,6 +4166,20 @@ __metadata: languageName: node linkType: hard +"ignore@npm:^5.1.8": + version: 5.2.4 + resolution: "ignore@npm:5.2.4" + checksum: 3d4c309c6006e2621659311783eaea7ebcd41fe4ca1d78c91c473157ad6666a57a2df790fe0d07a12300d9aac2888204d7be8d59f9aaf665b1c7fcdb432517ef + languageName: node + linkType: hard + +"immutable@npm:^4.0.0": + version: 4.2.4 + resolution: "immutable@npm:4.2.4" + checksum: 3be84eded37b05e65cad57bfba630bc1bf170c498b7472144bc02d2650cc9baef79daf03574a9c2e41d195ebb55a1c12c9b312f41ee324b653927b24ad8bcaa7 + languageName: node + linkType: hard + "import-fresh@npm:^3.0.0, import-fresh@npm:^3.2.1": version: 3.3.0 resolution: "import-fresh@npm:3.3.0" @@ -4048,6 +4251,15 @@ __metadata: languageName: node linkType: hard +"invariant@npm:2.2.4": + version: 2.2.4 + resolution: "invariant@npm:2.2.4" + dependencies: + loose-envify: ^1.0.0 + checksum: cc3182d793aad82a8d1f0af697b462939cb46066ec48bbf1707c150ad5fad6406137e91a262022c269702e01621f35ef60269f6c0d7fd178487959809acdfb14 + languageName: node + linkType: hard + "ip@npm:^2.0.0": version: 2.0.0 resolution: "ip@npm:2.0.0" @@ -4069,6 +4281,15 @@ __metadata: languageName: node linkType: hard +"is-binary-path@npm:~2.1.0": + version: 2.1.0 + resolution: "is-binary-path@npm:2.1.0" + dependencies: + binary-extensions: ^2.0.0 + checksum: 84192eb88cff70d320426f35ecd63c3d6d495da9d805b19bc65b518984b7c0760280e57dbf119b7e9be6b161784a5a673ab2c6abe83abb5198a432232ad5b35c + languageName: node + linkType: hard + "is-boolean-object@npm:^1.1.0": version: 1.1.1 resolution: "is-boolean-object@npm:1.1.1" @@ -4085,7 +4306,7 @@ __metadata: languageName: node linkType: hard -"is-core-module@npm:^2.8.1, is-core-module@npm:^2.9.0": +"is-core-module@npm:^2.4.0, is-core-module@npm:^2.8.1, is-core-module@npm:^2.9.0": version: 2.11.0 resolution: "is-core-module@npm:2.11.0" dependencies: @@ -4131,7 +4352,7 @@ __metadata: languageName: node linkType: hard -"is-glob@npm:^4.0.0, is-glob@npm:^4.0.1, is-glob@npm:^4.0.3": +"is-glob@npm:^4.0.0, is-glob@npm:^4.0.1, is-glob@npm:^4.0.3, is-glob@npm:~4.0.1": version: 4.0.3 resolution: "is-glob@npm:4.0.3" dependencies: @@ -4785,7 +5006,7 @@ __metadata: languageName: node linkType: hard -"js-tokens@npm:^4.0.0": +"js-tokens@npm:^3.0.0 || ^4.0.0, js-tokens@npm:^4.0.0": version: 4.0.0 resolution: "js-tokens@npm:4.0.0" checksum: 8a95213a5a77deb6cbe94d86340e8d9ace2b93bc367790b260101d2f36a2eaf4e4e22d9fa9cf459b38af3a32fb4190e638024cf82ec95ef708680e405ea7cc78 @@ -4804,6 +5025,18 @@ __metadata: languageName: node linkType: hard +"js-yaml@npm:^3.14.0": + version: 3.14.1 + resolution: "js-yaml@npm:3.14.1" + dependencies: + argparse: ^1.0.7 + esprima: ^4.0.0 + bin: + js-yaml: bin/js-yaml.js + checksum: bef146085f472d44dee30ec34e5cf36bf89164f5d585435a3d3da89e52622dff0b188a580e4ad091c3341889e14cb88cac6e4deb16dc5b1e9623bb0601fc255c + languageName: node + linkType: hard + "js-yaml@npm:^4.1.0": version: 4.1.0 resolution: "js-yaml@npm:4.1.0" @@ -4884,7 +5117,7 @@ __metadata: languageName: node linkType: hard -"json5@npm:^2.2.2, json5@npm:^2.2.3": +"json5@npm:^2.1.3, json5@npm:^2.2.2, json5@npm:^2.2.3": version: 2.2.3 resolution: "json5@npm:2.2.3" bin: @@ -5000,6 +5233,24 @@ __metadata: languageName: node linkType: hard +"lodash@npm:4.17.21, lodash@npm:^4.17.20, lodash@npm:^4.17.21": + version: 4.17.21 + resolution: "lodash@npm:4.17.21" + checksum: eb835a2e51d381e561e508ce932ea50a8e5a68f4ebdd771ea240d3048244a8d13658acbd502cd4829768c56f2e16bdd4340b9ea141297d472517b83868e677f7 + languageName: node + linkType: hard + +"loose-envify@npm:^1.0.0": + version: 1.4.0 + resolution: "loose-envify@npm:1.4.0" + dependencies: + js-tokens: ^3.0.0 || ^4.0.0 + bin: + loose-envify: cli.js + checksum: 6517e24e0cad87ec9888f500c5b5947032cdfe6ef65e1c1936a0c48a524b81e65542c9c3edc91c97d5bddc806ee2a985dbc79be89215d613b1de5db6d1cfe6f4 + languageName: node + linkType: hard + "lru-cache@npm:^5.1.1": version: 5.1.1 resolution: "lru-cache@npm:5.1.1" @@ -5032,6 +5283,15 @@ __metadata: languageName: node linkType: hard +"magic-string@npm:^0.25.7": + version: 0.25.9 + resolution: "magic-string@npm:0.25.9" + dependencies: + sourcemap-codec: ^1.4.8 + checksum: 9a0e55a15c7303fc360f9572a71cffba1f61451bc92c5602b1206c9d17f492403bf96f946dfce7483e66822d6b74607262e24392e87b0ac27b786e69a40e9b1a + languageName: node + linkType: hard + "make-dir@npm:^3.0.0": version: 3.1.0 resolution: "make-dir@npm:3.1.0" @@ -5296,6 +5556,28 @@ __metadata: languageName: node linkType: hard +"multimatch@npm:^5.0.0": + version: 5.0.0 + resolution: "multimatch@npm:5.0.0" + dependencies: + "@types/minimatch": ^3.0.3 + array-differ: ^3.0.0 + array-union: ^2.1.0 + arrify: ^2.0.1 + minimatch: ^3.0.4 + checksum: 82c8030a53af965cab48da22f1b0f894ef99e16ee680dabdfbd38d2dfacc3c8208c475203d747afd9e26db44118ed0221d5a0d65268c864f06d6efc7ac6df812 + languageName: node + linkType: hard + +"nanoid@npm:^3.3.4": + version: 3.3.4 + resolution: "nanoid@npm:3.3.4" + bin: + nanoid: bin/nanoid.cjs + checksum: 2fddd6dee994b7676f008d3ffa4ab16035a754f4bb586c61df5a22cf8c8c94017aadd360368f47d653829e0569a92b129979152ff97af23a558331e47e37cd9c + languageName: node + linkType: hard + "natural-compare-lite@npm:^1.4.0": version: 1.4.0 resolution: "natural-compare-lite@npm:1.4.0" @@ -5426,7 +5708,7 @@ __metadata: languageName: node linkType: hard -"normalize-path@npm:^3.0.0": +"normalize-path@npm:^3.0.0, normalize-path@npm:~3.0.0": version: 3.0.0 resolution: "normalize-path@npm:3.0.0" checksum: 88eeb4da891e10b1318c4b2476b6e2ecbeb5ff97d946815ffea7794c31a89017c70d7f34b3c2ebf23ef4e9fc9fb99f7dffe36da22011b5b5c6ffa34f4873ec20 @@ -5636,7 +5918,7 @@ __metadata: languageName: node linkType: hard -"parse-json@npm:^5.2.0": +"parse-json@npm:^5.0.0, parse-json@npm:^5.2.0": version: 5.2.0 resolution: "parse-json@npm:5.2.0" dependencies: @@ -5726,6 +6008,13 @@ __metadata: languageName: node linkType: hard +"picomatch@npm:^2.2.1": + version: 2.3.1 + resolution: "picomatch@npm:2.3.1" + checksum: 050c865ce81119c4822c45d3c84f1ced46f93a0126febae20737bd05ca20589c564d6e9226977df859ed5e03dc73f02584a2b0faad36e896936238238b0446cf + languageName: node + linkType: hard + "pirates@npm:^4.0.4": version: 4.0.5 resolution: "pirates@npm:4.0.5" @@ -5742,6 +6031,26 @@ __metadata: languageName: node linkType: hard +"please-upgrade-node@npm:^3.2.0": + version: 3.2.0 + resolution: "please-upgrade-node@npm:3.2.0" + dependencies: + semver-compare: ^1.0.0 + checksum: d87c41581a2a022fbe25965a97006238cd9b8cbbf49b39f78d262548149a9d30bd2bdf35fec3d810e0001e630cd46ef13c7e19c389dea8de7e64db271a2381bb + languageName: node + linkType: hard + +"postcss@npm:^8.1.10": + version: 8.4.21 + resolution: "postcss@npm:8.4.21" + dependencies: + nanoid: ^3.3.4 + picocolors: ^1.0.0 + source-map-js: ^1.0.2 + checksum: e39ac60ccd1542d4f9d93d894048aac0d686b3bb38e927d8386005718e6793dbbb46930f0a523fe382f1bbd843c6d980aaea791252bf5e176180e5a4336d9679 + languageName: node + linkType: hard + "prelude-ls@npm:^1.2.1": version: 1.2.1 resolution: "prelude-ls@npm:1.2.1" @@ -5847,6 +6156,16 @@ __metadata: languageName: node linkType: hard +"query-ast@npm:^1.0.3": + version: 1.0.5 + resolution: "query-ast@npm:1.0.5" + dependencies: + invariant: 2.2.4 + lodash: ^4.17.21 + checksum: 4b7ae79bc907d0614c8d306d77fc82a19d40f5900bace286943839b875d84a52aa4993a73fdb8f4e989461b88474c47a60a48c7a42964b53253d5abe1452e9ad + languageName: node + linkType: hard + "queue-microtask@npm:^1.2.2": version: 1.2.3 resolution: "queue-microtask@npm:1.2.3" @@ -5906,6 +6225,15 @@ __metadata: languageName: node linkType: hard +"readdirp@npm:^3.5.0, readdirp@npm:~3.6.0": + version: 3.6.0 + resolution: "readdirp@npm:3.6.0" + dependencies: + picomatch: ^2.2.1 + checksum: 1ced032e6e45670b6d7352d71d21ce7edf7b9b928494dcaba6f11fba63180d9da6cd7061ebc34175ffda6ff529f481818c962952004d273178acd70f7059b320 + languageName: node + linkType: hard + "regexp.prototype.flags@npm:^1.4.3": version: 1.4.3 resolution: "regexp.prototype.flags@npm:1.4.3" @@ -5959,6 +6287,13 @@ __metadata: languageName: node linkType: hard +"require-package-name@npm:^2.0.1": + version: 2.0.1 + resolution: "require-package-name@npm:2.0.1" + checksum: 00f4e9e467ebe2bbced2b4198a165de11c83b5ee9f4c20b05a8782659b92bcb544dbd50be9a3eed746d05ecd875453e258c079eb3a79604b50a27cf8ab0798b5 + languageName: node + linkType: hard + "resolve-cwd@npm:^3.0.0": version: 3.0.0 resolution: "resolve-cwd@npm:3.0.0" @@ -5989,7 +6324,7 @@ __metadata: languageName: node linkType: hard -"resolve@npm:^1.10.1, resolve@npm:^1.20.0, resolve@npm:^1.22.0": +"resolve@npm:^1.10.1, resolve@npm:^1.18.1, resolve@npm:^1.20.0, resolve@npm:^1.22.0": version: 1.22.1 resolution: "resolve@npm:1.22.1" dependencies: @@ -6002,7 +6337,7 @@ __metadata: languageName: node linkType: hard -"resolve@patch:resolve@^1.10.1#~builtin, resolve@patch:resolve@^1.20.0#~builtin, resolve@patch:resolve@^1.22.0#~builtin": +"resolve@patch:resolve@^1.10.1#~builtin, resolve@patch:resolve@^1.18.1#~builtin, resolve@patch:resolve@^1.20.0#~builtin, resolve@patch:resolve@^1.22.0#~builtin": version: 1.22.1 resolution: "resolve@patch:resolve@npm%3A1.22.1#~builtin::version=1.22.1&hash=07638b" dependencies: @@ -6111,6 +6446,19 @@ __metadata: languageName: node linkType: hard +"sass@npm:^1.29.0": + version: 1.58.3 + resolution: "sass@npm:1.58.3" + dependencies: + chokidar: ">=3.0.0 <4.0.0" + immutable: ^4.0.0 + source-map-js: ">=0.6.2 <2.0.0" + bin: + sass: sass.js + checksum: 35a2b98c037ef80fdc93c9b0be846e6ccc7d75596351a37ee79c397e66666d0a754c52c4696e746c0aff32327471e185343ca349e998a58340411adc9d0489a5 + languageName: node + linkType: hard + "scrypt-js@npm:^3.0.0, scrypt-js@npm:^3.0.1": version: 3.0.1 resolution: "scrypt-js@npm:3.0.1" @@ -6118,6 +6466,16 @@ __metadata: languageName: node linkType: hard +"scss-parser@npm:^1.0.4": + version: 1.0.6 + resolution: "scss-parser@npm:1.0.6" + dependencies: + invariant: 2.2.4 + lodash: 4.17.21 + checksum: f1424d73e9c6aec006df16da7222a590efc3ee9b2abb622caffb5e19ed029baf66cf0d2d7aaad1e3d84e5d7f75cf7a3f761570341f26b318b499b08a7e5cd91c + languageName: node + linkType: hard + "secp256k1@npm:^4.0.1": version: 4.0.2 resolution: "secp256k1@npm:4.0.2" @@ -6130,6 +6488,13 @@ __metadata: languageName: node linkType: hard +"semver-compare@npm:^1.0.0": + version: 1.0.0 + resolution: "semver-compare@npm:1.0.0" + checksum: dd1d7e2909744cf2cf71864ac718efc990297f9de2913b68e41a214319e70174b1d1793ac16e31183b128c2b9812541300cb324db8168e6cf6b570703b171c68 + languageName: node + linkType: hard + "semver@npm:7.x, semver@npm:^7.3.2, semver@npm:^7.3.5, semver@npm:^7.3.7, semver@npm:^7.3.8": version: 7.3.8 resolution: "semver@npm:7.3.8" @@ -6301,6 +6666,13 @@ __metadata: languageName: node linkType: hard +"source-map-js@npm:>=0.6.2 <2.0.0, source-map-js@npm:^1.0.2": + version: 1.0.2 + resolution: "source-map-js@npm:1.0.2" + checksum: c049a7fc4deb9a7e9b481ae3d424cc793cb4845daa690bc5a05d428bf41bf231ced49b4cf0c9e77f9d42fdb3d20d6187619fc586605f5eabe995a316da8d377c + languageName: node + linkType: hard + "source-map-support@npm:0.5.13": version: 0.5.13 resolution: "source-map-support@npm:0.5.13" @@ -6325,6 +6697,13 @@ __metadata: languageName: node linkType: hard +"sourcemap-codec@npm:^1.4.8": + version: 1.4.8 + resolution: "sourcemap-codec@npm:1.4.8" + checksum: b57981c05611afef31605732b598ccf65124a9fcb03b833532659ac4d29ac0f7bfacbc0d6c5a28a03e84c7510e7e556d758d0bb57786e214660016fb94279316 + languageName: node + linkType: hard + "spdx-exceptions@npm:^2.1.0": version: 2.2.0 resolution: "spdx-exceptions@npm:2.2.0" @@ -7059,6 +7438,13 @@ __metadata: languageName: node linkType: hard +"yaml@npm:^1.10.0": + version: 1.10.2 + resolution: "yaml@npm:1.10.2" + checksum: ce4ada136e8a78a0b08dc10b4b900936912d15de59905b2bf415b4d33c63df1d555d23acb2a41b23cf9fb5da41c256441afca3d6509de7247daa062fd2c5ea5f + languageName: node + linkType: hard + "yargs-parser@npm:^20.2.2": version: 20.2.9 resolution: "yargs-parser@npm:20.2.9" @@ -7073,7 +7459,7 @@ __metadata: languageName: node linkType: hard -"yargs@npm:^16.2.0": +"yargs@npm:^16.1.0, yargs@npm:^16.2.0": version: 16.2.0 resolution: "yargs@npm:16.2.0" dependencies: From 4d8bb84f8a3a11bc7d312a4f9e902aa06f8904ed Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed, 1 Mar 2023 19:00:50 -0300 Subject: [PATCH 034/109] Revert "Install depcheck and rv @metamask/eslint-config-commonjs" This reverts commit 1ba064efdbab9bcf490f2d0b4cef478d512e5dae. --- .depcheckrc.json | 10 -- package.json | 5 +- yarn.lock | 448 ++++------------------------------------------- 3 files changed, 33 insertions(+), 430 deletions(-) delete mode 100644 .depcheckrc.json diff --git a/.depcheckrc.json b/.depcheckrc.json deleted file mode 100644 index 3897120c..00000000 --- a/.depcheckrc.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "ignores": [ - "@lavamoat/allow-scripts", - "@metamask/auto-changelog", - "@types/*", - "prettier-plugin-packagejson", - "ts-node", - "typedoc" - ] -} diff --git a/package.json b/package.json index d94476a0..e13729fa 100644 --- a/package.json +++ b/package.json @@ -27,11 +27,10 @@ "build": "tsc --project tsconfig.build.json", "build:docs": "typedoc", "lint": "yarn lint:eslint && yarn lint:misc --check", - "lint:dependencies": "depcheck", "lint:eslint": "eslint . --cache --ext js,ts", "lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write", "lint:misc": "prettier '**/*.json' '**/*.md' '!CHANGELOG.md' '**/*.yml' '!.yarnrc.yml' --ignore-path .gitignore --no-error-on-unmatched-pattern", - "test": "jest && jest-it-up" + "test": "jest" }, "dependencies": { "@metamask/browser-passworder": "^4.0.2", @@ -45,6 +44,7 @@ "@lavamoat/allow-scripts": "^2.1.0", "@metamask/auto-changelog": "^3.0.0", "@metamask/eslint-config": "^11.1.0", + "@metamask/eslint-config-commonjs": "^11.1.0", "@metamask/eslint-config-jest": "^11.1.0", "@metamask/eslint-config-nodejs": "^11.1.0", "@metamask/eslint-config-typescript": "^11.1.0", @@ -53,7 +53,6 @@ "@types/sinon": "^10.0.13", "@typescript-eslint/eslint-plugin": "^5.53.0", "@typescript-eslint/parser": "^5.53.0", - "depcheck": "^1.4.3", "eslint": "^8.29.0", "eslint-config-prettier": "^8.5.0", "eslint-plugin-import": "^2.26.0", diff --git a/yarn.lock b/yarn.lock index b17a0c8f..3f9608d6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -276,15 +276,6 @@ __metadata: languageName: node linkType: hard -"@babel/parser@npm:7.16.4": - version: 7.16.4 - resolution: "@babel/parser@npm:7.16.4" - bin: - parser: ./bin/babel-parser.js - checksum: ce0a8f92f440f2a12bc932f070a7b60c5133bf8a63f461841f9e39af0194f573707959d606c6fad1a2fd496a45148553afd9b74d3b8dd36cdb7861598d1f3e36 - languageName: node - linkType: hard - "@babel/parser@npm:^7.1.0, @babel/parser@npm:^7.14.5, @babel/parser@npm:^7.14.7": version: 7.14.7 resolution: "@babel/parser@npm:7.14.7" @@ -294,7 +285,7 @@ __metadata: languageName: node linkType: hard -"@babel/parser@npm:^7.16.4, @babel/parser@npm:^7.20.7, @babel/parser@npm:^7.21.0, @babel/parser@npm:^7.21.2": +"@babel/parser@npm:^7.20.7, @babel/parser@npm:^7.21.0, @babel/parser@npm:^7.21.2": version: 7.21.2 resolution: "@babel/parser@npm:7.21.2" bin: @@ -479,7 +470,7 @@ __metadata: languageName: node linkType: hard -"@babel/traverse@npm:^7.12.5, @babel/traverse@npm:^7.21.0, @babel/traverse@npm:^7.21.2": +"@babel/traverse@npm:^7.21.0, @babel/traverse@npm:^7.21.2": version: 7.21.2 resolution: "@babel/traverse@npm:7.21.2" dependencies: @@ -989,6 +980,20 @@ __metadata: languageName: node linkType: hard +"@metamask/eslint-config-commonjs@npm:^11.1.0": + version: 11.1.0 + resolution: "@metamask/eslint-config-commonjs@npm:11.1.0" + peerDependencies: + eslint: ^8.27.0 + eslint-config-prettier: ^8.5.0 + eslint-plugin-import: ^2.26.0 + eslint-plugin-jsdoc: ^39.6.2 + eslint-plugin-prettier: ^4.2.1 + prettier: ^2.7.1 + checksum: 287e4f0126ec63c266104395f937715241f320c4e0c2f4621d6c38312650ad66eaeb71027e7413e088eb6b7f4a1fd00d31a6eedbf3ea9cc35d817d734bfe1412 + languageName: node + linkType: hard + "@metamask/eslint-config-jest@npm:^11.1.0": version: 11.1.0 resolution: "@metamask/eslint-config-jest@npm:11.1.0" @@ -1058,6 +1063,7 @@ __metadata: "@metamask/auto-changelog": ^3.0.0 "@metamask/browser-passworder": ^4.0.2 "@metamask/eslint-config": ^11.1.0 + "@metamask/eslint-config-commonjs": ^11.1.0 "@metamask/eslint-config-jest": ^11.1.0 "@metamask/eslint-config-nodejs": ^11.1.0 "@metamask/eslint-config-typescript": ^11.1.0 @@ -1070,7 +1076,6 @@ __metadata: "@types/sinon": ^10.0.13 "@typescript-eslint/eslint-plugin": ^5.53.0 "@typescript-eslint/parser": ^5.53.0 - depcheck: ^1.4.3 eslint: ^8.29.0 eslint-config-prettier: ^8.5.0 eslint-plugin-import: ^2.26.0 @@ -1494,13 +1499,6 @@ __metadata: languageName: node linkType: hard -"@types/minimatch@npm:^3.0.3": - version: 3.0.5 - resolution: "@types/minimatch@npm:3.0.5" - checksum: c41d136f67231c3131cf1d4ca0b06687f4a322918a3a5adddc87ce90ed9dbd175a3610adee36b106ae68c0b92c637c35e02b58c8a56c424f71d30993ea220b92 - languageName: node - linkType: hard - "@types/mocha@npm:^5.0.0": version: 5.2.7 resolution: "@types/mocha@npm:5.2.7" @@ -1522,13 +1520,6 @@ __metadata: languageName: node linkType: hard -"@types/parse-json@npm:^4.0.0": - version: 4.0.0 - resolution: "@types/parse-json@npm:4.0.0" - checksum: fd6bce2b674b6efc3db4c7c3d336bd70c90838e8439de639b909ce22f3720d21344f52427f1d9e57b265fcb7f6c018699b99e5e0c208a1a4823014269a6bf35b - languageName: node - linkType: hard - "@types/pbkdf2@npm:^3.0.0": version: 3.1.0 resolution: "@types/pbkdf2@npm:3.1.0" @@ -1784,76 +1775,6 @@ __metadata: languageName: node linkType: hard -"@vue/compiler-core@npm:3.2.47": - version: 3.2.47 - resolution: "@vue/compiler-core@npm:3.2.47" - dependencies: - "@babel/parser": ^7.16.4 - "@vue/shared": 3.2.47 - estree-walker: ^2.0.2 - source-map: ^0.6.1 - checksum: 9ccc2a0b897b59eea56ca4f92ed29c14cd1184f68532edf5fb0fe5cb2833bcf9e4836029effb6eb9a7c872e9e0350fafdcd96ff00c0b5b79e17ded0c068b5f84 - languageName: node - linkType: hard - -"@vue/compiler-dom@npm:3.2.47": - version: 3.2.47 - resolution: "@vue/compiler-dom@npm:3.2.47" - dependencies: - "@vue/compiler-core": 3.2.47 - "@vue/shared": 3.2.47 - checksum: 1eced735f865e6df0c2d7fa041f9f27996ff4c0d4baf5fad0f67e65e623215f4394c49bba337b78427c6e71f2cc2db12b19ec6b865b4c057c0a15ccedeb20752 - languageName: node - linkType: hard - -"@vue/compiler-sfc@npm:^3.0.5": - version: 3.2.47 - resolution: "@vue/compiler-sfc@npm:3.2.47" - dependencies: - "@babel/parser": ^7.16.4 - "@vue/compiler-core": 3.2.47 - "@vue/compiler-dom": 3.2.47 - "@vue/compiler-ssr": 3.2.47 - "@vue/reactivity-transform": 3.2.47 - "@vue/shared": 3.2.47 - estree-walker: ^2.0.2 - magic-string: ^0.25.7 - postcss: ^8.1.10 - source-map: ^0.6.1 - checksum: 4588a513310b9319a00adfdbe789cfe60d5ec19c51e8f2098152b9e81f54be170e16c40463f6b5e4c7ab79796fc31e2de93587a9dd1af136023fa03712b62e68 - languageName: node - linkType: hard - -"@vue/compiler-ssr@npm:3.2.47": - version: 3.2.47 - resolution: "@vue/compiler-ssr@npm:3.2.47" - dependencies: - "@vue/compiler-dom": 3.2.47 - "@vue/shared": 3.2.47 - checksum: 91bc6e46744d5405713c08d8e576971aa6d13a0cde84ec592d3221bf6ee228e49ce12233af8c18dc39723455b420df2951f3616ceb99758eb432485475fa7bc2 - languageName: node - linkType: hard - -"@vue/reactivity-transform@npm:3.2.47": - version: 3.2.47 - resolution: "@vue/reactivity-transform@npm:3.2.47" - dependencies: - "@babel/parser": ^7.16.4 - "@vue/compiler-core": 3.2.47 - "@vue/shared": 3.2.47 - estree-walker: ^2.0.2 - magic-string: ^0.25.7 - checksum: 6fe54374aa8c080c0c421e18134e84e723e2d3e53178cf084c1cd75bc8b1ffaaf07756801f3aa4e1e7ad1ba76356c28bbab4bc1b676159db8fc10f10f2cbd405 - languageName: node - linkType: hard - -"@vue/shared@npm:3.2.47": - version: 3.2.47 - resolution: "@vue/shared@npm:3.2.47" - checksum: 0aa711dc9160fa0e476e6e94eea4e019398adf2211352d0e4a672cfb6b65b104bbd5d234807d1c091107bdc0f5d818d0f12378987eb7861d39be3aa9f6cd6e3e - languageName: node - linkType: hard - "abbrev@npm:1, abbrev@npm:^1.0.0": version: 1.1.1 resolution: "abbrev@npm:1.1.1" @@ -2009,16 +1930,6 @@ __metadata: languageName: node linkType: hard -"anymatch@npm:~3.1.2": - version: 3.1.3 - resolution: "anymatch@npm:3.1.3" - dependencies: - normalize-path: ^3.0.0 - picomatch: ^2.0.4 - checksum: 3e044fd6d1d26545f235a9fe4d7a534e2029d8e59fa7fd9f2a6eb21230f6b5380ea1eaf55136e60cbf8e613544b3b766e7a6fa2102e2a3a117505466e3025dc2 - languageName: node - linkType: hard - "aproba@npm:^1.0.3": version: 1.2.0 resolution: "aproba@npm:1.2.0" @@ -2076,13 +1987,6 @@ __metadata: languageName: node linkType: hard -"array-differ@npm:^3.0.0": - version: 3.0.0 - resolution: "array-differ@npm:3.0.0" - checksum: 117edd9df5c1530bd116c6e8eea891d4bd02850fd89b1b36e532b6540e47ca620a373b81feca1c62d1395d9ae601516ba538abe5e8172d41091da2c546b05fb7 - languageName: node - linkType: hard - "array-includes@npm:^3.1.4": version: 3.1.6 resolution: "array-includes@npm:3.1.6" @@ -2115,13 +2019,6 @@ __metadata: languageName: node linkType: hard -"arrify@npm:^2.0.1": - version: 2.0.1 - resolution: "arrify@npm:2.0.1" - checksum: 067c4c1afd182806a82e4c1cb8acee16ab8b5284fbca1ce29408e6e91281c36bb5b612f6ddfbd40a0f7a7e0c75bf2696eb94c027f6e328d6e9c52465c98e4209 - languageName: node - linkType: hard - "asn1@npm:~0.2.3": version: 0.2.4 resolution: "asn1@npm:0.2.4" @@ -2267,13 +2164,6 @@ __metadata: languageName: node linkType: hard -"binary-extensions@npm:^2.0.0": - version: 2.2.0 - resolution: "binary-extensions@npm:2.2.0" - checksum: ccd267956c58d2315f5d3ea6757cf09863c5fc703e50fbeb13a7dc849b812ef76e3cf9ca8f35a0c48498776a7478d7b4a0418e1e2b8cb9cb9731f2922aaad7f8 - languageName: node - linkType: hard - "blakejs@npm:^1.1.0": version: 1.1.0 resolution: "blakejs@npm:1.1.0" @@ -2314,7 +2204,7 @@ __metadata: languageName: node linkType: hard -"braces@npm:^3.0.1, braces@npm:~3.0.2": +"braces@npm:^3.0.1": version: 3.0.2 resolution: "braces@npm:3.0.2" dependencies: @@ -2509,25 +2399,6 @@ __metadata: languageName: node linkType: hard -"chokidar@npm:>=3.0.0 <4.0.0": - version: 3.5.3 - resolution: "chokidar@npm:3.5.3" - dependencies: - anymatch: ~3.1.2 - braces: ~3.0.2 - fsevents: ~2.3.2 - glob-parent: ~5.1.2 - is-binary-path: ~2.1.0 - is-glob: ~4.0.1 - normalize-path: ~3.0.0 - readdirp: ~3.6.0 - dependenciesMeta: - fsevents: - optional: true - checksum: b49fcde40176ba007ff361b198a2d35df60d9bb2a5aab228279eb810feae9294a6b4649ab15981304447afe1e6ffbf4788ad5db77235dc770ab777c6e771980c - languageName: node - linkType: hard - "chownr@npm:^2.0.0": version: 2.0.0 resolution: "chownr@npm:2.0.0" @@ -2703,19 +2574,6 @@ __metadata: languageName: node linkType: hard -"cosmiconfig@npm:^7.0.0": - version: 7.1.0 - resolution: "cosmiconfig@npm:7.1.0" - dependencies: - "@types/parse-json": ^4.0.0 - import-fresh: ^3.2.1 - parse-json: ^5.0.0 - path-type: ^4.0.0 - yaml: ^1.10.0 - checksum: c53bf7befc1591b2651a22414a5e786cd5f2eeaa87f3678a3d49d6069835a9d8d1aef223728e98aa8fec9a95bf831120d245096db12abe019fecb51f5696c96f - languageName: node - linkType: hard - "create-hash@npm:^1.1.0, create-hash@npm:^1.1.2, create-hash@npm:^1.2.0": version: 1.2.0 resolution: "create-hash@npm:1.2.0" @@ -2770,7 +2628,7 @@ __metadata: languageName: node linkType: hard -"debug@npm:4, debug@npm:^4.1.0, debug@npm:^4.1.1, debug@npm:^4.2.0, debug@npm:^4.3.2, debug@npm:^4.3.3, debug@npm:^4.3.4": +"debug@npm:4, debug@npm:^4.1.0, debug@npm:^4.1.1, debug@npm:^4.3.2, debug@npm:^4.3.3, debug@npm:^4.3.4": version: 4.3.4 resolution: "debug@npm:4.3.4" dependencies: @@ -2845,39 +2703,6 @@ __metadata: languageName: node linkType: hard -"depcheck@npm:^1.4.3": - version: 1.4.3 - resolution: "depcheck@npm:1.4.3" - dependencies: - "@babel/parser": 7.16.4 - "@babel/traverse": ^7.12.5 - "@vue/compiler-sfc": ^3.0.5 - camelcase: ^6.2.0 - cosmiconfig: ^7.0.0 - debug: ^4.2.0 - deps-regex: ^0.1.4 - ignore: ^5.1.8 - is-core-module: ^2.4.0 - js-yaml: ^3.14.0 - json5: ^2.1.3 - lodash: ^4.17.20 - minimatch: ^3.0.4 - multimatch: ^5.0.0 - please-upgrade-node: ^3.2.0 - query-ast: ^1.0.3 - readdirp: ^3.5.0 - require-package-name: ^2.0.1 - resolve: ^1.18.1 - sass: ^1.29.0 - scss-parser: ^1.0.4 - semver: ^7.3.2 - yargs: ^16.1.0 - bin: - depcheck: bin/depcheck.js - checksum: 122631cab325707a55e26a8b530eb72c893bd481194100b1853ac2bc944b61320eb0e1ea0ff7e71724009cdfbd4057381d7bf868b9c5aad0c4207ac0bdca5e48 - languageName: node - linkType: hard - "depd@npm:^1.1.2": version: 1.1.2 resolution: "depd@npm:1.1.2" @@ -2885,13 +2710,6 @@ __metadata: languageName: node linkType: hard -"deps-regex@npm:^0.1.4": - version: 0.1.4 - resolution: "deps-regex@npm:0.1.4" - checksum: 70c5e7fa887513bb8c55165c53e4ae511786ed7bf3d98d4dbef97a8879a808a5bc549034b1dfcdc7565c153e2fc2f7d8ee766eeb88156e78b2447dd75c1516e9 - languageName: node - linkType: hard - "detect-indent@npm:^6.0.0": version: 6.1.0 resolution: "detect-indent@npm:6.1.0" @@ -3409,13 +3227,6 @@ __metadata: languageName: node linkType: hard -"estree-walker@npm:^2.0.2": - version: 2.0.2 - resolution: "estree-walker@npm:2.0.2" - checksum: 6151e6f9828abe2259e57f5fd3761335bb0d2ebd76dc1a01048ccee22fabcfef3c0859300f6d83ff0d1927849368775ec5a6d265dde2f6de5a1be1721cd94efc - languageName: node - linkType: hard - "esutils@npm:^2.0.2": version: 2.0.3 resolution: "esutils@npm:2.0.3" @@ -3722,7 +3533,7 @@ __metadata: languageName: node linkType: hard -"fsevents@npm:^2.3.2, fsevents@npm:~2.3.2": +"fsevents@npm:^2.3.2": version: 2.3.2 resolution: "fsevents@npm:2.3.2" dependencies: @@ -3732,7 +3543,7 @@ __metadata: languageName: node linkType: hard -"fsevents@patch:fsevents@^2.3.2#~builtin, fsevents@patch:fsevents@~2.3.2#~builtin": +"fsevents@patch:fsevents@^2.3.2#~builtin": version: 2.3.2 resolution: "fsevents@patch:fsevents@npm%3A2.3.2#~builtin::version=2.3.2&hash=18f3a7" dependencies: @@ -3864,7 +3675,7 @@ __metadata: languageName: node linkType: hard -"glob-parent@npm:^5.1.2, glob-parent@npm:~5.1.2": +"glob-parent@npm:^5.1.2": version: 5.1.2 resolution: "glob-parent@npm:5.1.2" dependencies: @@ -4166,20 +3977,6 @@ __metadata: languageName: node linkType: hard -"ignore@npm:^5.1.8": - version: 5.2.4 - resolution: "ignore@npm:5.2.4" - checksum: 3d4c309c6006e2621659311783eaea7ebcd41fe4ca1d78c91c473157ad6666a57a2df790fe0d07a12300d9aac2888204d7be8d59f9aaf665b1c7fcdb432517ef - languageName: node - linkType: hard - -"immutable@npm:^4.0.0": - version: 4.2.4 - resolution: "immutable@npm:4.2.4" - checksum: 3be84eded37b05e65cad57bfba630bc1bf170c498b7472144bc02d2650cc9baef79daf03574a9c2e41d195ebb55a1c12c9b312f41ee324b653927b24ad8bcaa7 - languageName: node - linkType: hard - "import-fresh@npm:^3.0.0, import-fresh@npm:^3.2.1": version: 3.3.0 resolution: "import-fresh@npm:3.3.0" @@ -4251,15 +4048,6 @@ __metadata: languageName: node linkType: hard -"invariant@npm:2.2.4": - version: 2.2.4 - resolution: "invariant@npm:2.2.4" - dependencies: - loose-envify: ^1.0.0 - checksum: cc3182d793aad82a8d1f0af697b462939cb46066ec48bbf1707c150ad5fad6406137e91a262022c269702e01621f35ef60269f6c0d7fd178487959809acdfb14 - languageName: node - linkType: hard - "ip@npm:^2.0.0": version: 2.0.0 resolution: "ip@npm:2.0.0" @@ -4281,15 +4069,6 @@ __metadata: languageName: node linkType: hard -"is-binary-path@npm:~2.1.0": - version: 2.1.0 - resolution: "is-binary-path@npm:2.1.0" - dependencies: - binary-extensions: ^2.0.0 - checksum: 84192eb88cff70d320426f35ecd63c3d6d495da9d805b19bc65b518984b7c0760280e57dbf119b7e9be6b161784a5a673ab2c6abe83abb5198a432232ad5b35c - languageName: node - linkType: hard - "is-boolean-object@npm:^1.1.0": version: 1.1.1 resolution: "is-boolean-object@npm:1.1.1" @@ -4306,7 +4085,7 @@ __metadata: languageName: node linkType: hard -"is-core-module@npm:^2.4.0, is-core-module@npm:^2.8.1, is-core-module@npm:^2.9.0": +"is-core-module@npm:^2.8.1, is-core-module@npm:^2.9.0": version: 2.11.0 resolution: "is-core-module@npm:2.11.0" dependencies: @@ -4352,7 +4131,7 @@ __metadata: languageName: node linkType: hard -"is-glob@npm:^4.0.0, is-glob@npm:^4.0.1, is-glob@npm:^4.0.3, is-glob@npm:~4.0.1": +"is-glob@npm:^4.0.0, is-glob@npm:^4.0.1, is-glob@npm:^4.0.3": version: 4.0.3 resolution: "is-glob@npm:4.0.3" dependencies: @@ -5006,7 +4785,7 @@ __metadata: languageName: node linkType: hard -"js-tokens@npm:^3.0.0 || ^4.0.0, js-tokens@npm:^4.0.0": +"js-tokens@npm:^4.0.0": version: 4.0.0 resolution: "js-tokens@npm:4.0.0" checksum: 8a95213a5a77deb6cbe94d86340e8d9ace2b93bc367790b260101d2f36a2eaf4e4e22d9fa9cf459b38af3a32fb4190e638024cf82ec95ef708680e405ea7cc78 @@ -5025,18 +4804,6 @@ __metadata: languageName: node linkType: hard -"js-yaml@npm:^3.14.0": - version: 3.14.1 - resolution: "js-yaml@npm:3.14.1" - dependencies: - argparse: ^1.0.7 - esprima: ^4.0.0 - bin: - js-yaml: bin/js-yaml.js - checksum: bef146085f472d44dee30ec34e5cf36bf89164f5d585435a3d3da89e52622dff0b188a580e4ad091c3341889e14cb88cac6e4deb16dc5b1e9623bb0601fc255c - languageName: node - linkType: hard - "js-yaml@npm:^4.1.0": version: 4.1.0 resolution: "js-yaml@npm:4.1.0" @@ -5117,7 +4884,7 @@ __metadata: languageName: node linkType: hard -"json5@npm:^2.1.3, json5@npm:^2.2.2, json5@npm:^2.2.3": +"json5@npm:^2.2.2, json5@npm:^2.2.3": version: 2.2.3 resolution: "json5@npm:2.2.3" bin: @@ -5233,24 +5000,6 @@ __metadata: languageName: node linkType: hard -"lodash@npm:4.17.21, lodash@npm:^4.17.20, lodash@npm:^4.17.21": - version: 4.17.21 - resolution: "lodash@npm:4.17.21" - checksum: eb835a2e51d381e561e508ce932ea50a8e5a68f4ebdd771ea240d3048244a8d13658acbd502cd4829768c56f2e16bdd4340b9ea141297d472517b83868e677f7 - languageName: node - linkType: hard - -"loose-envify@npm:^1.0.0": - version: 1.4.0 - resolution: "loose-envify@npm:1.4.0" - dependencies: - js-tokens: ^3.0.0 || ^4.0.0 - bin: - loose-envify: cli.js - checksum: 6517e24e0cad87ec9888f500c5b5947032cdfe6ef65e1c1936a0c48a524b81e65542c9c3edc91c97d5bddc806ee2a985dbc79be89215d613b1de5db6d1cfe6f4 - languageName: node - linkType: hard - "lru-cache@npm:^5.1.1": version: 5.1.1 resolution: "lru-cache@npm:5.1.1" @@ -5283,15 +5032,6 @@ __metadata: languageName: node linkType: hard -"magic-string@npm:^0.25.7": - version: 0.25.9 - resolution: "magic-string@npm:0.25.9" - dependencies: - sourcemap-codec: ^1.4.8 - checksum: 9a0e55a15c7303fc360f9572a71cffba1f61451bc92c5602b1206c9d17f492403bf96f946dfce7483e66822d6b74607262e24392e87b0ac27b786e69a40e9b1a - languageName: node - linkType: hard - "make-dir@npm:^3.0.0": version: 3.1.0 resolution: "make-dir@npm:3.1.0" @@ -5556,28 +5296,6 @@ __metadata: languageName: node linkType: hard -"multimatch@npm:^5.0.0": - version: 5.0.0 - resolution: "multimatch@npm:5.0.0" - dependencies: - "@types/minimatch": ^3.0.3 - array-differ: ^3.0.0 - array-union: ^2.1.0 - arrify: ^2.0.1 - minimatch: ^3.0.4 - checksum: 82c8030a53af965cab48da22f1b0f894ef99e16ee680dabdfbd38d2dfacc3c8208c475203d747afd9e26db44118ed0221d5a0d65268c864f06d6efc7ac6df812 - languageName: node - linkType: hard - -"nanoid@npm:^3.3.4": - version: 3.3.4 - resolution: "nanoid@npm:3.3.4" - bin: - nanoid: bin/nanoid.cjs - checksum: 2fddd6dee994b7676f008d3ffa4ab16035a754f4bb586c61df5a22cf8c8c94017aadd360368f47d653829e0569a92b129979152ff97af23a558331e47e37cd9c - languageName: node - linkType: hard - "natural-compare-lite@npm:^1.4.0": version: 1.4.0 resolution: "natural-compare-lite@npm:1.4.0" @@ -5708,7 +5426,7 @@ __metadata: languageName: node linkType: hard -"normalize-path@npm:^3.0.0, normalize-path@npm:~3.0.0": +"normalize-path@npm:^3.0.0": version: 3.0.0 resolution: "normalize-path@npm:3.0.0" checksum: 88eeb4da891e10b1318c4b2476b6e2ecbeb5ff97d946815ffea7794c31a89017c70d7f34b3c2ebf23ef4e9fc9fb99f7dffe36da22011b5b5c6ffa34f4873ec20 @@ -5918,7 +5636,7 @@ __metadata: languageName: node linkType: hard -"parse-json@npm:^5.0.0, parse-json@npm:^5.2.0": +"parse-json@npm:^5.2.0": version: 5.2.0 resolution: "parse-json@npm:5.2.0" dependencies: @@ -6008,13 +5726,6 @@ __metadata: languageName: node linkType: hard -"picomatch@npm:^2.2.1": - version: 2.3.1 - resolution: "picomatch@npm:2.3.1" - checksum: 050c865ce81119c4822c45d3c84f1ced46f93a0126febae20737bd05ca20589c564d6e9226977df859ed5e03dc73f02584a2b0faad36e896936238238b0446cf - languageName: node - linkType: hard - "pirates@npm:^4.0.4": version: 4.0.5 resolution: "pirates@npm:4.0.5" @@ -6031,26 +5742,6 @@ __metadata: languageName: node linkType: hard -"please-upgrade-node@npm:^3.2.0": - version: 3.2.0 - resolution: "please-upgrade-node@npm:3.2.0" - dependencies: - semver-compare: ^1.0.0 - checksum: d87c41581a2a022fbe25965a97006238cd9b8cbbf49b39f78d262548149a9d30bd2bdf35fec3d810e0001e630cd46ef13c7e19c389dea8de7e64db271a2381bb - languageName: node - linkType: hard - -"postcss@npm:^8.1.10": - version: 8.4.21 - resolution: "postcss@npm:8.4.21" - dependencies: - nanoid: ^3.3.4 - picocolors: ^1.0.0 - source-map-js: ^1.0.2 - checksum: e39ac60ccd1542d4f9d93d894048aac0d686b3bb38e927d8386005718e6793dbbb46930f0a523fe382f1bbd843c6d980aaea791252bf5e176180e5a4336d9679 - languageName: node - linkType: hard - "prelude-ls@npm:^1.2.1": version: 1.2.1 resolution: "prelude-ls@npm:1.2.1" @@ -6156,16 +5847,6 @@ __metadata: languageName: node linkType: hard -"query-ast@npm:^1.0.3": - version: 1.0.5 - resolution: "query-ast@npm:1.0.5" - dependencies: - invariant: 2.2.4 - lodash: ^4.17.21 - checksum: 4b7ae79bc907d0614c8d306d77fc82a19d40f5900bace286943839b875d84a52aa4993a73fdb8f4e989461b88474c47a60a48c7a42964b53253d5abe1452e9ad - languageName: node - linkType: hard - "queue-microtask@npm:^1.2.2": version: 1.2.3 resolution: "queue-microtask@npm:1.2.3" @@ -6225,15 +5906,6 @@ __metadata: languageName: node linkType: hard -"readdirp@npm:^3.5.0, readdirp@npm:~3.6.0": - version: 3.6.0 - resolution: "readdirp@npm:3.6.0" - dependencies: - picomatch: ^2.2.1 - checksum: 1ced032e6e45670b6d7352d71d21ce7edf7b9b928494dcaba6f11fba63180d9da6cd7061ebc34175ffda6ff529f481818c962952004d273178acd70f7059b320 - languageName: node - linkType: hard - "regexp.prototype.flags@npm:^1.4.3": version: 1.4.3 resolution: "regexp.prototype.flags@npm:1.4.3" @@ -6287,13 +5959,6 @@ __metadata: languageName: node linkType: hard -"require-package-name@npm:^2.0.1": - version: 2.0.1 - resolution: "require-package-name@npm:2.0.1" - checksum: 00f4e9e467ebe2bbced2b4198a165de11c83b5ee9f4c20b05a8782659b92bcb544dbd50be9a3eed746d05ecd875453e258c079eb3a79604b50a27cf8ab0798b5 - languageName: node - linkType: hard - "resolve-cwd@npm:^3.0.0": version: 3.0.0 resolution: "resolve-cwd@npm:3.0.0" @@ -6324,7 +5989,7 @@ __metadata: languageName: node linkType: hard -"resolve@npm:^1.10.1, resolve@npm:^1.18.1, resolve@npm:^1.20.0, resolve@npm:^1.22.0": +"resolve@npm:^1.10.1, resolve@npm:^1.20.0, resolve@npm:^1.22.0": version: 1.22.1 resolution: "resolve@npm:1.22.1" dependencies: @@ -6337,7 +6002,7 @@ __metadata: languageName: node linkType: hard -"resolve@patch:resolve@^1.10.1#~builtin, resolve@patch:resolve@^1.18.1#~builtin, resolve@patch:resolve@^1.20.0#~builtin, resolve@patch:resolve@^1.22.0#~builtin": +"resolve@patch:resolve@^1.10.1#~builtin, resolve@patch:resolve@^1.20.0#~builtin, resolve@patch:resolve@^1.22.0#~builtin": version: 1.22.1 resolution: "resolve@patch:resolve@npm%3A1.22.1#~builtin::version=1.22.1&hash=07638b" dependencies: @@ -6446,19 +6111,6 @@ __metadata: languageName: node linkType: hard -"sass@npm:^1.29.0": - version: 1.58.3 - resolution: "sass@npm:1.58.3" - dependencies: - chokidar: ">=3.0.0 <4.0.0" - immutable: ^4.0.0 - source-map-js: ">=0.6.2 <2.0.0" - bin: - sass: sass.js - checksum: 35a2b98c037ef80fdc93c9b0be846e6ccc7d75596351a37ee79c397e66666d0a754c52c4696e746c0aff32327471e185343ca349e998a58340411adc9d0489a5 - languageName: node - linkType: hard - "scrypt-js@npm:^3.0.0, scrypt-js@npm:^3.0.1": version: 3.0.1 resolution: "scrypt-js@npm:3.0.1" @@ -6466,16 +6118,6 @@ __metadata: languageName: node linkType: hard -"scss-parser@npm:^1.0.4": - version: 1.0.6 - resolution: "scss-parser@npm:1.0.6" - dependencies: - invariant: 2.2.4 - lodash: 4.17.21 - checksum: f1424d73e9c6aec006df16da7222a590efc3ee9b2abb622caffb5e19ed029baf66cf0d2d7aaad1e3d84e5d7f75cf7a3f761570341f26b318b499b08a7e5cd91c - languageName: node - linkType: hard - "secp256k1@npm:^4.0.1": version: 4.0.2 resolution: "secp256k1@npm:4.0.2" @@ -6488,13 +6130,6 @@ __metadata: languageName: node linkType: hard -"semver-compare@npm:^1.0.0": - version: 1.0.0 - resolution: "semver-compare@npm:1.0.0" - checksum: dd1d7e2909744cf2cf71864ac718efc990297f9de2913b68e41a214319e70174b1d1793ac16e31183b128c2b9812541300cb324db8168e6cf6b570703b171c68 - languageName: node - linkType: hard - "semver@npm:7.x, semver@npm:^7.3.2, semver@npm:^7.3.5, semver@npm:^7.3.7, semver@npm:^7.3.8": version: 7.3.8 resolution: "semver@npm:7.3.8" @@ -6666,13 +6301,6 @@ __metadata: languageName: node linkType: hard -"source-map-js@npm:>=0.6.2 <2.0.0, source-map-js@npm:^1.0.2": - version: 1.0.2 - resolution: "source-map-js@npm:1.0.2" - checksum: c049a7fc4deb9a7e9b481ae3d424cc793cb4845daa690bc5a05d428bf41bf231ced49b4cf0c9e77f9d42fdb3d20d6187619fc586605f5eabe995a316da8d377c - languageName: node - linkType: hard - "source-map-support@npm:0.5.13": version: 0.5.13 resolution: "source-map-support@npm:0.5.13" @@ -6697,13 +6325,6 @@ __metadata: languageName: node linkType: hard -"sourcemap-codec@npm:^1.4.8": - version: 1.4.8 - resolution: "sourcemap-codec@npm:1.4.8" - checksum: b57981c05611afef31605732b598ccf65124a9fcb03b833532659ac4d29ac0f7bfacbc0d6c5a28a03e84c7510e7e556d758d0bb57786e214660016fb94279316 - languageName: node - linkType: hard - "spdx-exceptions@npm:^2.1.0": version: 2.2.0 resolution: "spdx-exceptions@npm:2.2.0" @@ -7438,13 +7059,6 @@ __metadata: languageName: node linkType: hard -"yaml@npm:^1.10.0": - version: 1.10.2 - resolution: "yaml@npm:1.10.2" - checksum: ce4ada136e8a78a0b08dc10b4b900936912d15de59905b2bf415b4d33c63df1d555d23acb2a41b23cf9fb5da41c256441afca3d6509de7247daa062fd2c5ea5f - languageName: node - linkType: hard - "yargs-parser@npm:^20.2.2": version: 20.2.9 resolution: "yargs-parser@npm:20.2.9" @@ -7459,7 +7073,7 @@ __metadata: languageName: node linkType: hard -"yargs@npm:^16.1.0, yargs@npm:^16.2.0": +"yargs@npm:^16.2.0": version: 16.2.0 resolution: "yargs@npm:16.2.0" dependencies: From d43832b13dfe6d5f6ed1fb84f79f88144a4f0ae4 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed, 1 Mar 2023 19:01:12 -0300 Subject: [PATCH 035/109] Revert "Update mocks dir structure" This reverts commit 37f0d372c22b5689ef757ee9e5a8285128605f41. --- src/KeyringController.test.ts | 3 ++- src/mocks/index.ts | 4 ---- src/mocks/{encryptor.mock.ts => mock-encryptor.ts} | 0 src/mocks/{keyring.mock.ts => mock-keyring.ts} | 0 4 files changed, 2 insertions(+), 5 deletions(-) delete mode 100644 src/mocks/index.ts rename src/mocks/{encryptor.mock.ts => mock-encryptor.ts} (100%) rename src/mocks/{keyring.mock.ts => mock-keyring.ts} (100%) diff --git a/src/KeyringController.test.ts b/src/KeyringController.test.ts index 0601e44e..bd8f9fcf 100644 --- a/src/KeyringController.test.ts +++ b/src/KeyringController.test.ts @@ -6,7 +6,8 @@ import Wallet from 'ethereumjs-wallet'; import { restore, spy, stub, assert as sinonAssert } from 'sinon'; import { KeyringController, keyringBuilderFactory } from '.'; -import { mockEncryptor, KeyringMockWithInit } from './mocks'; +import mockEncryptor from './mocks/mock-encryptor'; +import KeyringMockWithInit from './mocks/mock-keyring'; import { ExtendedKeyring, KeyringType } from './types'; const password = 'password123'; diff --git a/src/mocks/index.ts b/src/mocks/index.ts deleted file mode 100644 index 1c2bd455..00000000 --- a/src/mocks/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import mockEncryptor from './encryptor.mock'; -import KeyringMockWithInit from './keyring.mock'; - -export { mockEncryptor, KeyringMockWithInit }; diff --git a/src/mocks/encryptor.mock.ts b/src/mocks/mock-encryptor.ts similarity index 100% rename from src/mocks/encryptor.mock.ts rename to src/mocks/mock-encryptor.ts diff --git a/src/mocks/keyring.mock.ts b/src/mocks/mock-keyring.ts similarity index 100% rename from src/mocks/keyring.mock.ts rename to src/mocks/mock-keyring.ts From 9fe79f0708abb9e97bd637a6a6cf431cbc51eec8 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed, 1 Mar 2023 18:21:09 -0300 Subject: [PATCH 036/109] Update mocks dir structure --- src/KeyringController.test.ts | 3 +-- src/mocks/{mock-encryptor.ts => encryptor.mock.ts} | 0 src/mocks/index.ts | 4 ++++ src/mocks/{mock-keyring.ts => keyring.mock.ts} | 0 4 files changed, 5 insertions(+), 2 deletions(-) rename src/mocks/{mock-encryptor.ts => encryptor.mock.ts} (100%) create mode 100644 src/mocks/index.ts rename src/mocks/{mock-keyring.ts => keyring.mock.ts} (100%) diff --git a/src/KeyringController.test.ts b/src/KeyringController.test.ts index bd8f9fcf..0601e44e 100644 --- a/src/KeyringController.test.ts +++ b/src/KeyringController.test.ts @@ -6,8 +6,7 @@ import Wallet from 'ethereumjs-wallet'; import { restore, spy, stub, assert as sinonAssert } from 'sinon'; import { KeyringController, keyringBuilderFactory } from '.'; -import mockEncryptor from './mocks/mock-encryptor'; -import KeyringMockWithInit from './mocks/mock-keyring'; +import { mockEncryptor, KeyringMockWithInit } from './mocks'; import { ExtendedKeyring, KeyringType } from './types'; const password = 'password123'; diff --git a/src/mocks/mock-encryptor.ts b/src/mocks/encryptor.mock.ts similarity index 100% rename from src/mocks/mock-encryptor.ts rename to src/mocks/encryptor.mock.ts diff --git a/src/mocks/index.ts b/src/mocks/index.ts new file mode 100644 index 00000000..1c2bd455 --- /dev/null +++ b/src/mocks/index.ts @@ -0,0 +1,4 @@ +import mockEncryptor from './encryptor.mock'; +import KeyringMockWithInit from './keyring.mock'; + +export { mockEncryptor, KeyringMockWithInit }; diff --git a/src/mocks/mock-keyring.ts b/src/mocks/keyring.mock.ts similarity index 100% rename from src/mocks/mock-keyring.ts rename to src/mocks/keyring.mock.ts From 921bcb4ff53644c6dbc3724f2517139965c391a4 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed, 1 Mar 2023 18:21:46 -0300 Subject: [PATCH 037/109] Install depcheck and rv @metamask/eslint-config-commonjs --- .depcheckrc.json | 10 ++ package.json | 5 +- yarn.lock | 448 +++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 430 insertions(+), 33 deletions(-) create mode 100644 .depcheckrc.json diff --git a/.depcheckrc.json b/.depcheckrc.json new file mode 100644 index 00000000..3897120c --- /dev/null +++ b/.depcheckrc.json @@ -0,0 +1,10 @@ +{ + "ignores": [ + "@lavamoat/allow-scripts", + "@metamask/auto-changelog", + "@types/*", + "prettier-plugin-packagejson", + "ts-node", + "typedoc" + ] +} diff --git a/package.json b/package.json index e13729fa..d94476a0 100644 --- a/package.json +++ b/package.json @@ -27,10 +27,11 @@ "build": "tsc --project tsconfig.build.json", "build:docs": "typedoc", "lint": "yarn lint:eslint && yarn lint:misc --check", + "lint:dependencies": "depcheck", "lint:eslint": "eslint . --cache --ext js,ts", "lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write", "lint:misc": "prettier '**/*.json' '**/*.md' '!CHANGELOG.md' '**/*.yml' '!.yarnrc.yml' --ignore-path .gitignore --no-error-on-unmatched-pattern", - "test": "jest" + "test": "jest && jest-it-up" }, "dependencies": { "@metamask/browser-passworder": "^4.0.2", @@ -44,7 +45,6 @@ "@lavamoat/allow-scripts": "^2.1.0", "@metamask/auto-changelog": "^3.0.0", "@metamask/eslint-config": "^11.1.0", - "@metamask/eslint-config-commonjs": "^11.1.0", "@metamask/eslint-config-jest": "^11.1.0", "@metamask/eslint-config-nodejs": "^11.1.0", "@metamask/eslint-config-typescript": "^11.1.0", @@ -53,6 +53,7 @@ "@types/sinon": "^10.0.13", "@typescript-eslint/eslint-plugin": "^5.53.0", "@typescript-eslint/parser": "^5.53.0", + "depcheck": "^1.4.3", "eslint": "^8.29.0", "eslint-config-prettier": "^8.5.0", "eslint-plugin-import": "^2.26.0", diff --git a/yarn.lock b/yarn.lock index 3f9608d6..b17a0c8f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -276,6 +276,15 @@ __metadata: languageName: node linkType: hard +"@babel/parser@npm:7.16.4": + version: 7.16.4 + resolution: "@babel/parser@npm:7.16.4" + bin: + parser: ./bin/babel-parser.js + checksum: ce0a8f92f440f2a12bc932f070a7b60c5133bf8a63f461841f9e39af0194f573707959d606c6fad1a2fd496a45148553afd9b74d3b8dd36cdb7861598d1f3e36 + languageName: node + linkType: hard + "@babel/parser@npm:^7.1.0, @babel/parser@npm:^7.14.5, @babel/parser@npm:^7.14.7": version: 7.14.7 resolution: "@babel/parser@npm:7.14.7" @@ -285,7 +294,7 @@ __metadata: languageName: node linkType: hard -"@babel/parser@npm:^7.20.7, @babel/parser@npm:^7.21.0, @babel/parser@npm:^7.21.2": +"@babel/parser@npm:^7.16.4, @babel/parser@npm:^7.20.7, @babel/parser@npm:^7.21.0, @babel/parser@npm:^7.21.2": version: 7.21.2 resolution: "@babel/parser@npm:7.21.2" bin: @@ -470,7 +479,7 @@ __metadata: languageName: node linkType: hard -"@babel/traverse@npm:^7.21.0, @babel/traverse@npm:^7.21.2": +"@babel/traverse@npm:^7.12.5, @babel/traverse@npm:^7.21.0, @babel/traverse@npm:^7.21.2": version: 7.21.2 resolution: "@babel/traverse@npm:7.21.2" dependencies: @@ -980,20 +989,6 @@ __metadata: languageName: node linkType: hard -"@metamask/eslint-config-commonjs@npm:^11.1.0": - version: 11.1.0 - resolution: "@metamask/eslint-config-commonjs@npm:11.1.0" - peerDependencies: - eslint: ^8.27.0 - eslint-config-prettier: ^8.5.0 - eslint-plugin-import: ^2.26.0 - eslint-plugin-jsdoc: ^39.6.2 - eslint-plugin-prettier: ^4.2.1 - prettier: ^2.7.1 - checksum: 287e4f0126ec63c266104395f937715241f320c4e0c2f4621d6c38312650ad66eaeb71027e7413e088eb6b7f4a1fd00d31a6eedbf3ea9cc35d817d734bfe1412 - languageName: node - linkType: hard - "@metamask/eslint-config-jest@npm:^11.1.0": version: 11.1.0 resolution: "@metamask/eslint-config-jest@npm:11.1.0" @@ -1063,7 +1058,6 @@ __metadata: "@metamask/auto-changelog": ^3.0.0 "@metamask/browser-passworder": ^4.0.2 "@metamask/eslint-config": ^11.1.0 - "@metamask/eslint-config-commonjs": ^11.1.0 "@metamask/eslint-config-jest": ^11.1.0 "@metamask/eslint-config-nodejs": ^11.1.0 "@metamask/eslint-config-typescript": ^11.1.0 @@ -1076,6 +1070,7 @@ __metadata: "@types/sinon": ^10.0.13 "@typescript-eslint/eslint-plugin": ^5.53.0 "@typescript-eslint/parser": ^5.53.0 + depcheck: ^1.4.3 eslint: ^8.29.0 eslint-config-prettier: ^8.5.0 eslint-plugin-import: ^2.26.0 @@ -1499,6 +1494,13 @@ __metadata: languageName: node linkType: hard +"@types/minimatch@npm:^3.0.3": + version: 3.0.5 + resolution: "@types/minimatch@npm:3.0.5" + checksum: c41d136f67231c3131cf1d4ca0b06687f4a322918a3a5adddc87ce90ed9dbd175a3610adee36b106ae68c0b92c637c35e02b58c8a56c424f71d30993ea220b92 + languageName: node + linkType: hard + "@types/mocha@npm:^5.0.0": version: 5.2.7 resolution: "@types/mocha@npm:5.2.7" @@ -1520,6 +1522,13 @@ __metadata: languageName: node linkType: hard +"@types/parse-json@npm:^4.0.0": + version: 4.0.0 + resolution: "@types/parse-json@npm:4.0.0" + checksum: fd6bce2b674b6efc3db4c7c3d336bd70c90838e8439de639b909ce22f3720d21344f52427f1d9e57b265fcb7f6c018699b99e5e0c208a1a4823014269a6bf35b + languageName: node + linkType: hard + "@types/pbkdf2@npm:^3.0.0": version: 3.1.0 resolution: "@types/pbkdf2@npm:3.1.0" @@ -1775,6 +1784,76 @@ __metadata: languageName: node linkType: hard +"@vue/compiler-core@npm:3.2.47": + version: 3.2.47 + resolution: "@vue/compiler-core@npm:3.2.47" + dependencies: + "@babel/parser": ^7.16.4 + "@vue/shared": 3.2.47 + estree-walker: ^2.0.2 + source-map: ^0.6.1 + checksum: 9ccc2a0b897b59eea56ca4f92ed29c14cd1184f68532edf5fb0fe5cb2833bcf9e4836029effb6eb9a7c872e9e0350fafdcd96ff00c0b5b79e17ded0c068b5f84 + languageName: node + linkType: hard + +"@vue/compiler-dom@npm:3.2.47": + version: 3.2.47 + resolution: "@vue/compiler-dom@npm:3.2.47" + dependencies: + "@vue/compiler-core": 3.2.47 + "@vue/shared": 3.2.47 + checksum: 1eced735f865e6df0c2d7fa041f9f27996ff4c0d4baf5fad0f67e65e623215f4394c49bba337b78427c6e71f2cc2db12b19ec6b865b4c057c0a15ccedeb20752 + languageName: node + linkType: hard + +"@vue/compiler-sfc@npm:^3.0.5": + version: 3.2.47 + resolution: "@vue/compiler-sfc@npm:3.2.47" + dependencies: + "@babel/parser": ^7.16.4 + "@vue/compiler-core": 3.2.47 + "@vue/compiler-dom": 3.2.47 + "@vue/compiler-ssr": 3.2.47 + "@vue/reactivity-transform": 3.2.47 + "@vue/shared": 3.2.47 + estree-walker: ^2.0.2 + magic-string: ^0.25.7 + postcss: ^8.1.10 + source-map: ^0.6.1 + checksum: 4588a513310b9319a00adfdbe789cfe60d5ec19c51e8f2098152b9e81f54be170e16c40463f6b5e4c7ab79796fc31e2de93587a9dd1af136023fa03712b62e68 + languageName: node + linkType: hard + +"@vue/compiler-ssr@npm:3.2.47": + version: 3.2.47 + resolution: "@vue/compiler-ssr@npm:3.2.47" + dependencies: + "@vue/compiler-dom": 3.2.47 + "@vue/shared": 3.2.47 + checksum: 91bc6e46744d5405713c08d8e576971aa6d13a0cde84ec592d3221bf6ee228e49ce12233af8c18dc39723455b420df2951f3616ceb99758eb432485475fa7bc2 + languageName: node + linkType: hard + +"@vue/reactivity-transform@npm:3.2.47": + version: 3.2.47 + resolution: "@vue/reactivity-transform@npm:3.2.47" + dependencies: + "@babel/parser": ^7.16.4 + "@vue/compiler-core": 3.2.47 + "@vue/shared": 3.2.47 + estree-walker: ^2.0.2 + magic-string: ^0.25.7 + checksum: 6fe54374aa8c080c0c421e18134e84e723e2d3e53178cf084c1cd75bc8b1ffaaf07756801f3aa4e1e7ad1ba76356c28bbab4bc1b676159db8fc10f10f2cbd405 + languageName: node + linkType: hard + +"@vue/shared@npm:3.2.47": + version: 3.2.47 + resolution: "@vue/shared@npm:3.2.47" + checksum: 0aa711dc9160fa0e476e6e94eea4e019398adf2211352d0e4a672cfb6b65b104bbd5d234807d1c091107bdc0f5d818d0f12378987eb7861d39be3aa9f6cd6e3e + languageName: node + linkType: hard + "abbrev@npm:1, abbrev@npm:^1.0.0": version: 1.1.1 resolution: "abbrev@npm:1.1.1" @@ -1930,6 +2009,16 @@ __metadata: languageName: node linkType: hard +"anymatch@npm:~3.1.2": + version: 3.1.3 + resolution: "anymatch@npm:3.1.3" + dependencies: + normalize-path: ^3.0.0 + picomatch: ^2.0.4 + checksum: 3e044fd6d1d26545f235a9fe4d7a534e2029d8e59fa7fd9f2a6eb21230f6b5380ea1eaf55136e60cbf8e613544b3b766e7a6fa2102e2a3a117505466e3025dc2 + languageName: node + linkType: hard + "aproba@npm:^1.0.3": version: 1.2.0 resolution: "aproba@npm:1.2.0" @@ -1987,6 +2076,13 @@ __metadata: languageName: node linkType: hard +"array-differ@npm:^3.0.0": + version: 3.0.0 + resolution: "array-differ@npm:3.0.0" + checksum: 117edd9df5c1530bd116c6e8eea891d4bd02850fd89b1b36e532b6540e47ca620a373b81feca1c62d1395d9ae601516ba538abe5e8172d41091da2c546b05fb7 + languageName: node + linkType: hard + "array-includes@npm:^3.1.4": version: 3.1.6 resolution: "array-includes@npm:3.1.6" @@ -2019,6 +2115,13 @@ __metadata: languageName: node linkType: hard +"arrify@npm:^2.0.1": + version: 2.0.1 + resolution: "arrify@npm:2.0.1" + checksum: 067c4c1afd182806a82e4c1cb8acee16ab8b5284fbca1ce29408e6e91281c36bb5b612f6ddfbd40a0f7a7e0c75bf2696eb94c027f6e328d6e9c52465c98e4209 + languageName: node + linkType: hard + "asn1@npm:~0.2.3": version: 0.2.4 resolution: "asn1@npm:0.2.4" @@ -2164,6 +2267,13 @@ __metadata: languageName: node linkType: hard +"binary-extensions@npm:^2.0.0": + version: 2.2.0 + resolution: "binary-extensions@npm:2.2.0" + checksum: ccd267956c58d2315f5d3ea6757cf09863c5fc703e50fbeb13a7dc849b812ef76e3cf9ca8f35a0c48498776a7478d7b4a0418e1e2b8cb9cb9731f2922aaad7f8 + languageName: node + linkType: hard + "blakejs@npm:^1.1.0": version: 1.1.0 resolution: "blakejs@npm:1.1.0" @@ -2204,7 +2314,7 @@ __metadata: languageName: node linkType: hard -"braces@npm:^3.0.1": +"braces@npm:^3.0.1, braces@npm:~3.0.2": version: 3.0.2 resolution: "braces@npm:3.0.2" dependencies: @@ -2399,6 +2509,25 @@ __metadata: languageName: node linkType: hard +"chokidar@npm:>=3.0.0 <4.0.0": + version: 3.5.3 + resolution: "chokidar@npm:3.5.3" + dependencies: + anymatch: ~3.1.2 + braces: ~3.0.2 + fsevents: ~2.3.2 + glob-parent: ~5.1.2 + is-binary-path: ~2.1.0 + is-glob: ~4.0.1 + normalize-path: ~3.0.0 + readdirp: ~3.6.0 + dependenciesMeta: + fsevents: + optional: true + checksum: b49fcde40176ba007ff361b198a2d35df60d9bb2a5aab228279eb810feae9294a6b4649ab15981304447afe1e6ffbf4788ad5db77235dc770ab777c6e771980c + languageName: node + linkType: hard + "chownr@npm:^2.0.0": version: 2.0.0 resolution: "chownr@npm:2.0.0" @@ -2574,6 +2703,19 @@ __metadata: languageName: node linkType: hard +"cosmiconfig@npm:^7.0.0": + version: 7.1.0 + resolution: "cosmiconfig@npm:7.1.0" + dependencies: + "@types/parse-json": ^4.0.0 + import-fresh: ^3.2.1 + parse-json: ^5.0.0 + path-type: ^4.0.0 + yaml: ^1.10.0 + checksum: c53bf7befc1591b2651a22414a5e786cd5f2eeaa87f3678a3d49d6069835a9d8d1aef223728e98aa8fec9a95bf831120d245096db12abe019fecb51f5696c96f + languageName: node + linkType: hard + "create-hash@npm:^1.1.0, create-hash@npm:^1.1.2, create-hash@npm:^1.2.0": version: 1.2.0 resolution: "create-hash@npm:1.2.0" @@ -2628,7 +2770,7 @@ __metadata: languageName: node linkType: hard -"debug@npm:4, debug@npm:^4.1.0, debug@npm:^4.1.1, debug@npm:^4.3.2, debug@npm:^4.3.3, debug@npm:^4.3.4": +"debug@npm:4, debug@npm:^4.1.0, debug@npm:^4.1.1, debug@npm:^4.2.0, debug@npm:^4.3.2, debug@npm:^4.3.3, debug@npm:^4.3.4": version: 4.3.4 resolution: "debug@npm:4.3.4" dependencies: @@ -2703,6 +2845,39 @@ __metadata: languageName: node linkType: hard +"depcheck@npm:^1.4.3": + version: 1.4.3 + resolution: "depcheck@npm:1.4.3" + dependencies: + "@babel/parser": 7.16.4 + "@babel/traverse": ^7.12.5 + "@vue/compiler-sfc": ^3.0.5 + camelcase: ^6.2.0 + cosmiconfig: ^7.0.0 + debug: ^4.2.0 + deps-regex: ^0.1.4 + ignore: ^5.1.8 + is-core-module: ^2.4.0 + js-yaml: ^3.14.0 + json5: ^2.1.3 + lodash: ^4.17.20 + minimatch: ^3.0.4 + multimatch: ^5.0.0 + please-upgrade-node: ^3.2.0 + query-ast: ^1.0.3 + readdirp: ^3.5.0 + require-package-name: ^2.0.1 + resolve: ^1.18.1 + sass: ^1.29.0 + scss-parser: ^1.0.4 + semver: ^7.3.2 + yargs: ^16.1.0 + bin: + depcheck: bin/depcheck.js + checksum: 122631cab325707a55e26a8b530eb72c893bd481194100b1853ac2bc944b61320eb0e1ea0ff7e71724009cdfbd4057381d7bf868b9c5aad0c4207ac0bdca5e48 + languageName: node + linkType: hard + "depd@npm:^1.1.2": version: 1.1.2 resolution: "depd@npm:1.1.2" @@ -2710,6 +2885,13 @@ __metadata: languageName: node linkType: hard +"deps-regex@npm:^0.1.4": + version: 0.1.4 + resolution: "deps-regex@npm:0.1.4" + checksum: 70c5e7fa887513bb8c55165c53e4ae511786ed7bf3d98d4dbef97a8879a808a5bc549034b1dfcdc7565c153e2fc2f7d8ee766eeb88156e78b2447dd75c1516e9 + languageName: node + linkType: hard + "detect-indent@npm:^6.0.0": version: 6.1.0 resolution: "detect-indent@npm:6.1.0" @@ -3227,6 +3409,13 @@ __metadata: languageName: node linkType: hard +"estree-walker@npm:^2.0.2": + version: 2.0.2 + resolution: "estree-walker@npm:2.0.2" + checksum: 6151e6f9828abe2259e57f5fd3761335bb0d2ebd76dc1a01048ccee22fabcfef3c0859300f6d83ff0d1927849368775ec5a6d265dde2f6de5a1be1721cd94efc + languageName: node + linkType: hard + "esutils@npm:^2.0.2": version: 2.0.3 resolution: "esutils@npm:2.0.3" @@ -3533,7 +3722,7 @@ __metadata: languageName: node linkType: hard -"fsevents@npm:^2.3.2": +"fsevents@npm:^2.3.2, fsevents@npm:~2.3.2": version: 2.3.2 resolution: "fsevents@npm:2.3.2" dependencies: @@ -3543,7 +3732,7 @@ __metadata: languageName: node linkType: hard -"fsevents@patch:fsevents@^2.3.2#~builtin": +"fsevents@patch:fsevents@^2.3.2#~builtin, fsevents@patch:fsevents@~2.3.2#~builtin": version: 2.3.2 resolution: "fsevents@patch:fsevents@npm%3A2.3.2#~builtin::version=2.3.2&hash=18f3a7" dependencies: @@ -3675,7 +3864,7 @@ __metadata: languageName: node linkType: hard -"glob-parent@npm:^5.1.2": +"glob-parent@npm:^5.1.2, glob-parent@npm:~5.1.2": version: 5.1.2 resolution: "glob-parent@npm:5.1.2" dependencies: @@ -3977,6 +4166,20 @@ __metadata: languageName: node linkType: hard +"ignore@npm:^5.1.8": + version: 5.2.4 + resolution: "ignore@npm:5.2.4" + checksum: 3d4c309c6006e2621659311783eaea7ebcd41fe4ca1d78c91c473157ad6666a57a2df790fe0d07a12300d9aac2888204d7be8d59f9aaf665b1c7fcdb432517ef + languageName: node + linkType: hard + +"immutable@npm:^4.0.0": + version: 4.2.4 + resolution: "immutable@npm:4.2.4" + checksum: 3be84eded37b05e65cad57bfba630bc1bf170c498b7472144bc02d2650cc9baef79daf03574a9c2e41d195ebb55a1c12c9b312f41ee324b653927b24ad8bcaa7 + languageName: node + linkType: hard + "import-fresh@npm:^3.0.0, import-fresh@npm:^3.2.1": version: 3.3.0 resolution: "import-fresh@npm:3.3.0" @@ -4048,6 +4251,15 @@ __metadata: languageName: node linkType: hard +"invariant@npm:2.2.4": + version: 2.2.4 + resolution: "invariant@npm:2.2.4" + dependencies: + loose-envify: ^1.0.0 + checksum: cc3182d793aad82a8d1f0af697b462939cb46066ec48bbf1707c150ad5fad6406137e91a262022c269702e01621f35ef60269f6c0d7fd178487959809acdfb14 + languageName: node + linkType: hard + "ip@npm:^2.0.0": version: 2.0.0 resolution: "ip@npm:2.0.0" @@ -4069,6 +4281,15 @@ __metadata: languageName: node linkType: hard +"is-binary-path@npm:~2.1.0": + version: 2.1.0 + resolution: "is-binary-path@npm:2.1.0" + dependencies: + binary-extensions: ^2.0.0 + checksum: 84192eb88cff70d320426f35ecd63c3d6d495da9d805b19bc65b518984b7c0760280e57dbf119b7e9be6b161784a5a673ab2c6abe83abb5198a432232ad5b35c + languageName: node + linkType: hard + "is-boolean-object@npm:^1.1.0": version: 1.1.1 resolution: "is-boolean-object@npm:1.1.1" @@ -4085,7 +4306,7 @@ __metadata: languageName: node linkType: hard -"is-core-module@npm:^2.8.1, is-core-module@npm:^2.9.0": +"is-core-module@npm:^2.4.0, is-core-module@npm:^2.8.1, is-core-module@npm:^2.9.0": version: 2.11.0 resolution: "is-core-module@npm:2.11.0" dependencies: @@ -4131,7 +4352,7 @@ __metadata: languageName: node linkType: hard -"is-glob@npm:^4.0.0, is-glob@npm:^4.0.1, is-glob@npm:^4.0.3": +"is-glob@npm:^4.0.0, is-glob@npm:^4.0.1, is-glob@npm:^4.0.3, is-glob@npm:~4.0.1": version: 4.0.3 resolution: "is-glob@npm:4.0.3" dependencies: @@ -4785,7 +5006,7 @@ __metadata: languageName: node linkType: hard -"js-tokens@npm:^4.0.0": +"js-tokens@npm:^3.0.0 || ^4.0.0, js-tokens@npm:^4.0.0": version: 4.0.0 resolution: "js-tokens@npm:4.0.0" checksum: 8a95213a5a77deb6cbe94d86340e8d9ace2b93bc367790b260101d2f36a2eaf4e4e22d9fa9cf459b38af3a32fb4190e638024cf82ec95ef708680e405ea7cc78 @@ -4804,6 +5025,18 @@ __metadata: languageName: node linkType: hard +"js-yaml@npm:^3.14.0": + version: 3.14.1 + resolution: "js-yaml@npm:3.14.1" + dependencies: + argparse: ^1.0.7 + esprima: ^4.0.0 + bin: + js-yaml: bin/js-yaml.js + checksum: bef146085f472d44dee30ec34e5cf36bf89164f5d585435a3d3da89e52622dff0b188a580e4ad091c3341889e14cb88cac6e4deb16dc5b1e9623bb0601fc255c + languageName: node + linkType: hard + "js-yaml@npm:^4.1.0": version: 4.1.0 resolution: "js-yaml@npm:4.1.0" @@ -4884,7 +5117,7 @@ __metadata: languageName: node linkType: hard -"json5@npm:^2.2.2, json5@npm:^2.2.3": +"json5@npm:^2.1.3, json5@npm:^2.2.2, json5@npm:^2.2.3": version: 2.2.3 resolution: "json5@npm:2.2.3" bin: @@ -5000,6 +5233,24 @@ __metadata: languageName: node linkType: hard +"lodash@npm:4.17.21, lodash@npm:^4.17.20, lodash@npm:^4.17.21": + version: 4.17.21 + resolution: "lodash@npm:4.17.21" + checksum: eb835a2e51d381e561e508ce932ea50a8e5a68f4ebdd771ea240d3048244a8d13658acbd502cd4829768c56f2e16bdd4340b9ea141297d472517b83868e677f7 + languageName: node + linkType: hard + +"loose-envify@npm:^1.0.0": + version: 1.4.0 + resolution: "loose-envify@npm:1.4.0" + dependencies: + js-tokens: ^3.0.0 || ^4.0.0 + bin: + loose-envify: cli.js + checksum: 6517e24e0cad87ec9888f500c5b5947032cdfe6ef65e1c1936a0c48a524b81e65542c9c3edc91c97d5bddc806ee2a985dbc79be89215d613b1de5db6d1cfe6f4 + languageName: node + linkType: hard + "lru-cache@npm:^5.1.1": version: 5.1.1 resolution: "lru-cache@npm:5.1.1" @@ -5032,6 +5283,15 @@ __metadata: languageName: node linkType: hard +"magic-string@npm:^0.25.7": + version: 0.25.9 + resolution: "magic-string@npm:0.25.9" + dependencies: + sourcemap-codec: ^1.4.8 + checksum: 9a0e55a15c7303fc360f9572a71cffba1f61451bc92c5602b1206c9d17f492403bf96f946dfce7483e66822d6b74607262e24392e87b0ac27b786e69a40e9b1a + languageName: node + linkType: hard + "make-dir@npm:^3.0.0": version: 3.1.0 resolution: "make-dir@npm:3.1.0" @@ -5296,6 +5556,28 @@ __metadata: languageName: node linkType: hard +"multimatch@npm:^5.0.0": + version: 5.0.0 + resolution: "multimatch@npm:5.0.0" + dependencies: + "@types/minimatch": ^3.0.3 + array-differ: ^3.0.0 + array-union: ^2.1.0 + arrify: ^2.0.1 + minimatch: ^3.0.4 + checksum: 82c8030a53af965cab48da22f1b0f894ef99e16ee680dabdfbd38d2dfacc3c8208c475203d747afd9e26db44118ed0221d5a0d65268c864f06d6efc7ac6df812 + languageName: node + linkType: hard + +"nanoid@npm:^3.3.4": + version: 3.3.4 + resolution: "nanoid@npm:3.3.4" + bin: + nanoid: bin/nanoid.cjs + checksum: 2fddd6dee994b7676f008d3ffa4ab16035a754f4bb586c61df5a22cf8c8c94017aadd360368f47d653829e0569a92b129979152ff97af23a558331e47e37cd9c + languageName: node + linkType: hard + "natural-compare-lite@npm:^1.4.0": version: 1.4.0 resolution: "natural-compare-lite@npm:1.4.0" @@ -5426,7 +5708,7 @@ __metadata: languageName: node linkType: hard -"normalize-path@npm:^3.0.0": +"normalize-path@npm:^3.0.0, normalize-path@npm:~3.0.0": version: 3.0.0 resolution: "normalize-path@npm:3.0.0" checksum: 88eeb4da891e10b1318c4b2476b6e2ecbeb5ff97d946815ffea7794c31a89017c70d7f34b3c2ebf23ef4e9fc9fb99f7dffe36da22011b5b5c6ffa34f4873ec20 @@ -5636,7 +5918,7 @@ __metadata: languageName: node linkType: hard -"parse-json@npm:^5.2.0": +"parse-json@npm:^5.0.0, parse-json@npm:^5.2.0": version: 5.2.0 resolution: "parse-json@npm:5.2.0" dependencies: @@ -5726,6 +6008,13 @@ __metadata: languageName: node linkType: hard +"picomatch@npm:^2.2.1": + version: 2.3.1 + resolution: "picomatch@npm:2.3.1" + checksum: 050c865ce81119c4822c45d3c84f1ced46f93a0126febae20737bd05ca20589c564d6e9226977df859ed5e03dc73f02584a2b0faad36e896936238238b0446cf + languageName: node + linkType: hard + "pirates@npm:^4.0.4": version: 4.0.5 resolution: "pirates@npm:4.0.5" @@ -5742,6 +6031,26 @@ __metadata: languageName: node linkType: hard +"please-upgrade-node@npm:^3.2.0": + version: 3.2.0 + resolution: "please-upgrade-node@npm:3.2.0" + dependencies: + semver-compare: ^1.0.0 + checksum: d87c41581a2a022fbe25965a97006238cd9b8cbbf49b39f78d262548149a9d30bd2bdf35fec3d810e0001e630cd46ef13c7e19c389dea8de7e64db271a2381bb + languageName: node + linkType: hard + +"postcss@npm:^8.1.10": + version: 8.4.21 + resolution: "postcss@npm:8.4.21" + dependencies: + nanoid: ^3.3.4 + picocolors: ^1.0.0 + source-map-js: ^1.0.2 + checksum: e39ac60ccd1542d4f9d93d894048aac0d686b3bb38e927d8386005718e6793dbbb46930f0a523fe382f1bbd843c6d980aaea791252bf5e176180e5a4336d9679 + languageName: node + linkType: hard + "prelude-ls@npm:^1.2.1": version: 1.2.1 resolution: "prelude-ls@npm:1.2.1" @@ -5847,6 +6156,16 @@ __metadata: languageName: node linkType: hard +"query-ast@npm:^1.0.3": + version: 1.0.5 + resolution: "query-ast@npm:1.0.5" + dependencies: + invariant: 2.2.4 + lodash: ^4.17.21 + checksum: 4b7ae79bc907d0614c8d306d77fc82a19d40f5900bace286943839b875d84a52aa4993a73fdb8f4e989461b88474c47a60a48c7a42964b53253d5abe1452e9ad + languageName: node + linkType: hard + "queue-microtask@npm:^1.2.2": version: 1.2.3 resolution: "queue-microtask@npm:1.2.3" @@ -5906,6 +6225,15 @@ __metadata: languageName: node linkType: hard +"readdirp@npm:^3.5.0, readdirp@npm:~3.6.0": + version: 3.6.0 + resolution: "readdirp@npm:3.6.0" + dependencies: + picomatch: ^2.2.1 + checksum: 1ced032e6e45670b6d7352d71d21ce7edf7b9b928494dcaba6f11fba63180d9da6cd7061ebc34175ffda6ff529f481818c962952004d273178acd70f7059b320 + languageName: node + linkType: hard + "regexp.prototype.flags@npm:^1.4.3": version: 1.4.3 resolution: "regexp.prototype.flags@npm:1.4.3" @@ -5959,6 +6287,13 @@ __metadata: languageName: node linkType: hard +"require-package-name@npm:^2.0.1": + version: 2.0.1 + resolution: "require-package-name@npm:2.0.1" + checksum: 00f4e9e467ebe2bbced2b4198a165de11c83b5ee9f4c20b05a8782659b92bcb544dbd50be9a3eed746d05ecd875453e258c079eb3a79604b50a27cf8ab0798b5 + languageName: node + linkType: hard + "resolve-cwd@npm:^3.0.0": version: 3.0.0 resolution: "resolve-cwd@npm:3.0.0" @@ -5989,7 +6324,7 @@ __metadata: languageName: node linkType: hard -"resolve@npm:^1.10.1, resolve@npm:^1.20.0, resolve@npm:^1.22.0": +"resolve@npm:^1.10.1, resolve@npm:^1.18.1, resolve@npm:^1.20.0, resolve@npm:^1.22.0": version: 1.22.1 resolution: "resolve@npm:1.22.1" dependencies: @@ -6002,7 +6337,7 @@ __metadata: languageName: node linkType: hard -"resolve@patch:resolve@^1.10.1#~builtin, resolve@patch:resolve@^1.20.0#~builtin, resolve@patch:resolve@^1.22.0#~builtin": +"resolve@patch:resolve@^1.10.1#~builtin, resolve@patch:resolve@^1.18.1#~builtin, resolve@patch:resolve@^1.20.0#~builtin, resolve@patch:resolve@^1.22.0#~builtin": version: 1.22.1 resolution: "resolve@patch:resolve@npm%3A1.22.1#~builtin::version=1.22.1&hash=07638b" dependencies: @@ -6111,6 +6446,19 @@ __metadata: languageName: node linkType: hard +"sass@npm:^1.29.0": + version: 1.58.3 + resolution: "sass@npm:1.58.3" + dependencies: + chokidar: ">=3.0.0 <4.0.0" + immutable: ^4.0.0 + source-map-js: ">=0.6.2 <2.0.0" + bin: + sass: sass.js + checksum: 35a2b98c037ef80fdc93c9b0be846e6ccc7d75596351a37ee79c397e66666d0a754c52c4696e746c0aff32327471e185343ca349e998a58340411adc9d0489a5 + languageName: node + linkType: hard + "scrypt-js@npm:^3.0.0, scrypt-js@npm:^3.0.1": version: 3.0.1 resolution: "scrypt-js@npm:3.0.1" @@ -6118,6 +6466,16 @@ __metadata: languageName: node linkType: hard +"scss-parser@npm:^1.0.4": + version: 1.0.6 + resolution: "scss-parser@npm:1.0.6" + dependencies: + invariant: 2.2.4 + lodash: 4.17.21 + checksum: f1424d73e9c6aec006df16da7222a590efc3ee9b2abb622caffb5e19ed029baf66cf0d2d7aaad1e3d84e5d7f75cf7a3f761570341f26b318b499b08a7e5cd91c + languageName: node + linkType: hard + "secp256k1@npm:^4.0.1": version: 4.0.2 resolution: "secp256k1@npm:4.0.2" @@ -6130,6 +6488,13 @@ __metadata: languageName: node linkType: hard +"semver-compare@npm:^1.0.0": + version: 1.0.0 + resolution: "semver-compare@npm:1.0.0" + checksum: dd1d7e2909744cf2cf71864ac718efc990297f9de2913b68e41a214319e70174b1d1793ac16e31183b128c2b9812541300cb324db8168e6cf6b570703b171c68 + languageName: node + linkType: hard + "semver@npm:7.x, semver@npm:^7.3.2, semver@npm:^7.3.5, semver@npm:^7.3.7, semver@npm:^7.3.8": version: 7.3.8 resolution: "semver@npm:7.3.8" @@ -6301,6 +6666,13 @@ __metadata: languageName: node linkType: hard +"source-map-js@npm:>=0.6.2 <2.0.0, source-map-js@npm:^1.0.2": + version: 1.0.2 + resolution: "source-map-js@npm:1.0.2" + checksum: c049a7fc4deb9a7e9b481ae3d424cc793cb4845daa690bc5a05d428bf41bf231ced49b4cf0c9e77f9d42fdb3d20d6187619fc586605f5eabe995a316da8d377c + languageName: node + linkType: hard + "source-map-support@npm:0.5.13": version: 0.5.13 resolution: "source-map-support@npm:0.5.13" @@ -6325,6 +6697,13 @@ __metadata: languageName: node linkType: hard +"sourcemap-codec@npm:^1.4.8": + version: 1.4.8 + resolution: "sourcemap-codec@npm:1.4.8" + checksum: b57981c05611afef31605732b598ccf65124a9fcb03b833532659ac4d29ac0f7bfacbc0d6c5a28a03e84c7510e7e556d758d0bb57786e214660016fb94279316 + languageName: node + linkType: hard + "spdx-exceptions@npm:^2.1.0": version: 2.2.0 resolution: "spdx-exceptions@npm:2.2.0" @@ -7059,6 +7438,13 @@ __metadata: languageName: node linkType: hard +"yaml@npm:^1.10.0": + version: 1.10.2 + resolution: "yaml@npm:1.10.2" + checksum: ce4ada136e8a78a0b08dc10b4b900936912d15de59905b2bf415b4d33c63df1d555d23acb2a41b23cf9fb5da41c256441afca3d6509de7247daa062fd2c5ea5f + languageName: node + linkType: hard + "yargs-parser@npm:^20.2.2": version: 20.2.9 resolution: "yargs-parser@npm:20.2.9" @@ -7073,7 +7459,7 @@ __metadata: languageName: node linkType: hard -"yargs@npm:^16.2.0": +"yargs@npm:^16.1.0, yargs@npm:^16.2.0": version: 16.2.0 resolution: "yargs@npm:16.2.0" dependencies: From 9ccd7317f433b7fd2844d6f8d98fad0a1e6d3cb3 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed, 1 Mar 2023 22:34:20 -0300 Subject: [PATCH 038/109] Update dependencies --- package.json | 3 +- yarn.lock | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index d94476a0..f9e34f06 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "lint:eslint": "eslint . --cache --ext js,ts", "lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write", "lint:misc": "prettier '**/*.json' '**/*.md' '!CHANGELOG.md' '**/*.yml' '!.yarnrc.yml' --ignore-path .gitignore --no-error-on-unmatched-pattern", - "test": "jest && jest-it-up" + "test": "jest" }, "dependencies": { "@metamask/browser-passworder": "^4.0.2", @@ -63,6 +63,7 @@ "eslint-plugin-prettier": "^4.2.1", "ethereumjs-wallet": "^1.0.1", "jest": "^29.0.0", + "jest-it-up": "^2.1.0", "prettier": "^2.8.1", "prettier-plugin-packagejson": "^2.3.0", "sinon": "^11.1.1", diff --git a/yarn.lock b/yarn.lock index b17a0c8f..405ceef7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -632,6 +632,44 @@ __metadata: languageName: node linkType: hard +"@inquirer/confirm@npm:^0.0.14-alpha.0": + version: 0.0.14-alpha.0 + resolution: "@inquirer/confirm@npm:0.0.14-alpha.0" + dependencies: + "@inquirer/core": ^0.0.15-alpha.0 + "@inquirer/input": ^0.0.15-alpha.0 + chalk: ^4.1.1 + checksum: 84daf47030318e0adf6eeef85388e341f6f68c0c06c0d1d329cb6185f6d21abf74c3124102bf62f4f42145c8dc9193d719209e3759987a1bdbcfb88139b9936c + languageName: node + linkType: hard + +"@inquirer/core@npm:^0.0.15-alpha.0": + version: 0.0.15-alpha.0 + resolution: "@inquirer/core@npm:0.0.15-alpha.0" + dependencies: + ansi-escapes: ^4.2.1 + chalk: ^4.1.1 + cli-spinners: ^2.6.0 + cli-width: ^3.0.0 + lodash: ^4.17.21 + mute-stream: ^0.0.8 + run-async: ^2.3.0 + string-width: ^4.1.0 + strip-ansi: ^6.0.0 + checksum: 26a94a8db80e57f926c889b5730c6c9a0f18d6bf1e6dbfb68eaa6bcda33550db66118ce6afd9e91130ea2e4da42b6d7236b94c16fbab931ed04b4f442b9a5c78 + languageName: node + linkType: hard + +"@inquirer/input@npm:^0.0.15-alpha.0": + version: 0.0.15-alpha.0 + resolution: "@inquirer/input@npm:0.0.15-alpha.0" + dependencies: + "@inquirer/core": ^0.0.15-alpha.0 + chalk: ^4.1.1 + checksum: c294b2fa100e2955e271b1b0590b5f360c65c560d653f39554cd381f145fdf13be9ea2c3c069d39a71f84fc3c8ba20d9d78a0b210f8cb5533d138567029e28ee + languageName: node + linkType: hard + "@istanbuljs/load-nyc-config@npm:^1.0.0": version: 1.1.0 resolution: "@istanbuljs/load-nyc-config@npm:1.1.0" @@ -1080,6 +1118,7 @@ __metadata: eslint-plugin-prettier: ^4.2.1 ethereumjs-wallet: ^1.0.1 jest: ^29.0.0 + jest-it-up: ^2.1.0 obs-store: ^4.0.3 prettier: ^2.8.1 prettier-plugin-packagejson: ^2.3.0 @@ -1944,6 +1983,13 @@ __metadata: languageName: node linkType: hard +"ansi-colors@npm:^4.1.0": + version: 4.1.3 + resolution: "ansi-colors@npm:4.1.3" + checksum: a9c2ec842038a1fabc7db9ece7d3177e2fe1c5dc6f0c51ecfbf5f39911427b89c00b5dc6b8bd95f82a26e9b16aaae2e83d45f060e98070ce4d1333038edceb0e + languageName: node + linkType: hard + "ansi-escapes@npm:^4.2.1": version: 4.3.2 resolution: "ansi-escapes@npm:4.3.2" @@ -2502,6 +2548,16 @@ __metadata: languageName: node linkType: hard +"chalk@npm:^4.1.1": + version: 4.1.2 + resolution: "chalk@npm:4.1.2" + dependencies: + ansi-styles: ^4.1.0 + supports-color: ^7.1.0 + checksum: fe75c9d5c76a7a98d45495b91b2172fa3b7a09e0cc9370e5c8feb1c567b85c4288e2b3fded7cfdd7359ac28d6b3844feb8b82b8686842e93d23c827c417e83fc + languageName: node + linkType: hard + "char-regex@npm:^1.0.2": version: 1.0.2 resolution: "char-regex@npm:1.0.2" @@ -2566,6 +2622,20 @@ __metadata: languageName: node linkType: hard +"cli-spinners@npm:^2.6.0": + version: 2.7.0 + resolution: "cli-spinners@npm:2.7.0" + checksum: a9afaf73f58d1f951fb23742f503631b3cf513f43f4c7acb1b640100eb76bfa16efbcd1994d149ffc6603a6d75dd3d4a516a76f125f90dce437de9b16fd0ee6f + languageName: node + linkType: hard + +"cli-width@npm:^3.0.0": + version: 3.0.0 + resolution: "cli-width@npm:3.0.0" + checksum: 4c94af3769367a70e11ed69aa6095f1c600c0ff510f3921ab4045af961820d57c0233acfa8b6396037391f31b4c397e1f614d234294f979ff61430a6c166c3f6 + languageName: node + linkType: hard + "cliui@npm:^7.0.2": version: 7.0.4 resolution: "cliui@npm:7.0.4" @@ -2659,6 +2729,13 @@ __metadata: languageName: node linkType: hard +"commander@npm:^9.0.0": + version: 9.5.0 + resolution: "commander@npm:9.5.0" + checksum: c7a3e27aa59e913b54a1bafd366b88650bc41d6651f0cbe258d4ff09d43d6a7394232a4dadd0bf518b3e696fdf595db1028a0d82c785b88bd61f8a440cecfade + languageName: node + linkType: hard + "comment-parser@npm:1.3.1": version: 1.3.1 resolution: "comment-parser@npm:1.3.1" @@ -4737,6 +4814,19 @@ __metadata: languageName: node linkType: hard +"jest-it-up@npm:^2.1.0": + version: 2.1.0 + resolution: "jest-it-up@npm:2.1.0" + dependencies: + "@inquirer/confirm": ^0.0.14-alpha.0 + ansi-colors: ^4.1.0 + commander: ^9.0.0 + bin: + jest-it-up: bin/jest-it-up + checksum: 3c1587aca43c8d7c84ae31bcf984e49e87ff13d0f2a50f25e25ec8657794bf35577a2b6d8a302db77d97d4033e9543065095e166d9212b7d3ba1b76f5ffcf057 + languageName: node + linkType: hard + "jest-leak-detector@npm:^29.4.3": version: 29.4.3 resolution: "jest-leak-detector@npm:29.4.3" @@ -5569,6 +5659,13 @@ __metadata: languageName: node linkType: hard +"mute-stream@npm:^0.0.8": + version: 0.0.8 + resolution: "mute-stream@npm:0.0.8" + checksum: ff48d251fc3f827e5b1206cda0ffdaec885e56057ee86a3155e1951bc940fd5f33531774b1cc8414d7668c10a8907f863f6561875ee6e8768931a62121a531a1 + languageName: node + linkType: hard + "nanoid@npm:^3.3.4": version: 3.3.4 resolution: "nanoid@npm:3.3.4" @@ -6396,6 +6493,13 @@ __metadata: languageName: node linkType: hard +"run-async@npm:^2.3.0": + version: 2.4.1 + resolution: "run-async@npm:2.4.1" + checksum: a2c88aa15df176f091a2878eb840e68d0bdee319d8d97bbb89112223259cebecb94bc0defd735662b83c2f7a30bed8cddb7d1674eb48ae7322dc602b22d03797 + languageName: node + linkType: hard + "run-parallel@npm:^1.1.9": version: 1.2.0 resolution: "run-parallel@npm:1.2.0" From 0dbb136e3a40384b25341b67e81023e4303790a4 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed, 1 Mar 2023 22:44:05 -0300 Subject: [PATCH 039/109] Update dependencies --- package.json | 4 +- src/index.ts | 2 + yarn.lock | 172 +++++++-------------------------------------------- 3 files changed, 24 insertions(+), 154 deletions(-) diff --git a/package.json b/package.json index f9e34f06..4a98c767 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,6 @@ "@metamask/eslint-config-nodejs": "^11.1.0", "@metamask/eslint-config-typescript": "^11.1.0", "@types/jest": "^29.4.0", - "@types/mocha": "^5.0.0", "@types/sinon": "^10.0.13", "@typescript-eslint/eslint-plugin": "^5.53.0", "@typescript-eslint/parser": "^5.53.0", @@ -63,10 +62,9 @@ "eslint-plugin-prettier": "^4.2.1", "ethereumjs-wallet": "^1.0.1", "jest": "^29.0.0", - "jest-it-up": "^2.1.0", "prettier": "^2.8.1", "prettier-plugin-packagejson": "^2.3.0", - "sinon": "^11.1.1", + "sinon": "15.0.1", "ts-jest": "^29.0.3", "ts-node": "^10.7.0", "typedoc": "^0.23.15", diff --git a/src/index.ts b/src/index.ts index 9b98ad6f..88f70784 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1 +1,3 @@ export * from './KeyringController'; + +export type { KeyringType, MessageParams } from './types'; diff --git a/yarn.lock b/yarn.lock index 405ceef7..8d6da74c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -632,44 +632,6 @@ __metadata: languageName: node linkType: hard -"@inquirer/confirm@npm:^0.0.14-alpha.0": - version: 0.0.14-alpha.0 - resolution: "@inquirer/confirm@npm:0.0.14-alpha.0" - dependencies: - "@inquirer/core": ^0.0.15-alpha.0 - "@inquirer/input": ^0.0.15-alpha.0 - chalk: ^4.1.1 - checksum: 84daf47030318e0adf6eeef85388e341f6f68c0c06c0d1d329cb6185f6d21abf74c3124102bf62f4f42145c8dc9193d719209e3759987a1bdbcfb88139b9936c - languageName: node - linkType: hard - -"@inquirer/core@npm:^0.0.15-alpha.0": - version: 0.0.15-alpha.0 - resolution: "@inquirer/core@npm:0.0.15-alpha.0" - dependencies: - ansi-escapes: ^4.2.1 - chalk: ^4.1.1 - cli-spinners: ^2.6.0 - cli-width: ^3.0.0 - lodash: ^4.17.21 - mute-stream: ^0.0.8 - run-async: ^2.3.0 - string-width: ^4.1.0 - strip-ansi: ^6.0.0 - checksum: 26a94a8db80e57f926c889b5730c6c9a0f18d6bf1e6dbfb68eaa6bcda33550db66118ce6afd9e91130ea2e4da42b6d7236b94c16fbab931ed04b4f442b9a5c78 - languageName: node - linkType: hard - -"@inquirer/input@npm:^0.0.15-alpha.0": - version: 0.0.15-alpha.0 - resolution: "@inquirer/input@npm:0.0.15-alpha.0" - dependencies: - "@inquirer/core": ^0.0.15-alpha.0 - chalk: ^4.1.1 - checksum: c294b2fa100e2955e271b1b0590b5f360c65c560d653f39554cd381f145fdf13be9ea2c3c069d39a71f84fc3c8ba20d9d78a0b210f8cb5533d138567029e28ee - languageName: node - linkType: hard - "@istanbuljs/load-nyc-config@npm:^1.0.0": version: 1.1.0 resolution: "@istanbuljs/load-nyc-config@npm:1.1.0" @@ -1104,7 +1066,6 @@ __metadata: "@metamask/eth-simple-keyring": ^5.0.0 "@metamask/utils": 4.0.0 "@types/jest": ^29.4.0 - "@types/mocha": ^5.0.0 "@types/sinon": ^10.0.13 "@typescript-eslint/eslint-plugin": ^5.53.0 "@typescript-eslint/parser": ^5.53.0 @@ -1118,11 +1079,10 @@ __metadata: eslint-plugin-prettier: ^4.2.1 ethereumjs-wallet: ^1.0.1 jest: ^29.0.0 - jest-it-up: ^2.1.0 obs-store: ^4.0.3 prettier: ^2.8.1 prettier-plugin-packagejson: ^2.3.0 - sinon: ^11.1.1 + sinon: 15.0.1 ts-jest: ^29.0.3 ts-node: ^10.7.0 typedoc: ^0.23.15 @@ -1310,15 +1270,6 @@ __metadata: languageName: node linkType: hard -"@sinonjs/commons@npm:^1.6.0, @sinonjs/commons@npm:^1.7.0, @sinonjs/commons@npm:^1.8.3": - version: 1.8.3 - resolution: "@sinonjs/commons@npm:1.8.3" - dependencies: - type-detect: 4.0.8 - checksum: 6159726db5ce6bf9f2297f8427f7ca5b3dff45b31e5cee23496f1fa6ef0bb4eab878b23fb2c5e6446381f6a66aba4968ef2fc255c1180d753d4b8c271636a2e5 - languageName: node - linkType: hard - "@sinonjs/commons@npm:^2.0.0": version: 2.0.0 resolution: "@sinonjs/commons@npm:2.0.0" @@ -1328,7 +1279,7 @@ __metadata: languageName: node linkType: hard -"@sinonjs/fake-timers@npm:^10.0.2": +"@sinonjs/fake-timers@npm:10.0.2, @sinonjs/fake-timers@npm:^10.0.2": version: 10.0.2 resolution: "@sinonjs/fake-timers@npm:10.0.2" dependencies: @@ -1337,23 +1288,14 @@ __metadata: languageName: node linkType: hard -"@sinonjs/fake-timers@npm:^7.0.4, @sinonjs/fake-timers@npm:^7.1.0": - version: 7.1.2 - resolution: "@sinonjs/fake-timers@npm:7.1.2" - dependencies: - "@sinonjs/commons": ^1.7.0 - checksum: c84773d7973edad5511a31d2cc75023447b5cf714a84de9bb50eda45dda88a0d3bd2c30bf6e6e936da50a048d5352e2151c694e13e59b97d187ba1f329e9a00c - languageName: node - linkType: hard - -"@sinonjs/samsam@npm:^6.0.2": - version: 6.0.2 - resolution: "@sinonjs/samsam@npm:6.0.2" +"@sinonjs/samsam@npm:^7.0.1": + version: 7.0.1 + resolution: "@sinonjs/samsam@npm:7.0.1" dependencies: - "@sinonjs/commons": ^1.6.0 + "@sinonjs/commons": ^2.0.0 lodash.get: ^4.4.2 type-detect: ^4.0.8 - checksum: bc1514edf15f4fa42a1bf27024b15f87654deb2999045c0e427659ff3c734eba44661fceae3624be23cc15ee9c6ddafe5209af2192845c6b267350b54eed1495 + checksum: 291efb158d54c67dee23ddabcb28873d22063449b692aaa3b2a4f1826d2f79d38695574063c92e9c17573cc805cd6acbf0ab0c66c9f3aed7afd0f12a2b905615 languageName: node linkType: hard @@ -1540,13 +1482,6 @@ __metadata: languageName: node linkType: hard -"@types/mocha@npm:^5.0.0": - version: 5.2.7 - resolution: "@types/mocha@npm:5.2.7" - checksum: 446e64292f37f4eac9221161f4c1026dd4a0dbeea0f16c4617227fcf5a1286b53d97e36a32ff7cb3a0435ab78791dd43e9ac1006f92abedb47d7d1d7636cb55c - languageName: node - linkType: hard - "@types/ms@npm:*": version: 0.7.31 resolution: "@types/ms@npm:0.7.31" @@ -1983,13 +1918,6 @@ __metadata: languageName: node linkType: hard -"ansi-colors@npm:^4.1.0": - version: 4.1.3 - resolution: "ansi-colors@npm:4.1.3" - checksum: a9c2ec842038a1fabc7db9ece7d3177e2fe1c5dc6f0c51ecfbf5f39911427b89c00b5dc6b8bd95f82a26e9b16aaae2e83d45f060e98070ce4d1333038edceb0e - languageName: node - linkType: hard - "ansi-escapes@npm:^4.2.1": version: 4.3.2 resolution: "ansi-escapes@npm:4.3.2" @@ -2548,16 +2476,6 @@ __metadata: languageName: node linkType: hard -"chalk@npm:^4.1.1": - version: 4.1.2 - resolution: "chalk@npm:4.1.2" - dependencies: - ansi-styles: ^4.1.0 - supports-color: ^7.1.0 - checksum: fe75c9d5c76a7a98d45495b91b2172fa3b7a09e0cc9370e5c8feb1c567b85c4288e2b3fded7cfdd7359ac28d6b3844feb8b82b8686842e93d23c827c417e83fc - languageName: node - linkType: hard - "char-regex@npm:^1.0.2": version: 1.0.2 resolution: "char-regex@npm:1.0.2" @@ -2622,20 +2540,6 @@ __metadata: languageName: node linkType: hard -"cli-spinners@npm:^2.6.0": - version: 2.7.0 - resolution: "cli-spinners@npm:2.7.0" - checksum: a9afaf73f58d1f951fb23742f503631b3cf513f43f4c7acb1b640100eb76bfa16efbcd1994d149ffc6603a6d75dd3d4a516a76f125f90dce437de9b16fd0ee6f - languageName: node - linkType: hard - -"cli-width@npm:^3.0.0": - version: 3.0.0 - resolution: "cli-width@npm:3.0.0" - checksum: 4c94af3769367a70e11ed69aa6095f1c600c0ff510f3921ab4045af961820d57c0233acfa8b6396037391f31b4c397e1f614d234294f979ff61430a6c166c3f6 - languageName: node - linkType: hard - "cliui@npm:^7.0.2": version: 7.0.4 resolution: "cliui@npm:7.0.4" @@ -2729,13 +2633,6 @@ __metadata: languageName: node linkType: hard -"commander@npm:^9.0.0": - version: 9.5.0 - resolution: "commander@npm:9.5.0" - checksum: c7a3e27aa59e913b54a1bafd366b88650bc41d6651f0cbe258d4ff09d43d6a7394232a4dadd0bf518b3e696fdf595db1028a0d82c785b88bd61f8a440cecfade - languageName: node - linkType: hard - "comment-parser@npm:1.3.1": version: 1.3.1 resolution: "comment-parser@npm:1.3.1" @@ -4814,19 +4711,6 @@ __metadata: languageName: node linkType: hard -"jest-it-up@npm:^2.1.0": - version: 2.1.0 - resolution: "jest-it-up@npm:2.1.0" - dependencies: - "@inquirer/confirm": ^0.0.14-alpha.0 - ansi-colors: ^4.1.0 - commander: ^9.0.0 - bin: - jest-it-up: bin/jest-it-up - checksum: 3c1587aca43c8d7c84ae31bcf984e49e87ff13d0f2a50f25e25ec8657794bf35577a2b6d8a302db77d97d4033e9543065095e166d9212b7d3ba1b76f5ffcf057 - languageName: node - linkType: hard - "jest-leak-detector@npm:^29.4.3": version: 29.4.3 resolution: "jest-leak-detector@npm:29.4.3" @@ -5659,13 +5543,6 @@ __metadata: languageName: node linkType: hard -"mute-stream@npm:^0.0.8": - version: 0.0.8 - resolution: "mute-stream@npm:0.0.8" - checksum: ff48d251fc3f827e5b1206cda0ffdaec885e56057ee86a3155e1951bc940fd5f33531774b1cc8414d7668c10a8907f863f6561875ee6e8768931a62121a531a1 - languageName: node - linkType: hard - "nanoid@npm:^3.3.4": version: 3.3.4 resolution: "nanoid@npm:3.3.4" @@ -5696,16 +5573,16 @@ __metadata: languageName: node linkType: hard -"nise@npm:^5.1.0": - version: 5.1.0 - resolution: "nise@npm:5.1.0" +"nise@npm:^5.1.2": + version: 5.1.4 + resolution: "nise@npm:5.1.4" dependencies: - "@sinonjs/commons": ^1.7.0 - "@sinonjs/fake-timers": ^7.0.4 + "@sinonjs/commons": ^2.0.0 + "@sinonjs/fake-timers": ^10.0.2 "@sinonjs/text-encoding": ^0.7.1 just-extend: ^4.0.2 path-to-regexp: ^1.7.0 - checksum: e3843cc125163ce99b7fb0328edf427b981be32c6c719684582cf0a46fb5206173835a9a14dedac3c4833e415ab0e0493f9f4d4163572a3a0c95db39b093166d + checksum: bc57c10eaec28a6a7ddfb2e1e9b21d5e1fe22710e514f8858ae477cf9c7e9c891475674d5241519193403db43d16c3675f4207bc094a7a27b7e4f56584a78c1b languageName: node linkType: hard @@ -6493,13 +6370,6 @@ __metadata: languageName: node linkType: hard -"run-async@npm:^2.3.0": - version: 2.4.1 - resolution: "run-async@npm:2.4.1" - checksum: a2c88aa15df176f091a2878eb840e68d0bdee319d8d97bbb89112223259cebecb94bc0defd735662b83c2f7a30bed8cddb7d1674eb48ae7322dc602b22d03797 - languageName: node - linkType: hard - "run-parallel@npm:^1.1.9": version: 1.2.0 resolution: "run-parallel@npm:1.2.0" @@ -6691,17 +6561,17 @@ __metadata: languageName: node linkType: hard -"sinon@npm:^11.1.1": - version: 11.1.1 - resolution: "sinon@npm:11.1.1" +"sinon@npm:15.0.1": + version: 15.0.1 + resolution: "sinon@npm:15.0.1" dependencies: - "@sinonjs/commons": ^1.8.3 - "@sinonjs/fake-timers": ^7.1.0 - "@sinonjs/samsam": ^6.0.2 + "@sinonjs/commons": ^2.0.0 + "@sinonjs/fake-timers": 10.0.2 + "@sinonjs/samsam": ^7.0.1 diff: ^5.0.0 - nise: ^5.1.0 + nise: ^5.1.2 supports-color: ^7.2.0 - checksum: 1c060b8d4c7b6307c67a06f96409e338fb4e23d4046557ec3ebd40836060c1f7dd0ac376069eb110799d9843bda66354edb45042d11eeff4cfe8a6cef36c95be + checksum: 4b5acff291b4650cf736bf45fc9eceed44dceca63b663cbd55926dd688fe8e9baa4b4629e296ee5d5b64245aedec5c540fea0416b8bb35bccfb98ca9e9ed87f3 languageName: node linkType: hard From 84b4e2e5fcf31112c991a8ff1929aba1822dbb48 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 2 Mar 2023 10:56:22 -0300 Subject: [PATCH 040/109] Improve types --- src/KeyringController.ts | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index d9fa9c76..21af8521 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -6,6 +6,7 @@ import type { Hex, Json, Bytes, + Keyring, KeyringClass, Transaction, SignedTransaction, @@ -37,13 +38,13 @@ function stripHexPrefix(address: Hex | string): string { } class KeyringController extends EventEmitter { - keyringBuilders: { (): any; type: any }[]; + keyringBuilders: { (): Keyring; type: string }[]; - store: any; + store: typeof ObservableStore; - memStore: any; + memStore: typeof ObservableStore; - encryptor: any; + encryptor: typeof encryptor; keyrings: ExtendedKeyring[]; @@ -757,6 +758,9 @@ class KeyringController extends EventEmitter { vault = JSON.stringify(vaultJSON); } } else { + if (typeof this.password !== 'string') { + throw new Error('KeyringController: password must be of type string'); + } vault = await this.encryptor.encrypt(this.password, serializedKeyrings); } @@ -823,6 +827,12 @@ class KeyringController extends EventEmitter { throw new Error('Encryption key and salt provided are expired'); } + if (typeof encryptionKey !== 'string') { + throw new Error( + 'KeyringController: encryptionKey must be of type string', + ); + } + const key = await this.encryptor.importKey(encryptionKey); vault = await this.encryptor.decryptWithKey(key, parsedEncryptedVault); @@ -834,6 +844,10 @@ class KeyringController extends EventEmitter { }); } } else { + if (typeof password !== 'string') { + throw new Error('KeyringController: password must be of type string'); + } + vault = await this.encryptor.decrypt(password, encryptedVault); this.password = password; } From a319df4b2086e07267d589bbfc2e4b550965188f Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 2 Mar 2023 11:26:34 -0300 Subject: [PATCH 041/109] Improve types --- src/KeyringController.ts | 2 +- src/types.ts | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index 21af8521..9bae9f4a 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -44,7 +44,7 @@ class KeyringController extends EventEmitter { memStore: typeof ObservableStore; - encryptor: typeof encryptor; + encryptor: any; keyrings: ExtendedKeyring[]; diff --git a/src/types.ts b/src/types.ts index 2356f8e1..dc23acd7 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,7 +1,5 @@ import type { Hex, Json, Keyring, Eip1024EncryptedData } from '@metamask/utils'; -export type IKeyringController = any; - export type MessageParams = { from: Hex | string; data: Hex | string | Eip1024EncryptedData | Record[]; From 9dd451b42953afcaa2bff592a041fbade3d42c21 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 2 Mar 2023 12:18:02 -0300 Subject: [PATCH 042/109] Update errors --- src/KeyringController.ts | 19 +++++++++++-------- src/constants.ts | 0 2 files changed, 11 insertions(+), 8 deletions(-) create mode 100644 src/constants.ts diff --git a/src/KeyringController.ts b/src/KeyringController.ts index 9bae9f4a..19c8ecaf 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -17,6 +17,7 @@ import type { import { EventEmitter } from 'events'; import ObservableStore from 'obs-store'; +import { hexPrefix } from './constants'; import { MessageParams, KeyringType, ExtendedKeyring } from './types'; const defaultKeyringBuilders = [ @@ -31,7 +32,7 @@ const defaultKeyringBuilders = [ * @returns The address without a hex prefix. */ function stripHexPrefix(address: Hex | string): string { - if (address.startsWith('0x')) { + if (address.startsWith(hexPrefix)) { return address.slice(2); } return address; @@ -54,10 +55,6 @@ class KeyringController extends EventEmitter { password?: string | undefined; - // - // PUBLIC METHODS - // - constructor(opts: any) { super(); const initState = opts.initState || {}; @@ -138,7 +135,9 @@ class KeyringController extends EventEmitter { seedPhrase: Uint8Array | string | number[], ): Promise { if (typeof password !== 'string') { - throw new Error('Password must be text.'); + throw new TypeError( + 'KeyringController - Password must be of type string.', + ); } this.password = password; @@ -759,7 +758,9 @@ class KeyringController extends EventEmitter { } } else { if (typeof this.password !== 'string') { - throw new Error('KeyringController: password must be of type string'); + throw new TypeError( + 'KeyringController: password must be of type string', + ); } vault = await this.encryptor.encrypt(this.password, serializedKeyrings); } @@ -845,7 +846,9 @@ class KeyringController extends EventEmitter { } } else { if (typeof password !== 'string') { - throw new Error('KeyringController: password must be of type string'); + throw new TypeError( + 'KeyringController: password must be of type string', + ); } vault = await this.encryptor.decrypt(password, encryptedVault); diff --git a/src/constants.ts b/src/constants.ts new file mode 100644 index 00000000..e69de29b From 85aa914ad1f5e392b3ede5ea18ef8eb9e3741cb3 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 2 Mar 2023 12:18:24 -0300 Subject: [PATCH 043/109] Add constants file --- src/constants.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/constants.ts b/src/constants.ts index e69de29b..7da62a37 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -0,0 +1 @@ +export const hexPrefix = '0x'; From c80f3d3d464557f3160c1a364819def4a0297496 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Mon, 6 Mar 2023 12:03:42 -0300 Subject: [PATCH 044/109] Update error messages --- src/KeyringController.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/KeyringController.test.ts b/src/KeyringController.test.ts index 0601e44e..5b436eb8 100644 --- a/src/KeyringController.test.ts +++ b/src/KeyringController.test.ts @@ -189,7 +189,7 @@ describe('KeyringController', () => { 12 as any, walletTwoSeedWords, ), - ).rejects.toThrow('Password must be text.'); + ).rejects.toThrow('KeyringController - Password must be of type string.'); }); it('throws error if mnemonic passed is invalid', async function () { From 8b930ff08bf69181710a1ff54cb747724ac7f6eb Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Mon, 6 Mar 2023 12:07:06 -0300 Subject: [PATCH 045/109] Update State --- src/KeyringController.ts | 48 ++++++++++++++++++++-------------------- src/types.ts | 2 ++ 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index 19c8ecaf..11447767 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -18,7 +18,7 @@ import { EventEmitter } from 'events'; import ObservableStore from 'obs-store'; import { hexPrefix } from './constants'; -import { MessageParams, KeyringType, ExtendedKeyring } from './types'; +import { State, MessageParams, KeyringType, ExtendedKeyring } from './types'; const defaultKeyringBuilders = [ keyringBuilderFactory(SimpleKeyring), @@ -41,19 +41,19 @@ function stripHexPrefix(address: Hex | string): string { class KeyringController extends EventEmitter { keyringBuilders: { (): Keyring; type: string }[]; - store: typeof ObservableStore; + public store: typeof ObservableStore; - memStore: typeof ObservableStore; + public memStore: typeof ObservableStore; - encryptor: any; + public encryptor: any; - keyrings: ExtendedKeyring[]; + public keyrings: ExtendedKeyring[]; - cacheEncryptionKey: boolean; + public cacheEncryptionKey: boolean; - unsupportedKeyrings: any[]; + public unsupportedKeyrings: any[]; - password?: string | undefined; + public password?: string | undefined; constructor(opts: any) { super(); @@ -92,7 +92,7 @@ class KeyringController extends EventEmitter { * * @returns The controller state. */ - fullUpdate() { + #fullUpdate() { this.emit('update', this.memStore.getState()); return this.memStore.getState(); } @@ -109,12 +109,12 @@ class KeyringController extends EventEmitter { * @param password - The password to encrypt the vault with. * @returns A promise that resolves to the state. */ - async createNewVaultAndKeychain(password: string): Promise { + async createNewVaultAndKeychain(password: string): Promise { this.password = password; await this.#createFirstKeyTree(); this.#setUnlocked(); - return this.fullUpdate(); + return this.#fullUpdate(); } /** @@ -133,7 +133,7 @@ class KeyringController extends EventEmitter { async createNewVaultAndRestore( password: string, seedPhrase: Uint8Array | string | number[], - ): Promise { + ): Promise { if (typeof password !== 'string') { throw new TypeError( 'KeyringController - Password must be of type string.', @@ -157,7 +157,7 @@ class KeyringController extends EventEmitter { throw new Error('KeyringController - First Account not found.'); } this.#setUnlocked(); - return this.fullUpdate(); + return this.#fullUpdate(); } /** @@ -167,7 +167,7 @@ class KeyringController extends EventEmitter { * @fires KeyringController#lock * @returns A promise that resolves to the state. */ - async setLocked(): Promise { + async setLocked(): Promise { delete this.password; // set locked @@ -181,7 +181,7 @@ class KeyringController extends EventEmitter { this.keyrings = []; await this.#updateMemStoreKeyrings(); this.emit('lock'); - return this.fullUpdate(); + return this.#fullUpdate(); } /** @@ -197,11 +197,11 @@ class KeyringController extends EventEmitter { * @param password - The keyring controller password. * @returns A promise that resolves to the state. */ - async submitPassword(password: string): Promise { + async submitPassword(password: string): Promise { this.keyrings = await this.unlockKeyrings(password); this.#setUnlocked(); - return this.fullUpdate(); + return this.#fullUpdate(); } /** @@ -225,7 +225,7 @@ class KeyringController extends EventEmitter { encryptionSalt, ); this.#setUnlocked(); - return this.fullUpdate(); + return this.#fullUpdate(); } /** @@ -260,7 +260,7 @@ class KeyringController extends EventEmitter { async addNewKeyring( type: string, opts?: Record, - ): Promise { + ): Promise> { const keyring = await this.#newKeyring( type, type === KeyringType.Simple && opts?.privateKeys @@ -283,7 +283,7 @@ class KeyringController extends EventEmitter { this.keyrings.push(keyring); await this.persistAllKeyrings(); - this.fullUpdate(); + this.#fullUpdate(); return keyring; } @@ -361,14 +361,14 @@ class KeyringController extends EventEmitter { * @param selectedKeyring - The currently selected keyring. * @returns A Promise that resolves to the state. */ - async addNewAccount(selectedKeyring: ExtendedKeyring): Promise { + async addNewAccount(selectedKeyring: Keyring): Promise { const accounts = await selectedKeyring.addAccounts(1); accounts.forEach((hexAccount: string) => { this.emit('newAccount', hexAccount); }); await this.persistAllKeyrings(); - return this.fullUpdate(); + return this.#fullUpdate(); } /** @@ -402,7 +402,7 @@ class KeyringController extends EventEmitter { * @param address - The address of the account to remove. * @returns A promise that resolves if the operation was successful. */ - async removeAccount(address: Hex): Promise { + async removeAccount(address: Hex): Promise { const keyring = await this.getKeyringForAccount(address); // Not all the keyrings support this, so we have to check @@ -422,7 +422,7 @@ class KeyringController extends EventEmitter { } await this.persistAllKeyrings(); - return this.fullUpdate(); + return this.#fullUpdate(); } // diff --git a/src/types.ts b/src/types.ts index dc23acd7..48cc3c3b 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,5 +1,7 @@ import type { Hex, Json, Keyring, Eip1024EncryptedData } from '@metamask/utils'; +export type State = Json; + export type MessageParams = { from: Hex | string; data: Hex | string | Eip1024EncryptedData | Record[]; From 4ed4fe2a44efd6a8d3a877c5d23c9f50cd381f71 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Mon, 6 Mar 2023 12:50:20 -0300 Subject: [PATCH 046/109] Update types, constants, and errors --- src/KeyringController.test.ts | 3 +- src/KeyringController.ts | 52 ++++++++++++++++++++--------------- src/constants.ts | 7 ++++- src/types.ts | 5 ---- 4 files changed, 38 insertions(+), 29 deletions(-) diff --git a/src/KeyringController.test.ts b/src/KeyringController.test.ts index 5b436eb8..1ded4475 100644 --- a/src/KeyringController.test.ts +++ b/src/KeyringController.test.ts @@ -6,8 +6,9 @@ import Wallet from 'ethereumjs-wallet'; import { restore, spy, stub, assert as sinonAssert } from 'sinon'; import { KeyringController, keyringBuilderFactory } from '.'; +import { KeyringType } from './constants'; import { mockEncryptor, KeyringMockWithInit } from './mocks'; -import { ExtendedKeyring, KeyringType } from './types'; +import { ExtendedKeyring } from './types'; const password = 'password123'; diff --git a/src/KeyringController.ts b/src/KeyringController.ts index 11447767..431cc16f 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -17,8 +17,8 @@ import type { import { EventEmitter } from 'events'; import ObservableStore from 'obs-store'; -import { hexPrefix } from './constants'; -import { State, MessageParams, KeyringType, ExtendedKeyring } from './types'; +import { HEX_PREFIX, KeyringType } from './constants'; +import { State, MessageParams, ExtendedKeyring } from './types'; const defaultKeyringBuilders = [ keyringBuilderFactory(SimpleKeyring), @@ -32,7 +32,7 @@ const defaultKeyringBuilders = [ * @returns The address without a hex prefix. */ function stripHexPrefix(address: Hex | string): string { - if (address.startsWith(hexPrefix)) { + if (address.startsWith(HEX_PREFIX)) { return address.slice(2); } return address; @@ -239,7 +239,9 @@ class KeyringController extends EventEmitter { async verifyPassword(password: string): Promise { const encryptedVault = this.store.getState().vault; if (!encryptedVault) { - throw new Error('Cannot unlock without a previous vault.'); + throw new Error( + 'KeyringController - Cannot unlock without a previous vault.', + ); } await this.encryptor.decrypt(password, encryptedVault); } @@ -340,7 +342,7 @@ class KeyringController extends EventEmitter { if (isIncluded) { throw new Error( - 'The account you are trying to import is a duplicate', + 'KeyringController - The account you are trying to import is a duplicate', ); } return newAccountArray; @@ -386,7 +388,7 @@ class KeyringController extends EventEmitter { const keyring = await this.getKeyringForAccount(address); if (!keyring.exportAccount) { throw new Error( - `The keyring for address ${address} does not support the method exportAccount.`, + `KeyringController - The keyring for address ${address} does not support the method exportAccount.`, ); } @@ -411,7 +413,7 @@ class KeyringController extends EventEmitter { this.emit('removedAccount', address); } else { throw new Error( - `Keyring ${keyring.type} doesn't support account removal operations`, + `KeyringController - Keyring ${keyring.type} doesn't support account removal operations`, ); } @@ -448,7 +450,7 @@ class KeyringController extends EventEmitter { const keyring = await this.getKeyringForAccount(address); if (!keyring.signTransaction) { throw new Error( - `The keyring for address ${address} does not support the method signTransaction.`, + `KeyringController - The keyring for address ${address} does not support the method signTransaction.`, ); } @@ -472,7 +474,7 @@ class KeyringController extends EventEmitter { const keyring = await this.getKeyringForAccount(address); if (!keyring.signMessage) { throw new Error( - `The keyring for address ${address} does not support the method signMessage.`, + `KeyringController - The keyring for address ${address} does not support the method signMessage.`, ); } @@ -497,7 +499,7 @@ class KeyringController extends EventEmitter { const keyring = await this.getKeyringForAccount(address); if (!keyring.signPersonalMessage) { throw new Error( - `The keyring for address ${address} does not support the method signPersonalMessage.`, + `KeyringController - The keyring for address ${address} does not support the method signPersonalMessage.`, ); } @@ -525,7 +527,7 @@ class KeyringController extends EventEmitter { const keyring = await this.getKeyringForAccount(address); if (!keyring.getEncryptionPublicKey) { throw new Error( - `The keyring for address ${address} does not support the method getEncryptionPublicKey.`, + `KeyringController - The keyring for address ${address} does not support the method getEncryptionPublicKey.`, ); } @@ -545,7 +547,7 @@ class KeyringController extends EventEmitter { const keyring = await this.getKeyringForAccount(address); if (!keyring.decryptMessage) { throw new Error( - `The keyring for address ${address} does not support the method decryptMessage.`, + `KeyringController - The keyring for address ${address} does not support the method decryptMessage.`, ); } @@ -571,7 +573,7 @@ class KeyringController extends EventEmitter { const keyring = await this.getKeyringForAccount(address); if (!keyring.signTypedData) { throw new Error( - `The keyring for address ${address} does not support the method signTypedData.`, + `KeyringController - The keyring for address ${address} does not support the method signTypedData.`, ); } @@ -594,7 +596,7 @@ class KeyringController extends EventEmitter { const keyring = await this.getKeyringForAccount(address); if (!keyring.getAppKeyAddress) { throw new Error( - `The keyring for address ${_address} does not support the method getAppKeyAddress.`, + `KeyringController - The keyring for address ${_address} does not support the method getAppKeyAddress.`, ); } @@ -620,7 +622,7 @@ class KeyringController extends EventEmitter { // eslint-disable-next-line no-restricted-syntax if (!keyring.exportAccount) { throw new Error( - `The keyring for address ${_address} does not support exporting.`, + `KeyringController - The keyring for address ${_address} does not support exporting.`, ); } return keyring.exportAccount(address, { withAppKeyOrigin: origin }); @@ -718,7 +720,7 @@ class KeyringController extends EventEmitter { if (!this.password && !encryptionKey) { throw new Error( - 'Cannot persist vault without password and encryption key', + 'KeyringController - Cannot persist vault without password and encryption key', ); } @@ -759,14 +761,16 @@ class KeyringController extends EventEmitter { } else { if (typeof this.password !== 'string') { throw new TypeError( - 'KeyringController: password must be of type string', + 'KeyringController - password must be of type string', ); } vault = await this.encryptor.encrypt(this.password, serializedKeyrings); } if (!vault) { - throw new Error('Cannot persist vault without vault information'); + throw new Error( + 'KeyringController - Cannot persist vault without vault information', + ); } this.store.updateState({ vault }); @@ -801,7 +805,9 @@ class KeyringController extends EventEmitter { ): Promise { const encryptedVault = this.store.getState().vault; if (!encryptedVault) { - throw new Error('Cannot unlock without a previous vault.'); + throw new Error( + 'KeyringController - Cannot unlock without a previous vault.', + ); } await this.#clearKeyrings(); @@ -825,7 +831,9 @@ class KeyringController extends EventEmitter { const parsedEncryptedVault = JSON.parse(encryptedVault); if (encryptionSalt !== parsedEncryptedVault.salt) { - throw new Error('Encryption key and salt provided are expired'); + throw new Error( + 'KeyringController - Encryption key and salt provided are expired', + ); } if (typeof encryptionKey !== 'string') { @@ -847,7 +855,7 @@ class KeyringController extends EventEmitter { } else { if (typeof password !== 'string') { throw new TypeError( - 'KeyringController: password must be of type string', + 'KeyringControlle - password must be of type string', ); } @@ -959,7 +967,7 @@ class KeyringController extends EventEmitter { errorInfo = 'There are keyrings, but none match the address'; } throw new Error( - `No keyring found for the requested account. Error info: ${errorInfo}`, + `KeyringController - No keyring found for the requested account. Error info: ${errorInfo}`, ); } diff --git a/src/constants.ts b/src/constants.ts index 7da62a37..11085b9a 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1 +1,6 @@ -export const hexPrefix = '0x'; +export const HEX_PREFIX = '0x'; + +export enum KeyringType { + HD = 'HD Key Tree', + Simple = 'Simple Key Pair', +} diff --git a/src/types.ts b/src/types.ts index 48cc3c3b..86a524aa 100644 --- a/src/types.ts +++ b/src/types.ts @@ -7,11 +7,6 @@ export type MessageParams = { data: Hex | string | Eip1024EncryptedData | Record[]; }; -export enum KeyringType { - HD = 'HD Key Tree', - Simple = 'Simple Key Pair', -} - export type ExtendedKeyring = Keyring & { generateRandomMnemonic: () => string; }; From 297363725e8eb9a5204d8ebcf07c1f90302e5008 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Mon, 6 Mar 2023 12:53:36 -0300 Subject: [PATCH 047/109] Fix tests and lint --- src/KeyringController.test.ts | 6 +++--- src/index.ts | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/KeyringController.test.ts b/src/KeyringController.test.ts index 1ded4475..3a15ad3d 100644 --- a/src/KeyringController.test.ts +++ b/src/KeyringController.test.ts @@ -579,7 +579,7 @@ describe('KeyringController', () => { keyringController.getKeyringForAccount(undefined as any), ).rejects.toThrow( new Error( - 'No keyring found for the requested account. Error info: The address passed in is invalid/empty', + 'KeyringController - No keyring found for the requested account. Error info: The address passed in is invalid/empty', ), ); }); @@ -590,7 +590,7 @@ describe('KeyringController', () => { keyringController.getKeyringForAccount('0x04'), ).rejects.toThrow( new Error( - 'No keyring found for the requested account. Error info: There are no keyrings', + 'KeyringController - No keyring found for the requested account. Error info: There are no keyrings', ), ); }); @@ -608,7 +608,7 @@ describe('KeyringController', () => { keyringController.getKeyringForAccount('0x04'), ).rejects.toThrow( new Error( - 'No keyring found for the requested account. Error info: There are keyrings, but none match the address', + 'KeyringController - No keyring found for the requested account. Error info: There are keyrings, but none match the address', ), ); }); diff --git a/src/index.ts b/src/index.ts index 88f70784..c73d5544 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,5 @@ export * from './KeyringController'; -export type { KeyringType, MessageParams } from './types'; +export { KeyringType } from './constants'; + +export type { MessageParams } from './types'; From e4898e413536c7427f30ea173002126ef2b4fb43 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Tue, 7 Mar 2023 13:14:58 -0300 Subject: [PATCH 048/109] Update dependencies --- package.json | 3 +- yarn.lock | 399 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 394 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 4a98c767..075e1b77 100644 --- a/package.json +++ b/package.json @@ -34,11 +34,12 @@ "test": "jest" }, "dependencies": { + "@ethereumjs/tx": "^4.1.1", "@metamask/browser-passworder": "^4.0.2", "@metamask/eth-hd-keyring": "^6.0.0", "@metamask/eth-sig-util": "5.0.2", "@metamask/eth-simple-keyring": "^5.0.0", - "@metamask/utils": "4.0.0", + "@metamask/utils": "5.0.0", "obs-store": "^4.0.3" }, "devDependencies": { diff --git a/yarn.lock b/yarn.lock index 8d6da74c..664b1547 100644 --- a/yarn.lock +++ b/yarn.lock @@ -543,6 +543,33 @@ __metadata: languageName: node linkType: hard +"@chainsafe/as-sha256@npm:^0.3.1": + version: 0.3.1 + resolution: "@chainsafe/as-sha256@npm:0.3.1" + checksum: 58ea733be1657b0e31dbf48b0dba862da0833df34a81c1460c7352f04ce90874f70003cbf34d0afb9e5e53a33ee2d63a261a8b12462be85b2ba0a6f7f13d6150 + languageName: node + linkType: hard + +"@chainsafe/persistent-merkle-tree@npm:^0.4.2": + version: 0.4.2 + resolution: "@chainsafe/persistent-merkle-tree@npm:0.4.2" + dependencies: + "@chainsafe/as-sha256": ^0.3.1 + checksum: f9cfcb2132a243992709715dbd28186ab48c7c0c696f29d30857693cca5526bf753974a505ef68ffd5623bbdbcaa10f9083f4dd40bf99eb6408e451cc26a1a9e + languageName: node + linkType: hard + +"@chainsafe/ssz@npm:0.9.4": + version: 0.9.4 + resolution: "@chainsafe/ssz@npm:0.9.4" + dependencies: + "@chainsafe/as-sha256": ^0.3.1 + "@chainsafe/persistent-merkle-tree": ^0.4.2 + case: ^1.6.3 + checksum: c6eaedeae9e5618b3c666ff4507a27647f665a8dcf17d5ca86da4ed4788c5a93868f256d0005467d184fdf35ec03f323517ec2e55ec42492d769540a2ec396bc + languageName: node + linkType: hard + "@cspotcode/source-map-support@npm:^0.8.0": version: 0.8.1 resolution: "@cspotcode/source-map-support@npm:0.8.1" @@ -580,6 +607,16 @@ __metadata: languageName: node linkType: hard +"@ethereumjs/common@npm:^3.1.1": + version: 3.1.1 + resolution: "@ethereumjs/common@npm:3.1.1" + dependencies: + "@ethereumjs/util": ^8.0.5 + crc-32: ^1.2.0 + checksum: 58602dee9fbcf691dca111b4fd7fd5770f5e86d68012ce48fba396c7038afdca4fca273a9cf39f88cf6ea7b256603a4bd214e94e9d01361efbcd060460b78952 + languageName: node + linkType: hard + "@ethereumjs/rlp@npm:^4.0.0-beta.2": version: 4.0.0 resolution: "@ethereumjs/rlp@npm:4.0.0" @@ -589,6 +626,34 @@ __metadata: languageName: node linkType: hard +"@ethereumjs/rlp@npm:^4.0.1": + version: 4.0.1 + resolution: "@ethereumjs/rlp@npm:4.0.1" + bin: + rlp: bin/rlp + checksum: 30db19c78faa2b6ff27275ab767646929207bb207f903f09eb3e4c273ce2738b45f3c82169ddacd67468b4f063d8d96035f2bf36f02b6b7e4d928eefe2e3ecbc + languageName: node + linkType: hard + +"@ethereumjs/tx@npm:^4.1.1": + version: 4.1.1 + resolution: "@ethereumjs/tx@npm:4.1.1" + dependencies: + "@chainsafe/ssz": 0.9.4 + "@ethereumjs/common": ^3.1.1 + "@ethereumjs/rlp": ^4.0.1 + "@ethereumjs/util": ^8.0.5 + "@ethersproject/providers": ^5.7.2 + ethereum-cryptography: ^1.1.2 + peerDependencies: + c-kzg: ^1.0.8 + peerDependenciesMeta: + c-kzg: + optional: true + checksum: 98897e79adf03ee90ed98c6a543e15e0b4e127bc5bc381d70cdcc76b111574205b94869c29d925ea9e30a98e5ef8b0f5597914359deb9db552017b2e78ef17a8 + languageName: node + linkType: hard + "@ethereumjs/util@npm:^8.0.0, @ethereumjs/util@npm:^8.0.2": version: 8.0.2 resolution: "@ethereumjs/util@npm:8.0.2" @@ -600,6 +665,272 @@ __metadata: languageName: node linkType: hard +"@ethereumjs/util@npm:^8.0.5": + version: 8.0.5 + resolution: "@ethereumjs/util@npm:8.0.5" + dependencies: + "@chainsafe/ssz": 0.9.4 + "@ethereumjs/rlp": ^4.0.1 + ethereum-cryptography: ^1.1.2 + checksum: 318386785295b4584289b1aa576d2621392b3a918d127890db62d3f74184f3377694dd9e951e19bfb9ab80e8dc9e38e180236cac2651dead26097d10963731f9 + languageName: node + linkType: hard + +"@ethersproject/abstract-provider@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/abstract-provider@npm:5.7.0" + dependencies: + "@ethersproject/bignumber": ^5.7.0 + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/logger": ^5.7.0 + "@ethersproject/networks": ^5.7.0 + "@ethersproject/properties": ^5.7.0 + "@ethersproject/transactions": ^5.7.0 + "@ethersproject/web": ^5.7.0 + checksum: 74cf4696245cf03bb7cc5b6cbf7b4b89dd9a79a1c4688126d214153a938126d4972d42c93182198653ce1de35f2a2cad68be40337d4774b3698a39b28f0228a8 + languageName: node + linkType: hard + +"@ethersproject/abstract-signer@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/abstract-signer@npm:5.7.0" + dependencies: + "@ethersproject/abstract-provider": ^5.7.0 + "@ethersproject/bignumber": ^5.7.0 + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/logger": ^5.7.0 + "@ethersproject/properties": ^5.7.0 + checksum: a823dac9cfb761e009851050ebebd5b229d1b1cc4a75b125c2da130ff37e8218208f7f9d1386f77407705b889b23d4a230ad67185f8872f083143e0073cbfbe3 + languageName: node + linkType: hard + +"@ethersproject/address@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/address@npm:5.7.0" + dependencies: + "@ethersproject/bignumber": ^5.7.0 + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/keccak256": ^5.7.0 + "@ethersproject/logger": ^5.7.0 + "@ethersproject/rlp": ^5.7.0 + checksum: 64ea5ebea9cc0e845c413e6cb1e54e157dd9fc0dffb98e239d3a3efc8177f2ff798cd4e3206cf3660ee8faeb7bef1a47dc0ebef0d7b132c32e61e550c7d4c843 + languageName: node + linkType: hard + +"@ethersproject/base64@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/base64@npm:5.7.0" + dependencies: + "@ethersproject/bytes": ^5.7.0 + checksum: 7dd5d734d623582f08f665434f53685041a3d3b334a0e96c0c8afa8bbcaab934d50e5b6b980e826a8fde8d353e0b18f11e61faf17468177274b8e7c69cd9742b + languageName: node + linkType: hard + +"@ethersproject/basex@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/basex@npm:5.7.0" + dependencies: + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/properties": ^5.7.0 + checksum: 326087b7e1f3787b5fe6cd1cf2b4b5abfafbc355a45e88e22e5e9d6c845b613ffc5301d629b28d5c4d5e2bfe9ec424e6782c804956dff79be05f0098cb5817de + languageName: node + linkType: hard + +"@ethersproject/bignumber@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/bignumber@npm:5.7.0" + dependencies: + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/logger": ^5.7.0 + bn.js: ^5.2.1 + checksum: 8c9a134b76f3feb4ec26a5a27379efb4e156b8fb2de0678a67788a91c7f4e30abe9d948638458e4b20f2e42380da0adacc7c9389d05fce070692edc6ae9b4904 + languageName: node + linkType: hard + +"@ethersproject/bytes@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/bytes@npm:5.7.0" + dependencies: + "@ethersproject/logger": ^5.7.0 + checksum: 66ad365ceaab5da1b23b72225c71dce472cf37737af5118181fa8ab7447d696bea15ca22e3a0e8836fdd8cfac161afe321a7c67d0dde96f9f645ddd759676621 + languageName: node + linkType: hard + +"@ethersproject/constants@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/constants@npm:5.7.0" + dependencies: + "@ethersproject/bignumber": ^5.7.0 + checksum: 6d4b1355747cce837b3e76ec3bde70e4732736f23b04f196f706ebfa5d4d9c2be50904a390d4d40ce77803b98d03d16a9b6898418e04ba63491933ce08c4ba8a + languageName: node + linkType: hard + +"@ethersproject/hash@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/hash@npm:5.7.0" + dependencies: + "@ethersproject/abstract-signer": ^5.7.0 + "@ethersproject/address": ^5.7.0 + "@ethersproject/base64": ^5.7.0 + "@ethersproject/bignumber": ^5.7.0 + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/keccak256": ^5.7.0 + "@ethersproject/logger": ^5.7.0 + "@ethersproject/properties": ^5.7.0 + "@ethersproject/strings": ^5.7.0 + checksum: 6e9fa8d14eb08171cd32f17f98cc108ec2aeca74a427655f0d689c550fee0b22a83b3b400fad7fb3f41cf14d4111f87f170aa7905bcbcd1173a55f21b06262ef + languageName: node + linkType: hard + +"@ethersproject/keccak256@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/keccak256@npm:5.7.0" + dependencies: + "@ethersproject/bytes": ^5.7.0 + js-sha3: 0.8.0 + checksum: ff70950d82203aab29ccda2553422cbac2e7a0c15c986bd20a69b13606ed8bb6e4fdd7b67b8d3b27d4f841e8222cbaccd33ed34be29f866fec7308f96ed244c6 + languageName: node + linkType: hard + +"@ethersproject/logger@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/logger@npm:5.7.0" + checksum: 075ab2f605f1fd0813f2e39c3308f77b44a67732b36e712d9bc085f22a84aac4da4f71b39bee50fe78da3e1c812673fadc41180c9970fe5e486e91ea17befe0d + languageName: node + linkType: hard + +"@ethersproject/networks@npm:^5.7.0": + version: 5.7.1 + resolution: "@ethersproject/networks@npm:5.7.1" + dependencies: + "@ethersproject/logger": ^5.7.0 + checksum: 0339f312304c17d9a0adce550edb825d4d2c8c9468c1634c44172c67a9ed256f594da62c4cda5c3837a0f28b7fabc03aca9b492f68ff1fdad337ee861b27bd5d + languageName: node + linkType: hard + +"@ethersproject/properties@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/properties@npm:5.7.0" + dependencies: + "@ethersproject/logger": ^5.7.0 + checksum: 6ab0ccf0c3aadc9221e0cdc5306ce6cd0df7f89f77d77bccdd1277182c9ead0202cd7521329ba3acde130820bf8af299e17cf567d0d497c736ee918207bbf59f + languageName: node + linkType: hard + +"@ethersproject/providers@npm:^5.7.2": + version: 5.7.2 + resolution: "@ethersproject/providers@npm:5.7.2" + dependencies: + "@ethersproject/abstract-provider": ^5.7.0 + "@ethersproject/abstract-signer": ^5.7.0 + "@ethersproject/address": ^5.7.0 + "@ethersproject/base64": ^5.7.0 + "@ethersproject/basex": ^5.7.0 + "@ethersproject/bignumber": ^5.7.0 + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/constants": ^5.7.0 + "@ethersproject/hash": ^5.7.0 + "@ethersproject/logger": ^5.7.0 + "@ethersproject/networks": ^5.7.0 + "@ethersproject/properties": ^5.7.0 + "@ethersproject/random": ^5.7.0 + "@ethersproject/rlp": ^5.7.0 + "@ethersproject/sha2": ^5.7.0 + "@ethersproject/strings": ^5.7.0 + "@ethersproject/transactions": ^5.7.0 + "@ethersproject/web": ^5.7.0 + bech32: 1.1.4 + ws: 7.4.6 + checksum: 1754c731a5ca6782ae9677f4a9cd8b6246c4ef21a966c9a01b133750f3c578431ec43ec254e699969c4a0f87e84463ded50f96b415600aabd37d2056aee58c19 + languageName: node + linkType: hard + +"@ethersproject/random@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/random@npm:5.7.0" + dependencies: + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/logger": ^5.7.0 + checksum: 017829c91cff6c76470852855108115b0b52c611b6be817ed1948d56ba42d6677803ec2012aa5ae298a7660024156a64c11fcf544e235e239ab3f89f0fff7345 + languageName: node + linkType: hard + +"@ethersproject/rlp@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/rlp@npm:5.7.0" + dependencies: + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/logger": ^5.7.0 + checksum: bce165b0f7e68e4d091c9d3cf47b247cac33252df77a095ca4281d32d5eeaaa3695d9bc06b2b057c5015353a68df89f13a4a54a72e888e4beeabbe56b15dda6e + languageName: node + linkType: hard + +"@ethersproject/sha2@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/sha2@npm:5.7.0" + dependencies: + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/logger": ^5.7.0 + hash.js: 1.1.7 + checksum: 09321057c022effbff4cc2d9b9558228690b5dd916329d75c4b1ffe32ba3d24b480a367a7cc92d0f0c0b1c896814d03351ae4630e2f1f7160be2bcfbde435dbc + languageName: node + linkType: hard + +"@ethersproject/signing-key@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/signing-key@npm:5.7.0" + dependencies: + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/logger": ^5.7.0 + "@ethersproject/properties": ^5.7.0 + bn.js: ^5.2.1 + elliptic: 6.5.4 + hash.js: 1.1.7 + checksum: 8f8de09b0aac709683bbb49339bc0a4cd2f95598f3546436c65d6f3c3a847ffa98e06d35e9ed2b17d8030bd2f02db9b7bd2e11c5cf8a71aad4537487ab4cf03a + languageName: node + linkType: hard + +"@ethersproject/strings@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/strings@npm:5.7.0" + dependencies: + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/constants": ^5.7.0 + "@ethersproject/logger": ^5.7.0 + checksum: 5ff78693ae3fdf3cf23e1f6dc047a61e44c8197d2408c42719fef8cb7b7b3613a4eec88ac0ed1f9f5558c74fe0de7ae3195a29ca91a239c74b9f444d8e8b50df + languageName: node + linkType: hard + +"@ethersproject/transactions@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/transactions@npm:5.7.0" + dependencies: + "@ethersproject/address": ^5.7.0 + "@ethersproject/bignumber": ^5.7.0 + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/constants": ^5.7.0 + "@ethersproject/keccak256": ^5.7.0 + "@ethersproject/logger": ^5.7.0 + "@ethersproject/properties": ^5.7.0 + "@ethersproject/rlp": ^5.7.0 + "@ethersproject/signing-key": ^5.7.0 + checksum: a31b71996d2b283f68486241bff0d3ea3f1ba0e8f1322a8fffc239ccc4f4a7eb2ea9994b8fd2f093283fd75f87bae68171e01b6265261f821369aca319884a79 + languageName: node + linkType: hard + +"@ethersproject/web@npm:^5.7.0": + version: 5.7.1 + resolution: "@ethersproject/web@npm:5.7.1" + dependencies: + "@ethersproject/base64": ^5.7.0 + "@ethersproject/bytes": ^5.7.0 + "@ethersproject/logger": ^5.7.0 + "@ethersproject/properties": ^5.7.0 + "@ethersproject/strings": ^5.7.0 + checksum: 7028c47103f82fd2e2c197ce0eecfacaa9180ffeec7de7845b1f4f9b19d84081b7a48227aaddde05a4aaa526af574a9a0ce01cc0fc75e3e371f84b38b5b16b2b + languageName: node + linkType: hard + "@gar/promisify@npm:^1.1.3": version: 1.1.3 resolution: "@gar/promisify@npm:1.1.3" @@ -1054,6 +1385,7 @@ __metadata: version: 0.0.0-use.local resolution: "@metamask/eth-keyring-controller@workspace:." dependencies: + "@ethereumjs/tx": ^4.1.1 "@lavamoat/allow-scripts": ^2.1.0 "@metamask/auto-changelog": ^3.0.0 "@metamask/browser-passworder": ^4.0.2 @@ -1064,7 +1396,7 @@ __metadata: "@metamask/eth-hd-keyring": ^6.0.0 "@metamask/eth-sig-util": 5.0.2 "@metamask/eth-simple-keyring": ^5.0.0 - "@metamask/utils": 4.0.0 + "@metamask/utils": 5.0.0 "@types/jest": ^29.4.0 "@types/sinon": ^10.0.13 "@typescript-eslint/eslint-plugin": ^5.53.0 @@ -1126,15 +1458,16 @@ __metadata: languageName: node linkType: hard -"@metamask/utils@npm:4.0.0": - version: 4.0.0 - resolution: "@metamask/utils@npm:4.0.0" +"@metamask/utils@npm:5.0.0": + version: 5.0.0 + resolution: "@metamask/utils@npm:5.0.0" dependencies: + "@ethereumjs/tx": ^4.1.1 "@types/debug": ^4.1.7 debug: ^4.3.4 semver: ^7.3.8 superstruct: ^1.0.3 - checksum: 6d4edca78fe1f66504ed5e5ca021a67f4b4e0893e86484c746b87039c2161c39d3b8bd8e4b9235ddfd023b2d76dd54210af94ec5550e27bc4ad9c0d7d5f3f231 + checksum: 34e39fc0bf28db5fe92676753de3291b05a517f8c81dbe332a4b6002739a58450a89fb2bddd85922a4f420affb1674604e6ad4627cdf052459e5371361ef7dd2 languageName: node linkType: hard @@ -2241,6 +2574,13 @@ __metadata: languageName: node linkType: hard +"bech32@npm:1.1.4": + version: 1.1.4 + resolution: "bech32@npm:1.1.4" + checksum: 0e98db619191548390d6f09ff68b0253ba7ae6a55db93dfdbb070ba234c1fd3308c0606fbcc95fad50437227b10011e2698b89f0181f6e7f845c499bd14d0f4b + languageName: node + linkType: hard + "binary-extensions@npm:^2.0.0": version: 2.2.0 resolution: "binary-extensions@npm:2.2.0" @@ -2269,6 +2609,13 @@ __metadata: languageName: node linkType: hard +"bn.js@npm:^5.2.1": + version: 5.2.1 + resolution: "bn.js@npm:5.2.1" + checksum: 3dd8c8d38055fedfa95c1d5fc3c99f8dd547b36287b37768db0abab3c239711f88ff58d18d155dd8ad902b0b0cee973747b7ae20ea12a09473272b0201c9edd3 + languageName: node + linkType: hard + "brace-expansion@npm:^1.1.7": version: 1.1.11 resolution: "brace-expansion@npm:1.1.11" @@ -2448,6 +2795,13 @@ __metadata: languageName: node linkType: hard +"case@npm:^1.6.3": + version: 1.6.3 + resolution: "case@npm:1.6.3" + checksum: febe73278f910b0d28aab7efd6f51c235f9aa9e296148edb56dfb83fd58faa88308c30ce9a0122b6e53e0362c44f4407105bd5ef89c46860fc2b184e540fd68d + languageName: node + linkType: hard + "caseless@npm:~0.12.0": version: 0.12.0 resolution: "caseless@npm:0.12.0" @@ -2690,6 +3044,15 @@ __metadata: languageName: node linkType: hard +"crc-32@npm:^1.2.0": + version: 1.2.2 + resolution: "crc-32@npm:1.2.2" + bin: + crc32: bin/crc32.njs + checksum: ad2d0ad0cbd465b75dcaeeff0600f8195b686816ab5f3ba4c6e052a07f728c3e70df2e3ca9fd3d4484dc4ba70586e161ca5a2334ec8bf5a41bf022a6103ff243 + languageName: node + linkType: hard + "create-hash@npm:^1.1.0, create-hash@npm:^1.1.2, create-hash@npm:^1.2.0": version: 1.2.0 resolution: "create-hash@npm:1.2.0" @@ -2945,7 +3308,7 @@ __metadata: languageName: node linkType: hard -"elliptic@npm:^6.5.2": +"elliptic@npm:6.5.4, elliptic@npm:^6.5.2": version: 6.5.4 resolution: "elliptic@npm:6.5.4" dependencies: @@ -4041,7 +4404,7 @@ __metadata: languageName: node linkType: hard -"hash.js@npm:^1.0.0, hash.js@npm:^1.0.3, hash.js@npm:^1.1.7": +"hash.js@npm:1.1.7, hash.js@npm:^1.0.0, hash.js@npm:^1.0.3, hash.js@npm:^1.1.7": version: 1.1.7 resolution: "hash.js@npm:1.1.7" dependencies: @@ -4980,6 +5343,13 @@ __metadata: languageName: node linkType: hard +"js-sha3@npm:0.8.0": + version: 0.8.0 + resolution: "js-sha3@npm:0.8.0" + checksum: 75df77c1fc266973f06cce8309ce010e9e9f07ec35ab12022ed29b7f0d9c8757f5a73e1b35aa24840dced0dea7059085aa143d817aea9e188e2a80d569d9adce + languageName: node + linkType: hard + "js-tokens@npm:^3.0.0 || ^4.0.0, js-tokens@npm:^4.0.0": version: 4.0.0 resolution: "js-tokens@npm:4.0.0" @@ -7384,6 +7754,21 @@ __metadata: languageName: node linkType: hard +"ws@npm:7.4.6": + version: 7.4.6 + resolution: "ws@npm:7.4.6" + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: ^5.0.2 + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + checksum: 3a990b32ed08c72070d5e8913e14dfcd831919205be52a3ff0b4cdd998c8d554f167c9df3841605cde8b11d607768cacab3e823c58c96a5c08c987e093eb767a + languageName: node + linkType: hard + "xtend@npm:^4.0.1, xtend@npm:~4.0.1": version: 4.0.2 resolution: "xtend@npm:4.0.2" From 5832e7dfdbb56fdd6f8f09a9dd81a97cc8a66bf7 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Tue, 7 Mar 2023 13:15:12 -0300 Subject: [PATCH 049/109] Update types --- src/KeyringController.test.ts | 16 ++++++++-------- src/KeyringController.ts | 35 ++++++++++++++++++++--------------- src/types.ts | 6 +----- 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/src/KeyringController.test.ts b/src/KeyringController.test.ts index 3a15ad3d..a3cbfcc3 100644 --- a/src/KeyringController.test.ts +++ b/src/KeyringController.test.ts @@ -1,6 +1,6 @@ import HdKeyring from '@metamask/eth-hd-keyring'; import { normalize as normalizeAddress } from '@metamask/eth-sig-util'; -import type { Hex, KeyringClass } from '@metamask/utils'; +import type { Hex, Keyring, KeyringClass } from '@metamask/utils'; import { strict as assert } from 'assert'; import Wallet from 'ethereumjs-wallet'; import { restore, spy, stub, assert as sinonAssert } from 'sinon'; @@ -8,7 +8,7 @@ import { restore, spy, stub, assert as sinonAssert } from 'sinon'; import { KeyringController, keyringBuilderFactory } from '.'; import { KeyringType } from './constants'; import { mockEncryptor, KeyringMockWithInit } from './mocks'; -import { ExtendedKeyring } from './types'; +import { State } from './types'; const password = 'password123'; @@ -367,12 +367,12 @@ describe('KeyringController', () => { async getAccounts() { return Promise.resolve([1, 2, 3]); }, - } as unknown as ExtendedKeyring, + } as unknown as Keyring, { async getAccounts() { return Promise.resolve([4, 5, 6]); }, - } as unknown as ExtendedKeyring, + } as unknown as Keyring, ]; const result = await keyringController.getAccounts(); @@ -510,7 +510,7 @@ describe('KeyringController', () => { const initialAccounts = await HDKeyring?.getAccounts(); expect(initialAccounts).toHaveLength(1); - await keyringController.addNewAccount(HDKeyring as ExtendedKeyring); + await keyringController.addNewAccount(HDKeyring as Keyring); const accountsAfterAdd = await HDKeyring?.getAccounts(); expect(accountsAfterAdd).toHaveLength(2); }); @@ -601,7 +601,7 @@ describe('KeyringController', () => { async getAccounts() { return Promise.resolve([1, 2, 3]); }, - } as unknown as ExtendedKeyring, + } as unknown as Keyring, ]; await expect( @@ -688,10 +688,10 @@ describe('KeyringController', () => { const [firstKeyring] = keyringController.keyrings; - await keyringController.addNewAccount(firstKeyring as ExtendedKeyring); + await keyringController.addNewAccount(firstKeyring as Keyring); expect(await keyringController.getAccounts()).toHaveLength(2); - await keyringController.addNewAccount(firstKeyring as ExtendedKeyring); + await keyringController.addNewAccount(firstKeyring as Keyring); expect(await keyringController.getAccounts()).toHaveLength(3); const account = { diff --git a/src/KeyringController.ts b/src/KeyringController.ts index 431cc16f..23b1f464 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -1,3 +1,4 @@ +import type { TypedTransaction, TxData } from '@ethereumjs/tx'; import encryptor from '@metamask/browser-passworder'; import HDKeyring from '@metamask/eth-hd-keyring'; import { normalize as normalizeAddress } from '@metamask/eth-sig-util'; @@ -8,8 +9,6 @@ import type { Bytes, Keyring, KeyringClass, - Transaction, - SignedTransaction, Eip1024EncryptedData, } from '@metamask/utils'; // TODO: Stop using `events`, and remove the notice about this from the README @@ -18,7 +17,7 @@ import { EventEmitter } from 'events'; import ObservableStore from 'obs-store'; import { HEX_PREFIX, KeyringType } from './constants'; -import { State, MessageParams, ExtendedKeyring } from './types'; +import { State, MessageParams } from './types'; const defaultKeyringBuilders = [ keyringBuilderFactory(SimpleKeyring), @@ -47,7 +46,7 @@ class KeyringController extends EventEmitter { public encryptor: any; - public keyrings: ExtendedKeyring[]; + public keyrings: Keyring[]; public cacheEncryptionKey: boolean; @@ -275,6 +274,12 @@ class KeyringController extends EventEmitter { } if (!opts?.mnemonic && type === KeyringType.HD) { + if (!keyring.generateRandomMnemonic) { + throw new Error( + `KeyringController - The current keyring does not support the method generateRandomMnemonic.`, + ); + } + keyring.generateRandomMnemonic(); await keyring.addAccounts(1); } @@ -297,14 +302,14 @@ class KeyringController extends EventEmitter { * (usually after removing the last / only account) from a keyring. */ async removeEmptyKeyrings(): Promise { - const validKeyrings: ExtendedKeyring[] = []; + const validKeyrings: Keyring[] = []; // Since getAccounts returns a Promise // We need to wait to hear back form each keyring // in order to decide which ones are now valid (accounts.length > 0) await Promise.all( - this.keyrings.map(async (keyring: ExtendedKeyring) => { + this.keyrings.map(async (keyring: Keyring) => { const accounts = await keyring.getAccounts(); if (accounts.length > 0) { validKeyrings.push(keyring); @@ -442,10 +447,10 @@ class KeyringController extends EventEmitter { * @returns The signed transaction object. */ async signTransaction( - ethTx: Transaction, + ethTx: TypedTransaction, _address: string | Hex, opts: Record = {}, - ): Promise { + ): Promise { const address = normalizeAddress(_address) as Hex; const keyring = await this.getKeyringForAccount(address); if (!keyring.signTransaction) { @@ -638,7 +643,7 @@ class KeyringController extends EventEmitter { * @param serialized - The serialized keyring. * @returns The deserialized keyring. */ - async restoreKeyring(serialized: any): Promise { + async restoreKeyring(serialized: any): Promise | undefined> { const keyring = await this.#restoreKeyring(serialized); if (keyring) { await this.#updateMemStoreKeyrings(); @@ -654,7 +659,7 @@ class KeyringController extends EventEmitter { * @param type - The keyring types to retrieve. * @returns Keyrings matching the specified type. */ - getKeyringsByType(type: KeyringType): ExtendedKeyring[] { + getKeyringsByType(type: KeyringType): Keyring[] { return this.keyrings.filter((keyring) => keyring.type === type); } @@ -802,7 +807,7 @@ class KeyringController extends EventEmitter { password: string | undefined, encryptionKey?: string, encryptionSalt?: string, - ): Promise { + ): Promise[]> { const encryptedVault = this.store.getState().vault; if (!encryptedVault) { throw new Error( @@ -877,7 +882,7 @@ class KeyringController extends EventEmitter { * @param serialized - The serialized keyring. * @returns The deserialized keyring or undefined if the keyring type is unsupported. */ - async #restoreKeyring(serialized: any): Promise { + async #restoreKeyring(serialized: any): Promise | undefined> { const { type, data } = serialized; const keyring = await this.#newKeyring(type, data); @@ -939,7 +944,7 @@ class KeyringController extends EventEmitter { * @param address - An account address. * @returns The keyring of the account, if it exists. */ - async getKeyringForAccount(address: string): Promise { + async getKeyringForAccount(address: string): Promise> { const hexed = normalizeAddress(address); const candidates = await Promise.all( @@ -980,7 +985,7 @@ class KeyringController extends EventEmitter { * @returns A keyring display object, with type and accounts properties. */ async #displayForKeyring( - keyring: ExtendedKeyring, + keyring: Keyring, ): Promise<{ type: string; accounts: string[] }> { const accounts = await keyring.getAccounts(); @@ -1025,7 +1030,7 @@ class KeyringController extends EventEmitter { * @param data - The data to restore a previously serialized keyring. * @returns The new keyring. */ - async #newKeyring(type: string, data: any): Promise { + async #newKeyring(type: string, data: any): Promise | void> { const keyringBuilder = this.#getKeyringBuilderForType(type); if (!keyringBuilder) { diff --git a/src/types.ts b/src/types.ts index 86a524aa..7d66b078 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,4 +1,4 @@ -import type { Hex, Json, Keyring, Eip1024EncryptedData } from '@metamask/utils'; +import type { Hex, Json, Eip1024EncryptedData } from '@metamask/utils'; export type State = Json; @@ -6,7 +6,3 @@ export type MessageParams = { from: Hex | string; data: Hex | string | Eip1024EncryptedData | Record[]; }; - -export type ExtendedKeyring = Keyring & { - generateRandomMnemonic: () => string; -}; From 979774b3c36ee324f006a72498ec2b1881a678ac Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Tue, 7 Mar 2023 15:31:21 -0300 Subject: [PATCH 050/109] Lint --- src/mocks/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mocks/index.ts b/src/mocks/index.ts index d80e2edd..4a658c06 100644 --- a/src/mocks/index.ts +++ b/src/mocks/index.ts @@ -4,7 +4,7 @@ import { MOCK_HARDCODED_KEY, MOCK_HEX, MOCK_ENCRYPTION_KEY, - MOCK_SALT + MOCK_SALT, } from './encryptor.mock'; import KeyringMockWithInit from './keyring.mock'; From 2ec20ffb468cd4218f2f2ffed9af4738f6ef688d Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Tue, 7 Mar 2023 23:18:28 -0300 Subject: [PATCH 051/109] Update data type --- src/KeyringController.test.ts | 2 +- src/KeyringController.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/KeyringController.test.ts b/src/KeyringController.test.ts index 1d83e79a..755bbf42 100644 --- a/src/KeyringController.test.ts +++ b/src/KeyringController.test.ts @@ -110,7 +110,7 @@ describe('KeyringController', () => { describe('persistAllKeyrings', function () { it('should persist keyrings in _unsupportedKeyrings array', async function () { - const unsupportedKeyring = 'DUMMY_KEYRING'; + const unsupportedKeyring = { type: 'DUMMY_KEYRING', data: {} }; keyringController.unsupportedKeyrings = [unsupportedKeyring]; await keyringController.persistAllKeyrings(); diff --git a/src/KeyringController.ts b/src/KeyringController.ts index a327f77e..94ee87c0 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -50,7 +50,7 @@ class KeyringController extends EventEmitter { public cacheEncryptionKey: boolean; - public unsupportedKeyrings: any[]; + public unsupportedKeyrings: { type: string; data: Json }[]; public password?: string | undefined; From c85a7bdaabfeb8baacea4e7983adf32af01724c6 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Tue, 7 Mar 2023 23:23:06 -0300 Subject: [PATCH 052/109] Update syntax to arrow function --- src/KeyringController.test.ts | 126 +++++++++++++++++----------------- 1 file changed, 63 insertions(+), 63 deletions(-) diff --git a/src/KeyringController.test.ts b/src/KeyringController.test.ts index 755bbf42..93c17a16 100644 --- a/src/KeyringController.test.ts +++ b/src/KeyringController.test.ts @@ -39,7 +39,7 @@ const walletTwoAddresses = [ describe('KeyringController', () => { let keyringController: KeyringController; - beforeEach(async function () { + beforeEach(async () => { keyringController = new KeyringController({ encryptor: mockEncryptor, keyringBuilders: [ @@ -53,12 +53,12 @@ describe('KeyringController', () => { await keyringController.submitPassword(PASSWORD); }); - afterEach(function () { + afterEach(() => { restore(); }); - describe('setLocked', function () { - it('setLocked correctly sets lock state', async function () { + describe('setLocked', () => { + it('setLocked correctly sets lock state', async () => { assert.notDeepEqual( keyringController.keyrings, [], @@ -72,7 +72,7 @@ describe('KeyringController', () => { expect(keyringController.keyrings).toHaveLength(0); }); - it('emits "lock" event', async function () { + it('emits "lock" event', async () => { const lockSpy = spy(); keyringController.on('lock', lockSpy); @@ -82,8 +82,8 @@ describe('KeyringController', () => { }); }); - describe('submitPassword', function () { - it('should not load keyrings when incorrect password', async function () { + describe('submitPassword', () => { + it('should not load keyrings when incorrect password', async () => { await keyringController.createNewVaultAndKeychain(PASSWORD); await keyringController.persistAllKeyrings(); expect(keyringController.keyrings).toHaveLength(1); @@ -97,7 +97,7 @@ describe('KeyringController', () => { expect(keyringController.keyrings).toHaveLength(0); }); - it('emits "unlock" event', async function () { + it('emits "unlock" event', async () => { await keyringController.setLocked(); const unlockSpy = spy(); @@ -108,8 +108,8 @@ describe('KeyringController', () => { }); }); - describe('persistAllKeyrings', function () { - it('should persist keyrings in _unsupportedKeyrings array', async function () { + describe('persistAllKeyrings', () => { + it('should persist keyrings in _unsupportedKeyrings array', async () => { const unsupportedKeyring = { type: 'DUMMY_KEYRING', data: {} }; keyringController.unsupportedKeyrings = [unsupportedKeyring]; await keyringController.persistAllKeyrings(); @@ -120,8 +120,8 @@ describe('KeyringController', () => { expect(keyrings).toHaveLength(2); }); - describe('when `cacheEncryptionKey` is enabled', function () { - it('should save an up to date encryption salt to the `memStore` when `password` is unset and `encryptionKey` is set', async function () { + describe('when `cacheEncryptionKey` is enabled', () => { + it('should save an up to date encryption salt to the `memStore` when `password` is unset and `encryptionKey` is set', async () => { keyringController.password = undefined; keyringController.cacheEncryptionKey = true; const vaultEncryptionKey = '🔑'; @@ -158,7 +158,7 @@ describe('KeyringController', () => { ); }); - it('should save an up to date encryption salt to the `memStore` when `password` is set through `createNewVaultAndKeychain`', async function () { + it('should save an up to date encryption salt to the `memStore` when `password` is set through `createNewVaultAndKeychain`', async () => { keyringController.cacheEncryptionKey = true; await keyringController.createNewVaultAndKeychain(PASSWORD); @@ -174,7 +174,7 @@ describe('KeyringController', () => { ); }); - it('should save an up to date encryption salt to the `memStore` when `password` is set through `submitPassword`', async function () { + it('should save an up to date encryption salt to the `memStore` when `password` is set through `submitPassword`', async () => { keyringController.cacheEncryptionKey = true; await keyringController.submitPassword(PASSWORD); @@ -192,8 +192,8 @@ describe('KeyringController', () => { }); }); - describe('createNewVaultAndKeychain', function () { - it('should create a new vault', async function () { + describe('createNewVaultAndKeychain', () => { + it('should create a new vault', async () => { keyringController.store.updateState({ vault: null }); assert(!keyringController.store.getState().vault, 'no previous vault'); @@ -205,7 +205,7 @@ describe('KeyringController', () => { expect(typeof newVault).toBe('object'); }); - it('should unlock the vault', async function () { + it('should unlock the vault', async () => { keyringController.store.updateState({ vault: null }); assert(!keyringController.store.getState().vault, 'no previous vault'); @@ -214,7 +214,7 @@ describe('KeyringController', () => { expect(isUnlocked).toBe(true); }); - it('should encrypt keyrings with the correct password each time they are persisted', async function () { + it('should encrypt keyrings with the correct password each time they are persisted', async () => { keyringController.store.updateState({ vault: null }); assert(!keyringController.store.getState().vault, 'no previous vault'); @@ -240,7 +240,7 @@ describe('KeyringController', () => { }); describe('when `cacheEncryptionKey` is enabled', () => { - it('should add an `encryptionSalt` to the `memStore` when a new vault is created', async function () { + it('should add an `encryptionSalt` to the `memStore` when a new vault is created', async () => { keyringController.cacheEncryptionKey = true; const initialMemStore = keyringController.memStore.getState(); @@ -256,8 +256,8 @@ describe('KeyringController', () => { }); }); - describe('createNewVaultAndRestore', function () { - it('clears old keyrings and creates a one', async function () { + describe('createNewVaultAndRestore', () => { + it('clears old keyrings and creates a one', async () => { const initialAccounts = await keyringController.getAccounts(); expect(initialAccounts).toHaveLength(1); @@ -275,7 +275,7 @@ describe('KeyringController', () => { expect(allAccountsAfter[0]).toBe(walletOneAddresses[0]); }); - it('throws error if argument password is not a string', async function () { + it('throws error if argument password is not a string', async () => { await expect(async () => keyringController.createNewVaultAndRestore( 12 as any, @@ -284,7 +284,7 @@ describe('KeyringController', () => { ).rejects.toThrow('KeyringController - Password must be of type string.'); }); - it('throws error if mnemonic passed is invalid', async function () { + it('throws error if mnemonic passed is invalid', async () => { await expect(async () => keyringController.createNewVaultAndRestore( PASSWORD, @@ -301,7 +301,7 @@ describe('KeyringController', () => { ); }); - it('accepts mnemonic passed as type array of numbers', async function () { + it('accepts mnemonic passed as type array of numbers', async () => { const allAccountsBefore = await keyringController.getAccounts(); expect(allAccountsBefore[0]).not.toBe(walletTwoAddresses[0]); const mnemonicAsArrayOfNumbers = Array.from( @@ -332,7 +332,7 @@ describe('KeyringController', () => { }); describe('when `cacheEncryptionKey` is enabled', () => { - it('should add an `encryptionSalt` to the `memStore` when a vault is restored', async function () { + it('should add an `encryptionSalt` to the `memStore` when a vault is restored', async () => { keyringController.cacheEncryptionKey = true; const initialMemStore = keyringController.memStore.getState(); @@ -352,7 +352,7 @@ describe('KeyringController', () => { }); describe('addNewKeyring', () => { - it('should add simple key pair', async function () { + it('should add simple key pair', async () => { const privateKey = 'c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3'; const previousAccounts = await keyringController.getAccounts(); @@ -374,7 +374,7 @@ describe('KeyringController', () => { expect(allAccounts).toStrictEqual(expectedAllAccounts); }); - it('should add HD Key Tree without mnemonic passed as an argument', async function () { + it('should add HD Key Tree without mnemonic passed as an argument', async () => { const previousAllAccounts = await keyringController.getAccounts(); expect(previousAllAccounts).toHaveLength(1); const keyring = await keyringController.addNewKeyring(KeyringType.HD); @@ -384,7 +384,7 @@ describe('KeyringController', () => { expect(allAccounts).toHaveLength(2); }); - it('should add HD Key Tree with mnemonic passed as an argument', async function () { + it('should add HD Key Tree with mnemonic passed as an argument', async () => { const previousAllAccounts = await keyringController.getAccounts(); expect(previousAllAccounts).toHaveLength(1); const keyring = await keyringController.addNewKeyring(KeyringType.HD, { @@ -399,7 +399,7 @@ describe('KeyringController', () => { expect(allAccounts).toHaveLength(3); }); - it('should call init method if available', async function () { + it('should call init method if available', async () => { const initSpy = spy(KeyringMockWithInit.prototype, 'init'); const keyring = await keyringController.addNewKeyring( @@ -442,8 +442,8 @@ describe('KeyringController', () => { }); }); - describe('restoreKeyring', function () { - it(`should pass a keyring's serialized data back to the correct type.`, async function () { + describe('restoreKeyring', () => { + it(`should pass a keyring's serialized data back to the correct type.`, async () => { const mockSerialized = { type: 'HD Key Tree', data: { @@ -461,7 +461,7 @@ describe('KeyringController', () => { expect(accounts?.[0]).toBe(walletOneAddresses[0]); }); - it('should return undefined if keyring type is not supported.', async function () { + it('should return undefined if keyring type is not supported.', async () => { const unsupportedKeyring = { type: 'Ledger Keyring', data: 'DUMMY' }; const keyring = await keyringController.restoreKeyring( unsupportedKeyring, @@ -470,8 +470,8 @@ describe('KeyringController', () => { }); }); - describe('getAccounts', function () { - it('returns the result of getAccounts for each keyring', async function () { + describe('getAccounts', () => { + it('returns the result of getAccounts for each keyring', async () => { keyringController.keyrings = [ { async getAccounts() { @@ -497,8 +497,8 @@ describe('KeyringController', () => { }); }); - describe('removeAccount', function () { - it('removes an account from the corresponding keyring', async function () { + describe('removeAccount', () => { + it('removes an account from the corresponding keyring', async () => { const account = { privateKey: 'c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3', @@ -522,7 +522,7 @@ describe('KeyringController', () => { expect(result).toStrictEqual(accountsBeforeAdding); }); - it('removes the keyring if there are no accounts after removal', async function () { + it('removes the keyring if there are no accounts after removal', async () => { const account = { privateKey: 'c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3', @@ -545,7 +545,7 @@ describe('KeyringController', () => { expect(keyringController.keyrings).toHaveLength(1); }); - it('does not remove the keyring if there are accounts remaining after removing one from the keyring', async function () { + it('does not remove the keyring if there are accounts remaining after removing one from the keyring', async () => { // Add a new keyring with two accounts await keyringController.addNewKeyring(KeyringType.HD, { mnemonic: walletTwoSeedWords, @@ -564,8 +564,8 @@ describe('KeyringController', () => { }); }); - describe('unlockKeyrings', function () { - it('returns the list of keyrings', async function () { + describe('unlockKeyrings', () => { + it('returns the list of keyrings', async () => { await keyringController.setLocked(); const keyrings = await keyringController.unlockKeyrings(PASSWORD); expect(keyrings).toHaveLength(1); @@ -577,7 +577,7 @@ describe('KeyringController', () => { ); }); - it('add serialized keyring to _unsupportedKeyrings array if keyring type is not known', async function () { + it('add serialized keyring to _unsupportedKeyrings array if keyring type is not known', async () => { const unsupportedKeyrings = [{ type: 'Ledger Keyring', data: 'DUMMY' }]; mockEncryptor.encrypt(PASSWORD, unsupportedKeyrings); await keyringController.setLocked(); @@ -589,14 +589,14 @@ describe('KeyringController', () => { }); }); - describe('verifyPassword', function () { + describe('verifyPassword', () => { beforeEach(() => { keyringController = new KeyringController({ encryptor: mockEncryptor, }); }); - it('throws an error if no encrypted vault is in controller state', async function () { + it('throws an error if no encrypted vault is in controller state', async () => { await expect(async () => keyringController.verifyPassword('test'), ).rejects.toThrow('Cannot unlock without a previous vault.'); @@ -614,8 +614,8 @@ describe('KeyringController', () => { }); }); - describe('addNewAccount', function () { - it('adds a new account to the keyring it receives as an argument', async function () { + describe('addNewAccount', () => { + it('adds a new account to the keyring it receives as an argument', async () => { const [HDKeyring] = keyringController.getKeyringsByType(KeyringType.HD); const initialAccounts = await HDKeyring?.getAccounts(); expect(initialAccounts).toHaveLength(1); @@ -626,8 +626,8 @@ describe('KeyringController', () => { }); }); - describe('getAppKeyAddress', function () { - it('returns the expected app key address', async function () { + describe('getAppKeyAddress', () => { + it('returns the expected app key address', async () => { const address = '0x01560cd3bac62cc6d7e6380600d9317363400896'; const privateKey = '0xb8a9c05beeedb25df85f8d641538cbffedf67216048de9c678ee26260eb91952'; @@ -657,8 +657,8 @@ describe('KeyringController', () => { }); }); - describe('exportAppKeyForAddress', function () { - it('returns a unique key', async function () { + describe('exportAppKeyForAddress', () => { + it('returns a unique key', async () => { const address = '0x01560cd3bac62cc6d7e6380600d9317363400896'; const privateKey = '0xb8a9c05beeedb25df85f8d641538cbffedf67216048de9c678ee26260eb91952'; @@ -683,8 +683,8 @@ describe('KeyringController', () => { }); }); - describe('getKeyringForAccount', function () { - it('throws error when address is not provided', async function () { + describe('getKeyringForAccount', () => { + it('throws error when address is not provided', async () => { await expect( keyringController.getKeyringForAccount(undefined as any), ).rejects.toThrow( @@ -694,7 +694,7 @@ describe('KeyringController', () => { ); }); - it('throws error when there are no keyrings', async function () { + it('throws error when there are no keyrings', async () => { keyringController.keyrings = []; await expect( keyringController.getKeyringForAccount('0x04'), @@ -705,7 +705,7 @@ describe('KeyringController', () => { ); }); - it('throws error when there are no matching keyrings', async function () { + it('throws error when there are no matching keyrings', async () => { keyringController.keyrings = [ { async getAccounts() { @@ -724,8 +724,8 @@ describe('KeyringController', () => { }); }); - describe('cacheEncryptionKey', function () { - it('sets encryption key data upon submitPassword', async function () { + describe('cacheEncryptionKey', () => { + it('sets encryption key data upon submitPassword', async () => { keyringController.cacheEncryptionKey = true; await keyringController.submitPassword(PASSWORD); @@ -736,7 +736,7 @@ describe('KeyringController', () => { ); }); - it('unlocks the keyrings with valid information', async function () { + it('unlocks the keyrings with valid information', async () => { keyringController.cacheEncryptionKey = true; const returnValue = await keyringController.encryptor.decryptWithKey(); const decryptWithKeyStub = stub( @@ -758,7 +758,7 @@ describe('KeyringController', () => { expect(keyringController.keyrings).toHaveLength(1); }); - it('should not load keyrings when invalid encryptionKey format', async function () { + it('should not load keyrings when invalid encryptionKey format', async () => { keyringController.cacheEncryptionKey = true; await keyringController.setLocked(); keyringController.store.updateState({ vault: MOCK_ENCRYPTION_DATA }); @@ -772,7 +772,7 @@ describe('KeyringController', () => { expect(keyringController.keyrings).toHaveLength(0); }); - it('should not load keyrings when encryptionKey is expired', async function () { + it('should not load keyrings when encryptionKey is expired', async () => { keyringController.cacheEncryptionKey = true; await keyringController.setLocked(); keyringController.store.updateState({ vault: MOCK_ENCRYPTION_DATA }); @@ -787,7 +787,7 @@ describe('KeyringController', () => { expect(keyringController.keyrings).toHaveLength(0); }); - it('persists keyrings when actions are performed', async function () { + it('persists keyrings when actions are performed', async () => { keyringController.cacheEncryptionKey = true; await keyringController.setLocked(); keyringController.store.updateState({ vault: MOCK_ENCRYPTION_DATA }); @@ -821,14 +821,14 @@ describe('KeyringController', () => { expect(await keyringController.getAccounts()).toHaveLength(3); }); - it('triggers an error when trying to persist without password or encryption key', async function () { + it('triggers an error when trying to persist without password or encryption key', async () => { keyringController.password = undefined; await expect(keyringController.persistAllKeyrings()).rejects.toThrow( 'Cannot persist vault without password and encryption key', ); }); - it('cleans up login artifacts upon lock', async function () { + it('cleans up login artifacts upon lock', async () => { keyringController.cacheEncryptionKey = true; await keyringController.submitPassword(PASSWORD); expect(keyringController.password).toBe(PASSWORD); @@ -848,7 +848,7 @@ describe('KeyringController', () => { }); }); - describe('exportAccount', function () { + describe('exportAccount', () => { it('returns the private key for the public key it is passed', async () => { await keyringController.createNewVaultAndRestore( PASSWORD, @@ -861,7 +861,7 @@ describe('KeyringController', () => { }); }); - describe('signing methods', function () { + describe('signing methods', () => { beforeEach(async () => { await keyringController.createNewVaultAndRestore( PASSWORD, From 06385150461bb94d8ae5f74cfa41bfd2801d4a80 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 9 Mar 2023 09:16:43 -0300 Subject: [PATCH 053/109] Add KeyringControllerArgs --- src/KeyringController.ts | 6 +++--- src/types.ts | 11 ++++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index 94ee87c0..58252918 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -17,7 +17,7 @@ import { EventEmitter } from 'events'; import ObservableStore from 'obs-store'; import { HEX_PREFIX, KeyringType } from './constants'; -import { State, MessageParams } from './types'; +import { State, MessageParams, KeyringControllerArgs } from './types'; const defaultKeyringBuilders = [ keyringBuilderFactory(SimpleKeyring), @@ -54,9 +54,9 @@ class KeyringController extends EventEmitter { public password?: string | undefined; - constructor(opts: any) { + constructor(opts: KeyringControllerArgs) { super(); - const initState = opts.initState || {}; + const initState = opts.initState ?? {}; this.keyringBuilders = opts.keyringBuilders ? defaultKeyringBuilders.concat(opts.keyringBuilders) : defaultKeyringBuilders; diff --git a/src/types.ts b/src/types.ts index 7d66b078..b3c2e6a8 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,4 +1,4 @@ -import type { Hex, Json, Eip1024EncryptedData } from '@metamask/utils'; +import type { Hex, Json, Keyring, Eip1024EncryptedData } from '@metamask/utils'; export type State = Json; @@ -6,3 +6,12 @@ export type MessageParams = { from: Hex | string; data: Hex | string | Eip1024EncryptedData | Record[]; }; + +export type KeyringControllerArgs = { + initState: State; + keyringBuilders: + | { (): Keyring; type: string } + | ConcatArray<{ (): Keyring; type: string }>; + encryptor: any; + cacheEncryptionKey: boolean; +}; From 526182c6c16499f75ced39fa50f81887975b20a8 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 9 Mar 2023 09:18:32 -0300 Subject: [PATCH 054/109] Add default to opts arg in addNewKeyring --- src/KeyringController.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index 58252918..e5e3f59c 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -260,20 +260,18 @@ class KeyringController extends EventEmitter { */ async addNewKeyring( type: string, - opts?: Record, + opts: Record = {}, ): Promise> { const keyring = await this.#newKeyring( type, - type === KeyringType.Simple && opts?.privateKeys - ? opts?.privateKeys - : opts, + type === KeyringType.Simple && opts.privateKeys ? opts.privateKeys : opts, ); if (!keyring) { throw new Error('KeyringController - No keyring found'); } - if (!opts?.mnemonic && type === KeyringType.HD) { + if (!opts.mnemonic && type === KeyringType.HD) { if (!keyring.generateRandomMnemonic) { throw new Error( `KeyringController - The current keyring does not support the method generateRandomMnemonic.`, From acd549eb31c8e12ab6d7103d66c06fe8ce533313 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 9 Mar 2023 09:18:46 -0300 Subject: [PATCH 055/109] Remove string casting --- src/KeyringController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index e5e3f59c..b7b0bd30 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -337,7 +337,7 @@ class KeyringController extends EventEmitter { case KeyringType.Simple: { const isIncluded = Boolean( accounts.find( - (key: string) => + (key) => key === newAccountArray[0] || key === stripHexPrefix(newAccountArray[0] as string), ), From 1d38cfc72fecec992244815ed2506065d65c8427 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 9 Mar 2023 09:23:14 -0300 Subject: [PATCH 056/109] Declare backfilled types --- types/@metamask/eth-hd-keyring.d.ts | 2 ++ declarations.d.ts => types/@metamask/eth-simple-keyring.d.ts | 2 -- types/obs-store.d.ts | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 types/@metamask/eth-hd-keyring.d.ts rename declarations.d.ts => types/@metamask/eth-simple-keyring.d.ts (56%) create mode 100644 types/obs-store.d.ts diff --git a/types/@metamask/eth-hd-keyring.d.ts b/types/@metamask/eth-hd-keyring.d.ts new file mode 100644 index 00000000..957e0663 --- /dev/null +++ b/types/@metamask/eth-hd-keyring.d.ts @@ -0,0 +1,2 @@ +// eslint-disable-next-line import/unambiguous +declare module '@metamask/eth-hd-keyring'; diff --git a/declarations.d.ts b/types/@metamask/eth-simple-keyring.d.ts similarity index 56% rename from declarations.d.ts rename to types/@metamask/eth-simple-keyring.d.ts index 8c9915ac..a44ddd1e 100644 --- a/declarations.d.ts +++ b/types/@metamask/eth-simple-keyring.d.ts @@ -1,4 +1,2 @@ // eslint-disable-next-line import/unambiguous -declare module '@metamask/eth-hd-keyring'; declare module '@metamask/eth-simple-keyring'; -declare module 'obs-store'; diff --git a/types/obs-store.d.ts b/types/obs-store.d.ts new file mode 100644 index 00000000..fd81cf19 --- /dev/null +++ b/types/obs-store.d.ts @@ -0,0 +1,2 @@ +// eslint-disable-next-line import/unambiguous +declare module 'obs-store'; From 8aa5ba07f5c2e9a1acba22b2a3d6d47ca646ad95 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 9 Mar 2023 10:42:08 -0300 Subject: [PATCH 057/109] Rename arg from _address to rawAddress --- src/KeyringController.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index b7b0bd30..80d26b4b 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -440,16 +440,16 @@ class KeyringController extends EventEmitter { * Signs an Ethereum transaction object. * * @param ethTx - The transaction to sign. - * @param _address - The transaction 'from' address. + * @param rawAddress - The transaction 'from' address. * @param opts - Signing options. * @returns The signed transaction object. */ async signTransaction( ethTx: TypedTransaction, - _address: string | Hex, + rawAddress: string | Hex, opts: Record = {}, ): Promise { - const address = normalizeAddress(_address) as Hex; + const address = normalizeAddress(rawAddress) as Hex; const keyring = await this.getKeyringForAccount(address); if (!keyring.signTransaction) { throw new Error( @@ -590,16 +590,16 @@ class KeyringController extends EventEmitter { /** * Gets the app key address for the given Ethereum address and origin. * - * @param _address - The Ethereum address for the app key. + * @param rawAddress - The Ethereum address for the app key. * @param origin - The origin for the app key. * @returns The app key address. */ - async getAppKeyAddress(_address: string, origin: string): Promise { - const address = normalizeAddress(_address) as Hex; + async getAppKeyAddress(rawAddress: string, origin: string): Promise { + const address = normalizeAddress(rawAddress) as Hex; const keyring = await this.getKeyringForAccount(address); if (!keyring.getAppKeyAddress) { throw new Error( - `KeyringController - The keyring for address ${_address} does not support the method getAppKeyAddress.`, + `KeyringController - The keyring for address ${rawAddress} does not support the method getAppKeyAddress.`, ); } @@ -609,15 +609,15 @@ class KeyringController extends EventEmitter { /** * Exports an app key private key for the given Ethereum address and origin. * - * @param _address - The Ethereum address for the app key. + * @param rawAddress - The Ethereum address for the app key. * @param origin - The origin for the app key. * @returns The app key private key. */ async exportAppKeyForAddress( - _address: string, + rawAddress: string, origin: string, ): Promise { - const address = normalizeAddress(_address) as Hex; + const address = normalizeAddress(rawAddress) as Hex; const keyring = await this.getKeyringForAccount(address); // The "in" operator is typically restricted because it also checks inherited properties, // which can be unexpected for plain objects. We're allowing it here because `keyring` is not @@ -625,7 +625,7 @@ class KeyringController extends EventEmitter { // eslint-disable-next-line no-restricted-syntax if (!keyring.exportAccount) { throw new Error( - `KeyringController - The keyring for address ${_address} does not support exporting.`, + `KeyringController - The keyring for address ${rawAddress} does not support exporting.`, ); } return keyring.exportAccount(address, { withAppKeyOrigin: origin }); From c59a8321d0e304c13b5aa9b09841356908b2cee5 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 9 Mar 2023 11:28:22 -0300 Subject: [PATCH 058/109] Remove noImplicitAny --- tsconfig.json | 1 - 1 file changed, 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index ab813717..271268db 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,6 @@ "noUncheckedIndexedAccess": true, "strict": true, "target": "ES2017", - "noImplicitAny": false }, "exclude": ["./dist/**/*", "node_modules"] } From f609772065886c279c181bb532dfe5cdb4c94751 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 9 Mar 2023 11:29:09 -0300 Subject: [PATCH 059/109] Remove unneed optionals --- src/KeyringController.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index 80d26b4b..2b39b481 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -959,7 +959,7 @@ class KeyringController extends EventEmitter { return accounts.includes(hexed); }); - if (winners?.length && winners?.[0]?.length) { + if (winners.length && winners[0]?.length) { return winners[0][0]; } @@ -967,9 +967,9 @@ class KeyringController extends EventEmitter { let errorInfo = ''; if (!address) { errorInfo = 'The address passed in is invalid/empty'; - } else if (!candidates?.length) { + } else if (!candidates.length) { errorInfo = 'There are no keyrings'; - } else if (!winners?.length) { + } else if (!winners.length) { errorInfo = 'There are keyrings, but none match the address'; } throw new Error( From 17b6354ac68b7508105a157eef3b3b77e87bce2d Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 9 Mar 2023 11:29:58 -0300 Subject: [PATCH 060/109] Update data type for arg in newKeyring method --- src/KeyringController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index 2b39b481..e47e5ce8 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -1031,7 +1031,7 @@ class KeyringController extends EventEmitter { * @param data - The data to restore a previously serialized keyring. * @returns The new keyring. */ - async #newKeyring(type: string, data: any): Promise | void> { + async #newKeyring(type: string, data: State): Promise | void> { const keyringBuilder = this.#getKeyringBuilderForType(type); if (!keyringBuilder) { From 70d5d8cd1462e130dad5c67f51ffed8b359cbf99 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 9 Mar 2023 13:33:24 -0300 Subject: [PATCH 061/109] Fix style --- tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 271268db..972fa493 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,7 +10,7 @@ "noErrorTruncation": true, "noUncheckedIndexedAccess": true, "strict": true, - "target": "ES2017", + "target": "ES2017" }, "exclude": ["./dist/**/*", "node_modules"] } From d892064577979a7b9c71f0fad743a86d52e683c3 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 9 Mar 2023 13:38:33 -0300 Subject: [PATCH 062/109] Improve KeyringControllerArgs --- src/KeyringController.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index e47e5ce8..b3126f68 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -54,11 +54,15 @@ class KeyringController extends EventEmitter { public password?: string | undefined; - constructor(opts: KeyringControllerArgs) { + constructor({ + keyringBuilders, + cacheEncryptionKey, + initState = {}, + encryptor = encryptorMM, + }: KeyringControllerArgs) { super(); - const initState = opts.initState ?? {}; - this.keyringBuilders = opts.keyringBuilders - ? defaultKeyringBuilders.concat(opts.keyringBuilders) + this.keyringBuilders = keyringBuilders + ? defaultKeyringBuilders.concat(keyringBuilders) : defaultKeyringBuilders; this.store = new ObservableStore(initState); this.memStore = new ObservableStore({ @@ -70,13 +74,13 @@ class KeyringController extends EventEmitter { encryptionKey: null, }); - this.encryptor = opts.encryptor || encryptor; + this.encryptor = encryptor; this.keyrings = []; this.unsupportedKeyrings = []; // This option allows the controller to cache an exported key // for use in decrypting and encrypting data without password - this.cacheEncryptionKey = Boolean(opts.cacheEncryptionKey); + this.cacheEncryptionKey = Boolean(cacheEncryptionKey); } /** From 13240e639bf103b7e25ef4c7a030e2f9264cb616 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 9 Mar 2023 13:39:03 -0300 Subject: [PATCH 063/109] Update logic in addNewKeyring for switch-case statement --- src/KeyringController.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index b3126f68..3821b573 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -266,10 +266,15 @@ class KeyringController extends EventEmitter { type: string, opts: Record = {}, ): Promise> { - const keyring = await this.#newKeyring( - type, - type === KeyringType.Simple && opts.privateKeys ? opts.privateKeys : opts, - ); + let keyring: Keyring; + switch (type) { + case KeyringType.Simple: + keyring = await this.#newKeyring(type, opts.privateKeys); + break; + default: + keyring = await this.#newKeyring(type, opts); + break; + } if (!keyring) { throw new Error('KeyringController - No keyring found'); From 1b460f3992609c6c9900e603b0a36204fe451d13 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 9 Mar 2023 13:39:47 -0300 Subject: [PATCH 064/109] Update import --- src/KeyringController.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index 3821b573..fca418ed 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -1,5 +1,5 @@ import type { TypedTransaction, TxData } from '@ethereumjs/tx'; -import encryptor from '@metamask/browser-passworder'; +import * as encryptorUtils from '@metamask/browser-passworder'; import HDKeyring from '@metamask/eth-hd-keyring'; import { normalize as normalizeAddress } from '@metamask/eth-sig-util'; import SimpleKeyring from '@metamask/eth-simple-keyring'; @@ -58,7 +58,7 @@ class KeyringController extends EventEmitter { keyringBuilders, cacheEncryptionKey, initState = {}, - encryptor = encryptorMM, + encryptor = encryptorUtils, }: KeyringControllerArgs) { super(); this.keyringBuilders = keyringBuilders From 05c1920a50c373bb11ae0d126217108b223ef559 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 9 Mar 2023 13:40:28 -0300 Subject: [PATCH 065/109] Update logic for newKeyring to throw an error instead of returning undefined --- src/KeyringController.ts | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index fca418ed..3870caaa 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -890,12 +890,23 @@ class KeyringController extends EventEmitter { * On success, returns the resulting keyring instance. * * @param serialized - The serialized keyring. + * @param serialized.type - Keyring type. + * @param serialized.data - Keyring data. * @returns The deserialized keyring or undefined if the keyring type is unsupported. */ - async #restoreKeyring(serialized: any): Promise | undefined> { + async #restoreKeyring(serialized: { + type: KeyringType.HD; + data: Json; + }): Promise | undefined> { const { type, data } = serialized; - const keyring = await this.#newKeyring(type, data); + let keyring: Keyring | undefined; + try { + keyring = await this.#newKeyring(type, data); + } catch { + // Error + } + if (!keyring) { this.unsupportedKeyrings.push(serialized); return undefined; @@ -1040,11 +1051,13 @@ class KeyringController extends EventEmitter { * @param data - The data to restore a previously serialized keyring. * @returns The new keyring. */ - async #newKeyring(type: string, data: State): Promise | void> { + async #newKeyring(type: string, data: unknown): Promise> { const keyringBuilder = this.#getKeyringBuilderForType(type); if (!keyringBuilder) { - return undefined; + throw new Error( + `KeyringController - No keyringBuilder found for keyring of type ${type}`, + ); } const keyring = keyringBuilder(); From 8915012fbf1bc2060d1dd040fcfe7c3e35aa5fa9 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 9 Mar 2023 13:42:13 -0300 Subject: [PATCH 066/109] Update types in tests --- src/KeyringController.test.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/KeyringController.test.ts b/src/KeyringController.test.ts index 93c17a16..cc3bb384 100644 --- a/src/KeyringController.test.ts +++ b/src/KeyringController.test.ts @@ -42,6 +42,7 @@ describe('KeyringController', () => { beforeEach(async () => { keyringController = new KeyringController({ encryptor: mockEncryptor, + cacheEncryptionKey: false, keyringBuilders: [ keyringBuilderFactory( KeyringMockWithInit as unknown as KeyringClass, @@ -115,8 +116,11 @@ describe('KeyringController', () => { await keyringController.persistAllKeyrings(); const { vault } = keyringController.store.getState(); - const keyrings = await mockEncryptor.decrypt(PASSWORD, vault); - expect(keyrings.indexOf(unsupportedKeyring) > -1).toBe(true); + const keyrings = (await mockEncryptor.decrypt(PASSWORD, vault)) as { + type: string; + data: State; + }[]; + expect(keyrings).toContain(unsupportedKeyring); expect(keyrings).toHaveLength(2); }); @@ -592,7 +596,13 @@ describe('KeyringController', () => { describe('verifyPassword', () => { beforeEach(() => { keyringController = new KeyringController({ + keyringBuilders: [ + keyringBuilderFactory( + KeyringMockWithInit as unknown as KeyringClass, + ), + ], encryptor: mockEncryptor, + cacheEncryptionKey: false, }); }); From 3550b93c1d52f865fa561bd11740c176419da228 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 9 Mar 2023 13:42:28 -0300 Subject: [PATCH 067/109] Update KeyringControllerArgs in types file --- src/types.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/types.ts b/src/types.ts index b3c2e6a8..584cff58 100644 --- a/src/types.ts +++ b/src/types.ts @@ -8,10 +8,11 @@ export type MessageParams = { }; export type KeyringControllerArgs = { - initState: State; keyringBuilders: | { (): Keyring; type: string } | ConcatArray<{ (): Keyring; type: string }>; - encryptor: any; + cacheEncryptionKey: boolean; + initState?: State; + encryptor?: any; }; From b257e312b63129bbf075561c512c7b8ef3af1705 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 9 Mar 2023 13:42:41 -0300 Subject: [PATCH 068/109] Update mocks --- src/mocks/encryptor.mock.ts | 14 ++++++++------ src/mocks/keyring.mock.ts | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/mocks/encryptor.mock.ts b/src/mocks/encryptor.mock.ts index be8ea341..1b0677e3 100644 --- a/src/mocks/encryptor.mock.ts +++ b/src/mocks/encryptor.mock.ts @@ -1,5 +1,7 @@ import { stub } from 'sinon'; +import { State } from '../types'; + const PASSWORD = 'password123'; const MOCK_ENCRYPTION_KEY = JSON.stringify({ alg: 'A256GCM', @@ -19,16 +21,16 @@ const MOCK_HEX = '0xabcdef0123456789'; const MOCK_SALT = 'SALT'; // eslint-disable-next-line no-restricted-globals const MOCK_KEY = Buffer.alloc(32); -let cacheVal; +let cacheVal: State; const mockEncryptor = { - encrypt: stub().callsFake(async function (_password, dataObj) { + encrypt: stub().callsFake(async (_password, dataObj) => { cacheVal = dataObj; return Promise.resolve(MOCK_HEX); }), - encryptWithDetail: stub().callsFake(async function (_password, dataObj) { + encryptWithDetail: stub().callsFake(async (_password, dataObj) => { cacheVal = dataObj; return Promise.resolve({ @@ -37,15 +39,15 @@ const mockEncryptor = { }); }), - async decrypt(_password, _text) { + async decrypt(_password: string, _text: string) { if (_password && _password !== PASSWORD) { throw new Error(INVALID_PASSWORD_ERROR); } - return Promise.resolve(cacheVal || {}); + return Promise.resolve(cacheVal ?? {}); }, - async decryptWithEncryptedKeyString(_keyStr) { + async decryptWithEncryptedKeyString(_keyStr: string) { const { vault } = await this.decryptWithDetail(_keyStr, 'mock vault'); return vault; }, diff --git a/src/mocks/keyring.mock.ts b/src/mocks/keyring.mock.ts index a520d131..23b09030 100644 --- a/src/mocks/keyring.mock.ts +++ b/src/mocks/keyring.mock.ts @@ -13,7 +13,7 @@ class KeyringMockWithInit { return Promise.resolve({}); } - async deserialize(_) { + async deserialize(_: any) { return Promise.resolve(); } } From a96cbca2a56dae5add872959dc8432488c4a056b Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 9 Mar 2023 14:48:50 -0300 Subject: [PATCH 069/109] Add backfill for normalize method and remove type casting --- src/KeyringController.ts | 18 +++++++++--------- types/@metamask/eth-sig-util.d.ts | 7 +++++++ 2 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 types/@metamask/eth-sig-util.d.ts diff --git a/src/KeyringController.ts b/src/KeyringController.ts index 3870caaa..a25a5ba7 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -404,7 +404,7 @@ class KeyringController extends EventEmitter { ); } - return await keyring.exportAccount(normalizeAddress(address) as Hex); + return await keyring.exportAccount(normalizeAddress(address)); } /** @@ -458,7 +458,7 @@ class KeyringController extends EventEmitter { rawAddress: string | Hex, opts: Record = {}, ): Promise { - const address = normalizeAddress(rawAddress) as Hex; + const address = normalizeAddress(rawAddress); const keyring = await this.getKeyringForAccount(address); if (!keyring.signTransaction) { throw new Error( @@ -482,7 +482,7 @@ class KeyringController extends EventEmitter { msgParams: MessageParams, opts: Record = {}, ) { - const address = normalizeAddress(msgParams.from) as Hex; + const address = normalizeAddress(msgParams.from); const keyring = await this.getKeyringForAccount(address); if (!keyring.signMessage) { throw new Error( @@ -507,7 +507,7 @@ class KeyringController extends EventEmitter { msgParams: MessageParams, opts: Record = {}, ): Promise { - const address = normalizeAddress(msgParams.from) as Hex; + const address = normalizeAddress(msgParams.from); const keyring = await this.getKeyringForAccount(address); if (!keyring.signPersonalMessage) { throw new Error( @@ -535,7 +535,7 @@ class KeyringController extends EventEmitter { address: string | Hex, opts: Record = {}, ): Promise { - const normalizedAddress = normalizeAddress(address) as Hex; + const normalizedAddress = normalizeAddress(address); const keyring = await this.getKeyringForAccount(address); if (!keyring.getEncryptionPublicKey) { throw new Error( @@ -555,7 +555,7 @@ class KeyringController extends EventEmitter { * @returns The raw decryption result. */ async decryptMessage(msgParams: MessageParams): Promise { - const address = normalizeAddress(msgParams.from) as Hex; + const address = normalizeAddress(msgParams.from); const keyring = await this.getKeyringForAccount(address); if (!keyring.decryptMessage) { throw new Error( @@ -581,7 +581,7 @@ class KeyringController extends EventEmitter { msgParams: MessageParams, opts = { version: 'V1' }, ): Promise { - const address = normalizeAddress(msgParams.from) as Hex; + const address = normalizeAddress(msgParams.from); const keyring = await this.getKeyringForAccount(address); if (!keyring.signTypedData) { throw new Error( @@ -604,7 +604,7 @@ class KeyringController extends EventEmitter { * @returns The app key address. */ async getAppKeyAddress(rawAddress: string, origin: string): Promise { - const address = normalizeAddress(rawAddress) as Hex; + const address = normalizeAddress(rawAddress); const keyring = await this.getKeyringForAccount(address); if (!keyring.getAppKeyAddress) { throw new Error( @@ -626,7 +626,7 @@ class KeyringController extends EventEmitter { rawAddress: string, origin: string, ): Promise { - const address = normalizeAddress(rawAddress) as Hex; + const address = normalizeAddress(rawAddress); const keyring = await this.getKeyringForAccount(address); // The "in" operator is typically restricted because it also checks inherited properties, // which can be unexpected for plain objects. We're allowing it here because `keyring` is not diff --git a/types/@metamask/eth-sig-util.d.ts b/types/@metamask/eth-sig-util.d.ts new file mode 100644 index 00000000..63e2eb0f --- /dev/null +++ b/types/@metamask/eth-sig-util.d.ts @@ -0,0 +1,7 @@ +// eslint-disable-next-line import/unambiguous +declare module '@metamask/eth-sig-util' { + import { Hex } from '@metamask/utils'; + + function normalize(address: string | Hex): Hex; + export { normalize }; +} From 9b48af0207631618e30a0076580cefc177e82746 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 9 Mar 2023 15:06:53 -0300 Subject: [PATCH 070/109] Fix data type --- src/KeyringController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index a25a5ba7..5ec2a220 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -895,7 +895,7 @@ class KeyringController extends EventEmitter { * @returns The deserialized keyring or undefined if the keyring type is unsupported. */ async #restoreKeyring(serialized: { - type: KeyringType.HD; + type: KeyringType; data: Json; }): Promise | undefined> { const { type, data } = serialized; From ce7d126375790bd07789a82f6c9609f0a2eb9813 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 9 Mar 2023 16:49:20 -0300 Subject: [PATCH 071/109] Add SerializedKeyring --- src/KeyringController.ts | 20 +++++++++++++------- src/types.ts | 6 ++++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index 5ec2a220..1e69f464 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -17,7 +17,12 @@ import { EventEmitter } from 'events'; import ObservableStore from 'obs-store'; import { HEX_PREFIX, KeyringType } from './constants'; -import { State, MessageParams, KeyringControllerArgs } from './types'; +import { + State, + MessageParams, + SerializedKeyring, + KeyringControllerArgs, +} from './types'; const defaultKeyringBuilders = [ keyringBuilderFactory(SimpleKeyring), @@ -50,7 +55,7 @@ class KeyringController extends EventEmitter { public cacheEncryptionKey: boolean; - public unsupportedKeyrings: { type: string; data: Json }[]; + public unsupportedKeyrings: SerializedKeyring[]; public password?: string | undefined; @@ -650,7 +655,9 @@ class KeyringController extends EventEmitter { * @param serialized - The serialized keyring. * @returns The deserialized keyring. */ - async restoreKeyring(serialized: any): Promise | undefined> { + async restoreKeyring( + serialized: SerializedKeyring, + ): Promise | undefined> { const keyring = await this.#restoreKeyring(serialized); if (keyring) { await this.#updateMemStoreKeyrings(); @@ -894,10 +901,9 @@ class KeyringController extends EventEmitter { * @param serialized.data - Keyring data. * @returns The deserialized keyring or undefined if the keyring type is unsupported. */ - async #restoreKeyring(serialized: { - type: KeyringType; - data: Json; - }): Promise | undefined> { + async #restoreKeyring( + serialized: SerializedKeyring, + ): Promise | undefined> { const { type, data } = serialized; let keyring: Keyring | undefined; diff --git a/src/types.ts b/src/types.ts index 584cff58..8d8afce3 100644 --- a/src/types.ts +++ b/src/types.ts @@ -16,3 +16,9 @@ export type KeyringControllerArgs = { initState?: State; encryptor?: any; }; + +export type SerializedKeyring = { + type: string; + data: Json; +}; + From b620d2a3ffcef7de97cf0cae13c86da017878ced Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 9 Mar 2023 17:44:40 -0300 Subject: [PATCH 072/109] Lint --- src/types.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/types.ts b/src/types.ts index 8d8afce3..157435da 100644 --- a/src/types.ts +++ b/src/types.ts @@ -21,4 +21,3 @@ export type SerializedKeyring = { type: string; data: Json; }; - From ded3cef9e5448062cfe5ff1fb9c8d9fc20fe5106 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 9 Mar 2023 18:35:36 -0300 Subject: [PATCH 073/109] Move mocks to test dir --- src/KeyringController.test.ts | 2 +- src/{mocks => test}/encryptor.mock.ts | 0 src/{mocks => test}/index.ts | 0 src/{mocks => test}/keyring.mock.ts | 0 4 files changed, 1 insertion(+), 1 deletion(-) rename src/{mocks => test}/encryptor.mock.ts (100%) rename src/{mocks => test}/index.ts (100%) rename src/{mocks => test}/keyring.mock.ts (100%) diff --git a/src/KeyringController.test.ts b/src/KeyringController.test.ts index cc3bb384..75f3bdc2 100644 --- a/src/KeyringController.test.ts +++ b/src/KeyringController.test.ts @@ -13,7 +13,7 @@ import { PASSWORD, MOCK_HARDCODED_KEY, MOCK_HEX, -} from './mocks'; +} from './test'; import { State } from './types'; const MOCK_ENCRYPTION_KEY = diff --git a/src/mocks/encryptor.mock.ts b/src/test/encryptor.mock.ts similarity index 100% rename from src/mocks/encryptor.mock.ts rename to src/test/encryptor.mock.ts diff --git a/src/mocks/index.ts b/src/test/index.ts similarity index 100% rename from src/mocks/index.ts rename to src/test/index.ts diff --git a/src/mocks/keyring.mock.ts b/src/test/keyring.mock.ts similarity index 100% rename from src/mocks/keyring.mock.ts rename to src/test/keyring.mock.ts From 352b11cab967de2377dd6b7ac570218660126997 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 9 Mar 2023 18:41:48 -0300 Subject: [PATCH 074/109] Update build config --- tsconfig.build.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tsconfig.build.json b/tsconfig.build.json index 67ab8057..43db3a45 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -8,8 +8,9 @@ "rootDir": "src", "sourceMap": true }, - "include": ["./src/**/*.ts"], + "include": ["./src/**/*.ts", "./types"], "exclude": [ + "./src/test/**/*.ts", "./src/**/*.test.ts", "./src/**/*.test-d.ts", "./src/__fixtures__" From 476124b7ba759f5880f79cdd5e565419473b4600 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 9 Mar 2023 18:44:10 -0300 Subject: [PATCH 075/109] Improve keyring mock --- src/test/keyring.mock.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/test/keyring.mock.ts b/src/test/keyring.mock.ts index 23b09030..aafc4ea5 100644 --- a/src/test/keyring.mock.ts +++ b/src/test/keyring.mock.ts @@ -1,5 +1,5 @@ class KeyringMockWithInit { - static type: string; + static type = 'Keyring Mock With Init'; async init() { return Promise.resolve(); @@ -18,6 +18,4 @@ class KeyringMockWithInit { } } -KeyringMockWithInit.type = 'Keyring Mock With Init'; - export default KeyringMockWithInit; From 7f2918616b9d3f2aad483dc00515cadc0ae3a0f2 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Sat, 11 Mar 2023 23:15:40 -0300 Subject: [PATCH 076/109] Improve error messages --- src/KeyringController.ts | 98 ++++++++++++---------------------------- src/constants.ts | 24 ++++++++++ 2 files changed, 53 insertions(+), 69 deletions(-) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index 1e69f464..129683b6 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -16,7 +16,7 @@ import type { import { EventEmitter } from 'events'; import ObservableStore from 'obs-store'; -import { HEX_PREFIX, KeyringType } from './constants'; +import { HEX_PREFIX, KeyringType, KeyringControllerError } from './constants'; import { State, MessageParams, @@ -143,9 +143,7 @@ class KeyringController extends EventEmitter { seedPhrase: Uint8Array | string | number[], ): Promise { if (typeof password !== 'string') { - throw new TypeError( - 'KeyringController - Password must be of type string.', - ); + throw new TypeError(KeyringControllerError.WrongPasswordType); } this.password = password; @@ -156,13 +154,13 @@ class KeyringController extends EventEmitter { }); if (!keyring) { - throw new Error('KeyringController - No keyring found'); + throw new Error(KeyringControllerError.NoKeyring); } const [firstAccount] = await keyring.getAccounts(); if (!firstAccount) { - throw new Error('KeyringController - First Account not found.'); + throw new Error(KeyringControllerError.NoFirstAccount); } this.#setUnlocked(); return this.#fullUpdate(); @@ -247,9 +245,7 @@ class KeyringController extends EventEmitter { async verifyPassword(password: string): Promise { const encryptedVault = this.store.getState().vault; if (!encryptedVault) { - throw new Error( - 'KeyringController - Cannot unlock without a previous vault.', - ); + throw new Error(KeyringControllerError.VaultError); } await this.encryptor.decrypt(password, encryptedVault); } @@ -282,13 +278,13 @@ class KeyringController extends EventEmitter { } if (!keyring) { - throw new Error('KeyringController - No keyring found'); + throw new Error(KeyringControllerError.NoKeyring); } if (!opts.mnemonic && type === KeyringType.HD) { if (!keyring.generateRandomMnemonic) { throw new Error( - `KeyringController - The current keyring does not support the method generateRandomMnemonic.`, + KeyringControllerError.UnsupportedGenerateRandomMnemonic, ); } @@ -358,9 +354,7 @@ class KeyringController extends EventEmitter { ); if (isIncluded) { - throw new Error( - 'KeyringController - The account you are trying to import is a duplicate', - ); + throw new Error(KeyringControllerError.DuplicatedAccount); } return newAccountArray; } @@ -404,9 +398,7 @@ class KeyringController extends EventEmitter { async exportAccount(address: Hex): Promise { const keyring = await this.getKeyringForAccount(address); if (!keyring.exportAccount) { - throw new Error( - `KeyringController - The keyring for address ${address} does not support the method exportAccount.`, - ); + throw new Error(KeyringControllerError.UnsupportedExportAccount); } return await keyring.exportAccount(normalizeAddress(address)); @@ -429,9 +421,7 @@ class KeyringController extends EventEmitter { keyring.removeAccount(address); this.emit('removedAccount', address); } else { - throw new Error( - `KeyringController - Keyring ${keyring.type} doesn't support account removal operations`, - ); + throw new Error(KeyringControllerError.UnsupportedRemoveAccount); } const accounts = await keyring.getAccounts(); @@ -466,9 +456,7 @@ class KeyringController extends EventEmitter { const address = normalizeAddress(rawAddress); const keyring = await this.getKeyringForAccount(address); if (!keyring.signTransaction) { - throw new Error( - `KeyringController - The keyring for address ${address} does not support the method signTransaction.`, - ); + throw new Error(KeyringControllerError.UnsupportedSignTransaction); } return await keyring.signTransaction(address, ethTx, opts); @@ -490,9 +478,7 @@ class KeyringController extends EventEmitter { const address = normalizeAddress(msgParams.from); const keyring = await this.getKeyringForAccount(address); if (!keyring.signMessage) { - throw new Error( - `KeyringController - The keyring for address ${address} does not support the method signMessage.`, - ); + throw new Error(KeyringControllerError.UnsupportedSignMessage); } return await keyring.signMessage(address, msgParams.data as string, opts); @@ -515,9 +501,7 @@ class KeyringController extends EventEmitter { const address = normalizeAddress(msgParams.from); const keyring = await this.getKeyringForAccount(address); if (!keyring.signPersonalMessage) { - throw new Error( - `KeyringController - The keyring for address ${address} does not support the method signPersonalMessage.`, - ); + throw new Error(KeyringControllerError.UnsupportedSignPersonalMessage); } return await keyring.signPersonalMessage( @@ -543,9 +527,7 @@ class KeyringController extends EventEmitter { const normalizedAddress = normalizeAddress(address); const keyring = await this.getKeyringForAccount(address); if (!keyring.getEncryptionPublicKey) { - throw new Error( - `KeyringController - The keyring for address ${address} does not support the method getEncryptionPublicKey.`, - ); + throw new Error(KeyringControllerError.UnsupportedGetEncryptionPublicKey); } return await keyring.getEncryptionPublicKey(normalizedAddress, opts); @@ -563,9 +545,7 @@ class KeyringController extends EventEmitter { const address = normalizeAddress(msgParams.from); const keyring = await this.getKeyringForAccount(address); if (!keyring.decryptMessage) { - throw new Error( - `KeyringController - The keyring for address ${address} does not support the method decryptMessage.`, - ); + throw new Error(KeyringControllerError.UnsupportedDecryptMessage); } return keyring.decryptMessage( @@ -589,9 +569,7 @@ class KeyringController extends EventEmitter { const address = normalizeAddress(msgParams.from); const keyring = await this.getKeyringForAccount(address); if (!keyring.signTypedData) { - throw new Error( - `KeyringController - The keyring for address ${address} does not support the method signTypedData.`, - ); + throw new Error(KeyringControllerError.UnsupportedSignTypedMessage); } return keyring.signTypedData( @@ -612,9 +590,7 @@ class KeyringController extends EventEmitter { const address = normalizeAddress(rawAddress); const keyring = await this.getKeyringForAccount(address); if (!keyring.getAppKeyAddress) { - throw new Error( - `KeyringController - The keyring for address ${rawAddress} does not support the method getAppKeyAddress.`, - ); + throw new Error(KeyringControllerError.UnsupportedGetAppKeyAddress); } return keyring.getAppKeyAddress(address, origin); @@ -638,9 +614,7 @@ class KeyringController extends EventEmitter { // a plain object, and we explicitly want to include inherited methods in this check. // eslint-disable-next-line no-restricted-syntax if (!keyring.exportAccount) { - throw new Error( - `KeyringController - The keyring for address ${rawAddress} does not support exporting.`, - ); + throw new Error(KeyringControllerError.UnsupportedExportAppKeyForAddress); } return keyring.exportAccount(address, { withAppKeyOrigin: origin }); } @@ -711,12 +685,12 @@ class KeyringController extends EventEmitter { const keyring = await this.addNewKeyring(KeyringType.HD); if (!keyring) { - throw new Error('KeyringController - No keyring found'); + throw new Error(KeyringControllerError.NoKeyring); } const [firstAccount] = await keyring.getAccounts(); if (!firstAccount) { - throw new Error('KeyringController - No account found on keychain.'); + throw new Error(KeyringControllerError.NoAccountOnKeychain); } const hexAccount = normalizeAddress(firstAccount); @@ -738,9 +712,7 @@ class KeyringController extends EventEmitter { const { encryptionKey, encryptionSalt } = this.memStore.getState(); if (!this.password && !encryptionKey) { - throw new Error( - 'KeyringController - Cannot persist vault without password and encryption key', - ); + throw new Error(KeyringControllerError.MissingCredentials); } const serializedKeyrings = await Promise.all( @@ -779,17 +751,13 @@ class KeyringController extends EventEmitter { } } else { if (typeof this.password !== 'string') { - throw new TypeError( - 'KeyringController - password must be of type string', - ); + throw new TypeError(KeyringControllerError.WrongPasswordType); } vault = await this.encryptor.encrypt(this.password, serializedKeyrings); } if (!vault) { - throw new Error( - 'KeyringController - Cannot persist vault without vault information', - ); + throw new Error(KeyringControllerError.MissingVaultData); } this.store.updateState({ vault }); @@ -827,9 +795,7 @@ class KeyringController extends EventEmitter { ): Promise[]> { const encryptedVault = this.store.getState().vault; if (!encryptedVault) { - throw new Error( - 'KeyringController - Cannot unlock without a previous vault.', - ); + throw new Error(KeyringControllerError.VaultError); } await this.#clearKeyrings(); @@ -853,15 +819,11 @@ class KeyringController extends EventEmitter { const parsedEncryptedVault = JSON.parse(encryptedVault); if (encryptionSalt !== parsedEncryptedVault.salt) { - throw new Error( - 'KeyringController - Encryption key and salt provided are expired', - ); + throw new Error(KeyringControllerError.ExpiredCredentials); } if (typeof encryptionKey !== 'string') { - throw new Error( - 'KeyringController: encryptionKey must be of type string', - ); + throw new TypeError(KeyringControllerError.WrongPasswordType); } const key = await this.encryptor.importKey(encryptionKey); @@ -876,9 +838,7 @@ class KeyringController extends EventEmitter { } } else { if (typeof password !== 'string') { - throw new TypeError( - 'KeyringControlle - password must be of type string', - ); + throw new TypeError(KeyringControllerError.WrongPasswordType); } vault = await this.encryptor.decrypt(password, encryptedVault); @@ -999,7 +959,7 @@ class KeyringController extends EventEmitter { errorInfo = 'There are keyrings, but none match the address'; } throw new Error( - `KeyringController - No keyring found for the requested account. Error info: ${errorInfo}`, + `${KeyringControllerError.NoKeyring}. Error info: ${errorInfo}`, ); } @@ -1062,7 +1022,7 @@ class KeyringController extends EventEmitter { if (!keyringBuilder) { throw new Error( - `KeyringController - No keyringBuilder found for keyring of type ${type}`, + `${KeyringControllerError.NoKeyringBuilder}. Keyring type: ${type}`, ); } diff --git a/src/constants.ts b/src/constants.ts index 11085b9a..503eabb8 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -4,3 +4,27 @@ export enum KeyringType { HD = 'HD Key Tree', Simple = 'Simple Key Pair', } + +export enum KeyringControllerError { + NoKeyring = 'KeyringController - No keyring found', + WrongPasswordType = 'KeyringController - Password must be of type string.', + NoFirstAccount = 'KeyringController - First Account not found.', + DuplicatedAccount = 'KeyringController - The account you are trying to import is a duplicate', + VaultError = 'KeyringController - Cannot unlock without a previous vault.', + UnsupportedGenerateRandomMnemonic = 'KeyringController - The current keyring does not support the method generateRandomMnemonic.', + UnsupportedExportAccount = '`KeyringController - The keyring for the current address does not support the method exportAccount', + UnsupportedRemoveAccount = '`KeyringController - The keyring for the current address does not support the method removeAccount', + UnsupportedSignTransaction = 'KeyringController - The keyring for the current address does not support the method signTransaction.', + UnsupportedSignMessage = 'KeyringController - The keyring for the current address does not support the method signMessage.', + UnsupportedSignPersonalMessage = 'KeyringController - The keyring for the current address does not support the method signPersonalMessage.', + UnsupportedGetEncryptionPublicKey = 'KeyringController - The keyring for the current address does not support the method getEncryptionPublicKey.', + UnsupportedDecryptMessage = 'KeyringController - The keyring for the current address does not support the method decryptMessage.', + UnsupportedSignTypedMessage = 'KeyringController - The keyring for the current address does not support the method signTypedMessage.', + UnsupportedGetAppKeyAddress = 'KeyringController - The keyring for the current address does not support the method getAppKeyAddress.', + UnsupportedExportAppKeyForAddress = 'KeyringController - The keyring for the current address does not support the method exportAppKeyForAddress.', + NoAccountOnKeychain = 'KeyringController - The keyring for the current address does not support the method decryptMessage.', + MissingCredentials = 'KeyringController - Cannot persist vault without password and encryption key', + MissingVaultData = 'KeyringController - Cannot persist vault without vault information', + ExpiredCredentials = 'KeyringController - Encryption key and salt provided are expired', + NoKeyringBuilder = 'KeyringController - No keyringBuilder found for keyring', +} From c1843f5f40e414b0c0710bf0419fc19c66350955 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Sat, 11 Mar 2023 23:20:09 -0300 Subject: [PATCH 077/109] Update tests --- src/KeyringController.test.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/KeyringController.test.ts b/src/KeyringController.test.ts index 75f3bdc2..a51b4c00 100644 --- a/src/KeyringController.test.ts +++ b/src/KeyringController.test.ts @@ -6,7 +6,7 @@ import Wallet from 'ethereumjs-wallet'; import { restore, spy, stub, assert as sinonAssert } from 'sinon'; import { KeyringController, keyringBuilderFactory } from '.'; -import { KeyringType } from './constants'; +import { KeyringType, KeyringControllerError } from './constants'; import { mockEncryptor, KeyringMockWithInit, @@ -240,7 +240,7 @@ describe('KeyringController', () => { await expect(async () => keyringController.createNewVaultAndKeychain(PASSWORD), - ).rejects.toThrow('KeyringController - No account found on keychain.'); + ).rejects.toThrow(KeyringControllerError.NoAccountOnKeychain); }); describe('when `cacheEncryptionKey` is enabled', () => { @@ -699,7 +699,7 @@ describe('KeyringController', () => { keyringController.getKeyringForAccount(undefined as any), ).rejects.toThrow( new Error( - 'KeyringController - No keyring found for the requested account. Error info: The address passed in is invalid/empty', + `${KeyringControllerError.NoKeyring}. Error info: The address passed in is invalid/empty`, ), ); }); @@ -710,7 +710,7 @@ describe('KeyringController', () => { keyringController.getKeyringForAccount('0x04'), ).rejects.toThrow( new Error( - 'KeyringController - No keyring found for the requested account. Error info: There are no keyrings', + `${KeyringControllerError.NoKeyring}. Error info: There are no keyrings`, ), ); }); @@ -728,7 +728,7 @@ describe('KeyringController', () => { keyringController.getKeyringForAccount('0x04'), ).rejects.toThrow( new Error( - 'KeyringController - No keyring found for the requested account. Error info: There are keyrings, but none match the address', + `${KeyringControllerError.NoKeyring}. Error info: There are keyrings, but none match the address`, ), ); }); From 5f4d845fdcd7ae7062edf90b5d6d4150db216663 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Sat, 11 Mar 2023 23:20:49 -0300 Subject: [PATCH 078/109] Export KeyringControllerError enum --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index c73d5544..8978ab2d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,5 @@ export * from './KeyringController'; -export { KeyringType } from './constants'; +export { KeyringType, KeyringControllerError } from './constants'; export type { MessageParams } from './types'; From 2272c18a34ecf102a4b25006285397dda7d64421 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Sat, 11 Mar 2023 23:23:09 -0300 Subject: [PATCH 079/109] Update exports --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 8978ab2d..bcbfbfe4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -export * from './KeyringController'; +export { KeyringController, keyringBuilderFactory } from './KeyringController'; export { KeyringType, KeyringControllerError } from './constants'; From d0f6e635771905e76c0e6f6d47eb874e8f28d16a Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Sat, 11 Mar 2023 23:39:18 -0300 Subject: [PATCH 080/109] Improve stripHexPrefix --- src/KeyringController.ts | 10 +++------- src/constants.ts | 2 -- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index 129683b6..6780606b 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -16,7 +16,7 @@ import type { import { EventEmitter } from 'events'; import ObservableStore from 'obs-store'; -import { HEX_PREFIX, KeyringType, KeyringControllerError } from './constants'; +import { KeyringType, KeyringControllerError } from './constants'; import { State, MessageParams, @@ -35,12 +35,8 @@ const defaultKeyringBuilders = [ * @param address - The address that might be hex prefixed. * @returns The address without a hex prefix. */ -function stripHexPrefix(address: Hex | string): string { - if (address.startsWith(HEX_PREFIX)) { - return address.slice(2); - } - return address; -} +const stripHexPrefix = (address: Hex | string): string => + parseInt(address, 16).toString(16); class KeyringController extends EventEmitter { keyringBuilders: { (): Keyring; type: string }[]; diff --git a/src/constants.ts b/src/constants.ts index 503eabb8..d8d28035 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,5 +1,3 @@ -export const HEX_PREFIX = '0x'; - export enum KeyringType { HD = 'HD Key Tree', Simple = 'Simple Key Pair', From 1b8c42b07f1e83fe71d54a3059f595d58f2055f7 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Mon, 13 Mar 2023 23:39:48 -0300 Subject: [PATCH 081/109] Sort methods --- src/KeyringController.ts | 226 +++++++++++++++---------------- src/utils/index.ts | 3 + src/utils/stripHexPrefix.test.ts | 9 ++ src/utils/stripHexPrefix.ts | 12 ++ 4 files changed, 135 insertions(+), 115 deletions(-) create mode 100644 src/utils/index.ts create mode 100644 src/utils/stripHexPrefix.test.ts create mode 100644 src/utils/stripHexPrefix.ts diff --git a/src/KeyringController.ts b/src/KeyringController.ts index 6780606b..0131d48a 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -23,21 +23,13 @@ import { SerializedKeyring, KeyringControllerArgs, } from './types'; +import { stripHexPrefix } from './utils'; const defaultKeyringBuilders = [ keyringBuilderFactory(SimpleKeyring), keyringBuilderFactory(HDKeyring), ]; -/** - * Strip the hex prefix from an address, if present. - * - * @param address - The address that might be hex prefixed. - * @returns The address without a hex prefix. - */ -const stripHexPrefix = (address: Hex | string): string => - parseInt(address, 16).toString(16); - class KeyringController extends EventEmitter { keyringBuilders: { (): Keyring; type: string }[]; @@ -101,6 +93,10 @@ class KeyringController extends EventEmitter { return this.memStore.getState(); } + // ====================== + // === Public Methods === + // ====================== + /** * Create New Vault And Keychain * @@ -220,7 +216,7 @@ class KeyringController extends EventEmitter { async submitEncryptionKey( encryptionKey: string, encryptionSalt: string, - ): Promise { + ): Promise { this.keyrings = await this.unlockKeyrings( undefined, encryptionKey, @@ -335,7 +331,7 @@ class KeyringController extends EventEmitter { */ async checkForDuplicate( type: string, - newAccountArray: string[], + newAccountArray: Hex[], ): Promise { const accounts = await this.getAccounts(); @@ -345,7 +341,7 @@ class KeyringController extends EventEmitter { accounts.find( (key) => key === newAccountArray[0] || - key === stripHexPrefix(newAccountArray[0] as string), + key === stripHexPrefix(newAccountArray[0] as Hex), ), ); @@ -430,9 +426,9 @@ class KeyringController extends EventEmitter { return this.#fullUpdate(); } - // - // SIGNING METHODS - // + // ============================== + // === Public Signing Methods === + // ============================== /** * Sign Ethereum Transaction @@ -470,7 +466,7 @@ class KeyringController extends EventEmitter { async signMessage( msgParams: MessageParams, opts: Record = {}, - ) { + ): Promise { const address = normalizeAddress(msgParams.from); const keyring = await this.getKeyringForAccount(address); if (!keyring.signMessage) { @@ -647,53 +643,6 @@ class KeyringController extends EventEmitter { return this.keyrings.filter((keyring) => keyring.type === type); } - /** - * Update memStore Keyrings - * - * Updates the in-memory keyrings, without persisting. - */ - async #updateMemStoreKeyrings(): Promise { - const keyrings = await Promise.all( - // eslint-disable-next-line @typescript-eslint/unbound-method - this.keyrings.map(this.#displayForKeyring), - ); - return this.memStore.updateState({ keyrings }); - } - - // ======================= - // === Private Methods === - // ======================= - - /** - * Create First Key Tree. - * - * - Clears the existing vault. - * - Creates a new vault. - * - Creates a random new HD Keyring with 1 account. - * - Makes that account the selected account. - * - Faucets that account on testnet. - * - Puts the current seed words into the state tree. - * - * @returns A promise that resolves if the operation was successful. - */ - async #createFirstKeyTree(): Promise { - await this.#clearKeyrings(); - - const keyring = await this.addNewKeyring(KeyringType.HD); - if (!keyring) { - throw new Error(KeyringControllerError.NoKeyring); - } - - const [firstAccount] = await keyring.getAccounts(); - if (!firstAccount) { - throw new Error(KeyringControllerError.NoAccountOnKeychain); - } - - const hexAccount = normalizeAddress(firstAccount); - this.emit('newVault', hexAccount); - return null; - } - /** * Persist All Keyrings * @@ -704,7 +653,7 @@ class KeyringController extends EventEmitter { * * @returns Resolves to true once keyrings are persisted. */ - async persistAllKeyrings() { + async persistAllKeyrings(): Promise { const { encryptionKey, encryptionSalt } = this.memStore.getState(); if (!this.password && !encryptionKey) { @@ -846,57 +795,6 @@ class KeyringController extends EventEmitter { return this.keyrings; } - /** - * Restore Keyring Helper - * - * Attempts to initialize a new keyring from the provided serialized payload. - * On success, returns the resulting keyring instance. - * - * @param serialized - The serialized keyring. - * @param serialized.type - Keyring type. - * @param serialized.data - Keyring data. - * @returns The deserialized keyring or undefined if the keyring type is unsupported. - */ - async #restoreKeyring( - serialized: SerializedKeyring, - ): Promise | undefined> { - const { type, data } = serialized; - - let keyring: Keyring | undefined; - try { - keyring = await this.#newKeyring(type, data); - } catch { - // Error - } - - if (!keyring) { - this.unsupportedKeyrings.push(serialized); - return undefined; - } - - // getAccounts also validates the accounts for some keyrings - await keyring.getAccounts(); - this.keyrings.push(keyring); - return keyring; - } - - /** - * Get Keyring Class For Type - * - * Searches the current `keyringBuilders` array - * for a Keyring builder whose unique `type` property - * matches the provided `type`, - * returning it if it exists. - * - * @param type - The type whose class to get. - * @returns The class, if it exists. - */ - #getKeyringBuilderForType(type: string): any { - return this.keyringBuilders.find( - (keyringBuilder) => keyringBuilder.type === type, - ); - } - /** * Get Accounts * @@ -959,6 +857,104 @@ class KeyringController extends EventEmitter { ); } + // ======================= + // === Private Methods === + // ======================= + + /** + * Update memStore Keyrings + * + * Updates the in-memory keyrings, without persisting. + */ + async #updateMemStoreKeyrings(): Promise { + const keyrings = await Promise.all( + // eslint-disable-next-line @typescript-eslint/unbound-method + this.keyrings.map(this.#displayForKeyring), + ); + return this.memStore.updateState({ keyrings }); + } + + /** + * Create First Key Tree. + * + * - Clears the existing vault. + * - Creates a new vault. + * - Creates a random new HD Keyring with 1 account. + * - Makes that account the selected account. + * - Faucets that account on testnet. + * - Puts the current seed words into the state tree. + * + * @returns A promise that resolves if the operation was successful. + */ + async #createFirstKeyTree(): Promise { + await this.#clearKeyrings(); + + const keyring = await this.addNewKeyring(KeyringType.HD); + if (!keyring) { + throw new Error(KeyringControllerError.NoKeyring); + } + + const [firstAccount] = await keyring.getAccounts(); + if (!firstAccount) { + throw new Error(KeyringControllerError.NoAccountOnKeychain); + } + + const hexAccount = normalizeAddress(firstAccount); + this.emit('newVault', hexAccount); + return null; + } + + /** + * Restore Keyring Helper + * + * Attempts to initialize a new keyring from the provided serialized payload. + * On success, returns the resulting keyring instance. + * + * @param serialized - The serialized keyring. + * @param serialized.type - Keyring type. + * @param serialized.data - Keyring data. + * @returns The deserialized keyring or undefined if the keyring type is unsupported. + */ + async #restoreKeyring( + serialized: SerializedKeyring, + ): Promise | undefined> { + const { type, data } = serialized; + + let keyring: Keyring | undefined; + try { + keyring = await this.#newKeyring(type, data); + } catch { + // Error + } + + if (!keyring) { + this.unsupportedKeyrings.push(serialized); + return undefined; + } + + // getAccounts also validates the accounts for some keyrings + await keyring.getAccounts(); + this.keyrings.push(keyring); + return keyring; + } + + /** + * Get Keyring Class For Type + * + * Searches the current `keyringBuilders` array + * for a Keyring builder whose unique `type` property + * matches the provided `type`, + * returning it if it exists. + * + * @param type - The type whose class to get. + * @returns The class, if it exists. + */ + #getKeyringBuilderForType(type: string): any { + return this.keyringBuilders.find( + (keyringBuilder) => keyringBuilder.type === type, + ); + } + /** * Display For Keyring * diff --git a/src/utils/index.ts b/src/utils/index.ts new file mode 100644 index 00000000..3e5897b7 --- /dev/null +++ b/src/utils/index.ts @@ -0,0 +1,3 @@ +import stripHexPrefix from './stripHexPrefix'; + +export { stripHexPrefix }; diff --git a/src/utils/stripHexPrefix.test.ts b/src/utils/stripHexPrefix.test.ts new file mode 100644 index 00000000..ba547a09 --- /dev/null +++ b/src/utils/stripHexPrefix.test.ts @@ -0,0 +1,9 @@ +import stripHexPrefix from './stripHexPrefix'; + +describe('stripHexPrefix', () => { + it('should return the value without the hex prefix', () => { + const hexWithPrefix = '0x123'; + const expectedResult = '123'; + expect(stripHexPrefix(hexWithPrefix)).toBe(expectedResult); + }); +}); diff --git a/src/utils/stripHexPrefix.ts b/src/utils/stripHexPrefix.ts new file mode 100644 index 00000000..3f0276c6 --- /dev/null +++ b/src/utils/stripHexPrefix.ts @@ -0,0 +1,12 @@ +import { Hex } from '@metamask/utils'; + +/** + * Strip the hex prefix from an address, if present. + * + * @param address - The address that might be hex prefixed. + * @returns The address without a hex prefix. + */ +const stripHexPrefix = (address: Hex): string => + parseInt(address, 16).toString(16); + +export default stripHexPrefix; From f054c3b540cf506a617beb25482ad0e6c24da8ca Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Tue, 14 Mar 2023 00:11:30 -0300 Subject: [PATCH 082/109] Replace State with Json --- src/KeyringController.ts | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index 0131d48a..c8a93a0e 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -39,7 +39,7 @@ class KeyringController extends EventEmitter { public encryptor: any; - public keyrings: Keyring[]; + public keyrings: Keyring[]; public cacheEncryptionKey: boolean; @@ -258,8 +258,8 @@ class KeyringController extends EventEmitter { async addNewKeyring( type: string, opts: Record = {}, - ): Promise> { - let keyring: Keyring; + ): Promise> { + let keyring: Keyring; switch (type) { case KeyringType.Simple: keyring = await this.#newKeyring(type, opts.privateKeys); @@ -302,14 +302,14 @@ class KeyringController extends EventEmitter { * (usually after removing the last / only account) from a keyring. */ async removeEmptyKeyrings(): Promise { - const validKeyrings: Keyring[] = []; + const validKeyrings: Keyring[] = []; // Since getAccounts returns a Promise // We need to wait to hear back form each keyring // in order to decide which ones are now valid (accounts.length > 0) await Promise.all( - this.keyrings.map(async (keyring: Keyring) => { + this.keyrings.map(async (keyring: Keyring) => { const accounts = await keyring.getAccounts(); if (accounts.length > 0) { validKeyrings.push(keyring); @@ -366,7 +366,7 @@ class KeyringController extends EventEmitter { * @param selectedKeyring - The currently selected keyring. * @returns A Promise that resolves to the state. */ - async addNewAccount(selectedKeyring: Keyring): Promise { + async addNewAccount(selectedKeyring: Keyring): Promise { const accounts = await selectedKeyring.addAccounts(1); accounts.forEach((hexAccount: string) => { this.emit('newAccount', hexAccount); @@ -623,7 +623,7 @@ class KeyringController extends EventEmitter { */ async restoreKeyring( serialized: SerializedKeyring, - ): Promise | undefined> { + ): Promise | undefined> { const keyring = await this.#restoreKeyring(serialized); if (keyring) { await this.#updateMemStoreKeyrings(); @@ -639,7 +639,7 @@ class KeyringController extends EventEmitter { * @param type - The keyring types to retrieve. * @returns Keyrings matching the specified type. */ - getKeyringsByType(type: KeyringType): Keyring[] { + getKeyringsByType(type: KeyringType): Keyring[] { return this.keyrings.filter((keyring) => keyring.type === type); } @@ -737,7 +737,7 @@ class KeyringController extends EventEmitter { password: string | undefined, encryptionKey?: string, encryptionSalt?: string, - ): Promise[]> { + ): Promise[]> { const encryptedVault = this.store.getState().vault; if (!encryptedVault) { throw new Error(KeyringControllerError.VaultError); @@ -825,7 +825,7 @@ class KeyringController extends EventEmitter { * @param address - An account address. * @returns The keyring of the account, if it exists. */ - async getKeyringForAccount(address: string): Promise> { + async getKeyringForAccount(address: string): Promise> { const hexed = normalizeAddress(address); const candidates = await Promise.all( @@ -917,10 +917,10 @@ class KeyringController extends EventEmitter { */ async #restoreKeyring( serialized: SerializedKeyring, - ): Promise | undefined> { + ): Promise | undefined> { const { type, data } = serialized; - let keyring: Keyring | undefined; + let keyring: Keyring | undefined; try { keyring = await this.#newKeyring(type, data); } catch { @@ -964,7 +964,7 @@ class KeyringController extends EventEmitter { * @returns A keyring display object, with type and accounts properties. */ async #displayForKeyring( - keyring: Keyring, + keyring: Keyring, ): Promise<{ type: string; accounts: string[] }> { const accounts = await keyring.getAccounts(); @@ -1009,7 +1009,7 @@ class KeyringController extends EventEmitter { * @param data - The data to restore a previously serialized keyring. * @returns The new keyring. */ - async #newKeyring(type: string, data: unknown): Promise> { + async #newKeyring(type: string, data: unknown): Promise> { const keyringBuilder = this.#getKeyringBuilderForType(type); if (!keyringBuilder) { From 5a1df6484f07b85d1fb81314dcc11582d0bfd80b Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Tue, 14 Mar 2023 00:55:19 -0300 Subject: [PATCH 083/109] Improve types --- src/KeyringController.test.ts | 17 ++++++++--------- src/KeyringController.ts | 20 ++++++++++++-------- src/test/encryptor.mock.ts | 5 ++--- src/types.ts | 16 +++++++++++++--- 4 files changed, 35 insertions(+), 23 deletions(-) diff --git a/src/KeyringController.test.ts b/src/KeyringController.test.ts index a51b4c00..e429d575 100644 --- a/src/KeyringController.test.ts +++ b/src/KeyringController.test.ts @@ -1,6 +1,6 @@ import HdKeyring from '@metamask/eth-hd-keyring'; import { normalize as normalizeAddress } from '@metamask/eth-sig-util'; -import type { Hex, Keyring, KeyringClass } from '@metamask/utils'; +import type { Hex, Json, Keyring, KeyringClass } from '@metamask/utils'; import { strict as assert } from 'assert'; import Wallet from 'ethereumjs-wallet'; import { restore, spy, stub, assert as sinonAssert } from 'sinon'; @@ -14,7 +14,6 @@ import { MOCK_HARDCODED_KEY, MOCK_HEX, } from './test'; -import { State } from './types'; const MOCK_ENCRYPTION_KEY = '{"alg":"A256GCM","ext":true,"k":"wYmxkxOOFBDP6F6VuuYFcRt_Po-tSLFHCWVolsHs4VI","key_ops":["encrypt","decrypt"],"kty":"oct"}'; @@ -118,7 +117,7 @@ describe('KeyringController', () => { const { vault } = keyringController.store.getState(); const keyrings = (await mockEncryptor.decrypt(PASSWORD, vault)) as { type: string; - data: State; + data: Json; }[]; expect(keyrings).toContain(unsupportedKeyring); expect(keyrings).toHaveLength(2); @@ -481,12 +480,12 @@ describe('KeyringController', () => { async getAccounts() { return Promise.resolve([1, 2, 3]); }, - } as unknown as Keyring, + } as unknown as Keyring, { async getAccounts() { return Promise.resolve([4, 5, 6]); }, - } as unknown as Keyring, + } as unknown as Keyring, ]; const result = await keyringController.getAccounts(); @@ -630,7 +629,7 @@ describe('KeyringController', () => { const initialAccounts = await HDKeyring?.getAccounts(); expect(initialAccounts).toHaveLength(1); - await keyringController.addNewAccount(HDKeyring as Keyring); + await keyringController.addNewAccount(HDKeyring as Keyring); const accountsAfterAdd = await HDKeyring?.getAccounts(); expect(accountsAfterAdd).toHaveLength(2); }); @@ -721,7 +720,7 @@ describe('KeyringController', () => { async getAccounts() { return Promise.resolve([1, 2, 3]); }, - } as unknown as Keyring, + } as unknown as Keyring, ]; await expect( @@ -808,10 +807,10 @@ describe('KeyringController', () => { const [firstKeyring] = keyringController.keyrings; - await keyringController.addNewAccount(firstKeyring as Keyring); + await keyringController.addNewAccount(firstKeyring as Keyring); expect(await keyringController.getAccounts()).toHaveLength(2); - await keyringController.addNewAccount(firstKeyring as Keyring); + await keyringController.addNewAccount(firstKeyring as Keyring); expect(await keyringController.getAccounts()).toHaveLength(3); const account = { diff --git a/src/KeyringController.ts b/src/KeyringController.ts index c8a93a0e..c4c2c371 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -18,10 +18,10 @@ import ObservableStore from 'obs-store'; import { KeyringType, KeyringControllerError } from './constants'; import { - State, MessageParams, SerializedKeyring, KeyringControllerArgs, + KeyringControllerState, } from './types'; import { stripHexPrefix } from './utils'; @@ -109,7 +109,9 @@ class KeyringController extends EventEmitter { * @param password - The password to encrypt the vault with. * @returns A promise that resolves to the state. */ - async createNewVaultAndKeychain(password: string): Promise { + async createNewVaultAndKeychain( + password: string, + ): Promise { this.password = password; await this.#createFirstKeyTree(); @@ -133,7 +135,7 @@ class KeyringController extends EventEmitter { async createNewVaultAndRestore( password: string, seedPhrase: Uint8Array | string | number[], - ): Promise { + ): Promise { if (typeof password !== 'string') { throw new TypeError(KeyringControllerError.WrongPasswordType); } @@ -165,7 +167,7 @@ class KeyringController extends EventEmitter { * @fires KeyringController#lock * @returns A promise that resolves to the state. */ - async setLocked(): Promise { + async setLocked(): Promise { delete this.password; // set locked @@ -195,7 +197,7 @@ class KeyringController extends EventEmitter { * @param password - The keyring controller password. * @returns A promise that resolves to the state. */ - async submitPassword(password: string): Promise { + async submitPassword(password: string): Promise { this.keyrings = await this.unlockKeyrings(password); this.#setUnlocked(); @@ -216,7 +218,7 @@ class KeyringController extends EventEmitter { async submitEncryptionKey( encryptionKey: string, encryptionSalt: string, - ): Promise { + ): Promise { this.keyrings = await this.unlockKeyrings( undefined, encryptionKey, @@ -366,7 +368,9 @@ class KeyringController extends EventEmitter { * @param selectedKeyring - The currently selected keyring. * @returns A Promise that resolves to the state. */ - async addNewAccount(selectedKeyring: Keyring): Promise { + async addNewAccount( + selectedKeyring: Keyring, + ): Promise { const accounts = await selectedKeyring.addAccounts(1); accounts.forEach((hexAccount: string) => { this.emit('newAccount', hexAccount); @@ -405,7 +409,7 @@ class KeyringController extends EventEmitter { * @param address - The address of the account to remove. * @returns A promise that resolves if the operation was successful. */ - async removeAccount(address: Hex): Promise { + async removeAccount(address: Hex): Promise { const keyring = await this.getKeyringForAccount(address); // Not all the keyrings support this, so we have to check diff --git a/src/test/encryptor.mock.ts b/src/test/encryptor.mock.ts index 1b0677e3..cc80011a 100644 --- a/src/test/encryptor.mock.ts +++ b/src/test/encryptor.mock.ts @@ -1,7 +1,6 @@ +import { Json } from '@metamask/utils'; import { stub } from 'sinon'; -import { State } from '../types'; - const PASSWORD = 'password123'; const MOCK_ENCRYPTION_KEY = JSON.stringify({ alg: 'A256GCM', @@ -21,7 +20,7 @@ const MOCK_HEX = '0xabcdef0123456789'; const MOCK_SALT = 'SALT'; // eslint-disable-next-line no-restricted-globals const MOCK_KEY = Buffer.alloc(32); -let cacheVal: State; +let cacheVal: Json; const mockEncryptor = { encrypt: stub().callsFake(async (_password, dataObj) => { diff --git a/src/types.ts b/src/types.ts index 157435da..ab1cc60b 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,7 +1,5 @@ import type { Hex, Json, Keyring, Eip1024EncryptedData } from '@metamask/utils'; -export type State = Json; - export type MessageParams = { from: Hex | string; data: Hex | string | Eip1024EncryptedData | Record[]; @@ -13,10 +11,22 @@ export type KeyringControllerArgs = { | ConcatArray<{ (): Keyring; type: string }>; cacheEncryptionKey: boolean; - initState?: State; + initState?: KeyringControllerState; encryptor?: any; }; +export type KeyringControllerState = { + keyrings?: Keyring[]; + + vaultUnlock?: boolean; + + encryptionKey?: string; + + encryptionSalt?: string; + + password?: string; +}; + export type SerializedKeyring = { type: string; data: Json; From b76b3db48908afa046642af309b3665708466736 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Fri, 17 Mar 2023 09:22:46 -0300 Subject: [PATCH 084/109] Update dependencies --- package.json | 8 +++--- yarn.lock | 70 ++++++++++++++++++++++++++++++++-------------------- 2 files changed, 47 insertions(+), 31 deletions(-) diff --git a/package.json b/package.json index eb51092a..cae24086 100644 --- a/package.json +++ b/package.json @@ -35,11 +35,11 @@ }, "dependencies": { "@ethereumjs/tx": "^4.1.1", - "@metamask/browser-passworder": "^4.0.2", + "@metamask/browser-passworder": "^4.1.0", "@metamask/eth-hd-keyring": "^6.0.0", "@metamask/eth-sig-util": "5.0.2", "@metamask/eth-simple-keyring": "^5.0.0", - "@metamask/utils": "5.0.0", + "@metamask/utils": "^5.0.0", "obs-store": "^4.0.3" }, "devDependencies": { @@ -65,11 +65,11 @@ "jest": "^29.0.0", "prettier": "^2.8.1", "prettier-plugin-packagejson": "^2.3.0", - "sinon": "15.0.1", + "sinon": "^15.0.1", "ts-jest": "^29.0.3", "ts-node": "^10.7.0", "typedoc": "^0.23.15", - "typescript": "~4.8.4" + "typescript": "~4.9.3-5" }, "packageManager": "yarn@3.2.4", "engines": { diff --git a/yarn.lock b/yarn.lock index 664b1547..a9d8c097 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1313,10 +1313,10 @@ __metadata: languageName: node linkType: hard -"@metamask/browser-passworder@npm:^4.0.2": - version: 4.0.2 - resolution: "@metamask/browser-passworder@npm:4.0.2" - checksum: 997c330b1c72f7135d0fd2a7f4b0dce37b3c2e6b30e92f048fa8d4f8c949f5b669dcc3064790f41df30ee2e53a9e64a812df72e00527736be704cce2cf4f6e49 +"@metamask/browser-passworder@npm:^4.1.0": + version: 4.1.0 + resolution: "@metamask/browser-passworder@npm:4.1.0" + checksum: f1edb3b75594b8e8d075b3134c9ce6c73573160eb48184ef722b9d96a5763db1e2e9acb166fc5c66c7c82936e134a02a3fb4c0022ca9a948857a30181cb84d7e languageName: node linkType: hard @@ -1388,7 +1388,7 @@ __metadata: "@ethereumjs/tx": ^4.1.1 "@lavamoat/allow-scripts": ^2.1.0 "@metamask/auto-changelog": ^3.0.0 - "@metamask/browser-passworder": ^4.0.2 + "@metamask/browser-passworder": ^4.1.0 "@metamask/eslint-config": ^11.1.0 "@metamask/eslint-config-jest": ^11.1.0 "@metamask/eslint-config-nodejs": ^11.1.0 @@ -1396,7 +1396,7 @@ __metadata: "@metamask/eth-hd-keyring": ^6.0.0 "@metamask/eth-sig-util": 5.0.2 "@metamask/eth-simple-keyring": ^5.0.0 - "@metamask/utils": 5.0.0 + "@metamask/utils": ^5.0.0 "@types/jest": ^29.4.0 "@types/sinon": ^10.0.13 "@typescript-eslint/eslint-plugin": ^5.53.0 @@ -1414,11 +1414,11 @@ __metadata: obs-store: ^4.0.3 prettier: ^2.8.1 prettier-plugin-packagejson: ^2.3.0 - sinon: 15.0.1 + sinon: ^15.0.1 ts-jest: ^29.0.3 ts-node: ^10.7.0 typedoc: ^0.23.15 - typescript: ~4.8.4 + typescript: ~4.9.3-5 languageName: unknown linkType: soft @@ -1458,7 +1458,7 @@ __metadata: languageName: node linkType: hard -"@metamask/utils@npm:5.0.0": +"@metamask/utils@npm:^5.0.0": version: 5.0.0 resolution: "@metamask/utils@npm:5.0.0" dependencies: @@ -1612,7 +1612,16 @@ __metadata: languageName: node linkType: hard -"@sinonjs/fake-timers@npm:10.0.2, @sinonjs/fake-timers@npm:^10.0.2": +"@sinonjs/commons@npm:^3.0.0": + version: 3.0.0 + resolution: "@sinonjs/commons@npm:3.0.0" + dependencies: + type-detect: 4.0.8 + checksum: b4b5b73d4df4560fb8c0c7b38c7ad4aeabedd362f3373859d804c988c725889cde33550e4bcc7cd316a30f5152a2d1d43db71b6d0c38f5feef71fd8d016763f8 + languageName: node + linkType: hard + +"@sinonjs/fake-timers@npm:^10.0.2": version: 10.0.2 resolution: "@sinonjs/fake-timers@npm:10.0.2" dependencies: @@ -3264,6 +3273,13 @@ __metadata: languageName: node linkType: hard +"diff@npm:^5.1.0": + version: 5.1.0 + resolution: "diff@npm:5.1.0" + checksum: c7bf0df7c9bfbe1cf8a678fd1b2137c4fb11be117a67bc18a0e03ae75105e8533dbfb1cda6b46beb3586ef5aed22143ef9d70713977d5fb1f9114e21455fba90 + languageName: node + linkType: hard + "dir-glob@npm:^3.0.1": version: 3.0.1 resolution: "dir-glob@npm:3.0.1" @@ -5943,7 +5959,7 @@ __metadata: languageName: node linkType: hard -"nise@npm:^5.1.2": +"nise@npm:^5.1.4": version: 5.1.4 resolution: "nise@npm:5.1.4" dependencies: @@ -6931,17 +6947,17 @@ __metadata: languageName: node linkType: hard -"sinon@npm:15.0.1": - version: 15.0.1 - resolution: "sinon@npm:15.0.1" +"sinon@npm:^15.0.1": + version: 15.0.2 + resolution: "sinon@npm:15.0.2" dependencies: - "@sinonjs/commons": ^2.0.0 - "@sinonjs/fake-timers": 10.0.2 + "@sinonjs/commons": ^3.0.0 + "@sinonjs/fake-timers": ^10.0.2 "@sinonjs/samsam": ^7.0.1 - diff: ^5.0.0 - nise: ^5.1.2 + diff: ^5.1.0 + nise: ^5.1.4 supports-color: ^7.2.0 - checksum: 4b5acff291b4650cf736bf45fc9eceed44dceca63b663cbd55926dd688fe8e9baa4b4629e296ee5d5b64245aedec5c540fea0416b8bb35bccfb98ca9e9ed87f3 + checksum: 98eb555442db3985d7fe0d90e23f081f3df71adffa0a50b049bcd2abbf5c2d71a43aeaa1e3c02500164cff5233d2f102f777356ebe8bfc257cb7059c1b2778b0 languageName: node linkType: hard @@ -7538,23 +7554,23 @@ __metadata: languageName: node linkType: hard -"typescript@npm:~4.8.4": - version: 4.8.4 - resolution: "typescript@npm:4.8.4" +"typescript@npm:~4.9.3-5": + version: 4.9.5 + resolution: "typescript@npm:4.9.5" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 3e4f061658e0c8f36c820802fa809e0fd812b85687a9a2f5430bc3d0368e37d1c9605c3ce9b39df9a05af2ece67b1d844f9f6ea8ff42819f13bcb80f85629af0 + checksum: ee000bc26848147ad423b581bd250075662a354d84f0e06eb76d3b892328d8d4440b7487b5a83e851b12b255f55d71835b008a66cbf8f255a11e4400159237db languageName: node linkType: hard -"typescript@patch:typescript@~4.8.4#~builtin": - version: 4.8.4 - resolution: "typescript@patch:typescript@npm%3A4.8.4#~builtin::version=4.8.4&hash=701156" +"typescript@patch:typescript@~4.9.3-5#~builtin": + version: 4.9.5 + resolution: "typescript@patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=701156" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 301459fc3eb3b1a38fe91bf96d98eb55da88a9cb17b4ef80b4d105d620f4d547ba776cc27b44cc2ef58b66eda23fe0a74142feb5e79a6fb99f54fc018a696afa + checksum: 2eee5c37cad4390385db5db5a8e81470e42e8f1401b0358d7390095d6f681b410f2c4a0c496c6ff9ebd775423c7785cdace7bcdad76c7bee283df3d9718c0f20 languageName: node linkType: hard From 850cb00785bd58f4bad757ca2552fcb20372e5bc Mon Sep 17 00:00:00 2001 From: LeoTM <1881059+leotm@users.noreply.github.com> Date: Fri, 17 Mar 2023 14:11:37 +0000 Subject: [PATCH 085/109] Bump @typescript-eslint/parser from 5.53.0 to 5.55.0 for TypeScript 5 ESLint checks still passing https://github.com/typescript-eslint/typescript-eslint/releases https://github.com/typescript-eslint/typescript-eslint/issues/6380 https://github.com/typescript-eslint/typescript-eslint/pull/6600 --- package.json | 2 +- yarn.lock | 61 +++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 54 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index cae24086..1e83bcad 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@types/jest": "^29.4.0", "@types/sinon": "^10.0.13", "@typescript-eslint/eslint-plugin": "^5.53.0", - "@typescript-eslint/parser": "^5.53.0", + "@typescript-eslint/parser": "^5.55.0", "depcheck": "^1.4.3", "eslint": "^8.29.0", "eslint-config-prettier": "^8.5.0", diff --git a/yarn.lock b/yarn.lock index a9d8c097..b6d9a5ba 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1400,7 +1400,7 @@ __metadata: "@types/jest": ^29.4.0 "@types/sinon": ^10.0.13 "@typescript-eslint/eslint-plugin": ^5.53.0 - "@typescript-eslint/parser": ^5.53.0 + "@typescript-eslint/parser": ^5.55.0 depcheck: ^1.4.3 eslint: ^8.29.0 eslint-config-prettier: ^8.5.0 @@ -1940,20 +1940,20 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/parser@npm:^5.53.0": - version: 5.53.0 - resolution: "@typescript-eslint/parser@npm:5.53.0" +"@typescript-eslint/parser@npm:^5.55.0": + version: 5.55.0 + resolution: "@typescript-eslint/parser@npm:5.55.0" dependencies: - "@typescript-eslint/scope-manager": 5.53.0 - "@typescript-eslint/types": 5.53.0 - "@typescript-eslint/typescript-estree": 5.53.0 + "@typescript-eslint/scope-manager": 5.55.0 + "@typescript-eslint/types": 5.55.0 + "@typescript-eslint/typescript-estree": 5.55.0 debug: ^4.3.4 peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 peerDependenciesMeta: typescript: optional: true - checksum: 979e5d63793a9e64998b1f956ba0f00f8a2674db3a664fafce7b2433323f5248bd776af8305e2419d73a9d94c55176fee099abc5c153b4cc52e5765c725c1edd + checksum: 48a20dc7e67960b5168b77bfb9d11d053a21d57bb83cf7b59f750191cbca5eea3b4636a8e6e75cc0aca5a84cdef91fed5440934fc2935f8c6fa71630a253a50c languageName: node linkType: hard @@ -1977,6 +1977,16 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/scope-manager@npm:5.55.0": + version: 5.55.0 + resolution: "@typescript-eslint/scope-manager@npm:5.55.0" + dependencies: + "@typescript-eslint/types": 5.55.0 + "@typescript-eslint/visitor-keys": 5.55.0 + checksum: f253db88f69a29e4abe2f567d0a611cc3e7fb1a911a2cc54a2f6baf16e3de4d1883b3f8e45ee61b3db9fa5543dda0fd7b608de9d28ba6173ab49bfd17ff90cad + languageName: node + linkType: hard + "@typescript-eslint/type-utils@npm:5.53.0": version: 5.53.0 resolution: "@typescript-eslint/type-utils@npm:5.53.0" @@ -2008,6 +2018,13 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/types@npm:5.55.0": + version: 5.55.0 + resolution: "@typescript-eslint/types@npm:5.55.0" + checksum: 7d851f09a2106514d3a9c7164d34758f30abfe554e3c7a02be75cdc7e16644e23ca32840a8f39a0321bc509927fb4d98ce91b22b21e8544ac56cef33b815a864 + languageName: node + linkType: hard + "@typescript-eslint/typescript-estree@npm:5.46.0": version: 5.46.0 resolution: "@typescript-eslint/typescript-estree@npm:5.46.0" @@ -2044,6 +2061,24 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/typescript-estree@npm:5.55.0": + version: 5.55.0 + resolution: "@typescript-eslint/typescript-estree@npm:5.55.0" + dependencies: + "@typescript-eslint/types": 5.55.0 + "@typescript-eslint/visitor-keys": 5.55.0 + debug: ^4.3.4 + globby: ^11.1.0 + is-glob: ^4.0.3 + semver: ^7.3.7 + tsutils: ^3.21.0 + peerDependenciesMeta: + typescript: + optional: true + checksum: d24a11aee3d01067018d99804f420aecb8af88e43bf170d5d14f6480bd378c0a81ce49a37f5d6c36e5f0f319e3fa8b099720f295f2767338be1a4f7e9a5323e1 + languageName: node + linkType: hard + "@typescript-eslint/utils@npm:5.53.0": version: 5.53.0 resolution: "@typescript-eslint/utils@npm:5.53.0" @@ -2100,6 +2135,16 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/visitor-keys@npm:5.55.0": + version: 5.55.0 + resolution: "@typescript-eslint/visitor-keys@npm:5.55.0" + dependencies: + "@typescript-eslint/types": 5.55.0 + eslint-visitor-keys: ^3.3.0 + checksum: 0b24c72dff99dd2cf41c19d20067f8ab20a38aa2e82c79c5530bec7cf651031e95c80702fc21c813c9b94e5f3d4cd210f13967b2966ef38abe548cb5f05848a3 + languageName: node + linkType: hard + "@vue/compiler-core@npm:3.2.47": version: 3.2.47 resolution: "@vue/compiler-core@npm:3.2.47" From b4a30058762d09a1a9455dc577885b961680dc82 Mon Sep 17 00:00:00 2001 From: LeoTM <1881059+leotm@users.noreply.github.com> Date: Fri, 17 Mar 2023 14:20:25 +0000 Subject: [PATCH 086/109] Upgrade TypeScript from 4.9.3-5 to 5.0.2 stable - Type checks still passing - ESLint still passing with no warnings https://devblogs.microsoft.com/typescript/announcing-typescript-5-0 --- package.json | 2 +- yarn.lock | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 1e83bcad..6a01fc73 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "ts-jest": "^29.0.3", "ts-node": "^10.7.0", "typedoc": "^0.23.15", - "typescript": "~4.9.3-5" + "typescript": "~5.0.2" }, "packageManager": "yarn@3.2.4", "engines": { diff --git a/yarn.lock b/yarn.lock index b6d9a5ba..1abc5fe5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1418,7 +1418,7 @@ __metadata: ts-jest: ^29.0.3 ts-node: ^10.7.0 typedoc: ^0.23.15 - typescript: ~4.9.3-5 + typescript: ~5.0.2 languageName: unknown linkType: soft @@ -7599,23 +7599,23 @@ __metadata: languageName: node linkType: hard -"typescript@npm:~4.9.3-5": - version: 4.9.5 - resolution: "typescript@npm:4.9.5" +"typescript@npm:~5.0.2": + version: 5.0.2 + resolution: "typescript@npm:5.0.2" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: ee000bc26848147ad423b581bd250075662a354d84f0e06eb76d3b892328d8d4440b7487b5a83e851b12b255f55d71835b008a66cbf8f255a11e4400159237db + checksum: bef1dcd166acfc6934b2ec4d72f93edb8961a5fab36b8dd2aaf6f4f4cd5c0210f2e0850aef4724f3b4913d5aef203a94a28ded731b370880c8bcff7e4ff91fc1 languageName: node linkType: hard -"typescript@patch:typescript@~4.9.3-5#~builtin": - version: 4.9.5 - resolution: "typescript@patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=701156" +"typescript@patch:typescript@~5.0.2#~builtin": + version: 5.0.2 + resolution: "typescript@patch:typescript@npm%3A5.0.2#~builtin::version=5.0.2&hash=701156" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 2eee5c37cad4390385db5db5a8e81470e42e8f1401b0358d7390095d6f681b410f2c4a0c496c6ff9ebd775423c7785cdace7bcdad76c7bee283df3d9718c0f20 + checksum: bdbf3d0aac0d6cf010fbe0536753dc19f278eb4aba88140dcd25487dfe1c56ca8b33abc0dcd42078790a939b08ebc4046f3e9bb961d77d3d2c3cfa9829da4d53 languageName: node linkType: hard From cfe3e449af27b6aa07901fd74e6a4e4163226569 Mon Sep 17 00:00:00 2001 From: LeoTM <1881059+leotm@users.noreply.github.com> Date: Fri, 17 Mar 2023 14:38:33 +0000 Subject: [PATCH 087/109] Bump remaining harmless ESLint deps --- package.json | 12 +- yarn.lock | 321 +++++++++++++++++++++++++-------------------------- 2 files changed, 161 insertions(+), 172 deletions(-) diff --git a/package.json b/package.json index 6a01fc73..b730d8b0 100644 --- a/package.json +++ b/package.json @@ -51,14 +51,14 @@ "@metamask/eslint-config-typescript": "^11.1.0", "@types/jest": "^29.4.0", "@types/sinon": "^10.0.13", - "@typescript-eslint/eslint-plugin": "^5.53.0", + "@typescript-eslint/eslint-plugin": "^5.55.0", "@typescript-eslint/parser": "^5.55.0", "depcheck": "^1.4.3", - "eslint": "^8.29.0", - "eslint-config-prettier": "^8.5.0", - "eslint-plugin-import": "^2.26.0", - "eslint-plugin-jest": "^27.1.6", - "eslint-plugin-jsdoc": "^39.6.4", + "eslint": "^8.36.0", + "eslint-config-prettier": "^8.7.0", + "eslint-plugin-import": "^2.27.5", + "eslint-plugin-jest": "^27.2.1", + "eslint-plugin-jsdoc": "^40.0.3", "eslint-plugin-node": "^11.1.0", "eslint-plugin-prettier": "^4.2.1", "ethereumjs-wallet": "^1.0.1", diff --git a/yarn.lock b/yarn.lock index 1abc5fe5..68ac6ab3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -579,31 +579,56 @@ __metadata: languageName: node linkType: hard -"@es-joy/jsdoccomment@npm:~0.36.1": - version: 0.36.1 - resolution: "@es-joy/jsdoccomment@npm:0.36.1" +"@es-joy/jsdoccomment@npm:~0.37.0": + version: 0.37.0 + resolution: "@es-joy/jsdoccomment@npm:0.37.0" dependencies: comment-parser: 1.3.1 esquery: ^1.4.0 - jsdoc-type-pratt-parser: ~3.1.0 - checksum: 28e697779230dc6a95b1f233a8c2a72b64fbea686e407106e5d4292083421a997452731c414de26c10bee86e8e0397c5fb84d6ecfd4b472a29735e1af103ddb6 + jsdoc-type-pratt-parser: ~4.0.0 + checksum: 949c0d164573f189998a7ad7ace936639535e1cacf495d7daa893142dbe9e947f146602615732eaa3174b7ca08af9eea5d9fa97a68fdfe0aa14213ab0f319b13 languageName: node linkType: hard -"@eslint/eslintrc@npm:^1.3.3": - version: 1.3.3 - resolution: "@eslint/eslintrc@npm:1.3.3" +"@eslint-community/eslint-utils@npm:^4.2.0": + version: 4.3.0 + resolution: "@eslint-community/eslint-utils@npm:4.3.0" + dependencies: + eslint-visitor-keys: ^3.3.0 + peerDependencies: + eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 + checksum: f487760a692f0f1fef76e248ad72976919576ba57edc2b1b1dc1d182553bae6b5bf7b078e654da85d04f0af8a485d20bd26280002768f4fbcd2e330078340cb0 + languageName: node + linkType: hard + +"@eslint-community/regexpp@npm:^4.4.0": + version: 4.4.0 + resolution: "@eslint-community/regexpp@npm:4.4.0" + checksum: 2d127af0c752b80e8a782eacfe996a86925d21de92da3ffc6f9e615e701145e44a62e26bdd88bfac2cd76779c39ba8d9875a91046ec5e7e5f23cb647c247ea6a + languageName: node + linkType: hard + +"@eslint/eslintrc@npm:^2.0.1": + version: 2.0.1 + resolution: "@eslint/eslintrc@npm:2.0.1" dependencies: ajv: ^6.12.4 debug: ^4.3.2 - espree: ^9.4.0 - globals: ^13.15.0 + espree: ^9.5.0 + globals: ^13.19.0 ignore: ^5.2.0 import-fresh: ^3.2.1 js-yaml: ^4.1.0 minimatch: ^3.1.2 strip-json-comments: ^3.1.1 - checksum: f03e9d6727efd3e0719da2051ea80c0c73d20e28c171121527dbb868cd34232ca9c1d0525a66e517a404afea26624b1e47895b6a92474678418c2f50c9566694 + checksum: 56b9192a687a450db53a7b883daf9f0f447c43b3510189cf88808a7a2467c2a302a42a50f184cc6d5a9faf3d1df890a2ef0fd0d60b751f32a3e9dfea717c6b48 + languageName: node + linkType: hard + +"@eslint/js@npm:8.36.0": + version: 8.36.0 + resolution: "@eslint/js@npm:8.36.0" + checksum: b7d6b84b823c8c7784be390741196617565527b1f7c0977fde9455bfb57fd88f81c074a03dd878757d2c33fa29f24291e9ecbc1425710f067917324b55e1bf3a languageName: node linkType: hard @@ -938,14 +963,14 @@ __metadata: languageName: node linkType: hard -"@humanwhocodes/config-array@npm:^0.11.6": - version: 0.11.7 - resolution: "@humanwhocodes/config-array@npm:0.11.7" +"@humanwhocodes/config-array@npm:^0.11.8": + version: 0.11.8 + resolution: "@humanwhocodes/config-array@npm:0.11.8" dependencies: "@humanwhocodes/object-schema": ^1.2.1 debug: ^4.1.1 minimatch: ^3.0.5 - checksum: cf506dc45d9488af7fbf108ea6ac2151ba1a25e6d2b94b9b4fc36d2c1e4099b89ff560296dbfa13947e44604d4ca4a90d97a4fb167370bf8dd01a6ca2b6d83ac + checksum: 0fd6b3c54f1674ce0a224df09b9c2f9846d20b9e54fabae1281ecfc04f2e6ad69bf19e1d6af6a28f88e8aa3990168b6cb9e1ef755868c3256a630605ec2cb1d3 languageName: node linkType: hard @@ -1399,14 +1424,14 @@ __metadata: "@metamask/utils": ^5.0.0 "@types/jest": ^29.4.0 "@types/sinon": ^10.0.13 - "@typescript-eslint/eslint-plugin": ^5.53.0 + "@typescript-eslint/eslint-plugin": ^5.55.0 "@typescript-eslint/parser": ^5.55.0 depcheck: ^1.4.3 - eslint: ^8.29.0 - eslint-config-prettier: ^8.5.0 - eslint-plugin-import: ^2.26.0 - eslint-plugin-jest: ^27.1.6 - eslint-plugin-jsdoc: ^39.6.4 + eslint: ^8.36.0 + eslint-config-prettier: ^8.7.0 + eslint-plugin-import: ^2.27.5 + eslint-plugin-jest: ^27.2.1 + eslint-plugin-jsdoc: ^40.0.3 eslint-plugin-node: ^11.1.0 eslint-plugin-prettier: ^4.2.1 ethereumjs-wallet: ^1.0.1 @@ -1916,18 +1941,18 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/eslint-plugin@npm:^5.53.0": - version: 5.53.0 - resolution: "@typescript-eslint/eslint-plugin@npm:5.53.0" +"@typescript-eslint/eslint-plugin@npm:^5.55.0": + version: 5.55.0 + resolution: "@typescript-eslint/eslint-plugin@npm:5.55.0" dependencies: - "@typescript-eslint/scope-manager": 5.53.0 - "@typescript-eslint/type-utils": 5.53.0 - "@typescript-eslint/utils": 5.53.0 + "@eslint-community/regexpp": ^4.4.0 + "@typescript-eslint/scope-manager": 5.55.0 + "@typescript-eslint/type-utils": 5.55.0 + "@typescript-eslint/utils": 5.55.0 debug: ^4.3.4 grapheme-splitter: ^1.0.4 ignore: ^5.2.0 natural-compare-lite: ^1.4.0 - regexpp: ^3.2.0 semver: ^7.3.7 tsutils: ^3.21.0 peerDependencies: @@ -1936,7 +1961,7 @@ __metadata: peerDependenciesMeta: typescript: optional: true - checksum: 12dffe65969d8e5248c86a700fe46a737e55ecafb276933e747b4731eab6266fe55e2d43a34b8b340179fe248e127d861cd016a7614b1b9804cd0687c99616d1 + checksum: e3239ec6016eeb73b8b4d8310581978e28b8d3378140a8eb70bd8e33ffd332266020c19d493e0ccae4edfd4abd6097608718c50308fe6288f4ffeb8e4784efd9 languageName: node linkType: hard @@ -1967,16 +1992,6 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/scope-manager@npm:5.53.0": - version: 5.53.0 - resolution: "@typescript-eslint/scope-manager@npm:5.53.0" - dependencies: - "@typescript-eslint/types": 5.53.0 - "@typescript-eslint/visitor-keys": 5.53.0 - checksum: 51f31dc01e95908611f402441f58404da80a338c0237b2b82f4a7b0b2e8868c4bfe8f7cf44b2567dd56533de609156a5d4ac54bb1f9f09c7014b99428aef2543 - languageName: node - linkType: hard - "@typescript-eslint/scope-manager@npm:5.55.0": version: 5.55.0 resolution: "@typescript-eslint/scope-manager@npm:5.55.0" @@ -1987,12 +2002,12 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/type-utils@npm:5.53.0": - version: 5.53.0 - resolution: "@typescript-eslint/type-utils@npm:5.53.0" +"@typescript-eslint/type-utils@npm:5.55.0": + version: 5.55.0 + resolution: "@typescript-eslint/type-utils@npm:5.55.0" dependencies: - "@typescript-eslint/typescript-estree": 5.53.0 - "@typescript-eslint/utils": 5.53.0 + "@typescript-eslint/typescript-estree": 5.55.0 + "@typescript-eslint/utils": 5.55.0 debug: ^4.3.4 tsutils: ^3.21.0 peerDependencies: @@ -2000,7 +2015,7 @@ __metadata: peerDependenciesMeta: typescript: optional: true - checksum: 52c40967c5fabd58c2ae8bf519ef89e4feb511e4df630aeaeac8335661a79b6b3a32d30a61a5f1d8acc703f21c4d90751a5d41cda1b35d08867524da11bc2e1d + checksum: 5c60d441355b51f96b596324068c10605c74abb46748c0bbc6d8f7f2ea40acb6b4bda3b537105fa189172324c56d18bd88e7102e67f99f8c03bc05c6d0e2023d languageName: node linkType: hard @@ -2011,13 +2026,6 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/types@npm:5.53.0": - version: 5.53.0 - resolution: "@typescript-eslint/types@npm:5.53.0" - checksum: b0eaf23de4ab13697d4d2095838c959a3f410c30f0d19091e5ca08e62320c3cc3c72bcb631823fb6a4fbb31db0a059e386a0801244930d0a88a6a698e5f46548 - languageName: node - linkType: hard - "@typescript-eslint/types@npm:5.55.0": version: 5.55.0 resolution: "@typescript-eslint/types@npm:5.55.0" @@ -2043,24 +2051,6 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/typescript-estree@npm:5.53.0": - version: 5.53.0 - resolution: "@typescript-eslint/typescript-estree@npm:5.53.0" - dependencies: - "@typescript-eslint/types": 5.53.0 - "@typescript-eslint/visitor-keys": 5.53.0 - debug: ^4.3.4 - globby: ^11.1.0 - is-glob: ^4.0.3 - semver: ^7.3.7 - tsutils: ^3.21.0 - peerDependenciesMeta: - typescript: - optional: true - checksum: 6e119c8e4167c8495d728c5556a834545a9c064918dd5e7b79b0d836726f4f8e2a0297b0ac82bf2b71f1e5427552217d0b59d8fb1406fd79bd3bf91b75dca873 - languageName: node - linkType: hard - "@typescript-eslint/typescript-estree@npm:5.55.0": version: 5.55.0 resolution: "@typescript-eslint/typescript-estree@npm:5.55.0" @@ -2079,21 +2069,21 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/utils@npm:5.53.0": - version: 5.53.0 - resolution: "@typescript-eslint/utils@npm:5.53.0" +"@typescript-eslint/utils@npm:5.55.0": + version: 5.55.0 + resolution: "@typescript-eslint/utils@npm:5.55.0" dependencies: + "@eslint-community/eslint-utils": ^4.2.0 "@types/json-schema": ^7.0.9 "@types/semver": ^7.3.12 - "@typescript-eslint/scope-manager": 5.53.0 - "@typescript-eslint/types": 5.53.0 - "@typescript-eslint/typescript-estree": 5.53.0 + "@typescript-eslint/scope-manager": 5.55.0 + "@typescript-eslint/types": 5.55.0 + "@typescript-eslint/typescript-estree": 5.55.0 eslint-scope: ^5.1.1 - eslint-utils: ^3.0.0 semver: ^7.3.7 peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 - checksum: 18e6bac14ae853385a74123759850bca367904723e170c37416fc014673eb714afb6bb090367bff61494a8387e941b6af65ee5f4f845f7177fabb4df85e01643 + checksum: 368cfc3fb9d6af6901e739e2e41c3f7f1c1244576607445f4f59d95eccb237f73e1a75e7f0816ec9a32a0f1ec6bb4a3602a99e17e70fe184e62f7c69dcbe4b8d languageName: node linkType: hard @@ -2125,16 +2115,6 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/visitor-keys@npm:5.53.0": - version: 5.53.0 - resolution: "@typescript-eslint/visitor-keys@npm:5.53.0" - dependencies: - "@typescript-eslint/types": 5.53.0 - eslint-visitor-keys: ^3.3.0 - checksum: 090695883c15364c6f401e97f56b13db0f31c1114f3bd22562bd41734864d27f6a3c80de33957e9dedab2d5f94b0f4480ba3fde1d4574e74dca4593917b7b54a - languageName: node - linkType: hard - "@typescript-eslint/visitor-keys@npm:5.55.0": version: 5.55.0 resolution: "@typescript-eslint/visitor-keys@npm:5.55.0" @@ -2444,7 +2424,7 @@ __metadata: languageName: node linkType: hard -"array-includes@npm:^3.1.4": +"array-includes@npm:^3.1.6": version: 3.1.6 resolution: "array-includes@npm:3.1.6" dependencies: @@ -2464,7 +2444,7 @@ __metadata: languageName: node linkType: hard -"array.prototype.flat@npm:^1.2.5": +"array.prototype.flat@npm:^1.3.1": version: 1.3.1 resolution: "array.prototype.flat@npm:1.3.1" dependencies: @@ -2476,6 +2456,18 @@ __metadata: languageName: node linkType: hard +"array.prototype.flatmap@npm:^1.3.1": + version: 1.3.1 + resolution: "array.prototype.flatmap@npm:1.3.1" + dependencies: + call-bind: ^1.0.2 + define-properties: ^1.1.4 + es-abstract: ^1.20.4 + es-shim-unscopables: ^1.0.0 + checksum: 8c1c43a4995f12cf12523436da28515184c753807b3f0bc2ca6c075f71c470b099e2090cc67dba8e5280958fea401c1d0c59e1db0143272aef6cd1103921a987 + languageName: node + linkType: hard + "arrify@npm:^2.0.1": version: 2.0.1 resolution: "arrify@npm:2.0.1" @@ -3173,15 +3165,6 @@ __metadata: languageName: node linkType: hard -"debug@npm:^2.6.9": - version: 2.6.9 - resolution: "debug@npm:2.6.9" - dependencies: - ms: 2.0.0 - checksum: d2f51589ca66df60bf36e1fa6e4386b318c3f1e06772280eea5b1ae9fd3d05e9c2b7fd8a7d862457d00853c75b00451aa2d7459b924629ee385287a650f58fe6 - languageName: node - linkType: hard - "debug@npm:^3.2.7": version: 3.2.7 resolution: "debug@npm:3.2.7" @@ -3511,28 +3494,29 @@ __metadata: languageName: node linkType: hard -"eslint-config-prettier@npm:^8.5.0": - version: 8.5.0 - resolution: "eslint-config-prettier@npm:8.5.0" +"eslint-config-prettier@npm:^8.7.0": + version: 8.7.0 + resolution: "eslint-config-prettier@npm:8.7.0" peerDependencies: eslint: ">=7.0.0" bin: eslint-config-prettier: bin/cli.js - checksum: 0d0f5c32e7a0ad91249467ce71ca92394ccd343178277d318baf32063b79ea90216f4c81d1065d60f96366fdc60f151d4d68ae7811a58bd37228b84c2083f893 + checksum: b05bc7f2296ce3e0925c14147849706544870e0382d38af2352d709a6cf8521bdaff2bd8e5021f1780e570775a8ffa1d2bac28b8065d90d43a3f1f98fd26ce52 languageName: node linkType: hard -"eslint-import-resolver-node@npm:^0.3.6": - version: 0.3.6 - resolution: "eslint-import-resolver-node@npm:0.3.6" +"eslint-import-resolver-node@npm:^0.3.7": + version: 0.3.7 + resolution: "eslint-import-resolver-node@npm:0.3.7" dependencies: debug: ^3.2.7 - resolve: ^1.20.0 - checksum: 6266733af1e112970e855a5bcc2d2058fb5ae16ad2a6d400705a86b29552b36131ffc5581b744c23d550de844206fb55e9193691619ee4dbf225c4bde526b1c8 + is-core-module: ^2.11.0 + resolve: ^1.22.1 + checksum: 3379aacf1d2c6952c1b9666c6fa5982c3023df695430b0d391c0029f6403a7775414873d90f397e98ba6245372b6c8960e16e74d9e4a3b0c0a4582f3bdbe3d6e languageName: node linkType: hard -"eslint-module-utils@npm:^2.7.3": +"eslint-module-utils@npm:^2.7.4": version: 2.7.4 resolution: "eslint-module-utils@npm:2.7.4" dependencies: @@ -3556,32 +3540,34 @@ __metadata: languageName: node linkType: hard -"eslint-plugin-import@npm:^2.26.0": - version: 2.26.0 - resolution: "eslint-plugin-import@npm:2.26.0" +"eslint-plugin-import@npm:^2.27.5": + version: 2.27.5 + resolution: "eslint-plugin-import@npm:2.27.5" dependencies: - array-includes: ^3.1.4 - array.prototype.flat: ^1.2.5 - debug: ^2.6.9 + array-includes: ^3.1.6 + array.prototype.flat: ^1.3.1 + array.prototype.flatmap: ^1.3.1 + debug: ^3.2.7 doctrine: ^2.1.0 - eslint-import-resolver-node: ^0.3.6 - eslint-module-utils: ^2.7.3 + eslint-import-resolver-node: ^0.3.7 + eslint-module-utils: ^2.7.4 has: ^1.0.3 - is-core-module: ^2.8.1 + is-core-module: ^2.11.0 is-glob: ^4.0.3 minimatch: ^3.1.2 - object.values: ^1.1.5 - resolve: ^1.22.0 + object.values: ^1.1.6 + resolve: ^1.22.1 + semver: ^6.3.0 tsconfig-paths: ^3.14.1 peerDependencies: eslint: ^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8 - checksum: 0bf77ad80339554481eafa2b1967449e1f816b94c7a6f9614ce33fb4083c4e6c050f10d241dd50b4975d47922880a34de1e42ea9d8e6fd663ebb768baa67e655 + checksum: f500571a380167e25d72a4d925ef9a7aae8899eada57653e5f3051ec3d3c16d08271fcefe41a30a9a2f4fefc232f066253673ee4ea77b30dba65ae173dade85d languageName: node linkType: hard -"eslint-plugin-jest@npm:^27.1.6": - version: 27.1.6 - resolution: "eslint-plugin-jest@npm:27.1.6" +"eslint-plugin-jest@npm:^27.2.1": + version: 27.2.1 + resolution: "eslint-plugin-jest@npm:27.2.1" dependencies: "@typescript-eslint/utils": ^5.10.0 peerDependencies: @@ -3592,24 +3578,24 @@ __metadata: optional: true jest: optional: true - checksum: 5b1640b5d575f0d5e27da8ef8cb3110a29f94ebd50ae51edc5ea34c1054f5dcf305416865b2919ac424bc02c4569848bbe7fd2c86e7e1aff23e77f1ff9ef7dfd + checksum: 579a4d26304cc6748b2e6dff6c965ea7a21b618d8b051eb02727d25cf5c7767f6db8ef5237531635ff77e242b983b973e7cb8c820a4d20d5bda73358c452a8ab languageName: node linkType: hard -"eslint-plugin-jsdoc@npm:^39.6.4": - version: 39.6.4 - resolution: "eslint-plugin-jsdoc@npm:39.6.4" +"eslint-plugin-jsdoc@npm:^40.0.3": + version: 40.0.3 + resolution: "eslint-plugin-jsdoc@npm:40.0.3" dependencies: - "@es-joy/jsdoccomment": ~0.36.1 + "@es-joy/jsdoccomment": ~0.37.0 comment-parser: 1.3.1 debug: ^4.3.4 escape-string-regexp: ^4.0.0 - esquery: ^1.4.0 + esquery: ^1.5.0 semver: ^7.3.8 spdx-expression-parse: ^3.0.1 peerDependencies: eslint: ^7.0.0 || ^8.0.0 - checksum: 2976112ae997b9f246eba98d849359a0df46ea07c0a9d6d90c3b76a29c253b9e92d1d46d6cf86f878e442653b97591e5ea01d05a6accdb078339c39e8767723e + checksum: abdb69d4aa7a2255dc92d1416f58e4060cfe310642c37b26175b721487be82eaad13466a5b2508d737762b5a382fbeecd41e13f81b239c294e2753a4b9ee0178 languageName: node linkType: hard @@ -3705,12 +3691,15 @@ __metadata: languageName: node linkType: hard -"eslint@npm:^8.29.0": - version: 8.29.0 - resolution: "eslint@npm:8.29.0" +"eslint@npm:^8.36.0": + version: 8.36.0 + resolution: "eslint@npm:8.36.0" dependencies: - "@eslint/eslintrc": ^1.3.3 - "@humanwhocodes/config-array": ^0.11.6 + "@eslint-community/eslint-utils": ^4.2.0 + "@eslint-community/regexpp": ^4.4.0 + "@eslint/eslintrc": ^2.0.1 + "@eslint/js": 8.36.0 + "@humanwhocodes/config-array": ^0.11.8 "@humanwhocodes/module-importer": ^1.0.1 "@nodelib/fs.walk": ^1.2.8 ajv: ^6.10.0 @@ -3720,16 +3709,15 @@ __metadata: doctrine: ^3.0.0 escape-string-regexp: ^4.0.0 eslint-scope: ^7.1.1 - eslint-utils: ^3.0.0 eslint-visitor-keys: ^3.3.0 - espree: ^9.4.0 - esquery: ^1.4.0 + espree: ^9.5.0 + esquery: ^1.4.2 esutils: ^2.0.2 fast-deep-equal: ^3.1.3 file-entry-cache: ^6.0.1 find-up: ^5.0.0 glob-parent: ^6.0.2 - globals: ^13.15.0 + globals: ^13.19.0 grapheme-splitter: ^1.0.4 ignore: ^5.2.0 import-fresh: ^3.0.0 @@ -3744,24 +3732,23 @@ __metadata: minimatch: ^3.1.2 natural-compare: ^1.4.0 optionator: ^0.9.1 - regexpp: ^3.2.0 strip-ansi: ^6.0.1 strip-json-comments: ^3.1.0 text-table: ^0.2.0 bin: eslint: bin/eslint.js - checksum: e05204b05907b82d910983995cb946e0ba62ca514eb2b6791c43f623333b143564a2eee0139909d31c10935c21877d815b1f76dd674a59cb91c471064325c4ab + checksum: e9a961fc3b3de5cff5a1cb2c92eeffaa7e155a715489e30b3e1e76f186bd1255e0481e09564f2094733c0b1dbd3453499fb72ae7c043c83156e11e6d965b2304 languageName: node linkType: hard -"espree@npm:^9.4.0": - version: 9.4.1 - resolution: "espree@npm:9.4.1" +"espree@npm:^9.5.0": + version: 9.5.0 + resolution: "espree@npm:9.5.0" dependencies: acorn: ^8.8.0 acorn-jsx: ^5.3.2 eslint-visitor-keys: ^3.3.0 - checksum: 4d266b0cf81c7dfe69e542c7df0f246e78d29f5b04dda36e514eb4c7af117ee6cfbd3280e560571ed82ff6c9c3f0003c05b82583fc7a94006db7497c4fe4270e + checksum: a7f110aefb6407e0d3237aa635ab3cea87106ae63748dd23c67031afccc640d04c4209fca2daf16e2233c82efb505faead0fb84097478fd9cc6e8f8dd80bf99d languageName: node linkType: hard @@ -3784,6 +3771,15 @@ __metadata: languageName: node linkType: hard +"esquery@npm:^1.4.2, esquery@npm:^1.5.0": + version: 1.5.0 + resolution: "esquery@npm:1.5.0" + dependencies: + estraverse: ^5.1.0 + checksum: aefb0d2596c230118656cd4ec7532d447333a410a48834d80ea648b1e7b5c9bc9ed8b5e33a89cb04e487b60d622f44cf5713bf4abed7c97343edefdc84a35900 + languageName: node + linkType: hard + "esrecurse@npm:^4.3.0": version: 4.3.0 resolution: "esrecurse@npm:4.3.0" @@ -4314,12 +4310,12 @@ __metadata: languageName: node linkType: hard -"globals@npm:^13.15.0": - version: 13.19.0 - resolution: "globals@npm:13.19.0" +"globals@npm:^13.19.0": + version: 13.20.0 + resolution: "globals@npm:13.20.0" dependencies: type-fest: ^0.20.2 - checksum: a000dbd00bcf28f0941d8a29c3522b1c3b8e4bfe4e60e262c477a550c3cbbe8dbe2925a6905f037acd40f9a93c039242e1f7079c76b0fd184bc41dcc3b5c8e2e + checksum: ad1ecf914bd051325faad281d02ea2c0b1df5d01bd94d368dcc5513340eac41d14b3c61af325768e3c7f8d44576e72780ec0b6f2d366121f8eec6e03c3a3b97a languageName: node linkType: hard @@ -4704,7 +4700,7 @@ __metadata: languageName: node linkType: hard -"is-core-module@npm:^2.4.0, is-core-module@npm:^2.8.1, is-core-module@npm:^2.9.0": +"is-core-module@npm:^2.11.0, is-core-module@npm:^2.4.0, is-core-module@npm:^2.9.0": version: 2.11.0 resolution: "is-core-module@npm:2.11.0" dependencies: @@ -5460,10 +5456,10 @@ __metadata: languageName: node linkType: hard -"jsdoc-type-pratt-parser@npm:~3.1.0": - version: 3.1.0 - resolution: "jsdoc-type-pratt-parser@npm:3.1.0" - checksum: 2f437b57621f1e481918165f6cf0e48256628a9e510d8b3f88a2ab667bf2128bf8b94c628b57c43e78f555ca61983e9c282814703840dc091d2623992214a061 +"jsdoc-type-pratt-parser@npm:~4.0.0": + version: 4.0.0 + resolution: "jsdoc-type-pratt-parser@npm:4.0.0" + checksum: af0629c9517e484be778d8564440fec8de5b7610e0c9c88a3ba4554321364faf72b46689c8d8845faa12c0718437a9ed97e231977efc0f2d50e8a2dbad807eb3 languageName: node linkType: hard @@ -5940,13 +5936,6 @@ __metadata: languageName: node linkType: hard -"ms@npm:2.0.0": - version: 2.0.0 - resolution: "ms@npm:2.0.0" - checksum: 0e6a22b8b746d2e0b65a430519934fefd41b6db0682e3477c10f60c76e947c4c0ad06f63ffdf1d78d335f83edee8c0aa928aa66a36c7cd95b69b26f468d527f4 - languageName: node - linkType: hard - "ms@npm:2.1.2": version: 2.1.2 resolution: "ms@npm:2.1.2" @@ -6207,7 +6196,7 @@ __metadata: languageName: node linkType: hard -"object.values@npm:^1.1.5": +"object.values@npm:^1.1.6": version: 1.1.6 resolution: "object.values@npm:1.1.6" dependencies: @@ -6650,7 +6639,7 @@ __metadata: languageName: node linkType: hard -"regexpp@npm:^3.0.0, regexpp@npm:^3.2.0": +"regexpp@npm:^3.0.0": version: 3.2.0 resolution: "regexpp@npm:3.2.0" checksum: a78dc5c7158ad9ddcfe01aa9144f46e192ddbfa7b263895a70a5c6c73edd9ce85faf7c0430e59ac38839e1734e275b9c3de5c57ee3ab6edc0e0b1bdebefccef8 @@ -6729,7 +6718,7 @@ __metadata: languageName: node linkType: hard -"resolve@npm:^1.10.1, resolve@npm:^1.18.1, resolve@npm:^1.20.0, resolve@npm:^1.22.0": +"resolve@npm:^1.10.1, resolve@npm:^1.18.1, resolve@npm:^1.20.0, resolve@npm:^1.22.1": version: 1.22.1 resolution: "resolve@npm:1.22.1" dependencies: @@ -6742,7 +6731,7 @@ __metadata: languageName: node linkType: hard -"resolve@patch:resolve@^1.10.1#~builtin, resolve@patch:resolve@^1.18.1#~builtin, resolve@patch:resolve@^1.20.0#~builtin, resolve@patch:resolve@^1.22.0#~builtin": +"resolve@patch:resolve@^1.10.1#~builtin, resolve@patch:resolve@^1.18.1#~builtin, resolve@patch:resolve@^1.20.0#~builtin, resolve@patch:resolve@^1.22.1#~builtin": version: 1.22.1 resolution: "resolve@patch:resolve@npm%3A1.22.1#~builtin::version=1.22.1&hash=07638b" dependencies: From b6189656984c6dcdaf7e511204038fb92beccb5b Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Tue, 21 Mar 2023 20:03:07 -0300 Subject: [PATCH 088/109] Add prettierignore and revert .yarnrc.yml file --- .prettierignore | 1 + .yarnrc.yml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 .prettierignore diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..b94bfd97 --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +.yarnrc.yml \ No newline at end of file diff --git a/.yarnrc.yml b/.yarnrc.yml index bffaec46..8668abfb 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -10,6 +10,6 @@ nodeLinker: node-modules plugins: - path: .yarn/plugins/@yarnpkg/plugin-allow-scripts.cjs - spec: 'https://raw.githubusercontent.com/LavaMoat/LavaMoat/main/packages/yarn-plugin-allow-scripts/bundles/@yarnpkg/plugin-allow-scripts.js' + spec: "https://raw.githubusercontent.com/LavaMoat/LavaMoat/main/packages/yarn-plugin-allow-scripts/bundles/@yarnpkg/plugin-allow-scripts.js" yarnPath: .yarn/releases/yarn-3.2.4.cjs From a12ce456af2831238844dcc5cab8cda903378b2c Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Tue, 21 Mar 2023 20:03:48 -0300 Subject: [PATCH 089/109] Update sinon import --- src/KeyringController.test.ts | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/KeyringController.test.ts b/src/KeyringController.test.ts index e429d575..9c34e2b8 100644 --- a/src/KeyringController.test.ts +++ b/src/KeyringController.test.ts @@ -3,7 +3,7 @@ import { normalize as normalizeAddress } from '@metamask/eth-sig-util'; import type { Hex, Json, Keyring, KeyringClass } from '@metamask/utils'; import { strict as assert } from 'assert'; import Wallet from 'ethereumjs-wallet'; -import { restore, spy, stub, assert as sinonAssert } from 'sinon'; +import * as sinon from 'sinon'; import { KeyringController, keyringBuilderFactory } from '.'; import { KeyringType, KeyringControllerError } from './constants'; @@ -54,7 +54,7 @@ describe('KeyringController', () => { }); afterEach(() => { - restore(); + sinon.restore(); }); describe('setLocked', () => { @@ -73,7 +73,7 @@ describe('KeyringController', () => { }); it('emits "lock" event', async () => { - const lockSpy = spy(); + const lockSpy = sinon.spy(); keyringController.on('lock', lockSpy); await keyringController.setLocked(); @@ -100,7 +100,7 @@ describe('KeyringController', () => { it('emits "unlock" event', async () => { await keyringController.setLocked(); - const unlockSpy = spy(); + const unlockSpy = sinon.spy(); keyringController.on('unlock', unlockSpy); await keyringController.submitPassword(PASSWORD); @@ -403,7 +403,7 @@ describe('KeyringController', () => { }); it('should call init method if available', async () => { - const initSpy = spy(KeyringMockWithInit.prototype, 'init'); + const initSpy = sinon.spy(KeyringMockWithInit.prototype, 'init'); const keyring = await keyringController.addNewKeyring( 'Keyring Mock With Init', @@ -411,12 +411,12 @@ describe('KeyringController', () => { expect(keyring).toBeInstanceOf(KeyringMockWithInit); - sinonAssert.calledOnce(initSpy); + sinon.assert.calledOnce(initSpy); }); it('should add HD Key Tree when addAccounts is asynchronous', async () => { const originalAccAccounts = HdKeyring.prototype.addAccounts; - stub(HdKeyring.prototype, 'addAccounts').callsFake(async () => { + sinon.stub(HdKeyring.prototype, 'addAccounts').callsFake(async () => { return new Promise((resolve) => { setImmediate(() => { resolve(originalAccAccounts.bind(this)()); @@ -424,7 +424,7 @@ describe('KeyringController', () => { }); }); - stub(HdKeyring.prototype, 'deserialize').callsFake(async () => { + sinon.stub(HdKeyring.prototype, 'deserialize').callsFake(async () => { return new Promise((resolve) => { setImmediate(() => { resolve(); @@ -432,9 +432,9 @@ describe('KeyringController', () => { }); }); - stub(HdKeyring.prototype, 'getAccounts').callsFake(() => [ - 'mock account', - ]); + sinon + .stub(HdKeyring.prototype, 'getAccounts') + .callsFake(() => ['mock account']); const keyring = await keyringController.addNewKeyring(KeyringType.HD, { mnemonic: 'mock mnemonic', @@ -646,11 +646,14 @@ describe('KeyringController', () => { { privateKeys: [privateKey] }, ); - const getAppKeyAddressSpy = spy(keyringController, 'getAppKeyAddress'); - /* eslint-disable-next-line require-atomic-updates */ - keyringController.getKeyringForAccount = stub().returns( - Promise.resolve(keyring), + const getAppKeyAddressSpy = sinon.spy( + keyringController, + 'getAppKeyAddress', ); + /* eslint-disable-next-line require-atomic-updates */ + keyringController.getKeyringForAccount = sinon + .stub() + .returns(Promise.resolve(keyring)); await keyringController.getAppKeyAddress(address, 'someapp.origin.io'); @@ -748,7 +751,7 @@ describe('KeyringController', () => { it('unlocks the keyrings with valid information', async () => { keyringController.cacheEncryptionKey = true; const returnValue = await keyringController.encryptor.decryptWithKey(); - const decryptWithKeyStub = stub( + const decryptWithKeyStub = sinon.stub( keyringController.encryptor, 'decryptWithKey', ); From 91fd4378dfc92de33b9b8203b39845157eac9244 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Tue, 21 Mar 2023 20:04:52 -0300 Subject: [PATCH 090/109] Remove type cast in submitPassword test --- src/KeyringController.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/KeyringController.test.ts b/src/KeyringController.test.ts index 9c34e2b8..198c8df9 100644 --- a/src/KeyringController.test.ts +++ b/src/KeyringController.test.ts @@ -91,7 +91,7 @@ describe('KeyringController', () => { await keyringController.setLocked(); await expect( - keyringController.submitPassword(`${PASSWORD as string}a`), + keyringController.submitPassword('Wrong password'), ).rejects.toThrow('Incorrect password.'); expect(keyringController.password).toBeUndefined(); expect(keyringController.keyrings).toHaveLength(0); From 5b17f35678083e8e0cc27688f698e3fe5a9a4bdc Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Tue, 21 Mar 2023 20:05:42 -0300 Subject: [PATCH 091/109] Remove type cast in persistAllKeyrings test --- src/KeyringController.test.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/KeyringController.test.ts b/src/KeyringController.test.ts index 198c8df9..3b4672c8 100644 --- a/src/KeyringController.test.ts +++ b/src/KeyringController.test.ts @@ -115,10 +115,7 @@ describe('KeyringController', () => { await keyringController.persistAllKeyrings(); const { vault } = keyringController.store.getState(); - const keyrings = (await mockEncryptor.decrypt(PASSWORD, vault)) as { - type: string; - data: Json; - }[]; + const keyrings = await mockEncryptor.decrypt(PASSWORD, vault); expect(keyrings).toContain(unsupportedKeyring); expect(keyrings).toHaveLength(2); }); From 5dc6cb096d1de884f6e3579eae143c1ccb917069 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Tue, 21 Mar 2023 20:27:10 -0300 Subject: [PATCH 092/109] Add @ts-expect-error to remove type casts --- src/KeyringController.test.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/KeyringController.test.ts b/src/KeyringController.test.ts index 3b4672c8..e0184262 100644 --- a/src/KeyringController.test.ts +++ b/src/KeyringController.test.ts @@ -277,10 +277,8 @@ describe('KeyringController', () => { it('throws error if argument password is not a string', async () => { await expect(async () => - keyringController.createNewVaultAndRestore( - 12 as any, - walletTwoSeedWords, - ), + // @ts-expect-error Missing other required permission types. + keyringController.createNewVaultAndRestore(12, walletTwoSeedWords), ).rejects.toThrow('KeyringController - Password must be of type string.'); }); @@ -695,7 +693,8 @@ describe('KeyringController', () => { describe('getKeyringForAccount', () => { it('throws error when address is not provided', async () => { await expect( - keyringController.getKeyringForAccount(undefined as any), + // @ts-expect-error Missing other required permission types. + keyringController.getKeyringForAccount(undefined), ).rejects.toThrow( new Error( `${KeyringControllerError.NoKeyring}. Error info: The address passed in is invalid/empty`, From 9c59391665f98e2b2e75f881204179b17b2248d1 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Tue, 21 Mar 2023 20:33:40 -0300 Subject: [PATCH 093/109] Set password to only string --- src/KeyringController.test.ts | 4 ++-- src/KeyringController.ts | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/KeyringController.test.ts b/src/KeyringController.test.ts index e0184262..39b30d78 100644 --- a/src/KeyringController.test.ts +++ b/src/KeyringController.test.ts @@ -122,7 +122,7 @@ describe('KeyringController', () => { describe('when `cacheEncryptionKey` is enabled', () => { it('should save an up to date encryption salt to the `memStore` when `password` is unset and `encryptionKey` is set', async () => { - keyringController.password = undefined; + delete keyringController.password; keyringController.cacheEncryptionKey = true; const vaultEncryptionKey = '🔑'; const vaultEncryptionSalt = '🧂'; @@ -830,7 +830,7 @@ describe('KeyringController', () => { }); it('triggers an error when trying to persist without password or encryption key', async () => { - keyringController.password = undefined; + delete keyringController.password; await expect(keyringController.persistAllKeyrings()).rejects.toThrow( 'Cannot persist vault without password and encryption key', ); diff --git a/src/KeyringController.ts b/src/KeyringController.ts index c4c2c371..14c05fcd 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -45,7 +45,7 @@ class KeyringController extends EventEmitter { public unsupportedKeyrings: SerializedKeyring[]; - public password?: string | undefined; + public password?: string; constructor({ keyringBuilders, @@ -332,7 +332,7 @@ class KeyringController extends EventEmitter { * @returns The account, if no duplicate is found. */ async checkForDuplicate( - type: string, + type: KeyringType | string, newAccountArray: Hex[], ): Promise { const accounts = await this.getAccounts(); @@ -517,7 +517,7 @@ class KeyringController extends EventEmitter { * @returns The public key. */ async getEncryptionPublicKey( - address: string | Hex, + address: string, opts: Record = {}, ): Promise { const normalizedAddress = normalizeAddress(address); @@ -643,7 +643,7 @@ class KeyringController extends EventEmitter { * @param type - The keyring types to retrieve. * @returns Keyrings matching the specified type. */ - getKeyringsByType(type: KeyringType): Keyring[] { + getKeyringsByType(type: KeyringType | string): Keyring[] { return this.keyrings.filter((keyring) => keyring.type === type); } @@ -953,7 +953,9 @@ class KeyringController extends EventEmitter { * @param type - The type whose class to get. * @returns The class, if it exists. */ - #getKeyringBuilderForType(type: string): any { + #getKeyringBuilderForType( + type: KeyringType | string, + ): { (): Keyring; type: string } | undefined { return this.keyringBuilders.find( (keyringBuilder) => keyringBuilder.type === type, ); @@ -1013,7 +1015,10 @@ class KeyringController extends EventEmitter { * @param data - The data to restore a previously serialized keyring. * @returns The new keyring. */ - async #newKeyring(type: string, data: unknown): Promise> { + async #newKeyring( + type: KeyringType | string, + data: unknown, + ): Promise> { const keyringBuilder = this.#getKeyringBuilderForType(type); if (!keyringBuilder) { @@ -1024,7 +1029,7 @@ class KeyringController extends EventEmitter { const keyring = keyringBuilder(); - await keyring.deserialize(data); + await keyring.deserialize(data as Json); if (keyring.init) { await keyring.init(); From 6eff4a1b4d09b68cc4ec3fc3b4d0ee378f153f90 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Tue, 21 Mar 2023 20:38:49 -0300 Subject: [PATCH 094/109] Remove type from forEach --- src/KeyringController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index 14c05fcd..8ece6227 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -372,7 +372,7 @@ class KeyringController extends EventEmitter { selectedKeyring: Keyring, ): Promise { const accounts = await selectedKeyring.addAccounts(1); - accounts.forEach((hexAccount: string) => { + accounts.forEach((hexAccount) => { this.emit('newAccount', hexAccount); }); From e36c1348aadc882625deda681912d6b45786060e Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Tue, 21 Mar 2023 20:57:00 -0300 Subject: [PATCH 095/109] Update hex methods --- src/KeyringController.ts | 51 +++++++++++++++++--------------- src/constants.ts | 1 + src/utils/index.ts | 3 -- src/utils/stripHexPrefix.test.ts | 9 ------ src/utils/stripHexPrefix.ts | 12 -------- 5 files changed, 28 insertions(+), 48 deletions(-) delete mode 100644 src/utils/index.ts delete mode 100644 src/utils/stripHexPrefix.test.ts delete mode 100644 src/utils/stripHexPrefix.ts diff --git a/src/KeyringController.ts b/src/KeyringController.ts index 8ece6227..f4bff97e 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -1,8 +1,9 @@ import type { TypedTransaction, TxData } from '@ethereumjs/tx'; import * as encryptorUtils from '@metamask/browser-passworder'; import HDKeyring from '@metamask/eth-hd-keyring'; -import { normalize as normalizeAddress } from '@metamask/eth-sig-util'; +import { normalize as normalizeToHex } from '@metamask/eth-sig-util'; import SimpleKeyring from '@metamask/eth-simple-keyring'; +import { remove0x } from '@metamask/utils'; import type { Hex, Json, @@ -23,7 +24,6 @@ import { KeyringControllerArgs, KeyringControllerState, } from './types'; -import { stripHexPrefix } from './utils'; const defaultKeyringBuilders = [ keyringBuilderFactory(SimpleKeyring), @@ -333,7 +333,7 @@ class KeyringController extends EventEmitter { */ async checkForDuplicate( type: KeyringType | string, - newAccountArray: Hex[], + newAccountArray: string[], ): Promise { const accounts = await this.getAccounts(); @@ -342,8 +342,9 @@ class KeyringController extends EventEmitter { const isIncluded = Boolean( accounts.find( (key) => - key === newAccountArray[0] || - key === stripHexPrefix(newAccountArray[0] as Hex), + newAccountArray[0] && + (key === newAccountArray[0] || + key === remove0x(newAccountArray[0])), ), ); @@ -397,7 +398,7 @@ class KeyringController extends EventEmitter { throw new Error(KeyringControllerError.UnsupportedExportAccount); } - return await keyring.exportAccount(normalizeAddress(address)); + return await keyring.exportAccount(normalizeToHex(address)); } /** @@ -449,7 +450,7 @@ class KeyringController extends EventEmitter { rawAddress: string | Hex, opts: Record = {}, ): Promise { - const address = normalizeAddress(rawAddress); + const address = normalizeToHex(rawAddress); const keyring = await this.getKeyringForAccount(address); if (!keyring.signTransaction) { throw new Error(KeyringControllerError.UnsupportedSignTransaction); @@ -471,7 +472,7 @@ class KeyringController extends EventEmitter { msgParams: MessageParams, opts: Record = {}, ): Promise { - const address = normalizeAddress(msgParams.from); + const address = normalizeToHex(msgParams.from); const keyring = await this.getKeyringForAccount(address); if (!keyring.signMessage) { throw new Error(KeyringControllerError.UnsupportedSignMessage); @@ -494,17 +495,19 @@ class KeyringController extends EventEmitter { msgParams: MessageParams, opts: Record = {}, ): Promise { - const address = normalizeAddress(msgParams.from); + const address = normalizeToHex(msgParams.from); const keyring = await this.getKeyringForAccount(address); if (!keyring.signPersonalMessage) { throw new Error(KeyringControllerError.UnsupportedSignPersonalMessage); } - return await keyring.signPersonalMessage( - address, - msgParams.data as Hex, - opts, - ); + if (typeof msgParams.data !== 'string') { + throw new Error(KeyringControllerError.DataType); + } + + const normalizedData = normalizeToHex(msgParams.data); + + return await keyring.signPersonalMessage(address, normalizedData, opts); } /** @@ -520,7 +523,7 @@ class KeyringController extends EventEmitter { address: string, opts: Record = {}, ): Promise { - const normalizedAddress = normalizeAddress(address); + const normalizedAddress = normalizeToHex(address); const keyring = await this.getKeyringForAccount(address); if (!keyring.getEncryptionPublicKey) { throw new Error(KeyringControllerError.UnsupportedGetEncryptionPublicKey); @@ -538,7 +541,7 @@ class KeyringController extends EventEmitter { * @returns The raw decryption result. */ async decryptMessage(msgParams: MessageParams): Promise { - const address = normalizeAddress(msgParams.from); + const address = normalizeToHex(msgParams.from); const keyring = await this.getKeyringForAccount(address); if (!keyring.decryptMessage) { throw new Error(KeyringControllerError.UnsupportedDecryptMessage); @@ -562,7 +565,7 @@ class KeyringController extends EventEmitter { msgParams: MessageParams, opts = { version: 'V1' }, ): Promise { - const address = normalizeAddress(msgParams.from); + const address = normalizeToHex(msgParams.from); const keyring = await this.getKeyringForAccount(address); if (!keyring.signTypedData) { throw new Error(KeyringControllerError.UnsupportedSignTypedMessage); @@ -583,7 +586,7 @@ class KeyringController extends EventEmitter { * @returns The app key address. */ async getAppKeyAddress(rawAddress: string, origin: string): Promise { - const address = normalizeAddress(rawAddress); + const address = normalizeToHex(rawAddress); const keyring = await this.getKeyringForAccount(address); if (!keyring.getAppKeyAddress) { throw new Error(KeyringControllerError.UnsupportedGetAppKeyAddress); @@ -603,7 +606,7 @@ class KeyringController extends EventEmitter { rawAddress: string, origin: string, ): Promise { - const address = normalizeAddress(rawAddress); + const address = normalizeToHex(rawAddress); const keyring = await this.getKeyringForAccount(address); // The "in" operator is typically restricted because it also checks inherited properties, // which can be unexpected for plain objects. We're allowing it here because `keyring` is not @@ -817,7 +820,7 @@ class KeyringController extends EventEmitter { return res.concat(arr); }, []); - return addresses.map(normalizeAddress); + return addresses.map(normalizeToHex); } /** @@ -830,7 +833,7 @@ class KeyringController extends EventEmitter { * @returns The keyring of the account, if it exists. */ async getKeyringForAccount(address: string): Promise> { - const hexed = normalizeAddress(address); + const hexed = normalizeToHex(address); const candidates = await Promise.all( this.keyrings.map(async (keyring) => { @@ -839,7 +842,7 @@ class KeyringController extends EventEmitter { ); const winners = candidates.filter((candidate) => { - const accounts = candidate[1].map(normalizeAddress); + const accounts = candidate[1].map(normalizeToHex); return accounts.includes(hexed); }); @@ -903,7 +906,7 @@ class KeyringController extends EventEmitter { throw new Error(KeyringControllerError.NoAccountOnKeychain); } - const hexAccount = normalizeAddress(firstAccount); + const hexAccount = normalizeToHex(firstAccount); this.emit('newVault', hexAccount); return null; } @@ -976,7 +979,7 @@ class KeyringController extends EventEmitter { return { type: keyring.type, - accounts: accounts.map(normalizeAddress), + accounts: accounts.map(normalizeToHex), }; } diff --git a/src/constants.ts b/src/constants.ts index d8d28035..1a1a3d27 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -25,4 +25,5 @@ export enum KeyringControllerError { MissingVaultData = 'KeyringController - Cannot persist vault without vault information', ExpiredCredentials = 'KeyringController - Encryption key and salt provided are expired', NoKeyringBuilder = 'KeyringController - No keyringBuilder found for keyring', + DataType = 'KeyringController - Incorrect data type provided', } diff --git a/src/utils/index.ts b/src/utils/index.ts deleted file mode 100644 index 3e5897b7..00000000 --- a/src/utils/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import stripHexPrefix from './stripHexPrefix'; - -export { stripHexPrefix }; diff --git a/src/utils/stripHexPrefix.test.ts b/src/utils/stripHexPrefix.test.ts deleted file mode 100644 index ba547a09..00000000 --- a/src/utils/stripHexPrefix.test.ts +++ /dev/null @@ -1,9 +0,0 @@ -import stripHexPrefix from './stripHexPrefix'; - -describe('stripHexPrefix', () => { - it('should return the value without the hex prefix', () => { - const hexWithPrefix = '0x123'; - const expectedResult = '123'; - expect(stripHexPrefix(hexWithPrefix)).toBe(expectedResult); - }); -}); diff --git a/src/utils/stripHexPrefix.ts b/src/utils/stripHexPrefix.ts deleted file mode 100644 index 3f0276c6..00000000 --- a/src/utils/stripHexPrefix.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Hex } from '@metamask/utils'; - -/** - * Strip the hex prefix from an address, if present. - * - * @param address - The address that might be hex prefixed. - * @returns The address without a hex prefix. - */ -const stripHexPrefix = (address: Hex): string => - parseInt(address, 16).toString(16); - -export default stripHexPrefix; From 4fba438faab615601c54ad7dbbaeeaea48c76db2 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Tue, 21 Mar 2023 21:14:52 -0300 Subject: [PATCH 096/109] Remove KeyringType as data type in methods --- src/KeyringController.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index f4bff97e..668e777e 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -332,7 +332,7 @@ class KeyringController extends EventEmitter { * @returns The account, if no duplicate is found. */ async checkForDuplicate( - type: KeyringType | string, + type: string, newAccountArray: string[], ): Promise { const accounts = await this.getAccounts(); @@ -646,7 +646,7 @@ class KeyringController extends EventEmitter { * @param type - The keyring types to retrieve. * @returns Keyrings matching the specified type. */ - getKeyringsByType(type: KeyringType | string): Keyring[] { + getKeyringsByType(type: string): Keyring[] { return this.keyrings.filter((keyring) => keyring.type === type); } @@ -957,7 +957,7 @@ class KeyringController extends EventEmitter { * @returns The class, if it exists. */ #getKeyringBuilderForType( - type: KeyringType | string, + type: string, ): { (): Keyring; type: string } | undefined { return this.keyringBuilders.find( (keyringBuilder) => keyringBuilder.type === type, @@ -1018,10 +1018,7 @@ class KeyringController extends EventEmitter { * @param data - The data to restore a previously serialized keyring. * @returns The new keyring. */ - async #newKeyring( - type: KeyringType | string, - data: unknown, - ): Promise> { + async #newKeyring(type: string, data: unknown): Promise> { const keyringBuilder = this.#getKeyringBuilderForType(type); if (!keyringBuilder) { From 7044d640adbd718a1c8540f8ec3faa1940db8edc Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Tue, 21 Mar 2023 21:15:10 -0300 Subject: [PATCH 097/109] Move displayForKeyring outside class --- src/KeyringController.ts | 43 +++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index 668e777e..492df21b 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -874,10 +874,7 @@ class KeyringController extends EventEmitter { * Updates the in-memory keyrings, without persisting. */ async #updateMemStoreKeyrings(): Promise { - const keyrings = await Promise.all( - // eslint-disable-next-line @typescript-eslint/unbound-method - this.keyrings.map(this.#displayForKeyring), - ); + const keyrings = await Promise.all(this.keyrings.map(displayForKeyring)); return this.memStore.updateState({ keyrings }); } @@ -964,25 +961,6 @@ class KeyringController extends EventEmitter { ); } - /** - * Display For Keyring - * - * Is used for adding the current keyrings to the state object. - * - * @param keyring - The keyring to display. - * @returns A keyring display object, with type and accounts properties. - */ - async #displayForKeyring( - keyring: Keyring, - ): Promise<{ type: string; accounts: string[] }> { - const accounts = await keyring.getAccounts(); - - return { - type: keyring.type, - accounts: accounts.map(normalizeToHex), - }; - } - /** * Clear Keyrings * @@ -1055,4 +1033,23 @@ function keyringBuilderFactory(Keyring: KeyringClass) { return builder; } +/** + * Display For Keyring + * + * Is used for adding the current keyrings to the state object. + * + * @param keyring - The keyring to display. + * @returns A keyring display object, with type and accounts properties. + */ +async function displayForKeyring( + keyring: Keyring, +): Promise<{ type: string; accounts: string[] }> { + const accounts = await keyring.getAccounts(); + + return { + type: keyring.type, + accounts: accounts.map(normalizeToHex), + }; +} + export { KeyringController, keyringBuilderFactory }; From f7223059576a90ec781090201a3bfe5b53c71a3b Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Tue, 21 Mar 2023 22:09:55 -0300 Subject: [PATCH 098/109] Clean up code --- src/KeyringController.test.ts | 6 +++-- src/KeyringController.ts | 51 +++++++++++++++++++++-------------- src/index.ts | 2 -- src/types.ts | 7 +---- 4 files changed, 36 insertions(+), 30 deletions(-) diff --git a/src/KeyringController.test.ts b/src/KeyringController.test.ts index 39b30d78..f23f25ba 100644 --- a/src/KeyringController.test.ts +++ b/src/KeyringController.test.ts @@ -22,6 +22,8 @@ const MOCK_ENCRYPTION_DATA = `{"data":"2fOOPRKClNrisB+tmqIcETyZvDuL2iIR1Hr1nO7XZ const walletOneSeedWords = 'puzzle seed penalty soldier say clay field arctic metal hen cage runway'; + +const mockAddress = '0xef35ca8ebb9669a35c31b5f6f249a9941a812ac1'; const walletOneAddresses = ['0xef35ca8ebb9669a35c31b5f6f249a9941a812ac1']; const walletOnePrivateKey = [ 'ace918800411c0b96b915f76efbbd4d50e6c997180fee58e01f60d3a412d2f7e', @@ -645,7 +647,7 @@ describe('KeyringController', () => { keyringController, 'getAppKeyAddress', ); - /* eslint-disable-next-line require-atomic-updates */ + keyringController.getKeyringForAccount = sinon .stub() .returns(Promise.resolve(keyring)); @@ -910,7 +912,7 @@ describe('KeyringController', () => { it('signTypedMessage', async () => { const inputParams = { - from: walletOneAddresses[0] as Hex, + from: mockAddress, data: [ { type: 'string', diff --git a/src/KeyringController.ts b/src/KeyringController.ts index 492df21b..78407601 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -19,7 +19,6 @@ import ObservableStore from 'obs-store'; import { KeyringType, KeyringControllerError } from './constants'; import { - MessageParams, SerializedKeyring, KeyringControllerArgs, KeyringControllerState, @@ -447,7 +446,7 @@ class KeyringController extends EventEmitter { */ async signTransaction( ethTx: TypedTransaction, - rawAddress: string | Hex, + rawAddress: string, opts: Record = {}, ): Promise { const address = normalizeToHex(rawAddress); @@ -465,11 +464,16 @@ class KeyringController extends EventEmitter { * Attempts to sign the provided message parameters. * * @param msgParams - The message parameters to sign. + * @param msgParams.from - From address. + * @param msgParams.data - The message to sign. * @param opts - Additional signing options. * @returns The raw signature. */ async signMessage( - msgParams: MessageParams, + msgParams: { + from: string; + data: string; + }, opts: Record = {}, ): Promise { const address = normalizeToHex(msgParams.from); @@ -478,7 +482,7 @@ class KeyringController extends EventEmitter { throw new Error(KeyringControllerError.UnsupportedSignMessage); } - return await keyring.signMessage(address, msgParams.data as string, opts); + return await keyring.signMessage(address, msgParams.data, opts); } /** @@ -488,11 +492,16 @@ class KeyringController extends EventEmitter { * Prefixes the hash before signing per the personal sign expectation. * * @param msgParams - The message parameters to sign. + * @param msgParams.from - From address. + * @param msgParams.data - The message to sign. * @param opts - Additional signing options. * @returns The raw signature. */ async signPersonalMessage( - msgParams: MessageParams, + msgParams: { + from: string; + data: string; + }, opts: Record = {}, ): Promise { const address = normalizeToHex(msgParams.from); @@ -501,10 +510,6 @@ class KeyringController extends EventEmitter { throw new Error(KeyringControllerError.UnsupportedSignPersonalMessage); } - if (typeof msgParams.data !== 'string') { - throw new Error(KeyringControllerError.DataType); - } - const normalizedData = normalizeToHex(msgParams.data); return await keyring.signPersonalMessage(address, normalizedData, opts); @@ -538,19 +543,21 @@ class KeyringController extends EventEmitter { * Attempts to decrypt the provided message parameters. * * @param msgParams - The decryption message parameters. + * @param msgParams.from - The address of the account you want to use to decrypt the message. + * @param msgParams.data - The encrypted data that you want to decrypt. * @returns The raw decryption result. */ - async decryptMessage(msgParams: MessageParams): Promise { + async decryptMessage(msgParams: { + from: string; + data: Eip1024EncryptedData; + }): Promise { const address = normalizeToHex(msgParams.from); const keyring = await this.getKeyringForAccount(address); if (!keyring.decryptMessage) { throw new Error(KeyringControllerError.UnsupportedDecryptMessage); } - return keyring.decryptMessage( - address, - msgParams.data as Eip1024EncryptedData, - ); + return keyring.decryptMessage(address, msgParams.data); } /** @@ -558,11 +565,16 @@ class KeyringController extends EventEmitter { * * @see {@link https://github.com/ethereum/EIPs/pull/712#issuecomment-329988454|EIP712}. * @param msgParams - The message parameters to sign. + * @param msgParams.from - From address. + * @param msgParams.data - The data to sign. * @param opts - Additional signing options. * @returns The raw signature. */ async signTypedMessage( - msgParams: MessageParams, + msgParams: { + from: string; + data: Record[]; + }, opts = { version: 'V1' }, ): Promise { const address = normalizeToHex(msgParams.from); @@ -571,11 +583,10 @@ class KeyringController extends EventEmitter { throw new Error(KeyringControllerError.UnsupportedSignTypedMessage); } - return keyring.signTypedData( - address, - msgParams.data as Eip1024EncryptedData, - opts, - ); + // Looks like this is not well defined in the Keyring interface since + // our tests show that we should be able to pass an array. + // @ts-expect-error Missing other required permission types. + return keyring.signTypedData(address, msgParams.data, opts); } /** diff --git a/src/index.ts b/src/index.ts index bcbfbfe4..68943618 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,3 @@ export { KeyringController, keyringBuilderFactory } from './KeyringController'; export { KeyringType, KeyringControllerError } from './constants'; - -export type { MessageParams } from './types'; diff --git a/src/types.ts b/src/types.ts index ab1cc60b..1875880b 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,9 +1,4 @@ -import type { Hex, Json, Keyring, Eip1024EncryptedData } from '@metamask/utils'; - -export type MessageParams = { - from: Hex | string; - data: Hex | string | Eip1024EncryptedData | Record[]; -}; +import type { Json, Keyring } from '@metamask/utils'; export type KeyringControllerArgs = { keyringBuilders: From 3edc176ead8370c5a9632db13c2e2367df019cea Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed, 22 Mar 2023 23:30:14 -0300 Subject: [PATCH 099/109] Update @metamask/eth-sig-util type file --- types/@metamask/eth-sig-util.d.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/types/@metamask/eth-sig-util.d.ts b/types/@metamask/eth-sig-util.d.ts index 63e2eb0f..a3d38c39 100644 --- a/types/@metamask/eth-sig-util.d.ts +++ b/types/@metamask/eth-sig-util.d.ts @@ -1,7 +1,2 @@ // eslint-disable-next-line import/unambiguous -declare module '@metamask/eth-sig-util' { - import { Hex } from '@metamask/utils'; - - function normalize(address: string | Hex): Hex; - export { normalize }; -} +declare module '@metamask/eth-sig-util'; From 10bb8c842d7fb49aefabfecb2f2d54bb88983ef7 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed, 22 Mar 2023 23:31:01 -0300 Subject: [PATCH 100/109] Validate that data is Json in newKeyring method --- src/KeyringController.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index 78407601..4fe60546 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -3,7 +3,7 @@ import * as encryptorUtils from '@metamask/browser-passworder'; import HDKeyring from '@metamask/eth-hd-keyring'; import { normalize as normalizeToHex } from '@metamask/eth-sig-util'; import SimpleKeyring from '@metamask/eth-simple-keyring'; -import { remove0x } from '@metamask/utils'; +import { remove0x, isValidJson } from '@metamask/utils'; import type { Hex, Json, @@ -1018,7 +1018,11 @@ class KeyringController extends EventEmitter { const keyring = keyringBuilder(); - await keyring.deserialize(data as Json); + if (!isValidJson(data)) { + throw new Error(KeyringControllerError.DataType); + } + + await keyring.deserialize(data); if (keyring.init) { await keyring.init(); From a34434283fb67a978690bc320f698a20db2b8e77 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed, 22 Mar 2023 23:31:20 -0300 Subject: [PATCH 101/109] Console.error in restoreKeyring --- src/KeyringController.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index 4fe60546..e8db4440 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -938,8 +938,9 @@ class KeyringController extends EventEmitter { let keyring: Keyring | undefined; try { keyring = await this.#newKeyring(type, data); - } catch { - // Error + } catch (error) { + // Ignore error. + console.error(error); } if (!keyring) { From 1c76cf097f7f149317c38b6029e5f1c2a4e1d9d0 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed, 22 Mar 2023 23:31:52 -0300 Subject: [PATCH 102/109] Remove unnecessary comment --- src/KeyringController.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index e8db4440..306dba65 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -619,10 +619,6 @@ class KeyringController extends EventEmitter { ): Promise { const address = normalizeToHex(rawAddress); const keyring = await this.getKeyringForAccount(address); - // The "in" operator is typically restricted because it also checks inherited properties, - // which can be unexpected for plain objects. We're allowing it here because `keyring` is not - // a plain object, and we explicitly want to include inherited methods in this check. - // eslint-disable-next-line no-restricted-syntax if (!keyring.exportAccount) { throw new Error(KeyringControllerError.UnsupportedExportAppKeyForAddress); } From c87885c11a1bd0e716d1dccde1cf0afe3c5e3498 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed, 22 Mar 2023 23:32:16 -0300 Subject: [PATCH 103/109] Refactor removeAccount method --- src/KeyringController.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index 306dba65..edae029c 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -413,12 +413,11 @@ class KeyringController extends EventEmitter { const keyring = await this.getKeyringForAccount(address); // Not all the keyrings support this, so we have to check - if (typeof keyring.removeAccount === 'function') { - keyring.removeAccount(address); - this.emit('removedAccount', address); - } else { + if (!keyring.removeAccount) { throw new Error(KeyringControllerError.UnsupportedRemoveAccount); } + keyring.removeAccount(address); + this.emit('removedAccount', address); const accounts = await keyring.getAccounts(); // Check if this was the last/only account From ee755fd7534dfcd5417407b1b7bf30d31b8ce9d1 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed, 22 Mar 2023 23:32:34 -0300 Subject: [PATCH 104/109] Change data type from Hex to string --- src/KeyringController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index edae029c..8eb9fdd6 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -391,7 +391,7 @@ class KeyringController extends EventEmitter { * @param address - The address of the account to export. * @returns The private key of the account. */ - async exportAccount(address: Hex): Promise { + async exportAccount(address: string): Promise { const keyring = await this.getKeyringForAccount(address); if (!keyring.exportAccount) { throw new Error(KeyringControllerError.UnsupportedExportAccount); From c7afbff7b11414ab7c55fddf9b8cac218915430d Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed, 22 Mar 2023 23:33:14 -0300 Subject: [PATCH 105/109] Change data type from Hex to string --- src/KeyringController.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index 8eb9fdd6..c983c3b1 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -416,8 +416,8 @@ class KeyringController extends EventEmitter { if (!keyring.removeAccount) { throw new Error(KeyringControllerError.UnsupportedRemoveAccount); } - keyring.removeAccount(address); - this.emit('removedAccount', address); + keyring.removeAccount(address); + this.emit('removedAccount', address); const accounts = await keyring.getAccounts(); // Check if this was the last/only account From ee12163285929294b7962546377c5489e107e220 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed, 22 Mar 2023 23:56:00 -0300 Subject: [PATCH 106/109] Update test name --- src/KeyringController.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/KeyringController.test.ts b/src/KeyringController.test.ts index f23f25ba..f204ceff 100644 --- a/src/KeyringController.test.ts +++ b/src/KeyringController.test.ts @@ -577,7 +577,7 @@ describe('KeyringController', () => { ); }); - it('add serialized keyring to _unsupportedKeyrings array if keyring type is not known', async () => { + it('add serialized keyring to unsupportedKeyrings array if keyring type is not known', async () => { const unsupportedKeyrings = [{ type: 'Ledger Keyring', data: 'DUMMY' }]; mockEncryptor.encrypt(PASSWORD, unsupportedKeyrings); await keyringController.setLocked(); From 1ae48d3ea56aff3eb4c60f0c49d11c6675bb0cc0 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed, 22 Mar 2023 23:56:13 -0300 Subject: [PATCH 107/109] Sort methods --- src/KeyringController.ts | 70 ++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index c983c3b1..bcb1e1b6 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -178,7 +178,7 @@ class KeyringController extends EventEmitter { // remove keyrings this.keyrings = []; - await this.#updateMemStoreKeyrings(); + await this.updateMemStoreKeyrings(); this.emit('lock'); return this.#fullUpdate(); } @@ -429,6 +429,35 @@ class KeyringController extends EventEmitter { return this.#fullUpdate(); } + /** + * Get Keyring Class For Type + * + * Searches the current `keyringBuilders` array + * for a Keyring builder whose unique `type` property + * matches the provided `type`, + * returning it if it exists. + * + * @param type - The type whose class to get. + * @returns The class, if it exists. + */ + getKeyringBuilderForType( + type: string, + ): { (): Keyring; type: string } | undefined { + return this.keyringBuilders.find( + (keyringBuilder) => keyringBuilder.type === type, + ); + } + + /** + * Update memStore Keyrings + * + * Updates the in-memory keyrings, without persisting. + */ + async updateMemStoreKeyrings(): Promise { + const keyrings = await Promise.all(this.keyrings.map(displayForKeyring)); + return this.memStore.updateState({ keyrings }); + } + // ============================== // === Public Signing Methods === // ============================== @@ -639,7 +668,7 @@ class KeyringController extends EventEmitter { ): Promise | undefined> { const keyring = await this.#restoreKeyring(serialized); if (keyring) { - await this.#updateMemStoreKeyrings(); + await this.updateMemStoreKeyrings(); } return keyring; } @@ -722,9 +751,9 @@ class KeyringController extends EventEmitter { // The keyring updates need to be announced before updating the encryptionKey // so that the updated keyring gets propagated to the extension first. - // Not calling {@link #updateMemStoreKeyrings} results in the wrong account being selected + // Not calling {@link updateMemStoreKeyrings} results in the wrong account being selected // in the extension. - await this.#updateMemStoreKeyrings(); + await this.updateMemStoreKeyrings(); if (newEncryptionKey) { this.memStore.updateState({ encryptionKey: newEncryptionKey, @@ -804,7 +833,7 @@ class KeyringController extends EventEmitter { } await Promise.all(vault.map(this.#restoreKeyring.bind(this))); - await this.#updateMemStoreKeyrings(); + await this.updateMemStoreKeyrings(); return this.keyrings; } @@ -874,16 +903,6 @@ class KeyringController extends EventEmitter { // === Private Methods === // ======================= - /** - * Update memStore Keyrings - * - * Updates the in-memory keyrings, without persisting. - */ - async #updateMemStoreKeyrings(): Promise { - const keyrings = await Promise.all(this.keyrings.map(displayForKeyring)); - return this.memStore.updateState({ keyrings }); - } - /** * Create First Key Tree. * @@ -949,25 +968,6 @@ class KeyringController extends EventEmitter { return keyring; } - /** - * Get Keyring Class For Type - * - * Searches the current `keyringBuilders` array - * for a Keyring builder whose unique `type` property - * matches the provided `type`, - * returning it if it exists. - * - * @param type - The type whose class to get. - * @returns The class, if it exists. - */ - #getKeyringBuilderForType( - type: string, - ): { (): Keyring; type: string } | undefined { - return this.keyringBuilders.find( - (keyringBuilder) => keyringBuilder.type === type, - ); - } - /** * Clear Keyrings * @@ -1004,7 +1004,7 @@ class KeyringController extends EventEmitter { * @returns The new keyring. */ async #newKeyring(type: string, data: unknown): Promise> { - const keyringBuilder = this.#getKeyringBuilderForType(type); + const keyringBuilder = this.getKeyringBuilderForType(type); if (!keyringBuilder) { throw new Error( From ea8dda7f47aacd16506db8eb5a8f5e3d55d7d25a Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Fri, 24 Mar 2023 18:34:43 -0300 Subject: [PATCH 108/109] Sort methods --- src/KeyringController.ts | 386 ++++++++++++++++++++------------------- src/types.ts | 7 + 2 files changed, 206 insertions(+), 187 deletions(-) diff --git a/src/KeyringController.ts b/src/KeyringController.ts index bcb1e1b6..c01efc0b 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -92,9 +92,11 @@ class KeyringController extends EventEmitter { return this.memStore.getState(); } - // ====================== - // === Public Methods === - // ====================== + /** + * ======================================= + * === Public Vault Management Methods === + * ======================================= + */ /** * Create New Vault And Keychain @@ -146,10 +148,6 @@ class KeyringController extends EventEmitter { numberOfAccounts: 1, }); - if (!keyring) { - throw new Error(KeyringControllerError.NoKeyring); - } - const [firstAccount] = await keyring.getAccounts(); if (!firstAccount) { @@ -160,7 +158,7 @@ class KeyringController extends EventEmitter { } /** - * Set Locked + * Set Locked. * This method deallocates all secrets, and effectively locks MetaMask. * * @fires KeyringController#lock @@ -244,120 +242,10 @@ class KeyringController extends EventEmitter { } /** - * Add New Keyring - * - * Adds a new Keyring of the given `type` to the vault - * and the current decrypted Keyrings array. - * - * All Keyring classes implement a unique `type` string, - * and this is used to retrieve them from the keyringBuilders array. - * - * @param type - The type of keyring to add. - * @param opts - The constructor options for the keyring. - * @returns The new keyring. - */ - async addNewKeyring( - type: string, - opts: Record = {}, - ): Promise> { - let keyring: Keyring; - switch (type) { - case KeyringType.Simple: - keyring = await this.#newKeyring(type, opts.privateKeys); - break; - default: - keyring = await this.#newKeyring(type, opts); - break; - } - - if (!keyring) { - throw new Error(KeyringControllerError.NoKeyring); - } - - if (!opts.mnemonic && type === KeyringType.HD) { - if (!keyring.generateRandomMnemonic) { - throw new Error( - KeyringControllerError.UnsupportedGenerateRandomMnemonic, - ); - } - - keyring.generateRandomMnemonic(); - await keyring.addAccounts(1); - } - - const accounts = await keyring.getAccounts(); - await this.checkForDuplicate(type, accounts); - - this.keyrings.push(keyring); - await this.persistAllKeyrings(); - - this.#fullUpdate(); - - return keyring; - } - - /** - * Remove empty keyrings. - * - * Loops through the keyrings and removes the ones with empty accounts - * (usually after removing the last / only account) from a keyring. - */ - async removeEmptyKeyrings(): Promise { - const validKeyrings: Keyring[] = []; - - // Since getAccounts returns a Promise - // We need to wait to hear back form each keyring - // in order to decide which ones are now valid (accounts.length > 0) - - await Promise.all( - this.keyrings.map(async (keyring: Keyring) => { - const accounts = await keyring.getAccounts(); - if (accounts.length > 0) { - validKeyrings.push(keyring); - } - }), - ); - this.keyrings = validKeyrings; - } - - /** - * Checks for duplicate keypairs, using the the first account in the given - * array. Rejects if a duplicate is found. - * - * Only supports 'Simple Key Pair'. - * - * @param type - The key pair type to check for. - * @param newAccountArray - Array of new accounts. - * @returns The account, if no duplicate is found. + * ========================================= + * === Public Account Management Methods === + * ========================================= */ - async checkForDuplicate( - type: string, - newAccountArray: string[], - ): Promise { - const accounts = await this.getAccounts(); - - switch (type) { - case KeyringType.Simple: { - const isIncluded = Boolean( - accounts.find( - (key) => - newAccountArray[0] && - (key === newAccountArray[0] || - key === remove0x(newAccountArray[0])), - ), - ); - - if (isIncluded) { - throw new Error(KeyringControllerError.DuplicatedAccount); - } - return newAccountArray; - } - - default: { - return newAccountArray; - } - } - } /** * Add New Account. @@ -429,6 +317,27 @@ class KeyringController extends EventEmitter { return this.#fullUpdate(); } + /** + * Get Accounts + * + * Returns the public addresses of all current accounts + * managed by all currently unlocked keyrings. + * + * @returns The array of accounts. + */ + async getAccounts(): Promise { + const keyrings = this.keyrings || []; + + const keyringArrays = await Promise.all( + keyrings.map(async (keyring) => keyring.getAccounts()), + ); + const addresses = keyringArrays.reduce((res, arr) => { + return res.concat(arr); + }, []); + + return addresses.map(normalizeToHex); + } + /** * Get Keyring Class For Type * @@ -458,9 +367,11 @@ class KeyringController extends EventEmitter { return this.memStore.updateState({ keyrings }); } - // ============================== - // === Public Signing Methods === - // ============================== + /** + * =========================================== + * === Public RPC Requests Routing Methods === + * =========================================== + */ /** * Sign Ethereum Transaction @@ -603,7 +514,7 @@ class KeyringController extends EventEmitter { from: string; data: Record[]; }, - opts = { version: 'V1' }, + opts: Record = { version: 'V1' }, ): Promise { const address = normalizeToHex(msgParams.from); const keyring = await this.getKeyringForAccount(address); @@ -653,6 +564,169 @@ class KeyringController extends EventEmitter { return keyring.exportAccount(address, { withAppKeyOrigin: origin }); } + /** + * ========================================= + * === Public Keyring Management Methods === + * ========================================= + */ + + /** + * Add New Keyring + * + * Adds a new Keyring of the given `type` to the vault + * and the current decrypted Keyrings array. + * + * All Keyring classes implement a unique `type` string, + * and this is used to retrieve them from the keyringBuilders array. + * + * @param type - The type of keyring to add. + * @param opts - The constructor options for the keyring. + * @returns The new keyring. + */ + async addNewKeyring( + type: string, + opts: Record = {}, + ): Promise> { + let keyring: Keyring; + switch (type) { + case KeyringType.Simple: + keyring = await this.#newKeyring(type, opts.privateKeys); + break; + default: + keyring = await this.#newKeyring(type, opts); + break; + } + + if (!keyring) { + throw new Error(KeyringControllerError.NoKeyring); + } + + if (!opts.mnemonic && type === KeyringType.HD) { + if (!keyring.generateRandomMnemonic) { + throw new Error( + KeyringControllerError.UnsupportedGenerateRandomMnemonic, + ); + } + + keyring.generateRandomMnemonic(); + await keyring.addAccounts(1); + } + + const accounts = await keyring.getAccounts(); + await this.checkForDuplicate(type, accounts); + + this.keyrings.push(keyring); + await this.persistAllKeyrings(); + + this.#fullUpdate(); + + return keyring; + } + + /** + * Remove empty keyrings. + * + * Loops through the keyrings and removes the ones with empty accounts + * (usually after removing the last / only account) from a keyring. + */ + async removeEmptyKeyrings(): Promise { + const validKeyrings: Keyring[] = []; + + // Since getAccounts returns a Promise + // We need to wait to hear back form each keyring + // in order to decide which ones are now valid (accounts.length > 0) + + await Promise.all( + this.keyrings.map(async (keyring: Keyring) => { + const accounts = await keyring.getAccounts(); + if (accounts.length > 0) { + validKeyrings.push(keyring); + } + }), + ); + this.keyrings = validKeyrings; + } + + /** + * Checks for duplicate keypairs, using the the first account in the given + * array. Rejects if a duplicate is found. + * + * Only supports 'Simple Key Pair'. + * + * @param type - The key pair type to check for. + * @param newAccountArray - Array of new accounts. + * @returns The account, if no duplicate is found. + */ + async checkForDuplicate( + type: string, + newAccountArray: string[], + ): Promise { + const accounts = await this.getAccounts(); + + switch (type) { + case KeyringType.Simple: { + const isIncluded = Boolean( + accounts.find( + (key) => + newAccountArray[0] && + (key === newAccountArray[0] || + key === remove0x(newAccountArray[0])), + ), + ); + + if (isIncluded) { + throw new Error(KeyringControllerError.DuplicatedAccount); + } + return newAccountArray; + } + + default: { + return newAccountArray; + } + } + } + + /** + * Get Keyring For Account + * + * Returns the currently initialized keyring that manages + * the specified `address` if one exists. + * + * @param address - An account address. + * @returns The keyring of the account, if it exists. + */ + async getKeyringForAccount(address: string): Promise> { + const hexed = normalizeToHex(address); + + const candidates = await Promise.all( + this.keyrings.map(async (keyring) => { + return Promise.all([keyring, keyring.getAccounts()]); + }), + ); + + const winners = candidates.filter((candidate) => { + const accounts = candidate[1].map(normalizeToHex); + return accounts.includes(hexed); + }); + + if (winners.length && winners[0]?.length) { + return winners[0][0]; + } + + // Adding more info to the error + let errorInfo = ''; + if (!address) { + errorInfo = 'The address passed in is invalid/empty'; + } else if (!candidates.length) { + errorInfo = 'There are no keyrings'; + } else if (!winners.length) { + errorInfo = 'There are keyrings, but none match the address'; + } + throw new Error( + `${KeyringControllerError.NoKeyring}. Error info: ${errorInfo}`, + ); + } + /** * Restore Keyring * @@ -837,68 +911,6 @@ class KeyringController extends EventEmitter { return this.keyrings; } - /** - * Get Accounts - * - * Returns the public addresses of all current accounts - * managed by all currently unlocked keyrings. - * - * @returns The array of accounts. - */ - async getAccounts(): Promise { - const keyrings = this.keyrings || []; - - const keyringArrays = await Promise.all( - keyrings.map(async (keyring) => keyring.getAccounts()), - ); - const addresses = keyringArrays.reduce((res, arr) => { - return res.concat(arr); - }, []); - - return addresses.map(normalizeToHex); - } - - /** - * Get Keyring For Account - * - * Returns the currently initialized keyring that manages - * the specified `address` if one exists. - * - * @param address - An account address. - * @returns The keyring of the account, if it exists. - */ - async getKeyringForAccount(address: string): Promise> { - const hexed = normalizeToHex(address); - - const candidates = await Promise.all( - this.keyrings.map(async (keyring) => { - return Promise.all([keyring, keyring.getAccounts()]); - }), - ); - - const winners = candidates.filter((candidate) => { - const accounts = candidate[1].map(normalizeToHex); - return accounts.includes(hexed); - }); - - if (winners.length && winners[0]?.length) { - return winners[0][0]; - } - - // Adding more info to the error - let errorInfo = ''; - if (!address) { - errorInfo = 'The address passed in is invalid/empty'; - } else if (!candidates.length) { - errorInfo = 'There are no keyrings'; - } else if (!winners.length) { - errorInfo = 'There are keyrings, but none match the address'; - } - throw new Error( - `${KeyringControllerError.NoKeyring}. Error info: ${errorInfo}`, - ); - } - // ======================= // === Private Methods === // ======================= diff --git a/src/types.ts b/src/types.ts index 1875880b..e3b9f8c9 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,4 +1,5 @@ import type { Json, Keyring } from '@metamask/utils'; +import ObservableStore from 'obs-store'; export type KeyringControllerArgs = { keyringBuilders: @@ -11,6 +12,12 @@ export type KeyringControllerArgs = { }; export type KeyringControllerState = { + keyringBuilders?: { (): Keyring; type: string }[]; + + store?: typeof ObservableStore; + + memStore?: typeof ObservableStore; + keyrings?: Keyring[]; vaultUnlock?: boolean; From 977facf11c37f5418c5303954037d7ecf125b734 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Mon, 27 Mar 2023 18:53:39 -0300 Subject: [PATCH 109/109] Improve data types in test suite --- src/KeyringController.test.ts | 65 +++++++++++++++++++---------------- src/KeyringController.ts | 14 +++++--- src/test/keyring.mock.ts | 25 +++++++++++--- 3 files changed, 65 insertions(+), 39 deletions(-) diff --git a/src/KeyringController.test.ts b/src/KeyringController.test.ts index f204ceff..cff79bfd 100644 --- a/src/KeyringController.test.ts +++ b/src/KeyringController.test.ts @@ -1,6 +1,6 @@ import HdKeyring from '@metamask/eth-hd-keyring'; import { normalize as normalizeAddress } from '@metamask/eth-sig-util'; -import type { Hex, Json, Keyring, KeyringClass } from '@metamask/utils'; +import type { Hex } from '@metamask/utils'; import { strict as assert } from 'assert'; import Wallet from 'ethereumjs-wallet'; import * as sinon from 'sinon'; @@ -44,11 +44,7 @@ describe('KeyringController', () => { keyringController = new KeyringController({ encryptor: mockEncryptor, cacheEncryptionKey: false, - keyringBuilders: [ - keyringBuilderFactory( - KeyringMockWithInit as unknown as KeyringClass, - ), - ], + keyringBuilders: [keyringBuilderFactory(KeyringMockWithInit)], }); await keyringController.createNewVaultAndKeychain(PASSWORD); @@ -454,7 +450,8 @@ describe('KeyringController', () => { const keyring = await keyringController.restoreKeyring(mockSerialized); // eslint-disable-next-line no-unsafe-optional-chaining - const { numberOfAccounts } = (await keyring?.serialize()) as any; + // @ts-expect-error this value should never be undefined in this specific context. + const { numberOfAccounts } = await keyring.serialize(); expect(numberOfAccounts).toBe(1); const accounts = await keyring?.getAccounts(); @@ -474,15 +471,17 @@ describe('KeyringController', () => { it('returns the result of getAccounts for each keyring', async () => { keyringController.keyrings = [ { + // @ts-expect-error there's only a need to mock the getAccounts method for this test. async getAccounts() { return Promise.resolve([1, 2, 3]); }, - } as unknown as Keyring, + }, { + // @ts-expect-error there's only a need to mock the getAccounts method for this test. async getAccounts() { return Promise.resolve([4, 5, 6]); }, - } as unknown as Keyring, + }, ]; const result = await keyringController.getAccounts(); @@ -499,7 +498,7 @@ describe('KeyringController', () => { describe('removeAccount', () => { it('removes an account from the corresponding keyring', async () => { - const account = { + const account: { privateKey: string; publicKey: Hex } = { privateKey: 'c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3', publicKey: '0x627306090abab3a6e1400e9345bc60c78a8bef57', @@ -514,7 +513,7 @@ describe('KeyringController', () => { expect(keyringController.keyrings).toHaveLength(2); // remove that account that we just added - await keyringController.removeAccount(account.publicKey as Hex); + await keyringController.removeAccount(account.publicKey); expect(keyringController.keyrings).toHaveLength(1); // fetch accounts after removal @@ -523,7 +522,7 @@ describe('KeyringController', () => { }); it('removes the keyring if there are no accounts after removal', async () => { - const account = { + const account: { privateKey: string; publicKey: Hex } = { privateKey: 'c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3', publicKey: '0x627306090abab3a6e1400e9345bc60c78a8bef57', @@ -538,7 +537,7 @@ describe('KeyringController', () => { expect(keyringController.keyrings).toHaveLength(2); // remove that account that we just added - await keyringController.removeAccount(account.publicKey as Hex); + await keyringController.removeAccount(account.publicKey); // Check that the previous keyring with only one account // was also removed after removing the account @@ -556,7 +555,8 @@ describe('KeyringController', () => { expect(keyringController.keyrings).toHaveLength(2); // remove one account from the keyring we just added - await keyringController.removeAccount(walletTwoAddresses[0] as Hex); + // @ts-expect-error this value should never be undefied + await keyringController.removeAccount(walletTwoAddresses[0]); // Check that the newly added keyring was not removed after // removing the account since it still has an account left @@ -571,7 +571,8 @@ describe('KeyringController', () => { expect(keyrings).toHaveLength(1); await Promise.all( keyrings.map(async (keyring) => { - const { numberOfAccounts } = (await keyring.serialize()) as any; + // @ts-expect-error numberOfAccounts mising in Json specification. + const { numberOfAccounts } = await keyring.serialize(); expect(numberOfAccounts).toBe(1); }), ); @@ -592,11 +593,7 @@ describe('KeyringController', () => { describe('verifyPassword', () => { beforeEach(() => { keyringController = new KeyringController({ - keyringBuilders: [ - keyringBuilderFactory( - KeyringMockWithInit as unknown as KeyringClass, - ), - ], + keyringBuilders: [keyringBuilderFactory(KeyringMockWithInit)], encryptor: mockEncryptor, cacheEncryptionKey: false, }); @@ -626,7 +623,8 @@ describe('KeyringController', () => { const initialAccounts = await HDKeyring?.getAccounts(); expect(initialAccounts).toHaveLength(1); - await keyringController.addNewAccount(HDKeyring as Keyring); + // @ts-expect-error this value should never be undefined in this specific context. + await keyringController.addNewAccount(HDKeyring); const accountsAfterAdd = await HDKeyring?.getAccounts(); expect(accountsAfterAdd).toHaveLength(2); }); @@ -718,10 +716,11 @@ describe('KeyringController', () => { it('throws error when there are no matching keyrings', async () => { keyringController.keyrings = [ { + // @ts-expect-error there's only a need to mock the getAccounts method for this test. async getAccounts() { return Promise.resolve([1, 2, 3]); }, - } as unknown as Keyring, + }, ]; await expect( @@ -808,13 +807,15 @@ describe('KeyringController', () => { const [firstKeyring] = keyringController.keyrings; - await keyringController.addNewAccount(firstKeyring as Keyring); + // @ts-expect-error this value should never be undefined in this specific context. + await keyringController.addNewAccount(firstKeyring); expect(await keyringController.getAccounts()).toHaveLength(2); - await keyringController.addNewAccount(firstKeyring as Keyring); + // @ts-expect-error this value should never be undefined in this specific context. + await keyringController.addNewAccount(firstKeyring); expect(await keyringController.getAccounts()).toHaveLength(3); - const account = { + const account: { privateKey: string; publicKey: Hex } = { privateKey: 'c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3', publicKey: '0x627306090abab3a6e1400e9345bc60c78a8bef57', @@ -827,7 +828,7 @@ describe('KeyringController', () => { expect(await keyringController.getAccounts()).toHaveLength(4); // remove that account that we just added - await keyringController.removeAccount(account.publicKey as Hex); + await keyringController.removeAccount(account.publicKey); expect(await keyringController.getAccounts()).toHaveLength(3); }); @@ -865,7 +866,8 @@ describe('KeyringController', () => { walletOneSeedWords, ); const privateKey = await keyringController.exportAccount( - walletOneAddresses[0] as Hex, + // @ts-expect-error this value should never be undefined in this specific context. + walletOneAddresses[0], ); expect(privateKey).toStrictEqual(walletOnePrivateKey[0]); }); @@ -881,10 +883,11 @@ describe('KeyringController', () => { it('signMessage', async () => { const inputParams = { - from: walletOneAddresses[0] as Hex, + from: walletOneAddresses[0], data: '0x879a053d4800c6354e76c7985a865d2922c82fb5b3f4577b2fe08b998954f2e0', origin: 'https://metamask.github.io', }; + // @ts-expect-error this value should never be undefined in this specific context. const result = await keyringController.signMessage(inputParams); expect(result).toMatchInlineSnapshot( `"0x93e0035090e8144debae03f45c5339a78d24c41e38e810a82dd3387e48353db645bd77716f3b7c4fb1f07f3b97bdbd33b0d7c55f7e7eedf3a678a2081948b67f1c"`, @@ -893,10 +896,11 @@ describe('KeyringController', () => { it('signPersonalMessage', async () => { const inputParams = { - from: walletOneAddresses[0] as Hex, + from: walletOneAddresses[0], data: '0x4578616d706c652060706572736f6e616c5f7369676e60206d657373616765', origin: 'https://metamask.github.io', }; + // @ts-expect-error this value should never be undefined in this specific context. const result = await keyringController.signPersonalMessage(inputParams); expect(result).toBe( '0xfa2e5989b483e1f40a41b306f275b0009bcc07bfe5322c87682145e7d4889a3247182b4bd8138a965a7e37dea9d9b492b6f9f6d01185412f2d80466237b2805e1b', @@ -905,7 +909,8 @@ describe('KeyringController', () => { it('getEncryptionPublicKey', async () => { const result = await keyringController.getEncryptionPublicKey( - walletOneAddresses[0] as Hex, + // @ts-expect-error this value should never be undefined in this specific context. + walletOneAddresses[0], ); expect(result).toBe('SR6bQ1m3OTHvI1FLwcGzm+Uk6hffoFPxsQ0DTOeKMEc='); }); diff --git a/src/KeyringController.ts b/src/KeyringController.ts index c01efc0b..901fe4e9 100644 --- a/src/KeyringController.ts +++ b/src/KeyringController.ts @@ -756,7 +756,11 @@ class KeyringController extends EventEmitter { * @returns Keyrings matching the specified type. */ getKeyringsByType(type: string): Keyring[] { - return this.keyrings.filter((keyring) => keyring.type === type); + const keyrings = this.keyrings.filter((keyring) => keyring.type === type); + if (!keyrings.length) { + throw new Error(KeyringControllerError.NoKeyring); + } + return keyrings; } /** @@ -1045,13 +1049,13 @@ class KeyringController extends EventEmitter { * * Returns a builder function for `Keyring` with a `type` property. * - * @param Keyring - The Keyring class for the builder. + * @param KeyringConstructor - The Keyring class for the builder. * @returns A builder function for the given Keyring. */ -function keyringBuilderFactory(Keyring: KeyringClass) { - const builder = () => new Keyring(); +function keyringBuilderFactory(KeyringConstructor: KeyringClass) { + const builder = () => new KeyringConstructor(); - builder.type = Keyring.type; + builder.type = KeyringConstructor.type; return builder; } diff --git a/src/test/keyring.mock.ts b/src/test/keyring.mock.ts index aafc4ea5..ecf003a3 100644 --- a/src/test/keyring.mock.ts +++ b/src/test/keyring.mock.ts @@ -1,12 +1,29 @@ -class KeyringMockWithInit { - static type = 'Keyring Mock With Init'; +import type { Keyring, Json, Hex } from '@metamask/utils'; + +const TYPE = 'Keyring Mock With Init'; + +class KeyringMockWithInit implements Keyring { + static type = TYPE; + + public type = TYPE; + + #accounts: Hex[] = []; + + constructor(options: Record | undefined = {}) { + // eslint-disable-next-line @typescript-eslint/no-floating-promises, @typescript-eslint/promise-function-async + this.deserialize(options); + } async init() { return Promise.resolve(); } - getAccounts() { - return []; + async addAccounts(_: number): Promise { + return Promise.resolve(this.#accounts); + } + + async getAccounts() { + return Promise.resolve(this.#accounts); } async serialize() {