From f60ba798e7eb084541e8f0c0157b6e523ad27f19 Mon Sep 17 00:00:00 2001 From: Daniel Dimitrov Date: Tue, 9 Jan 2024 11:40:28 +0100 Subject: [PATCH] current progress --- package.json | 5 +- .../common/TokenAmountInput/index.tsx | 4 +- src/components/common/WalletBalance/index.tsx | 3 +- .../useEstimateSafeCreationGas.test.ts | 2 +- .../new-safe/create/logic/index.test.ts | 2 +- src/components/new-safe/create/logic/index.ts | 11 +- .../create/steps/ReviewStep/index.tsx | 6 +- .../__tests__/useSafeCreation.test.ts | 2 +- .../steps/StatusStep/useSafeCreation.ts | 2 +- .../settings/PushNotifications/logic.ts | 6 +- .../__tests__/SafeModules.test.tsx | 6 +- .../__tests__/TransactionGuards.test.tsx | 4 +- .../TxDetails/Summary/TxDataRow/index.tsx | 4 +- .../TxData/Transfer/TransferActions.tsx | 2 +- .../flows/ExecuteBatch/ReviewBatch.tsx | 6 +- .../tx-flow/flows/NewSpendingLimit/index.tsx | 2 +- .../RecoverAccountFlowReview.tsx | 2 +- .../flows/SignMessage/SignMessage.test.tsx | 32 +- .../ReviewSignMessageOnChain.test.tsx | 150 +++++---- .../ReviewSignMessageOnChain.tsx | 22 +- .../TokenTransfer/CreateTokenTransfer.tsx | 6 +- .../TokenTransfer/ReviewSpendingLimitTx.tsx | 2 +- .../__tests__/CreateTokenTransfer.test.tsx | 2 +- .../tx-flow/flows/TokenTransfer/index.tsx | 2 +- .../tx/ApprovalEditor/ApprovalEditorForm.tsx | 2 +- .../hooks/useApprovalInfos.test.ts | 24 +- .../ApprovalEditor/hooks/useApprovalInfos.ts | 6 +- src/components/tx/ApprovalEditor/index.tsx | 2 +- .../tx/ApprovalEditor/utils/approvals.ts | 2 +- src/components/tx/DecodedTx/index.test.tsx | 2 +- .../tx/GasParams/GasParams.test.tsx | 1 + src/components/tx/GasParams/index.tsx | 2 +- .../tx/SignOrExecuteForm/hooks.test.ts | 72 ++-- src/components/tx/SignOrExecuteForm/hooks.ts | 2 +- .../security/tenderly/__tests__/utils.test.ts | 50 +-- src/components/tx/security/tenderly/utils.ts | 10 +- .../components/RecoveryDetails/index.tsx | 6 +- .../components/RecoverySettings/index.tsx | 4 +- .../components/RecoverySigners/index.tsx | 2 +- .../recovery/hooks/useRecoveryTxState.ts | 10 +- .../services/__tests__/recovery-state.test.ts | 74 ++-- .../recovery/services/__tests__/setup.test.ts | 2 +- .../__tests__/transaction-list.test.ts | 4 +- .../services/__tests__/transaction.test.ts | 2 +- .../recovery/services/delay-modifier.ts | 2 +- .../recovery/services/recovery-state.ts | 34 +- src/features/recovery/services/selectors.ts | 2 +- src/features/recovery/services/setup.ts | 6 +- .../recovery/services/transaction-list.ts | 6 +- src/features/recovery/services/transaction.ts | 2 +- .../__tests__/useAddressResolver.test.ts | 4 +- .../__tests__/useLoadSpendingLimits.test.ts | 2 +- .../__tests__/useSafeTokenAllocation.test.ts | 4 +- .../coreSDK/__tests__/safeCoreSDK.test.ts | 14 +- .../__tests__/useInitSafeCoreSDK.test.ts | 2 +- src/hooks/coreSDK/safeCoreSDK.ts | 22 +- src/hooks/loadables/useLoadSpendingLimits.ts | 2 +- src/hooks/useGasLimit.ts | 2 +- src/hooks/useGasPrice.ts | 8 +- src/hooks/useSafeTokenAllocation.ts | 11 +- src/hooks/useVisibleBalances.ts | 4 +- src/hooks/useWalletCanPay.ts | 2 +- src/hooks/wallets/useWalletBalance.ts | 8 +- src/hooks/wallets/web3.ts | 14 +- src/services/contracts/safeContracts.ts | 50 ++- src/services/ens/custom.ts | 10 +- .../__tests__/safeMsgSender.test.ts | 47 +-- .../RecipientAddressModule/index.test.ts | 87 ++--- .../modules/RecipientAddressModule/index.ts | 2 +- .../tx/__tests__/safeUpdateParams.test.ts | 6 +- .../tx/__tests__/spendingLimitParams.test.ts | 4 +- src/services/tx/encodeSignatures.ts | 2 +- .../tx/tx-sender/__tests__/ts-sender.test.ts | 31 +- src/services/tx/tx-sender/create.ts | 4 +- src/services/tx/tx-sender/dispatch.ts | 7 +- src/services/tx/tx-sender/sdk.ts | 15 +- src/tests/builders/safeTx.ts | 2 +- src/tests/test-utils.tsx | 4 +- src/tests/transactions.ts | 8 +- src/utils/__tests__/safe-messages.test.ts | 4 +- src/utils/ethers-utils.ts | 8 + src/utils/safe-messages.ts | 2 +- tsconfig.json | 2 +- yarn.lock | 315 ++++++++++++++++-- 84 files changed, 820 insertions(+), 505 deletions(-) diff --git a/package.json b/package.json index f806f413ea..88a84cd035 100644 --- a/package.json +++ b/package.json @@ -50,8 +50,9 @@ "@mui/material": "^5.14.20", "@mui/x-date-pickers": "^5.0.20", "@reduxjs/toolkit": "^1.9.5", + "@safe-global/api-kit": "^2.0.0", + "@safe-global/protocol-kit": "^2.0.0", "@safe-global/safe-apps-sdk": "^9.0.0-next.1", - "@safe-global/safe-core-sdk": "^3.3.5", "@safe-global/safe-core-sdk-utils": "^1.7.4", "@safe-global/safe-deployments": "1.28.0", "@safe-global/safe-ethers-lib": "^1.9.4", @@ -100,7 +101,7 @@ "@faker-js/faker": "^8.1.0", "@next/bundle-analyzer": "^13.5.6", "@openzeppelin/contracts": "^4.9.2", - "@safe-global/safe-core-sdk-types": "^1.9.1", + "@safe-global/safe-core-sdk-types": "^3.0.1", "@sentry/types": "^7.74.0", "@svgr/webpack": "^6.3.1", "@testing-library/cypress": "^8.0.7", diff --git a/src/components/common/TokenAmountInput/index.tsx b/src/components/common/TokenAmountInput/index.tsx index 274ba6c7d4..660fe434aa 100644 --- a/src/components/common/TokenAmountInput/index.tsx +++ b/src/components/common/TokenAmountInput/index.tsx @@ -23,7 +23,7 @@ const TokenAmountInput = ({ }: { balances: SafeBalanceResponse['items'] selectedToken: SafeBalanceResponse['items'][number] | undefined - maxAmount?: BigNumber + maxAmount?: bigint validate?: (value: string) => string | undefined }) => { const { @@ -63,7 +63,7 @@ const TokenAmountInput = ({ variant="standard" InputProps={{ disableUnderline: true, - endAdornment: maxAmount && ( + endAdornment: Number(maxAmount) && ( diff --git a/src/components/common/WalletBalance/index.tsx b/src/components/common/WalletBalance/index.tsx index 6feccf6798..8a8976cede 100644 --- a/src/components/common/WalletBalance/index.tsx +++ b/src/components/common/WalletBalance/index.tsx @@ -1,9 +1,8 @@ import { formatVisualAmount } from '@/utils/formatters' import { Skeleton } from '@mui/material' -import { type BigNumber } from 'ethers' import { useCurrentChain } from '@/hooks/useChains' -const WalletBalance = ({ balance }: { balance: string | BigNumber | undefined }) => { +const WalletBalance = ({ balance }: { balance: string | bigint | undefined }) => { const currentChain = useCurrentChain() if (!balance) { diff --git a/src/components/new-safe/create/__tests__/useEstimateSafeCreationGas.test.ts b/src/components/new-safe/create/__tests__/useEstimateSafeCreationGas.test.ts index 94532fb3b0..98bb07dd75 100644 --- a/src/components/new-safe/create/__tests__/useEstimateSafeCreationGas.test.ts +++ b/src/components/new-safe/create/__tests__/useEstimateSafeCreationGas.test.ts @@ -8,7 +8,7 @@ import * as safeContracts from '@/services/contracts/safeContracts' import * as store from '@/store' import { renderHook } from '@/tests/test-utils' import { JsonRpcProvider } from '@ethersproject/providers' -import { EMPTY_DATA, ZERO_ADDRESS } from '@safe-global/safe-core-sdk/dist/src/utils/constants' +import { EMPTY_DATA, ZERO_ADDRESS } from '@safe-global/protocol-kit/dist/src/utils/constants' import type GnosisSafeProxyFactoryEthersContract from '@safe-global/safe-ethers-lib/dist/src/contracts/GnosisSafeProxyFactory/GnosisSafeProxyFactoryEthersContract' import { waitFor } from '@testing-library/react' import { type EIP1193Provider } from '@web3-onboard/core' diff --git a/src/components/new-safe/create/logic/index.test.ts b/src/components/new-safe/create/logic/index.test.ts index ef2d061476..5501fd5ee3 100644 --- a/src/components/new-safe/create/logic/index.test.ts +++ b/src/components/new-safe/create/logic/index.test.ts @@ -1,5 +1,5 @@ import { JsonRpcProvider, type TransactionResponse, Web3Provider } from '@ethersproject/providers' -import { EMPTY_DATA, ZERO_ADDRESS } from '@safe-global/safe-core-sdk/dist/src/utils/constants' +import { EMPTY_DATA, ZERO_ADDRESS } from '@safe-global/protocol-kit/dist/src/utils/constants' import * as web3 from '@/hooks/wallets/web3' import type { TransactionReceipt } from '@ethersproject/abstract-provider' import { diff --git a/src/components/new-safe/create/logic/index.ts b/src/components/new-safe/create/logic/index.ts index 6c0bc8d863..db386ef856 100644 --- a/src/components/new-safe/create/logic/index.ts +++ b/src/components/new-safe/create/logic/index.ts @@ -18,14 +18,15 @@ import { AppRoutes } from '@/config/routes' import { SAFE_APPS_EVENTS, trackEvent } from '@/services/analytics' import type { AppDispatch, AppThunk } from '@/store' import { showNotification } from '@/store/notificationsSlice' -import { SafeFactory } from '@safe-global/safe-core-sdk' -import type Safe from '@safe-global/safe-core-sdk' -import type { DeploySafeProps } from '@safe-global/safe-core-sdk' +import { SafeFactory } from '@safe-global/protocol-kit' +import type Safe from '@safe-global/protocol-kit' +import type { DeploySafeProps } from '@safe-global/protocol-kit' import { createEthersAdapter } from '@/hooks/coreSDK/safeCoreSDK' -import type { PredictSafeProps } from '@safe-global/safe-core-sdk/dist/src/safeFactory' +import type { PredictSafeProps } from '@safe-global/protocol-kit/dist/src/safeFactory' + import { backOff } from 'exponential-backoff' import { LATEST_SAFE_VERSION } from '@/config/constants' -import { EMPTY_DATA, ZERO_ADDRESS } from '@safe-global/safe-core-sdk/dist/src/utils/constants' +import { EMPTY_DATA, ZERO_ADDRESS } from '@safe-global/protocol-kit/dist/src/utils/constants' import { formatError } from '@/utils/formatters' import { sponsoredCall } from '@/services/tx/relaying' diff --git a/src/components/new-safe/create/steps/ReviewStep/index.tsx b/src/components/new-safe/create/steps/ReviewStep/index.tsx index eaf0807434..2150fe01c9 100644 --- a/src/components/new-safe/create/steps/ReviewStep/index.tsx +++ b/src/components/new-safe/create/steps/ReviewStep/index.tsx @@ -131,11 +131,11 @@ const ReviewStep = ({ data, onSubmit, onBack, setStep }: StepRenderProps 0.001' diff --git a/src/components/new-safe/create/steps/StatusStep/__tests__/useSafeCreation.test.ts b/src/components/new-safe/create/steps/StatusStep/__tests__/useSafeCreation.test.ts index 6a37f91de4..1ef8f94e11 100644 --- a/src/components/new-safe/create/steps/StatusStep/__tests__/useSafeCreation.test.ts +++ b/src/components/new-safe/create/steps/StatusStep/__tests__/useSafeCreation.test.ts @@ -11,7 +11,7 @@ import { JsonRpcProvider, Web3Provider } from '@ethersproject/providers' import type { ConnectedWallet } from '@/hooks/wallets/useOnboard' import { chainBuilder } from '@/tests/builders/chains' import { waitFor } from '@testing-library/react' -import type Safe from '@safe-global/safe-core-sdk' +import type Safe from '@safe-global/protocol-kit' import { hexZeroPad } from '@ethersproject/bytes' import type CompatibilityFallbackHandlerEthersContract from '@safe-global/safe-ethers-lib/dist/src/contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerEthersContract' import { FEATURES } from '@safe-global/safe-gateway-typescript-sdk' diff --git a/src/components/new-safe/create/steps/StatusStep/useSafeCreation.ts b/src/components/new-safe/create/steps/StatusStep/useSafeCreation.ts index 883dc9695f..ddbabca6d7 100644 --- a/src/components/new-safe/create/steps/StatusStep/useSafeCreation.ts +++ b/src/components/new-safe/create/steps/StatusStep/useSafeCreation.ts @@ -24,7 +24,7 @@ import { waitForCreateSafeTx } from '@/services/tx/txMonitor' import useGasPrice from '@/hooks/useGasPrice' import { hasFeature } from '@/utils/chains' import { FEATURES } from '@safe-global/safe-gateway-typescript-sdk' -import type { DeploySafeProps } from '@safe-global/safe-core-sdk' +import type { DeploySafeProps } from '@safe-global/protocol-kit' import { usePendingSafe } from './usePendingSafe' export enum SafeCreationStatus { diff --git a/src/components/settings/PushNotifications/logic.ts b/src/components/settings/PushNotifications/logic.ts index 913f35b6d6..16afe16359 100644 --- a/src/components/settings/PushNotifications/logic.ts +++ b/src/components/settings/PushNotifications/logic.ts @@ -1,4 +1,5 @@ -import { arrayify, joinSignature, keccak256, splitSignature, toUtf8Bytes } from 'ethers' +import { getBytes, keccak256, toUtf8Bytes } from 'ethers' +import { joinSignature, splitSignature } from '@/utils/ethers-utils' import { getToken, getMessaging } from 'firebase/messaging' import { DeviceType } from '@safe-global/safe-gateway-typescript-sdk' import type { RegisterNotificationsRequest } from '@safe-global/safe-gateway-typescript-sdk' @@ -41,6 +42,7 @@ export const requestNotificationPermission = async (): Promise => { export const _adjustLedgerSignatureV = (signature: string): string => { const split = splitSignature(signature) + // @ts-ignore if (split.v === 0 || split.v === 1) { split.v += 27 } @@ -74,7 +76,7 @@ const getSafeRegistrationSignature = async ({ const message = MESSAGE_PREFIX + timestamp + uuid + token + safeAddresses.sort().join('') const hashedMessage = keccak256(toUtf8Bytes(message)) - const signature = await web3.getSigner().signMessage(arrayify(hashedMessage)) + const signature = await web3.getSigner().signMessage(getBytes(hashedMessage)) if (!isLedger) { return signature diff --git a/src/components/settings/SafeModules/__tests__/SafeModules.test.tsx b/src/components/settings/SafeModules/__tests__/SafeModules.test.tsx index e991d4f1e8..f0204108a6 100644 --- a/src/components/settings/SafeModules/__tests__/SafeModules.test.tsx +++ b/src/components/settings/SafeModules/__tests__/SafeModules.test.tsx @@ -2,10 +2,10 @@ import { render, waitFor } from '@/tests/test-utils' import * as useSafeInfoHook from '@/hooks/useSafeInfo' import SafeModules from '..' import type { AddressEx, SafeInfo } from '@safe-global/safe-gateway-typescript-sdk' -import { ethers } from 'ethers' +import { zeroPadValue } from 'ethers' -const MOCK_MODULE_1 = ethers.utils.hexZeroPad('0x1', 20) -const MOCK_MODULE_2 = ethers.utils.hexZeroPad('0x2', 20) +const MOCK_MODULE_1 = zeroPadValue('0x01', 20) +const MOCK_MODULE_2 = zeroPadValue('0x02', 20) describe('SafeModules', () => { it('should render placeholder label without any modules', async () => { diff --git a/src/components/settings/TransactionGuards/__tests__/TransactionGuards.test.tsx b/src/components/settings/TransactionGuards/__tests__/TransactionGuards.test.tsx index 53301ef0ec..15e7b4b0b0 100644 --- a/src/components/settings/TransactionGuards/__tests__/TransactionGuards.test.tsx +++ b/src/components/settings/TransactionGuards/__tests__/TransactionGuards.test.tsx @@ -1,10 +1,10 @@ import { render, waitFor } from '@/tests/test-utils' import * as useSafeInfoHook from '@/hooks/useSafeInfo' import type { SafeInfo } from '@safe-global/safe-gateway-typescript-sdk' -import { ethers } from 'ethers' +import { zeroPadValue } from 'ethers' import TransactionGuards from '..' -const MOCK_GUARD = ethers.utils.hexZeroPad('0x1', 20) +const MOCK_GUARD = zeroPadValue('0x01', 20) const EMPTY_LABEL = 'No transaction guard set' describe('TransactionGuards', () => { diff --git a/src/components/transactions/TxDetails/Summary/TxDataRow/index.tsx b/src/components/transactions/TxDetails/Summary/TxDataRow/index.tsx index 7abed53d96..cfb208a1bc 100644 --- a/src/components/transactions/TxDetails/Summary/TxDataRow/index.tsx +++ b/src/components/transactions/TxDetails/Summary/TxDataRow/index.tsx @@ -3,7 +3,7 @@ import type { AddressEx } from '@safe-global/safe-gateway-typescript-sdk' import CopyButton from '@/components/common/CopyButton' import { HexEncodedData } from '@/components/transactions/HexEncodedData' import { Typography } from '@mui/material' -import { hexDataLength } from 'ethers' +import { dataLength } from 'ethers' import css from './styles.module.css' import EthHashInfo from '@/components/common/EthHashInfo' @@ -58,7 +58,7 @@ export const generateDataRowValue = ( case 'rawData': return (
-
{value ? hexDataLength(value) : 0} bytes
+
{value ? dataLength(value) : 0} bytes
) diff --git a/src/components/transactions/TxDetails/TxData/Transfer/TransferActions.tsx b/src/components/transactions/TxDetails/TxData/Transfer/TransferActions.tsx index db7210908b..3dac032a8b 100644 --- a/src/components/transactions/TxDetails/TxData/Transfer/TransferActions.tsx +++ b/src/components/transactions/TxDetails/TxData/Transfer/TransferActions.tsx @@ -10,7 +10,7 @@ import EntryDialog from '@/components/address-book/EntryDialog' import ContextMenu from '@/components/common/ContextMenu' import { TokenTransferFlow } from '@/components/tx-flow/flows' import type { Transfer } from '@safe-global/safe-gateway-typescript-sdk' -import { ZERO_ADDRESS } from '@safe-global/safe-core-sdk/dist/src/utils/constants' +import { ZERO_ADDRESS } from '@safe-global/protocol-kit/dist/src/utils/constants' import { isERC20Transfer, isNativeTokenTransfer, isOutgoingTransfer } from '@/utils/transaction-guards' import { trackEvent, TX_LIST_EVENTS } from '@/services/analytics' import { safeFormatUnits } from '@/utils/formatters' diff --git a/src/components/tx-flow/flows/ExecuteBatch/ReviewBatch.tsx b/src/components/tx-flow/flows/ExecuteBatch/ReviewBatch.tsx index 1d07309421..69dc0c509d 100644 --- a/src/components/tx-flow/flows/ExecuteBatch/ReviewBatch.tsx +++ b/src/components/tx-flow/flows/ExecuteBatch/ReviewBatch.tsx @@ -5,7 +5,7 @@ import type { TransactionDetails } from '@safe-global/safe-gateway-typescript-sd import { getReadOnlyMultiSendCallOnlyContract } from '@/services/contracts/safeContracts' import { useCurrentChain } from '@/hooks/useChains' import useSafeInfo from '@/hooks/useSafeInfo' -import { encodeMultiSendData } from '@safe-global/safe-core-sdk/dist/src/utils/transactions/utils' +import { encodeMultiSendData } from '@safe-global/protocol-kit/dist/src/utils/transactions/utils' import { useState, useMemo, useContext } from 'react' import type { SyntheticEvent } from 'react' import { generateDataRowValue } from '@/components/transactions/TxDetails/Summary/TxDataRow' @@ -30,7 +30,7 @@ import commonCss from '@/components/tx-flow/common/styles.module.css' import { TxModalContext } from '@/components/tx-flow' import useGasPrice from '@/hooks/useGasPrice' import { hasFeature } from '@/utils/chains' -import type { PayableOverrides } from 'ethers' +import type { Overrides } from 'ethers' import { trackEvent } from '@/services/analytics' import { TX_EVENTS, TX_TYPES } from '@/services/analytics/events/transactions' @@ -77,7 +77,7 @@ export const ReviewBatch = ({ params }: { params: ExecuteBatchFlowProps }) => { const onExecute = async () => { if (!onboard || !multiSendTxData || !multiSendContract || !txsWithDetails || !gasPrice) return - const overrides: PayableOverrides = isEIP1559 + const overrides: Overrides = isEIP1559 ? { maxFeePerGas: maxFeePerGas?.toString(), maxPriorityFeePerGas: maxPriorityFeePerGas?.toString() } : { gasPrice: maxFeePerGas?.toString() } diff --git a/src/components/tx-flow/flows/NewSpendingLimit/index.tsx b/src/components/tx-flow/flows/NewSpendingLimit/index.tsx index aaea462271..007b24f183 100644 --- a/src/components/tx-flow/flows/NewSpendingLimit/index.tsx +++ b/src/components/tx-flow/flows/NewSpendingLimit/index.tsx @@ -3,7 +3,7 @@ import useTxStepper from '../../useTxStepper' import { CreateSpendingLimit } from './CreateSpendingLimit' import { ReviewSpendingLimit } from './ReviewSpendingLimit' import SaveAddressIcon from '@/public/images/common/save-address.svg' -import { ZERO_ADDRESS } from '@safe-global/safe-core-sdk/dist/src/utils/constants' +import { ZERO_ADDRESS } from '@safe-global/protocol-kit/dist/src/utils/constants' import { TokenAmountFields } from '@/components/common/TokenAmountInput' enum Fields { diff --git a/src/components/tx-flow/flows/RecoverAccount/RecoverAccountFlowReview.tsx b/src/components/tx-flow/flows/RecoverAccount/RecoverAccountFlowReview.tsx index 390488cc52..7cc1077ccd 100644 --- a/src/components/tx-flow/flows/RecoverAccount/RecoverAccountFlowReview.tsx +++ b/src/components/tx-flow/flows/RecoverAccount/RecoverAccountFlowReview.tsx @@ -156,7 +156,7 @@ export function RecoverAccountFlowReview({ params }: { params: RecoverAccountFlo {recovery?.delay && ( Recovery will be{' '} - {recovery.delay.isZero() ? 'immediately possible' : `possible in ${getPeriod(recovery.delay.toNumber())}`}{' '} + {recovery.delay === 0n ? 'immediately possible' : `possible in ${getPeriod(Number(recovery.delay))}`}{' '} after this transaction is executed. )} diff --git a/src/components/tx-flow/flows/SignMessage/SignMessage.test.tsx b/src/components/tx-flow/flows/SignMessage/SignMessage.test.tsx index 9c633df5f7..1d93175fca 100644 --- a/src/components/tx-flow/flows/SignMessage/SignMessage.test.tsx +++ b/src/components/tx-flow/flows/SignMessage/SignMessage.test.tsx @@ -1,4 +1,4 @@ -import { hexlify, hexZeroPad, toUtf8Bytes } from 'ethers' +import { hexlify, zeroPadValue, toUtf8Bytes } from 'ethers' import type { SafeInfo, SafeMessage, SafeMessageListPage } from '@safe-global/safe-gateway-typescript-sdk' import { SafeMessageListItemType } from '@safe-global/safe-gateway-typescript-sdk' @@ -98,12 +98,12 @@ describe('SignMessage', () => { safe: { version: '1.3.0', address: { - value: hexZeroPad('0x1', 20), + value: zeroPadValue('0x01', 20), }, chainId: '5', threshold: 2, } as SafeInfo, - safeAddress: hexZeroPad('0x1', 20), + safeAddress: zeroPadValue('0x01', 20), safeError: undefined, safeLoading: false, safeLoaded: true, @@ -237,7 +237,7 @@ describe('SignMessage', () => { confirmations: [ { owner: { - value: hexZeroPad('0x2', 20), + value: zeroPadValue('0x02', 20), }, }, ], @@ -258,7 +258,7 @@ describe('SignMessage', () => { safe: { version: '1.3.0', address: { - value: hexZeroPad('0x1', 20), + value: zeroPadValue('0x01', 20), }, chainId: '5', threshold: 2, @@ -280,7 +280,7 @@ describe('SignMessage', () => { jest.spyOn(useWalletHook, 'default').mockImplementation( () => ({ - address: hexZeroPad('0x3', 20), + address: zeroPadValue('0x03', 20), } as ConnectedWallet), ) @@ -289,7 +289,7 @@ describe('SignMessage', () => { { version: '1.3.0', address: { - value: hexZeroPad('0x1', 20), + value: zeroPadValue('0x01', 20), }, chainId: '5', } as SafeInfo, @@ -301,7 +301,7 @@ describe('SignMessage', () => { confirmations: [ { owner: { - value: hexZeroPad('0x2', 20), + value: zeroPadValue('0x02', 20), }, }, ], @@ -343,12 +343,12 @@ describe('SignMessage', () => { confirmations: [ { owner: { - value: hexZeroPad('0x2', 20), + value: zeroPadValue('0x02', 20), }, }, { owner: { - value: hexZeroPad('0x3', 20), + value: zeroPadValue('0x03', 20), }, }, ], @@ -366,7 +366,7 @@ describe('SignMessage', () => { safe: { version: '1.3.0', address: { - value: hexZeroPad('0x1', 20), + value: zeroPadValue('0x01', 20), }, chainId: '5', threshold: 2, @@ -423,7 +423,7 @@ describe('SignMessage', () => { jest.spyOn(useWalletHook, 'default').mockImplementation( () => ({ - address: hexZeroPad('0x7', 20), + address: zeroPadValue('0x07', 20), } as ConnectedWallet), ) jest.spyOn(useIsSafeOwnerHook, 'default').mockImplementation(() => false) @@ -451,7 +451,7 @@ describe('SignMessage', () => { jest.spyOn(useWalletHook, 'default').mockImplementation( () => ({ - address: hexZeroPad('0x2', 20), + address: zeroPadValue('0x02', 20), } as ConnectedWallet), ) const messageText = 'Hello world!' @@ -459,7 +459,7 @@ describe('SignMessage', () => { { version: '1.3.0', address: { - value: hexZeroPad('0x1', 20), + value: zeroPadValue('0x01', 20), }, chainId: '5', } as SafeInfo, @@ -471,7 +471,7 @@ describe('SignMessage', () => { confirmations: [ { owner: { - value: hexZeroPad('0x2', 20), + value: zeroPadValue('0x02', 20), }, }, ], @@ -509,7 +509,7 @@ describe('SignMessage', () => { jest.spyOn(useWalletHook, 'default').mockImplementation( () => ({ - address: hexZeroPad('0x3', 20), + address: zeroPadValue('0x03', 20), } as ConnectedWallet), ) diff --git a/src/components/tx-flow/flows/SignMessageOnChain/ReviewSignMessageOnChain.test.tsx b/src/components/tx-flow/flows/SignMessageOnChain/ReviewSignMessageOnChain.test.tsx index b53654b189..e54c2a515d 100644 --- a/src/components/tx-flow/flows/SignMessageOnChain/ReviewSignMessageOnChain.test.tsx +++ b/src/components/tx-flow/flows/SignMessageOnChain/ReviewSignMessageOnChain.test.tsx @@ -1,89 +1,107 @@ import { Methods } from '@safe-global/safe-apps-sdk' import * as web3 from '@/hooks/wallets/web3' import * as useSafeInfo from '@/hooks/useSafeInfo' -import { Web3Provider } from '@ethersproject/providers' +import { Web3Provider, JsonRpcProvider } from '@ethersproject/providers' import { render, screen } from '@/tests/test-utils' import { SafeAppAccessPolicyTypes } from '@safe-global/safe-gateway-typescript-sdk' import ReviewSignMessageOnChain from '@/components/tx-flow/flows/SignMessageOnChain/ReviewSignMessageOnChain' -import { hexZeroPad } from '@ethersproject/bytes' +import { zeroPadValue } from 'ethers' +import {act} from '@testing-library/react' + +jest.mock('@safe-global/protocol-kit', () => { + const originalModule = jest.requireActual('@safe-global/protocol-kit'); + + // Mock class + class MockEthersAdapter extends originalModule.EthersAdapter { + getChainId = jest.fn().mockImplementation(() => Promise.resolve(BigInt(1))); + } + + return { + ...originalModule, + EthersAdapter: MockEthersAdapter, + }; +}); describe('ReviewSignMessageOnChain', () => { - test('can handle messages with EIP712Domain type in the JSON-RPC payload', () => { + test.only('can handle messages with EIP712Domain type in the JSON-RPC payload', async () => { jest.spyOn(web3, 'getWeb3ReadOnly').mockImplementation(() => new Web3Provider(jest.fn())) jest.spyOn(useSafeInfo, 'default').mockImplementation( () => ({ safe: { address: { - value: hexZeroPad('0x1', 20), + value: zeroPadValue('0x01', 20), }, version: '1.3.0', } as ReturnType['safe'], } as ReturnType), ) - render( - , - ) + await act(async () => { + render( + , + ) + }) + expect(screen.getByText('Interact with SignMessageLib')).toBeInTheDocument() }) diff --git a/src/components/tx-flow/flows/SignMessageOnChain/ReviewSignMessageOnChain.tsx b/src/components/tx-flow/flows/SignMessageOnChain/ReviewSignMessageOnChain.tsx index 1b8440d208..258abd01d4 100644 --- a/src/components/tx-flow/flows/SignMessageOnChain/ReviewSignMessageOnChain.tsx +++ b/src/components/tx-flow/flows/SignMessageOnChain/ReviewSignMessageOnChain.tsx @@ -1,7 +1,7 @@ import type { ReactElement } from 'react' -import { useContext, useEffect } from 'react' +import { useContext, useEffect, useState } from 'react' import { useMemo } from 'react' -import { hashMessage, _TypedDataEncoder } from 'ethers' +import { hashMessage, TypedDataEncoder } from 'ethers' import { Box } from '@mui/system' import { Typography, SvgIcon } from '@mui/material' import WarningIcon from '@/public/images/notifications/warning.svg' @@ -26,6 +26,7 @@ import { type SafeAppData } from '@safe-global/safe-gateway-typescript-sdk' import { SafeTxContext } from '@/components/tx-flow/SafeTxProvider' import { asError } from '@/services/exceptions/utils' import { isEIP712TypedData } from '@/utils/safe-messages' +import useAsync from '@/hooks/useAsync' export type SignMessageOnChainProps = { app?: SafeAppData @@ -39,17 +40,22 @@ const ReviewSignMessageOnChain = ({ message, method, requestId }: SignMessageOnC const { safe } = useSafeInfo() const onboard = useOnboard() const { safeTx, setSafeTx, setSafeTxError } = useContext(SafeTxContext) - useHighlightHiddenTab() const isTextMessage = method === Methods.signMessage && typeof message === 'string' const isTypedMessage = method === Methods.signTypedMessage && isEIP712TypedData(message) - const readOnlySignMessageLibContract = useMemo( - () => getReadOnlySignMessageLibContract(chainId, safe.version), + const [readOnlySignMessageLibContract] = useAsync( + async () => getReadOnlySignMessageLibContract(chainId, safe.version), [chainId, safe.version], ) - const signMessageAddress = readOnlySignMessageLibContract.getAddress() + + const [signMessageAddress, setSignMessageAddress] = useState("") + + useEffect(() => { + if (!readOnlySignMessageLibContract) return + readOnlySignMessageLibContract.getAddress().then(setSignMessageAddress) + }, [readOnlySignMessageLibContract]) const [decodedMessage, readableMessage] = useMemo(() => { if (isTextMessage) { @@ -64,6 +70,8 @@ const ReviewSignMessageOnChain = ({ message, method, requestId }: SignMessageOnC useEffect(() => { let txData + if (!readOnlySignMessageLibContract) return + if (isTextMessage) { txData = readOnlySignMessageLibContract.encode('signMessage', [hashMessage(getDecodedMessage(message))]) } else if (isTypedMessage) { @@ -76,7 +84,7 @@ const ReviewSignMessageOnChain = ({ message, method, requestId }: SignMessageOnC delete typesCopy.EIP712Domain txData = readOnlySignMessageLibContract.encode('signMessage', [ // @ts-ignore - _TypedDataEncoder.hash(message.domain, typesCopy, message.message), + TypedDataEncoder.hash(message.domain, typesCopy, message.message), ]) } diff --git a/src/components/tx-flow/flows/TokenTransfer/CreateTokenTransfer.tsx b/src/components/tx-flow/flows/TokenTransfer/CreateTokenTransfer.tsx index c76fff0cac..f312db8aaf 100644 --- a/src/components/tx-flow/flows/TokenTransfer/CreateTokenTransfer.tsx +++ b/src/components/tx-flow/flows/TokenTransfer/CreateTokenTransfer.tsx @@ -88,14 +88,14 @@ export const CreateTokenTransfer = ({ const isSpendingLimitType = type === TokenTransferType.spendingLimit - const maxAmount = isSpendingLimitType && totalAmount.gt(spendingLimitAmount) ? spendingLimitAmount : totalAmount + const maxAmount = isSpendingLimitType && totalAmount > spendingLimitAmount ? spendingLimitAmount : totalAmount const isSafeTokenSelected = sameAddress(safeTokenAddress, tokenAddress) const isDisabled = isSafeTokenSelected && isSafeTokenPaused const isAddressValid = !!recipient && !errors[TokenTransferFields.recipient] useEffect(() => { - setNonceNeeded(!isSpendingLimitType || spendingLimitAmount.eq(0)) + setNonceNeeded(!isSpendingLimitType || spendingLimitAmount === 0n) }, [setNonceNeeded, isSpendingLimitType, spendingLimitAmount]) return ( @@ -121,7 +121,7 @@ export const CreateTokenTransfer = ({ )} - {!disableSpendingLimit && spendingLimitAmount.gt(0) && ( + {!disableSpendingLimit && spendingLimitAmount > 0n && ( diff --git a/src/components/tx-flow/flows/TokenTransfer/ReviewSpendingLimitTx.tsx b/src/components/tx-flow/flows/TokenTransfer/ReviewSpendingLimitTx.tsx index 7737966647..eca55a5198 100644 --- a/src/components/tx-flow/flows/TokenTransfer/ReviewSpendingLimitTx.tsx +++ b/src/components/tx-flow/flows/TokenTransfer/ReviewSpendingLimitTx.tsx @@ -10,7 +10,7 @@ import useSpendingLimit from '@/hooks/useSpendingLimit' import useSpendingLimitGas from '@/hooks/useSpendingLimitGas' import AdvancedParams, { useAdvancedParams } from '@/components/tx/AdvancedParams' import { parseUnits } from '@ethersproject/units' -import { EMPTY_DATA, ZERO_ADDRESS } from '@safe-global/safe-core-sdk/dist/src/utils/constants' +import { EMPTY_DATA, ZERO_ADDRESS } from '@safe-global/protocol-kit/dist/src/utils/constants' import useSafeInfo from '@/hooks/useSafeInfo' import { Errors, logError } from '@/services/exceptions' import ErrorMessage from '@/components/tx/ErrorMessage' diff --git a/src/components/tx-flow/flows/TokenTransfer/__tests__/CreateTokenTransfer.test.tsx b/src/components/tx-flow/flows/TokenTransfer/__tests__/CreateTokenTransfer.test.tsx index 584d583f22..af351c4fa9 100644 --- a/src/components/tx-flow/flows/TokenTransfer/__tests__/CreateTokenTransfer.test.tsx +++ b/src/components/tx-flow/flows/TokenTransfer/__tests__/CreateTokenTransfer.test.tsx @@ -2,7 +2,7 @@ import { TokenTransferType } from '@/components/tx-flow/flows/TokenTransfer' import { CreateTokenTransfer } from '@/components/tx-flow/flows/TokenTransfer/CreateTokenTransfer' import * as tokenUtils from '@/components/tx-flow/flows/TokenTransfer/utils' import { render } from '@/tests/test-utils' -import { ZERO_ADDRESS } from '@safe-global/safe-core-sdk/dist/src/utils/constants' +import { ZERO_ADDRESS } from '@safe-global/protocol-kit/dist/src/utils/constants' describe('CreateTokenTransfer', () => { const mockParams = { diff --git a/src/components/tx-flow/flows/TokenTransfer/index.tsx b/src/components/tx-flow/flows/TokenTransfer/index.tsx index e1fa557a0f..89b99fd8cd 100644 --- a/src/components/tx-flow/flows/TokenTransfer/index.tsx +++ b/src/components/tx-flow/flows/TokenTransfer/index.tsx @@ -3,7 +3,7 @@ import useTxStepper from '../../useTxStepper' import CreateTokenTransfer from './CreateTokenTransfer' import ReviewTokenTx from '@/components/tx-flow/flows/TokenTransfer/ReviewTokenTx' import AssetsIcon from '@/public/images/sidebar/assets.svg' -import { ZERO_ADDRESS } from '@safe-global/safe-core-sdk/dist/src/utils/constants' +import { ZERO_ADDRESS } from '@safe-global/protocol-kit/dist/src/utils/constants' import { TokenAmountFields } from '@/components/common/TokenAmountInput' export enum TokenTransferType { diff --git a/src/components/tx/ApprovalEditor/ApprovalEditorForm.tsx b/src/components/tx/ApprovalEditor/ApprovalEditorForm.tsx index d4a416d03f..442127a5d3 100644 --- a/src/components/tx/ApprovalEditor/ApprovalEditorForm.tsx +++ b/src/components/tx/ApprovalEditor/ApprovalEditorForm.tsx @@ -47,7 +47,7 @@ export const ApprovalEditorForm = ({ {approvalInfos.map((tx, idx) => ( diff --git a/src/components/tx/ApprovalEditor/hooks/useApprovalInfos.test.ts b/src/components/tx/ApprovalEditor/hooks/useApprovalInfos.test.ts index cb884027e9..a16eef4db1 100644 --- a/src/components/tx/ApprovalEditor/hooks/useApprovalInfos.test.ts +++ b/src/components/tx/ApprovalEditor/hooks/useApprovalInfos.test.ts @@ -1,5 +1,5 @@ import { renderHook } from '@/tests/test-utils' -import { hexZeroPad, Interface } from 'ethers' +import { zeroPadValue, Interface } from 'ethers' import { type ApprovalInfo, useApprovalInfos } from '@/components/tx/ApprovalEditor/hooks/useApprovalInfos' import { waitFor } from '@testing-library/react' import { createMockSafeTransaction } from '@/tests/transactions' @@ -32,8 +32,8 @@ describe('useApprovalInfos', () => { it('returns an empty array if the transaction does not contain any approvals', async () => { const mockSafeTx = createMockSafeTransaction({ - to: hexZeroPad('0x123', 20), - data: createNonApproveCallData(hexZeroPad('0x2', 20), '20'), + to: zeroPadValue('0x0123', 20), + data: createNonApproveCallData(zeroPadValue('0x02', 20), '20'), operation: OperationType.DelegateCall, }) @@ -48,8 +48,8 @@ describe('useApprovalInfos', () => { const testInterface = new Interface(['function approve(address, uint256)']) const mockSafeTx = createMockSafeTransaction({ - to: hexZeroPad('0x123', 20), - data: testInterface.encodeFunctionData('approve', [hexZeroPad('0x2', 20), '123']), + to: zeroPadValue('0x0123', 20), + data: testInterface.encodeFunctionData('approve', [zeroPadValue('0x02', 20), '123']), operation: OperationType.Call, }) @@ -73,8 +73,8 @@ describe('useApprovalInfos', () => { const testInterface = new Interface(['function increaseAllowance(address, uint256)']) const mockSafeTx = createMockSafeTransaction({ - to: hexZeroPad('0x123', 20), - data: testInterface.encodeFunctionData('increaseAllowance', [hexZeroPad('0x2', 20), '123']), + to: zeroPadValue('0x0123', 20), + data: testInterface.encodeFunctionData('increaseAllowance', [zeroPadValue('0x02', 20), '123']), operation: OperationType.Call, }) @@ -100,7 +100,7 @@ describe('useApprovalInfos', () => { fiatBalance: '40', fiatConversion: '1', tokenInfo: { - address: hexZeroPad('0x123', 20), + address: zeroPadValue('0x0123', 20), decimals: 18, logoUri: '', name: 'Hidden Token', @@ -115,8 +115,8 @@ describe('useApprovalInfos', () => { const testInterface = new Interface(['function approve(address, uint256)']) const mockSafeTx = createMockSafeTransaction({ - to: hexZeroPad('0x123', 20), - data: testInterface.encodeFunctionData('approve', [hexZeroPad('0x2', 20), '123']), + to: zeroPadValue('0x0123', 20), + data: testInterface.encodeFunctionData('approve', [zeroPadValue('0x02', 20), '123']), operation: OperationType.DelegateCall, }) @@ -149,8 +149,8 @@ describe('useApprovalInfos', () => { const testInterface = new Interface(['function approve(address, uint256)']) const mockSafeTx = createMockSafeTransaction({ - to: hexZeroPad('0x123', 20), - data: testInterface.encodeFunctionData('approve', [hexZeroPad('0x2', 20), '123']), + to: zeroPadValue('0x0123', 20), + data: testInterface.encodeFunctionData('approve', [zeroPadValue('0x02', 20), '123']), operation: OperationType.DelegateCall, }) diff --git a/src/components/tx/ApprovalEditor/hooks/useApprovalInfos.ts b/src/components/tx/ApprovalEditor/hooks/useApprovalInfos.ts index fbf97cf806..896ecd0e8f 100644 --- a/src/components/tx/ApprovalEditor/hooks/useApprovalInfos.ts +++ b/src/components/tx/ApprovalEditor/hooks/useApprovalInfos.ts @@ -4,7 +4,7 @@ import { type Approval, ApprovalModule } from '@/services/security/modules/Appro import { getERC20TokenInfoOnChain, UNLIMITED_APPROVAL_AMOUNT } from '@/utils/tokens' import { type SafeTransaction } from '@safe-global/safe-core-sdk-types' import { type TokenInfo } from '@safe-global/safe-gateway-typescript-sdk' -import { ethers } from 'ethers' +import { formatUnits } from 'ethers' import { PSEUDO_APPROVAL_VALUES } from '../utils/approvals' import { useMemo } from 'react' @@ -45,9 +45,9 @@ export const useApprovalInfos = ( tokenInfo = await getERC20TokenInfoOnChain(approval.tokenAddress) } - const amountFormatted = UNLIMITED_APPROVAL_AMOUNT.eq(approval.amount) + const amountFormatted = UNLIMITED_APPROVAL_AMOUNT == approval.amount ? PSEUDO_APPROVAL_VALUES.UNLIMITED - : ethers.utils.formatUnits(approval.amount, tokenInfo?.decimals) + : formatUnits(approval.amount, tokenInfo?.decimals) return { ...approval, tokenInfo: tokenInfo, amountFormatted } }), diff --git a/src/components/tx/ApprovalEditor/index.tsx b/src/components/tx/ApprovalEditor/index.tsx index 4650595948..01cb34c799 100644 --- a/src/components/tx/ApprovalEditor/index.tsx +++ b/src/components/tx/ApprovalEditor/index.tsx @@ -32,7 +32,7 @@ export const ApprovalEditor = ({ safeTransaction }: { safeTransaction: SafeTrans const { setSafeTx, setSafeTxError } = useContext(SafeTxContext) const [readableApprovals, error, loading] = useApprovalInfos(safeTransaction) - const nonZeroApprovals = readableApprovals?.filter((approval) => !BigInt(0).eq(approval.amount)) + const nonZeroApprovals = readableApprovals?.filter((approval) => !(0n === approval.amount)) if (nonZeroApprovals?.length === 0 || !safeTransaction) { return null diff --git a/src/components/tx/ApprovalEditor/utils/approvals.ts b/src/components/tx/ApprovalEditor/utils/approvals.ts index dc7b710daf..9a457e9b16 100644 --- a/src/components/tx/ApprovalEditor/utils/approvals.ts +++ b/src/components/tx/ApprovalEditor/utils/approvals.ts @@ -3,7 +3,7 @@ import { UNLIMITED_APPROVAL_AMOUNT } from '@/utils/tokens' import type { BaseTransaction } from '@safe-global/safe-apps-sdk' import type { DecodedDataResponse } from '@safe-global/safe-gateway-typescript-sdk' import { parseUnits, id } from 'ethers' -import { EMPTY_DATA } from '@safe-global/safe-core-sdk/dist/src/utils/constants' +import { EMPTY_DATA } from '@safe-global/protocol-kit/dist/src/utils/constants' import { type ApprovalInfo } from '../hooks/useApprovalInfos' export const APPROVAL_SIGNATURE_HASH = id('approve(address,uint256)').slice(0, 10) diff --git a/src/components/tx/DecodedTx/index.test.tsx b/src/components/tx/DecodedTx/index.test.tsx index d0d796688f..76c543303d 100644 --- a/src/components/tx/DecodedTx/index.test.tsx +++ b/src/components/tx/DecodedTx/index.test.tsx @@ -106,7 +106,7 @@ describe('DecodedTx', () => { data: { to: '0x40A2aCCbd92BCA938b02010E17A5b8929b49130D', value: '0', - data: '0x8d80ff0', + data: '0x8d80ff00', operation: 1, baseGas: 0, gasPrice: 0, diff --git a/src/components/tx/GasParams/GasParams.test.tsx b/src/components/tx/GasParams/GasParams.test.tsx index 9e4ca9b461..3082a2dee9 100644 --- a/src/components/tx/GasParams/GasParams.test.tsx +++ b/src/components/tx/GasParams/GasParams.test.tsx @@ -15,6 +15,7 @@ describe('GasParams', () => { const { getByText } = render() + expect(getByText('Estimated fee')).toBeInTheDocument() }) diff --git a/src/components/tx/GasParams/index.tsx b/src/components/tx/GasParams/index.tsx index 49ed1ca1f6..3a1e393a60 100644 --- a/src/components/tx/GasParams/index.tsx +++ b/src/components/tx/GasParams/index.tsx @@ -52,7 +52,7 @@ export const _GasParams = ({ // Total gas cost const totalFee = !isLoading - ? formatVisualAmount(maxFeePerGas.mul(gasLimit), chain?.nativeCurrency.decimals) + ? formatVisualAmount(maxFeePerGas * gasLimit, chain?.nativeCurrency.decimals) : '> 0.001' // Individual gas params diff --git a/src/components/tx/SignOrExecuteForm/hooks.test.ts b/src/components/tx/SignOrExecuteForm/hooks.test.ts index 7062272fe9..2571070e5b 100644 --- a/src/components/tx/SignOrExecuteForm/hooks.test.ts +++ b/src/components/tx/SignOrExecuteForm/hooks.test.ts @@ -1,5 +1,5 @@ import { renderHook } from '@/tests/test-utils' -import { ethers } from 'ethers' +import { zeroPadValue } from 'ethers' import { createSafeTx } from '@/tests/builders/safeTx' import type { SafeInfo } from '@safe-global/safe-gateway-typescript-sdk' import { type ConnectedWallet } from '@/hooks/wallets/useOnboard' @@ -46,13 +46,13 @@ describe('SignOrExecute hooks', () => { jest.spyOn(useSafeInfoHook, 'default').mockImplementation(() => ({ safe: { version: '1.3.0', - address: { value: ethers.utils.hexZeroPad('0x000', 20) }, + address: { value: zeroPadValue('0x0000', 20) }, nonce: 100, threshold: 2, - owners: [{ value: ethers.utils.hexZeroPad('0x123', 20) }, { value: ethers.utils.hexZeroPad('0x456', 20) }], + owners: [{ value: zeroPadValue('0x0123', 20) }, { value: zeroPadValue('0x0456', 20) }], chainId: '1', } as SafeInfo, - safeAddress: ethers.utils.hexZeroPad('0x000', 20), + safeAddress: zeroPadValue('0x0000', 20), safeError: undefined, safeLoading: false, safeLoaded: true, @@ -67,13 +67,13 @@ describe('SignOrExecute hooks', () => { jest.spyOn(useSafeInfoHook, 'default').mockImplementation(() => ({ safe: { version: '1.3.0', - address: { value: ethers.utils.hexZeroPad('0x000', 20) }, + address: { value: zeroPadValue('0x0000', 20) }, nonce: 90, threshold: 2, - owners: [{ value: ethers.utils.hexZeroPad('0x123', 20) }, { value: ethers.utils.hexZeroPad('0x456', 20) }], + owners: [{ value: zeroPadValue('0x0123', 20) }, { value: zeroPadValue('0x0456', 20) }], chainId: '1', } as SafeInfo, - safeAddress: ethers.utils.hexZeroPad('0x000', 20), + safeAddress: zeroPadValue('0x0000', 20), safeError: undefined, safeLoading: false, safeLoaded: true, @@ -87,7 +87,7 @@ describe('SignOrExecute hooks', () => { describe('useIsExecutionLoop', () => { it('should return true when a safe is executing its own transaction', () => { - const address = ethers.utils.hexZeroPad('0x789', 20) + const address = zeroPadValue('0x0789', 20) jest.spyOn(useSafeInfoHook, 'default').mockReturnValue({ safeAddress: address, @@ -118,7 +118,7 @@ describe('SignOrExecute hooks', () => { jest.spyOn(wallet, 'default').mockReturnValue({ chainId: '1', label: 'MetaMask', - address: ethers.utils.hexZeroPad('0x456', 20), + address: zeroPadValue('0x0456', 20), } as ConnectedWallet) const { result } = renderHook(() => useIsExecutionLoop()) @@ -130,11 +130,11 @@ describe('SignOrExecute hooks', () => { describe('useImmediatelyExecutable', () => { it('should return true for newly created transactions with threshold 1 and no pending transactions', () => { jest.spyOn(useSafeInfoHook, 'default').mockReturnValue({ - safeAddress: ethers.utils.hexZeroPad('0x000', 20), + safeAddress: zeroPadValue('0x0000', 20), safe: { version: '1.3.0', - address: { value: ethers.utils.hexZeroPad('0x000', 20) }, - owners: [{ value: ethers.utils.hexZeroPad('0x123', 20) }], + address: { value: zeroPadValue('0x0000', 20) }, + owners: [{ value: zeroPadValue('0x0123', 20) }], threshold: 1, nonce: 100, } as SafeInfo, @@ -152,11 +152,11 @@ describe('SignOrExecute hooks', () => { it('should return false for newly created transactions with threshold > 1', () => { jest.spyOn(useSafeInfoHook, 'default').mockReturnValue({ - safeAddress: ethers.utils.hexZeroPad('0x000', 20), + safeAddress: zeroPadValue('0x0000', 20), safe: { version: '1.3.0', - address: { value: ethers.utils.hexZeroPad('0x000', 20) }, - owners: [{ value: ethers.utils.hexZeroPad('0x123', 20) }], + address: { value: zeroPadValue('0x0000', 20) }, + owners: [{ value: zeroPadValue('0x0123', 20) }], threshold: 2, nonce: 100, chainId: '1', @@ -175,11 +175,11 @@ describe('SignOrExecute hooks', () => { it('should return false for safes with pending transactions', () => { jest.spyOn(useSafeInfoHook, 'default').mockReturnValue({ - safeAddress: ethers.utils.hexZeroPad('0x000', 20), + safeAddress: zeroPadValue('0x0000', 20), safe: { version: '1.3.0', - address: { value: ethers.utils.hexZeroPad('0x000', 20) }, - owners: [{ value: ethers.utils.hexZeroPad('0x123', 20) }], + address: { value: zeroPadValue('0x0000', 20) }, + owners: [{ value: zeroPadValue('0x0123', 20) }], threshold: 1, nonce: 100, chainId: '1', @@ -202,10 +202,10 @@ describe('SignOrExecute hooks', () => { jest.spyOn(useSafeInfoHook, 'default').mockImplementation(() => ({ safe: { version: '1.3.0', - address: { value: ethers.utils.hexZeroPad('0x000', 20) }, + address: { value: zeroPadValue('0x0000', 20) }, nonce: 100, threshold: 2, - owners: [{ value: ethers.utils.hexZeroPad('0x123', 20) }, { value: ethers.utils.hexZeroPad('0x456', 20) }], + owners: [{ value: zeroPadValue('0x0123', 20) }, { value: zeroPadValue('0x0456', 20) }], chainId: '1', } as SafeInfo, safeAddress: '0x123', @@ -226,10 +226,10 @@ describe('SignOrExecute hooks', () => { jest.spyOn(useSafeInfoHook, 'default').mockImplementation(() => ({ safe: { version: '1.3.0', - address: { value: ethers.utils.hexZeroPad('0x000', 20) }, + address: { value: zeroPadValue('0x0000', 20) }, nonce: 100, threshold: 2, - owners: [{ value: ethers.utils.hexZeroPad('0x123', 20) }, { value: ethers.utils.hexZeroPad('0x456', 20) }], + owners: [{ value: zeroPadValue('0x0123', 20) }, { value: zeroPadValue('0x0456', 20) }], chainId: '1', } as SafeInfo, safeAddress: '0x123', @@ -267,10 +267,10 @@ describe('SignOrExecute hooks', () => { jest.spyOn(useSafeInfoHook, 'default').mockImplementation(() => ({ safe: { version: '1.3.0', - address: { value: ethers.utils.hexZeroPad('0x000', 20) }, + address: { value: zeroPadValue('0x0000', 20) }, nonce: 100, threshold: 2, - owners: [{ value: ethers.utils.hexZeroPad('0x123', 20) }, { value: ethers.utils.hexZeroPad('0x456', 20) }], + owners: [{ value: zeroPadValue('0x0123', 20) }, { value: zeroPadValue('0x0456', 20) }], chainId: '1', } as SafeInfo, safeAddress: '0x123', @@ -296,10 +296,10 @@ describe('SignOrExecute hooks', () => { jest.spyOn(useSafeInfoHook, 'default').mockImplementation(() => ({ safe: { version: '1.3.0', - address: { value: ethers.utils.hexZeroPad('0x000', 20) }, + address: { value: zeroPadValue('0x0000', 20) }, nonce: 100, threshold: 2, - owners: [{ value: ethers.utils.hexZeroPad('0x123', 20) }, { value: ethers.utils.hexZeroPad('0x456', 20) }], + owners: [{ value: zeroPadValue('0x0123', 20) }, { value: zeroPadValue('0x0456', 20) }], chainId: '1', } as SafeInfo, safeAddress: '0x123', @@ -328,10 +328,10 @@ describe('SignOrExecute hooks', () => { jest.spyOn(useSafeInfoHook, 'default').mockImplementation(() => ({ safe: { version: '1.3.0', - address: { value: ethers.utils.hexZeroPad('0x000', 20) }, + address: { value: zeroPadValue('0x0000', 20) }, nonce: 100, threshold: 2, - owners: [{ value: ethers.utils.hexZeroPad('0x123', 20) }, { value: ethers.utils.hexZeroPad('0x456', 20) }], + owners: [{ value: zeroPadValue('0x0123', 20) }, { value: zeroPadValue('0x0456', 20) }], chainId: '1', } as SafeInfo, safeAddress: '0x123', @@ -360,10 +360,10 @@ describe('SignOrExecute hooks', () => { jest.spyOn(useSafeInfoHook, 'default').mockImplementation(() => ({ safe: { version: '1.3.0', - address: { value: ethers.utils.hexZeroPad('0x000', 20) }, + address: { value: zeroPadValue('0x0000', 20) }, nonce: 100, threshold: 2, - owners: [{ value: ethers.utils.hexZeroPad('0x123', 20) }, { value: ethers.utils.hexZeroPad('0x456', 20) }], + owners: [{ value: zeroPadValue('0x0123', 20) }, { value: zeroPadValue('0x0456', 20) }], chainId: '1', } as SafeInfo, safeAddress: '0x123', @@ -384,10 +384,10 @@ describe('SignOrExecute hooks', () => { jest.spyOn(useSafeInfoHook, 'default').mockImplementation(() => ({ safe: { version: '1.3.0', - address: { value: ethers.utils.hexZeroPad('0x000', 20) }, + address: { value: zeroPadValue('0x0000', 20) }, nonce: 100, threshold: 1, - owners: [{ value: ethers.utils.hexZeroPad('0x123', 20) }, { value: ethers.utils.hexZeroPad('0x456', 20) }], + owners: [{ value: zeroPadValue('0x0123', 20) }, { value: zeroPadValue('0x0456', 20) }], chainId: '1', } as SafeInfo, safeAddress: '0x123', @@ -424,10 +424,10 @@ describe('SignOrExecute hooks', () => { jest.spyOn(useSafeInfoHook, 'default').mockImplementation(() => ({ safe: { version: '1.3.0', - address: { value: ethers.utils.hexZeroPad('0x000', 20) }, + address: { value: zeroPadValue('0x0000', 20) }, nonce: 100, threshold: 2, - owners: [{ value: ethers.utils.hexZeroPad('0x123', 20) }, { value: ethers.utils.hexZeroPad('0x456', 20) }], + owners: [{ value: zeroPadValue('0x0123', 20) }, { value: zeroPadValue('0x0456', 20) }], chainId: '1', } as SafeInfo, safeAddress: '0x123', @@ -474,10 +474,10 @@ describe('SignOrExecute hooks', () => { jest.spyOn(useSafeInfoHook, 'default').mockImplementation(() => ({ safe: { version: '1.3.0', - address: { value: ethers.utils.hexZeroPad('0x000', 20) }, + address: { value: zeroPadValue('0x0000', 20) }, nonce: 100, threshold: 2, - owners: [{ value: ethers.utils.hexZeroPad('0x123', 20) }, { value: ethers.utils.hexZeroPad('0x456', 20) }], + owners: [{ value: zeroPadValue('0x0123', 20) }, { value: zeroPadValue('0x0456', 20) }], chainId: '1', } as SafeInfo, safeAddress: '0x123', diff --git a/src/components/tx/SignOrExecuteForm/hooks.ts b/src/components/tx/SignOrExecuteForm/hooks.ts index 39b2f24e85..1d2f3be657 100644 --- a/src/components/tx/SignOrExecuteForm/hooks.ts +++ b/src/components/tx/SignOrExecuteForm/hooks.ts @@ -1,6 +1,6 @@ import { useMemo } from 'react' import { type TransactionOptions, type SafeTransaction } from '@safe-global/safe-core-sdk-types' -import { sameString } from '@safe-global/safe-core-sdk/dist/src/utils' +import { sameString } from '@safe-global/protocol-kit/dist/src/utils' import useSafeInfo from '@/hooks/useSafeInfo' import useWallet from '@/hooks/wallets/useWallet' import useOnboard from '@/hooks/wallets/useOnboard' diff --git a/src/components/tx/security/tenderly/__tests__/utils.test.ts b/src/components/tx/security/tenderly/__tests__/utils.test.ts index 34325d5532..e9817a8e63 100644 --- a/src/components/tx/security/tenderly/__tests__/utils.test.ts +++ b/src/components/tx/security/tenderly/__tests__/utils.test.ts @@ -1,6 +1,6 @@ import type { MetaTransactionData, SafeTransaction } from '@safe-global/safe-core-sdk-types' import type { SafeInfo } from '@safe-global/safe-gateway-typescript-sdk' -import { ethers } from 'ethers' +import { zeroPadValue, Interface } from 'ethers' import { getSimulationPayload, NONCE_STORAGE_POSITION, @@ -8,9 +8,9 @@ import { } from '@/components/tx/security/tenderly/utils' import * as safeContracts from '@/services/contracts/safeContracts' import { getMultiSendCallOnlyDeployment, getSafeSingletonDeployment } from '@safe-global/safe-deployments' -import EthSafeTransaction from '@safe-global/safe-core-sdk/dist/src/utils/transactions/SafeTransaction' -import { ZERO_ADDRESS } from '@safe-global/safe-core-sdk/dist/src/utils/constants' -import { generatePreValidatedSignature } from '@safe-global/safe-core-sdk/dist/src/utils/signatures' +import EthSafeTransaction from '@safe-global/protocol-kit/dist/src/utils/transactions/SafeTransaction' +import { ZERO_ADDRESS } from '@safe-global/protocol-kit/dist/src/utils/constants' +import { generatePreValidatedSignature } from '@safe-global/protocol-kit/dist/src/utils/signatures' import { hexZeroPad } from '@ethersproject/bytes' import * as Web3 from '@/hooks/wallets/web3' @@ -19,12 +19,12 @@ const SIGNATURE_LENGTH = 65 * 2 const getPreValidatedSignature = (addr: string): string => generatePreValidatedSignature(addr).data describe('simulation utils', () => { - const safeContractInterface = new ethers.utils.Interface(getSafeSingletonDeployment({ version: '1.3.0' })?.abi || []) - const multiSendContractInterface = new ethers.utils.Interface( + const safeContractInterface = new Interface(getSafeSingletonDeployment({ version: '1.3.0' })?.abi || []) + const multiSendContractInterface = new Interface( getMultiSendCallOnlyDeployment({ version: '1.3.0' })?.abi || [], ) - const mockSafeAddress = ethers.utils.hexZeroPad('0x123', 20) - const mockMultisendAddress = ethers.utils.hexZeroPad('0x1234', 20) + const mockSafeAddress = zeroPadValue('0x0123', 20) + const mockMultisendAddress = zeroPadValue('0x1234', 20) beforeAll(() => { const safeContractMock = { @@ -54,12 +54,12 @@ describe('simulation utils', () => { }) describe('getSimulationPayload', () => { it('unsigned executable multisig transaction with threshold 1', async () => { - const ownerAddress = ethers.utils.hexZeroPad('0x1', 20) + const ownerAddress = zeroPadValue('0x01', 20) const mockSafeInfo: Partial = { threshold: 1, nonce: 0, chainId: '4', - address: { value: ethers.utils.hexZeroPad('0x123', 20) }, + address: { value: zeroPadValue('0x0123', 20) }, } const mockTx: SafeTransaction = new EthSafeTransaction({ to: ZERO_ADDRESS, @@ -99,7 +99,7 @@ describe('simulation utils', () => { expect(decodedTxData[0]).toEqual(ZERO_ADDRESS) expect(decodedTxData[1]).toEqual(BigInt(0)) expect(decodedTxData[2]).toEqual('0x') - expect(decodedTxData[3]).toEqual(0) + expect(decodedTxData[3]).toEqual(0n) expect(decodedTxData[4]).toEqual(BigInt(0)) expect(decodedTxData[5]).toEqual(BigInt(0)) expect(decodedTxData[6]).toEqual(BigInt(0)) @@ -116,15 +116,15 @@ describe('simulation utils', () => { }) it('fully signed executable multisig transaction with threshold 2', async () => { - const ownerAddress = ethers.utils.hexZeroPad('0x1', 20) - const otherOwnerAddress1 = ethers.utils.hexZeroPad('0x11', 20) - const otherOwnerAddress2 = ethers.utils.hexZeroPad('0x12', 20) + const ownerAddress = zeroPadValue('0x01', 20) + const otherOwnerAddress1 = zeroPadValue('0x11', 20) + const otherOwnerAddress2 = zeroPadValue('0x12', 20) const mockSafeInfo: Partial = { threshold: 2, nonce: 0, chainId: '4', - address: { value: ethers.utils.hexZeroPad('0x123', 20) }, + address: { value: zeroPadValue('0x0123', 20) }, } const mockTx: SafeTransaction = new EthSafeTransaction({ to: ZERO_ADDRESS, @@ -158,14 +158,14 @@ describe('simulation utils', () => { }) it('partially signed multisig transaction with threshold 2 and higher nonce', async () => { - const ownerAddress = ethers.utils.hexZeroPad('0x1', 20) - const otherOwnerAddress1 = ethers.utils.hexZeroPad('0x11', 20) + const ownerAddress = zeroPadValue('0x01', 20) + const otherOwnerAddress1 = zeroPadValue('0x11', 20) const mockSafeInfo: Partial = { threshold: 2, nonce: 0, chainId: '4', - address: { value: ethers.utils.hexZeroPad('0x123', 20) }, + address: { value: zeroPadValue('0x0123', 20) }, } const mockTx: SafeTransaction = new EthSafeTransaction({ to: ZERO_ADDRESS, @@ -202,14 +202,14 @@ describe('simulation utils', () => { }) it('partially signed executable multisig transaction with threshold 2 and matching nonce', async () => { - const ownerAddress = ethers.utils.hexZeroPad('0x1', 20) - const otherOwnerAddress1 = ethers.utils.hexZeroPad('0x11', 20) + const ownerAddress = zeroPadValue('0x01', 20) + const otherOwnerAddress1 = zeroPadValue('0x11', 20) const mockSafeInfo: Partial = { threshold: 2, nonce: 0, chainId: '4', - address: { value: ethers.utils.hexZeroPad('0x123', 20) }, + address: { value: zeroPadValue('0x0123', 20) }, } const mockTx: SafeTransaction = new EthSafeTransaction({ to: ZERO_ADDRESS, @@ -243,13 +243,13 @@ describe('simulation utils', () => { }) it('unsigned signed not-executable multisig transaction with threshold 2', async () => { - const ownerAddress = ethers.utils.hexZeroPad('0x1', 20) + const ownerAddress = zeroPadValue('0x01', 20) const mockSafeInfo: Partial = { threshold: 2, nonce: 0, chainId: '4', - address: { value: ethers.utils.hexZeroPad('0x123', 20) }, + address: { value: zeroPadValue('0x0123', 20) }, } const mockTx: SafeTransaction = new EthSafeTransaction({ to: ZERO_ADDRESS, @@ -284,13 +284,13 @@ describe('simulation utils', () => { }) it('batched transaction without gas limit', async () => { - const ownerAddress = ethers.utils.hexZeroPad('0x1', 20) + const ownerAddress = zeroPadValue('0x01', 20) const mockSafeInfo: Partial = { threshold: 2, nonce: 0, chainId: '4', - address: { value: ethers.utils.hexZeroPad('0x123', 20) }, + address: { value: zeroPadValue('0x0123', 20) }, } const mockTxs: MetaTransactionData[] = [ { diff --git a/src/components/tx/security/tenderly/utils.ts b/src/components/tx/security/tenderly/utils.ts index bd6c13c84f..78c8e641bf 100644 --- a/src/components/tx/security/tenderly/utils.ts +++ b/src/components/tx/security/tenderly/utils.ts @@ -1,6 +1,6 @@ -import { generatePreValidatedSignature } from '@safe-global/safe-core-sdk/dist/src/utils/signatures' -import EthSafeTransaction from '@safe-global/safe-core-sdk/dist/src/utils/transactions/SafeTransaction' -import { encodeMultiSendData } from '@safe-global/safe-core-sdk/dist/src/utils/transactions/utils' +import { generatePreValidatedSignature } from '@safe-global/protocol-kit/dist/src/utils/signatures' +import EthSafeTransaction from '@safe-global/protocol-kit/dist/src/utils/transactions/SafeTransaction' +import { encodeMultiSendData } from '@safe-global/protocol-kit/dist/src/utils/transactions/utils' import { type SafeInfo, type ChainInfo } from '@safe-global/safe-gateway-typescript-sdk' import type { MetaTransactionData, SafeTransaction } from '@safe-global/safe-core-sdk-types' @@ -194,7 +194,7 @@ const getStateOverwrites = (params: SimulationTxParams) => { storageOverwrites[THRESHOLD_STORAGE_POSITION] = THRESHOLD_OVERWRITE } if (nonceOverwrite) { - storageOverwrites[NONCE_STORAGE_POSITION] = hexZeroPad(BigInt(nonceOverwrite).toHexString(), 32) + storageOverwrites[NONCE_STORAGE_POSITION] = hexZeroPad('0x' + BigInt(nonceOverwrite).toString(16), 32) } return storageOverwrites @@ -206,7 +206,7 @@ const getLatestBlockGasLimit = async (): Promise => { if (!latestBlock) { throw Error('Could not determine block gas limit') } - return latestBlock.gasLimit.toNumber() + return Number(latestBlock.gasLimit) } export const getSimulationPayload = async (params: SimulationTxParams): Promise => { diff --git a/src/features/recovery/components/RecoveryDetails/index.tsx b/src/features/recovery/components/RecoveryDetails/index.tsx index 2cb2f3d781..c20056f953 100644 --- a/src/features/recovery/components/RecoveryDetails/index.tsx +++ b/src/features/recovery/components/RecoveryDetails/index.tsx @@ -30,9 +30,9 @@ export function RecoveryDetails({ item }: { item: RecoveryQueueItem }): ReactEle
{generateDataRowValue(transactionHash, 'hash', true)} - {dateString(timestamp.toNumber())} - {dateString(validFrom.toNumber())} - {expiresAt && {dateString(expiresAt.toNumber())}} + {dateString(Number(timestamp))} + {dateString(Number(validFrom))} + {expiresAt && {dateString(Number(expiresAt))}} Advanced details diff --git a/src/features/recovery/components/RecoverySettings/index.tsx b/src/features/recovery/components/RecoverySettings/index.tsx index d7b4e56585..d2ed57b7fe 100644 --- a/src/features/recovery/components/RecoverySettings/index.tsx +++ b/src/features/recovery/components/RecoverySettings/index.tsx @@ -78,8 +78,8 @@ function RecoverySettings(): ReactElement { const { recoverers, delay, expiry } = delayModifier return recoverers.map((recoverer) => { - const delaySeconds = delay.toNumber() - const expirySeconds = expiry.toNumber() + const delaySeconds = Number(delay) + const expirySeconds = Number(expiry) return { cells: { diff --git a/src/features/recovery/components/RecoverySigners/index.tsx b/src/features/recovery/components/RecoverySigners/index.tsx index 328f1c44e0..dfc15cdafa 100644 --- a/src/features/recovery/components/RecoverySigners/index.tsx +++ b/src/features/recovery/components/RecoverySigners/index.tsx @@ -21,7 +21,7 @@ export function RecoverySigners({ item }: { item: RecoveryQueueItem }): ReactEle item.expiresAt ? ( <> The recovery proposal can be executed{' '} - until {formatDateTime(item.expiresAt.toNumber())}. + until {formatDateTime(Number(item.expiresAt))}. ) : ( 'The recovery proposal can be executed now.' diff --git a/src/features/recovery/hooks/useRecoveryTxState.ts b/src/features/recovery/hooks/useRecoveryTxState.ts index 7b79edb576..a352fcbc18 100644 --- a/src/features/recovery/hooks/useRecoveryTxState.ts +++ b/src/features/recovery/hooks/useRecoveryTxState.ts @@ -17,18 +17,18 @@ export function useRecoveryTxState({ validFrom, expiresAt, transactionHash, args // We don't display seconds in the interface, so we can use a 60s interval const timestamp = useClock(60_000) - const remainingMs = validFrom.sub(timestamp) + const remainingMs = Number(validFrom) - (timestamp) - const isValid = remainingMs.lte(0) - const isExpired = expiresAt ? expiresAt.toNumber() <= Date.now() : false + const isValid = remainingMs <= 0 + const isExpired = expiresAt !== null ? Number(expiresAt) <= Date.now() : false // Check module address in case multiple Delay Modifiers enabled const isNext = - !delayModifier || (sameAddress(delayModifier.address, address) && args.queueNonce.eq(delayModifier.txNonce)) + !delayModifier || (sameAddress(delayModifier.address, address) && BigInt(args.queueNonce) === BigInt(delayModifier.txNonce)) const isExecutable = isNext && isValid && !isExpired const isPending = !!pending?.[args.txHash] - const remainingSeconds = isValid ? 0 : Math.ceil(remainingMs.div(1_000).toNumber()) + const remainingSeconds = isValid ? 0 : Math.ceil(remainingMs / 1_000) return { isNext, isExecutable, isExpired, remainingSeconds, isPending } } diff --git a/src/features/recovery/services/__tests__/recovery-state.test.ts b/src/features/recovery/services/__tests__/recovery-state.test.ts index 0d18f13d0b..9977abff00 100644 --- a/src/features/recovery/services/__tests__/recovery-state.test.ts +++ b/src/features/recovery/services/__tests__/recovery-state.test.ts @@ -1,5 +1,5 @@ import { faker } from '@faker-js/faker' -import { ethers } from 'ethers' +import { id, zeroPadValue } from 'ethers' import { JsonRpcProvider } from '@ethersproject/providers' import cloneDeep from 'lodash/cloneDeep' import type { Delay, TransactionAddedEvent } from '@gnosis.pm/zodiac/dist/cjs/types/Delay' @@ -12,7 +12,7 @@ import { _isMaliciousRecovery, } from '../recovery-state' import { useWeb3ReadOnly } from '@/hooks/wallets/web3' -import { encodeMultiSendData } from '@safe-global/safe-core-sdk/dist/src/utils/transactions/utils' +import { encodeMultiSendData } from '@safe-global/protocol-kit/dist/src/utils/transactions/utils' import { getMultiSendCallOnlyDeployment, getSafeSingletonDeployment } from '@safe-global/safe-deployments' import { Interface } from 'ethers' import { LATEST_SAFE_VERSION } from '@/config/constants' @@ -211,11 +211,11 @@ describe('recovery-state', () => { } as unknown as Delay const transactionAdded = { args: { - queueNonce: BigInt(0), + queueNonce: 0n, }, } as TransactionAddedEvent - const delay = BigInt(1) - const expiry = BigInt(2) + const delay = (1n) + const expiry = (2n) const item = await _getRecoveryQueueItemTimestamps({ delayModifier, @@ -225,9 +225,9 @@ describe('recovery-state', () => { }) expect(item).toStrictEqual({ - timestamp: BigInt(1_000), - validFrom: BigInt(2_000), - expiresAt: BigInt(4_000), + timestamp: (1_000n), + validFrom: (2_000n), + expiresAt: (4_000n), }) }) @@ -237,11 +237,11 @@ describe('recovery-state', () => { } as unknown as Delay const transactionAdded = { args: { - queueNonce: BigInt(0), + queueNonce: (0n), }, } as TransactionAddedEvent - const delay = BigInt(1) - const expiry = BigInt(0) + const delay = (1n) + const expiry = (0n) const item = await _getRecoveryQueueItemTimestamps({ delayModifier, @@ -251,8 +251,8 @@ describe('recovery-state', () => { }) expect(item).toStrictEqual({ - timestamp: BigInt(1_000), - validFrom: BigInt(2_000), + timestamp: 1_000n, + validFrom: (2_000n), expiresAt: null, }) }) @@ -378,32 +378,32 @@ describe('recovery-state', () => { }) const recoverers = [faker.finance.ethereumAddress()] - const expiry = BigInt(0) - const delay = BigInt(69420) - const txNonce = BigInt(2) - const queueNonce = BigInt(4) + const expiry = 0n + const delay = 69420n + const txNonce = 2n + const queueNonce = 4n const transactionsAdded = [ { args: { - queueNonce: BigInt(2), + queueNonce: 2n, to: safeAddress, - value: BigInt(0), + value: 0n, data: '0x', }, } as unknown, { args: { - queueNonce: BigInt(3), + queueNonce: 3n, to: faker.finance.ethereumAddress(), // Malicious - value: BigInt(0), + value: 0n, data: '0x', }, } as unknown, { args: { - queueNonce: BigInt(4), + queueNonce: 4n, to: safeAddress, - value: BigInt(0), + value: 0n, data: '0x', }, removed: true, // Reorg @@ -413,7 +413,7 @@ describe('recovery-state', () => { const queryFilterMock = jest.fn() const defaultTransactionAddedFilter = { address: faker.finance.ethereumAddress(), - topics: [ethers.utils.id('TransactionAdded(uint256,bytes32,address,uint256,bytes,uint8)')], + topics: [id('TransactionAdded(uint256,bytes32,address,uint256,bytes,uint8)')], } const delayModifier = { filters: { @@ -426,9 +426,9 @@ describe('recovery-state', () => { txNonce: () => Promise.resolve(txNonce), txCreatedAt: jest .fn() - .mockResolvedValueOnce(BigInt(420)) - .mockResolvedValueOnce(BigInt(69420)) - .mockResolvedValueOnce(BigInt(6942069)), + .mockResolvedValueOnce(420n) + .mockResolvedValueOnce(69420n) + .mockResolvedValueOnce(6942069n), queueNonce: () => Promise.resolve(queueNonce), queryFilter: queryFilterMock.mockImplementation(() => Promise.resolve(transactionsAdded)), } @@ -452,16 +452,16 @@ describe('recovery-state', () => { queue: [ { ...transactionsAdded[0], - timestamp: BigInt(420).mul(1_000), - validFrom: BigInt(420).add(delay).mul(1_000), + timestamp: 420n * 1_000n, + validFrom: (420n + delay) * 1_000n, expiresAt: null, isMalicious: false, executor: transactionAddedReceipt.from, }, { ...transactionsAdded[1], - timestamp: BigInt(69420).mul(1_000), - validFrom: BigInt(69420).add(delay).mul(1_000), + timestamp: 69420n*1_000n, + validFrom: (69420n+delay)*1_000n, expiresAt: null, isMalicious: true, executor: transactionAddedReceipt.from, @@ -473,7 +473,7 @@ describe('recovery-state', () => { ...defaultTransactionAddedFilter, topics: [ ...defaultTransactionAddedFilter.topics, - [ethers.utils.hexZeroPad('0x2', 32), ethers.utils.hexZeroPad('0x3', 32)], + [zeroPadValue('0x02', 32), zeroPadValue('0x03', 32)], ], }, safeCreationReceipt.blockNumber, @@ -489,15 +489,15 @@ describe('recovery-state', () => { const provider = {} as unknown as JsonRpcProvider const recoverers = [faker.finance.ethereumAddress()] - const expiry = BigInt(0) - const delay = BigInt(69420) - const txNonce = BigInt(2) - const queueNonce = BigInt(2) + const expiry = (0n) + const delay = (69420n) + const txNonce = (2n) + const queueNonce = (2n) const queryFilterMock = jest.fn() const defaultTransactionAddedFilter = { address: faker.finance.ethereumAddress(), - topics: [ethers.utils.id('TransactionAdded(uint256,bytes32,address,uint256,bytes,uint8)')], + topics: [id('TransactionAdded(uint256,bytes32,address,uint256,bytes,uint8)')], } const delayModifier = { filters: { diff --git a/src/features/recovery/services/__tests__/setup.test.ts b/src/features/recovery/services/__tests__/setup.test.ts index 81e53660d3..1582739b06 100644 --- a/src/features/recovery/services/__tests__/setup.test.ts +++ b/src/features/recovery/services/__tests__/setup.test.ts @@ -1,7 +1,7 @@ import { getModuleInstance, KnownContracts, deployAndSetUpModule } from '@gnosis.pm/zodiac' import { faker } from '@faker-js/faker' import { OperationType } from '@safe-global/safe-core-sdk-types' -import { SENTINEL_ADDRESS } from '@safe-global/safe-core-sdk/dist/src/utils/constants' +import { SENTINEL_ADDRESS } from '@safe-global/protocol-kit/dist/src/utils/constants' import type { Web3Provider } from '@ethersproject/providers' import { _getEditRecoveryTransactions, _getRecoverySetupTransactions } from '@/features/recovery/services/setup' diff --git a/src/features/recovery/services/__tests__/transaction-list.test.ts b/src/features/recovery/services/__tests__/transaction-list.test.ts index 042b44febd..431a86fe47 100644 --- a/src/features/recovery/services/__tests__/transaction-list.test.ts +++ b/src/features/recovery/services/__tests__/transaction-list.test.ts @@ -1,8 +1,8 @@ import { faker } from '@faker-js/faker' import { getMultiSendCallOnlyDeployment, getSafeSingletonDeployment } from '@safe-global/safe-deployments' import { Interface } from 'ethers' -import { SENTINEL_ADDRESS } from '@safe-global/safe-core-sdk/dist/src/utils/constants' -import { encodeMultiSendData } from '@safe-global/safe-core-sdk/dist/src/utils/transactions/utils' +import { SENTINEL_ADDRESS } from '@safe-global/protocol-kit/dist/src/utils/constants' +import { encodeMultiSendData } from '@safe-global/protocol-kit/dist/src/utils/transactions/utils' import { safeInfoBuilder } from '@/tests/builders/safe' import { getRecoveredSafeInfo } from '../transaction-list' diff --git a/src/features/recovery/services/__tests__/transaction.test.ts b/src/features/recovery/services/__tests__/transaction.test.ts index 32b6674e38..920b2a511e 100644 --- a/src/features/recovery/services/__tests__/transaction.test.ts +++ b/src/features/recovery/services/__tests__/transaction.test.ts @@ -1,6 +1,6 @@ import { faker } from '@faker-js/faker' import { Interface } from 'ethers' -import { SENTINEL_ADDRESS } from '@safe-global/safe-core-sdk/dist/src/utils/constants' +import { SENTINEL_ADDRESS } from '@safe-global/protocol-kit/dist/src/utils/constants' import type { SafeInfo } from '@safe-global/safe-gateway-typescript-sdk' import { getRecoveryProposalTransactions } from '../transaction' diff --git a/src/features/recovery/services/delay-modifier.ts b/src/features/recovery/services/delay-modifier.ts index 054137cf59..26e5fb277f 100644 --- a/src/features/recovery/services/delay-modifier.ts +++ b/src/features/recovery/services/delay-modifier.ts @@ -1,5 +1,5 @@ import { ContractVersions, getModuleInstance, KnownContracts } from '@gnosis.pm/zodiac' -import { SENTINEL_ADDRESS } from '@safe-global/safe-core-sdk/dist/src/utils/constants' +import { SENTINEL_ADDRESS } from '@safe-global/protocol-kit/dist/src/utils/constants' import type { Delay, SupportedNetworks } from '@gnosis.pm/zodiac' import type { JsonRpcProvider } from '@ethersproject/providers' import type { SafeInfo } from '@safe-global/safe-gateway-typescript-sdk' diff --git a/src/features/recovery/services/recovery-state.ts b/src/features/recovery/services/recovery-state.ts index 4f9d7ca7dc..275737006b 100644 --- a/src/features/recovery/services/recovery-state.ts +++ b/src/features/recovery/services/recovery-state.ts @@ -1,4 +1,4 @@ -import { SENTINEL_ADDRESS } from '@safe-global/safe-core-sdk/dist/src/utils/constants' +import { SENTINEL_ADDRESS } from '@safe-global/protocol-kit/dist/src/utils/constants' import memoize from 'lodash/memoize' import { getMultiSendCallOnlyDeployment } from '@safe-global/safe-deployments' import { hexZeroPad } from '@ethersproject/bytes' @@ -47,10 +47,10 @@ export function _isMaliciousRecovery({ transaction: Pick }) { const BASE_MULTI_SEND_CALL_ONLY_VERSION = '1.3.0' - + const isMultiSend = isMultiSendCalldata(transaction.data) const transactions = isMultiSend ? decodeMultiSendTxs(transaction.data) : [transaction] - + if (!isMultiSend) { // Calling the Safe itself return !sameAddress(transaction.to, safeAddress) @@ -84,8 +84,7 @@ export const _getRecoveryQueueItemTimestamps = async ({ delay: bigint expiry: bigint }): Promise> => { - const timestamp = (await delayModifier.txCreatedAt(transactionAdded.args.queueNonce)).toBigInt() - + const timestamp = BigInt(await delayModifier.txCreatedAt(transactionAdded.args.queueNonce)) const validFrom = timestamp + delay const expiresAt = expiry === BigInt(0) @@ -143,8 +142,13 @@ const queryAddedTransactions = async ( // We filter for the valid nonces while fetching the event logs. // The nonce has to be one between the current queueNonce and the txNonce. const diff = queueNonce - txNonce - const queueNonceFilter = Array.from({ length: Number(diff) }, (_, idx) => - hexZeroPad(BigInt(txNonce + BigInt(idx)).toString(16), 32), + const queueNonceFilter = Array.from({ length: Number(diff) }, (_, idx) => { + console.log('queueNonceFilter', queueNonce, txNonce, idx, + + BigInt(12319283721298371289312893).toString(16), + BigInt(txNonce + BigInt(idx)), BigInt(txNonce + BigInt(idx)).toString(16)) + return hexZeroPad('0x'+BigInt(txNonce + BigInt(idx)).toString(16), 32) + } ) transactionAddedFilter.topics[1] = queueNonceFilter } @@ -223,8 +227,8 @@ export const _getRecoveryStateItem = async ({ const queuedTransactionsAdded = await queryAddedTransactions( delayModifier, - queueNonce.toBigInt(), - txNonce.toBigInt(), + BigInt(queueNonce), + BigInt(txNonce), transactionService, provider, safeAddress, @@ -235,8 +239,8 @@ export const _getRecoveryStateItem = async ({ return getRecoveryQueueItem({ delayModifier, transactionAdded, - delay: delay.toBigInt(), - expiry: expiry.toBigInt(), + delay: BigInt(delay), + expiry: BigInt(expiry), provider, chainId, version, @@ -248,10 +252,10 @@ export const _getRecoveryStateItem = async ({ return { address: delayModifier.address, recoverers, - expiry: expiry.toBigInt(), - delay: delay.toBigInt(), - txNonce: txNonce.toBigInt(), - queueNonce: queueNonce.toBigInt(), + expiry: BigInt(expiry), + delay: BigInt(delay), + txNonce: BigInt(txNonce), + queueNonce: BigInt(queueNonce), queue: queue.filter((item) => !item.removed), } } diff --git a/src/features/recovery/services/selectors.ts b/src/features/recovery/services/selectors.ts index dee0968be2..ceda752f17 100644 --- a/src/features/recovery/services/selectors.ts +++ b/src/features/recovery/services/selectors.ts @@ -16,7 +16,7 @@ export const selectDelayModifierByRecoverer = createSelector( ) export const selectRecoveryQueues = createSelector([selectRecovery], (recovery) => { - return recovery?.flatMap(({ queue }) => queue).sort((a, b) => a.timestamp.sub(b.timestamp).toNumber()) + return recovery?.flatMap(({ queue }) => queue).sort((a, b) => Number(a.timestamp - b.timestamp)) }) export const selectDelayModifierByTxHash = createSelector( diff --git a/src/features/recovery/services/setup.ts b/src/features/recovery/services/setup.ts index c72f7a2bc8..19d8ad4406 100644 --- a/src/features/recovery/services/setup.ts +++ b/src/features/recovery/services/setup.ts @@ -1,5 +1,5 @@ import { OperationType } from '@safe-global/safe-core-sdk-types' -import { SENTINEL_ADDRESS } from '@safe-global/safe-core-sdk/dist/src/utils/constants' +import { SENTINEL_ADDRESS } from '@safe-global/protocol-kit/dist/src/utils/constants' import { getModuleInstance, KnownContracts, deployAndSetUpModule } from '@gnosis.pm/zodiac' import { Interface } from 'ethers' import type { JsonRpcProvider } from '@ethersproject/providers' @@ -114,13 +114,13 @@ export async function _getEditRecoveryTransactions({ const txData: Array = [] // Update cooldown - if (!oldDelay.eq(newDelay)) { + if (oldDelay !== BigInt(newDelay)) { const setTxCooldown = delayModifierContract.interface.encodeFunctionData('setTxCooldown', [newDelay]) txData.push(setTxCooldown) } // Update expiration - if (!oldExpiry.eq(newExpiry)) { + if (oldExpiry !== BigInt(newExpiry)) { const setTxExpiration = delayModifierContract.interface.encodeFunctionData('setTxExpiration', [newExpiry]) txData.push(setTxExpiration) } diff --git a/src/features/recovery/services/transaction-list.ts b/src/features/recovery/services/transaction-list.ts index b520176655..084acf0273 100644 --- a/src/features/recovery/services/transaction-list.ts +++ b/src/features/recovery/services/transaction-list.ts @@ -32,16 +32,16 @@ function decodeOwnerManagementTransaction(safe: SafeInfo, transaction: BaseTrans const [ownerToAdd, newThreshold] = safeInterface.decodeFunctionData('addOwnerWithThreshold', transaction.data) _owners = _owners.concat({ value: ownerToAdd }) - _threshold = newThreshold.toNumber() + _threshold = Number(newThreshold) } else if (isRemoveOwnerCalldata(transaction.data)) { const [, ownerToRemove, newThreshold] = safeInterface.decodeFunctionData('removeOwner', transaction.data) _owners = safe.owners.filter((owner) => !sameAddress(owner.value, ownerToRemove)) - _threshold = newThreshold.toNumber() + _threshold = Number(newThreshold) } else if (isChangeThresholdCalldata(transaction.data)) { const [newThreshold] = safeInterface.decodeFunctionData('changeThreshold', transaction.data) - _threshold = newThreshold.toNumber() + _threshold = Number(newThreshold) } else { throw new Error('Unexpected transaction') } diff --git a/src/features/recovery/services/transaction.ts b/src/features/recovery/services/transaction.ts index eeabb46111..164c20f62c 100644 --- a/src/features/recovery/services/transaction.ts +++ b/src/features/recovery/services/transaction.ts @@ -1,6 +1,6 @@ import { Interface } from 'ethers' import { getSafeSingletonDeployment } from '@safe-global/safe-deployments' -import { SENTINEL_ADDRESS } from '@safe-global/safe-core-sdk/dist/src/utils/constants' +import { SENTINEL_ADDRESS } from '@safe-global/protocol-kit/dist/src/utils/constants' import { OperationType } from '@safe-global/safe-core-sdk-types' import { sameAddress } from '@/utils/addresses' import { getModuleInstance, KnownContracts } from '@gnosis.pm/zodiac' diff --git a/src/hooks/__tests__/useAddressResolver.test.ts b/src/hooks/__tests__/useAddressResolver.test.ts index f2356f1e6d..cf8604113e 100644 --- a/src/hooks/__tests__/useAddressResolver.test.ts +++ b/src/hooks/__tests__/useAddressResolver.test.ts @@ -1,13 +1,13 @@ import { useAddressResolver } from '@/hooks/useAddressResolver' import * as addressBook from '@/hooks/useAddressBook' -import { ethers } from 'ethers' +import { zeroPadValue } from 'ethers' import * as domains from '@/services/ens' import * as web3 from '@/hooks/wallets/web3' import * as useChains from '@/hooks/useChains' import { renderHook, waitFor } from '@/tests/test-utils' import { JsonRpcProvider } from '@ethersproject/providers' -const ADDRESS1 = ethers.utils.hexZeroPad('0x1', 20) +const ADDRESS1 = zeroPadValue('0x01', 20) const mockProvider = new JsonRpcProvider() describe('useAddressResolver', () => { diff --git a/src/hooks/__tests__/useLoadSpendingLimits.test.ts b/src/hooks/__tests__/useLoadSpendingLimits.test.ts index 66c2f9a6ae..4d97dd9a37 100644 --- a/src/hooks/__tests__/useLoadSpendingLimits.test.ts +++ b/src/hooks/__tests__/useLoadSpendingLimits.test.ts @@ -1,6 +1,6 @@ import * as spendingLimit from '@/services/contracts/spendingLimitContracts' import { JsonRpcProvider } from '@ethersproject/providers' -import { ZERO_ADDRESS } from '@safe-global/safe-core-sdk/dist/src/utils/constants' +import { ZERO_ADDRESS } from '@safe-global/protocol-kit/dist/src/utils/constants' import type { AllowanceModule } from '@/types/contracts' import { ERC20__factory } from '@/types/contracts' import { diff --git a/src/hooks/__tests__/useSafeTokenAllocation.test.ts b/src/hooks/__tests__/useSafeTokenAllocation.test.ts index a20f45ef2c..3006e45906 100644 --- a/src/hooks/__tests__/useSafeTokenAllocation.test.ts +++ b/src/hooks/__tests__/useSafeTokenAllocation.test.ts @@ -10,7 +10,7 @@ import useSafeTokenAllocation, { } from '../useSafeTokenAllocation' import * as web3 from '../wallets/web3' import * as useSafeInfoHook from '@/hooks/useSafeInfo' -import { ZERO_ADDRESS } from '@safe-global/safe-core-sdk/dist/src/utils/constants' +import { ZERO_ADDRESS } from '@safe-global/protocol-kit/dist/src/utils/constants' import type { JsonRpcProvider } from '@ethersproject/providers' const setupFetchStub = @@ -313,7 +313,7 @@ describe('Allocations', () => { const balanceOfSigHash = keccak256(toUtf8Bytes('balanceOf(address)')).slice(0, 10) if (transaction.data?.startsWith(balanceOfSigHash)) { - return Promise.resolve(BigInt('400').toString(16)) + return Promise.resolve('0x' + BigInt('400').toString(16)) } return Promise.resolve('0x') }, diff --git a/src/hooks/coreSDK/__tests__/safeCoreSDK.test.ts b/src/hooks/coreSDK/__tests__/safeCoreSDK.test.ts index 0e1d7731ad..fe81eb6656 100644 --- a/src/hooks/coreSDK/__tests__/safeCoreSDK.test.ts +++ b/src/hooks/coreSDK/__tests__/safeCoreSDK.test.ts @@ -1,11 +1,11 @@ import { defaultAbiCoder } from '@ethersproject/abi' import { hexZeroPad } from '@ethersproject/bytes' import { id } from 'ethers' -import Safe from '@safe-global/safe-core-sdk' +import Safe from '@safe-global/protocol-kit' import { getProxyFactoryContract, getSafeContract, -} from '@safe-global/safe-core-sdk/dist/src/contracts/safeDeploymentContracts' +} from '@safe-global/protocol-kit/dist/src/contracts/safeDeploymentContracts' import { ImplementationVersionState } from '@safe-global/safe-gateway-typescript-sdk' import { Web3Provider } from '@ethersproject/providers' @@ -18,7 +18,7 @@ jest.mock('@/services/contracts/safeContracts', () => { } }) -jest.mock('@safe-global/safe-core-sdk/dist/src/contracts/safeDeploymentContracts') +jest.mock('@safe-global/protocol-kit/dist/src/contracts/safeDeploymentContracts') jest.mock('@/types/contracts', () => { return { @@ -142,7 +142,7 @@ describe('safeCoreSDK', () => { }) expect(sdk).toBeInstanceOf(Safe) - expect(sdk?.getContractManager().isL1SafeMasterCopy).toBe(true) + expect(sdk?.getContractManager().isL1SafeSingleton).toBe(true) }) it('should return an L2 SDK instance for L2 chain', async () => { @@ -161,7 +161,7 @@ describe('safeCoreSDK', () => { }) expect(sdk).toBeInstanceOf(Safe) - expect(sdk?.getContractManager().isL1SafeMasterCopy).toBe(false) + expect(sdk?.getContractManager().isL1SafeSingleton).toBe(false) }) it('should return an L1 SDK instance for legacy Safes, regardless of chain', async () => { @@ -180,7 +180,7 @@ describe('safeCoreSDK', () => { }) expect(sdk).toBeInstanceOf(Safe) - expect(sdk?.getContractManager().isL1SafeMasterCopy).toBe(true) + expect(sdk?.getContractManager().isL1SafeSingleton).toBe(true) }) }) @@ -220,7 +220,7 @@ describe('safeCoreSDK', () => { }) expect(sdk).toBeInstanceOf(Safe) - expect(sdk?.getContractManager().isL1SafeMasterCopy).toBe(true) + expect(sdk?.getContractManager().isL1SafeSingleton).toBe(true) }) it('should return undefined for unsupported mastercopies', async () => { diff --git a/src/hooks/coreSDK/__tests__/useInitSafeCoreSDK.test.ts b/src/hooks/coreSDK/__tests__/useInitSafeCoreSDK.test.ts index 8a4a64ae4e..aebaad93ca 100644 --- a/src/hooks/coreSDK/__tests__/useInitSafeCoreSDK.test.ts +++ b/src/hooks/coreSDK/__tests__/useInitSafeCoreSDK.test.ts @@ -7,7 +7,7 @@ import * as coreSDK from '@/hooks/coreSDK/safeCoreSDK' import type { SafeInfo } from '@safe-global/safe-gateway-typescript-sdk' import { ImplementationVersionState } from '@safe-global/safe-gateway-typescript-sdk' import { waitFor } from '@testing-library/react' -import type Safe from '@safe-global/safe-core-sdk' +import type Safe from '@safe-global/protocol-kit' import type { JsonRpcProvider } from '@ethersproject/providers' describe('useInitSafeCoreSDK hook', () => { diff --git a/src/hooks/coreSDK/safeCoreSDK.ts b/src/hooks/coreSDK/safeCoreSDK.ts index f942e96469..fd369721f6 100644 --- a/src/hooks/coreSDK/safeCoreSDK.ts +++ b/src/hooks/coreSDK/safeCoreSDK.ts @@ -4,10 +4,11 @@ import { getSafeSingletonDeployment, getSafeL2SingletonDeployment } from '@safe- import ExternalStore from '@/services/ExternalStore' import { Gnosis_safe__factory } from '@/types/contracts' import { invariant } from '@/utils/helpers' -import type { JsonRpcProvider, Web3Provider } from '@ethersproject/providers' -import Safe from '@safe-global/safe-core-sdk' +// import type { JsonRpcProvider, Web3Provider } from '@ethersproject/providers' +import type { JsonRpcProvider, BrowserProvider } from 'ethers' +import Safe from '@safe-global/protocol-kit' import type { SafeVersion } from '@safe-global/safe-core-sdk-types' -import EthersAdapter from '@safe-global/safe-ethers-lib' +import {EthersAdapter} from '@safe-global/protocol-kit' import type { SafeInfo } from '@safe-global/safe-gateway-typescript-sdk' import { ethers } from 'ethers' import semverSatisfies from 'semver/functions/satisfies' @@ -28,8 +29,8 @@ export function assertValidSafeVersion(safeVersio return invariant(isValidSafeVersion(safeVersion), `${safeVersion} is not a valid Safe Account version`) } -export const createEthersAdapter = (provider: Web3Provider) => { - const signer = provider.getSigner(0) +export const createEthersAdapter = async (provider: BrowserProvider) => { + const signer = await provider.getSigner(0) return new EthersAdapter({ ethers, signerOrProvider: signer, @@ -37,6 +38,7 @@ export const createEthersAdapter = (provider: Web3Provider) => { } export const createReadOnlyEthersAdapter = (provider = getWeb3ReadOnly()) => { + if (!provider) { throw new Error('Unable to create `EthersAdapter` without a provider') } @@ -67,7 +69,7 @@ export const initSafeSDK = async ({ }: SafeCoreSDKProps): Promise => { const safeVersion = version ?? (await Gnosis_safe__factory.connect(address, provider).VERSION()) - let isL1SafeMasterCopy = chainId === chains.eth + let isL1SafeSingleton = chainId === chains.eth // If it is an official deployment we should still initiate the safeSDK if (!isValidMasterCopy(implementationVersionState)) { @@ -76,24 +78,24 @@ export const initSafeSDK = async ({ const safeL1Deployment = getSafeSingletonDeployment({ network: chainId, version: safeVersion }) const safeL2Deployment = getSafeL2SingletonDeployment({ network: chainId, version: safeVersion }) - isL1SafeMasterCopy = masterCopy === safeL1Deployment?.networkAddresses[chainId] + isL1SafeSingleton = masterCopy === safeL1Deployment?.networkAddresses[chainId] const isL2SafeMasterCopy = masterCopy === safeL2Deployment?.networkAddresses[chainId] // Unknown deployment, which we do not want to support - if (!isL1SafeMasterCopy && !isL2SafeMasterCopy) { + if (!isL1SafeSingleton && !isL2SafeMasterCopy) { return Promise.resolve(undefined) } } // Legacy Safe contracts if (isLegacyVersion(safeVersion)) { - isL1SafeMasterCopy = true + isL1SafeSingleton = true } return Safe.create({ ethAdapter: createReadOnlyEthersAdapter(provider), safeAddress: address, - isL1SafeMasterCopy, + isL1SafeSingleton: isL1SafeSingleton, }) } diff --git a/src/hooks/loadables/useLoadSpendingLimits.ts b/src/hooks/loadables/useLoadSpendingLimits.ts index 74ed511988..82d77a7f66 100644 --- a/src/hooks/loadables/useLoadSpendingLimits.ts +++ b/src/hooks/loadables/useLoadSpendingLimits.ts @@ -12,7 +12,7 @@ import { sameAddress } from '@/utils/addresses' import { type AllowanceModule } from '@/types/contracts' import { getERC20TokenInfoOnChain } from '@/utils/tokens' -import { sameString } from '@safe-global/safe-core-sdk/dist/src/utils' +import { sameString } from '@safe-global/protocol-kit/dist/src/utils' import { useAppSelector } from '@/store' import { selectTokens } from '@/store/balancesSlice' import isEqual from 'lodash/isEqual' diff --git a/src/hooks/useGasLimit.ts b/src/hooks/useGasLimit.ts index 6cfe236c00..92dc302557 100644 --- a/src/hooks/useGasLimit.ts +++ b/src/hooks/useGasLimit.ts @@ -1,5 +1,5 @@ import { useEffect, useMemo } from 'react' -import type Safe from '@safe-global/safe-core-sdk' +import type Safe from '@safe-global/protocol-kit' import { encodeSignatures } from '@/services/tx/encodeSignatures' import type { SafeTransaction } from '@safe-global/safe-core-sdk-types' import { OperationType } from '@safe-global/safe-core-sdk-types' diff --git a/src/hooks/useGasPrice.ts b/src/hooks/useGasPrice.ts index b003c52d72..a8ab44f7be 100644 --- a/src/hooks/useGasPrice.ts +++ b/src/hooks/useGasPrice.ts @@ -1,4 +1,4 @@ -import type { FeeData } from '@ethersproject/abstract-provider' +import type { FeeData } from 'ethers' import type { GasPrice, GasPriceFixed, @@ -102,8 +102,8 @@ const getGasParameters = ( ): GasFeeParams => { if (!estimation) { return { - maxFeePerGas: isEIP1559 ? feeData?.maxFeePerGas?.toBigInt() : feeData?.gasPrice?.toBigInt(), - maxPriorityFeePerGas: isEIP1559 ? feeData?.maxPriorityFeePerGas?.toBigInt() : undefined, + maxFeePerGas: isEIP1559 ? feeData?.maxFeePerGas : feeData?.gasPrice, + maxPriorityFeePerGas: isEIP1559 ? feeData?.maxPriorityFeePerGas : undefined, } } @@ -114,7 +114,7 @@ const getGasParameters = ( if ('gasPrice' in estimation) { return { maxFeePerGas: estimation.gasPrice, - maxPriorityFeePerGas: isEIP1559 ? feeData?.maxPriorityFeePerGas?.toBigInt() : undefined, + maxPriorityFeePerGas: isEIP1559 ? feeData?.maxPriorityFeePerGas : undefined, } } diff --git a/src/hooks/useSafeTokenAllocation.ts b/src/hooks/useSafeTokenAllocation.ts index 2b17d6903e..70aa31434f 100644 --- a/src/hooks/useSafeTokenAllocation.ts +++ b/src/hooks/useSafeTokenAllocation.ts @@ -1,9 +1,9 @@ import { getSafeTokenAddress } from '@/components/common/SafeTokenWidget' import { cgwDebugStorage } from '@/components/sidebar/DebugToggle' import { IS_PRODUCTION } from '@/config/constants' -import { ZERO_ADDRESS } from '@safe-global/safe-core-sdk/dist/src/utils/constants' +import { ZERO_ADDRESS } from '@safe-global/protocol-kit/dist/src/utils/constants' import { isPast } from 'date-fns' -import { defaultAbiCoder, Interface } from '@ethersproject/abi' +import { AbiCoder, Interface } from 'ethers' import { useMemo } from 'react' import useAsync, { type AsyncResult } from './useAsync' import useSafeInfo from './useSafeInfo' @@ -38,7 +38,7 @@ export type Vesting = VestingData & { // We currently do not have typechain as dependency so we fallback to human readable ABIs const airdropInterface = new Interface([ 'function redeemDeadline() public returns (uint64)', - 'function vestings(bytes32) public returns ({address account, uint8 curveType,bool managed, uint16 durationWeeks, uint64 startDate, uint128 amount, uint128 amountClaimed, uint64 pausingDate,bool cancelled})', + 'function vestings(bytes32) public returns (address account, uint8 curveType,bool managed, uint16 durationWeeks, uint64 startDate, uint128 amount, uint128 amountClaimed, uint64 pausingDate,bool cancelled)', ]) const tokenInterface = new Interface(['function balanceOf(address _owner) public view returns (uint256 balance)']) @@ -66,11 +66,12 @@ const completeAllocation = async (allocation: VestingData): Promise => data: airdropInterface.encodeFunctionData('vestings', [allocation.vestingId]), }) - const decodedVestingData = defaultAbiCoder.decode( + const decodedVestingData = AbiCoder.defaultAbiCoder().decode( // account, curveType, managed, durationWeeks, startDate, amount, amountClaimed, pausingDate, cancelled} ['address', 'uint8', 'bool', 'uint16', 'uint64', 'uint128', 'uint128', 'uint64', 'bool'], onChainVestingData, ) + const isRedeemed = decodedVestingData[0].toLowerCase() !== ZERO_ADDRESS.toLowerCase() if (isRedeemed) { return { ...allocation, isRedeemed, isExpired: false, amountClaimed: decodedVestingData[6] } @@ -159,7 +160,7 @@ export const useSafeVotingPower = (allocationData?: Vesting[]): AsyncResult { if (hiddenAssets.includes(balanceItem.tokenInfo.address)) { - return acc.sub(safeParseUnits(truncateNumber(balanceItem.fiatBalance), PRECISION) || 0) + return acc - BigInt(safeParseUnits(truncateNumber(balanceItem.fiatBalance), PRECISION) || 0) } return acc - }, BigInt(balances.fiatTotal === '' ? 0 : safeParseUnits(truncateNumber(balances.fiatTotal), PRECISION))) + }, BigInt(balances.fiatTotal === '' ? 0 : safeParseUnits(truncateNumber(balances.fiatTotal), PRECISION) || 0)) .toString(), PRECISION, ) diff --git a/src/hooks/useWalletCanPay.ts b/src/hooks/useWalletCanPay.ts index dd60f2d586..ddd1a06cc8 100644 --- a/src/hooks/useWalletCanPay.ts +++ b/src/hooks/useWalletCanPay.ts @@ -17,7 +17,7 @@ const useWalletCanPay = ({ const totalFee = (maxFeePerGas + BigInt(maxPriorityFeePerGas || 0)) * gasLimit - return walletBalance.gte(totalFee) + return walletBalance >= totalFee } export default useWalletCanPay diff --git a/src/hooks/wallets/useWalletBalance.ts b/src/hooks/wallets/useWalletBalance.ts index 9f7551ab28..80644fcd50 100644 --- a/src/hooks/wallets/useWalletBalance.ts +++ b/src/hooks/wallets/useWalletBalance.ts @@ -1,18 +1,18 @@ import useAsync, { type AsyncResult } from '../useAsync' import useWallet from './useWallet' import { useWeb3ReadOnly } from '@/hooks/wallets/web3' -import { type BigNumber } from 'ethers' -const useWalletBalance = (): AsyncResult => { +const useWalletBalance = (): AsyncResult => { const web3ReadOnly = useWeb3ReadOnly() const wallet = useWallet() - return useAsync(() => { + return useAsync(async () => { if (!wallet || !web3ReadOnly) { return undefined } - return web3ReadOnly.getBalance(wallet.address, 'latest') + const balance = await web3ReadOnly.getBalance(wallet.address, 'latest') + return balance.toBigInt() }, [wallet, web3ReadOnly]) } diff --git a/src/hooks/wallets/web3.ts b/src/hooks/wallets/web3.ts index 796cf8b741..442b27e866 100644 --- a/src/hooks/wallets/web3.ts +++ b/src/hooks/wallets/web3.ts @@ -1,9 +1,9 @@ import { RPC_AUTHENTICATION, type RpcUri } from '@safe-global/safe-gateway-typescript-sdk' import { INFURA_TOKEN, SAFE_APPS_INFURA_TOKEN } from '@/config/constants' import { type EIP1193Provider } from '@web3-onboard/core' -import { JsonRpcProvider, Web3Provider } from '@ethersproject/providers' +import { JsonRpcProvider, BrowserProvider } from 'ethers' import ExternalStore from '@/services/ExternalStore' -import { EMPTY_DATA } from '@safe-global/safe-core-sdk/dist/src/utils/constants' +import { EMPTY_DATA } from '@safe-global/protocol-kit/dist/src/utils/constants' // RPC helpers const formatRpcServiceUrl = ({ authentication, value }: RpcUri, token: string): string => { @@ -24,20 +24,20 @@ export const getRpcServiceUrl = (rpcUri: RpcUri): string => { export const createWeb3ReadOnly = (rpcUri: RpcUri, customRpc?: string): JsonRpcProvider | undefined => { const url = customRpc || getRpcServiceUrl(rpcUri) if (!url) return - return new JsonRpcProvider({ url, timeout: 10_000 }) + return new JsonRpcProvider(url) } -export const createWeb3 = (walletProvider: EIP1193Provider): Web3Provider => { - return new Web3Provider(walletProvider) +export const createWeb3 = (walletProvider: EIP1193Provider): BrowserProvider => { + return new BrowserProvider(walletProvider) } export const createSafeAppsWeb3Provider = (safeAppsRpcUri: RpcUri, customRpc?: string): JsonRpcProvider | undefined => { const url = customRpc || formatRpcServiceUrl(safeAppsRpcUri, SAFE_APPS_INFURA_TOKEN) if (!url) return - return new JsonRpcProvider({ url, timeout: 10_000 }) + return new JsonRpcProvider(url) } -export const { setStore: setWeb3, useStore: useWeb3 } = new ExternalStore() +export const { setStore: setWeb3, useStore: useWeb3 } = new ExternalStore() export const { getStore: getWeb3ReadOnly, diff --git a/src/services/contracts/safeContracts.ts b/src/services/contracts/safeContracts.ts index ada870c7db..332f23fdde 100644 --- a/src/services/contracts/safeContracts.ts +++ b/src/services/contracts/safeContracts.ts @@ -10,13 +10,12 @@ import { ImplementationVersionState } from '@safe-global/safe-gateway-typescript import type { ChainInfo, SafeInfo } from '@safe-global/safe-gateway-typescript-sdk' import type { GetContractProps, SafeVersion } from '@safe-global/safe-core-sdk-types' import { assertValidSafeVersion, createEthersAdapter, createReadOnlyEthersAdapter } from '@/hooks/coreSDK/safeCoreSDK' -import type SignMessageLibEthersContract from '@safe-global/safe-ethers-lib/dist/src/contracts/SignMessageLib/SignMessageLibEthersContract' -import type CompatibilityFallbackHandlerEthersContract from '@safe-global/safe-ethers-lib/dist/src/contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerEthersContract' -import type { Web3Provider } from '@ethersproject/providers' -import type GnosisSafeContractEthers from '@safe-global/safe-ethers-lib/dist/src/contracts/GnosisSafe/GnosisSafeContractEthers' -import type EthersAdapter from '@safe-global/safe-ethers-lib' +import type { BrowserProvider } from 'ethers' +import type { EthersAdapter, SafeContractEthers, SignMessageLibEthersContract } from '@safe-global/protocol-kit' import semver from 'semver' +import CompatibilityFallbackHandlerEthersContract from '@safe-global/protocol-kit/dist/src/adapters/ethers/contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerEthersContract'; + // `UNKNOWN` is returned if the mastercopy does not match supported ones // @see https://github.com/safe-global/safe-client-gateway/blob/main/src/routes/safes/handlers/safes.rs#L28-L31 // https://github.com/safe-global/safe-client-gateway/blob/main/src/routes/safes/converters.rs#L77-L79 @@ -25,9 +24,8 @@ export const isValidMasterCopy = (implementationVersionState: SafeInfo['implemen } export const _getValidatedGetContractProps = ( - chainId: string, safeVersion: SafeInfo['version'], -): Pick => { +): Pick => { assertValidSafeVersion(safeVersion) // SDK request here: https://github.com/safe-global/safe-core-sdk/issues/261 @@ -35,27 +33,26 @@ export const _getValidatedGetContractProps = ( const [noMetadataVersion] = safeVersion.split('+') return { - chainId: +chainId, safeVersion: noMetadataVersion as SafeVersion, } } // GnosisSafe -const getGnosisSafeContractEthers = (safe: SafeInfo, ethAdapter: EthersAdapter): GnosisSafeContractEthers => { +const getGnosisSafeContractEthers = async (safe: SafeInfo, ethAdapter: EthersAdapter): Promise => { return ethAdapter.getSafeContract({ customContractAddress: safe.address.value, - ..._getValidatedGetContractProps(safe.chainId, safe.version), + ..._getValidatedGetContractProps(safe.version), }) } -export const getReadOnlyCurrentGnosisSafeContract = (safe: SafeInfo): GnosisSafeContractEthers => { +export const getReadOnlyCurrentGnosisSafeContract = async (safe: SafeInfo): Promise => { const ethAdapter = createReadOnlyEthersAdapter() return getGnosisSafeContractEthers(safe, ethAdapter) } -export const getCurrentGnosisSafeContract = (safe: SafeInfo, provider: Web3Provider): GnosisSafeContractEthers => { - const ethAdapter = createEthersAdapter(provider) +export const getCurrentGnosisSafeContract = async (safe: SafeInfo, provider: BrowserProvider): Promise => { + const ethAdapter = await createEthersAdapter(provider) return getGnosisSafeContractEthers(safe, ethAdapter) } @@ -64,7 +61,7 @@ export const getReadOnlyGnosisSafeContract = (chain: ChainInfo, safeVersion: str return ethAdapter.getSafeContract({ singletonDeployment: getSafeContractDeployment(chain, safeVersion), - ..._getValidatedGetContractProps(chain.chainId, safeVersion), + ..._getValidatedGetContractProps(safeVersion), }) } @@ -80,17 +77,17 @@ export const _getMinimumMultiSendCallOnlyVersion = (safeVersion: SafeInfo['versi return semver.gte(safeVersion, INITIAL_CALL_ONLY_VERSION) ? safeVersion : INITIAL_CALL_ONLY_VERSION } -export const getMultiSendCallOnlyContract = ( +export const getMultiSendCallOnlyContract = async ( chainId: string, safeVersion: SafeInfo['version'], - provider: Web3Provider, + provider: BrowserProvider, ) => { - const ethAdapter = createEthersAdapter(provider) + const ethAdapter = await createEthersAdapter(provider) const multiSendVersion = _getMinimumMultiSendCallOnlyVersion(safeVersion) return ethAdapter.getMultiSendCallOnlyContract({ singletonDeployment: getMultiSendCallOnlyContractDeployment(chainId, multiSendVersion), - ..._getValidatedGetContractProps(chainId, safeVersion), + ..._getValidatedGetContractProps(safeVersion), }) } @@ -100,7 +97,7 @@ export const getReadOnlyMultiSendCallOnlyContract = (chainId: string, safeVersio return ethAdapter.getMultiSendCallOnlyContract({ singletonDeployment: getMultiSendCallOnlyContractDeployment(chainId, multiSendVersion), - ..._getValidatedGetContractProps(chainId, safeVersion), + ..._getValidatedGetContractProps(safeVersion), }) } @@ -111,34 +108,35 @@ export const getReadOnlyProxyFactoryContract = (chainId: string, safeVersion: Sa return ethAdapter.getSafeProxyFactoryContract({ singletonDeployment: getProxyFactoryContractDeployment(chainId, safeVersion), - ..._getValidatedGetContractProps(chainId, safeVersion), + ..._getValidatedGetContractProps(safeVersion), }) } // Fallback handler -export const getReadOnlyFallbackHandlerContract = ( +export const getReadOnlyFallbackHandlerContract = async ( chainId: string, safeVersion: SafeInfo['version'], -): CompatibilityFallbackHandlerEthersContract => { +): Promise => { const ethAdapter = createReadOnlyEthersAdapter() return ethAdapter.getCompatibilityFallbackHandlerContract({ singletonDeployment: getFallbackHandlerContractDeployment(chainId, safeVersion), - ..._getValidatedGetContractProps(chainId, safeVersion), + ..._getValidatedGetContractProps(safeVersion), }) } // Sign messages deployment -export const getReadOnlySignMessageLibContract = ( +export const getReadOnlySignMessageLibContract = async ( chainId: string, safeVersion: SafeInfo['version'], -): SignMessageLibEthersContract => { +): Promise => { + const ethAdapter = createReadOnlyEthersAdapter() return ethAdapter.getSignMessageLibContract({ singletonDeployment: getSignMessageLibContractDeployment(chainId, safeVersion), - ..._getValidatedGetContractProps(chainId, safeVersion), + ..._getValidatedGetContractProps(safeVersion), }) } diff --git a/src/services/ens/custom.ts b/src/services/ens/custom.ts index 1f5f2aeed7..07d95f5023 100644 --- a/src/services/ens/custom.ts +++ b/src/services/ens/custom.ts @@ -1,5 +1,5 @@ import { type JsonRpcProvider } from '@ethersproject/providers' -import { Contract, utils, constants } from 'ethers' +import { Contract, namehash, ZeroAddress } from 'ethers' // ENS Registry ABI (simplified version) const ensRegistryAbi = ['function resolver(bytes32 node) external view returns (address)'] @@ -11,15 +11,15 @@ export const customResolveName = async ( name: string, ): Promise => { const ensRegistry = new Contract(registryAddress, ensRegistryAbi, rpcProvider) - const namehash = utils.namehash(name) - const resolverAddress = await ensRegistry.resolver(namehash) + const nhash = namehash(name) + const resolverAddress = await ensRegistry.resolver(nhash) - if (resolverAddress === constants.AddressZero) { + if (resolverAddress === ZeroAddress) { return undefined } const resolver = new Contract(resolverAddress, resolverAbi, rpcProvider) - const address = await resolver.addr(namehash) + const address = await resolver.addr(nhash) return address || undefined } diff --git a/src/services/safe-messages/__tests__/safeMsgSender.test.ts b/src/services/safe-messages/__tests__/safeMsgSender.test.ts index d3fa5d93a0..1b47eb77b2 100644 --- a/src/services/safe-messages/__tests__/safeMsgSender.test.ts +++ b/src/services/safe-messages/__tests__/safeMsgSender.test.ts @@ -5,7 +5,8 @@ import { dispatchSafeMsgConfirmation, dispatchSafeMsgProposal } from '@/services import * as utils from '@/utils/safe-messages' import * as events from '@/services/safe-messages/safeMsgEvents' import * as sdk from '@/services/tx/tx-sender/sdk' -import { hexZeroPad } from '@ethersproject/bytes' +// import { hexZeroPad } from '@ethersproject/bytes' +import {zeroPadValue} from 'ethers' import type { EIP1193Provider, OnboardAPI, WalletState, AppState } from '@web3-onboard/core' jest.mock('@safe-global/safe-gateway-typescript-sdk', () => ({ @@ -59,14 +60,14 @@ const mockOnboard = { }, } as unknown as OnboardAPI -const mockValidSignature = `${hexZeroPad('0x456', 64)}1c` -const mockSignatureWithInvalidV = `${hexZeroPad('0x456', 64)}01` +const mockValidSignature = `${zeroPadValue('0x0456', 64)}1c` +const mockSignatureWithInvalidV = `${zeroPadValue('0x0456', 64)}01` describe('safeMsgSender', () => { beforeEach(() => { jest.clearAllMocks() - jest.spyOn(utils, 'generateSafeMessageHash').mockImplementation(() => '0x123') + jest.spyOn(utils, 'generateSafeMessageHash').mockImplementation(() => '0x0123') jest.spyOn(sdk, 'getAssertedChainSigner').mockResolvedValue({ _signTypedData: jest.fn().mockImplementation(() => Promise.resolve(mockValidSignature)), @@ -84,7 +85,7 @@ describe('safeMsgSender', () => { version: '1.3.0', chainId: '5', address: { - value: hexZeroPad('0x789', 20), + value: zeroPadValue('0x0789', 20), }, } as unknown as gateway.SafeInfo const message = 'Hello world' @@ -92,14 +93,14 @@ describe('safeMsgSender', () => { await dispatchSafeMsgProposal({ onboard: mockOnboard, safe, message, safeAppId }) - expect(proposeSafeMessageSpy).toHaveBeenCalledWith('5', hexZeroPad('0x789', 20), { + expect(proposeSafeMessageSpy).toHaveBeenCalledWith('5', zeroPadValue('0x0789', 20), { message, signature: mockValidSignature, safeAppId, }) expect(safeMsgDispatchSpy).toHaveBeenCalledWith(events.SafeMsgEvent.PROPOSE, { - messageHash: '0x123', + messageHash: '0x0123', }) }) @@ -112,7 +113,7 @@ describe('safeMsgSender', () => { version: '1.3.0', chainId: '5', address: { - value: hexZeroPad('0x789', 20), + value: zeroPadValue('0x0789', 20), }, } as unknown as gateway.SafeInfo const message: { @@ -125,9 +126,9 @@ describe('safeMsgSender', () => { Test: [{ name: 'test', type: 'string' }], }, domain: { - chainId: '1', + chainId: '0x1', name: 'TestDapp', - verifyingContract: hexZeroPad('0x1234', 20), + verifyingContract: zeroPadValue('0x1234', 20), }, message: { test: 'Hello World!', @@ -145,7 +146,7 @@ describe('safeMsgSender', () => { ] message.primaryType = 'Test' - expect(proposeSafeMessageSpy).toHaveBeenCalledWith('5', hexZeroPad('0x789', 20), { + expect(proposeSafeMessageSpy).toHaveBeenCalledWith('5', zeroPadValue('0x0789', 20), { message, signature: mockValidSignature, safeAppId, @@ -166,7 +167,7 @@ describe('safeMsgSender', () => { version: '1.3.0', chainId: '5', address: { - value: hexZeroPad('0x789', 20), + value: zeroPadValue('0x0789', 20), }, } as unknown as gateway.SafeInfo const message = 'Hello world' @@ -174,7 +175,7 @@ describe('safeMsgSender', () => { await dispatchSafeMsgProposal({ onboard: mockOnboard, safe, message, safeAppId }) - expect(proposeSafeMessageSpy).toHaveBeenCalledWith('5', hexZeroPad('0x789', 20), { + expect(proposeSafeMessageSpy).toHaveBeenCalledWith('5', zeroPadValue('0x0789', 20), { message, // Even though the mock returns the signature with invalid V, the valid signature should get dispatched as we adjust invalid Vs signature: mockValidSignature, @@ -182,7 +183,7 @@ describe('safeMsgSender', () => { }) expect(safeMsgDispatchSpy).toHaveBeenCalledWith(events.SafeMsgEvent.PROPOSE, { - messageHash: '0x123', + messageHash: '0x0123', }) }) @@ -196,7 +197,7 @@ describe('safeMsgSender', () => { version: '1.3.0', chainId: '5', address: { - value: hexZeroPad('0x789', 20), + value: zeroPadValue('0x0789', 20), }, } as unknown as gateway.SafeInfo const message = 'Hello world' @@ -207,14 +208,14 @@ describe('safeMsgSender', () => { } catch (e) { expect((e as Error).message).toBe('Example error') - expect(proposeSafeMessageSpy).toHaveBeenCalledWith('5', hexZeroPad('0x789', 20), { + expect(proposeSafeMessageSpy).toHaveBeenCalledWith('5', zeroPadValue('0x0789', 20), { message, signature: mockValidSignature, safeAppId, }) expect(safeMsgDispatchSpy).toHaveBeenCalledWith(events.SafeMsgEvent.PROPOSE_FAILED, { - messageHash: '0x123', + messageHash: '0x0123', error: expect.any(Error), }) } @@ -232,19 +233,19 @@ describe('safeMsgSender', () => { version: '1.3.0', chainId: '5', address: { - value: hexZeroPad('0x789', 20), + value: zeroPadValue('0x0789', 20), }, } as unknown as gateway.SafeInfo const message = 'Hello world' await dispatchSafeMsgConfirmation({ onboard: mockOnboard, safe, message }) - expect(confirmSafeMessageSpy).toHaveBeenCalledWith('5', '0x123', { + expect(confirmSafeMessageSpy).toHaveBeenCalledWith('5', '0x0123', { signature: mockValidSignature, }) expect(safeMsgDispatchSpy).toHaveBeenCalledWith(events.SafeMsgEvent.CONFIRM_PROPOSE, { - messageHash: '0x123', + messageHash: '0x0123', }) }) @@ -258,7 +259,7 @@ describe('safeMsgSender', () => { version: '1.3.0', chainId: '5', address: { - value: hexZeroPad('0x789', 20), + value: zeroPadValue('0x0789', 20), }, } as unknown as gateway.SafeInfo const message = 'Hello world' @@ -268,12 +269,12 @@ describe('safeMsgSender', () => { } catch (e) { expect((e as Error).message).toBe('Example error') - expect(confirmSafeMessageSpy).toHaveBeenCalledWith('5', '0x123', { + expect(confirmSafeMessageSpy).toHaveBeenCalledWith('5', '0x0123', { signature: mockValidSignature, }) expect(safeMsgDispatchSpy).toHaveBeenCalledWith(events.SafeMsgEvent.CONFIRM_PROPOSE_FAILED, { - messageHash: '0x123', + messageHash: '0x0123', error: expect.any(Error), }) } diff --git a/src/services/security/modules/RecipientAddressModule/index.test.ts b/src/services/security/modules/RecipientAddressModule/index.test.ts index 55dbf61eba..eeff2a9a89 100644 --- a/src/services/security/modules/RecipientAddressModule/index.test.ts +++ b/src/services/security/modules/RecipientAddressModule/index.test.ts @@ -34,7 +34,7 @@ describe('RecipientAddressModule', () => { it('should not warn if the address(es) is/are known', async () => { isSmartContractSpy.mockImplementation(() => Promise.resolve(false)) - mockGetBalance.mockImplementation(() => Promise.resolve(ethers.BigInt(1))) + mockGetBalance.mockImplementation(() => Promise.resolve(1n)) mockGetSafeInfo.mockImplementation(() => Promise.reject('Safe not found')) const recipient = hexZeroPad('0x1', 20) @@ -62,15 +62,15 @@ describe('RecipientAddressModule', () => { describe('it should warn if the address(es) is/are not known', () => { beforeEach(() => { isSmartContractSpy.mockImplementation(() => Promise.resolve(false)) - mockGetBalance.mockImplementation(() => Promise.resolve(ethers.BigInt(1))) + mockGetBalance.mockImplementation(() => Promise.resolve(1n)) mockGetSafeInfo.mockImplementation(() => Promise.reject('Safe not found')) }) // ERC-20 it('should warn about recipient of ERC-20 transfer recipients', async () => { - const erc20 = hexZeroPad('0x1', 20) + const erc20 = hexZeroPad('0x01', 20) - const recipient = hexZeroPad('0x2', 20) + const recipient = hexZeroPad('0x02', 20) const data = getMockErc20TransferCalldata(recipient) const safeTransaction = createMockSafeTransaction({ @@ -108,9 +108,9 @@ describe('RecipientAddressModule', () => { // ERC-721 it('should warn about recipient of ERC-721 transferFrom recipients', async () => { - const erc721 = hexZeroPad('0x1', 20) + const erc721 = hexZeroPad('0x01', 20) - const recipient = hexZeroPad('0x2', 20) + const recipient = hexZeroPad('0x02', 20) const data = getMockErc721TransferFromCalldata(recipient) const safeTransaction = createMockSafeTransaction({ @@ -147,9 +147,9 @@ describe('RecipientAddressModule', () => { }) it('should warn about recipient of ERC-721 safeTransferFrom(address,address,uint256) recipients', async () => { - const erc721 = hexZeroPad('0x1', 20) + const erc721 = hexZeroPad('0x01', 20) - const recipient = hexZeroPad('0x2', 20) + const recipient = hexZeroPad('0x02', 20) const data = getMockErc721SafeTransferFromCalldata(recipient) const safeTransaction = createMockSafeTransaction({ @@ -186,9 +186,9 @@ describe('RecipientAddressModule', () => { }) it('should warn about recipient of ERC-721 safeTransferFrom(address,address,uint256,bytes) recipients', async () => { - const erc721 = hexZeroPad('0x1', 20) + const erc721 = hexZeroPad('0x01', 20) - const recipient = hexZeroPad('0x2', 20) + const recipient = hexZeroPad('0x02', 20) const data = getMockErc721SafeTransferFromWithBytesCalldata(recipient) const safeTransaction = createMockSafeTransaction({ @@ -226,10 +226,10 @@ describe('RecipientAddressModule', () => { // multiSend it('should warn about recipient(s) of multiSend recipients', async () => { - const multiSend = hexZeroPad('0x1', 20) + const multiSend = hexZeroPad('0x01', 20) - const recipient1 = hexZeroPad('0x2', 20) - const recipient2 = hexZeroPad('0x3', 20) + const recipient1 = hexZeroPad('0x02', 20) + const recipient2 = hexZeroPad('0x03', 20) const data = getMockMultiSendCalldata([recipient1, recipient2]) @@ -282,10 +282,10 @@ describe('RecipientAddressModule', () => { it('should warn about recipient of native transfer recipients / should not warn if the address(es) is/are used', async () => { isSmartContractSpy.mockImplementation(() => Promise.resolve(false)) - mockGetBalance.mockImplementation(() => Promise.resolve(ethers.BigInt(1))) + mockGetBalance.mockImplementation(() => Promise.resolve(1n)) mockGetSafeInfo.mockImplementation(() => Promise.reject('Safe not found')) - const recipient = hexZeroPad('0x1', 20) + const recipient = hexZeroPad('0x01', 20) const safeTransaction = createMockSafeTransaction({ to: recipient, @@ -323,15 +323,15 @@ describe('RecipientAddressModule', () => { describe('it should warn if the address(es) is/are unused', () => { beforeEach(() => { isSmartContractSpy.mockImplementation(() => Promise.resolve(false)) - mockGetBalance.mockImplementation(() => Promise.resolve(ethers.BigInt(0))) + mockGetBalance.mockImplementation(() => Promise.resolve(0n)) mockGetSafeInfo.mockImplementation(() => Promise.reject('Safe not found')) }) // ERC-20 it('should warn about recipient of ERC-20 transfer recipients', async () => { - const erc20 = hexZeroPad('0x1', 20) + const erc20 = hexZeroPad('0x01', 20) - const recipient = hexZeroPad('0x2', 20) + const recipient = hexZeroPad('0x02', 20) const data = getMockErc20TransferCalldata(recipient) const safeTransaction = createMockSafeTransaction({ @@ -378,9 +378,9 @@ describe('RecipientAddressModule', () => { // ERC-721 it('should warn about recipient of ERC-721 transferFrom recipients', async () => { - const erc721 = hexZeroPad('0x1', 20) + const erc721 = hexZeroPad('0x01', 20) - const recipient = hexZeroPad('0x2', 20) + const recipient = hexZeroPad('0x02', 20) const data = getMockErc721TransferFromCalldata(recipient) const safeTransaction = createMockSafeTransaction({ @@ -426,9 +426,9 @@ describe('RecipientAddressModule', () => { }) it('should warn about recipient of ERC-721 safeTransferFrom(address,address,uint256) recipients', async () => { - const erc721 = hexZeroPad('0x1', 20) + const erc721 = hexZeroPad('0x01', 20) - const recipient = hexZeroPad('0x2', 20) + const recipient = hexZeroPad('0x02', 20) const data = getMockErc721SafeTransferFromCalldata(recipient) const safeTransaction = createMockSafeTransaction({ @@ -474,9 +474,9 @@ describe('RecipientAddressModule', () => { }) it('should warn about recipient of ERC-721 safeTransferFrom(address,address,uint256,bytes) recipients', async () => { - const erc721 = hexZeroPad('0x1', 20) + const erc721 = hexZeroPad('0x01', 20) - const recipient = hexZeroPad('0x2', 20) + const recipient = hexZeroPad('0x02', 20) const data = getMockErc721SafeTransferFromWithBytesCalldata(recipient) const safeTransaction = createMockSafeTransaction({ @@ -523,10 +523,10 @@ describe('RecipientAddressModule', () => { // multiSend it('should warn about recipient(s) of multiSend recipients', async () => { - const multiSend = hexZeroPad('0x1', 20) + const multiSend = hexZeroPad('0x01', 20) - const recipient1 = hexZeroPad('0x2', 20) - const recipient2 = hexZeroPad('0x3', 20) + const recipient1 = hexZeroPad('0x02', 20) + const recipient2 = hexZeroPad('0x03', 20) const data = getMockMultiSendCalldata([recipient1, recipient2]) @@ -593,7 +593,7 @@ describe('RecipientAddressModule', () => { // Other it('should warn about recipient of native transfer recipients', async () => { - const recipient = hexZeroPad('0x1', 20) + const recipient = hexZeroPad('0x01', 20) const safeTransaction = createMockSafeTransaction({ to: recipient, @@ -640,10 +640,10 @@ describe('RecipientAddressModule', () => { it('should not warn if the address(s) is/are Safe(s) deployed on the current network', async () => { isSmartContractSpy.mockImplementation(() => Promise.resolve(false)) - mockGetBalance.mockImplementation(() => Promise.resolve(ethers.BigInt(1))) + mockGetBalance.mockImplementation(() => Promise.resolve(1n)) mockGetSafeInfo.mockImplementation(() => Promise.resolve({} as SafeInfo)) - const recipient = hexZeroPad('0x1', 20) + const recipient = hexZeroPad('0x01', 20) const safeTransaction = createMockSafeTransaction({ to: recipient, @@ -681,15 +681,15 @@ describe('RecipientAddressModule', () => { describe('it should warn if the address(es) is/are Safe(s) deployed on mainnet but not the current network', () => { beforeEach(() => { isSmartContractSpy.mockImplementation(() => Promise.resolve(false)) - mockGetBalance.mockImplementation(() => Promise.resolve(ethers.BigInt(1))) + mockGetBalance.mockImplementation(() => Promise.resolve(1n)) mockGetSafeInfo.mockImplementation(() => Promise.resolve({} as SafeInfo)) }) // ERC-20 it('should warn about recipient of ERC-20 transfer recipients', async () => { - const erc20 = hexZeroPad('0x1', 20) + const erc20 = hexZeroPad('0x01', 20) - const recipient = hexZeroPad('0x2', 20) + const recipient = hexZeroPad('0x02', 20) const data = getMockErc20TransferCalldata(recipient) const safeTransaction = createMockSafeTransaction({ @@ -735,9 +735,9 @@ describe('RecipientAddressModule', () => { // ERC-721 it('should warn about recipient of ERC-721 transferFrom recipients', async () => { - const erc721 = hexZeroPad('0x1', 20) + const erc721 = hexZeroPad('0x01', 20) - const recipient = hexZeroPad('0x2', 20) + const recipient = hexZeroPad('0x02', 20) const data = getMockErc721TransferFromCalldata(recipient) const safeTransaction = createMockSafeTransaction({ @@ -782,9 +782,9 @@ describe('RecipientAddressModule', () => { }) it('should warn about recipient of ERC-721 safeTransferFrom(address,address,uint256) recipients', async () => { - const erc721 = hexZeroPad('0x1', 20) + const erc721 = hexZeroPad('0x01', 20) - const recipient = hexZeroPad('0x2', 20) + const recipient = hexZeroPad('0x02', 20) const data = getMockErc721SafeTransferFromCalldata(recipient) const safeTransaction = createMockSafeTransaction({ @@ -829,9 +829,9 @@ describe('RecipientAddressModule', () => { }) it('should warn about recipient of ERC-721 safeTransferFrom(address,address,uint256,bytes) recipients', async () => { - const erc721 = hexZeroPad('0x1', 20) + const erc721 = hexZeroPad('0x01', 20) - const recipient = hexZeroPad('0x2', 20) + const recipient = hexZeroPad('0x02', 20) const data = getMockErc721SafeTransferFromWithBytesCalldata(recipient) const safeTransaction = createMockSafeTransaction({ @@ -877,10 +877,10 @@ describe('RecipientAddressModule', () => { // multiSend it('should warn about recipient(s) of multiSend recipients', async () => { - const multiSend = hexZeroPad('0x1', 20) + const multiSend = hexZeroPad('0x01', 20) - const recipient1 = hexZeroPad('0x2', 20) - const recipient2 = hexZeroPad('0x3', 20) + const recipient1 = hexZeroPad('0x02', 20) + const recipient2 = hexZeroPad('0x03', 20) const data = getMockMultiSendCalldata([recipient1, recipient2]) @@ -946,7 +946,7 @@ describe('RecipientAddressModule', () => { // Other it('should warn about recipient of native transfer recipients', async () => { - const recipient = hexZeroPad('0x1', 20) + const recipient = hexZeroPad('0x01', 20) const safeTransaction = createMockSafeTransaction({ to: recipient, @@ -990,3 +990,4 @@ describe('RecipientAddressModule', () => { }) }) }) + \ No newline at end of file diff --git a/src/services/security/modules/RecipientAddressModule/index.ts b/src/services/security/modules/RecipientAddressModule/index.ts index aa514baea2..48957a7653 100644 --- a/src/services/security/modules/RecipientAddressModule/index.ts +++ b/src/services/security/modules/RecipientAddressModule/index.ts @@ -87,7 +87,7 @@ export class RecipientAddressModule this.shouldWarnOfMainnetSafe(chainId, address), ]) - if (balance.eq(0)) { + if (balance === 0n) { warnings.push({ severity: SecuritySeverity.LOW, address, diff --git a/src/services/tx/__tests__/safeUpdateParams.test.ts b/src/services/tx/__tests__/safeUpdateParams.test.ts index 12c8ae1b37..87f078f8c8 100644 --- a/src/services/tx/__tests__/safeUpdateParams.test.ts +++ b/src/services/tx/__tests__/safeUpdateParams.test.ts @@ -5,7 +5,7 @@ import { getSafeSingletonDeployment, } from '@safe-global/safe-deployments' import type { ChainInfo, SafeInfo } from '@safe-global/safe-gateway-typescript-sdk' -import { ethers } from 'ethers' +import { Interface } from 'ethers' import { createUpdateSafeTxs } from '../safeUpdateParams' import { LATEST_SAFE_VERSION } from '@/config/constants' import { Web3Provider } from '@ethersproject/providers' @@ -111,7 +111,7 @@ describe('safeUpgradeParams', () => { const decodeChangeMasterCopyAddress = (data: string): string => { const CHANGE_MASTER_COPY_ABI = 'function changeMasterCopy(address _masterCopy)' - const multiSendInterface = new ethers.utils.Interface([CHANGE_MASTER_COPY_ABI]) + const multiSendInterface = new Interface([CHANGE_MASTER_COPY_ABI]) const decodedAddress = multiSendInterface.decodeFunctionData('changeMasterCopy', data)[0] return decodedAddress.toString() } @@ -119,7 +119,7 @@ const decodeChangeMasterCopyAddress = (data: string): string => { const decodeSetFallbackHandlerAddress = (data: string): string => { const CHANGE_FALLBACK_HANDLER_ABI = 'function setFallbackHandler(address handler)' - const multiSendInterface = new ethers.utils.Interface([CHANGE_FALLBACK_HANDLER_ABI]) + const multiSendInterface = new Interface([CHANGE_FALLBACK_HANDLER_ABI]) const decodedAddress = multiSendInterface.decodeFunctionData('setFallbackHandler', data)[0] return decodedAddress.toString() } diff --git a/src/services/tx/__tests__/spendingLimitParams.test.ts b/src/services/tx/__tests__/spendingLimitParams.test.ts index 28ed94fe03..fdce131ff6 100644 --- a/src/services/tx/__tests__/spendingLimitParams.test.ts +++ b/src/services/tx/__tests__/spendingLimitParams.test.ts @@ -1,10 +1,10 @@ import type { NewSpendingLimitFlowProps } from '@/components/tx-flow/flows/NewSpendingLimit' -import { ZERO_ADDRESS } from '@safe-global/safe-core-sdk/dist/src/utils/constants' +import { ZERO_ADDRESS } from '@safe-global/protocol-kit/dist/src/utils/constants' import * as safeCoreSDK from '@/hooks/coreSDK/safeCoreSDK' import * as spendingLimit from '@/services/contracts/spendingLimitContracts' import * as txSender from '@/services/tx/tx-sender/create' import * as spendingLimitParams from '@/services/tx/spendingLimitParams' -import type Safe from '@safe-global/safe-core-sdk' +import type Safe from '@safe-global/protocol-kit' import type { SpendingLimitState } from '@/store/spendingLimitsSlice' import { createNewSpendingLimitTx } from '@/services/tx/tx-sender' diff --git a/src/services/tx/encodeSignatures.ts b/src/services/tx/encodeSignatures.ts index 689913ed96..84d3f73135 100644 --- a/src/services/tx/encodeSignatures.ts +++ b/src/services/tx/encodeSignatures.ts @@ -1,5 +1,5 @@ import type { SafeTransaction } from '@safe-global/safe-core-sdk-types' -import { generatePreValidatedSignature } from '@safe-global/safe-core-sdk/dist/src/utils/signatures' +import { generatePreValidatedSignature } from '@safe-global/protocol-kit/dist/src/utils/signatures' export const encodeSignatures = (safeTx: SafeTransaction, from?: string): string => { const owner = from?.toLowerCase() diff --git a/src/services/tx/tx-sender/__tests__/ts-sender.test.ts b/src/services/tx/tx-sender/__tests__/ts-sender.test.ts index 622fa3d374..2108bce0fb 100644 --- a/src/services/tx/tx-sender/__tests__/ts-sender.test.ts +++ b/src/services/tx/tx-sender/__tests__/ts-sender.test.ts @@ -1,5 +1,5 @@ import { setSafeSDK } from '@/hooks/coreSDK/safeCoreSDK' -import type Safe from '@safe-global/safe-core-sdk' +import type Safe from '@safe-global/protocol-kit' import type { TransactionResult } from '@safe-global/safe-core-sdk-types' import { type TransactionDetails } from '@safe-global/safe-gateway-typescript-sdk' import { getTransactionDetails } from '@safe-global/safe-gateway-typescript-sdk' @@ -17,9 +17,15 @@ import { } from '..' import { ErrorCode } from '@ethersproject/logger' import { waitFor } from '@/tests/test-utils' -import { ethers } from 'ethers' +import { BrowserProvider, zeroPadValue } from 'ethers' import * as safeContracts from '@/services/contracts/safeContracts' -import type MultiSendCallOnlyEthersContract from '@safe-global/safe-ethers-lib/dist/src/contracts/MultiSendCallOnly/MultiSendCallOnlyEthersContract' + +import type {MultiSendCallOnlyEthersContract} from '@safe-global/protocol-kit' +// import { BrowserProvider } from 'ethers' + +// import { createWeb3 } from '@/hooks/wallets/web3' +import * as web3 from '@/hooks/wallets/web3' + const setupFetchStub = (data: any) => (_url: string) => { return Promise.resolve({ @@ -30,8 +36,9 @@ const setupFetchStub = (data: any) => (_url: string) => { } import type { EIP1193Provider, OnboardAPI, WalletState, AppState } from '@web3-onboard/core' import { hexZeroPad } from '@ethersproject/bytes' -import { generatePreValidatedSignature } from '@safe-global/safe-core-sdk/dist/src/utils/signatures' +import { generatePreValidatedSignature } from '@safe-global/protocol-kit/dist/src/utils/signatures' import { createMockSafeTransaction } from '@/tests/transactions' +import { JsonRpcApiPollingProvider, JsonRpcSigner } from 'ethers/lib.commonjs/providers/provider-jsonrpc' // Mock getTransactionDetails jest.mock('@safe-global/safe-gateway-typescript-sdk', () => ({ @@ -57,10 +64,12 @@ jest.mock('../../proposeTransaction', () => ({ default: jest.fn(() => Promise.resolve({ txId: '123' })), })) + const mockProvider = { request: jest.fn, } as unknown as EIP1193Provider + const mockOnboardState = { chains: [], walletModules: [], @@ -545,7 +554,7 @@ describe('txSender', () => { ) }) - it('should reprice a tx', async () => { + it.only('should reprice a tx', async () => { jest.spyOn(mockSafeSDK, 'executeTransaction').mockImplementationOnce(() => Promise.resolve({ transactionResponse: { @@ -554,6 +563,14 @@ describe('txSender', () => { } as unknown as TransactionResult), ) + const mockBrowserProvider = new BrowserProvider(jest.fn() as unknown as EIP1193Provider) + + jest.spyOn(mockBrowserProvider, 'getSigner').mockImplementation( + async(address?: string | number | undefined) => Promise.resolve(jest.fn()) as unknown as JsonRpcSigner, + ) + jest.spyOn(web3, 'createWeb3').mockImplementation(() => mockBrowserProvider) + + const txId = 'tx_id_123' const safeTx = await createTx({ @@ -574,7 +591,7 @@ describe('txSender', () => { describe('dispatchBatchExecutionRelay', () => { it('should relay a batch execution', async () => { - const mockMultisendAddress = ethers.utils.hexZeroPad('0x1234', 20) + const mockMultisendAddress = zeroPadValue('0x1234', 20) const safeAddress = hexZeroPad('0x567', 20) const txDetails1 = { @@ -595,7 +612,7 @@ describe('txSender', () => { encodeFunctionData: jest.fn(() => expectedData), }, } as any, - getAddress: () => mockMultisendAddress, + getAddress: async () => mockMultisendAddress } as MultiSendCallOnlyEthersContract jest diff --git a/src/services/tx/tx-sender/create.ts b/src/services/tx/tx-sender/create.ts index bf4073c209..00cae72cc0 100644 --- a/src/services/tx/tx-sender/create.ts +++ b/src/services/tx/tx-sender/create.ts @@ -1,6 +1,6 @@ import type { TransactionDetails } from '@safe-global/safe-gateway-typescript-sdk' import { getTransactionDetails } from '@safe-global/safe-gateway-typescript-sdk' -import type { AddOwnerTxParams, RemoveOwnerTxParams, SwapOwnerTxParams } from '@safe-global/safe-core-sdk' +import type { AddOwnerTxParams, RemoveOwnerTxParams, SwapOwnerTxParams } from '@safe-global/protocol-kit' import type { MetaTransactionData, SafeTransaction, SafeTransactionDataPartial } from '@safe-global/safe-core-sdk-types' import extractTxInfo from '../extractTxInfo' import { getAndValidateSafeSDK } from './sdk' @@ -11,7 +11,7 @@ import { getAndValidateSafeSDK } from './sdk' export const createTx = async (txParams: SafeTransactionDataPartial, nonce?: number): Promise => { if (nonce !== undefined) txParams = { ...txParams, nonce } const safeSDK = getAndValidateSafeSDK() - return safeSDK.createTransaction({ safeTransactionData: txParams }) + return safeSDK.createTransaction({ transactions: [txParams] }) } /** diff --git a/src/services/tx/tx-sender/dispatch.ts b/src/services/tx/tx-sender/dispatch.ts index 7b1ab004e2..0c53bcc531 100644 --- a/src/services/tx/tx-sender/dispatch.ts +++ b/src/services/tx/tx-sender/dispatch.ts @@ -2,10 +2,10 @@ import type { SafeInfo, TransactionDetails } from '@safe-global/safe-gateway-typ import type { SafeTransaction, TransactionOptions, TransactionResult } from '@safe-global/safe-core-sdk-types' import type { EthersError } from '@/utils/ethers-utils' import { didReprice, didRevert } from '@/utils/ethers-utils' -import type MultiSendCallOnlyEthersContract from '@safe-global/safe-ethers-lib/dist/src/contracts/MultiSendCallOnly/MultiSendCallOnlyEthersContract' +import type { MultiSendCallOnlyEthersContract } from '@safe-global/protocol-kit' import { type SpendingLimitTxParams } from '@/components/tx-flow/flows/TokenTransfer/ReviewSpendingLimitTx' import { getSpendingLimitContract } from '@/services/contracts/spendingLimitContracts' -import type { ContractTransaction, PayableOverrides } from 'ethers' +import type { ContractTransaction, Overrides } from 'ethers' import type { RequestId } from '@safe-global/safe-apps-sdk' import proposeTx from '../proposeTransaction' import { txDispatch, TxEvent } from '../txEvents' @@ -138,6 +138,7 @@ export const dispatchTxExecution = async ( safeAddress: string, ): Promise => { const sdkUnchecked = await getUncheckedSafeSDK(onboard, chainId) + console.log('sdkUnchecked', sdkUnchecked) const eventParams = { txId } // Execute the tx @@ -182,7 +183,7 @@ export const dispatchBatchExecution = async ( onboard: OnboardAPI, chainId: SafeInfo['chainId'], safeAddress: string, - overrides?: PayableOverrides, + overrides?: Overrides, ) => { const groupKey = multiSendTxData diff --git a/src/services/tx/tx-sender/sdk.ts b/src/services/tx/tx-sender/sdk.ts index b30ae499d7..12fc240c3e 100644 --- a/src/services/tx/tx-sender/sdk.ts +++ b/src/services/tx/tx-sender/sdk.ts @@ -1,6 +1,6 @@ import { getSafeSDK } from '@/hooks/coreSDK/safeCoreSDK' -import type Safe from '@safe-global/safe-core-sdk' -import EthersAdapter from '@safe-global/safe-ethers-lib' +import type Safe from '@safe-global/protocol-kit' +import {EthersAdapter} from '@safe-global/protocol-kit' import { ethers } from 'ethers' import { isWalletRejection, isHardwareWallet } from '@/utils/wallets' import { OperationType, type SafeTransaction } from '@safe-global/safe-core-sdk-types' @@ -8,11 +8,11 @@ import type { SafeInfo } from '@safe-global/safe-gateway-typescript-sdk' import { SAFE_FEATURES } from '@safe-global/safe-core-sdk-utils' import { hasSafeFeature } from '@/utils/safe-versions' import { createWeb3 } from '@/hooks/wallets/web3' -import { hexValue } from 'ethers' +import { toQuantity } from 'ethers' import { connectWallet, getConnectedWallet } from '@/hooks/wallets/useOnboard' import { type OnboardAPI } from '@web3-onboard/core' import type { ConnectedWallet } from '@/hooks/wallets/useOnboard' -import type { JsonRpcSigner } from '@ethersproject/providers' +import type { JsonRpcSigner } from 'ethers' import { asError } from '@/services/exceptions/utils' export const getAndValidateSafeSDK = (): Safe => { @@ -39,7 +39,7 @@ export const switchWalletChain = async (onboard: OnboardAPI, chainId: string): P return wallets ? getConnectedWallet(wallets) : null } - const didSwitch = await onboard.setChain({ chainId: hexValue(parseInt(chainId)) }) + const didSwitch = await onboard.setChain({ chainId: toQuantity(parseInt(chainId)) }) if (!didSwitch) { return currentWallet } @@ -87,7 +87,9 @@ export const getAssertedChainSigner = async ( chainId: SafeInfo['chainId'], ): Promise => { const wallet = await assertWalletChain(onboard, chainId) + console.log('getAssertedChainSigner', wallet.provider) const provider = createWeb3(wallet.provider) + // console.log('provider', provider.getSigner()) return provider.getSigner() } @@ -98,12 +100,13 @@ export const getAssertedChainSigner = async ( * dealing with smart-contract wallet owners */ export const getUncheckedSafeSDK = async (onboard: OnboardAPI, chainId: SafeInfo['chainId']): Promise => { + // console.log('getUncheckedSafeSDK', onboard, chainId) const signer = await getAssertedChainSigner(onboard, chainId) const sdk = getAndValidateSafeSDK() const ethAdapter = new EthersAdapter({ ethers, - signerOrProvider: signer.connectUnchecked(), + signerOrProvider: signer.connect(), }) return sdk.connect({ ethAdapter }) diff --git a/src/tests/builders/safeTx.ts b/src/tests/builders/safeTx.ts index e4d798168a..84e6817499 100644 --- a/src/tests/builders/safeTx.ts +++ b/src/tests/builders/safeTx.ts @@ -1,7 +1,7 @@ import { Builder, type IBuilder } from '@/tests/Builder' import { faker } from '@faker-js/faker' import type { SafeSignature, SafeTransaction } from '@safe-global/safe-core-sdk-types' -import { ZERO_ADDRESS } from '@safe-global/safe-core-sdk/dist/src/utils/constants' +import { ZERO_ADDRESS } from '@safe-global/protocol-kit/dist/src/utils/constants' // TODO: Convert to builder export const createSafeTx = (data = '0x'): SafeTransaction => { diff --git a/src/tests/test-utils.tsx b/src/tests/test-utils.tsx index 988ce56465..5beaa9560f 100644 --- a/src/tests/test-utils.tsx +++ b/src/tests/test-utils.tsx @@ -8,7 +8,7 @@ import SafeThemeProvider from '@/components/theme/SafeThemeProvider' import type { RootState } from '@/store' import * as web3 from '@/hooks/wallets/web3' import { defaultAbiCoder } from '@ethersproject/abi' -import { ethers } from 'ethers' +import { id } from 'ethers' import type { Web3Provider } from '@ethersproject/providers' const mockRouter = (props: Partial = {}): NextRouter => ({ @@ -111,7 +111,7 @@ const mockWeb3Provider = ( call: (tx: { data: string; to: string }) => { { const matchedImplementation = callImplementations.find((implementation) => { - return tx.data.startsWith(ethers.utils.id(implementation.signature).slice(0, 10)) + return tx.data.startsWith(id(implementation.signature).slice(0, 10)) }) if (!matchedImplementation) { diff --git a/src/tests/transactions.ts b/src/tests/transactions.ts index 00c8a507ac..51286f71b7 100644 --- a/src/tests/transactions.ts +++ b/src/tests/transactions.ts @@ -1,5 +1,5 @@ -import { ZERO_ADDRESS } from '@safe-global/safe-core-sdk/dist/src/utils/constants' -import { ethers } from 'ethers' +import { ZERO_ADDRESS } from '@safe-global/protocol-kit/dist/src/utils/constants' +import { solidityPacked, concat } from 'ethers' import { OperationType, type SafeSignature } from '@safe-global/safe-core-sdk-types' import type { SafeTransaction } from '@safe-global/safe-core-sdk-types' @@ -48,7 +48,7 @@ export const getMockMultiSendCalldata = (recipients: Array): string => { const data = '0x' const internalTransactions = recipients.map((recipient) => { - return ethers.utils.solidityPack( + return solidityPacked( ['uint8', 'address', 'uint256', 'uint256', 'bytes'], [ OPERATION, @@ -61,7 +61,7 @@ export const getMockMultiSendCalldata = (recipients: Array): string => { }) const multiSendInterface = Multi_send__factory.createInterface() - return multiSendInterface.encodeFunctionData('multiSend', [ethers.utils.concat(internalTransactions)]) + return multiSendInterface.encodeFunctionData('multiSend', [concat(internalTransactions)]) } // TODO: Replace with safeTxBuilder diff --git a/src/utils/__tests__/safe-messages.test.ts b/src/utils/__tests__/safe-messages.test.ts index a61b338e03..0f4b126417 100644 --- a/src/utils/__tests__/safe-messages.test.ts +++ b/src/utils/__tests__/safe-messages.test.ts @@ -1,11 +1,11 @@ -import { ethers } from 'ethers' +import { zeroPadValue } from 'ethers' import type { SafeInfo } from '@safe-global/safe-gateway-typescript-sdk' import { generateSafeMessageTypedData, isOffchainEIP1271Supported } from '../safe-messages' import { hexZeroPad } from '@ethersproject/bytes' import { FEATURES } from '../chains' -const MOCK_ADDRESS = ethers.utils.hexZeroPad('0x123', 20) +const MOCK_ADDRESS = zeroPadValue('0x0123', 20) describe('safe-messages', () => { describe('createSafeMessage', () => { diff --git a/src/utils/ethers-utils.ts b/src/utils/ethers-utils.ts index 5b611b706a..a58930f983 100644 --- a/src/utils/ethers-utils.ts +++ b/src/utils/ethers-utils.ts @@ -1,5 +1,6 @@ import type { TransactionReceipt } from '@ethersproject/abstract-provider/lib' import type { ErrorCode } from '@ethersproject/logger' +import { Signature, type SignatureLike } from 'ethers'; // https://docs.ethers.io/v5/api/providers/types/#providers-TransactionResponse export enum EthersTxReplacedReason { @@ -18,3 +19,10 @@ export const didRevert = (receipt: EthersError['receipt']): boolean => { export const didReprice = (error: EthersError): boolean => { return error.reason === EthersTxReplacedReason.repriced } + +export const splitSignature = (sigBytes: string): Signature => { + return Signature.from(sigBytes) +} +export const joinSignature = (splitSig: SignatureLike): string => { + return Signature.from(splitSig).serialized +} \ No newline at end of file diff --git a/src/utils/safe-messages.ts b/src/utils/safe-messages.ts index b26e337b78..8f49212d6b 100644 --- a/src/utils/safe-messages.ts +++ b/src/utils/safe-messages.ts @@ -1,7 +1,7 @@ import { type JsonRpcSigner } from '@ethersproject/providers' import { getBytes, hashMessage, type TypedDataDomain } from 'ethers' import { gte } from 'semver' -import { adjustVInSignature } from '@safe-global/safe-core-sdk/dist/src/utils/signatures' +import { adjustVInSignature } from '@safe-global/protocol-kit/dist/src/utils/signatures' import { hashTypedData } from '@/utils/web3' import { isValidAddress } from './validation' diff --git a/tsconfig.json b/tsconfig.json index 045cbd3169..1fc4f56929 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "es2015", + "target": "es2020", "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "skipLibCheck": true, diff --git a/yarn.lock b/yarn.lock index f81d3fa018..58759c78b4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1466,7 +1466,7 @@ minimatch "^3.1.2" strip-json-comments "^3.1.1" -"@ethereumjs/common@2.5.0", "@ethereumjs/common@2.6.2", "@ethereumjs/common@^2.0.0", "@ethereumjs/common@^2.4.0", "@ethereumjs/common@^2.5.0", "@ethereumjs/common@^2.6.3", "@ethereumjs/common@^2.6.4", "@ethereumjs/common@^3.0.0", "@ethereumjs/common@^3.2.0": +"@ethereumjs/common@2.5.0", "@ethereumjs/common@2.6.2", "@ethereumjs/common@2.6.5", "@ethereumjs/common@^2.0.0", "@ethereumjs/common@^2.4.0", "@ethereumjs/common@^2.5.0", "@ethereumjs/common@^2.6.3", "@ethereumjs/common@^2.6.4", "@ethereumjs/common@^3.0.0", "@ethereumjs/common@^3.2.0": version "3.2.0" resolved "https://registry.yarnpkg.com/@ethereumjs/common/-/common-3.2.0.tgz#b71df25845caf5456449163012074a55f048e0a0" integrity sha512-pksvzI0VyLgmuEF2FA/JR/4/y6hcPq8OUail3/AvycBaW1d5VSauOZzqGvJ3RTmR4MU35lWE8KseKOsEhrFRBA== @@ -2086,7 +2086,7 @@ "@ethersproject/sha2" "^5.5.0" "@ethersproject/strings" "^5.5.0" -"@ethersproject/solidity@5.7.0", "@ethersproject/solidity@^5.7.0": +"@ethersproject/solidity@5.7.0": version "5.7.0" resolved "https://registry.yarnpkg.com/@ethersproject/solidity/-/solidity-5.7.0.tgz#5e9c911d8a2acce2a5ebb48a5e2e0af20b631cb8" integrity sha512-HmabMd2Dt/raavyaGukF4XxizWKhKQ24DoLtdNbBmNKUOPqwjsKQSdV9GQtj9CBEea9DlzETlVER1gYeXXBGaA== @@ -3629,6 +3629,11 @@ resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.2.tgz#6f26dbc8fbc7205873ce3cee2f690eba0d421b39" integrity sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ== +"@noble/hashes@^1.3.2": + version "1.3.3" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.3.tgz#39908da56a4adc270147bb07968bf3b16cfe1699" + integrity sha512-V7/fPHgl+jsVPXqqeOzT8egNj2iBIVt+ECeMMG8TdcnTikP3oaBtUVqpT/gYCR68aEBJSF+XbYUxStjbFMqIIA== + "@noble/hashes@~1.1.1": version "1.1.5" resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.1.5.tgz#1a0377f3b9020efe2fae03290bd2a12140c95c11" @@ -3882,6 +3887,30 @@ resolved "https://registry.yarnpkg.com/@rushstack/eslint-patch/-/eslint-patch-1.5.1.tgz#5f1b518ec5fa54437c0b7c4a821546c64fed6922" integrity sha512-6i/8UoL0P5y4leBIGzvkZdS85RDMG9y1ihZzmTZQ5LdHUYmZ7pKFoj8X0236s3lusPs1Fa5HTQUpwI+UfTcmeA== +"@safe-global/api-kit@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@safe-global/api-kit/-/api-kit-2.0.0.tgz#5d7aaf0a36f5843ba1d788343f0036bf015aa92f" + integrity sha512-Tz6pLEmhhv/ROsYSjVzoR8qw4YK72yNPJCFcK97kSvNJQpM2+HpRVYNjB53rY0IkvP0kVFvF6Ogp/BJri8g1Pw== + dependencies: + "@safe-global/protocol-kit" "^2.0.0" + "@safe-global/safe-core-sdk-types" "^3.0.0" + ethers "^6.7.1" + node-fetch "^2.7.0" + +"@safe-global/protocol-kit@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@safe-global/protocol-kit/-/protocol-kit-2.0.0.tgz#9d7cd6299dc9728c5c5d229a45b73a3b07ec4af7" + integrity sha512-alnSxNZKC1ssKrFG5ytluu9kNKGwBifb1xhOyCqwMnm72JksbCEo0UWlNvaeCiYMwhYvMyS++mfxcLAsV/8Gfw== + dependencies: + "@noble/hashes" "^1.3.2" + "@safe-global/safe-deployments" "^1.28.0" + ethereumjs-util "^7.1.5" + ethers "^6.7.1" + semver "^7.5.4" + web3 "^1.10.3" + web3-core "^1.10.3" + web3-utils "^1.10.3" + "@safe-global/safe-apps-sdk@^9.0.0-next.1": version "9.0.0-next.1" resolved "https://registry.yarnpkg.com/@safe-global/safe-apps-sdk/-/safe-apps-sdk-9.0.0-next.1.tgz#762186e36a3580c93e7efe7f49259c75043c5b7b" @@ -3890,7 +3919,7 @@ "@safe-global/safe-gateway-typescript-sdk" "^3.5.3" viem "^1.6.0" -"@safe-global/safe-core-sdk-types@^1.9.1", "@safe-global/safe-core-sdk-types@^1.9.2": +"@safe-global/safe-core-sdk-types@^1.9.2": version "1.10.1" resolved "https://registry.yarnpkg.com/@safe-global/safe-core-sdk-types/-/safe-core-sdk-types-1.10.1.tgz#94331b982671d2f2b8cc23114c58baf63d460c81" integrity sha512-BKvuYTLOlY16Rq6qCXglmnL6KxInDuXMFqZMaCzwDKiEh+uoHu3xCumG5tVtWOkCgBF4XEZXMqwZUiLcon7IsA== @@ -3901,6 +3930,16 @@ web3-core "^1.8.1" web3-utils "^1.8.1" +"@safe-global/safe-core-sdk-types@^3.0.0", "@safe-global/safe-core-sdk-types@^3.0.1": + version "3.0.1" + resolved "https://registry.yarnpkg.com/@safe-global/safe-core-sdk-types/-/safe-core-sdk-types-3.0.1.tgz#ec6d053b1648ab80c8d6909cf9d6b0be90b3d0f1" + integrity sha512-2AdlK6GJ5YEZXrQwFsHFwQScnNo3OonF3O6KzVeMc0/7OAuOTYBzKq1jzju2Eck6Z8UNPUinlHoF2Zb2pvTKhw== + dependencies: + "@safe-global/safe-deployments" "^1.28.0" + ethers "^6.7.1" + web3-core "^1.10.3" + web3-utils "^1.10.3" + "@safe-global/safe-core-sdk-utils@^1.7.4": version "1.7.4" resolved "https://registry.yarnpkg.com/@safe-global/safe-core-sdk-utils/-/safe-core-sdk-utils-1.7.4.tgz#810d36cf9629129a28eb1b9c6e690b163834b572" @@ -3910,20 +3949,6 @@ semver "^7.3.8" web3-utils "^1.8.1" -"@safe-global/safe-core-sdk@^3.3.5": - version "3.3.5" - resolved "https://registry.yarnpkg.com/@safe-global/safe-core-sdk/-/safe-core-sdk-3.3.5.tgz#30884639d368a9f50aa5fc96f78de87261ebdab3" - integrity sha512-ul+WmpxZOXgDIXrZ6MIHptThYbm0CVV3/rypMQEn4tZLkudh/yXK7EuWBFnx9prR3MePuku51Zcz9fu1vi7sfQ== - dependencies: - "@ethersproject/solidity" "^5.7.0" - "@safe-global/safe-core-sdk-types" "^1.9.2" - "@safe-global/safe-core-sdk-utils" "^1.7.4" - "@safe-global/safe-deployments" "^1.25.0" - ethereumjs-util "^7.1.5" - semver "^7.3.8" - web3-utils "^1.8.1" - zksync-web3 "^0.14.3" - "@safe-global/safe-deployments@1.28.0": version "1.28.0" resolved "https://registry.yarnpkg.com/@safe-global/safe-deployments/-/safe-deployments-1.28.0.tgz#9984b513999e5a1cd4449ed2c1ba9a66cb5b223c" @@ -3931,13 +3956,20 @@ dependencies: semver "^7.3.7" -"@safe-global/safe-deployments@^1.20.2", "@safe-global/safe-deployments@^1.25.0": +"@safe-global/safe-deployments@^1.20.2": version "1.27.0" resolved "https://registry.yarnpkg.com/@safe-global/safe-deployments/-/safe-deployments-1.27.0.tgz#e074d88543d084764b8bef7e3bddd238ac0d6819" integrity sha512-Fj6NW2JwSrC3vFIiheTRBGTAdZJSUtXk4rTkZgGoO8MnFM+pWU2pJU2rWzH3EYOXvrndxT2UxsiUIkTbmB2hkw== dependencies: semver "^7.3.7" +"@safe-global/safe-deployments@^1.28.0": + version "1.29.0" + resolved "https://registry.yarnpkg.com/@safe-global/safe-deployments/-/safe-deployments-1.29.0.tgz#72091773dccdea67d4a0066eeaaa816613b43cca" + integrity sha512-rXTktZblfklQyPe2JLK7GtXW/jH8htE6oP9MQHpVU5K/98OLkR4ApLAzlJscQEcyCaK+XOQunOk/gQYK1M2IpQ== + dependencies: + semver "^7.3.7" + "@safe-global/safe-ethers-lib@^1.9.4": version "1.9.4" resolved "https://registry.yarnpkg.com/@safe-global/safe-ethers-lib/-/safe-ethers-lib-1.9.4.tgz#049989a302c6f2010c574cf3a834b0cfb9cf67c5" @@ -5101,14 +5133,6 @@ mkdirp "^1.0.4" path-browserify "^1.0.1" -"@typechain/ethers-v5@^10.2.0": - version "10.2.1" - resolved "https://registry.yarnpkg.com/@typechain/ethers-v5/-/ethers-v5-10.2.1.tgz#50241e6957683281ecfa03fb5a6724d8a3ce2391" - integrity sha512-n3tQmCZjRE6IU4h6lqUGiQ1j866n5MTCBJreNEHHVWXa2u9GJTaeYyU1/k+1qLutkyw+sS6VAN+AbeiTqsxd/A== - dependencies: - lodash "^4.17.15" - ts-essentials "^7.0.1" - "@typechain/ethers-v6@^0.5.1": version "0.5.1" resolved "https://registry.yarnpkg.com/@typechain/ethers-v6/-/ethers-v6-0.5.1.tgz#42fe214a19a8b687086c93189b301e2b878797ea" @@ -9445,7 +9469,7 @@ ethers@5.7.2, ethers@^5.7.1: "@ethersproject/web" "5.7.1" "@ethersproject/wordlists" "5.7.0" -ethers@6.9.2: +ethers@6.9.2, ethers@^6.7.1: version "6.9.2" resolved "https://registry.yarnpkg.com/ethers/-/ethers-6.9.2.tgz#6f4632f62e2350fa8354ff28624027a175ef85a4" integrity sha512-YpkrtILnMQz5jSEsJQRTpduaGT/CXuLnUIuOYzHA0v/7c8IX91m2J48wSKjzGL5L9J/Us3tLoUdb+OwE3U+FFQ== @@ -12630,7 +12654,7 @@ node-fetch@2.6.7: dependencies: whatwg-url "^5.0.0" -node-fetch@^2.0.0, node-fetch@^2.6.0, node-fetch@^2.6.1, node-fetch@^2.6.12, node-fetch@^2.6.7: +node-fetch@^2.0.0, node-fetch@^2.6.0, node-fetch@^2.6.1, node-fetch@^2.6.12, node-fetch@^2.6.7, node-fetch@^2.7.0: version "2.7.0" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d" integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A== @@ -15747,6 +15771,15 @@ web3-bzz@1.10.0: got "12.1.0" swarm-js "^0.1.40" +web3-bzz@1.10.3: + version "1.10.3" + resolved "https://registry.yarnpkg.com/web3-bzz/-/web3-bzz-1.10.3.tgz#13942b37757eb850f3500a8e08bf605448b67566" + integrity sha512-XDIRsTwekdBXtFytMpHBuun4cK4x0ZMIDXSoo1UVYp+oMyZj07c7gf7tNQY5qZ/sN+CJIas4ilhN25VJcjSijQ== + dependencies: + "@types/node" "^12.12.6" + got "12.1.0" + swarm-js "^0.1.40" + web3-core-helpers@1.10.0: version "1.10.0" resolved "https://registry.yarnpkg.com/web3-core-helpers/-/web3-core-helpers-1.10.0.tgz#1016534c51a5df77ed4f94d1fcce31de4af37fad" @@ -15763,6 +15796,14 @@ web3-core-helpers@1.10.2: web3-eth-iban "1.10.2" web3-utils "1.10.2" +web3-core-helpers@1.10.3: + version "1.10.3" + resolved "https://registry.yarnpkg.com/web3-core-helpers/-/web3-core-helpers-1.10.3.tgz#f2db40ea57e888795e46f229b06113b60bcd671c" + integrity sha512-Yv7dQC3B9ipOc5sWm3VAz1ys70Izfzb8n9rSiQYIPjpqtJM+3V4EeK6ghzNR6CO2es0+Yu9CtCkw0h8gQhrTxA== + dependencies: + web3-eth-iban "1.10.3" + web3-utils "1.10.3" + web3-core-method@1.10.0: version "1.10.0" resolved "https://registry.yarnpkg.com/web3-core-method/-/web3-core-method-1.10.0.tgz#82668197fa086e8cc8066742e35a9d72535e3412" @@ -15785,6 +15826,17 @@ web3-core-method@1.10.2: web3-core-subscriptions "1.10.2" web3-utils "1.10.2" +web3-core-method@1.10.3: + version "1.10.3" + resolved "https://registry.yarnpkg.com/web3-core-method/-/web3-core-method-1.10.3.tgz#63f16310ccab4eec8eca0a337d534565c2ba8d33" + integrity sha512-VZ/Dmml4NBmb0ep5PTSg9oqKoBtG0/YoMPei/bq/tUdlhB2dMB79sbeJPwx592uaV0Vpk7VltrrrBv5hTM1y4Q== + dependencies: + "@ethersproject/transactions" "^5.6.2" + web3-core-helpers "1.10.3" + web3-core-promievent "1.10.3" + web3-core-subscriptions "1.10.3" + web3-utils "1.10.3" + web3-core-promievent@1.10.0: version "1.10.0" resolved "https://registry.yarnpkg.com/web3-core-promievent/-/web3-core-promievent-1.10.0.tgz#cbb5b3a76b888df45ed3a8d4d8d4f54ccb66a37b" @@ -15799,6 +15851,13 @@ web3-core-promievent@1.10.2: dependencies: eventemitter3 "4.0.4" +web3-core-promievent@1.10.3: + version "1.10.3" + resolved "https://registry.yarnpkg.com/web3-core-promievent/-/web3-core-promievent-1.10.3.tgz#9765dd42ce6cf2dc0a08eaffee607b855644f290" + integrity sha512-HgjY+TkuLm5uTwUtaAfkTgRx/NzMxvVradCi02gy17NxDVdg/p6svBHcp037vcNpkuGeFznFJgULP+s2hdVgUQ== + dependencies: + eventemitter3 "4.0.4" + web3-core-requestmanager@1.10.0: version "1.10.0" resolved "https://registry.yarnpkg.com/web3-core-requestmanager/-/web3-core-requestmanager-1.10.0.tgz#4b34f6e05837e67c70ff6f6993652afc0d54c340" @@ -15821,6 +15880,17 @@ web3-core-requestmanager@1.10.2: web3-providers-ipc "1.10.2" web3-providers-ws "1.10.2" +web3-core-requestmanager@1.10.3: + version "1.10.3" + resolved "https://registry.yarnpkg.com/web3-core-requestmanager/-/web3-core-requestmanager-1.10.3.tgz#c34ca8e998a18d6ca3fa7f7a11d4391da401c987" + integrity sha512-VT9sKJfgM2yBOIxOXeXiDuFMP4pxzF6FT+y8KTLqhDFHkbG3XRe42Vm97mB/IvLQCJOmokEjl3ps8yP1kbggyw== + dependencies: + util "^0.12.5" + web3-core-helpers "1.10.3" + web3-providers-http "1.10.3" + web3-providers-ipc "1.10.3" + web3-providers-ws "1.10.3" + web3-core-subscriptions@1.10.0: version "1.10.0" resolved "https://registry.yarnpkg.com/web3-core-subscriptions/-/web3-core-subscriptions-1.10.0.tgz#b534592ee1611788fc0cb0b95963b9b9b6eacb7c" @@ -15837,6 +15907,14 @@ web3-core-subscriptions@1.10.2: eventemitter3 "4.0.4" web3-core-helpers "1.10.2" +web3-core-subscriptions@1.10.3: + version "1.10.3" + resolved "https://registry.yarnpkg.com/web3-core-subscriptions/-/web3-core-subscriptions-1.10.3.tgz#58768cd72a9313252ef05dc52c09536f009a9479" + integrity sha512-KW0Mc8sgn70WadZu7RjQ4H5sNDJ5Lx8JMI3BWos+f2rW0foegOCyWhRu33W1s6ntXnqeBUw5rRCXZRlA3z+HNA== + dependencies: + eventemitter3 "4.0.4" + web3-core-helpers "1.10.3" + web3-core@1.10.0: version "1.10.0" resolved "https://registry.yarnpkg.com/web3-core/-/web3-core-1.10.0.tgz#9aa07c5deb478cf356c5d3b5b35afafa5fa8e633" @@ -15863,6 +15941,19 @@ web3-core@1.10.2, web3-core@^1.8.1: web3-core-requestmanager "1.10.2" web3-utils "1.10.2" +web3-core@1.10.3, web3-core@^1.10.3: + version "1.10.3" + resolved "https://registry.yarnpkg.com/web3-core/-/web3-core-1.10.3.tgz#4aeb8f4b0cb5775d9fa4edf1127864743f1c3ae3" + integrity sha512-Vbk0/vUNZxJlz3RFjAhNNt7qTpX8yE3dn3uFxfX5OHbuon5u65YEOd3civ/aQNW745N0vGUlHFNxxmn+sG9DIw== + dependencies: + "@types/bn.js" "^5.1.1" + "@types/node" "^12.12.6" + bignumber.js "^9.0.0" + web3-core-helpers "1.10.3" + web3-core-method "1.10.3" + web3-core-requestmanager "1.10.3" + web3-utils "1.10.3" + web3-eth-abi@1.10.0: version "1.10.0" resolved "https://registry.yarnpkg.com/web3-eth-abi/-/web3-eth-abi-1.10.0.tgz#53a7a2c95a571e205e27fd9e664df4919483cce1" @@ -15879,6 +15970,14 @@ web3-eth-abi@1.10.2: "@ethersproject/abi" "^5.6.3" web3-utils "1.10.2" +web3-eth-abi@1.10.3: + version "1.10.3" + resolved "https://registry.yarnpkg.com/web3-eth-abi/-/web3-eth-abi-1.10.3.tgz#7decfffa8fed26410f32cfefdc32d3e76f717ca2" + integrity sha512-O8EvV67uhq0OiCMekqYsDtb6FzfYzMXT7VMHowF8HV6qLZXCGTdB/NH4nJrEh2mFtEwVdS6AmLFJAQd2kVyoMQ== + dependencies: + "@ethersproject/abi" "^5.6.3" + web3-utils "1.10.3" + web3-eth-accounts@1.10.0: version "1.10.0" resolved "https://registry.yarnpkg.com/web3-eth-accounts/-/web3-eth-accounts-1.10.0.tgz#2942beca0a4291455f32cf09de10457a19a48117" @@ -15895,6 +15994,22 @@ web3-eth-accounts@1.10.0: web3-core-method "1.10.0" web3-utils "1.10.0" +web3-eth-accounts@1.10.3: + version "1.10.3" + resolved "https://registry.yarnpkg.com/web3-eth-accounts/-/web3-eth-accounts-1.10.3.tgz#9ecb816b81cd97333988bfcd0afaee5d13bbb198" + integrity sha512-8MipGgwusDVgn7NwKOmpeo3gxzzd+SmwcWeBdpXknuyDiZSQy9tXe+E9LeFGrmys/8mLLYP79n3jSbiTyv+6pQ== + dependencies: + "@ethereumjs/common" "2.6.5" + "@ethereumjs/tx" "3.5.2" + "@ethereumjs/util" "^8.1.0" + eth-lib "0.2.8" + scrypt-js "^3.0.1" + uuid "^9.0.0" + web3-core "1.10.3" + web3-core-helpers "1.10.3" + web3-core-method "1.10.3" + web3-utils "1.10.3" + web3-eth-contract@1.10.0: version "1.10.0" resolved "https://registry.yarnpkg.com/web3-eth-contract/-/web3-eth-contract-1.10.0.tgz#8e68c7654576773ec3c91903f08e49d0242c503a" @@ -15909,6 +16024,20 @@ web3-eth-contract@1.10.0: web3-eth-abi "1.10.0" web3-utils "1.10.0" +web3-eth-contract@1.10.3: + version "1.10.3" + resolved "https://registry.yarnpkg.com/web3-eth-contract/-/web3-eth-contract-1.10.3.tgz#8880468e2ba7d8a4791cf714f67d5e1ec1591275" + integrity sha512-Y2CW61dCCyY4IoUMD4JsEQWrILX4FJWDWC/Txx/pr3K/+fGsBGvS9kWQN5EsVXOp4g7HoFOfVh9Lf7BmVVSRmg== + dependencies: + "@types/bn.js" "^5.1.1" + web3-core "1.10.3" + web3-core-helpers "1.10.3" + web3-core-method "1.10.3" + web3-core-promievent "1.10.3" + web3-core-subscriptions "1.10.3" + web3-eth-abi "1.10.3" + web3-utils "1.10.3" + web3-eth-contract@^1.8.1: version "1.10.2" resolved "https://registry.yarnpkg.com/web3-eth-contract/-/web3-eth-contract-1.10.2.tgz#9114c52ba5ca5859f3403abea69a13f8678828ad" @@ -15937,6 +16066,20 @@ web3-eth-ens@1.10.0: web3-eth-contract "1.10.0" web3-utils "1.10.0" +web3-eth-ens@1.10.3: + version "1.10.3" + resolved "https://registry.yarnpkg.com/web3-eth-ens/-/web3-eth-ens-1.10.3.tgz#ae5b49bcb9823027e0b28aa6b1de58d726cbaafa" + integrity sha512-hR+odRDXGqKemw1GFniKBEXpjYwLgttTES+bc7BfTeoUyUZXbyDHe5ifC+h+vpzxh4oS0TnfcIoarK0Z9tFSiQ== + dependencies: + content-hash "^2.5.2" + eth-ens-namehash "2.0.8" + web3-core "1.10.3" + web3-core-helpers "1.10.3" + web3-core-promievent "1.10.3" + web3-eth-abi "1.10.3" + web3-eth-contract "1.10.3" + web3-utils "1.10.3" + web3-eth-iban@1.10.0: version "1.10.0" resolved "https://registry.yarnpkg.com/web3-eth-iban/-/web3-eth-iban-1.10.0.tgz#5a46646401965b0f09a4f58e7248c8a8cd22538a" @@ -15953,6 +16096,14 @@ web3-eth-iban@1.10.2: bn.js "^5.2.1" web3-utils "1.10.2" +web3-eth-iban@1.10.3: + version "1.10.3" + resolved "https://registry.yarnpkg.com/web3-eth-iban/-/web3-eth-iban-1.10.3.tgz#91d458e5400195edc883a0d4383bf1cecd17240d" + integrity sha512-ZCfOjYKAjaX2TGI8uif5ah+J3BYFuo+47JOIV1RIz2l7kD9VfnxvRH5UiQDRyMALQC7KFd2hUqIEtHklapNyKA== + dependencies: + bn.js "^5.2.1" + web3-utils "1.10.3" + web3-eth-personal@1.10.0: version "1.10.0" resolved "https://registry.yarnpkg.com/web3-eth-personal/-/web3-eth-personal-1.10.0.tgz#94d525f7a29050a0c2a12032df150ac5ea633071" @@ -15965,6 +16116,18 @@ web3-eth-personal@1.10.0: web3-net "1.10.0" web3-utils "1.10.0" +web3-eth-personal@1.10.3: + version "1.10.3" + resolved "https://registry.yarnpkg.com/web3-eth-personal/-/web3-eth-personal-1.10.3.tgz#4e72008aa211327ccc3bfa7671c510e623368457" + integrity sha512-avrQ6yWdADIvuNQcFZXmGLCEzulQa76hUOuVywN7O3cklB4nFc/Gp3yTvD3bOAaE7DhjLQfhUTCzXL7WMxVTsw== + dependencies: + "@types/node" "^12.12.6" + web3-core "1.10.3" + web3-core-helpers "1.10.3" + web3-core-method "1.10.3" + web3-net "1.10.3" + web3-utils "1.10.3" + web3-eth@1.10.0: version "1.10.0" resolved "https://registry.yarnpkg.com/web3-eth/-/web3-eth-1.10.0.tgz#38b905e2759697c9624ab080cfcf4e6c60b3a6cf" @@ -15983,6 +16146,24 @@ web3-eth@1.10.0: web3-net "1.10.0" web3-utils "1.10.0" +web3-eth@1.10.3: + version "1.10.3" + resolved "https://registry.yarnpkg.com/web3-eth/-/web3-eth-1.10.3.tgz#b8c6f37f1aac52422583a5a9c29130983a3fb3b1" + integrity sha512-Uk1U2qGiif2mIG8iKu23/EQJ2ksB1BQXy3wF3RvFuyxt8Ft9OEpmGlO7wOtAyJdoKzD5vcul19bJpPcWSAYZhA== + dependencies: + web3-core "1.10.3" + web3-core-helpers "1.10.3" + web3-core-method "1.10.3" + web3-core-subscriptions "1.10.3" + web3-eth-abi "1.10.3" + web3-eth-accounts "1.10.3" + web3-eth-contract "1.10.3" + web3-eth-ens "1.10.3" + web3-eth-iban "1.10.3" + web3-eth-personal "1.10.3" + web3-net "1.10.3" + web3-utils "1.10.3" + web3-net@1.10.0: version "1.10.0" resolved "https://registry.yarnpkg.com/web3-net/-/web3-net-1.10.0.tgz#be53e7f5dafd55e7c9013d49c505448b92c9c97b" @@ -15992,6 +16173,15 @@ web3-net@1.10.0: web3-core-method "1.10.0" web3-utils "1.10.0" +web3-net@1.10.3: + version "1.10.3" + resolved "https://registry.yarnpkg.com/web3-net/-/web3-net-1.10.3.tgz#9486c2fe51452cb958e11915db6f90bd6caa5482" + integrity sha512-IoSr33235qVoI1vtKssPUigJU9Fc/Ph0T9CgRi15sx+itysmvtlmXMNoyd6Xrgm9LuM4CIhxz7yDzH93B79IFg== + dependencies: + web3-core "1.10.3" + web3-core-method "1.10.3" + web3-utils "1.10.3" + web3-provider-engine@16.0.3: version "16.0.3" resolved "https://registry.yarnpkg.com/web3-provider-engine/-/web3-provider-engine-16.0.3.tgz#8ff93edf3a8da2f70d7f85c5116028c06a0d9f07" @@ -16040,6 +16230,16 @@ web3-providers-http@1.10.2: es6-promise "^4.2.8" web3-core-helpers "1.10.2" +web3-providers-http@1.10.3: + version "1.10.3" + resolved "https://registry.yarnpkg.com/web3-providers-http/-/web3-providers-http-1.10.3.tgz#d8166ee89db82d37281ea9e15c5882a2d7928755" + integrity sha512-6dAgsHR3MxJ0Qyu3QLFlQEelTapVfWNTu5F45FYh8t7Y03T1/o+YAkVxsbY5AdmD+y5bXG/XPJ4q8tjL6MgZHw== + dependencies: + abortcontroller-polyfill "^1.7.5" + cross-fetch "^4.0.0" + es6-promise "^4.2.8" + web3-core-helpers "1.10.3" + web3-providers-ipc@1.10.0: version "1.10.0" resolved "https://registry.yarnpkg.com/web3-providers-ipc/-/web3-providers-ipc-1.10.0.tgz#9747c7a6aee96a51488e32fa7c636c3460b39889" @@ -16056,6 +16256,14 @@ web3-providers-ipc@1.10.2: oboe "2.1.5" web3-core-helpers "1.10.2" +web3-providers-ipc@1.10.3: + version "1.10.3" + resolved "https://registry.yarnpkg.com/web3-providers-ipc/-/web3-providers-ipc-1.10.3.tgz#a7e015957fc037d8a87bd4b6ae3561c1b1ad1f46" + integrity sha512-vP5WIGT8FLnGRfswTxNs9rMfS1vCbMezj/zHbBe/zB9GauBRTYVrUo2H/hVrhLg8Ut7AbsKZ+tCJ4mAwpKi2hA== + dependencies: + oboe "2.1.5" + web3-core-helpers "1.10.3" + web3-providers-ws@1.10.0: version "1.10.0" resolved "https://registry.yarnpkg.com/web3-providers-ws/-/web3-providers-ws-1.10.0.tgz#cb0b87b94c4df965cdf486af3a8cd26daf3975e5" @@ -16074,6 +16282,15 @@ web3-providers-ws@1.10.2: web3-core-helpers "1.10.2" websocket "^1.0.32" +web3-providers-ws@1.10.3: + version "1.10.3" + resolved "https://registry.yarnpkg.com/web3-providers-ws/-/web3-providers-ws-1.10.3.tgz#03c84958f9da251349cd26fd7a4ae567e3af6caa" + integrity sha512-/filBXRl48INxsh6AuCcsy4v5ndnTZ/p6bl67kmO9aK1wffv7CT++DrtclDtVMeDGCgB3van+hEf9xTAVXur7Q== + dependencies: + eventemitter3 "4.0.4" + web3-core-helpers "1.10.3" + websocket "^1.0.32" + web3-shh@1.10.0: version "1.10.0" resolved "https://registry.yarnpkg.com/web3-shh/-/web3-shh-1.10.0.tgz#c2979b87e0f67a7fef2ce9ee853bd7bfbe9b79a8" @@ -16084,6 +16301,16 @@ web3-shh@1.10.0: web3-core-subscriptions "1.10.0" web3-net "1.10.0" +web3-shh@1.10.3: + version "1.10.3" + resolved "https://registry.yarnpkg.com/web3-shh/-/web3-shh-1.10.3.tgz#ee44f760598a65a290d611c443838aac854ee858" + integrity sha512-cAZ60CPvs9azdwMSQ/PSUdyV4PEtaW5edAZhu3rCXf6XxQRliBboic+AvwUvB6j3eswY50VGa5FygfVmJ1JVng== + dependencies: + web3-core "1.10.3" + web3-core-method "1.10.3" + web3-core-subscriptions "1.10.3" + web3-net "1.10.3" + web3-utils@1.10.0: version "1.10.0" resolved "https://registry.yarnpkg.com/web3-utils/-/web3-utils-1.10.0.tgz#ca4c1b431a765c14ac7f773e92e0fd9377ccf578" @@ -16111,6 +16338,20 @@ web3-utils@1.10.2, web3-utils@^1.8.1: randombytes "^2.1.0" utf8 "3.0.0" +web3-utils@1.10.3, web3-utils@^1.10.3: + version "1.10.3" + resolved "https://registry.yarnpkg.com/web3-utils/-/web3-utils-1.10.3.tgz#f1db99c82549c7d9f8348f04ffe4e0188b449714" + integrity sha512-OqcUrEE16fDBbGoQtZXWdavsPzbGIDc5v3VrRTZ0XrIpefC/viZ1ZU9bGEemazyS0catk/3rkOOxpzTfY+XsyQ== + dependencies: + "@ethereumjs/util" "^8.1.0" + bn.js "^5.2.1" + ethereum-bloom-filters "^1.0.6" + ethereum-cryptography "^2.1.2" + ethjs-unit "0.1.6" + number-to-bn "1.7.0" + randombytes "^2.1.0" + utf8 "3.0.0" + web3@1.10.0: version "1.10.0" resolved "https://registry.yarnpkg.com/web3/-/web3-1.10.0.tgz#2fde0009f59aa756c93e07ea2a7f3ab971091274" @@ -16124,6 +16365,19 @@ web3@1.10.0: web3-shh "1.10.0" web3-utils "1.10.0" +web3@^1.10.3: + version "1.10.3" + resolved "https://registry.yarnpkg.com/web3/-/web3-1.10.3.tgz#5e80ac532dc432b09fde668d570b0ad4e6710897" + integrity sha512-DgUdOOqC/gTqW+VQl1EdPxrVRPB66xVNtuZ5KD4adVBtko87hkgM8BTZ0lZ8IbUfnQk6DyjcDujMiH3oszllAw== + dependencies: + web3-bzz "1.10.3" + web3-core "1.10.3" + web3-eth "1.10.3" + web3-eth-personal "1.10.3" + web3-net "1.10.3" + web3-shh "1.10.3" + web3-utils "1.10.3" + webextension-polyfill@^0.10.0: version "0.10.0" resolved "https://registry.yarnpkg.com/webextension-polyfill/-/webextension-polyfill-0.10.0.tgz#ccb28101c910ba8cf955f7e6a263e662d744dbb8" @@ -16757,8 +17011,3 @@ yocto-queue@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== - -zksync-web3@^0.14.3: - version "0.14.3" - resolved "https://registry.yarnpkg.com/zksync-web3/-/zksync-web3-0.14.3.tgz#64ac2a16d597464c3fc4ae07447a8007631c57c9" - integrity sha512-hT72th4AnqyLW1d5Jlv8N2B/qhEnl2NePK2A3org7tAa24niem/UAaHMkEvmWI3SF9waYUPtqAtjpf+yvQ9zvQ==