Skip to content

Commit

Permalink
current progress
Browse files Browse the repository at this point in the history
  • Loading branch information
compojoom committed Jan 9, 2024
1 parent d92bda7 commit f60ba79
Show file tree
Hide file tree
Showing 84 changed files with 820 additions and 505 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/components/common/TokenAmountInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const TokenAmountInput = ({
}: {
balances: SafeBalanceResponse['items']
selectedToken: SafeBalanceResponse['items'][number] | undefined
maxAmount?: BigNumber
maxAmount?: bigint
validate?: (value: string) => string | undefined
}) => {
const {
Expand Down Expand Up @@ -63,7 +63,7 @@ const TokenAmountInput = ({
variant="standard"
InputProps={{
disableUnderline: true,
endAdornment: maxAmount && (
endAdornment: Number(maxAmount) && (
<Button className={css.max} onClick={onMaxAmountClick}>
Max
</Button>
Expand Down
3 changes: 1 addition & 2 deletions src/components/common/WalletBalance/index.tsx
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion src/components/new-safe/create/logic/index.test.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
11 changes: 6 additions & 5 deletions src/components/new-safe/create/logic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
6 changes: 3 additions & 3 deletions src/components/new-safe/create/steps/ReviewStep/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ const ReviewStep = ({ data, onSubmit, onBack, setStep }: StepRenderProps<NewSafe
gasLimit && maxFeePerGas
? formatVisualAmount(
maxFeePerGas
.add(
+ (
// maxPriorityFeePerGas is undefined if EIP-1559 disabled
maxPriorityFeePerGas || BigInt(0),
maxPriorityFeePerGas || 0n
)
.mul(gasLimit),
* gasLimit,
chain?.nativeCurrency.decimals,
)
: '> 0.001'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions src/components/settings/PushNotifications/logic.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -41,6 +42,7 @@ export const requestNotificationPermission = async (): Promise<boolean> => {
export const _adjustLedgerSignatureV = (signature: string): string => {
const split = splitSignature(signature)

// @ts-ignore
if (split.v === 0 || split.v === 1) {
split.v += 27
}
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -58,7 +58,7 @@ export const generateDataRowValue = (
case 'rawData':
return (
<div data-testid="tx-data-row" className={css.rawData}>
<div>{value ? hexDataLength(value) : 0} bytes</div>
<div>{value ? dataLength(value) : 0} bytes</div>
<CopyButton text={value} />
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
6 changes: 3 additions & 3 deletions src/components/tx-flow/flows/ExecuteBatch/ReviewBatch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'

Expand Down Expand Up @@ -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() }

Expand Down
2 changes: 1 addition & 1 deletion src/components/tx-flow/flows/NewSpendingLimit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export function RecoverAccountFlowReview({ params }: { params: RecoverAccountFlo
{recovery?.delay && (
<ErrorMessage level="info">
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.
</ErrorMessage>
)}
Expand Down
32 changes: 16 additions & 16 deletions src/components/tx-flow/flows/SignMessage/SignMessage.test.tsx
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -237,7 +237,7 @@ describe('SignMessage', () => {
confirmations: [
{
owner: {
value: hexZeroPad('0x2', 20),
value: zeroPadValue('0x02', 20),
},
},
],
Expand All @@ -258,7 +258,7 @@ describe('SignMessage', () => {
safe: {
version: '1.3.0',
address: {
value: hexZeroPad('0x1', 20),
value: zeroPadValue('0x01', 20),
},
chainId: '5',
threshold: 2,
Expand All @@ -280,7 +280,7 @@ describe('SignMessage', () => {
jest.spyOn(useWalletHook, 'default').mockImplementation(
() =>
({
address: hexZeroPad('0x3', 20),
address: zeroPadValue('0x03', 20),
} as ConnectedWallet),
)

Expand All @@ -289,7 +289,7 @@ describe('SignMessage', () => {
{
version: '1.3.0',
address: {
value: hexZeroPad('0x1', 20),
value: zeroPadValue('0x01', 20),
},
chainId: '5',
} as SafeInfo,
Expand All @@ -301,7 +301,7 @@ describe('SignMessage', () => {
confirmations: [
{
owner: {
value: hexZeroPad('0x2', 20),
value: zeroPadValue('0x02', 20),
},
},
],
Expand Down Expand Up @@ -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),
},
},
],
Expand All @@ -366,7 +366,7 @@ describe('SignMessage', () => {
safe: {
version: '1.3.0',
address: {
value: hexZeroPad('0x1', 20),
value: zeroPadValue('0x01', 20),
},
chainId: '5',
threshold: 2,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -451,15 +451,15 @@ describe('SignMessage', () => {
jest.spyOn(useWalletHook, 'default').mockImplementation(
() =>
({
address: hexZeroPad('0x2', 20),
address: zeroPadValue('0x02', 20),
} as ConnectedWallet),
)
const messageText = 'Hello world!'
const messageHash = generateSafeMessageHash(
{
version: '1.3.0',
address: {
value: hexZeroPad('0x1', 20),
value: zeroPadValue('0x01', 20),
},
chainId: '5',
} as SafeInfo,
Expand All @@ -471,7 +471,7 @@ describe('SignMessage', () => {
confirmations: [
{
owner: {
value: hexZeroPad('0x2', 20),
value: zeroPadValue('0x02', 20),
},
},
],
Expand Down Expand Up @@ -509,7 +509,7 @@ describe('SignMessage', () => {
jest.spyOn(useWalletHook, 'default').mockImplementation(
() =>
({
address: hexZeroPad('0x3', 20),
address: zeroPadValue('0x03', 20),
} as ConnectedWallet),
)

Expand Down
Loading

0 comments on commit f60ba79

Please sign in to comment.