diff --git a/src/components/settings/PushNotifications/PushNotificationsBanner/PushNotificationsBanner.test.tsx b/src/components/settings/PushNotifications/PushNotificationsBanner/PushNotificationsBanner.test.tsx
index 448c997e01..d48d520c6c 100644
--- a/src/components/settings/PushNotifications/PushNotificationsBanner/PushNotificationsBanner.test.tsx
+++ b/src/components/settings/PushNotifications/PushNotificationsBanner/PushNotificationsBanner.test.tsx
@@ -1,9 +1,10 @@
import 'fake-indexeddb/auto'
+import { extendedSafeInfoBuilder } from '@/tests/builders/safe'
import { toBeHex } from 'ethers'
import * as tracking from '@/services/analytics'
import { set } from 'idb-keyval'
import * as navigation from 'next/navigation'
-import type { ChainInfo, SafeInfo } from '@safe-global/safe-gateway-typescript-sdk'
+import type { ChainInfo } from '@safe-global/safe-gateway-typescript-sdk'
import { PushNotificationsBanner, _getSafesToRegister } from '.'
import { createPushNotificationPrefsIndexedDb } from '@/services/push-notifications/preferences'
@@ -95,6 +96,14 @@ describe('PushNotificationsBanner', () => {
})
describe('PushNotificationsBanner', () => {
+ const extendedSafeInfo = {
+ ...extendedSafeInfoBuilder().build(),
+ chainId: '1',
+ address: {
+ value: toBeHex('0x123', 20),
+ },
+ }
+
beforeEach(() => {
// Reset indexedDB
indexedDB = new IDBFactory()
@@ -140,12 +149,7 @@ describe('PushNotificationsBanner', () => {
safeInfo: {
loading: false,
error: undefined,
- data: {
- chainId: '1',
- address: {
- value: toBeHex('0x123', 20),
- },
- } as unknown as SafeInfo,
+ data: extendedSafeInfo,
},
},
})
@@ -187,12 +191,7 @@ describe('PushNotificationsBanner', () => {
safeInfo: {
loading: false,
error: undefined,
- data: {
- chainId: '1',
- address: {
- value: toBeHex('0x123', 20),
- },
- } as unknown as SafeInfo,
+ data: extendedSafeInfo,
},
},
},
@@ -233,12 +232,7 @@ describe('PushNotificationsBanner', () => {
safeInfo: {
loading: false,
error: undefined,
- data: {
- chainId: '1',
- address: {
- value: toBeHex('0x123', 20),
- },
- } as unknown as SafeInfo,
+ data: extendedSafeInfo,
},
},
},
@@ -277,12 +271,7 @@ describe('PushNotificationsBanner', () => {
safeInfo: {
loading: false,
error: undefined,
- data: {
- chainId: '1',
- address: {
- value: toBeHex('0x123', 20),
- },
- } as unknown as SafeInfo,
+ data: extendedSafeInfo,
},
},
},
@@ -317,12 +306,7 @@ describe('PushNotificationsBanner', () => {
safeInfo: {
loading: false,
error: undefined,
- data: {
- chainId: '1',
- address: {
- value: toBeHex('0x123', 20),
- },
- } as unknown as SafeInfo,
+ data: extendedSafeInfo,
},
},
},
@@ -366,12 +350,7 @@ describe('PushNotificationsBanner', () => {
safeInfo: {
loading: false,
error: undefined,
- data: {
- chainId: '1',
- address: {
- value: toBeHex('0x123', 20),
- },
- } as unknown as SafeInfo,
+ data: extendedSafeInfo,
},
},
},
diff --git a/src/components/settings/SafeModules/__tests__/SafeModules.test.tsx b/src/components/settings/SafeModules/__tests__/SafeModules.test.tsx
index f0204108a6..f68dafe367 100644
--- a/src/components/settings/SafeModules/__tests__/SafeModules.test.tsx
+++ b/src/components/settings/SafeModules/__tests__/SafeModules.test.tsx
@@ -1,19 +1,18 @@
+import { extendedSafeInfoBuilder } from '@/tests/builders/safe'
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 { zeroPadValue } from 'ethers'
const MOCK_MODULE_1 = zeroPadValue('0x01', 20)
const MOCK_MODULE_2 = zeroPadValue('0x02', 20)
describe('SafeModules', () => {
+ const extendedSafeInfo = extendedSafeInfoBuilder().build()
+
it('should render placeholder label without any modules', async () => {
jest.spyOn(useSafeInfoHook, 'default').mockImplementation(() => ({
- safe: {
- modules: [] as AddressEx[],
- chainId: '4',
- } as SafeInfo,
+ safe: extendedSafeInfo,
safeAddress: '0x123',
safeError: undefined,
safeLoading: false,
@@ -26,7 +25,7 @@ describe('SafeModules', () => {
it('should render placeholder label if safe is loading', async () => {
jest.spyOn(useSafeInfoHook, 'default').mockImplementation(() => ({
- safe: {} as SafeInfo,
+ safe: extendedSafeInfo,
safeAddress: '',
safeError: undefined,
safeLoading: true,
@@ -39,6 +38,7 @@ describe('SafeModules', () => {
it('should render module addresses for defined modules', async () => {
jest.spyOn(useSafeInfoHook, 'default').mockImplementation(() => ({
safe: {
+ ...extendedSafeInfo,
modules: [
{
value: MOCK_MODULE_1,
@@ -47,8 +47,7 @@ describe('SafeModules', () => {
value: MOCK_MODULE_2,
},
],
- chainId: '4',
- } as SafeInfo,
+ },
safeAddress: '0x123',
safeError: undefined,
safeLoading: false,
diff --git a/src/components/settings/TransactionGuards/__tests__/TransactionGuards.test.tsx b/src/components/settings/TransactionGuards/__tests__/TransactionGuards.test.tsx
index 15e7b4b0b0..b318020784 100644
--- a/src/components/settings/TransactionGuards/__tests__/TransactionGuards.test.tsx
+++ b/src/components/settings/TransactionGuards/__tests__/TransactionGuards.test.tsx
@@ -1,6 +1,6 @@
+import { extendedSafeInfoBuilder } from '@/tests/builders/safe'
import { render, waitFor } from '@/tests/test-utils'
import * as useSafeInfoHook from '@/hooks/useSafeInfo'
-import type { SafeInfo } from '@safe-global/safe-gateway-typescript-sdk'
import { zeroPadValue } from 'ethers'
import TransactionGuards from '..'
@@ -8,13 +8,11 @@ const MOCK_GUARD = zeroPadValue('0x01', 20)
const EMPTY_LABEL = 'No transaction guard set'
describe('TransactionGuards', () => {
+ const extendedSafeInfo = extendedSafeInfoBuilder().build()
+
it('should render placeholder label without an tx guard', async () => {
jest.spyOn(useSafeInfoHook, 'default').mockImplementation(() => ({
- safe: {
- guard: null,
- chainId: '4',
- version: '1.3.0',
- } as any as SafeInfo,
+ safe: extendedSafeInfo,
safeAddress: '0x123',
safeError: undefined,
safeLoading: false,
@@ -27,7 +25,7 @@ describe('TransactionGuards', () => {
it('should render null if safe is loading', async () => {
jest.spyOn(useSafeInfoHook, 'default').mockImplementation(() => ({
- safe: {} as SafeInfo,
+ safe: extendedSafeInfo,
safeAddress: '',
safeError: undefined,
safeLoading: true,
@@ -41,10 +39,11 @@ describe('TransactionGuards', () => {
it('should render null if safe version < 1.3.0', async () => {
jest.spyOn(useSafeInfoHook, 'default').mockImplementation(() => ({
safe: {
+ ...extendedSafeInfo,
guard: null,
chainId: '4',
version: '1.2.0',
- } as any as SafeInfo,
+ },
safeAddress: '0x123',
safeError: undefined,
safeLoading: false,
@@ -58,12 +57,11 @@ describe('TransactionGuards', () => {
it('should render tx guard address if defined', async () => {
jest.spyOn(useSafeInfoHook, 'default').mockImplementation(() => ({
safe: {
+ ...extendedSafeInfo,
guard: {
value: MOCK_GUARD,
},
- chainId: '4',
- version: '1.3.0',
- } as SafeInfo,
+ },
safeAddress: '0x123',
safeError: undefined,
safeLoading: false,
diff --git a/src/components/transactions/SingleTx/SingleTx.test.tsx b/src/components/transactions/SingleTx/SingleTx.test.tsx
index eca17836e4..467f2805d8 100644
--- a/src/components/transactions/SingleTx/SingleTx.test.tsx
+++ b/src/components/transactions/SingleTx/SingleTx.test.tsx
@@ -1,7 +1,10 @@
+import { extendedSafeInfoBuilder } from '@/tests/builders/safe'
import { fireEvent, render } from '@/tests/test-utils'
import SingleTx from '@/pages/transactions/tx'
import * as useSafeInfo from '@/hooks/useSafeInfo'
-import type { SafeInfo, TransactionDetails } from '@safe-global/safe-gateway-typescript-sdk'
+import * as gatewaySDK from '@safe-global/safe-gateway-typescript-sdk'
+import type { TransactionDetails } from '@safe-global/safe-gateway-typescript-sdk'
+import { waitFor } from '@testing-library/react'
const MOCK_SAFE_ADDRESS = '0x0000000000000000000000000000000000005AFE'
const SAFE_ADDRESS = '0x87a57cBf742CC1Fc702D0E9BF595b1E056693e2f'
@@ -30,23 +33,27 @@ jest.mock('next/router', () => ({
},
}))
-jest.mock('@safe-global/safe-gateway-typescript-sdk', () => ({
- ...jest.requireActual('@safe-global/safe-gateway-typescript-sdk'),
- getTransactionDetails: jest.fn(() => Promise.resolve(txDetails)),
-}))
+const extendedSafeInfo = extendedSafeInfoBuilder().build()
jest.spyOn(useSafeInfo, 'default').mockImplementation(() => ({
safeAddress: SAFE_ADDRESS,
safe: {
+ ...extendedSafeInfo,
chainId: '5',
- } as SafeInfo,
+ },
safeError: undefined,
safeLoading: false,
safeLoaded: true,
}))
describe('SingleTx', () => {
+ beforeEach(() => {
+ jest.clearAllMocks()
+ })
+
it('renders ', async () => {
+ jest.spyOn(gatewaySDK, 'getTransactionDetails').mockImplementation(() => Promise.resolve(txDetails))
+
const screen = render()
const button = screen.queryByText('Details')
@@ -56,28 +63,22 @@ describe('SingleTx', () => {
})
it('shows an error when the transaction has failed to load', async () => {
- const getTransactionDetails = jest.spyOn(
- require('@safe-global/safe-gateway-typescript-sdk'),
- 'getTransactionDetails',
- )
- getTransactionDetails.mockImplementation(() => Promise.reject(new Error('Server error')))
+ jest.spyOn(gatewaySDK, 'getTransactionDetails').mockImplementation(() => Promise.reject(new Error('Server error')))
const screen = render()
- expect(await screen.findByText('Failed to load transaction')).toBeInTheDocument()
+ await waitFor(() => {
+ expect(screen.getByText('Failed to load transaction')).toBeInTheDocument()
+ })
- const button = screen.getByText('Details')
- fireEvent.click(button!)
-
- expect(screen.getByText('Server error')).toBeInTheDocument()
+ await waitFor(() => {
+ fireEvent.click(screen.getByText('Details'))
+ expect(screen.getByText('Server error')).toBeInTheDocument()
+ })
})
it('shows an error when transaction is not from the opened Safe', async () => {
- const getTransactionDetails = jest.spyOn(
- require('@safe-global/safe-gateway-typescript-sdk'),
- 'getTransactionDetails',
- )
- getTransactionDetails.mockImplementation(() =>
+ jest.spyOn(gatewaySDK, 'getTransactionDetails').mockImplementation(() =>
Promise.resolve({
...txDetails,
safeAddress: MOCK_SAFE_ADDRESS,
@@ -86,11 +87,14 @@ describe('SingleTx', () => {
const screen = render()
- expect(await screen.findByText('Failed to load transaction')).toBeInTheDocument()
+ await waitFor(() => {
+ expect(screen.getByText('Failed to load transaction')).toBeInTheDocument()
+ })
- const button = screen.getByText('Details')
- fireEvent.click(button!)
+ fireEvent.click(screen.getByText('Details'))
- expect(screen.getByText('Transaction with this id was not found in this Safe Account')).toBeInTheDocument()
+ await waitFor(() => {
+ expect(screen.getByText('Transaction with this id was not found in this Safe Account')).toBeInTheDocument()
+ })
})
})
diff --git a/src/components/tx-flow/flows/SignMessage/SignMessage.test.tsx b/src/components/tx-flow/flows/SignMessage/SignMessage.test.tsx
index 1d93175fca..c1098a8e54 100644
--- a/src/components/tx-flow/flows/SignMessage/SignMessage.test.tsx
+++ b/src/components/tx-flow/flows/SignMessage/SignMessage.test.tsx
@@ -1,3 +1,4 @@
+import { extendedSafeInfoBuilder } from '@/tests/builders/safe'
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'
@@ -90,19 +91,21 @@ describe('SignMessage', () => {
})
const mockUseSafeMessages = useSafeMessages as jest.Mock
+ const extendedSafeInfo = {
+ ...extendedSafeInfoBuilder().build(),
+ version: '1.3.0',
+ address: {
+ value: zeroPadValue('0x01', 20),
+ },
+ chainId: '5',
+ threshold: 2,
+ }
beforeEach(() => {
jest.clearAllMocks()
jest.spyOn(useSafeInfoHook, 'default').mockImplementation(() => ({
- safe: {
- version: '1.3.0',
- address: {
- value: zeroPadValue('0x01', 20),
- },
- chainId: '5',
- threshold: 2,
- } as SafeInfo,
+ safe: extendedSafeInfo,
safeAddress: zeroPadValue('0x01', 20),
safeError: undefined,
safeLoading: false,
@@ -255,16 +258,10 @@ describe('SignMessage', () => {
expect(proposalSpy).toHaveBeenCalledWith(
expect.objectContaining({
- safe: {
- version: '1.3.0',
- address: {
- value: zeroPadValue('0x01', 20),
- },
- chainId: '5',
- threshold: 2,
- } as SafeInfo,
+ safe: extendedSafeInfo,
message: 'Hello world!',
safeAppId: 25,
+ //onboard: expect.anything(),
}),
)
@@ -363,15 +360,9 @@ describe('SignMessage', () => {
expect(confirmationSpy).toHaveBeenCalledWith(
expect.objectContaining({
- safe: {
- version: '1.3.0',
- address: {
- value: zeroPadValue('0x01', 20),
- },
- chainId: '5',
- threshold: 2,
- } as SafeInfo,
+ safe: extendedSafeInfo,
message: 'Hello world!',
+ onboard: expect.anything(),
}),
)
diff --git a/src/components/tx/SignOrExecuteForm/hooks.test.ts b/src/components/tx/SignOrExecuteForm/hooks.test.ts
index b2ede6cbb6..6d2598e8c4 100644
--- a/src/components/tx/SignOrExecuteForm/hooks.test.ts
+++ b/src/components/tx/SignOrExecuteForm/hooks.test.ts
@@ -1,7 +1,7 @@
+import { extendedSafeInfoBuilder } from '@/tests/builders/safe'
import { renderHook } from '@/tests/test-utils'
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'
import * as useSafeInfoHook from '@/hooks/useSafeInfo'
import * as wallet from '@/hooks/wallets/useWallet'
@@ -13,6 +13,8 @@ import { type OnboardAPI } from '@web3-onboard/core'
import { useAlreadySigned, useImmediatelyExecutable, useIsExecutionLoop, useTxActions, useValidateNonce } from './hooks'
describe('SignOrExecute hooks', () => {
+ const extendedSafeInfo = extendedSafeInfoBuilder().build()
+
beforeEach(() => {
jest.clearAllMocks()
@@ -45,13 +47,14 @@ describe('SignOrExecute hooks', () => {
it('should return true if nonce is correct', () => {
jest.spyOn(useSafeInfoHook, 'default').mockImplementation(() => ({
safe: {
+ ...extendedSafeInfo,
version: '1.3.0',
address: { value: zeroPadValue('0x0000', 20) },
nonce: 100,
threshold: 2,
owners: [{ value: zeroPadValue('0x0123', 20) }, { value: zeroPadValue('0x0456', 20) }],
chainId: '1',
- } as SafeInfo,
+ },
safeAddress: zeroPadValue('0x0000', 20),
safeError: undefined,
safeLoading: false,
@@ -66,13 +69,14 @@ describe('SignOrExecute hooks', () => {
it('should return false if nonce is incorrect', () => {
jest.spyOn(useSafeInfoHook, 'default').mockImplementation(() => ({
safe: {
+ ...extendedSafeInfo,
version: '1.3.0',
address: { value: zeroPadValue('0x0000', 20) },
nonce: 90,
threshold: 2,
owners: [{ value: zeroPadValue('0x0123', 20) }, { value: zeroPadValue('0x0456', 20) }],
chainId: '1',
- } as SafeInfo,
+ },
safeAddress: zeroPadValue('0x0000', 20),
safeError: undefined,
safeLoading: false,
@@ -92,12 +96,13 @@ describe('SignOrExecute hooks', () => {
jest.spyOn(useSafeInfoHook, 'default').mockReturnValue({
safeAddress: address,
safe: {
+ ...extendedSafeInfo,
version: '1.3.0',
address: { value: address },
owners: [{ value: address }],
nonce: 100,
chainId: '1',
- } as SafeInfo,
+ },
safeLoaded: true,
safeLoading: false,
safeError: undefined,
@@ -132,12 +137,13 @@ describe('SignOrExecute hooks', () => {
jest.spyOn(useSafeInfoHook, 'default').mockReturnValue({
safeAddress: zeroPadValue('0x0000', 20),
safe: {
+ ...extendedSafeInfo,
version: '1.3.0',
address: { value: zeroPadValue('0x0000', 20) },
owners: [{ value: zeroPadValue('0x0123', 20) }],
threshold: 1,
nonce: 100,
- } as SafeInfo,
+ },
safeLoaded: true,
safeLoading: false,
safeError: undefined,
@@ -154,13 +160,14 @@ describe('SignOrExecute hooks', () => {
jest.spyOn(useSafeInfoHook, 'default').mockReturnValue({
safeAddress: zeroPadValue('0x0000', 20),
safe: {
+ ...extendedSafeInfo,
version: '1.3.0',
address: { value: zeroPadValue('0x0000', 20) },
owners: [{ value: zeroPadValue('0x0123', 20) }],
threshold: 2,
nonce: 100,
chainId: '1',
- } as SafeInfo,
+ },
safeLoaded: true,
safeLoading: false,
safeError: undefined,
@@ -177,13 +184,14 @@ describe('SignOrExecute hooks', () => {
jest.spyOn(useSafeInfoHook, 'default').mockReturnValue({
safeAddress: zeroPadValue('0x0000', 20),
safe: {
+ ...extendedSafeInfo,
version: '1.3.0',
address: { value: zeroPadValue('0x0000', 20) },
owners: [{ value: zeroPadValue('0x0123', 20) }],
threshold: 1,
nonce: 100,
chainId: '1',
- } as SafeInfo,
+ },
safeLoaded: true,
safeLoading: false,
safeError: undefined,
@@ -201,13 +209,14 @@ describe('SignOrExecute hooks', () => {
it('should return sign and execute actions', () => {
jest.spyOn(useSafeInfoHook, 'default').mockImplementation(() => ({
safe: {
+ ...extendedSafeInfo,
version: '1.3.0',
address: { value: zeroPadValue('0x0000', 20) },
nonce: 100,
threshold: 2,
owners: [{ value: zeroPadValue('0x0123', 20) }, { value: zeroPadValue('0x0456', 20) }],
chainId: '1',
- } as SafeInfo,
+ },
safeAddress: '0x123',
safeError: undefined,
safeLoading: false,
@@ -225,13 +234,14 @@ describe('SignOrExecute hooks', () => {
jest.spyOn(useSafeInfoHook, 'default').mockImplementation(() => ({
safe: {
+ ...extendedSafeInfo,
version: '1.3.0',
address: { value: zeroPadValue('0x0000', 20) },
nonce: 100,
threshold: 2,
owners: [{ value: zeroPadValue('0x0123', 20) }, { value: zeroPadValue('0x0456', 20) }],
chainId: '1',
- } as SafeInfo,
+ },
safeAddress: '0x123',
safeError: undefined,
safeLoading: false,
@@ -266,13 +276,14 @@ describe('SignOrExecute hooks', () => {
jest.spyOn(useSafeInfoHook, 'default').mockImplementation(() => ({
safe: {
+ ...extendedSafeInfo,
version: '1.3.0',
address: { value: zeroPadValue('0x0000', 20) },
nonce: 100,
threshold: 2,
owners: [{ value: zeroPadValue('0x0123', 20) }, { value: zeroPadValue('0x0456', 20) }],
chainId: '1',
- } as SafeInfo,
+ },
safeAddress: '0x123',
safeError: undefined,
safeLoading: false,
@@ -295,13 +306,14 @@ describe('SignOrExecute hooks', () => {
it('should execute a tx without a txId (immediate execution)', async () => {
jest.spyOn(useSafeInfoHook, 'default').mockImplementation(() => ({
safe: {
+ ...extendedSafeInfo,
version: '1.3.0',
address: { value: zeroPadValue('0x0000', 20) },
nonce: 100,
threshold: 2,
owners: [{ value: zeroPadValue('0x0123', 20) }, { value: zeroPadValue('0x0456', 20) }],
chainId: '1',
- } as SafeInfo,
+ },
safeAddress: '0x123',
safeError: undefined,
safeLoading: false,
@@ -327,13 +339,14 @@ describe('SignOrExecute hooks', () => {
it('should execute a tx with an id (existing tx)', async () => {
jest.spyOn(useSafeInfoHook, 'default').mockImplementation(() => ({
safe: {
+ ...extendedSafeInfo,
version: '1.3.0',
address: { value: zeroPadValue('0x0000', 20) },
nonce: 100,
threshold: 2,
owners: [{ value: zeroPadValue('0x0123', 20) }, { value: zeroPadValue('0x0456', 20) }],
chainId: '1',
- } as SafeInfo,
+ },
safeAddress: '0x123',
safeError: undefined,
safeLoading: false,
@@ -359,13 +372,14 @@ describe('SignOrExecute hooks', () => {
it('should throw an error if the tx is undefined', async () => {
jest.spyOn(useSafeInfoHook, 'default').mockImplementation(() => ({
safe: {
+ ...extendedSafeInfo,
version: '1.3.0',
address: { value: zeroPadValue('0x0000', 20) },
nonce: 100,
threshold: 2,
owners: [{ value: zeroPadValue('0x0123', 20) }, { value: zeroPadValue('0x0456', 20) }],
chainId: '1',
- } as SafeInfo,
+ },
safeAddress: '0x123',
safeError: undefined,
safeLoading: false,
@@ -383,13 +397,15 @@ describe('SignOrExecute hooks', () => {
it('should relay a tx execution', async () => {
jest.spyOn(useSafeInfoHook, 'default').mockImplementation(() => ({
safe: {
+ ...extendedSafeInfo,
+ ...extendedSafeInfoBuilder().build(),
version: '1.3.0',
address: { value: zeroPadValue('0x0000', 20) },
nonce: 100,
threshold: 1,
owners: [{ value: zeroPadValue('0x0123', 20) }, { value: zeroPadValue('0x0456', 20) }],
chainId: '1',
- } as SafeInfo,
+ },
safeAddress: '0x123',
safeError: undefined,
safeLoading: false,
@@ -423,13 +439,15 @@ describe('SignOrExecute hooks', () => {
jest.spyOn(useSafeInfoHook, 'default').mockImplementation(() => ({
safe: {
+ ...extendedSafeInfo,
+ ...extendedSafeInfoBuilder().build(),
version: '1.3.0',
address: { value: zeroPadValue('0x0000', 20) },
nonce: 100,
threshold: 2,
owners: [{ value: zeroPadValue('0x0123', 20) }, { value: zeroPadValue('0x0456', 20) }],
chainId: '1',
- } as SafeInfo,
+ },
safeAddress: '0x123',
safeError: undefined,
safeLoading: false,
@@ -473,13 +491,15 @@ describe('SignOrExecute hooks', () => {
jest.spyOn(useSafeInfoHook, 'default').mockImplementation(() => ({
safe: {
+ ...extendedSafeInfo,
+ ...extendedSafeInfoBuilder().build(),
version: '1.3.0',
address: { value: zeroPadValue('0x0000', 20) },
nonce: 100,
threshold: 2,
owners: [{ value: zeroPadValue('0x0123', 20) }, { value: zeroPadValue('0x0456', 20) }],
chainId: '1',
- } as SafeInfo,
+ },
safeAddress: '0x123',
safeError: undefined,
safeLoading: false,
diff --git a/src/features/walletconnect/__tests__/WalletConnectContext.test.tsx b/src/features/walletconnect/__tests__/WalletConnectContext.test.tsx
index 1019fad1b8..54ecde09ed 100644
--- a/src/features/walletconnect/__tests__/WalletConnectContext.test.tsx
+++ b/src/features/walletconnect/__tests__/WalletConnectContext.test.tsx
@@ -1,3 +1,4 @@
+import { extendedSafeInfoBuilder } from '@/tests/builders/safe'
import { toBeHex } from 'ethers'
import { useContext } from 'react'
import type { SafeInfo } from '@safe-global/safe-gateway-typescript-sdk'
@@ -42,6 +43,14 @@ const TestComponent = () => {
}
describe('WalletConnectProvider', () => {
+ const extendedSafeInfo = {
+ ...extendedSafeInfoBuilder().build(),
+ address: {
+ value: toBeHex('0x123', 20),
+ },
+ chainId: '5',
+ }
+
beforeEach(() => {
jest.resetAllMocks()
jest.restoreAllMocks()
@@ -59,12 +68,7 @@ describe('WalletConnectProvider', () => {
initialReduxState: {
safeInfo: {
loading: false,
- data: {
- address: {
- value: toBeHex('0x123', 20),
- },
- chainId: '5',
- } as SafeInfo,
+ data: extendedSafeInfo,
},
},
},
@@ -89,12 +93,7 @@ describe('WalletConnectProvider', () => {
initialReduxState: {
safeInfo: {
loading: false,
- data: {
- address: {
- value: toBeHex('0x123', 20),
- },
- chainId: '5',
- } as SafeInfo,
+ data: extendedSafeInfo,
},
},
},
@@ -106,6 +105,14 @@ describe('WalletConnectProvider', () => {
})
describe('updateSessions', () => {
+ const extendedSafeInfo = {
+ ...extendedSafeInfoBuilder().build(),
+ address: {
+ value: toBeHex('0x123', 20),
+ },
+ chainId: '5',
+ }
+
const getUpdateSafeInfoComponent = (safeInfo: SafeInfo) => {
// eslint-disable-next-line react/display-name
return () => {
@@ -114,7 +121,7 @@ describe('WalletConnectProvider', () => {
dispatch(
safeInfoSlice.actions.set({
loading: false,
- data: safeInfo,
+ data: { ...extendedSafeInfo, ...safeInfo },
}),
)
}
@@ -141,12 +148,7 @@ describe('WalletConnectProvider', () => {
initialReduxState: {
safeInfo: {
loading: false,
- data: {
- address: {
- value: toBeHex('0x123', 20),
- },
- chainId: '5',
- } as SafeInfo,
+ data: extendedSafeInfo,
},
},
},
@@ -183,11 +185,12 @@ describe('WalletConnectProvider', () => {
safeInfo: {
loading: false,
data: {
+ ...extendedSafeInfo,
address: {
value: toBeHex('0x123', 20),
},
chainId: '5',
- } as SafeInfo,
+ },
},
},
},
@@ -220,11 +223,12 @@ describe('WalletConnectProvider', () => {
safeInfo: {
loading: false,
data: {
+ ...extendedSafeInfo,
address: {
value: toBeHex('0x123', 20),
},
chainId: '5',
- } as SafeInfo,
+ },
},
},
},
@@ -237,6 +241,14 @@ describe('WalletConnectProvider', () => {
})
describe('onRequest', () => {
+ const extendedSafeInfo = {
+ ...extendedSafeInfoBuilder().build(),
+ address: {
+ value: toBeHex('0x123', 20),
+ },
+ chainId: '5',
+ }
+
it('does not continue with the request if there is no matching topic', async () => {
jest.spyOn(WalletConnectWallet.prototype, 'init').mockImplementation(() => Promise.resolve())
jest.spyOn(WalletConnectWallet.prototype, 'updateSessions').mockImplementation(() => Promise.resolve())
@@ -261,12 +273,7 @@ describe('WalletConnectProvider', () => {
initialReduxState: {
safeInfo: {
loading: false,
- data: {
- address: {
- value: toBeHex('0x123', 20),
- },
- chainId: '5',
- } as SafeInfo,
+ data: extendedSafeInfo,
},
},
},
@@ -325,12 +332,7 @@ describe('WalletConnectProvider', () => {
initialReduxState: {
safeInfo: {
loading: false,
- data: {
- address: {
- value: toBeHex('0x123', 20),
- },
- chainId: '5',
- } as SafeInfo,
+ data: extendedSafeInfo,
},
},
},
@@ -397,12 +399,7 @@ describe('WalletConnectProvider', () => {
initialReduxState: {
safeInfo: {
loading: false,
- data: {
- address: {
- value: toBeHex('0x123', 20),
- },
- chainId: '5',
- } as SafeInfo,
+ data: extendedSafeInfo,
},
},
},
@@ -477,12 +474,7 @@ describe('WalletConnectProvider', () => {
initialReduxState: {
safeInfo: {
loading: false,
- data: {
- address: {
- value: toBeHex('0x123', 20),
- },
- chainId: '5',
- } as SafeInfo,
+ data: extendedSafeInfo,
},
},
},
diff --git a/src/features/walletconnect/components/WcProposalForm/__tests__/useCompatibilityWarning.test.ts b/src/features/walletconnect/components/WcProposalForm/__tests__/useCompatibilityWarning.test.ts
index 747bf1eff9..039fe6d1f8 100644
--- a/src/features/walletconnect/components/WcProposalForm/__tests__/useCompatibilityWarning.test.ts
+++ b/src/features/walletconnect/components/WcProposalForm/__tests__/useCompatibilityWarning.test.ts
@@ -1,5 +1,6 @@
+import { extendedSafeInfoBuilder } from '@/tests/builders/safe'
import { renderHook } from '@/tests/test-utils'
-import type { ChainInfo, SafeInfo } from '@safe-global/safe-gateway-typescript-sdk'
+import type { ChainInfo } from '@safe-global/safe-gateway-typescript-sdk'
import type { Web3WalletTypes } from '@walletconnect/web3wallet'
import { useCompatibilityWarning } from '../useCompatibilityWarning'
import * as wcUtils from '@/features/walletconnect/services/utils'
@@ -141,9 +142,10 @@ describe('useCompatibilityWarning', () => {
loading: false,
error: undefined,
data: {
- address: {},
+ ...extendedSafeInfoBuilder().build(),
+ address: { value: '' },
chainId: '1',
- } as unknown as SafeInfo,
+ },
},
},
})
diff --git a/src/hooks/__tests__/usePendingActions.test.ts b/src/hooks/__tests__/usePendingActions.test.ts
index cb476277cd..09c560a544 100644
--- a/src/hooks/__tests__/usePendingActions.test.ts
+++ b/src/hooks/__tests__/usePendingActions.test.ts
@@ -1,6 +1,7 @@
import usePendingActions from '@/hooks/usePendingActions'
+import { extendedSafeInfoBuilder } from '@/tests/builders/safe'
import { renderHook, waitFor } from '@/tests/test-utils'
-import type { SafeInfo, TransactionListPage, TransactionSummary } from '@safe-global/safe-gateway-typescript-sdk'
+import type { TransactionListPage, TransactionSummary } from '@safe-global/safe-gateway-typescript-sdk'
import {
ConflictType,
DetailedExecutionInfoType,
@@ -46,8 +47,9 @@ describe('usePendingActions hook', () => {
jest.spyOn(useSafeInfo, 'default').mockReturnValue({
safeAddress: mockSafeAddress,
safe: {
+ ...extendedSafeInfoBuilder().build(),
chainId: '5',
- } as SafeInfo,
+ },
safeError: undefined,
safeLoading: false,
safeLoaded: true,
@@ -82,8 +84,9 @@ describe('usePendingActions hook', () => {
jest.spyOn(useSafeInfo, 'default').mockReturnValue({
safeAddress: mockSafeAddress,
safe: {
+ ...extendedSafeInfoBuilder().build(),
chainId: '5',
- } as SafeInfo,
+ },
safeError: undefined,
safeLoading: false,
safeLoaded: true,
@@ -153,8 +156,9 @@ describe('usePendingActions hook', () => {
jest.spyOn(useSafeInfo, 'default').mockReturnValue({
safeAddress: mockSafeAddress,
safe: {
+ ...extendedSafeInfoBuilder().build(),
chainId: '5',
- } as SafeInfo,
+ },
safeError: undefined,
safeLoading: false,
safeLoaded: true,
diff --git a/src/hooks/__tests__/usePendingTxs.test.ts b/src/hooks/__tests__/usePendingTxs.test.ts
index a40d25f367..724964d5b5 100644
--- a/src/hooks/__tests__/usePendingTxs.test.ts
+++ b/src/hooks/__tests__/usePendingTxs.test.ts
@@ -1,6 +1,7 @@
import { type PendingTx } from '@/store/pendingTxsSlice'
+import { extendedSafeInfoBuilder } from '@/tests/builders/safe'
import { act, renderHook } from '@/tests/test-utils'
-import type { Label, SafeInfo, Transaction } from '@safe-global/safe-gateway-typescript-sdk'
+import type { Label, Transaction } from '@safe-global/safe-gateway-typescript-sdk'
import * as useSafeInfoHook from '@/hooks/useSafeInfo'
import { useHasPendingTxs, usePendingTxsQueue } from '../usePendingTxs'
@@ -39,11 +40,12 @@ describe('usePendingTxsQueue', () => {
jest.spyOn(useSafeInfoHook, 'default').mockImplementation(() => ({
safe: {
+ ...extendedSafeInfoBuilder().build(),
nonce: 100,
threshold: 1,
owners: [{ value: '0x123' }],
chainId: '5',
- } as SafeInfo,
+ },
safeAddress: '0x0000000000000000000000000000000000000001',
safeError: undefined,
safeLoading: false,
diff --git a/src/hooks/coreSDK/__tests__/useInitSafeCoreSDK.test.ts b/src/hooks/coreSDK/__tests__/useInitSafeCoreSDK.test.ts
index d11c92f58b..c47cd38ca3 100644
--- a/src/hooks/coreSDK/__tests__/useInitSafeCoreSDK.test.ts
+++ b/src/hooks/coreSDK/__tests__/useInitSafeCoreSDK.test.ts
@@ -1,10 +1,10 @@
+import type { ExtendedSafeInfo } from '@/store/safeInfoSlice'
import { renderHook } from '@/tests/test-utils'
import { useInitSafeCoreSDK } from '@/hooks/coreSDK/useInitSafeCoreSDK'
import * as web3 from '@/hooks/wallets/web3'
import * as router from 'next/router'
import * as useSafeInfo from '@/hooks/useSafeInfo'
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/protocol-kit'
@@ -24,7 +24,7 @@ describe('useInitSafeCoreSDK hook', () => {
value: '0x1',
},
implementationVersionState: ImplementationVersionState.UP_TO_DATE,
- } as SafeInfo,
+ } as ExtendedSafeInfo,
safeAddress: mockSafeAddress,
safeLoaded: true,
safeError: undefined,
@@ -58,6 +58,7 @@ describe('useInitSafeCoreSDK hook', () => {
provider: mockProvider,
address: mockSafeInfo.safe.address.value,
implementation: mockSafeInfo.safe.implementation.value,
+ undeployedSafe: undefined,
})
await waitFor(() => {
diff --git a/src/hooks/coreSDK/safeCoreSDK.ts b/src/hooks/coreSDK/safeCoreSDK.ts
index f4c72c7fb3..c039e9a1d1 100644
--- a/src/hooks/coreSDK/safeCoreSDK.ts
+++ b/src/hooks/coreSDK/safeCoreSDK.ts
@@ -5,7 +5,7 @@ import ExternalStore from '@/services/ExternalStore'
import { Gnosis_safe__factory } from '@/types/contracts'
import { invariant } from '@/utils/helpers'
import type { BrowserProvider, Provider } from 'ethers'
-import Safe, { PredictedSafeProps } from '@safe-global/protocol-kit'
+import Safe, { type PredictedSafeProps } from '@safe-global/protocol-kit'
import type { SafeVersion } from '@safe-global/safe-core-sdk-types'
import { EthersAdapter } from '@safe-global/protocol-kit'
import type { SafeInfo } from '@safe-global/safe-gateway-typescript-sdk'
diff --git a/src/services/safe-wallet-provider/useSafeWalletProvider.test.tsx b/src/services/safe-wallet-provider/useSafeWalletProvider.test.tsx
index 37c84502da..9150a12166 100644
--- a/src/services/safe-wallet-provider/useSafeWalletProvider.test.tsx
+++ b/src/services/safe-wallet-provider/useSafeWalletProvider.test.tsx
@@ -1,3 +1,4 @@
+import type { ExtendedSafeInfo } from '@/store/safeInfoSlice'
import * as gateway from '@safe-global/safe-gateway-typescript-sdk'
import * as router from 'next/router'
@@ -43,7 +44,8 @@ describe('useSafeWalletProvider', () => {
address: {
value: '0x1234567890000000000000000000000000000000',
},
- } as gateway.SafeInfo,
+ deployed: true,
+ } as unknown as ExtendedSafeInfo,
},
},
})
diff --git a/src/tests/builders/safe.ts b/src/tests/builders/safe.ts
index d1b6fbf6c5..91db6ba631 100644
--- a/src/tests/builders/safe.ts
+++ b/src/tests/builders/safe.ts
@@ -1,3 +1,4 @@
+import type { ExtendedSafeInfo } from '@/store/safeInfoSlice'
import { faker } from '@faker-js/faker'
import { ImplementationVersionState } from '@safe-global/safe-gateway-typescript-sdk'
import type { SafeInfo, AddressEx } from '@safe-global/safe-gateway-typescript-sdk'
@@ -37,3 +38,10 @@ export function safeInfoBuilder(): IBuilder {
messagesTag: faker.string.numeric(),
})
}
+
+export function extendedSafeInfoBuilder(): IBuilder {
+ return Builder.new().with({
+ ...safeInfoBuilder().build(),
+ deployed: faker.datatype.boolean(),
+ })
+}