diff --git a/__tests__/service/keyring.test.ts b/__tests__/service/keyring.test.ts index 3eedeaa9fa9..aa459e01ff6 100644 --- a/__tests__/service/keyring.test.ts +++ b/__tests__/service/keyring.test.ts @@ -4,7 +4,7 @@ import mockEncryptor from './mock-encryptor'; import contactBook from '@/background/service/contactBook'; import { normalizeAddress } from '@/background/utils'; import { Wallet } from '@ethereumjs/wallet'; -import { bytesToHex } from '@ethereumjs/util'; +import { utils } from '@ethereumjs/rlp'; const password = 'password123'; const walletOneSeedWords = @@ -286,7 +286,7 @@ describe('keyringService', () => { ); const wallet = Wallet.fromPrivateKey(Buffer.from(privateAppKey, 'hex')); - const recoveredAddress = bytesToHex(wallet.getAddress()); + const recoveredAddress = utils.bytesToHex(wallet.getAddress()); expect(recoveredAddress).toBe(appKeyAddress); expect(privateAppKey).not.toBe(privateKey); diff --git a/package.json b/package.json index 46f8dfe951d..e97a6a00400 100644 --- a/package.json +++ b/package.json @@ -30,16 +30,17 @@ "@dnd-kit/utilities": "3.0.2", "@eth-optimism/contracts": "0.5.32", "@eth-optimism/contracts-ts": "0.17.2", - "@ethereumjs/common": "2.5.0", - "@ethereumjs/tx": "3.3.2", - "@ethereumjs/util": "9.0.3", + "@ethereumjs/common": "3.1.1", + "@ethereumjs/rlp": "4.0.1", + "@ethereumjs/tx": "4.1.1", + "@ethereumjs/util": "8.0.5", "@ethereumjs/wallet": "2.0.3", "@gnosis.pm/safe-core-sdk": "1.1.1", "@gnosis.pm/safe-core-sdk-types": "0.1.1", "@imkey/web3-provider": "1.3.10", "@keystonehq/hw-app-eth": "0.4.4", "@keystonehq/hw-transport-webusb": "0.3.2", - "@keystonehq/metamask-airgapped-keyring": "0.2.5-alpha.2.1", + "@keystonehq/metamask-airgapped-keyring": "0.14.1", "@ledgerhq/devices": "8.4.4", "@ledgerhq/hw-app-eth": "6.39.0", "@ledgerhq/hw-transport-webhid": "6.29.4", @@ -55,9 +56,9 @@ "@rabby-wallet/eth-coinbase-keyring": "0.0.0-beta.8", "@rabby-wallet/eth-gnosis-keyring": "0.0.1", "@rabby-wallet/eth-hd-keyring": "4.3.2", - "@rabby-wallet/eth-lattice-keyring": "1.2.2", + "@rabby-wallet/eth-lattice-keyring": "1.2.4", "@rabby-wallet/eth-simple-keyring": "5.0.1", - "@rabby-wallet/eth-trezor-keyring": "2.6.1", + "@rabby-wallet/eth-trezor-keyring": "2.6.3", "@rabby-wallet/eth-walletconnect-keyring": "2.1.5", "@rabby-wallet/eth-watch-keyring": "1.0.0", "@rabby-wallet/gnosis-sdk": "1.3.10", diff --git a/src/background/controller/provider/controller.ts b/src/background/controller/provider/controller.ts index a73795588c3..9f3ab8f5925 100644 --- a/src/background/controller/provider/controller.ts +++ b/src/background/controller/provider/controller.ts @@ -1,14 +1,13 @@ import { matomoRequestEvent } from '@/utils/matomo-request'; -import * as Sentry from '@sentry/browser'; -import Common, { Hardfork } from '@ethereumjs/common'; +import { Common, Hardfork } from '@ethereumjs/common'; import { TransactionFactory } from '@ethereumjs/tx'; import { ethers } from 'ethers'; import { - bufferToHex, isHexString, addHexPrefix, intToHex, -} from 'ethereumjs-util'; + bufferToHex, +} from '@ethereumjs/util'; import { stringToHex } from 'web3-utils'; import { ethErrors } from 'eth-rpc-errors'; import { @@ -87,6 +86,13 @@ const reportSignText = (params: { }); }; +const convertToHex = (data: Buffer | bigint) => { + if (typeof data === 'bigint') { + return `0x${data.toString(16)}`; + } + return bufferToHex(data); +}; + interface ApprovalRes extends Tx { type?: string; address?: string; @@ -488,6 +494,7 @@ class ProviderController extends BaseController { opts ); } catch (e) { + console.error(e); const errObj = typeof e === 'object' ? { message: e.message } @@ -540,9 +547,9 @@ class ProviderController extends BaseController { const _rawTx = { ...rawTx, ...approvalRes, - r: bufferToHex(signedTx.r), - s: bufferToHex(signedTx.s), - v: bufferToHex(signedTx.v), + r: convertToHex(signedTx.r), + s: convertToHex(signedTx.s), + v: convertToHex(signedTx.v), }; if (is1559) { delete _rawTx.gasPrice; @@ -659,28 +666,6 @@ class ProviderController extends BaseController { return signedTx; } - const buildTx = TransactionFactory.fromTxData({ - ...approvalRes, - r: addHexPrefix(signedTx.r), - s: addHexPrefix(signedTx.s), - v: addHexPrefix(signedTx.v), - type: is1559 ? '0x2' : '0x0', - }); - - // Report address type(not sensitive information) to sentry when tx signature is invalid - if (!buildTx.verifySignature()) { - if (!buildTx.v) { - Sentry.captureException(new Error(`v missed, ${keyring.type}`)); - } else if (!buildTx.s) { - Sentry.captureException(new Error(`s missed, ${keyring.type}`)); - } else if (!buildTx.r) { - Sentry.captureException(new Error(`r missed, ${keyring.type}`)); - } else { - Sentry.captureException( - new Error(`invalid signature, ${keyring.type}`) - ); - } - } signedTransactionSuccess = true; statsData.signed = true; statsData.signedSuccess = true; @@ -728,9 +713,9 @@ class ProviderController extends BaseController { const res = await openapiService.submitTx({ tx: { ...approvalRes, - r: bufferToHex(signedTx.r), - s: bufferToHex(signedTx.s), - v: bufferToHex(signedTx.v), + r: convertToHex(signedTx.r), + s: convertToHex(signedTx.s), + v: convertToHex(signedTx.v), value: approvalRes.value || '0x0', }, push_type: pushType, diff --git a/src/background/controller/provider/rpcFlow.ts b/src/background/controller/provider/rpcFlow.ts index 49b183d4e3f..0ddeebcbe86 100644 --- a/src/background/controller/provider/rpcFlow.ts +++ b/src/background/controller/provider/rpcFlow.ts @@ -12,7 +12,7 @@ import { resemblesETHAddress } from '@/utils'; import { ProviderRequest } from './type'; import * as Sentry from '@sentry/browser'; import stats from '@/stats'; -import { addHexPrefix, stripHexPrefix } from 'ethereumjs-util'; +import { addHexPrefix, stripHexPrefix } from '@ethereumjs/util'; import { findChain } from '@/utils/chain'; import { waitSignComponentAmounted } from '@/utils/signEvent'; import { gnosisController } from './gnosisController'; diff --git a/src/background/controller/wallet.ts b/src/background/controller/wallet.ts index d4ce9e39e5d..5a48c19e62e 100644 --- a/src/background/controller/wallet.ts +++ b/src/background/controller/wallet.ts @@ -1,4 +1,9 @@ -import * as ethUtil from 'ethereumjs-util'; +import { + stripHexPrefix, + isValidPrivate, + addHexPrefix, + toChecksumAddress, +} from '@ethereumjs/util'; import { ethErrors } from 'eth-rpc-errors'; import { ethers, Contract } from 'ethers'; import { groupBy, isEqual, sortBy, truncate, uniq } from 'lodash'; @@ -80,11 +85,6 @@ import stats from '@/stats'; import { generateAliasName } from '@/utils/account'; import BigNumber from 'bignumber.js'; import * as Sentry from '@sentry/browser'; -import { - addHexPrefix, - unpadHexString, - toChecksumAddress, -} from 'ethereumjs-util'; import PQueue from 'p-queue'; import { ProviderRequest } from './provider/type'; import { QuoteResult } from '@rabby-wallet/rabby-swap/dist/quote'; @@ -305,11 +305,9 @@ export class WalletController extends BaseController { params.to = to; delete params.data; params.value = addHexPrefix( - unpadHexString( - ((abiCoder as unknown) as AbiCoder).encodeParameter( - 'uint256', - rawAmount - ) + ((abiCoder as unknown) as AbiCoder).encodeParameter( + 'uint256', + rawAmount ) ); } @@ -2984,12 +2982,12 @@ export class WalletController extends BaseController { }; validatePrivateKey = async (data: string) => { - const privateKey = ethUtil.stripHexPrefix(data); + const privateKey = stripHexPrefix(data); const buffer = Buffer.from(privateKey, 'hex'); const error = new Error(t('background.error.invalidPrivateKey')); try { - if (!ethUtil.isValidPrivate(buffer)) { + if (!isValidPrivate(buffer)) { throw error; } } catch { @@ -2998,12 +2996,12 @@ export class WalletController extends BaseController { }; importPrivateKey = async (data) => { - const privateKey = ethUtil.stripHexPrefix(data); + const privateKey = stripHexPrefix(data); const buffer = Buffer.from(privateKey, 'hex'); const error = new Error(t('background.error.invalidPrivateKey')); try { - if (!ethUtil.isValidPrivate(buffer)) { + if (!isValidPrivate(buffer)) { throw error; } } catch { @@ -3033,7 +3031,7 @@ export class WalletController extends BaseController { const privateKey = wallet.getPrivateKeyString(); const keyring = await keyringService.importPrivateKey( - ethUtil.stripHexPrefix(privateKey) + stripHexPrefix(privateKey) ); return this._setCurrentAccountFromKeyring(keyring); }; @@ -3698,7 +3696,7 @@ export class WalletController extends BaseController { options?: any; }) => { if (data.startsWith('0x')) { - const stripped = ethUtil.stripHexPrefix(data); + const stripped = stripHexPrefix(data); const buff = Buffer.from(stripped, 'hex'); data = JSON.parse(buff.toString('utf8')); } else { diff --git a/src/background/service/customTestnet.ts b/src/background/service/customTestnet.ts index b213151c270..3e6e6f80bf2 100644 --- a/src/background/service/customTestnet.ts +++ b/src/background/service/customTestnet.ts @@ -4,7 +4,7 @@ import { CHAINS_ENUM } from '@debank/common'; import { GasLevel, Tx } from 'background/service/openapi'; import { createPersistStore, withTimeout } from 'background/utils'; import { BigNumber } from 'bignumber.js'; -import { intToHex } from 'ethereumjs-util'; +import { intToHex } from '@ethereumjs/util'; import { omitBy, sortBy } from 'lodash'; import { createClient, defineChain, erc20Abi, http, isAddress } from 'viem'; import { diff --git a/src/background/service/keyring/eth-bitbox02-keyring/eth-bitbox02-keyring.ts b/src/background/service/keyring/eth-bitbox02-keyring/eth-bitbox02-keyring.ts index b19dcc8221d..9e0a63cd1fc 100644 --- a/src/background/service/keyring/eth-bitbox02-keyring/eth-bitbox02-keyring.ts +++ b/src/background/service/keyring/eth-bitbox02-keyring/eth-bitbox02-keyring.ts @@ -1,17 +1,18 @@ import 'regenerator-runtime/runtime'; import EventEmitter from 'events'; import * as ethUtil from 'ethereumjs-util'; +import { toChecksumAddress } from '@ethereumjs/util'; import * as sigUtil from '@metamask/eth-sig-util'; import { TypedTransaction, FeeMarketEIP1559Transaction, - Transaction, JsonTx, TransactionFactory, AccessListEIP2930Transaction, + Transaction, } from '@ethereumjs/tx'; -import { EVENTS } from '@/constant'; import { BitBox02BridgeInterface } from './bitbox02-bridge-interface'; +import { bufferToHex } from '@ethereumjs/util'; const hdPathString = "m/44'/60'/0'/0"; const keyringType = 'BitBox02 Hardware'; @@ -127,7 +128,7 @@ class BitBox02Keyring extends EventEmitter { balance: null, index: i + 1, }); - this.paths[ethUtil.toChecksumAddress(address)] = i; + this.paths[toChecksumAddress(address)] = i; } return accounts; } @@ -148,7 +149,7 @@ class BitBox02Keyring extends EventEmitter { balance: null, index: i + 1, }); - this.paths[ethUtil.toChecksumAddress(address)] = i; + this.paths[toChecksumAddress(address)] = i; } return accounts; } @@ -175,10 +176,10 @@ class BitBox02Keyring extends EventEmitter { let result; const txData: JsonTx = { to: tx.to!.toString(), - value: `0x${tx.value.toString('hex')}`, + value: `0x${tx.value.toString(16)}`, data: this._normalize(tx.data), - nonce: `0x${tx.nonce.toString('hex')}`, - gasLimit: `0x${tx.gasLimit.toString('hex')}`, + nonce: `0x${tx.nonce.toString(16)}`, + gasLimit: `0x${tx.gasLimit.toString(16)}`, }; if (tx instanceof FeeMarketEIP1559Transaction) { @@ -187,30 +188,28 @@ class BitBox02Keyring extends EventEmitter { tx.toJSON() ); txData.type = '0x02'; - txData.maxPriorityFeePerGas = `0x${tx.maxPriorityFeePerGas.toString( - 'hex' - )}`; - txData.maxFeePerGas = `0x${tx.maxFeePerGas.toString('hex')}`; + txData.maxPriorityFeePerGas = `0x${tx.maxPriorityFeePerGas.toString(16)}`; + txData.maxFeePerGas = `0x${tx.maxFeePerGas.toString(16)}`; } else if ( tx instanceof Transaction || tx instanceof AccessListEIP2930Transaction ) { result = await this.bridge.ethSignTransaction( - tx.common.chainIdBN().toNumber(), + Number(tx.common.chainId()), this._pathFromAddress(address), tx.toJSON() ); - txData.gasPrice = `0x${tx.gasPrice.toString('hex')}`; + txData.gasPrice = `0x${tx.gasPrice.toString(16)}`; } - txData.chainId = `0x${tx.common.chainIdBN().toString('hex')}`; - txData.r = result.r; - txData.s = result.s; - txData.v = result.v; + txData.chainId = `0x${tx.common.chainId().toString(16)}`; + txData.r = bufferToHex(result.r); + txData.s = bufferToHex(result.s); + txData.v = bufferToHex(result.v); const signedTx = TransactionFactory.fromTxData(txData); - const addressSignedWith = ethUtil.toChecksumAddress( + const addressSignedWith = toChecksumAddress( signedTx.getSenderAddress().toString() ); - const correctAddress = ethUtil.toChecksumAddress(address); + const correctAddress = toChecksumAddress(address); if (addressSignedWith !== correctAddress) { throw new Error('signature doesnt match the right address'); } @@ -263,8 +262,7 @@ class BitBox02Keyring extends EventEmitter { version: options.version, }); if ( - ethUtil.toChecksumAddress(addressSignedWith) !== - ethUtil.toChecksumAddress(withAccount) + toChecksumAddress(addressSignedWith) !== toChecksumAddress(withAccount) ) { throw new Error('The signature doesnt match the right address'); } @@ -285,7 +283,7 @@ class BitBox02Keyring extends EventEmitter { /* PRIVATE METHODS */ _normalize(buf: Buffer): string { - return ethUtil.bufferToHex(buf).toString(); + return bufferToHex(buf); } // eslint-disable-next-line no-shadow @@ -294,11 +292,11 @@ class BitBox02Keyring extends EventEmitter { const address = ethUtil .publicToAddress(dkey.publicKey, true) .toString('hex'); - return ethUtil.toChecksumAddress(`0x${address}`); + return toChecksumAddress(`0x${address}`); } _pathFromAddress(address: string): string { - const checksummedAddress = ethUtil.toChecksumAddress(address); + const checksummedAddress = toChecksumAddress(address); let index = this.paths[checksummedAddress]; if (typeof index === 'undefined') { for (let i = 0; i < MAX_INDEX; i++) { @@ -320,7 +318,7 @@ class BitBox02Keyring extends EventEmitter { const addrs = await this.getAccounts(); return addrs.map((address) => { - const checksummedAddress = ethUtil.toChecksumAddress(address); + const checksummedAddress = toChecksumAddress(address); return { address, index: this.paths[checksummedAddress] + 1, diff --git a/src/background/service/keyring/eth-cobo-argus-keyring.ts b/src/background/service/keyring/eth-cobo-argus-keyring.ts index 4146fe9389d..3d3018c6d0b 100644 --- a/src/background/service/keyring/eth-cobo-argus-keyring.ts +++ b/src/background/service/keyring/eth-cobo-argus-keyring.ts @@ -1,6 +1,5 @@ -import { addHexPrefix } from 'ethereumjs-util'; +import { addHexPrefix } from '@ethereumjs/util'; import EventEmitter from 'events'; -import { t } from 'i18next'; import { isAddress } from 'web3-utils'; export const keyringType = 'CoboArgus'; diff --git a/src/background/service/keyring/eth-gnosis-keyring.ts b/src/background/service/keyring/eth-gnosis-keyring.ts index fef2b102283..4ef0b587855 100644 --- a/src/background/service/keyring/eth-gnosis-keyring.ts +++ b/src/background/service/keyring/eth-gnosis-keyring.ts @@ -1,6 +1,6 @@ import { EventEmitter } from 'events'; import { isAddress, toChecksumAddress } from 'web3-utils'; -import { addHexPrefix, bufferToHex } from 'ethereumjs-util'; +import { addHexPrefix, bufferToHex } from '@ethereumjs/util'; import Safe from '@rabby-wallet/gnosis-sdk'; import { SafeTransaction, @@ -12,12 +12,12 @@ import SafeMessage from '@safe-global/protocol-kit/dist/src/utils/messages/SafeM import { adjustVInSignature, buildSignatureBytes, - calculateSafeMessageHash, EthSafeSignature, hashSafeMessage, } from '@safe-global/protocol-kit/dist/src/utils'; import { SigningMethod } from '@safe-global/protocol-kit'; import { SafeClientTxStatus } from '@safe-global/sdk-starter-kit/dist/src/constants'; +import { TypedTransaction } from '@ethereumjs/tx'; export const keyringType = 'Gnosis'; export const TransactionBuiltEvent = 'TransactionBuilt'; export const TransactionConfirmedEvent = 'TransactionConfirmed'; @@ -543,7 +543,7 @@ class GnosisKeyring extends EventEmitter { async signTransaction( address: string, - transaction, + transaction: TypedTransaction, opts: SignTransactionOptions ) { // eslint-disable-next-line no-async-promise-executor @@ -556,7 +556,7 @@ class GnosisKeyring extends EventEmitter { } let safeTransaction: SafeTransaction; let transactionHash: string; - const networkId = transaction?.chainId?.toString(); + const networkId = transaction.common.chainId().toString(); const checksumAddress = toChecksumAddress(address); const version = await Safe.getSafeVersion({ provider: opts.provider, diff --git a/src/background/service/keyring/eth-imkey-keyring/eth-imkey-keyring.ts b/src/background/service/keyring/eth-imkey-keyring/eth-imkey-keyring.ts index 36464749128..a4293b1d55f 100644 --- a/src/background/service/keyring/eth-imkey-keyring/eth-imkey-keyring.ts +++ b/src/background/service/keyring/eth-imkey-keyring/eth-imkey-keyring.ts @@ -1,8 +1,13 @@ import EventEmitter from 'events'; -import * as ethUtil from 'ethereumjs-util'; -import { FeeMarketEIP1559Transaction, Transaction } from '@ethereumjs/tx'; +import { + FeeMarketEIP1559Transaction, + FeeMarketEIP1559TxData, + Transaction, + TypedTransaction, +} from '@ethereumjs/tx'; +import { addHexPrefix, bufferToHex, toChecksumAddress } from '@ethereumjs/util'; +import { RLP, utils } from '@ethereumjs/rlp'; import { is1559Tx } from '@/utils/transaction'; -import { bytesToHex } from 'web3-utils'; import { ImKeyBridgeInterface } from './imkey-bridge-interface'; import { signHashHex } from './utils'; @@ -133,7 +138,7 @@ export class EthImKeyKeyring extends EventEmitter { const address = await this.addressFromIndex(i); if (!this.accounts.includes(address)) { this.accounts.push(address); - this.accountDetails[ethUtil.toChecksumAddress(address)] = { + this.accountDetails[toChecksumAddress(address)] = { hdPath: this.getPathForIndex(i), hdPathType: this.hdPathType, hdPathBasePublicKey: await this.getPathBasePublicKey( @@ -180,7 +185,7 @@ export class EthImKeyKeyring extends EventEmitter { balance: null, index: i + 1, }); - this.paths[ethUtil.toChecksumAddress(address)] = i; + this.paths[toChecksumAddress(address)] = i; } resolve(accounts); }) @@ -211,7 +216,7 @@ export class EthImKeyKeyring extends EventEmitter { balance: null, index: i + 1, }); - this.paths[ethUtil.toChecksumAddress(address)] = i; + this.paths[toChecksumAddress(address)] = i; } resolve(accounts); }) @@ -234,31 +239,34 @@ export class EthImKeyKeyring extends EventEmitter { this.accounts = this.accounts.filter( (a) => a.toLowerCase() !== address.toLowerCase() ); - const checksummedAddress = ethUtil.toChecksumAddress(address); + const checksummedAddress = toChecksumAddress(address); delete this.accountDetails[checksummedAddress]; delete this.paths[checksummedAddress]; } // tx is an instance of the ethereumjs-transaction class. - async signTransaction(address: string, transaction) { + async signTransaction(address: string, transaction: TypedTransaction) { await this.unlock(); - const checksummedAddress = ethUtil.toChecksumAddress(address); + const checksummedAddress = toChecksumAddress(address); const accountDetail = this.accountDetails[checksummedAddress]; const txChainId = getChainId(transaction.common); const dataHex = transaction.data.toString('hex'); const txJSON = transaction.toJSON(); - const is1559 = is1559Tx(txJSON); + const is1559 = is1559Tx(txJSON as any); const txData = is1559 ? { data: dataHex === '' ? '' : `0x${dataHex}`, gasLimit: convertToHex(transaction.gasLimit), type: convertToHex(transaction.type.toString()), - accessList: transaction.accessList, - maxFeePerGas: convertToHex(transaction.maxFeePerGas), - maxPriorityFeePerGas: convertToHex(transaction.maxPriorityFeePerGas), + maxFeePerGas: convertToHex( + (transaction as FeeMarketEIP1559Transaction).maxFeePerGas + ), + maxPriorityFeePerGas: convertToHex( + (transaction as FeeMarketEIP1559Transaction).maxPriorityFeePerGas + ), nonce: convertToHex(transaction.nonce), to: transaction.to!.toString(), value: convertToHex(transaction.value), @@ -287,20 +295,21 @@ export class EthImKeyKeyring extends EventEmitter { let decoded; if (is1559) { - decoded = ethUtil.rlp.decode('0x' + signature.substring(4), true); - - txJSON.r = bytesToHex(decoded.data[10]); - txJSON.s = bytesToHex(decoded.data[11]); - txJSON.v = bytesToHex(decoded.data[9]); - txJSON.hash = txHash; - return FeeMarketEIP1559Transaction.fromTxData(txJSON); + decoded = RLP.decode('0x' + signature.substring(4), true); + + txJSON.r = addHexPrefix(utils.bytesToHex(decoded.data[10])); + txJSON.s = addHexPrefix(utils.bytesToHex(decoded.data[11])); + txJSON.v = addHexPrefix(utils.bytesToHex(decoded.data[9])); + return FeeMarketEIP1559Transaction.fromTxData( + txJSON as FeeMarketEIP1559TxData + ); } else { - decoded = ethUtil.rlp.decode(signature, true); + decoded = RLP.decode(signature, true); - txJSON.r = bytesToHex(decoded.data[7]); - txJSON.s = bytesToHex(decoded.data[8]); - txJSON.v = bytesToHex(decoded.data[6]); - txJSON.hash = txHash; + txJSON.r = addHexPrefix(utils.bytesToHex(decoded.data[7])); + txJSON.s = addHexPrefix(utils.bytesToHex(decoded.data[8])); + txJSON.v = addHexPrefix(utils.bytesToHex(decoded.data[6])); + // txJSON.hash = txHash; return Transaction.fromTxData(txJSON); } } @@ -312,7 +321,7 @@ export class EthImKeyKeyring extends EventEmitter { // For personal_sign, we need to prefix the message: async signPersonalMessage(address: string, message: string) { await this.unlock(); - const checksummedAddress = ethUtil.toChecksumAddress(address); + const checksummedAddress = toChecksumAddress(address); const accountDetail = this.accountDetails[checksummedAddress]; const res = await this.invokeApp('signMessage', [ @@ -326,7 +335,7 @@ export class EthImKeyKeyring extends EventEmitter { async signTypedData(address, data, opts) { await this.unlock(); - const checksummedAddress = ethUtil.toChecksumAddress(address); + const checksummedAddress = toChecksumAddress(address); const accountDetail = this.accountDetails[checksummedAddress]; const isV4 = opts.version === 'V4'; @@ -358,10 +367,6 @@ export class EthImKeyKeyring extends EventEmitter { /* PRIVATE METHODS */ - _normalize(buf: Buffer): string { - return ethUtil.bufferToHex(buf).toString(); - } - private getPathForIndex(i: number) { let htPath = this.getHDPathBase(this.hdPathType); if (this.hdPathType === HDPathType.LedgerLive) { @@ -386,7 +391,7 @@ export class EthImKeyKeyring extends EventEmitter { } async indexFromAddress(address: string): Promise { - const checksummedAddress = ethUtil.toChecksumAddress(address); + const checksummedAddress = toChecksumAddress(address); let index = this.paths[checksummedAddress] || this.accountDetails[checksummedAddress]?.index; @@ -415,7 +420,7 @@ export class EthImKeyKeyring extends EventEmitter { for (let i = 0; i < addresses.length; i++) { const address = addresses[i]; - const detail = this.accountDetails[ethUtil.toChecksumAddress(address)]; + const detail = this.accountDetails[toChecksumAddress(address)]; if (detail?.hdPathBasePublicKey !== currentPublicKey) { continue; diff --git a/src/background/service/keyring/eth-keystone-keyring/index.ts b/src/background/service/keyring/eth-keystone-keyring/index.ts index ff22d757ef4..c428107e50b 100644 --- a/src/background/service/keyring/eth-keystone-keyring/index.ts +++ b/src/background/service/keyring/eth-keystone-keyring/index.ts @@ -1,5 +1,5 @@ import { MetaMaskKeyring } from '@keystonehq/metamask-airgapped-keyring'; -import { toChecksumAddress } from 'ethereumjs-util'; +import { toChecksumAddress } from '@ethereumjs/util'; import { StoredKeyring } from '@keystonehq/base-eth-keyring'; import { Eth, default as EthLegacy } from '@keystonehq/hw-app-eth'; import { TransportWebUSB } from '@keystonehq/hw-transport-webusb'; diff --git a/src/background/service/keyring/eth-ledger-keyring.ts b/src/background/service/keyring/eth-ledger-keyring.ts index f45382a67f1..9950f46b2d5 100644 --- a/src/background/service/keyring/eth-ledger-keyring.ts +++ b/src/background/service/keyring/eth-ledger-keyring.ts @@ -1,5 +1,11 @@ -import * as ethUtil from 'ethereumjs-util'; import * as sigUtil from 'eth-sig-util'; +import { + toChecksumAddress, + addHexPrefix, + bufferToHex, + stripHexPrefix, +} from '@ethereumjs/util'; +import { RLP, utils } from '@ethereumjs/rlp'; import TransportWebHID from '@ledgerhq/hw-transport-webhid'; import Transport from '@ledgerhq/hw-transport'; import LedgerEth from '@ledgerhq/hw-app-eth'; @@ -8,7 +14,6 @@ import { TransactionFactory, FeeMarketEIP1559Transaction, } from '@ethereumjs/tx'; -import { EVENTS } from 'consts'; import { isSameAddress } from '@/background/utils'; import { LedgerHDPathType } from './helper'; @@ -113,9 +118,7 @@ class LedgerBridgeKeyring { // Remove accounts that don't have corresponding account details this.accounts = this.accounts.filter((account) => - Object.keys(this.accountDetails).includes( - ethUtil.toChecksumAddress(account) - ) + Object.keys(this.accountDetails).includes(toChecksumAddress(account)) ); return Promise.resolve(); @@ -201,7 +204,7 @@ class LedgerBridgeKeyring { address = await this.unlock(path); const hdPathType = this.getHDPathType(path); - this.accountDetails[ethUtil.toChecksumAddress(address)] = { + this.accountDetails[toChecksumAddress(address)] = { hdPath: path, hdPathBasePublicKey: await this.getPathBasePublicKey(hdPathType), hdPathType, @@ -246,7 +249,7 @@ class LedgerBridgeKeyring { this.accounts = this.accounts.filter( (a) => a.toLowerCase() !== address.toLowerCase() ); - const checksummedAddress = ethUtil.toChecksumAddress(address); + const checksummedAddress = toChecksumAddress(address); delete this.accountDetails[checksummedAddress]; delete this.paths[checksummedAddress]; } @@ -265,7 +268,7 @@ class LedgerBridgeKeyring { // transaction which is only communicated to ethereumjs-tx in this // value. In newer versions the chainId is communicated via the 'Common' // object. - tx.v = ethUtil.bufferToHex(tx.getChainId()); + tx.v = bufferToHex(tx.getChainId()); tx.r = '0x00'; tx.s = '0x00'; @@ -290,16 +293,16 @@ class LedgerBridgeKeyring { const messageToSign = tx.getMessageToSign(false); const rawTxHex = Buffer.isBuffer(messageToSign) ? messageToSign.toString('hex') - : ethUtil.rlp.encode(messageToSign).toString('hex'); + : stripHexPrefix(utils.bytesToHex(RLP.encode(messageToSign))); return this._signTransaction(address, rawTxHex, (payload) => { // Because tx will be immutable, first get a plain javascript object that // represents the transaction. Using txData here as it aligns with the // nomenclature of ethereumjs/tx. const txData = tx.toJSON(); // The fromTxData utility expects v,r and s to be hex prefixed - txData.v = ethUtil.addHexPrefix(payload.v); - txData.r = ethUtil.addHexPrefix(payload.r); - txData.s = ethUtil.addHexPrefix(payload.s); + txData.v = addHexPrefix(payload.v); + txData.r = addHexPrefix(payload.r); + txData.s = addHexPrefix(payload.s); // Adopt the 'common' option from the original transaction and set the // returned object to be frozen if the original is frozen. if (is1559Tx(txData)) { @@ -343,7 +346,7 @@ class LedgerBridgeKeyring { const hdPath = await this.unlockAccountByAddress(withAccount); const res = await ethApp!.signPersonalMessage( hdPath, - ethUtil.stripHexPrefix(message) + stripHexPrefix(message) ); // let v: string | number = res.v - 27; let v = res.v.toString(16); @@ -356,8 +359,7 @@ class LedgerBridgeKeyring { sig: signature, }); if ( - ethUtil.toChecksumAddress(addressSignedWith) !== - ethUtil.toChecksumAddress(withAccount) + toChecksumAddress(addressSignedWith) !== toChecksumAddress(withAccount) ) { throw new Error( "Ledger: The signature doesn't match the right address" @@ -372,7 +374,7 @@ class LedgerBridgeKeyring { } async unlockAccountByAddress(address) { - const checksummedAddress = ethUtil.toChecksumAddress(address); + const checksummedAddress = toChecksumAddress(address); if (!Object.keys(this.accountDetails).includes(checksummedAddress)) { throw new Error( `Ledger: Account for address '${checksummedAddress}' not found` @@ -438,8 +440,7 @@ class LedgerBridgeKeyring { sig: signature, }); if ( - ethUtil.toChecksumAddress(addressSignedWith) !== - ethUtil.toChecksumAddress(withAccount) + toChecksumAddress(addressSignedWith) !== toChecksumAddress(withAccount) ) { throw new Error('Ledger: The signature doesnt match the right address'); } @@ -489,7 +490,7 @@ class LedgerBridgeKeyring { } getIndexFromAddress(address: string) { - const checksummedAddress = ethUtil.toChecksumAddress(address); + const checksummedAddress = toChecksumAddress(address); if (!this.accountDetails[checksummedAddress]) { throw new Error(`Address ${address} not found`); } @@ -501,7 +502,7 @@ class LedgerBridgeKeyring { index = parseInt(res[1], 10); } } else { - const checksummedAddress = ethUtil.toChecksumAddress(address); + const checksummedAddress = toChecksumAddress(address); const arr = this.accountDetails[checksummedAddress].hdPath.split('/'); index = Number(arr[arr.length - 1]); } @@ -569,7 +570,7 @@ class LedgerBridgeKeyring { } private async _fixAccountDetail(address: string) { - const checksummedAddress = ethUtil.toChecksumAddress(address); + const checksummedAddress = toChecksumAddress(address); const detail = this.accountDetails[checksummedAddress]; // The detail is already fixed @@ -628,7 +629,7 @@ class LedgerBridgeKeyring { const address = addresses[i]; await this._fixAccountDetail(address); - const detail = this.accountDetails[ethUtil.toChecksumAddress(address)]; + const detail = this.accountDetails[toChecksumAddress(address)]; if (detail.hdPathBasePublicKey === currentPublicKey) { const info = this.getAccountInfo(address); @@ -659,7 +660,7 @@ class LedgerBridgeKeyring { } getAccountInfo(address: string) { - const detail = this.accountDetails[ethUtil.toChecksumAddress(address)]; + const detail = this.accountDetails[toChecksumAddress(address)]; if (detail) { const { hdPath, hdPathType, hdPathBasePublicKey } = detail; return { diff --git a/src/background/service/keyring/eth-onekey-keyring/eth-onekey-keyring.ts b/src/background/service/keyring/eth-onekey-keyring/eth-onekey-keyring.ts index 1021016a061..484a97ebba9 100644 --- a/src/background/service/keyring/eth-onekey-keyring/eth-onekey-keyring.ts +++ b/src/background/service/keyring/eth-onekey-keyring/eth-onekey-keyring.ts @@ -1,11 +1,20 @@ import EventEmitter from 'events'; -import * as ethUtil from 'ethereumjs-util'; +import { + toChecksumAddress, + stripHexPrefix, + addHexPrefix, + publicToAddress, + bufferToHex, +} from '@ethereumjs/util'; import * as sigUtil from 'eth-sig-util'; -import { TransactionFactory } from '@ethereumjs/tx'; +import { + FeeMarketEIP1559Transaction, + Transaction, + TransactionFactory, + TypedTransaction, +} from '@ethereumjs/tx'; import HDKey from 'hdkey'; import { isSameAddress } from '@/background/utils'; -import { EVENTS } from '@/constant'; -import type { EVMTransaction, EVMTransactionEIP1559 } from '@onekeyfe/hd-core'; import { OneKeyBridgeInterface } from './onekey-bridge-interface'; import { isManifestV3 } from '@/utils/env'; import browser from 'webextension-polyfill'; @@ -45,23 +54,6 @@ interface AccountDetail { index: number; } -/** - * Check if the given transaction is made with ethereumjs-tx or @ethereumjs/tx - * - * Transactions built with older versions of ethereumjs-tx have a - * getChainId method that newer versions do not. - * Older versions are mutable - * while newer versions default to being immutable. - * Expected shape and type - * of data for v, r and s differ (Buffer (old) vs BN (new)). - * - * @param {TypedTransaction | OldEthJsTransaction} tx - * @returns {tx is OldEthJsTransaction} Returns `true` if tx is an old-style ethereumjs-tx transaction. - */ -function isOldStyleEthereumjsTx(tx) { - return typeof tx.getChainId === 'function'; -} - class OneKeyKeyring extends EventEmitter { static type = keyringType; type = keyringType; @@ -238,7 +230,7 @@ class OneKeyKeyring extends EventEmitter { const address = this._addressFromIndex(pathBase, i); if (!this.accounts.includes(address)) { this.accounts.push(address); - this.accountDetails[ethUtil.toChecksumAddress(address)] = { + this.accountDetails[toChecksumAddress(address)] = { hdPath: this._pathFromAddress(address), hdPathType: LedgerHDPathType.BIP44, hdPathBasePublicKey: this.getPathBasePublicKey(), @@ -283,7 +275,7 @@ class OneKeyKeyring extends EventEmitter { balance: null, index: i + 1, }); - this.paths[ethUtil.toChecksumAddress(address)] = i; + this.paths[toChecksumAddress(address)] = i; } resolve(accounts); }) @@ -314,7 +306,7 @@ class OneKeyKeyring extends EventEmitter { balance: null, index: i + 1, }); - this.paths[ethUtil.toChecksumAddress(address)] = i; + this.paths[toChecksumAddress(address)] = i; } resolve(accounts); }) @@ -337,64 +329,44 @@ class OneKeyKeyring extends EventEmitter { this.accounts = this.accounts.filter( (a) => a.toLowerCase() !== address.toLowerCase() ); - const checksummedAddress = ethUtil.toChecksumAddress(address); + const checksummedAddress = toChecksumAddress(address); delete this.accountDetails[checksummedAddress]; delete this.paths[checksummedAddress]; } // tx is an instance of the ethereumjs-transaction class. - signTransaction(address: string, tx): Promise { + signTransaction(address: string, tx: TypedTransaction): Promise { return new Promise((resolve, reject) => { this.unlock() .then((status) => { setTimeout( (_) => { - if (isOldStyleEthereumjsTx(tx)) { - // In this version of ethereumjs-tx we must add the chainId in hex format - // to the initial v value. The chainId must be included in the serialized - // transaction which is only communicated to ethereumjs-tx in this - // value. In newer versions the chainId is communicated via the 'Common' - // object. - this._signTransaction( - address, - tx.getChainId(), - tx, - (payload) => { - tx.v = Buffer.from(payload.v, 'hex'); - tx.r = Buffer.from(payload.r, 'hex'); - tx.s = Buffer.from(payload.s, 'hex'); - return tx; - } - ) - .then(resolve) - .catch(reject); - } else { - this._signTransaction( - address, - Number(tx.common.chainId()), - tx, - (payload) => { - // Because tx will be immutable, first get a plain javascript object that - // represents the transaction. Using txData here as it aligns with the - // nomenclature of ethereumjs/tx. - const txData = tx.toJSON(); - // The fromTxData utility expects a type to support transactions with a type other than 0 - txData.type = tx.type; - // The fromTxData utility expects v,r and s to be hex prefixed - txData.v = ethUtil.addHexPrefix(payload.v); - txData.r = ethUtil.addHexPrefix(payload.r); - txData.s = ethUtil.addHexPrefix(payload.s); - // Adopt the 'common' option from the original transaction and set the - // returned object to be frozen if the original is frozen. - return TransactionFactory.fromTxData(txData, { - common: tx.common, - freeze: Object.isFrozen(tx), - }); - } - ) - .then(resolve) - .catch(reject); - } + this._signTransaction( + address, + Number(tx.common.chainId()), + tx, + (payload) => { + // Because tx will be immutable, first get a plain javascript object that + // represents the transaction. Using txData here as it aligns with the + // nomenclature of ethereumjs/tx. + const txData = tx.toJSON(); + // The fromTxData utility expects a type to support transactions with a type other than 0 + txData.type = `0x${tx.type.toString(16)}`; + // The fromTxData utility expects v,r and s to be hex prefixed + txData.v = addHexPrefix(payload.v); + txData.r = addHexPrefix(payload.r); + txData.s = addHexPrefix(payload.s); + // Adopt the 'common' option from the original transaction and set the + // returned object to be frozen if the original is frozen. + return TransactionFactory.fromTxData(txData, { + common: tx.common, + freeze: Object.isFrozen(tx), + }); + } + ) + .then(resolve) + .catch(reject); + // This is necessary to avoid popup collision // between the unlock & sign trezor popups }, @@ -407,44 +379,32 @@ class OneKeyKeyring extends EventEmitter { }); } - async _signTransaction(address, chainId, tx, handleSigning) { - let transaction: EVMTransaction | EVMTransactionEIP1559; - if (isOldStyleEthereumjsTx(tx)) { - // legacy transaction from ethereumjs-tx package has no .toJSON() function, - // so we need to convert to hex-strings manually manually - transaction = { - to: this._normalize(tx.to), - value: this._normalize(tx.value), - data: this._normalize(tx.data), - chainId, - nonce: this._normalize(tx.nonce), - gasLimit: this._normalize(tx.gasLimit), - gasPrice: this._normalize(tx.gasPrice), - }; - } else { - // new-style transaction from @ethereumjs/tx package - // we can just copy tx.toJSON() for everything except chainId, which must be a number - transaction = { - ...tx.toJSON(), - chainId, - to: this._normalize(tx.to), - }; - } + async _signTransaction( + address, + chainId, + tx: TypedTransaction, + handleSigning + ) { + // new-style transaction from @ethereumjs/tx package + // we can just copy tx.toJSON() for everything except chainId, which must be a number + const transaction = { + ...tx.toJSON(), + chainId, + to: tx.to?.toString(), + }; return this.bridge .evmSignTransaction(this.connectId!, this.deviceId!, { path: this._pathFromAddress(address), passphraseState: this.passphraseState, - transaction, + transaction: transaction as any, }) .then((res) => { if (res.success) { - const newOrMutatedTx = handleSigning(res.payload); - const addressSignedWith = ethUtil.toChecksumAddress( - ethUtil.addHexPrefix( - newOrMutatedTx.getSenderAddress().toString('hex') - ) + const newOrMutatedTx: TypedTransaction = handleSigning(res.payload); + const addressSignedWith = toChecksumAddress( + addHexPrefix(newOrMutatedTx.getSenderAddress().toString()) ); - const correctAddress = ethUtil.toChecksumAddress(address); + const correctAddress = toChecksumAddress(address); if (addressSignedWith !== correctAddress) { throw new Error('signature doesnt match the right address'); } @@ -472,14 +432,14 @@ class OneKeyKeyring extends EventEmitter { this.bridge .evmSignMessage(this.connectId!, this.deviceId!, { path: this._pathFromAddress(withAccount), - messageHex: ethUtil.stripHexPrefix(message), + messageHex: stripHexPrefix(message), passphraseState: this.passphraseState, }) .then((response) => { if (response.success) { if ( response.payload.address !== - ethUtil.toChecksumAddress(withAccount) + toChecksumAddress(withAccount) ) { reject( new Error('signature doesnt match the right address') @@ -577,8 +537,7 @@ class OneKeyKeyring extends EventEmitter { .then((response) => { if (response.success) { if ( - response.payload.address !== - ethUtil.toChecksumAddress(address) + response.payload.address !== toChecksumAddress(address) ) { reject( new Error('signature doesnt match the right address') @@ -652,16 +611,14 @@ class OneKeyKeyring extends EventEmitter { /* PRIVATE METHODS */ _normalize(buf: Buffer): string { - return ethUtil.bufferToHex(buf).toString(); + return bufferToHex(buf); } // eslint-disable-next-line no-shadow _addressFromIndex(pathBase: string, i: number): string { const dkey = this.hdk.derive(`${pathBase}/${i}`); - const address = ethUtil - .publicToAddress(dkey.publicKey, true) - .toString('hex'); - return ethUtil.toChecksumAddress(`0x${address}`); + const address = bufferToHex(publicToAddress(dkey.publicKey, true)); + return toChecksumAddress(address); } _pathFromAddress(address: string): string { @@ -669,7 +626,7 @@ class OneKeyKeyring extends EventEmitter { } indexFromAddress(address: string) { - const checksummedAddress = ethUtil.toChecksumAddress(address); + const checksummedAddress = toChecksumAddress(address); let index = this.paths[checksummedAddress] || this.accountDetails[checksummedAddress]?.index; @@ -699,7 +656,7 @@ class OneKeyKeyring extends EventEmitter { const address = addresses[i]; await this._fixAccountDetail(address); - const detail = this.accountDetails[ethUtil.toChecksumAddress(address)]; + const detail = this.accountDetails[toChecksumAddress(address)]; if (detail?.hdPathBasePublicKey !== currentPublicKey) { continue; @@ -724,7 +681,7 @@ class OneKeyKeyring extends EventEmitter { } private async _fixAccountDetail(address: string) { - const checksummedAddress = ethUtil.toChecksumAddress(address); + const checksummedAddress = toChecksumAddress(address); const detail = this.accountDetails[checksummedAddress]; // The detail is already fixed diff --git a/src/background/service/keyring/index.ts b/src/background/service/keyring/index.ts index 0ad30073014..731b84626f7 100644 --- a/src/background/service/keyring/index.ts +++ b/src/background/service/keyring/index.ts @@ -2,7 +2,7 @@ import { EventEmitter } from 'events'; import log from 'loglevel'; -import * as ethUtil from 'ethereumjs-util'; +import { stripHexPrefix } from '@ethereumjs/util'; import * as bip39 from '@scure/bip39'; import { wordlist } from '@scure/bip39/wordlists/english'; import { ObservableStore } from '@metamask/obs-store'; @@ -477,8 +477,7 @@ export class KeyringService extends EventEmitter { const isIncluded = newAccountArray.find((account) => { return accounts.find( (key) => - key === account.toLowerCase() || - key === ethUtil.stripHexPrefix(account) + key === account.toLowerCase() || key === stripHexPrefix(account) ); }); diff --git a/src/ui/hooks/useParseAddress.ts b/src/ui/hooks/useParseAddress.ts index 2cbd4c71552..473fcdde7ae 100644 --- a/src/ui/hooks/useParseAddress.ts +++ b/src/ui/hooks/useParseAddress.ts @@ -1,8 +1,8 @@ import { useState, useMemo } from 'react'; import { useAsync } from 'react-use'; -import { formatNumber, useWallet } from '../utils'; +import { useWallet } from '../utils'; import { Chain } from '@debank/common'; -import { isValidAddress } from 'ethereumjs-util'; +import { isValidAddress } from '@ethereumjs/util'; import { AddressType } from '../utils/address'; import { INTERNAL_REQUEST_ORIGIN } from '@/constant'; import { formatTxExplainAbiData } from '../utils/transaction'; diff --git a/src/ui/views/Approval/components/SignTestnetTx/index.tsx b/src/ui/views/Approval/components/SignTestnetTx/index.tsx index 76282246b67..0c5d44b23e5 100644 --- a/src/ui/views/Approval/components/SignTestnetTx/index.tsx +++ b/src/ui/views/Approval/components/SignTestnetTx/index.tsx @@ -1,7 +1,6 @@ import { Account, ChainGas } from 'background/service/preference'; import React, { ReactNode, useMemo, useRef, useState } from 'react'; import { useTranslation } from 'react-i18next'; -import styled from 'styled-components'; import { findChain } from '@/utils/chain'; import { TestnetActions } from './components/TestnetActions'; import BigNumber from 'bignumber.js'; @@ -26,9 +25,8 @@ import { import { useEnterPassphraseModal } from '@/ui/hooks/useEnterPassphraseModal'; import { GasLevel, Tx } from '@rabby-wallet/rabby-api/dist/types'; import { normalizeTxParams } from '../SignTx'; -import { isHexString, toChecksumAddress } from 'ethereumjs-util'; +import { isHexString, toChecksumAddress } from '@ethereumjs/util'; import { WaitingSignComponent } from '../map'; -import { useLedgerDeviceConnected } from '@/ui/utils/ledger'; import IconGnosis from 'ui/assets/walletlogo/safe.svg'; import { matomoRequestEvent } from '@/utils/matomo-request'; import i18n from '@/i18n'; @@ -39,7 +37,6 @@ import { MessageWrapper } from '../TextActions'; import { Card } from '../Card'; import { SignAdvancedSettings } from '../SignAdvancedSettings'; import clsx from 'clsx'; -import { useGasAccountSign } from '@/ui/views/GasAccount/hooks'; import { Modal } from 'antd'; import { ga4 } from '@/utils/ga4'; diff --git a/src/ui/views/Approval/components/SignTx.tsx b/src/ui/views/Approval/components/SignTx.tsx index ab8f891e6e2..122a1a27f68 100644 --- a/src/ui/views/Approval/components/SignTx.tsx +++ b/src/ui/views/Approval/components/SignTx.tsx @@ -35,11 +35,11 @@ import { GAS_TOP_UP_ADDRESS, ALIAS_ADDRESS, } from 'consts'; -import { addHexPrefix, isHexPrefixed, isHexString } from 'ethereumjs-util'; +import { addHexPrefix, isHexPrefixed, isHexString } from '@ethereumjs/util'; import React, { ReactNode, useEffect, useMemo, useRef, useState } from 'react'; import { matomoRequestEvent } from '@/utils/matomo-request'; import { useTranslation } from 'react-i18next'; -import { useAsync, useAsyncFn, useDebounce, useScroll } from 'react-use'; +import { useScroll } from 'react-use'; import { useSize, useDebounceFn, useRequest } from 'ahooks'; import IconGnosis from 'ui/assets/walletlogo/safe.svg'; import { diff --git a/src/ui/views/GnosisQueue/components/GnosisTransactionQueue/GnosisTransactionQueueList.tsx b/src/ui/views/GnosisQueue/components/GnosisTransactionQueue/GnosisTransactionQueueList.tsx index e28afbbcec6..b2a2ce5e561 100644 --- a/src/ui/views/GnosisQueue/components/GnosisTransactionQueue/GnosisTransactionQueueList.tsx +++ b/src/ui/views/GnosisQueue/components/GnosisTransactionQueue/GnosisTransactionQueueList.tsx @@ -23,7 +23,7 @@ import { LoadingOutlined } from '@ant-design/icons'; import { SafeTransactionDataPartial } from '@gnosis.pm/safe-core-sdk-types'; import { useRequest } from 'ahooks'; import { CHAINS_ENUM, INTERNAL_REQUEST_ORIGIN, KEYRING_CLASS } from 'consts'; -import { intToHex } from 'ethereumjs-util'; +import { intToHex } from '@ethereumjs/util'; import { useHistory } from 'react-router-dom'; import { Virtuoso } from 'react-virtuoso'; import IconUser from 'ui/assets/address-management.svg'; diff --git a/src/ui/views/ImportGnosisAddress/index.tsx b/src/ui/views/ImportGnosisAddress/index.tsx index 83d5c85bf27..274eb9d0fde 100644 --- a/src/ui/views/ImportGnosisAddress/index.tsx +++ b/src/ui/views/ImportGnosisAddress/index.tsx @@ -3,7 +3,7 @@ import { useRequest } from 'ahooks'; import { Button, Form, Input } from 'antd'; import { useForm } from 'antd/lib/form/Form'; import { KEYRING_CLASS, KEYRING_TYPE, WALLET_BRAND_CATEGORY } from 'consts'; -import { isValidAddress } from 'ethereumjs-util'; +import { isValidAddress } from '@ethereumjs/util'; import React, { useState } from 'react'; import { useTranslation } from 'react-i18next'; import { useHistory } from 'react-router-dom'; diff --git a/src/ui/views/ImportWatchAddress.tsx b/src/ui/views/ImportWatchAddress.tsx index e3718ed5978..b288c81859d 100644 --- a/src/ui/views/ImportWatchAddress.tsx +++ b/src/ui/views/ImportWatchAddress.tsx @@ -4,7 +4,7 @@ import { useHistory } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import QRCode from 'qrcode.react'; import QRCodeReader from 'ui/component/QRCodeReader'; -import { isValidAddress } from 'ethereumjs-util'; +import { isValidAddress } from '@ethereumjs/util'; import { Popup, StrayPageWithButton } from 'ui/component'; import { useWallet, useWalletRequest } from 'ui/utils'; import { openInternalPageInTab } from 'ui/utils/webapi'; diff --git a/src/ui/views/NewUserImport/ImportGnosisAddress.tsx b/src/ui/views/NewUserImport/ImportGnosisAddress.tsx index b1355fa73e5..c6eacc0037f 100644 --- a/src/ui/views/NewUserImport/ImportGnosisAddress.tsx +++ b/src/ui/views/NewUserImport/ImportGnosisAddress.tsx @@ -4,7 +4,7 @@ import { LoadingOutlined } from '@ant-design/icons'; import { useMemoizedFn, useMount, useRequest } from 'ahooks'; import { Button, Form, Input } from 'antd'; import clsx from 'clsx'; -import { isValidAddress } from 'ethereumjs-util'; +import { isValidAddress } from '@ethereumjs/util'; import React, { useState } from 'react'; import { useTranslation } from 'react-i18next'; import { useHistory } from 'react-router-dom'; diff --git a/src/ui/views/SendNFT/index.tsx b/src/ui/views/SendNFT/index.tsx index 08d97ce7bfa..24fbc625a4b 100644 --- a/src/ui/views/SendNFT/index.tsx +++ b/src/ui/views/SendNFT/index.tsx @@ -4,14 +4,9 @@ import BigNumber from 'bignumber.js'; import { Trans, useTranslation } from 'react-i18next'; import { useHistory, useLocation } from 'react-router-dom'; import { matomoRequestEvent } from '@/utils/matomo-request'; -import { Input, Form, message, Button } from 'antd'; -import { isValidAddress } from 'ethereumjs-util'; -import { - CHAINS, - KEYRING_PURPLE_LOGOS, - KEYRING_CLASS, - CHAINS_ENUM, -} from 'consts'; +import { Form, message, Button } from 'antd'; +import { isValidAddress } from '@ethereumjs/util'; +import { KEYRING_PURPLE_LOGOS, KEYRING_CLASS, CHAINS_ENUM } from 'consts'; import { useRabbyDispatch, useRabbySelector, connectStore } from 'ui/store'; import { Account } from 'background/service/preference'; import { NFTItem } from '@/background/service/openapi'; @@ -19,29 +14,19 @@ import { UIContactBookItem } from 'background/service/contactBook'; import { useWallet, isSameAddress, openInTab } from 'ui/utils'; import AccountCard from '../Approval/components/AccountCard'; import { PageHeader, AddressViewer, Copy } from 'ui/component'; -import AuthenticationModalPromise from 'ui/component/AuthenticationModal'; import ContactEditModal from 'ui/component/Contact/EditModal'; import ContactListModal from 'ui/component/Contact/ListModal'; import NumberInput from '@/ui/component/NFTNumberInput'; import NFTAvatar from 'ui/views/Dashboard/components/NFT/NFTAvatar'; -import IconWhitelist, { - ReactComponent as RcIconWhitelist, -} from 'ui/assets/dashboard/whitelist.svg'; +import { ReactComponent as RcIconWhitelist } from 'ui/assets/dashboard/whitelist.svg'; import { ReactComponent as RcIconEdit } from 'ui/assets/edit-purple.svg'; -import IconContact, { - ReactComponent as RcIconContact, -} from 'ui/assets/send-token/contact.svg'; -import IconCheck, { - ReactComponent as RcIconCheck, -} from 'ui/assets/send-token/check.svg'; -import IconTemporaryGrantCheckbox, { - ReactComponent as RcIconTemporaryGrantCheckbox, -} from 'ui/assets/send-token/temporary-grant-checkbox.svg'; +import { ReactComponent as RcIconContact } from 'ui/assets/send-token/contact.svg'; +import { ReactComponent as RcIconCheck } from 'ui/assets/send-token/check.svg'; +import { ReactComponent as RcIconTemporaryGrantCheckbox } from 'ui/assets/send-token/temporary-grant-checkbox.svg'; import './style.less'; import { getKRCategoryByType } from '@/utils/transaction'; import { filterRbiSource, useRbiSource } from '@/ui/utils/ga-event'; import { ReactComponent as RcIconExternal } from 'ui/assets/icon-share-currentcolor.svg'; -import { ReactComponent as RcIconCopy } from 'ui/assets/icon-copy-2-currentcolor.svg'; import { findChain, findChainByEnum } from '@/utils/chain'; import ChainSelectorInForm from '@/ui/component/ChainSelector/InForm'; diff --git a/src/ui/views/SendToken/index.tsx b/src/ui/views/SendToken/index.tsx index bb4a9d4abf8..2ffe8e5e226 100644 --- a/src/ui/views/SendToken/index.tsx +++ b/src/ui/views/SendToken/index.tsx @@ -6,10 +6,10 @@ import BigNumber from 'bignumber.js'; import { Trans, useTranslation } from 'react-i18next'; import { useHistory } from 'react-router-dom'; import { matomoRequestEvent } from '@/utils/matomo-request'; -import { createGlobalState, useAsyncFn, useDebounce } from 'react-use'; +import { useAsyncFn, useDebounce } from 'react-use'; import { Input, Form, Skeleton, message, Button, InputProps } from 'antd'; import abiCoderInst, { AbiCoder } from 'web3-eth-abi'; -import { isValidAddress, intToHex, zeroAddress } from 'ethereumjs-util'; +import { isValidAddress, intToHex, zeroAddress } from '@ethereumjs/util'; import { CHAINS_ENUM, diff --git a/src/ui/views/TransactionHistory/components/TransactionItem.tsx b/src/ui/views/TransactionHistory/components/TransactionItem.tsx index 3c4ecdb7d06..f68733a0ef1 100644 --- a/src/ui/views/TransactionHistory/components/TransactionItem.tsx +++ b/src/ui/views/TransactionHistory/components/TransactionItem.tsx @@ -1,16 +1,16 @@ import { getTokenSymbol } from '@/ui/utils/token'; import { Tooltip, message } from 'antd'; -import { GasLevel, TokenItem, TxRequest } from 'background/service/openapi'; +import { GasLevel, TxRequest } from 'background/service/openapi'; import { TransactionGroup, TransactionHistoryItem, } from 'background/service/transactionHistory'; import clsx from 'clsx'; -import { CANCEL_TX_TYPE, CHAINS } from 'consts'; -import { intToHex } from 'ethereumjs-util'; +import { CANCEL_TX_TYPE } from 'consts'; +import { intToHex } from '@ethereumjs/util'; import maxBy from 'lodash/maxBy'; import minBy from 'lodash/minBy'; -import React, { useEffect, useState } from 'react'; +import React, { useState } from 'react'; import { useTranslation } from 'react-i18next'; import styled from 'styled-components'; import { SvgPendingSpin } from 'ui/assets'; @@ -25,7 +25,7 @@ import { TransactionWebsite } from './TransactionWebsite'; import { CancelTxPopup } from './CancelTxPopup'; import { TransactionPendingTag } from './TransactionPendingTag'; import { checkIsPendingTxGroup, findMaxGasTx } from '@/utils/tx'; -import { useGetTx, useLoadTxData } from '../hooks'; +import { useLoadTxData } from '../hooks'; import ThemeIcon from '@/ui/component/ThemeMode/ThemeIcon'; import { findChain } from '@/utils/chain'; import { getTxScanLink } from '@/utils'; diff --git a/src/utils/optimism/buildUnserializedTransaction.ts b/src/utils/optimism/buildUnserializedTransaction.ts index c65b3aaf0dd..e446ab1139a 100644 --- a/src/utils/optimism/buildUnserializedTransaction.ts +++ b/src/utils/optimism/buildUnserializedTransaction.ts @@ -1,6 +1,5 @@ import { omit } from 'lodash'; -import { BN, stripHexPrefix } from 'ethereumjs-util'; -import Common, { Chain, Hardfork } from '@ethereumjs/common'; +import { Common, Hardfork } from '@ethereumjs/common'; import { TransactionFactory } from '@ethereumjs/tx'; function buildTxParams(txMeta) { @@ -16,9 +15,8 @@ function buildTransactionCommon(txMeta) { // genesis points to the mainnet genesis, not the Optimism genesis — but // considering that all we want to do is serialize a transaction, this works // fine for our use case. - return Common.forCustomChain(Chain.Mainnet, { - chainId: new BN(stripHexPrefix(txMeta.chainId), 16), - networkId: new BN(txMeta.metamaskNetworkId, 10), + return Common.custom({ + chainId: Number(txMeta.chainId), // Optimism only supports type-0 transactions; it does not support any of // the newer EIPs since EIP-155. Source: // diff --git a/src/utils/transaction.ts b/src/utils/transaction.ts index f0b312ca053..7b77622fc95 100644 --- a/src/utils/transaction.ts +++ b/src/utils/transaction.ts @@ -1,4 +1,4 @@ -import { intToHex, isHexString } from 'ethereumjs-util'; +import { intToHex, isHexString } from '@ethereumjs/util'; import BigNumber from 'bignumber.js'; import { CAN_ESTIMATE_L1_FEE_CHAINS, diff --git a/yarn.lock b/yarn.lock index b96aad86a77..8ecea3a3aa5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1587,6 +1587,27 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== +"@chainsafe/as-sha256@^0.3.1": + version "0.3.1" + resolved "https://registry.yarnpkg.com/@chainsafe/as-sha256/-/as-sha256-0.3.1.tgz#3639df0e1435cab03f4d9870cc3ac079e57a6fc9" + integrity sha512-hldFFYuf49ed7DAakWVXSJODuq3pzJEguD8tQ7h+sGkM18vja+OFoJI9krnGmgzyuZC2ETX0NOIcCTy31v2Mtg== + +"@chainsafe/persistent-merkle-tree@^0.4.2": + version "0.4.2" + resolved "https://registry.yarnpkg.com/@chainsafe/persistent-merkle-tree/-/persistent-merkle-tree-0.4.2.tgz#4c9ee80cc57cd3be7208d98c40014ad38f36f7ff" + integrity sha512-lLO3ihKPngXLTus/L7WHKaw9PnNJWizlOF1H9NNzHP6Xvh82vzg9F2bzkXhYIFshMZ2gTCEz8tq6STe7r5NDfQ== + dependencies: + "@chainsafe/as-sha256" "^0.3.1" + +"@chainsafe/ssz@0.9.4": + version "0.9.4" + resolved "https://registry.yarnpkg.com/@chainsafe/ssz/-/ssz-0.9.4.tgz#696a8db46d6975b600f8309ad3a12f7c0e310497" + integrity sha512-77Qtg2N1ayqs4Bg/wvnWfg5Bta7iy7IRh8XqXh7oNMeP2HBbBwx8m6yTpA8p0EHItWPEBkgZd5S5/LSlp3GXuQ== + dependencies: + "@chainsafe/as-sha256" "^0.3.1" + "@chainsafe/persistent-merkle-tree" "^0.4.2" + case "^1.6.3" + "@coinbase/wallet-sdk@3.8.0-beta.3", "@coinbase/wallet-sdk@beta": version "3.8.0-beta.3" resolved "https://registry.yarnpkg.com/@coinbase/wallet-sdk/-/wallet-sdk-3.8.0-beta.3.tgz#28400b01047be18f6b06bb91520eed36546259e0" @@ -1767,23 +1788,15 @@ chai "^4.3.4" ethers "^5.6.8" -"@ethereumjs/common@2.4.0": - version "2.4.0" - resolved "https://registry.yarnpkg.com/@ethereumjs/common/-/common-2.4.0.tgz#2d67f6e6ba22246c5c89104e6b9a119fb3039766" - integrity sha512-UdkhFWzWcJCZVsj1O/H8/oqj/0RVYjLc1OhPjBrQdALAkQHpCp8xXI4WLnuGTADqTdJZww0NtgwG+TRPkXt27w== - dependencies: - crc-32 "^1.2.0" - ethereumjs-util "^7.1.0" - -"@ethereumjs/common@2.5.0", "@ethereumjs/common@^2.5.0": - version "2.5.0" - resolved "https://registry.yarnpkg.com/@ethereumjs/common/-/common-2.5.0.tgz#ec61551b31bef7a69d1dc634d8932468866a4268" - integrity sha512-DEHjW6e38o+JmB/NO3GZBpW4lpaiBpkFgXF6jLcJ6gETBYpEyaA5nTimsWBUJR3Vmtm/didUEbNjajskugZORg== +"@ethereumjs/common@3.1.1", "@ethereumjs/common@^3.1.1": + version "3.1.1" + resolved "https://registry.yarnpkg.com/@ethereumjs/common/-/common-3.1.1.tgz#6f754c8933727ad781f63ca3929caab542fe184e" + integrity sha512-iEl4gQtcrj2udNhEizs04z7WA15ez1QoXL0XzaCyaNgwRyXezIg1DnfNeZUUpJnkrOF/0rYXyq2UFSLxt1NPQg== dependencies: + "@ethereumjs/util" "^8.0.5" crc-32 "^1.2.0" - ethereumjs-util "^7.1.1" -"@ethereumjs/common@^2.0.0", "@ethereumjs/common@^2.4.0", "@ethereumjs/common@^2.6.4": +"@ethereumjs/common@^2.4.0", "@ethereumjs/common@^2.6.4": version "2.6.5" resolved "https://registry.yarnpkg.com/@ethereumjs/common/-/common-2.6.5.tgz#0a75a22a046272579d91919cb12d84f2756e8d30" integrity sha512-lRyVQOeCDaIVtgfbowla32pzeDv2Obr8oR8Put5RdUBNRGr1VGPGQNGP6elWIpgK3YdpzqTOh4GyUGOureVeeA== @@ -1791,6 +1804,14 @@ crc-32 "^1.2.0" ethereumjs-util "^7.1.5" +"@ethereumjs/common@^2.5.0": + version "2.5.0" + resolved "https://registry.yarnpkg.com/@ethereumjs/common/-/common-2.5.0.tgz#ec61551b31bef7a69d1dc634d8932468866a4268" + integrity sha512-DEHjW6e38o+JmB/NO3GZBpW4lpaiBpkFgXF6jLcJ6gETBYpEyaA5nTimsWBUJR3Vmtm/didUEbNjajskugZORg== + dependencies: + crc-32 "^1.2.0" + ethereumjs-util "^7.1.1" + "@ethereumjs/common@^3.2.0": version "3.2.0" resolved "https://registry.yarnpkg.com/@ethereumjs/common/-/common-3.2.0.tgz#b71df25845caf5456449163012074a55f048e0a0" @@ -1813,7 +1834,7 @@ dependencies: "@ethereumjs/util" "^9.1.0" -"@ethereumjs/rlp@^4.0.1": +"@ethereumjs/rlp@4.0.1", "@ethereumjs/rlp@^4.0.1": version "4.0.1" resolved "https://registry.yarnpkg.com/@ethereumjs/rlp/-/rlp-4.0.1.tgz#626fabfd9081baab3d0a3074b0c7ecaf674aaa41" integrity sha512-tqsQiBQDQdmPWE1xkkBq4rlSW5QZpLOUJ5RJh2/9fug+q9tnUhuZoVLk7s0scUIKTOzEtR72DFBXI4WiZcMpvw== @@ -1828,23 +1849,19 @@ resolved "https://registry.yarnpkg.com/@ethereumjs/rlp/-/rlp-5.0.2.tgz#c89bd82f2f3bec248ab2d517ae25f5bbc4aac842" integrity sha512-DziebCdg4JpGlEqEdGgXmjqcFoJi+JGulUXwEjsZGAscAQ7MyD/7LE/GVCP29vEQxKc7AAwjT3A2ywHp2xfoCA== -"@ethereumjs/tx@3", "@ethereumjs/tx@^3.3.0", "@ethereumjs/tx@^3.5.2": - version "3.5.2" - resolved "https://registry.yarnpkg.com/@ethereumjs/tx/-/tx-3.5.2.tgz#197b9b6299582ad84f9527ca961466fce2296c1c" - integrity sha512-gQDNJWKrSDGu2w7w0PzVXVBNMzb7wwdDOmOqczmhNjqFxFuIbhVJDwiGEnxFNC2/b8ifcZzY7MLcluizohRzNw== - dependencies: - "@ethereumjs/common" "^2.6.4" - ethereumjs-util "^7.1.5" - -"@ethereumjs/tx@3.0.0": - version "3.0.0" - resolved "https://registry.yarnpkg.com/@ethereumjs/tx/-/tx-3.0.0.tgz#8dfd91ed6e91e63996e37b3ddc340821ebd48c81" - integrity sha512-H9tfy6qgYxPXvt1TSObfVmVjlF43OoQqoPQ3PJsG2JiuqaMHj5ettV1pGFEC3FamENDBkl6vD6niQEvIlXv/VQ== +"@ethereumjs/tx@4.1.1": + version "4.1.1" + resolved "https://registry.yarnpkg.com/@ethereumjs/tx/-/tx-4.1.1.tgz#d1b5bf2c4fd3618f2f333b66e262848530d4686a" + integrity sha512-QDj7nuROfoeyK83RObMA0XCZ+LUDdneNkSCIekO498uEKTY25FxI4Whduc/6j0wdd4IqpQvkq+/7vxSULjGIBQ== dependencies: - "@ethereumjs/common" "^2.0.0" - ethereumjs-util "^7.0.7" + "@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" -"@ethereumjs/tx@3.3.2", "@ethereumjs/tx@^3.3.2": +"@ethereumjs/tx@^3.3.2": version "3.3.2" resolved "https://registry.yarnpkg.com/@ethereumjs/tx/-/tx-3.3.2.tgz#348d4624bf248aaab6c44fec2ae67265efe3db00" integrity sha512-6AaJhwg4ucmwTvw/1qLaZUX5miWrwZ4nLOUsKyb/HtzS3BMw/CasKhdi1ims9mBKeK9sOJCH4qGKOBGyJCeeog== @@ -1852,7 +1869,15 @@ "@ethereumjs/common" "^2.5.0" ethereumjs-util "^7.1.2" -"@ethereumjs/tx@^4.1.2", "@ethereumjs/tx@^4.2.0": +"@ethereumjs/tx@^3.5.2": + version "3.5.2" + resolved "https://registry.yarnpkg.com/@ethereumjs/tx/-/tx-3.5.2.tgz#197b9b6299582ad84f9527ca961466fce2296c1c" + integrity sha512-gQDNJWKrSDGu2w7w0PzVXVBNMzb7wwdDOmOqczmhNjqFxFuIbhVJDwiGEnxFNC2/b8ifcZzY7MLcluizohRzNw== + dependencies: + "@ethereumjs/common" "^2.6.4" + ethereumjs-util "^7.1.5" + +"@ethereumjs/tx@^4.0.2", "@ethereumjs/tx@^4.1.2", "@ethereumjs/tx@^4.2.0": version "4.2.0" resolved "https://registry.yarnpkg.com/@ethereumjs/tx/-/tx-4.2.0.tgz#5988ae15daf5a3b3c815493bc6b495e76009e853" integrity sha512-1nc6VO4jtFd172BbSnTnDQVr9IYBFl1y4xPzZdtkrkKIncBCkdbgfdRV+MiTkJYAtTxvV12GRZLqBFT1PNK6Yw== @@ -1882,15 +1907,16 @@ "@ethereumjs/util" "^9.1.0" ethereum-cryptography "^2.2.1" -"@ethereumjs/util@9.0.3", "@ethereumjs/util@^9.0.3": - version "9.0.3" - resolved "https://registry.yarnpkg.com/@ethereumjs/util/-/util-9.0.3.tgz#c2709e6127a85bbe23a71937ac78358ac93e7241" - integrity sha512-PmwzWDflky+7jlZIFqiGsBPap12tk9zK5SVH9YW2OEnDN7OEhCjUOMzbOqwuClrbkSIkM2ERivd7sXZ48Rh/vg== +"@ethereumjs/util@8.0.5": + version "8.0.5" + resolved "https://registry.yarnpkg.com/@ethereumjs/util/-/util-8.0.5.tgz#b9088fc687cc13f0c1243d6133d145dfcf3fe446" + integrity sha512-259rXKK3b3D8HRVdRmlOEi6QFvwxdt304hhrEAmpZhsj7ufXEOTIc9JRZPMnXatKjECokdLNBcDOFBeBSzAIaw== dependencies: - "@ethereumjs/rlp" "^5.0.2" - ethereum-cryptography "^2.1.3" + "@chainsafe/ssz" "0.9.4" + "@ethereumjs/rlp" "^4.0.1" + ethereum-cryptography "^1.1.2" -"@ethereumjs/util@^8.0.6", "@ethereumjs/util@^8.1.0": +"@ethereumjs/util@^8.0.0", "@ethereumjs/util@^8.0.5", "@ethereumjs/util@^8.0.6", "@ethereumjs/util@^8.1.0": version "8.1.0" resolved "https://registry.yarnpkg.com/@ethereumjs/util/-/util-8.1.0.tgz#299df97fb6b034e0577ce9f94c7d9d1004409ed4" integrity sha512-zQ0IqbdX8FZ9aw11vP+dZkKDkS+kgIvQPHnSAXzP9pLu+Rfu3D3XEeLbicvoXJTYnhZiPmsZUxgdzXwNKxRPbA== @@ -1915,6 +1941,14 @@ "@ethereumjs/rlp" "^5.0.2" ethereum-cryptography "^2.1.3" +"@ethereumjs/util@^9.0.3": + version "9.0.3" + resolved "https://registry.yarnpkg.com/@ethereumjs/util/-/util-9.0.3.tgz#c2709e6127a85bbe23a71937ac78358ac93e7241" + integrity sha512-PmwzWDflky+7jlZIFqiGsBPap12tk9zK5SVH9YW2OEnDN7OEhCjUOMzbOqwuClrbkSIkM2ERivd7sXZ48Rh/vg== + dependencies: + "@ethereumjs/rlp" "^5.0.2" + ethereum-cryptography "^2.1.3" + "@ethereumjs/util@^9.1.0": version "9.1.0" resolved "https://registry.yarnpkg.com/@ethereumjs/util/-/util-9.1.0.tgz#75e3898a3116d21c135fa9e29886565609129bce" @@ -2798,7 +2832,7 @@ bech32 "1.1.4" ws "7.4.6" -"@ethersproject/providers@5.7.2": +"@ethersproject/providers@5.7.2", "@ethersproject/providers@^5.7.2": version "5.7.2" resolved "https://registry.yarnpkg.com/@ethersproject/providers/-/providers-5.7.2.tgz#f8b1a4f275d7ce58cf0a2eec222269a08beb18cb" integrity sha512-g34EWZ1WWAVgr4aptGlVBF8mhl3VWjv+8hoAnzStu8Ah22VHBsuGzP17eb6xDVRzw895G4W7vvx60lFFur/1Rg== @@ -3835,14 +3869,25 @@ "@jridgewell/resolve-uri" "^3.0.3" "@jridgewell/sourcemap-codec" "^1.4.10" -"@keystonehq/base-eth-keyring@^0.3.5-alpha.0": - version "0.3.5-alpha.0" - resolved "https://registry.yarnpkg.com/@keystonehq/base-eth-keyring/-/base-eth-keyring-0.3.5-alpha.0.tgz#e42d2e40fb83caf68cd489a94a92d42e5198ece4" - integrity sha512-bjObp+QRPBSJWEpdfnzmUumLwKoqjNgaOn5TKHizgWjtkltRCFjRnSTGA/MHBnf+afRb1AP1FZdv9Pk0ogjtEQ== +"@keystonehq/base-eth-keyring@^0.14.1": + version "0.14.1" + resolved "https://registry.yarnpkg.com/@keystonehq/base-eth-keyring/-/base-eth-keyring-0.14.1.tgz#b838524678e5d3e70c0f1e9e1089baece6ef5f87" + integrity sha512-rhsbN7YlwWEcaUcwapApZe4EC/xQFJVnU0CpzLN0r9b2nqyEp8q9oz42jPr8W6vXHD72bezAZKMvqU/6rCecQQ== dependencies: - "@ethereumjs/tx" "3.0.0" - "@keystonehq/bc-ur-registry-eth" "^0.8.1-alpha.0" - ethereumjs-util "^7.0.8" + "@ethereumjs/tx" "^4.0.2" + "@ethereumjs/util" "^8.0.0" + "@keystonehq/bc-ur-registry-eth" "^0.19.1" + hdkey "^2.0.1" + rlp "^3.0.0" + uuid "^8.3.2" + +"@keystonehq/bc-ur-registry-eth@^0.19.1": + version "0.19.1" + resolved "https://registry.yarnpkg.com/@keystonehq/bc-ur-registry-eth/-/bc-ur-registry-eth-0.19.1.tgz#eac508b9d15d17c0abd00b107691585f9c789ffc" + integrity sha512-5+skb1zsmMEIGZCbk+4KssZTpLMTriaFlt+Lc6pZLmxexXrX8a/9aHoho3asOqf7GeXXqkB9YKs8i8TN/hbaHA== + dependencies: + "@ethereumjs/util" "^8.0.0" + "@keystonehq/bc-ur-registry" "^0.6.0" hdkey "^2.0.1" uuid "^8.3.2" @@ -3874,6 +3919,15 @@ base58check "^2.0.0" tslib "^2.3.0" +"@keystonehq/bc-ur-registry@^0.6.0": + version "0.6.4" + resolved "https://registry.yarnpkg.com/@keystonehq/bc-ur-registry/-/bc-ur-registry-0.6.4.tgz#9c57ff9687cafdc0d2bbd04dc36676d3a38c1485" + integrity sha512-j8Uy44DuAkvYkbf0jMxRY3UizJfn8wsEQr7GS3miRF44vcq7k0/yemVkftbn3jQ+0JYaUXf5wY7lVpLhAeW5nQ== + dependencies: + "@ngraveio/bc-ur" "^1.1.5" + bs58check "^2.1.2" + tslib "^2.3.0" + "@keystonehq/hw-app-eth@0.4.4": version "0.4.4" resolved "https://registry.yarnpkg.com/@keystonehq/hw-app-eth/-/hw-app-eth-0.4.4.tgz#60ad49a9ae943f472b618b989357775886f1a123" @@ -3912,15 +3966,15 @@ "@keystonehq/hw-transport-error" "^0.0.2" buffer "^6.0.3" -"@keystonehq/metamask-airgapped-keyring@0.2.5-alpha.2.1": - version "0.2.5-alpha.2.1" - resolved "https://registry.yarnpkg.com/@keystonehq/metamask-airgapped-keyring/-/metamask-airgapped-keyring-0.2.5-alpha.2.1.tgz#999d80aa9a00db5485417e9cff2f4c6780032add" - integrity sha512-2w2PQ84vwznyK2u//Mt7ZeIn92qF55eodbnsz7iZCXPY33Xbk3c1CC0YCA7IHhDz3Wb9cZpWdQWn2jDh9nC1AQ== +"@keystonehq/metamask-airgapped-keyring@0.14.1": + version "0.14.1" + resolved "https://registry.yarnpkg.com/@keystonehq/metamask-airgapped-keyring/-/metamask-airgapped-keyring-0.14.1.tgz#1b797f7ad40fc908e411f201694fb31ebaa564d6" + integrity sha512-ffBa+LMkZUMj0KKW/YYoncxuUqsnBPn9xss1kHEgvva5GviylMcosbVyV2AAbtnRii1VK6wTSWzAzUdR8giq3A== dependencies: - "@ethereumjs/tx" "^3.3.0" - "@keystonehq/base-eth-keyring" "^0.3.5-alpha.0" - "@keystonehq/bc-ur-registry-eth" "^0.8.1-alpha.0" - "@metamask/obs-store" "^7.0.0" + "@ethereumjs/tx" "^4.0.2" + "@keystonehq/base-eth-keyring" "^0.14.1" + "@keystonehq/bc-ur-registry-eth" "^0.19.1" + "@metamask/obs-store" "^9.0.0" rlp "^2.2.6" uuid "^8.3.2" @@ -4122,7 +4176,19 @@ json-rpc-random-id "^1.0.0" xtend "^4.0.1" -"@metamask/eth-sig-util@5", "@metamask/eth-sig-util@5.1.0": +"@metamask/eth-sig-util@5.0.2": + version "5.0.2" + resolved "https://registry.yarnpkg.com/@metamask/eth-sig-util/-/eth-sig-util-5.0.2.tgz#c518279a6e17a88135a13d53a0b970f145ff8bce" + integrity sha512-RU6fG/H6/UlBol221uBkq5C7w3TwLK611nEZliO2u+kO0vHKGBXnIPlhI0tzKUigjhUeOd9mhCNbNvhh0LKt9Q== + dependencies: + "@ethereumjs/util" "^8.0.0" + bn.js "^4.11.8" + ethereum-cryptography "^1.1.2" + ethjs-util "^0.1.6" + tweetnacl "^1.0.3" + tweetnacl-util "^0.15.1" + +"@metamask/eth-sig-util@5.1.0": version "5.1.0" resolved "https://registry.yarnpkg.com/@metamask/eth-sig-util/-/eth-sig-util-5.1.0.tgz#a47f62800ee1917fef976ba67544a0ccd7d1bd6b" integrity sha512-mlgziIHYlA9pi/XZerChqg4NocdOgBPB9NmxgXWQO2U2hH8RGOJQrz6j/AIKkYxgCMIE2PY000+joOwXfzeTDQ== @@ -4187,13 +4253,13 @@ readable-stream "^2.2.2" through2 "^2.0.3" -"@metamask/obs-store@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@metamask/obs-store/-/obs-store-7.0.0.tgz#6cae5f28306bb3e83a381bc9ae22682316095bd3" - integrity sha512-Tr61Uu9CGXkCg5CZwOYRMQERd+y6fbtrtLd/PzDTPHO5UJpmSbU+7MPcQK7d1DwZCOCeCIvhmZSUCvYliC8uGw== +"@metamask/obs-store@^9.0.0": + version "9.1.0" + resolved "https://registry.yarnpkg.com/@metamask/obs-store/-/obs-store-9.1.0.tgz#3784f088ad9127a1d0fa073109564217a9f2785f" + integrity sha512-Ok1GreroQpV39PBYzTvEEyWrXBcjjsb8O3Q62PVHZEqDJ+8ehjBEFblX6eRTfS9vhNVHCf+GTayaFp9Bmeh1/A== dependencies: - "@metamask/safe-event-emitter" "^2.0.0" - through2 "^2.0.3" + "@metamask/safe-event-emitter" "^3.0.0" + readable-stream "^3.6.2" "@metamask/post-message-stream@8.1.0": version "8.1.0" @@ -4364,6 +4430,11 @@ resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.1.2.tgz#e9e035b9b166ca0af657a7848eb2718f0f22f183" integrity sha512-KYRCASVTv6aeUi1tsF8/vpyR7zpfs3FUzy2Jqm+MU+LmUKhQ0y2FpfwqkCcxSg2ua4GALJd8k2R76WxwZGbQpA== +"@noble/hashes@1.2.0", "@noble/hashes@~1.2.0": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.2.0.tgz#a3150eeb09cc7ab207ebf6d7b9ad311a9bdbed12" + integrity sha512-FZfhjEDbT5GRswV3C6uvLPHMiVD6lQBmpoX5+eSiPaMTXte/IKqI5dykDxzZB/WBeK/CDuQRBWarPdi3FNY2zQ== + "@noble/hashes@1.3.1": version "1.3.1" resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.1.tgz#8831ef002114670c603c458ab8b11328406953a9" @@ -4399,7 +4470,7 @@ resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.0.tgz#085fd70f6d7d9d109671090ccae1d3bec62554a1" integrity sha512-ilHEACi9DwqJB0pw7kv+Apvh50jiiSyR/cQ3y4W7lOR5mhvn/50FLUfsnfJz0BDZtl/RR16kXvptiv6q1msYZg== -"@noble/secp256k1@1.7.1": +"@noble/secp256k1@1.7.1", "@noble/secp256k1@~1.7.0": version "1.7.1" resolved "https://registry.yarnpkg.com/@noble/secp256k1/-/secp256k1-1.7.1.tgz#b251c70f824ce3ca7f8dc3df08d58f005cc0507c" integrity sha512-hOUk6AyBFmqVrv7k5WAw/LpszxVbj9gGN4JRkIX52fdFAj1UA61KXmZDvqVEm+pOyec3+fIeZB02LYa/pWOArw== @@ -4746,13 +4817,13 @@ ethereum-cryptography "^2.1.2" slip39 "^0.1.9" -"@rabby-wallet/eth-lattice-keyring@1.2.2": - version "1.2.2" - resolved "https://registry.yarnpkg.com/@rabby-wallet/eth-lattice-keyring/-/eth-lattice-keyring-1.2.2.tgz#3002cea9dbf88d56093b2b39642860134730f547" - integrity sha512-RXgnF3cs5pTp66jlq/EHtdPQcjA8LoY6I4RkQUwPrYtD17OW07WFnoo4UMrdrBEQxN3Ray1z4Pv7L/3ZfTyi2g== +"@rabby-wallet/eth-lattice-keyring@1.2.4": + version "1.2.4" + resolved "https://registry.yarnpkg.com/@rabby-wallet/eth-lattice-keyring/-/eth-lattice-keyring-1.2.4.tgz#92085eded9e4cc8b9a47e51ffbc973c2d55b0f0a" + integrity sha512-fMPahQJ8hiDiHOhFKHrHbIm34LBLQIlNHS9MOkfEUkqkEt4JBYbdQoUF85AG49Yn+Xfo08E32V+ivQgyTdzq5Q== dependencies: - "@ethereumjs/common" "2.4.0" - "@ethereumjs/tx" "3.3.2" + "@ethereumjs/tx" "4.1.1" + "@ethereumjs/util" "8.0.5" bn.js "^5.2.0" ethereumjs-util "^7.0.10" gridplus-sdk "3.2.0" @@ -4774,16 +4845,16 @@ ethereumjs-wallet "^1.0.2" randombytes "^2.1.0" -"@rabby-wallet/eth-trezor-keyring@2.6.1": - version "2.6.1" - resolved "https://registry.yarnpkg.com/@rabby-wallet/eth-trezor-keyring/-/eth-trezor-keyring-2.6.1.tgz#5a5903c62cab609c21d4aa821d8c8bad7dc87d1a" - integrity sha512-v4gxiGbLHCbqRNLukvOjt3QjFTOVGnP3fFglaLlLqa7kwyglXWdkn4YkD1zL+28X6iM5pW+pgROPM+Bu/231MQ== +"@rabby-wallet/eth-trezor-keyring@2.6.3": + version "2.6.3" + resolved "https://registry.yarnpkg.com/@rabby-wallet/eth-trezor-keyring/-/eth-trezor-keyring-2.6.3.tgz#adee5aac9aa9a3004186f8954eca0754a9dc94d3" + integrity sha512-WkjaydKljDKG1ssz6Izo1ZEGYHLSksMZW8EVCLK9+r0uPas2DWq1DcnUPE6j4zMoCAqJbUf3t56UC/+H46+JSQ== dependencies: - "@ethereumjs/tx" "3" - "@metamask/eth-sig-util" "5" + "@ethereumjs/tx" "4.1.1" + "@ethereumjs/util" "8.0.5" + "@metamask/eth-sig-util" "5.0.2" "@trezor/connect-plugin-ethereum" "^9.0.3" "@trezor/connect-web" "^9.2.1" - ethereumjs-util "^7.1.5" hdkey "0.8.0" "@rabby-wallet/eth-walletconnect-keyring@2.1.5": @@ -5138,6 +5209,15 @@ resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.1.7.tgz#fe973311a5c6267846aa131bc72e96c5d40d2b30" integrity sha512-PPNYBslrLNNUQ/Yad37MHYsNQtK67EhWb6WtSvNLLPo7SdVZgkUjD6Dg+5On7zNwmskf8OX7I7Nx5oN+MIWE0g== +"@scure/bip32@1.1.5": + version "1.1.5" + resolved "https://registry.yarnpkg.com/@scure/bip32/-/bip32-1.1.5.tgz#d2ccae16dcc2e75bc1d75f5ef3c66a338d1ba300" + integrity sha512-XyNh1rB0SkEqd3tXcXMi+Xe1fvg+kUIcoRIEujP1Jgv7DqW2r9lg3Ah0NkFaCs9sTkQAQA8kw7xiRXzENi9Rtw== + dependencies: + "@noble/hashes" "~1.2.0" + "@noble/secp256k1" "~1.7.0" + "@scure/base" "~1.1.0" + "@scure/bip32@1.3.1": version "1.3.1" resolved "https://registry.yarnpkg.com/@scure/bip32/-/bip32-1.3.1.tgz#7248aea723667f98160f593d621c47e208ccbb10" @@ -5174,6 +5254,14 @@ "@noble/hashes" "~1.5.0" "@scure/base" "~1.1.7" +"@scure/bip39@1.1.1": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@scure/bip39/-/bip39-1.1.1.tgz#b54557b2e86214319405db819c4b6a370cf340c5" + integrity sha512-t+wDck2rVkh65Hmv280fYdVdY25J9YeEUIgn2LG1WM6gxFkGzcksoDiUkWVpVp3Oex9xGC68JU2dSbUfwZ2jPg== + dependencies: + "@noble/hashes" "~1.2.0" + "@scure/base" "~1.1.0" + "@scure/bip39@1.2.1", "@scure/bip39@^1.2.1": version "1.2.1" resolved "https://registry.yarnpkg.com/@scure/bip39/-/bip39-1.2.1.tgz#5cee8978656b272a917b7871c981e0541ad6ac2a" @@ -9036,6 +9124,11 @@ capital-case@^1.0.4: tslib "^2.0.3" upper-case-first "^2.0.2" +case@^1.6.3: + version "1.6.3" + resolved "https://registry.yarnpkg.com/case/-/case-1.6.3.tgz#0a4386e3e9825351ca2e6216c60467ff5f1ea1c9" + integrity sha512-mzDSXIPaFwVDvZAHqZ9VlbyF4yyXRuX6IvB06WvPYkqJVO24kX1PPhv9bfpKNFZyxYFmmgo03HUiD8iklmJYRQ== + cashaddrjs@0.4.4: version "0.4.4" resolved "https://registry.yarnpkg.com/cashaddrjs/-/cashaddrjs-0.4.4.tgz#169f1ae620d325db77700273d972282adeeee331" @@ -11202,6 +11295,16 @@ ethereum-cryptography@^0.1.3: secp256k1 "^4.0.1" setimmediate "^1.0.5" +ethereum-cryptography@^1.1.2: + version "1.2.0" + resolved "https://registry.yarnpkg.com/ethereum-cryptography/-/ethereum-cryptography-1.2.0.tgz#5ccfa183e85fdaf9f9b299a79430c044268c9b3a" + integrity sha512-6yFQC9b5ug6/17CQpCyE3k9eKBMdhyVjzUy1WkiuY/E4vj/SXDBbCw8QEIaXqf0Mf2SnY6RmpDcwlUmBSS0EJw== + dependencies: + "@noble/hashes" "1.2.0" + "@noble/secp256k1" "1.7.1" + "@scure/bip32" "1.1.5" + "@scure/bip39" "1.1.1" + ethereum-cryptography@^2.0.0, ethereum-cryptography@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/ethereum-cryptography/-/ethereum-cryptography-2.1.2.tgz#18fa7108622e56481157a5cb7c01c0c6a672eb67" @@ -11301,17 +11404,6 @@ ethereumjs-util@^6.0.0, ethereumjs-util@^6.2.1: ethjs-util "0.1.6" rlp "^2.2.3" -ethereumjs-util@^7.0.7, ethereumjs-util@^7.1.5: - version "7.1.5" - resolved "https://registry.yarnpkg.com/ethereumjs-util/-/ethereumjs-util-7.1.5.tgz#9ecf04861e4fbbeed7465ece5f23317ad1129181" - integrity sha512-SDl5kKrQAudFBUe5OJM9Ac6WmMyYmXX/6sTmLZ3ffG2eY6ZIGBes3pEDxNN6V72WyOw4CPD5RomKdsa8DAAwLg== - dependencies: - "@types/bn.js" "^5.1.0" - bn.js "^5.1.2" - create-hash "^1.1.2" - ethereum-cryptography "^0.1.3" - rlp "^2.2.4" - ethereumjs-util@^7.0.8: version "7.1.4" resolved "https://registry.yarnpkg.com/ethereumjs-util/-/ethereumjs-util-7.1.4.tgz#a6885bcdd92045b06f596c7626c3e89ab3312458" @@ -11335,6 +11427,17 @@ ethereumjs-util@^7.0.9: ethjs-util "0.1.6" rlp "^2.2.4" +ethereumjs-util@^7.1.5: + version "7.1.5" + resolved "https://registry.yarnpkg.com/ethereumjs-util/-/ethereumjs-util-7.1.5.tgz#9ecf04861e4fbbeed7465ece5f23317ad1129181" + integrity sha512-SDl5kKrQAudFBUe5OJM9Ac6WmMyYmXX/6sTmLZ3ffG2eY6ZIGBes3pEDxNN6V72WyOw4CPD5RomKdsa8DAAwLg== + dependencies: + "@types/bn.js" "^5.1.0" + bn.js "^5.1.2" + create-hash "^1.1.2" + ethereum-cryptography "^0.1.3" + rlp "^2.2.4" + ethereumjs-wallet@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/ethereumjs-wallet/-/ethereumjs-wallet-1.0.2.tgz#2c000504b4c71e8f3782dabe1113d192522e99b6"