Skip to content

Commit 141907c

Browse files
authored
fix: readValue UInt256 error (#224)
* fix: readValue UInt256 error Fixing `readValue(reader`gensym50, result)' is of type 'UInt256' and has to be used (or discarded)` error by ensuring value returned by `readValue` is used. * Only one readValue function needs to be defined * ci: force arm64 target For some reason, clang assumed x86_64 and rejected nimcrypto's "-march=armv8-a+crypto" flag.
1 parent c2b10b4 commit 141907c

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@ jobs:
148148
echo "ncpu=$ncpu" >> $GITHUB_ENV
149149
echo "MAKE_CMD=${MAKE_CMD}" >> $GITHUB_ENV
150150
151+
- name: Configure ARM64 build environment (macOS)
152+
if: runner.os == 'macOS' && matrix.target.cpu == 'arm64'
153+
run: |
154+
# Force ARM64 architecture for Nim compilation with proper flags passed to clang
155+
echo "NIMFLAGS=--cpu:arm64 --cc:clang --passC:\"-target arm64-apple-macos11\" --passL:\"-target arm64-apple-macos11\"" >> $GITHUB_ENV
156+
151157
- name: Build Nim and Nimble
152158
run: |
153159
curl -O -L -s -S https://raw.githubusercontent.com/status-im/nimbus-build-system/master/scripts/build_nim.sh

web3/decoding.nim

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -325,24 +325,16 @@ proc decode*(decoder: var AbiDecoder, T: type): T {.raises: [SerializationError]
325325
decoder.finish()
326326
return value
327327

328-
proc readValue*[T](r: var AbiReader, value: T): T {.raises: [SerializationError]} =
329-
try:
330-
readValue[T](r, T)
331-
except SerializationError as e:
332-
raise newException(SerializationError, e.msg)
333-
334-
proc readValue*[T](r: var AbiReader, _: typedesc[T]): T {.raises: [SerializationError]} =
335-
var resultObj: T
328+
proc readValue*[T](r: var AbiReader, value: var T) {.raises: [SerializationError]} =
336329
var decoder = AbiDecoder(input: r.getStream)
337330
type StInts = StInt | StUint
338331

339332
when T is object and T is not StInts:
340-
resultObj = decodeObject(decoder, T)
333+
value = decodeObject(decoder, T)
341334
else:
342-
resultObj = decoder.decode(T)
335+
value = decoder.decode(T)
343336

344337
decoder.finish()
345-
result = resultObj
346338

347339
# Keep the old encode functions for compatibility
348340
func decode*(input: openArray[byte], baseOffset, offset: int, to: var StUint): int {.deprecated: "use Abi.decode instead"} =

0 commit comments

Comments
 (0)