Giter Club home page Giter Club logo

Comments (7)

0crat avatar 0crat commented on June 4, 2024

@Biboran/z please, pay attention to this issue

from web3swift.

rockfridrich avatar rockfridrich commented on June 4, 2024

However, most of the use cases will be:

  1. Arithmetic operators +, -, *, /, %, +=, -=, *=, /=, %=
  2. Output (prettifier, string conversion)
  3. Working with decimals — we will have large Int and then we need to set precision.
  4. Working with hex <-> Int

from web3swift.

abdulowork avatar abdulowork commented on June 4, 2024

@rockfridrich design wise, I would want to stay away from representing numerical types in the library as big numbers because the user of the library working with ethereum is already likely to depend on some big number library. If we can try to stick to String, Data/Array<UInt8> and behavior for objects we should do that. In the case we will have to use a library for arithmetic operations we shouldn't expose these dependencies to the user of the library.

  1. Arithmetic operators +, -, *, /, %, +=, -=, *=, /=, %=

Lets list the cases where we might need arithmetic operations on big numbers in the library.

  1. Output (prettifier, string conversion)

I believe we should do that through our own numeric type that will be able to return its decimal and hex representation as a string.

  1. Working with decimals — we will have large Int and then we need to set precision.

I am not sure what you mean. Could you please elaborate?

  1. Working with hex <-> Int

Lets keep it same as 2.

from web3swift.

abdulowork avatar abdulowork commented on June 4, 2024

I gave it a though and I think we should get rid of NumberScalar. Let's model all numbers as 2s complements BytesScalar and make a bunch of objects to validate and operate on those numbers. Let's also make a StringScalar to convert them to string representation decimal.

from web3swift.

rockfridrich avatar rockfridrich commented on June 4, 2024

@Biboran the first arithmetic and comparison operations I got in mind is checking if the user has enough Ether of tokens to perform the procedure. In the case of ether, we are checking account balance, sending amount and transaction fee. In case the user does not have enough Ether we can throw an error in high domain objects.

For the decimals, we often convert large Ints to decimal numbers based on some power. For example, ETH is 10^18 WEI or gas price is calculated in Gwei (10^9). Another example, the token balance is calculated and displayed as:
{balance}/10^{token decimals}, however when we perform calls and transactions to contract we need to deal with integers.

We need to cover these use cases to simplify everyday operations. Here are some ideas about how to structure number classes.
screen shot 2018-05-19 at 17 47 05

from web3swift.

0crat avatar 0crat commented on June 4, 2024

Job gh:blockstoreapp/web3swift#60 is not assigned, can't get performer

from web3swift.

0crat avatar 0crat commented on June 4, 2024

The job is not in WBS, won't close the order

from web3swift.

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.