Skip to content

Commit

Permalink
fix bytes32 validation message
Browse files Browse the repository at this point in the history
  • Loading branch information
gsteenkamp89 committed Apr 12, 2024
1 parent 93e734b commit b8087cf
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/plugins/oSnap/components/Input/MethodParameter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
InputTypes,
validateArrayInput,
validateInput,
validateTupleInput
validateTupleInput,
isBytesLikeSafe
} from '../../utils';
const props = defineProps<{
Expand Down Expand Up @@ -124,7 +125,7 @@ const errorMessageForDisplay = computed(() => {
});
const allowQuickFixForBytes32 = computed(() => {
if (!errorMessageForDisplay?.value?.includes('long')) {
if (errorMessageForDisplay?.value?.includes('short')) {
return true;
}
return false;
Expand Down Expand Up @@ -159,16 +160,21 @@ watch(newValue, () => {
watch(newValue, value => {
if (isBytes32Input.value && !isArrayInput.value) {
const data = value?.slice(2) || '';
if (data.length < 64) {
validationErrorMessage.value = 'bytes32 too short';
return;
const padded = hexZeroPad(value, 32);
if (isBytesLikeSafe(padded)) {
validationErrorMessage.value = 'bytes32 too short';
return;
}
}
if (data.length > 64) {
validationErrorMessage.value = 'bytes32 too long';
return;
}
validationErrorMessage.value = '';
validationErrorMessage.value = undefined;
}
});
Expand Down

0 comments on commit b8087cf

Please sign in to comment.