GithubHelp home page GithubHelp logo

Comments (14)

tomtau avatar tomtau commented on August 15, 2024 2

@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.

tomtau avatar tomtau commented on August 15, 2024

@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.

calvinaco avatar calvinaco commented on August 15, 2024

@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.

tomtau avatar tomtau commented on August 15, 2024

@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.

tomtau avatar tomtau commented on August 15, 2024

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.

calvinaco avatar calvinaco commented on August 15, 2024

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.

leejw51crypto avatar leejw51crypto commented on August 15, 2024

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.

calvinaco avatar calvinaco commented on August 15, 2024

it can be in changing denom in genesis
denom_metadata, when genesis is created

milli, 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.

leejw51crypto avatar leejw51crypto commented on August 15, 2024

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.

tomtau avatar tomtau commented on August 15, 2024

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.

calvinaco avatar calvinaco commented on August 15, 2024

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.

cdc-Hitesh avatar cdc-Hitesh commented on August 15, 2024

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.

tomtau avatar tomtau commented on August 15, 2024

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.

calvinaco avatar calvinaco commented on August 15, 2024

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)

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.