ethereum-multicall icon indicating copy to clipboard operation
ethereum-multicall copied to clipboard

Multicall doesn't return result with same type like BigNumber from "ether" when using singlecall !!!

Open nguy3nds opened this issue 3 years ago • 5 comments

Mulltilcall returns CallValueResult with type: { type: "BigNumber", hex: "0x0176b344f2a78c0000" },

It doesn't the same type as I call single. This case type is likely { BigNumber } from "ether." It's { _isBigNumber: true, _hex: "0x0176b344f2a78c0000" },

Could anyone tell me if I missed anything?

nguy3nds avatar Apr 24 '22 09:04 nguy3nds

You can use BigNumber.From to parse it on the response in your code. right now in the lib it just returns the nine class version.. would be nicer if it parsed for you for sure on cases where _isBigNumber = true

Will look at doing that but for now parse it yourself once result comes back

joshstevens19 avatar Apr 24 '22 09:04 joshstevens19

You can use BigNumber.From to parse it on the response in your code. right now in the lib it just returns the nine class version.. would be nicer if it parsed for you for sure on cases where _isBigNumber = true

Will look at doing that but for now parse it yourself once result comes back

Hi! As we have introduced an options parameter into the call method, we could add a new parameter to return bignumbers instead of strings?

jsertx avatar Jul 02 '22 10:07 jsertx

For sure great idea!! be my guest to do a PR @jsertx

joshstevens19 avatar Jul 02 '22 18:07 joshstevens19

I have seen that the issue is on the Utils.deepClone when building returnObjectResult pushing to callsReturnContext array in the following lines:

https://github.com/joshstevens19/ethereum-multicall/blob/80ae156f2672fe154c79fc09183790282134dfb5/src/multicall.ts#L165 https://github.com/joshstevens19/ethereum-multicall/blob/80ae156f2672fe154c79fc09183790282134dfb5/src/multicall.ts#L209 https://github.com/joshstevens19/ethereum-multicall/blob/80ae156f2672fe154c79fc09183790282134dfb5/src/multicall.ts#L237

We could release a new minor version: adding the extra options parameter returnBigNumber to parse it with false as default to not break current implementations. And maybe, in a major version add that parsing option default to true, so removes friction for first time users.

jsertx avatar Jul 06 '22 15:07 jsertx

Nice find yeah that will nuke the big number class! And now it’s in the wild we can’t really break it! I would say yes do the returnBigNumber option and make it parse stuff back and then as you say we can bring in a breaking change on the major! We can guide the docs to this as well! PR welcome!

joshstevens19 avatar Jul 06 '22 20:07 joshstevens19