Skip to content

Commit

Permalink
frontend: Show a warning if the same address as the connected Safe is…
Browse files Browse the repository at this point in the history
… chosen as the target
  • Loading branch information
manuelwedler committed May 8, 2023
1 parent 9caa948 commit 78034b3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions frontend/src/components/RequestTargetInputs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
<div v-if="v$.selectedTargetAddress.$errors.length">
{{ v$.selectedTargetAddress.$errors[0].$message }}
</div>
<div v-else-if="showSafeSameTargetWarning" class="text-orange">
Make sure you own a Safe with this address on the destination chain.
</div>
<div v-else>&nbsp;</div>
</InputValidationMessage>
<Transition>
Expand All @@ -66,7 +69,9 @@ import Selector from '@/components/inputs/Selector.vue';
import InputValidationMessage from '@/components/layout/InputValidationMessage.vue';
import { useChainSelection } from '@/composables/useChainSelection';
import { useRequestTargetInputValidations } from '@/composables/useRequestTargetInputValidations';
import { SafeProvider } from '@/services/web3-provider';
import { useConfiguration } from '@/stores/configuration';
import { useEthereumProvider } from '@/stores/ethereum-provider';
import { usePortals } from '@/stores/portals';
import type { Chain, Token } from '@/types/data';
import type { RequestTarget, SelectorOption } from '@/types/form';
Expand All @@ -86,8 +91,10 @@ const props = defineProps<Props>();
const emits = defineEmits<Emits>();
const configuration = useConfiguration();
const ethereumProvider = useEthereumProvider();
const { hideActionButton, showActionButton } = usePortals();
const { provider, signerAddress } = storeToRefs(ethereumProvider);
const { chains } = storeToRefs(configuration);
const selectedTargetChain = ref<SelectorOption<Chain> | null>(props.modelValue.targetChain);
Expand All @@ -98,6 +105,11 @@ const ignoreChains = computed(() =>
);
const { chainOptions } = useChainSelection(chains, ignoreChains);
const showSafeSameTargetWarning = computed(
() =>
provider.value instanceof SafeProvider && signerAddress.value === selectedTargetAddress.value,
);
watch(
() => props.sourceChain,
(newSourceChain) => {
Expand Down

0 comments on commit 78034b3

Please sign in to comment.