Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amount.toString should support FormatSpec #3036

Open
Geod24 opened this issue Feb 11, 2022 · 1 comment
Open

Amount.toString should support FormatSpec #3036

Geod24 opened this issue Feb 11, 2022 · 1 comment
Labels
difficulty-easy An issue which is estimated to be relatively easy to resolve prio-low
Milestone

Comments

@Geod24
Copy link
Collaborator

Geod24 commented Feb 11, 2022

Currently our formatting for Amount is very basic and leads to some surprise.

/// Pretty-print this value
public void toString (scope SinkT dg) const @safe
{
formattedWrite(dg, "%d", this.value);
}
/// Also support for Vibe.d serialization to JSON
public string toString () const @safe
{
string ret;
scope SinkT dg = (in v) { ret ~= v; };
this.toString(dg);
return ret;
}

We should support %d to get the absolute value like currently, but being able to get 40,000 or 40,000.000,000,1 (up for discussion) would be nicer.

@Geod24 Geod24 added prio-low difficulty-easy An issue which is estimated to be relatively easy to resolve labels Feb 11, 2022
@Geod24 Geod24 added this to the 99. Unbounded milestone Feb 11, 2022
@Geod24
Copy link
Collaborator Author

Geod24 commented Feb 11, 2022

Context:
https://github.com/bosagora/faucet/blob/834e16342aa5699ded55b90425734012e8135276/source/faucet/main.d#L535

Prints:

Feb 11 05:57:13 eu-001.bosagora.io docker[73427]: 2022-02-11 05:57:13,329 Info [faucet.main] - Sending 400000000000 BOA to boa1xz3qed5979y0v0mjjsndh5lcjmyvp9hrcsu78qs4mjw8gugqnkxx25e3qfd

Which is wrong, it's sending 400000000000 (400,000,000,000) units, which is 40k BOA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty-easy An issue which is estimated to be relatively easy to resolve prio-low
Projects
None yet
Development

No branches or pull requests

2 participants
@Geod24 and others