From b8087cfa81706463b8fed50b9c07d81e6a0a8b21 Mon Sep 17 00:00:00 2001 From: Gerhard Steenkamp Date: Fri, 12 Apr 2024 11:58:18 +0200 Subject: [PATCH] fix bytes32 validation message --- .../oSnap/components/Input/MethodParameter.vue | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/plugins/oSnap/components/Input/MethodParameter.vue b/src/plugins/oSnap/components/Input/MethodParameter.vue index 8856e6dd..d6fcada1 100644 --- a/src/plugins/oSnap/components/Input/MethodParameter.vue +++ b/src/plugins/oSnap/components/Input/MethodParameter.vue @@ -6,7 +6,8 @@ import { InputTypes, validateArrayInput, validateInput, - validateTupleInput + validateTupleInput, + isBytesLikeSafe } from '../../utils'; const props = defineProps<{ @@ -124,7 +125,7 @@ const errorMessageForDisplay = computed(() => { }); const allowQuickFixForBytes32 = computed(() => { - if (!errorMessageForDisplay?.value?.includes('long')) { + if (errorMessageForDisplay?.value?.includes('short')) { return true; } return false; @@ -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; } });