diff --git a/frontend/src/components/RequestDialog.vue b/frontend/src/components/RequestDialog.vue index c90712da2..1d5c388f5 100644 --- a/frontend/src/components/RequestDialog.vue +++ b/frontend/src/components/RequestDialog.vue @@ -77,7 +77,6 @@ import { useToggleOnActivation } from '@/composables/useToggleOnActivation'; import { useTokenAllowance } from '@/composables/useTokenAllowance'; import { useTransferRequest } from '@/composables/useTransferRequest'; import { switchToActivities } from '@/router/navigation'; -import { SafeProvider } from '@/services/web3-provider'; import { useConfiguration } from '@/stores/configuration'; import { useEthereumProvider } from '@/stores/ethereum-provider'; import { useTransferHistory } from '@/stores/transfer-history'; @@ -196,7 +195,8 @@ function resetFormValidation() { } watch(signerAddress, (currSignerAddress, prevSignerAddress) => { - if (provider.value instanceof SafeProvider) { + // Contract wallets should not prefill the target address as they need to be deployed separately per chain + if (provider.value && provider.value.isContractWallet) { return; } diff --git a/frontend/src/components/wallet/Disconnect.vue b/frontend/src/components/wallet/Disconnect.vue index cc8fed299..04c2b69f1 100644 --- a/frontend/src/components/wallet/Disconnect.vue +++ b/frontend/src/components/wallet/Disconnect.vue @@ -14,7 +14,6 @@ import { storeToRefs } from 'pinia'; import { computed, ref } from 'vue'; import { useWallet } from '@/composables/useWallet'; -import { SafeProvider } from '@/services/web3-provider'; import { useEthereumProvider } from '@/stores/ethereum-provider'; import { useSettings } from '@/stores/settings'; @@ -22,6 +21,6 @@ const ethereumProvider = useEthereumProvider(); const { provider } = storeToRefs(ethereumProvider); const { connectedWallet } = storeToRefs(useSettings()); -const showDisconnect = computed(() => !(provider.value instanceof SafeProvider)); +const showDisconnect = computed(() => !!provider.value?.disconnectable); const { disconnectWallet: disconnect } = useWallet(provider, connectedWallet, ref()); diff --git a/frontend/src/services/web3-provider/ethereum-provider.ts b/frontend/src/services/web3-provider/ethereum-provider.ts index 0989e4a92..8b8ee5e7d 100644 --- a/frontend/src/services/web3-provider/ethereum-provider.ts +++ b/frontend/src/services/web3-provider/ethereum-provider.ts @@ -12,6 +12,8 @@ export abstract class BasicEthereumProvider extends EventEmitter implements IEth signer: ShallowRef = shallowRef(undefined); signerAddress: ShallowRef = shallowRef(undefined); chainId: Ref = ref(1); + disconnectable = true; + isContractWallet = false; protected web3Provider: Web3Provider; protected externalProvider: Eip1193Provider; diff --git a/frontend/src/services/web3-provider/safe-provider.ts b/frontend/src/services/web3-provider/safe-provider.ts index 734d8be04..0b259b501 100644 --- a/frontend/src/services/web3-provider/safe-provider.ts +++ b/frontend/src/services/web3-provider/safe-provider.ts @@ -24,6 +24,9 @@ export async function createSafeProvider(): Promise { } export class SafeProvider extends BasicEthereumProvider { + disconnectable = false; + isContractWallet = true; + constructor(safe: SafeInfo, private sdk: SafeAppsSDK) { super(new SafeAppProvider(safe, sdk)); } diff --git a/frontend/src/services/web3-provider/types.ts b/frontend/src/services/web3-provider/types.ts index 220864603..6efd8f4a9 100644 --- a/frontend/src/services/web3-provider/types.ts +++ b/frontend/src/services/web3-provider/types.ts @@ -19,6 +19,8 @@ export interface IEthereumProvider { getChainId(): Promise; addToken?(token: Token): Promise; getActualTransactionHash?(internalTransactionHash: string): Promise; + disconnectable: boolean; + isContractWallet: boolean; } export interface EventEmitter { diff --git a/frontend/tests/unit/components/wallet/Disconnect.spec.ts b/frontend/tests/unit/components/wallet/Disconnect.spec.ts index 6758a225b..f35817938 100644 --- a/frontend/tests/unit/components/wallet/Disconnect.spec.ts +++ b/frontend/tests/unit/components/wallet/Disconnect.spec.ts @@ -3,6 +3,7 @@ import { mount } from '@vue/test-utils'; import Disconnect from '@/components/wallet/Disconnect.vue'; import * as useWalletComposable from '@/composables/useWallet'; +import { MockedEthereumProvider } from '~/utils/mocks/ethereum-provider'; vi.mock('@/composables/useWallet'); @@ -10,7 +11,15 @@ const createWrapper = () => { return mount(Disconnect, { shallow: true, global: { - plugins: [createTestingPinia()], + plugins: [ + createTestingPinia({ + initialState: { + ethereumProvider: { + provider: new MockedEthereumProvider(), + }, + }, + }), + ], }, }); }; diff --git a/frontend/tests/utils/mocks/ethereum-provider.ts b/frontend/tests/utils/mocks/ethereum-provider.ts index fd720f026..0c5eb1650 100644 --- a/frontend/tests/utils/mocks/ethereum-provider.ts +++ b/frontend/tests/utils/mocks/ethereum-provider.ts @@ -65,6 +65,8 @@ export class MockedEthereumProvider implements IEthereumProvider, EventEmitter { readonly signer: ShallowRef; readonly signerAddress: ShallowRef; readonly chainId: Ref; + disconnectable = true; + isContractWallet = false; constructor(options?: { chainId?: number; signer?: JsonRpcSigner; signerAddress?: string }) { this.signer = shallowRef(options?.signer);