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

feat(textual): Value Renderers for numbers #12088

Merged
merged 34 commits into from
Jul 25, 2022
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d8fe696
Add value renderer interface
amaury1093 Mar 21, 2022
ae64e51
Add test cases
amaury1093 Mar 21, 2022
31ca5d4
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/tex…
amaury1093 May 2, 2022
b17fac7
add coins tests
amaury1093 May 2, 2022
03682d0
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/tex…
amaury1093 May 16, 2022
49e9f64
Add formatCoins
amaury1093 May 16, 2022
0fa93b9
Add basic protoreflect infra
amaury1093 May 30, 2022
78d690e
Make integers test pass
amaury1093 May 30, 2022
5936d0f
Update interface
amaury1093 May 30, 2022
971e5fb
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/tex…
amaury1093 May 30, 2022
decc3be
Move to core/tx
amaury1093 Jun 2, 2022
3965e54
Fix decimal tests
amaury1093 Jun 2, 2022
186bea0
Add coins
amaury1093 Jun 2, 2022
0adabbc
Fix coin test
amaury1093 Jun 2, 2022
b2364b0
Add coins test
amaury1093 Jun 2, 2022
69a053f
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/tex…
amaury1093 Jul 13, 2022
a8b4e74
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/tex…
amaury1093 Jul 18, 2022
1208cb7
Add coins
amaury1093 Jul 18, 2022
78a5d43
Better interface
amaury1093 Jul 18, 2022
83f1d99
Add registry
amaury1093 Jul 18, 2022
e63e70f
Small tweaks
amaury1093 Jul 18, 2022
1844fe2
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/tex…
amaury1093 Jul 18, 2022
de9560c
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/tex…
amaury1093 Jul 19, 2022
dbe153b
Use io.Reader/Writer in interface
amaury1093 Jul 19, 2022
dcc8d62
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/tex…
amaury1093 Jul 20, 2022
f6a4c31
Use the new math LegacyDec
amaury1093 Jul 20, 2022
752aeb7
Fix test
amaury1093 Jul 21, 2022
40f629c
Merge branch 'main' into am/textual-number
amaury1093 Jul 21, 2022
28c878a
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/tex…
amaury1093 Jul 25, 2022
586147a
Move all to tx module
amaury1093 Jul 25, 2022
eb442e6
Cleanups go.mod
amaury1093 Jul 25, 2022
7a7a027
Merge branch 'am/textual-number' of ssh://github.com/cosmos/cosmos-sd…
amaury1093 Jul 25, 2022
c4d9b96
go mod tidy core
amaury1093 Jul 25, 2022
0857782
Merge branch 'main' into am/textual-number
amaury1093 Jul 25, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions core/tx/textual/internal/fixtures/coin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[
[{"amount": "1", "denom": "ucosm"}, { "denom": "COSM", "exponent": 6 }, "0.000001 COSM"],
[{"amount": "10", "denom": "ucosm"}, { "denom": "COSM", "exponent": 6 }, "0.00001 COSM"],
[{"amount": "100", "denom": "ucosm"}, { "denom": "COSM", "exponent": 6 }, "0.0001 COSM"],
[{"amount": "1000", "denom": "ucosm"}, { "denom": "COSM", "exponent": 6 }, "0.001 COSM"],
[{"amount": "10000", "denom": "ucosm"}, { "denom": "COSM", "exponent": 6 }, "0.01 COSM"],
[{"amount": "100000", "denom": "ucosm"}, { "denom": "COSM", "exponent": 6 }, "0.1 COSM"],
[{"amount": "1000000", "denom": "ucosm"}, { "denom": "COSM", "exponent": 6 }, "1 COSM"],
[{"amount": "10000000", "denom": "ucosm"}, { "denom": "COSM", "exponent": 6 }, "10 COSM"],
[{"amount": "1", "denom": "ucosm"}, { "denom": "COSM", "exponent": 2 }, "0.01 COSM"],
[{"amount": "10", "denom": "ucosm"}, { "denom": "COSM", "exponent": 2 }, "0.1 COSM"],
[{"amount": "100", "denom": "ucosm"}, { "denom": "COSM", "exponent": 2 }, "1 COSM"],
[{"amount": "1000", "denom": "ucosm"}, { "denom": "COSM", "exponent": 2 }, "10 COSM"],
[{"amount": "10000", "denom": "ucosm"}, { "denom": "COSM", "exponent": 2 }, "100 COSM"],
[{"amount": "100000", "denom": "ucosm"}, { "denom": "COSM", "exponent": 2 }, "1'000 COSM"],
[{"amount": "1000000", "denom": "ucosm"}, { "denom": "COSM", "exponent": 2 }, "10'000 COSM"],
[{"amount": "10000000", "denom": "ucosm"}, { "denom": "COSM", "exponent": 2 }, "100'000 COSM"],
[{"amount": "1", "denom": "point"}, { "denom": "POINT", "exponent": 0 }, "1 POINT"],
[{"amount": "10", "denom": "point"}, { "denom": "POINT", "exponent": 0 }, "10 POINT"],
[{"amount": "100", "denom": "point"}, { "denom": "POINT", "exponent": 0 }, "100 POINT"],
[{"amount": "1000", "denom": "point"}, { "denom": "POINT", "exponent": 0 }, "1'000 POINT"],
[{"amount": "10000", "denom": "point"}, { "denom": "POINT", "exponent": 0 }, "10'000 POINT"],
[{"amount": "100000", "denom": "point"}, { "denom": "POINT", "exponent": 0 }, "100'000 POINT"],
[{"amount": "1000000", "denom": "point"}, { "denom": "POINT", "exponent": 0 }, "1'000'000 POINT"],
[{"amount": "10000000", "denom": "point"}, { "denom": "POINT", "exponent": 0 }, "10'000'000 POINT"]
]
52 changes: 52 additions & 0 deletions core/tx/textual/internal/fixtures/coins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[
[
[
{ "amount": "1", "denom": "ucosm" },
{ "amount": "3", "denom": "ustake" }
],
{
"ucosm": { "denom": "COSM", "exponent": 6 },
"ustake": { "denom": "STAKE", "exponent": 6 }
},
"0.000001 COSM, 0.000003 STAKE"
],
[
[
{ "amount": "3", "denom": "ustake" },
{ "amount": "1", "denom": "ucosm" }
],
{
"ucosm": { "denom": "COSM", "exponent": 6 },
"ustake": { "denom": "STAKE", "exponent": 6 }
},
"0.000001 COSM, 0.000003 STAKE"
],
[
[
{ "amount": "1", "denom": "uaa" },
{ "amount": "2", "denom": "ubb" },
{ "amount": "3", "denom": "uatom" }
],
{
"uaa": { "denom": "AA", "exponent": 6 },
"ubb": { "denom": "BB", "exponent": 6 },
"uatom": { "denom": "atom", "exponent": 6 }
},
"0.000001 AA, 0.000002 BB, 0.000003 atom"
],
[
[
{ "amount": "4", "denom": "uxc1" },
{ "amount": "3", "denom": "uxc" },
{ "amount": "2", "denom": "uxb" },
{ "amount": "1", "denom": "uxa" }
],
{
"uxa": { "denom": "xA", "exponent": 6 },
"uxb": { "denom": "xB", "exponent": 6 },
"uxc": { "denom": "xC", "exponent": 6 },
"uxc1": { "denom": "xC1", "exponent": 6 }
},
"0.000001 xA, 0.000002 xB, 0.000003 xC, 0.000004 xC1"
]
]
43 changes: 43 additions & 0 deletions core/tx/textual/internal/fixtures/decimals.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[
["0", "0"],
["1", "1"],
["12", "12"],
["123", "123"],
["1234", "1'234"],
["0.1", "0.1"],
["0.01", "0.01"],
["0.001", "0.001"],
["0.0001", "0.0001"],
["0.00001", "0.00001"],
["0.000001", "0.000001"],
["0.0000001", "0.0000001"],
["0.00000001", "0.00000001"],
["0.000000001", "0.000000001"],
["0.0000000001", "0.0000000001"],
["0.00000000001", "0.00000000001"],
["0.000000000001", "0.000000000001"],
["0.0000000000001", "0.0000000000001"],
["0.00000000000001", "0.00000000000001"],
["0.000000000000001", "0.000000000000001"],
["0.0000000000000001", "0.0000000000000001"],
["0.00000000000000001", "0.00000000000000001"],
["0.000000000000000001", "0.000000000000000001"],
["0.100000000000000000", "0.1"],
["0.010000000000000000", "0.01"],
["0.001000000000000000", "0.001"],
["0.000100000000000000", "0.0001"],
["0.000010000000000000", "0.00001"],
["0.000001000000000000", "0.000001"],
["0.000000100000000000", "0.0000001"],
["0.000000010000000000", "0.00000001"],
["0.000000001000000000", "0.000000001"],
["0.000000000100000000", "0.0000000001"],
["0.000000000010000000", "0.00000000001"],
["0.000000000001000000", "0.000000000001"],
["0.000000000000100000", "0.0000000000001"],
["0.000000000000010000", "0.00000000000001"],
["0.000000000000001000", "0.000000000000001"],
["0.000000000000000100", "0.0000000000000001"],
["0.000000000000000010", "0.00000000000000001"],
["0.000000000000000001", "0.000000000000000001"]
]
19 changes: 19 additions & 0 deletions core/tx/textual/internal/fixtures/integers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[
["0", "0"],
["1", "1"],
["12", "12"],
["123", "123"],
["1234", "1'234"],
["12345", "12'345"],
["123456", "123'456"],
["1234567", "1'234'567"],
["9007199254740991", "9'007'199'254'740'991"],
["9007199254740992", "9'007'199'254'740'992"],
["18446744073709551615", "18'446'744'073'709'551'615"],
["18446744073709551616", "18'446'744'073'709'551'616"],
["340282366920938463463374607431768211455", "340'282'366'920'938'463'463'374'607'431'768'211'455"],
["01", "1"],
["001", "1"],
["0001", "1"],
["00001", "1"]
]
40 changes: 40 additions & 0 deletions core/tx/textual/internal/testpb/1.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
syntax="proto3";

option go_package = "cosmossdk.io/core/tx/textual/internal/testpb";

import "google/protobuf/descriptor.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/base/v1beta1/coin.proto";

enum Enumeration {
One = 0;
Two = 1;
}

// A contains fields that are parseable by SIGN_MODE_TEXTUAL.
message A {
uint32 UINT32 = 1;
uint64 UINT64 = 2;
int32 INT32 = 3;
int64 INT64 = 4;
string SDKINT = 5 [(cosmos_proto.scalar) = "cosmos.Int"];
string SDKDEC = 6 [(cosmos_proto.scalar) = "cosmos.Dec"];
cosmos.base.v1beta1.Coin COIN = 7;
repeated cosmos.base.v1beta1.Coin COINS = 8;
}

// B contains fields that are not parseable by SIGN_MODE_TEXTUAL, some fields
// may be moved to A at some point.
message B {
int32 INT32 = 1;
sint32 SINT32 = 2;
int64 INT64 = 3;
sint64 SING64 = 4;
sfixed32 SFIXED32 = 5;
fixed32 FIXED32 = 6;
float FLOAT = 7;
sfixed64 SFIXED64 = 8;
fixed64 FIXED64 = 9;
double DOUBLE = 10;
map<string, B> MAP = 11;
}
Loading