What behavior did you observed
I have a Bytes with value = 0x00000000000000000000000000000000000000000000000000001925d7b1b0d9
called BigInt.fromBytesBigEndian to convert to BigInt and print it out, got 192d7b1b0d9, missing a '5'.
What is the expected behavior
should give me 1925d7b1b0d9
How to reproduce
use the default zkgraph (src/), with the following modification:
mapping.ts:
//@ts-ignore
import { require } from "../lib/common/zkwasm";
import { Bytes, Event, BigInt } from "../lib/common/type";
export function handleEvents(events: Event[]): Bytes {
const source = changetype<Bytes>(events[0].data);
let reserve0 = source.slice(0, 32);
let reserve1 = source.slice(32, 64);
console.log(reserve0.toHexString())
let r0b = BigInt.fromBytesBigEndian(reserve0);
console.log(r0b.toHexString())
let r0 = BigInt.fromString(reserve0.toHexString(), 16);
console.log(r0.toHexString())
let r1 = BigInt.fromString(reserve1.toHexString(), 16);
let bi_price = r1.div(r0)
let payload = Bytes.fromHexString(bi_price.toString(16)).paddingTo(32, true, 0)
return payload;
}
$ npm run compile-local && npm run exec-local 0x10d1125
Which branch bignum
What behavior did you observed I have a Bytes with value = 0x00000000000000000000000000000000000000000000000000001925d7b1b0d9 called BigInt.fromBytesBigEndian to convert to BigInt and print it out, got 192d7b1b0d9, missing a '5'.
What is the expected behavior should give me 1925d7b1b0d9
How to reproduce use the default zkgraph (src/), with the following modification:
mapping.ts:
$ npm run compile-local && npm run exec-local 0x10d1125
output:
Other information you'd like to share It seems BigInt.fromBytes has the same issue.