Giter VIP home page Giter VIP logo

Comments (4)

volovyks avatar volovyks commented on September 24, 2024 1

Looks like we have a flexible way to format N amount here:
https://github.com/near/near-api-js/blob/master/src/utils/format.ts
@frol if you feel like we need something more specific - feel free to reopen this issue.

from near-api-js.

janedegtiareva avatar janedegtiareva commented on September 24, 2024
  • We need to design how this shows up in UI
    @frol do you mind providing some specific requirements for near-api-js?

from near-api-js.

frol avatar frol commented on September 24, 2024

The main requirement is to display any amounts of NEAR in a human-readable format no matter how small or how huge the value is, we should just use all the metric prefixes, so the number is always less than 1000 and greater or equal than 1:

  • 1 NEAR (N)
  • 999.99 milliNEAR (mN)
  • 1 yoctoNEAR (yN)
  • 999 yoctoNEAR (yN)
  • 1 zeptoNEAR (zN) [1000 yoctoNEAR]
  • 1 kiloNEAR (kN) [1000 NEAR]

We should not round the amounts up, so 9,999,999,999 yN should be 9.99 femtoNEAR, thus we need to indicate that there is some more tokens, e.g. 9.99+ fN or 9.99~ fN.

In Explorer, we display the balances, transfers, and fees, so the amounts of tokens we need to display can be both huge and small.

from near-api-js.

amgando avatar amgando commented on September 24, 2024

The main requirement is to display any amounts of NEAR in a human-readable format

As far as user interfaces go (wallet, shell, explorer, etc) i suggest we round things off to simple values of NEAR because that's what humans are expecting (you have ~$1, not $1.00000000001). The API should surface the exact number along with a human readable value. The UI can show the human readable value with the exact number showing up as a tooltip (or similar hidden-before-reveal container)

from near-api-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.