docs icon indicating copy to clipboard operation
docs copied to clipboard

Type conversion from BigInt to Bytes

Open schmidsi opened this issue 3 years ago • 2 comments

https://thegraph.com/docs/en/developing/assemblyscript-api/#type-conversions-reference

schmidsi avatar Oct 18 '22 13:10 schmidsi

@schmidsi are you saying this needs to be added to the docs?

azf20 avatar Oct 19 '22 20:10 azf20

@azf20 Yes. Or maybe even better support it in TS. Sorry for not better speccing this out since I was focusing on something else but wanted to leave the note here.

I ended up with something like:

Bytes.fromI32(event.params.tokenId.toI32()

But to transform a BigInt to I32 is removing info and should be avoided. Better would be Bytes.fromBigInt or BigInt.toBytes(). But for now, we could document the code above.

schmidsi avatar Oct 20 '22 02:10 schmidsi