PaulRBerg / evm-bn

Convert fixed-point numbers to ethers big numbers and vice-versa.
MIT License
49 stars 4 forks source link

migrate BigNumber to BigInt #18

Open ahmedali8 opened 1 year ago

ahmedali8 commented 1 year ago

Hi @PaulRBerg, would like to open a PR for this, if you think it's a good idea to migrate as ethers now use bigint in v6.

PaulRBerg commented 1 year ago

Yeah, go for it, thanks very much!

ahmedali8 commented 1 year ago

I think there are two possible ways, correct me if I'm wrong please.

  1. we use such technique for toBn and fromBn:

return parseFixed(xs, decimals).toBigInt()

https://github.com/PaulRBerg/evm-bn/blob/bff6991c697150f2d387e0b591ce81d23efb8271/src/toBn.ts#L40

  1. we rewrite the implementation of parseFixed for bigint

https://github.com/ethers-io/ethers.js/blob/ec1b9583039a14a0e0fa15d0a2a6082a2f41cf5b/packages/bignumber/src.ts/fixednumber.ts#L70

What do you suggest?

PaulRBerg commented 1 year ago

@ahmedali8 I'm unfortunately tied up with my work at Sablier V2 and not able to provide implementation feedback at the moment

ahmedali8 commented 1 year ago

No worries @PaulRBerg, do let me know whenever you get time. I'll use a workaround for my task as of now. Thanks!