elrond-sdk-erdjs icon indicating copy to clipboard operation
elrond-sdk-erdjs copied to clipboard

BooleanValue is always encoded as false

Open gfusee opened this issue 1 year ago • 1 comments

Here is a reproductible example :

const booleanString = "true"
const value = NativeSerializer.nativeToTypedValues(
    [booleanString],
    new EndpointDefinition(
        "test",
        [
            new EndpointParameterDefinition("test", "test", new BooleanType())
        ],
        [],
        new EndpointModifiers("mutable", [])
    )
)[0]
const codec = new BinaryCodec()
const encodedTopLevel = codec.encodeTopLevel(value)
const encodedNested = codec.encodeNested(value)
console.log({
    encodedTopLevel: encodedTopLevel.toString("hex"),
    encodedNested: encodedNested.toString("hex")
})

And what is logged :

{ encodedTopLevel: '', encodedNested: '00' }

The result is the same if I replace "true" by "1"

I'm using @multiversx/sdk-core: ^11.3.0

gfusee avatar Feb 16 '23 21:02 gfusee

It may not be a bug since true or 1 instead of "true" or "1" is working, but this leads to confusion to consider "true" as false

gfusee avatar Feb 16 '23 22:02 gfusee