#Error in scvalToBigNumber

3 messages · Page 1 of 1 (latest)

summer jacinth
#

Hello, I am exploring soroban-example-dapp.
When I support with 100 units, I get in the front end that I have supported with 100 units
With 200 units, appears 200 units

But when I support with 300 units, appears -129,497
With 400, appears -29,497

I realize that is a problem of convert.ts's function: scvalToBigNumber

I did some console logs...

case xdr.ScObjectType.scoI128(): {
      const parts = obj.i128();
      console.log("parts: ", parts)
      const a = parts.hi();
      console.log("a: ", a)
      const b = parts.lo();
      console.log("b: ", b)
      return bigNumberFromBytes(true, a.high, a.low, b.high, b.low);
    }

WIth 200 I get

a:  UnsignedHyper {low: 0, high: 0, unsigned: true}high: 0low: 0unsigned: true[[Prototype]]: Long
VM3520 index.tsx:115
b: UnsignedHyper {low: 2000000000, high: 0, unsigned: true} high : 0 low : 2000000000 unsigned : true [[Prototype]] : Long  

Wich seems OK

But with 400 I get

a:  UnsignedHyper {low: 0, high: 0, unsigned: true}high: 0low: 0unsigned: true[[Prototype]]: Long index.tsx?a5ff:80
b:  b:  UnsignedHyper {low: -294967296, high: 0, unsigned: true}

I guess this is a problem of stellar-base ScVal class?
Does anyone have some clue?

Thanks!

#

@lethal umbra , do you have any idea?

lethal umbra
#

scvalToBigNumber could definitely be buggy