Comments (14)
@calvinaco it seems it's always an integer to prevent confusion -- in that case, it's perhaps the easiest just to use SI units (milliCRO, microCRO, nanoCRO). "nanoCRO" won't have a correspondence on Eth, so one visual check is that, in genesis, it should always end with "0" (1 carson = 10 nanoCRO) -- in the case that any amounts in genesis need to be specified with sub-CRO denominations
from chain-main.
@calvinaco is that an issue here? in SDK's codebase, base units aren't really exposed / are rarely used (it seems all "end-user" RPC, CLI, configs etc. specify values in full coins)?
one other thing is that SDK has a fixed precision that's larger than the original erc20's 8 decimal points -- and it's used everywhere... "carson" referred to the base unit in the old code (and erc20), but here one can have "sub-carson" units
from chain-main.
@tomtau Oh actually this is something I want to clarify first as well. In the SDK the Coin should be CRO
or the base unit? Because it seems coin is the base unit and the proposal to further divide the "coin" to smaller usb unit is still in draft. But perhaps I overlook the concept.
If we look into the gaia genesis, it is also specifying the uatom
but not atom
https://raw.githubusercontent.com/cosmos/launch/master/genesis.json
from chain-main.
@calvinaco SDK's Coin is flexible -- it will always operate on that highest/fixed precision.
For application denominations, one can configure/register them and then convert between them: https://github.com/cosmos/cosmos-sdk/blob/master/types/denom.go#L44
from chain-main.
so I suggest just using "base denomination" as CRO (inputted with a decimal point if needed).
if there's ever a need to have that weird 10^-8
denomination (e.g. if it'll make easier some conversions from Eth), then just call RegisterDenom("carson", NewDecWithPrec(1, 8))
, as it's developer-only and it's already used
from chain-main.
Oh, but do coin
support decimal places? Because I saw the parse coin function in #15 , and the implementation seems to assume integer only.
Reference: https://github.com/cosmos/cosmos-sdk/blob/master/types/coin.go#L622
from chain-main.
it can be done by changing denom
in genesis
denom_metadata, when genesis is created
milli, micro, nano will be easy to use
from chain-main.
it can be in changing denom in genesis
denom_metadata, when genesis is createdmilli, micro, nano will be easy to use
Oh, how does it work? Because I saw it is in a draft proposal here
https://docs.cosmos.network/master/architecture/adr-024-coin-metadata.html
from chain-main.
i think, it's given by genesis block.
that adr merged into code, already
how about adding init
function to chain-main daemon?
which does, override various parameters for cro
from chain-main.
I can try to work on this -- I think setting denominations should just be a matter of registering them e.g. here: https://github.com/crypto-com/chain-main/blob/master/app/prefix.go#L17
from chain-main.
I can try to work on this -- I think setting denominations should just be a matter of registering them e.g. here: https://github.com/crypto-com/chain-main/blob/master/app/prefix.go#L17
I can share some of my experiments and findings here:
To use the denmo.go, yes I think we just need to call it at app bootstrap. But https://github.com/cosmos/cosmos-sdk/blob/master/types/denom.go#L44 .
On the other hand, I tried deno_metadata
, and after some tries I realize the proposal is implemented but only on the master branch
Commit: cosmos/cosmos-sdk@5a7e220#diff-593a9b28254d0c45f2e9c3974b0dd55d
Genesi: https://github.com/cosmos/cosmos-sdk/blob/master/x/bank/keeper/genesis.go#L42
Coin: https://github.com/cosmos/cosmos-sdk/blob/master/types/coin.go
so it is not available on 0.39.1 yet
Either way, they seems to assume always integer arithmetic. For example, let's say we want to say send 1.0000884cro, both the solutions seems won't support it. I could think of two ways, and maybe more:
- We keep only the base unit in the chain code, and implement the deno logic in client level (SDK, chain-maincli)
- We implement our own coin denom logic in the chain. Something like this: https://play.golang.org/p/32F5xDD6j55 but more complicated (this is for the Block explorer experiment and I tweak it a bit)
- and other solutions...
from chain-main.
We keep only the base unit in the chain code, and implement the deno logic in client level (SDK, chain-maincli)
+1 For this approach. Provided BigNumber handling is seamless.
from chain-main.
Either way, they seems to assume always integer arithmetic. For example, let's say we want to say send 1.0000884cro, both the solutions seems won't support it. I could think of two ways, and maybe more:
integer arithmetic is there for determinism (across platforms and architectures) -- we only do integer arithmetic in the old code.
from chain-main.
Either way, they seems to assume always integer arithmetic. For example, let's say we want to say send 1.0000884cro, both the solutions seems won't support it. I could think of two ways, and maybe more:
integer arithmetic is there for determinism (across platforms and architectures) -- we only do integer arithmetic in the old code.
Oh I see, thanks for the clarification.
from chain-main.
Related Issues (20)
- Problem: liquid staking module is not integrated HOT 1
- PQ
- My contract with Crypto.org is supersedes [OKX/CRO] 2018 @BrodysgotMs
- error="post failed: Post \"https://testnet-croeseid-4.crypto.org:26657\": context deadline exceeded"
- Problem: sdk 0.50 not integrated
- [proof-of-reserves-master.zip](https://github.com/user-attachments/files/16353163/proof-of-reserves-master.zip) HOT 1
- ![36958b46-5fb3-4b0b-938c-14f9eab38644](https://github.com/user-attachments/assets/1ef78a0c-e627-41de-879a-7219656991a1)
- [proof-of-reserves-master.zip](https://github.com/user-attachments/files/16353163/proof-of-reserves-master.zip) HOT 1
- Problem: no minimum packet timeout check for send-tx to host chain on behalf of ica account HOT 4
- # [Codecov](https://codecov.io/gh/crypto-org-chain/chain-main/pull/857?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=crypto-org-chain) Report HOT 1
- Problem: upgrading protobuf to 3.19.5 fails
- Problem: filepath not cleaned from potential variable inclusion
- Problem: unhandled iterator error in export HOT 2
- Problem: `cosmos-sdk` is not upgraded to `v0.46.2`
- Bug HOT 1
- Problem: Unable to statesync without statesync snapshotting enabled
- Problem: `query nft owner` returns error when user has NFTs transferred over IBC
- Problem: Lack error check in ExportAppStateAndValidators function HOT 3
- Tirle HOT 1
- Problem: comment for github action doesn't work well with go 1.20.1
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 chain-main.