Fixes after breaking changes in stew and stint

This commit is contained in:
Mark Spanbroek 2023-06-29 11:01:14 +02:00 committed by markspanbroek
parent 61f8f59b39
commit a5f676eecc
2 changed files with 8 additions and 2 deletions

View File

@ -2,6 +2,7 @@ import std/typetraits
import pkg/stint
import pkg/upraises
import pkg/stew/byteutils
import pkg/stew/endians2
import ./integers
import ./address
@ -87,7 +88,12 @@ func padright(encoder: var AbiEncoder, bytes: openArray[byte], padding=0'u8) =
func encode(encoder: var AbiEncoder, value: SomeUnsignedInt | StUint) =
encoder.padleft(value.toBytesBE)
func encode(encoder: var AbiEncoder, value: SomeSignedInt | StInt) =
func encode(encoder: var AbiEncoder, value: SomeSignedInt) =
let bytes = value.unsigned.toBytesBE
let padding = if value < 0: 0xFF'u8 else: 0x00'u8
encoder.padleft(bytes, padding)
func encode(encoder: var AbiEncoder, value: StInt) =
let bytes = value.unsigned.toBytesBE
let padding = if value.isNegative: 0xFF'u8 else: 0x00'u8
encoder.padleft(bytes, padding)

View File

@ -14,4 +14,4 @@ func unsigned*(value: SomeSignedInt): SomeUnsignedInt =
cast[typeof(value).unsigned](value)
func unsigned*[bits](value: StInt[bits]): StUint[bits] =
value.stuint(bits)
cast[typeof(value).unsigned](value)