Comments (7)
@Biboran/z please, pay attention to this issue
from web3swift.
However, most of the use cases will be:
- Arithmetic operators
+, -, *, /, %, +=, -=, *=, /=, %=
- Output (prettifier, string conversion)
- Working with
decimals
— we will have largeInt
and then we need to set precision. - Working with
hex
<->Int
from web3swift.
@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.
-
Arithmetic operators +, -, *, /, %, +=, -=, *=, /=, %=
Lets list the cases where we might need arithmetic operations on big numbers in the library.
-
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.
-
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?
-
Working with hex <-> Int
Lets keep it same as 2.
from web3swift.
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.
@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 Int
s 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.
from web3swift.
Job gh:blockstoreapp/web3swift#60
is not assigned, can't get performer
from web3swift.
The job is not in WBS, won't close the order
from web3swift.
Related Issues (20)
- Missing Decimal and Normalized Decimal conversion HOT 2
- Missing ability to fetch Logs
- Migrate to Swift 5
- Use SPM instead of cocoapods example project
- Separate tests that use ganache from those that do not
- Upgrade BigInt library HOT 1
- Upgrade Travis build config
- Update alchemy adapter
- Migrate to Boilertalk/secp256k1 to resolve secp256k1 header conflicts
- Make EmptyBytes constructor public
- Add EthContractCall constructor, which accepts weiAmount
- Add EthContractCallBytes constructor, which accepts custom gasPrice
- Make Zero init public
- How to add Basic Auth? HOT 1
- Dapp with no to address how to send coin HOT 2
- Mavann599- [Safari Shared/web3-provider/Not.yarn.unlock ] HOT 1
- - [No
- Is there an SDK for ios HOT 1
- X
- Ocean protocol's startOrder(...) method implementation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from web3swift.