mirror of
https://github.com/logos-storage/nim-contract-abi.git
synced 2026-01-08 16:43:08 +00:00
Fixes after breaking changes in stew and stint
This commit is contained in:
parent
61f8f59b39
commit
4fc7c8a779
@ -2,6 +2,7 @@ import std/typetraits
|
|||||||
import pkg/stint
|
import pkg/stint
|
||||||
import pkg/upraises
|
import pkg/upraises
|
||||||
import pkg/stew/byteutils
|
import pkg/stew/byteutils
|
||||||
|
import pkg/stew/endians2
|
||||||
import ./integers
|
import ./integers
|
||||||
import ./address
|
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) =
|
func encode(encoder: var AbiEncoder, value: SomeUnsignedInt | StUint) =
|
||||||
encoder.padleft(value.toBytesBE)
|
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 bytes = value.unsigned.toBytesBE
|
||||||
let padding = if value.isNegative: 0xFF'u8 else: 0x00'u8
|
let padding = if value.isNegative: 0xFF'u8 else: 0x00'u8
|
||||||
encoder.padleft(bytes, padding)
|
encoder.padleft(bytes, padding)
|
||||||
|
|||||||
@ -14,4 +14,4 @@ func unsigned*(value: SomeSignedInt): SomeUnsignedInt =
|
|||||||
cast[typeof(value).unsigned](value)
|
cast[typeof(value).unsigned](value)
|
||||||
|
|
||||||
func unsigned*[bits](value: StInt[bits]): StUint[bits] =
|
func unsigned*[bits](value: StInt[bits]): StUint[bits] =
|
||||||
value.stuint(bits)
|
cast[typeof(value).unsigned](value)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user