Skip to content

Commit

Permalink
make address required
Browse files Browse the repository at this point in the history
Signed-off-by: ryanwolhuter <[email protected]>
  • Loading branch information
ryanwolhuter committed Oct 6, 2023
1 parent bce625b commit f93cc9a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
17 changes: 9 additions & 8 deletions src/plugins/oSnap/components/Input/Address.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@
import { mustBeEthereumAddress } from '../../utils';
const props = defineProps(['modelValue', 'inputProps', 'label', 'disabled']);
const emit = defineEmits(['update:modelValue', 'validAddress']);
const emit = defineEmits(['update:modelValue']);
const input = ref('');
const isValid = ref(false);
const dirty = ref(false);
const error = computed(() => {
if (!dirty.value) return '';
if (input.value === '') return 'Address is required';
if (!mustBeEthereumAddress(input.value)) return 'Invalid address';
return '';
})
watch(
() => props.modelValue,
Expand All @@ -22,12 +27,7 @@ onMounted(() => {
});
const handleInput = () => {
dirty.value = input.value !== '';
emit('update:modelValue', input.value);
isValid.value = mustBeEthereumAddress(input.value);
if (isValid.value) {
emit('validAddress', input.value);
}
};
</script>

Expand All @@ -36,8 +36,9 @@ const handleInput = () => {
v-model="input"
v-bind="inputProps"
:disabled="disabled"
:error="dirty && !isValid && $t('safeSnap.invalidAddress')"
:error="error !== '' && error"
@input="handleInput()"
@blur="dirty = true"
>
<template v-if="label" #label>{{ label }}</template>
</UiInput>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const isToValid = computed(() => {
});
const abi = ref(props.transaction.abi ?? '');
const isAbiValid = ref(true);
const value = ref(props.transaction.value ?? '');
const value = ref(props.transaction.value ?? '0');
const isValueValid = ref(true);
const methods = ref<FunctionFragment[]>([]);
const selectedMethodName = ref(props.transaction.methodName ?? '');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@ watch(selectedTokenAddress, updateTransaction);
<div class="space-y-2">
<InputAddress
v-model="recipient"
:input-props="{
required: true
}"
:label="$t('safeSnap.to')"
/>
<InputAmount
Expand Down

0 comments on commit f93cc9a

Please sign in to comment.