Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move from TinyBig to BigInt #193

Open
dawsbot opened this issue Feb 12, 2023 · 3 comments
Open

Move from TinyBig to BigInt #193

dawsbot opened this issue Feb 12, 2023 · 3 comments
Labels
enhancement New feature or request Epic Big or tricky

Comments

@dawsbot
Copy link
Owner

dawsbot commented Feb 12, 2023

This is low priority for now. We should wait until BigInt becomes more of an industry standard.

This change is inspired by the recent change in ethers.js to BigInt.

https://docs.ethers.org/v6-beta/migrating/#migrate-bigint

@dawsbot dawsbot added enhancement New feature or request Epic Big or tricky labels Mar 5, 2023
@jtfirek
Copy link
Collaborator

jtfirek commented May 17, 2023

I have started to look into this.

Do we want to upgrade to a new version of TypeScript in the tsconfig.json for this?

I have been playing around with using BigInt and I am running into a ts error when trying to use BigInt literals.
For example:

export function etherToWei(
  etherQuantity: string | number | bigint,
): bigint {
  validateType(etherQuantity, ['string', 'number', 'object']);
  const result = BigInt(etherQuantity) * 1000000000000000000n
  return BigInt(result);
}

throws this ts error:
BigInt literals are not available when targeting lower than ES2020.

We could use the constructor which compiles just fine with our current version of typescript

  const result = BigInt(etherQuantity) * BigInt(1000000000000000000)

@jtfirek
Copy link
Collaborator

jtfirek commented May 17, 2023

Also are we completely deprecating TinyBig and only supporting BigInt?
Like removing the TinyBig and Big inputs from functions?
https://github.com/dawsbot/essential-eth/blob/b079202c2b1dc51f5a03bac966bebb1862413e5c/src/utils/ether-to-wei.ts#LL31C12-L31C31

@dawsbot
Copy link
Owner Author

dawsbot commented May 22, 2023

Let's wait on this with the first priority now being a full refresh of the landing page.

I really like viem.sh and would love your input/shaping of this new website @jtfirek 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Epic Big or tricky
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants