From 76189c63575b700fae5c38e5f4f6826de05cef66 Mon Sep 17 00:00:00 2001 From: jangko Date: Wed, 5 May 2021 19:48:56 +0700 Subject: [PATCH] fixes graphql.scalar.Bytes32 relaxing the rigid length validation of Bytes32 scalar. allow it to parse hex less than 64 bytes, and add leading zeroes if needed. --- nimbus/graphql/ethapi.nim | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/nimbus/graphql/ethapi.nim b/nimbus/graphql/ethapi.nim index 6f31c7c60..4204524e5 100644 --- a/nimbus/graphql/ethapi.nim +++ b/nimbus/graphql/ethapi.nim @@ -315,7 +315,26 @@ proc validateHex(x: Node, minLen = 0): NodeResult = return err("invalid chars in hex") ok(x) -proc validateFixedLenHex(x: Node, minLen: int, kind: string): NodeResult = +proc padBytes(n: Node, prefixLen, minLen: int) = + let tmp = n.stringVal + if prefixLen != 0: + n.stringVal = newString(minLen + prefixLen) + for i in 0..