Zondax / filecoin-solidity

Filecoin Solidity API Library
Apache License 2.0
94 stars 43 forks source link

Add lib function to convert ints/uints to BigInt and vice versa #230

Closed shrenujbansal closed 1 year ago

shrenujbansal commented 1 year ago

It'd be very useful to add a library function to convert ints/uints to BigInt which is required by some structures in builtin actors

:link: zboto Link

emmanuelm41 commented 1 year ago

Hi @shrenujbansal! For that we found this library. As you can see, it is a fork. We just released the package on NPM for dev experience. I think it is enough for handling bigints from bulletin actors.

shrenujbansal commented 1 year ago

@emmanuelm41 I don't think we can use this library. It provides a struct BigNumber which is very different from the BigInt used by the builtin actors. This struct is defined and marshalled/unmarshalled in solidity here: https://github.com/Zondax/filecoin-solidity/blob/master/contracts/v0.8/cbor/BigIntCbor.sol#L22

We will be using this struct for fields within params/returns for the builtin actors and will need tooling for conversion for this

emmanuelm41 commented 1 year ago

Builtin actors use a different structure, but when we serialize params we require BigInt (our own structure) as input type. Same when we deserialize return values. They are converted from builtin actors biting to BigInt (our own structure). That structure is very much compatible to the one defined on the library I shared before.