chore: replace amino cosmos_dec_bytes annoation by scalar cosmos.Dec and add missing annotations (#17000)

This commit is contained in:
Julien Robert
2023-07-14 18:10:28 +00:00
committed by GitHub
parent 38f1014d26
commit 7ed04f71b4
16 changed files with 454 additions and 443 deletions
+3
View File
@@ -216,3 +216,6 @@ replace (
// TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.1
)
// TODO to be removed after API tag
replace cosmossdk.io/api => ../api
-2
View File
@@ -187,8 +187,6 @@ cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xX
cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuWDEEsqMTg=
cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0=
cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M=
cosmossdk.io/api v0.6.0 h1:AEpx/sRZaQEusARZqAxbg20zRXnS6e1F+uoal39trOM=
cosmossdk.io/api v0.6.0/go.mod h1:kJFAEMLN57y0viszHDPLMmieF0471o5QAwwApa+270M=
cosmossdk.io/collections v0.3.0 h1:v0eEqLBxebAV+t+Ahwf9tSJOu95HVLINwROXx2TTZ08=
cosmossdk.io/collections v0.3.0/go.mod h1:CHE1+niUElL9ikCpevRZcp0yqQ4TU0TrEEGirN0mvIg=
cosmossdk.io/core v0.9.0 h1:30ScAOHDIUOCg1DKAwqkho9wuQJnu7GUrMcg0XLioic=
+4 -9
View File
@@ -11,7 +11,6 @@ import (
"google.golang.org/protobuf/reflect/protoregistry"
"pgregory.net/rapid"
"cosmossdk.io/api/amino"
authapi "cosmossdk.io/api/cosmos/auth/v1beta1"
authzapi "cosmossdk.io/api/cosmos/authz/v1beta1"
bankapi "cosmossdk.io/api/cosmos/bank/v1beta1"
@@ -77,22 +76,18 @@ func WithDecisionPolicy(opts rapidproto.GeneratorOptions) rapidproto.GeneratorOp
func GeneratorFieldMapper(t *rapid.T, field protoreflect.FieldDescriptor, name string) (protoreflect.Value, bool) {
opts := field.Options()
switch {
case proto.HasExtension(opts, cosmos_proto.E_Scalar):
if proto.HasExtension(opts, cosmos_proto.E_Scalar) {
scalar := proto.GetExtension(opts, cosmos_proto.E_Scalar).(string)
switch scalar {
case "cosmos.Int":
i32 := rapid.Int32().Draw(t, name)
return protoreflect.ValueOfString(fmt.Sprintf("%d", i32)), true
case "cosmos.Dec":
return protoreflect.ValueOfString(""), true
}
case field.Kind() == protoreflect.BytesKind:
if proto.HasExtension(opts, amino.E_Encoding) {
encoding := proto.GetExtension(opts, amino.E_Encoding).(string)
if encoding == "cosmos_dec_bytes" {
if field.Kind() == protoreflect.BytesKind {
return protoreflect.ValueOfBytes([]byte{}), true
}
return protoreflect.ValueOfString(""), true
}
}