From ab3febab0c342e7303968c72b93265680ef9a7be Mon Sep 17 00:00:00 2001 From: Amaury <1293565+amaurym@users.noreply.github.com> Date: Mon, 25 Jul 2022 18:55:24 +0200 Subject: [PATCH] feat(textual): Value Renderers for numbers (#12088) ## Description closes #12613 This PR sets up the infrastructure for value renderers as discussed in ADR-050. It's only additive, in a new package, and isn't wired up to the rest of the codebase. It adds a new root go module `tx`, which has one `textual` subpackage for now. Only adds implementation for: - integers - decimals Sister PR: - [ ] https://github.com/cosmos/cosmjs/pull/1147 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable) --- go.mod | 2 +- tx/go.mod | 18 + tx/go.sum | 65 + tx/textual/internal/testdata/README.md | 3 + tx/textual/internal/testdata/decimals.json | 43 + tx/textual/internal/testdata/integers.json | 19 + tx/textual/internal/testpb/1.proto | 40 + tx/textual/internal/testpb/1.pulsar.go | 2441 +++++++++++++++++ tx/textual/internal/testpb/Makefile | 2 + tx/textual/internal/testpb/buf.gen.yaml | 15 + tx/textual/internal/testpb/buf.lock | 17 + tx/textual/internal/testpb/buf.yaml | 12 + tx/textual/valuerenderer/dec.go | 56 + tx/textual/valuerenderer/int.go | 48 + tx/textual/valuerenderer/types.go | 20 + tx/textual/valuerenderer/valuerenderer.go | 69 + .../valuerenderer/valuerenderer_test.go | 145 + 17 files changed, 3014 insertions(+), 1 deletion(-) create mode 100644 tx/go.mod create mode 100644 tx/go.sum create mode 100644 tx/textual/internal/testdata/README.md create mode 100644 tx/textual/internal/testdata/decimals.json create mode 100644 tx/textual/internal/testdata/integers.json create mode 100644 tx/textual/internal/testpb/1.proto create mode 100644 tx/textual/internal/testpb/1.pulsar.go create mode 100644 tx/textual/internal/testpb/Makefile create mode 100644 tx/textual/internal/testpb/buf.gen.yaml create mode 100644 tx/textual/internal/testpb/buf.lock create mode 100644 tx/textual/internal/testpb/buf.yaml create mode 100644 tx/textual/valuerenderer/dec.go create mode 100644 tx/textual/valuerenderer/int.go create mode 100644 tx/textual/valuerenderer/types.go create mode 100644 tx/textual/valuerenderer/valuerenderer.go create mode 100644 tx/textual/valuerenderer/valuerenderer_test.go diff --git a/go.mod b/go.mod index 8757c68475..c8af0f5489 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( cosmossdk.io/core v0.0.0 cosmossdk.io/depinject v1.0.0-alpha.4 cosmossdk.io/errors v1.0.0-beta.7 - cosmossdk.io/math v1.0.0-beta.2 + cosmossdk.io/math v1.0.0-beta.3 github.com/99designs/keyring v1.2.1 github.com/armon/go-metrics v0.4.0 github.com/bgentry/speakeasy v0.1.0 diff --git a/tx/go.mod b/tx/go.mod new file mode 100644 index 0000000000..2218f368c3 --- /dev/null +++ b/tx/go.mod @@ -0,0 +1,18 @@ +module cosmossdk.io/tx + +go 1.18 + +require ( + cosmossdk.io/api v0.1.0-alpha8 + cosmossdk.io/math v1.0.0-beta.3 + github.com/cosmos/cosmos-proto v1.0.0-alpha7 + github.com/stretchr/testify v1.8.0 + google.golang.org/protobuf v1.28.0 +) + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/tx/go.sum b/tx/go.sum new file mode 100644 index 0000000000..12080601f1 --- /dev/null +++ b/tx/go.sum @@ -0,0 +1,65 @@ +cosmossdk.io/api v0.1.0-alpha8 h1:Hr+8bLI4UphF+aMiDIVklrdzRm99dFaNq2inBKGDzNU= +cosmossdk.io/api v0.1.0-alpha8/go.mod h1:gIs3NW5OSNK5wKqxF8JHnGTL82QMsXpwGeKmu2i5xFA= +cosmossdk.io/math v1.0.0-beta.3 h1:TbZxSopz2LqjJ7aXYfn7nJSb8vNaBklW6BLpcei1qwM= +cosmossdk.io/math v1.0.0-beta.3/go.mod h1:3LYasri3Zna4XpbrTNdKsWmD5fHHkaNAod/mNT9XdE4= +github.com/cosmos/cosmos-proto v1.0.0-alpha7 h1:yqYUOHF2jopwZh4dVQp3xgqwftE5/2hkrwIV6vkUbO0= +github.com/cosmos/cosmos-proto v1.0.0-alpha7/go.mod h1:dosO4pSAbJF8zWCzCoTWP7nNsjcvSUBQmniFxDg5daw= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +pgregory.net/rapid v0.4.7/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU= +sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= diff --git a/tx/textual/internal/testdata/README.md b/tx/textual/internal/testdata/README.md new file mode 100644 index 0000000000..b7af90f778 --- /dev/null +++ b/tx/textual/internal/testdata/README.md @@ -0,0 +1,3 @@ +# Testdata + +This folder contains test vectors shared between [CosmJS](https://github.com/cosmos/cosmjs/pull/1147) and the Cosmos SDK. \ No newline at end of file diff --git a/tx/textual/internal/testdata/decimals.json b/tx/textual/internal/testdata/decimals.json new file mode 100644 index 0000000000..8893fef9e2 --- /dev/null +++ b/tx/textual/internal/testdata/decimals.json @@ -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"] +] diff --git a/tx/textual/internal/testdata/integers.json b/tx/textual/internal/testdata/integers.json new file mode 100644 index 0000000000..0faa4f5fea --- /dev/null +++ b/tx/textual/internal/testdata/integers.json @@ -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"] +] diff --git a/tx/textual/internal/testpb/1.proto b/tx/textual/internal/testpb/1.proto new file mode 100644 index 0000000000..fc7106dac9 --- /dev/null +++ b/tx/textual/internal/testpb/1.proto @@ -0,0 +1,40 @@ +syntax="proto3"; + +option go_package = "cosmossdk.io/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 MAP = 11; +} diff --git a/tx/textual/internal/testpb/1.pulsar.go b/tx/textual/internal/testpb/1.pulsar.go new file mode 100644 index 0000000000..78ad4b16aa --- /dev/null +++ b/tx/textual/internal/testpb/1.pulsar.go @@ -0,0 +1,2441 @@ +// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. +package testpb + +import ( + v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" + binary "encoding/binary" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + runtime "github.com/cosmos/cosmos-proto/runtime" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoiface "google.golang.org/protobuf/runtime/protoiface" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + _ "google.golang.org/protobuf/types/descriptorpb" + io "io" + math "math" + reflect "reflect" + sort "sort" + sync "sync" +) + +var _ protoreflect.List = (*_A_8_list)(nil) + +type _A_8_list struct { + list *[]*v1beta1.Coin +} + +func (x *_A_8_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_A_8_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) +} + +func (x *_A_8_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*v1beta1.Coin) + (*x.list)[i] = concreteValue +} + +func (x *_A_8_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*v1beta1.Coin) + *x.list = append(*x.list, concreteValue) +} + +func (x *_A_8_list) AppendMutable() protoreflect.Value { + v := new(v1beta1.Coin) + *x.list = append(*x.list, v) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_A_8_list) Truncate(n int) { + for i := n; i < len(*x.list); i++ { + (*x.list)[i] = nil + } + *x.list = (*x.list)[:n] +} + +func (x *_A_8_list) NewElement() protoreflect.Value { + v := new(v1beta1.Coin) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_A_8_list) IsValid() bool { + return x.list != nil +} + +var ( + md_A protoreflect.MessageDescriptor + fd_A_UINT32 protoreflect.FieldDescriptor + fd_A_UINT64 protoreflect.FieldDescriptor + fd_A_INT32 protoreflect.FieldDescriptor + fd_A_INT64 protoreflect.FieldDescriptor + fd_A_SDKINT protoreflect.FieldDescriptor + fd_A_SDKDEC protoreflect.FieldDescriptor + fd_A_COIN protoreflect.FieldDescriptor + fd_A_COINS protoreflect.FieldDescriptor +) + +func init() { + file__1_proto_init() + md_A = File__1_proto.Messages().ByName("A") + fd_A_UINT32 = md_A.Fields().ByName("UINT32") + fd_A_UINT64 = md_A.Fields().ByName("UINT64") + fd_A_INT32 = md_A.Fields().ByName("INT32") + fd_A_INT64 = md_A.Fields().ByName("INT64") + fd_A_SDKINT = md_A.Fields().ByName("SDKINT") + fd_A_SDKDEC = md_A.Fields().ByName("SDKDEC") + fd_A_COIN = md_A.Fields().ByName("COIN") + fd_A_COINS = md_A.Fields().ByName("COINS") +} + +var _ protoreflect.Message = (*fastReflection_A)(nil) + +type fastReflection_A A + +func (x *A) ProtoReflect() protoreflect.Message { + return (*fastReflection_A)(x) +} + +func (x *A) slowProtoReflect() protoreflect.Message { + mi := &file__1_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_A_messageType fastReflection_A_messageType +var _ protoreflect.MessageType = fastReflection_A_messageType{} + +type fastReflection_A_messageType struct{} + +func (x fastReflection_A_messageType) Zero() protoreflect.Message { + return (*fastReflection_A)(nil) +} +func (x fastReflection_A_messageType) New() protoreflect.Message { + return new(fastReflection_A) +} +func (x fastReflection_A_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_A +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_A) Descriptor() protoreflect.MessageDescriptor { + return md_A +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_A) Type() protoreflect.MessageType { + return _fastReflection_A_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_A) New() protoreflect.Message { + return new(fastReflection_A) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_A) Interface() protoreflect.ProtoMessage { + return (*A)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_A) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.UINT32 != uint32(0) { + value := protoreflect.ValueOfUint32(x.UINT32) + if !f(fd_A_UINT32, value) { + return + } + } + if x.UINT64 != uint64(0) { + value := protoreflect.ValueOfUint64(x.UINT64) + if !f(fd_A_UINT64, value) { + return + } + } + if x.INT32 != int32(0) { + value := protoreflect.ValueOfInt32(x.INT32) + if !f(fd_A_INT32, value) { + return + } + } + if x.INT64 != int64(0) { + value := protoreflect.ValueOfInt64(x.INT64) + if !f(fd_A_INT64, value) { + return + } + } + if x.SDKINT != "" { + value := protoreflect.ValueOfString(x.SDKINT) + if !f(fd_A_SDKINT, value) { + return + } + } + if x.SDKDEC != "" { + value := protoreflect.ValueOfString(x.SDKDEC) + if !f(fd_A_SDKDEC, value) { + return + } + } + if x.COIN != nil { + value := protoreflect.ValueOfMessage(x.COIN.ProtoReflect()) + if !f(fd_A_COIN, value) { + return + } + } + if len(x.COINS) != 0 { + value := protoreflect.ValueOfList(&_A_8_list{list: &x.COINS}) + if !f(fd_A_COINS, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_A) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "A.UINT32": + return x.UINT32 != uint32(0) + case "A.UINT64": + return x.UINT64 != uint64(0) + case "A.INT32": + return x.INT32 != int32(0) + case "A.INT64": + return x.INT64 != int64(0) + case "A.SDKINT": + return x.SDKINT != "" + case "A.SDKDEC": + return x.SDKDEC != "" + case "A.COIN": + return x.COIN != nil + case "A.COINS": + return len(x.COINS) != 0 + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: A")) + } + panic(fmt.Errorf("message A does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_A) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "A.UINT32": + x.UINT32 = uint32(0) + case "A.UINT64": + x.UINT64 = uint64(0) + case "A.INT32": + x.INT32 = int32(0) + case "A.INT64": + x.INT64 = int64(0) + case "A.SDKINT": + x.SDKINT = "" + case "A.SDKDEC": + x.SDKDEC = "" + case "A.COIN": + x.COIN = nil + case "A.COINS": + x.COINS = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: A")) + } + panic(fmt.Errorf("message A does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_A) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "A.UINT32": + value := x.UINT32 + return protoreflect.ValueOfUint32(value) + case "A.UINT64": + value := x.UINT64 + return protoreflect.ValueOfUint64(value) + case "A.INT32": + value := x.INT32 + return protoreflect.ValueOfInt32(value) + case "A.INT64": + value := x.INT64 + return protoreflect.ValueOfInt64(value) + case "A.SDKINT": + value := x.SDKINT + return protoreflect.ValueOfString(value) + case "A.SDKDEC": + value := x.SDKDEC + return protoreflect.ValueOfString(value) + case "A.COIN": + value := x.COIN + return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "A.COINS": + if len(x.COINS) == 0 { + return protoreflect.ValueOfList(&_A_8_list{}) + } + listValue := &_A_8_list{list: &x.COINS} + return protoreflect.ValueOfList(listValue) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: A")) + } + panic(fmt.Errorf("message A does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_A) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "A.UINT32": + x.UINT32 = uint32(value.Uint()) + case "A.UINT64": + x.UINT64 = value.Uint() + case "A.INT32": + x.INT32 = int32(value.Int()) + case "A.INT64": + x.INT64 = value.Int() + case "A.SDKINT": + x.SDKINT = value.Interface().(string) + case "A.SDKDEC": + x.SDKDEC = value.Interface().(string) + case "A.COIN": + x.COIN = value.Message().Interface().(*v1beta1.Coin) + case "A.COINS": + lv := value.List() + clv := lv.(*_A_8_list) + x.COINS = *clv.list + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: A")) + } + panic(fmt.Errorf("message A does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_A) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "A.COIN": + if x.COIN == nil { + x.COIN = new(v1beta1.Coin) + } + return protoreflect.ValueOfMessage(x.COIN.ProtoReflect()) + case "A.COINS": + if x.COINS == nil { + x.COINS = []*v1beta1.Coin{} + } + value := &_A_8_list{list: &x.COINS} + return protoreflect.ValueOfList(value) + case "A.UINT32": + panic(fmt.Errorf("field UINT32 of message A is not mutable")) + case "A.UINT64": + panic(fmt.Errorf("field UINT64 of message A is not mutable")) + case "A.INT32": + panic(fmt.Errorf("field INT32 of message A is not mutable")) + case "A.INT64": + panic(fmt.Errorf("field INT64 of message A is not mutable")) + case "A.SDKINT": + panic(fmt.Errorf("field SDKINT of message A is not mutable")) + case "A.SDKDEC": + panic(fmt.Errorf("field SDKDEC of message A is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: A")) + } + panic(fmt.Errorf("message A does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_A) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "A.UINT32": + return protoreflect.ValueOfUint32(uint32(0)) + case "A.UINT64": + return protoreflect.ValueOfUint64(uint64(0)) + case "A.INT32": + return protoreflect.ValueOfInt32(int32(0)) + case "A.INT64": + return protoreflect.ValueOfInt64(int64(0)) + case "A.SDKINT": + return protoreflect.ValueOfString("") + case "A.SDKDEC": + return protoreflect.ValueOfString("") + case "A.COIN": + m := new(v1beta1.Coin) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "A.COINS": + list := []*v1beta1.Coin{} + return protoreflect.ValueOfList(&_A_8_list{list: &list}) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: A")) + } + panic(fmt.Errorf("message A does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_A) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in A", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_A) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_A) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_A) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_A) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*A) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if x.UINT32 != 0 { + n += 1 + runtime.Sov(uint64(x.UINT32)) + } + if x.UINT64 != 0 { + n += 1 + runtime.Sov(uint64(x.UINT64)) + } + if x.INT32 != 0 { + n += 1 + runtime.Sov(uint64(x.INT32)) + } + if x.INT64 != 0 { + n += 1 + runtime.Sov(uint64(x.INT64)) + } + l = len(x.SDKINT) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.SDKDEC) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.COIN != nil { + l = options.Size(x.COIN) + n += 1 + l + runtime.Sov(uint64(l)) + } + if len(x.COINS) > 0 { + for _, e := range x.COINS { + l = options.Size(e) + n += 1 + l + runtime.Sov(uint64(l)) + } + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*A) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if len(x.COINS) > 0 { + for iNdEx := len(x.COINS) - 1; iNdEx >= 0; iNdEx-- { + encoded, err := options.Marshal(x.COINS[iNdEx]) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x42 + } + } + if x.COIN != nil { + encoded, err := options.Marshal(x.COIN) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x3a + } + if len(x.SDKDEC) > 0 { + i -= len(x.SDKDEC) + copy(dAtA[i:], x.SDKDEC) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.SDKDEC))) + i-- + dAtA[i] = 0x32 + } + if len(x.SDKINT) > 0 { + i -= len(x.SDKINT) + copy(dAtA[i:], x.SDKINT) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.SDKINT))) + i-- + dAtA[i] = 0x2a + } + if x.INT64 != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.INT64)) + i-- + dAtA[i] = 0x20 + } + if x.INT32 != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.INT32)) + i-- + dAtA[i] = 0x18 + } + if x.UINT64 != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.UINT64)) + i-- + dAtA[i] = 0x10 + } + if x.UINT32 != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.UINT32)) + i-- + dAtA[i] = 0x8 + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*A) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: A: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: A: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field UINT32", wireType) + } + x.UINT32 = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.UINT32 |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field UINT64", wireType) + } + x.UINT64 = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.UINT64 |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field INT32", wireType) + } + x.INT32 = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.INT32 |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field INT64", wireType) + } + x.INT64 = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.INT64 |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field SDKINT", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.SDKINT = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field SDKDEC", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.SDKDEC = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field COIN", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if x.COIN == nil { + x.COIN = &v1beta1.Coin{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.COIN); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field COINS", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.COINS = append(x.COINS, &v1beta1.Coin{}) + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.COINS[len(x.COINS)-1]); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var _ protoreflect.Map = (*_B_11_map)(nil) + +type _B_11_map struct { + m *map[string]*B +} + +func (x *_B_11_map) Len() int { + if x.m == nil { + return 0 + } + return len(*x.m) +} + +func (x *_B_11_map) Range(f func(protoreflect.MapKey, protoreflect.Value) bool) { + if x.m == nil { + return + } + for k, v := range *x.m { + mapKey := (protoreflect.MapKey)(protoreflect.ValueOfString(k)) + mapValue := protoreflect.ValueOfMessage(v.ProtoReflect()) + if !f(mapKey, mapValue) { + break + } + } +} + +func (x *_B_11_map) Has(key protoreflect.MapKey) bool { + if x.m == nil { + return false + } + keyUnwrapped := key.String() + concreteValue := keyUnwrapped + _, ok := (*x.m)[concreteValue] + return ok +} + +func (x *_B_11_map) Clear(key protoreflect.MapKey) { + if x.m == nil { + return + } + keyUnwrapped := key.String() + concreteKey := keyUnwrapped + delete(*x.m, concreteKey) +} + +func (x *_B_11_map) Get(key protoreflect.MapKey) protoreflect.Value { + if x.m == nil { + return protoreflect.Value{} + } + keyUnwrapped := key.String() + concreteKey := keyUnwrapped + v, ok := (*x.m)[concreteKey] + if !ok { + return protoreflect.Value{} + } + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_B_11_map) Set(key protoreflect.MapKey, value protoreflect.Value) { + if !key.IsValid() || !value.IsValid() { + panic("invalid key or value provided") + } + keyUnwrapped := key.String() + concreteKey := keyUnwrapped + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*B) + (*x.m)[concreteKey] = concreteValue +} + +func (x *_B_11_map) Mutable(key protoreflect.MapKey) protoreflect.Value { + keyUnwrapped := key.String() + concreteKey := keyUnwrapped + v, ok := (*x.m)[concreteKey] + if ok { + return protoreflect.ValueOfMessage(v.ProtoReflect()) + } + newValue := new(B) + (*x.m)[concreteKey] = newValue + return protoreflect.ValueOfMessage(newValue.ProtoReflect()) +} + +func (x *_B_11_map) NewValue() protoreflect.Value { + v := new(B) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_B_11_map) IsValid() bool { + return x.m != nil +} + +var ( + md_B protoreflect.MessageDescriptor + fd_B_INT32 protoreflect.FieldDescriptor + fd_B_SINT32 protoreflect.FieldDescriptor + fd_B_INT64 protoreflect.FieldDescriptor + fd_B_SING64 protoreflect.FieldDescriptor + fd_B_SFIXED32 protoreflect.FieldDescriptor + fd_B_FIXED32 protoreflect.FieldDescriptor + fd_B_FLOAT protoreflect.FieldDescriptor + fd_B_SFIXED64 protoreflect.FieldDescriptor + fd_B_FIXED64 protoreflect.FieldDescriptor + fd_B_DOUBLE protoreflect.FieldDescriptor + fd_B_MAP protoreflect.FieldDescriptor +) + +func init() { + file__1_proto_init() + md_B = File__1_proto.Messages().ByName("B") + fd_B_INT32 = md_B.Fields().ByName("INT32") + fd_B_SINT32 = md_B.Fields().ByName("SINT32") + fd_B_INT64 = md_B.Fields().ByName("INT64") + fd_B_SING64 = md_B.Fields().ByName("SING64") + fd_B_SFIXED32 = md_B.Fields().ByName("SFIXED32") + fd_B_FIXED32 = md_B.Fields().ByName("FIXED32") + fd_B_FLOAT = md_B.Fields().ByName("FLOAT") + fd_B_SFIXED64 = md_B.Fields().ByName("SFIXED64") + fd_B_FIXED64 = md_B.Fields().ByName("FIXED64") + fd_B_DOUBLE = md_B.Fields().ByName("DOUBLE") + fd_B_MAP = md_B.Fields().ByName("MAP") +} + +var _ protoreflect.Message = (*fastReflection_B)(nil) + +type fastReflection_B B + +func (x *B) ProtoReflect() protoreflect.Message { + return (*fastReflection_B)(x) +} + +func (x *B) slowProtoReflect() protoreflect.Message { + mi := &file__1_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_B_messageType fastReflection_B_messageType +var _ protoreflect.MessageType = fastReflection_B_messageType{} + +type fastReflection_B_messageType struct{} + +func (x fastReflection_B_messageType) Zero() protoreflect.Message { + return (*fastReflection_B)(nil) +} +func (x fastReflection_B_messageType) New() protoreflect.Message { + return new(fastReflection_B) +} +func (x fastReflection_B_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_B +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_B) Descriptor() protoreflect.MessageDescriptor { + return md_B +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_B) Type() protoreflect.MessageType { + return _fastReflection_B_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_B) New() protoreflect.Message { + return new(fastReflection_B) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_B) Interface() protoreflect.ProtoMessage { + return (*B)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_B) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.INT32 != int32(0) { + value := protoreflect.ValueOfInt32(x.INT32) + if !f(fd_B_INT32, value) { + return + } + } + if x.SINT32 != int32(0) { + value := protoreflect.ValueOfInt32(x.SINT32) + if !f(fd_B_SINT32, value) { + return + } + } + if x.INT64 != int64(0) { + value := protoreflect.ValueOfInt64(x.INT64) + if !f(fd_B_INT64, value) { + return + } + } + if x.SING64 != int64(0) { + value := protoreflect.ValueOfInt64(x.SING64) + if !f(fd_B_SING64, value) { + return + } + } + if x.SFIXED32 != int32(0) { + value := protoreflect.ValueOfInt32(x.SFIXED32) + if !f(fd_B_SFIXED32, value) { + return + } + } + if x.FIXED32 != uint32(0) { + value := protoreflect.ValueOfUint32(x.FIXED32) + if !f(fd_B_FIXED32, value) { + return + } + } + if x.FLOAT != float32(0) || math.Signbit(float64(x.FLOAT)) { + value := protoreflect.ValueOfFloat32(x.FLOAT) + if !f(fd_B_FLOAT, value) { + return + } + } + if x.SFIXED64 != int64(0) { + value := protoreflect.ValueOfInt64(x.SFIXED64) + if !f(fd_B_SFIXED64, value) { + return + } + } + if x.FIXED64 != uint64(0) { + value := protoreflect.ValueOfUint64(x.FIXED64) + if !f(fd_B_FIXED64, value) { + return + } + } + if x.DOUBLE != float64(0) || math.Signbit(x.DOUBLE) { + value := protoreflect.ValueOfFloat64(x.DOUBLE) + if !f(fd_B_DOUBLE, value) { + return + } + } + if len(x.MAP) != 0 { + value := protoreflect.ValueOfMap(&_B_11_map{m: &x.MAP}) + if !f(fd_B_MAP, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_B) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "B.INT32": + return x.INT32 != int32(0) + case "B.SINT32": + return x.SINT32 != int32(0) + case "B.INT64": + return x.INT64 != int64(0) + case "B.SING64": + return x.SING64 != int64(0) + case "B.SFIXED32": + return x.SFIXED32 != int32(0) + case "B.FIXED32": + return x.FIXED32 != uint32(0) + case "B.FLOAT": + return x.FLOAT != float32(0) || math.Signbit(float64(x.FLOAT)) + case "B.SFIXED64": + return x.SFIXED64 != int64(0) + case "B.FIXED64": + return x.FIXED64 != uint64(0) + case "B.DOUBLE": + return x.DOUBLE != float64(0) || math.Signbit(x.DOUBLE) + case "B.MAP": + return len(x.MAP) != 0 + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: B")) + } + panic(fmt.Errorf("message B does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_B) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "B.INT32": + x.INT32 = int32(0) + case "B.SINT32": + x.SINT32 = int32(0) + case "B.INT64": + x.INT64 = int64(0) + case "B.SING64": + x.SING64 = int64(0) + case "B.SFIXED32": + x.SFIXED32 = int32(0) + case "B.FIXED32": + x.FIXED32 = uint32(0) + case "B.FLOAT": + x.FLOAT = float32(0) + case "B.SFIXED64": + x.SFIXED64 = int64(0) + case "B.FIXED64": + x.FIXED64 = uint64(0) + case "B.DOUBLE": + x.DOUBLE = float64(0) + case "B.MAP": + x.MAP = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: B")) + } + panic(fmt.Errorf("message B does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_B) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "B.INT32": + value := x.INT32 + return protoreflect.ValueOfInt32(value) + case "B.SINT32": + value := x.SINT32 + return protoreflect.ValueOfInt32(value) + case "B.INT64": + value := x.INT64 + return protoreflect.ValueOfInt64(value) + case "B.SING64": + value := x.SING64 + return protoreflect.ValueOfInt64(value) + case "B.SFIXED32": + value := x.SFIXED32 + return protoreflect.ValueOfInt32(value) + case "B.FIXED32": + value := x.FIXED32 + return protoreflect.ValueOfUint32(value) + case "B.FLOAT": + value := x.FLOAT + return protoreflect.ValueOfFloat32(value) + case "B.SFIXED64": + value := x.SFIXED64 + return protoreflect.ValueOfInt64(value) + case "B.FIXED64": + value := x.FIXED64 + return protoreflect.ValueOfUint64(value) + case "B.DOUBLE": + value := x.DOUBLE + return protoreflect.ValueOfFloat64(value) + case "B.MAP": + if len(x.MAP) == 0 { + return protoreflect.ValueOfMap(&_B_11_map{}) + } + mapValue := &_B_11_map{m: &x.MAP} + return protoreflect.ValueOfMap(mapValue) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: B")) + } + panic(fmt.Errorf("message B does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_B) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "B.INT32": + x.INT32 = int32(value.Int()) + case "B.SINT32": + x.SINT32 = int32(value.Int()) + case "B.INT64": + x.INT64 = value.Int() + case "B.SING64": + x.SING64 = value.Int() + case "B.SFIXED32": + x.SFIXED32 = int32(value.Int()) + case "B.FIXED32": + x.FIXED32 = uint32(value.Uint()) + case "B.FLOAT": + x.FLOAT = float32(value.Float()) + case "B.SFIXED64": + x.SFIXED64 = value.Int() + case "B.FIXED64": + x.FIXED64 = value.Uint() + case "B.DOUBLE": + x.DOUBLE = value.Float() + case "B.MAP": + mv := value.Map() + cmv := mv.(*_B_11_map) + x.MAP = *cmv.m + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: B")) + } + panic(fmt.Errorf("message B does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_B) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "B.MAP": + if x.MAP == nil { + x.MAP = make(map[string]*B) + } + value := &_B_11_map{m: &x.MAP} + return protoreflect.ValueOfMap(value) + case "B.INT32": + panic(fmt.Errorf("field INT32 of message B is not mutable")) + case "B.SINT32": + panic(fmt.Errorf("field SINT32 of message B is not mutable")) + case "B.INT64": + panic(fmt.Errorf("field INT64 of message B is not mutable")) + case "B.SING64": + panic(fmt.Errorf("field SING64 of message B is not mutable")) + case "B.SFIXED32": + panic(fmt.Errorf("field SFIXED32 of message B is not mutable")) + case "B.FIXED32": + panic(fmt.Errorf("field FIXED32 of message B is not mutable")) + case "B.FLOAT": + panic(fmt.Errorf("field FLOAT of message B is not mutable")) + case "B.SFIXED64": + panic(fmt.Errorf("field SFIXED64 of message B is not mutable")) + case "B.FIXED64": + panic(fmt.Errorf("field FIXED64 of message B is not mutable")) + case "B.DOUBLE": + panic(fmt.Errorf("field DOUBLE of message B is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: B")) + } + panic(fmt.Errorf("message B does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_B) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "B.INT32": + return protoreflect.ValueOfInt32(int32(0)) + case "B.SINT32": + return protoreflect.ValueOfInt32(int32(0)) + case "B.INT64": + return protoreflect.ValueOfInt64(int64(0)) + case "B.SING64": + return protoreflect.ValueOfInt64(int64(0)) + case "B.SFIXED32": + return protoreflect.ValueOfInt32(int32(0)) + case "B.FIXED32": + return protoreflect.ValueOfUint32(uint32(0)) + case "B.FLOAT": + return protoreflect.ValueOfFloat32(float32(0)) + case "B.SFIXED64": + return protoreflect.ValueOfInt64(int64(0)) + case "B.FIXED64": + return protoreflect.ValueOfUint64(uint64(0)) + case "B.DOUBLE": + return protoreflect.ValueOfFloat64(float64(0)) + case "B.MAP": + m := make(map[string]*B) + return protoreflect.ValueOfMap(&_B_11_map{m: &m}) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: B")) + } + panic(fmt.Errorf("message B does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_B) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in B", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_B) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_B) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_B) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_B) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*B) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if x.INT32 != 0 { + n += 1 + runtime.Sov(uint64(x.INT32)) + } + if x.SINT32 != 0 { + n += 1 + runtime.Soz(uint64(x.SINT32)) + } + if x.INT64 != 0 { + n += 1 + runtime.Sov(uint64(x.INT64)) + } + if x.SING64 != 0 { + n += 1 + runtime.Soz(uint64(x.SING64)) + } + if x.SFIXED32 != 0 { + n += 5 + } + if x.FIXED32 != 0 { + n += 5 + } + if x.FLOAT != 0 || math.Signbit(float64(x.FLOAT)) { + n += 5 + } + if x.SFIXED64 != 0 { + n += 9 + } + if x.FIXED64 != 0 { + n += 9 + } + if x.DOUBLE != 0 || math.Signbit(x.DOUBLE) { + n += 9 + } + if len(x.MAP) > 0 { + SiZeMaP := func(k string, v *B) { + l := 0 + if v != nil { + l = options.Size(v) + } + l += 1 + runtime.Sov(uint64(l)) + mapEntrySize := 1 + len(k) + runtime.Sov(uint64(len(k))) + l + n += mapEntrySize + 1 + runtime.Sov(uint64(mapEntrySize)) + } + if options.Deterministic { + sortme := make([]string, 0, len(x.MAP)) + for k := range x.MAP { + sortme = append(sortme, k) + } + sort.Strings(sortme) + for _, k := range sortme { + v := x.MAP[k] + SiZeMaP(k, v) + } + } else { + for k, v := range x.MAP { + SiZeMaP(k, v) + } + } + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*B) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if len(x.MAP) > 0 { + MaRsHaLmAp := func(k string, v *B) (protoiface.MarshalOutput, error) { + baseI := i + encoded, err := options.Marshal(v) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x12 + i -= len(k) + copy(dAtA[i:], k) + i = runtime.EncodeVarint(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = runtime.EncodeVarint(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x5a + return protoiface.MarshalOutput{}, nil + } + if options.Deterministic { + keysForMAP := make([]string, 0, len(x.MAP)) + for k := range x.MAP { + keysForMAP = append(keysForMAP, string(k)) + } + sort.Slice(keysForMAP, func(i, j int) bool { + return keysForMAP[i] < keysForMAP[j] + }) + for iNdEx := len(keysForMAP) - 1; iNdEx >= 0; iNdEx-- { + v := x.MAP[string(keysForMAP[iNdEx])] + out, err := MaRsHaLmAp(keysForMAP[iNdEx], v) + if err != nil { + return out, err + } + } + } else { + for k := range x.MAP { + v := x.MAP[k] + out, err := MaRsHaLmAp(k, v) + if err != nil { + return out, err + } + } + } + } + if x.DOUBLE != 0 || math.Signbit(x.DOUBLE) { + i -= 8 + binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(x.DOUBLE)))) + i-- + dAtA[i] = 0x51 + } + if x.FIXED64 != 0 { + i -= 8 + binary.LittleEndian.PutUint64(dAtA[i:], uint64(x.FIXED64)) + i-- + dAtA[i] = 0x49 + } + if x.SFIXED64 != 0 { + i -= 8 + binary.LittleEndian.PutUint64(dAtA[i:], uint64(x.SFIXED64)) + i-- + dAtA[i] = 0x41 + } + if x.FLOAT != 0 || math.Signbit(float64(x.FLOAT)) { + i -= 4 + binary.LittleEndian.PutUint32(dAtA[i:], uint32(math.Float32bits(float32(x.FLOAT)))) + i-- + dAtA[i] = 0x3d + } + if x.FIXED32 != 0 { + i -= 4 + binary.LittleEndian.PutUint32(dAtA[i:], uint32(x.FIXED32)) + i-- + dAtA[i] = 0x35 + } + if x.SFIXED32 != 0 { + i -= 4 + binary.LittleEndian.PutUint32(dAtA[i:], uint32(x.SFIXED32)) + i-- + dAtA[i] = 0x2d + } + if x.SING64 != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64((uint64(x.SING64)<<1)^uint64((x.SING64>>63)))) + i-- + dAtA[i] = 0x20 + } + if x.INT64 != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.INT64)) + i-- + dAtA[i] = 0x18 + } + if x.SINT32 != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64((uint32(x.SINT32)<<1)^uint32((x.SINT32>>31)))) + i-- + dAtA[i] = 0x10 + } + if x.INT32 != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.INT32)) + i-- + dAtA[i] = 0x8 + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*B) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: B: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: B: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field INT32", wireType) + } + x.INT32 = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.INT32 |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field SINT32", wireType) + } + var v int32 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + v = int32((uint32(v) >> 1) ^ uint32(((v&1)<<31)>>31)) + x.SINT32 = v + case 3: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field INT64", wireType) + } + x.INT64 = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.INT64 |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field SING64", wireType) + } + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + v = (v >> 1) ^ uint64((int64(v&1)<<63)>>63) + x.SING64 = int64(v) + case 5: + if wireType != 5 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field SFIXED32", wireType) + } + x.SFIXED32 = 0 + if (iNdEx + 4) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.SFIXED32 = int32(binary.LittleEndian.Uint32(dAtA[iNdEx:])) + iNdEx += 4 + case 6: + if wireType != 5 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field FIXED32", wireType) + } + x.FIXED32 = 0 + if (iNdEx + 4) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.FIXED32 = uint32(binary.LittleEndian.Uint32(dAtA[iNdEx:])) + iNdEx += 4 + case 7: + if wireType != 5 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field FLOAT", wireType) + } + var v uint32 + if (iNdEx + 4) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + v = uint32(binary.LittleEndian.Uint32(dAtA[iNdEx:])) + iNdEx += 4 + x.FLOAT = float32(math.Float32frombits(v)) + case 8: + if wireType != 1 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field SFIXED64", wireType) + } + x.SFIXED64 = 0 + if (iNdEx + 8) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.SFIXED64 = int64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + case 9: + if wireType != 1 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field FIXED64", wireType) + } + x.FIXED64 = 0 + if (iNdEx + 8) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.FIXED64 = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + case 10: + if wireType != 1 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field DOUBLE", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + x.DOUBLE = float64(math.Float64frombits(v)) + case 11: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field MAP", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if x.MAP == nil { + x.MAP = make(map[string]*B) + } + var mapkey string + var mapvalue *B + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postStringIndexmapkey > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postmsgIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + mapvalue = &B{} + if err := options.Unmarshal(dAtA[iNdEx:postmsgIndex], mapvalue); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > postIndex { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + x.MAP[mapkey] = mapvalue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.27.0 +// protoc (unknown) +// source: 1.proto + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Enumeration int32 + +const ( + Enumeration_One Enumeration = 0 + Enumeration_Two Enumeration = 1 +) + +// Enum value maps for Enumeration. +var ( + Enumeration_name = map[int32]string{ + 0: "One", + 1: "Two", + } + Enumeration_value = map[string]int32{ + "One": 0, + "Two": 1, + } +) + +func (x Enumeration) Enum() *Enumeration { + p := new(Enumeration) + *p = x + return p +} + +func (x Enumeration) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Enumeration) Descriptor() protoreflect.EnumDescriptor { + return file__1_proto_enumTypes[0].Descriptor() +} + +func (Enumeration) Type() protoreflect.EnumType { + return &file__1_proto_enumTypes[0] +} + +func (x Enumeration) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Enumeration.Descriptor instead. +func (Enumeration) EnumDescriptor() ([]byte, []int) { + return file__1_proto_rawDescGZIP(), []int{0} +} + +// A contains fields that are parseable by SIGN_MODE_TEXTUAL. +type A struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UINT32 uint32 `protobuf:"varint,1,opt,name=UINT32,proto3" json:"UINT32,omitempty"` + UINT64 uint64 `protobuf:"varint,2,opt,name=UINT64,proto3" json:"UINT64,omitempty"` + INT32 int32 `protobuf:"varint,3,opt,name=INT32,proto3" json:"INT32,omitempty"` + INT64 int64 `protobuf:"varint,4,opt,name=INT64,proto3" json:"INT64,omitempty"` + SDKINT string `protobuf:"bytes,5,opt,name=SDKINT,proto3" json:"SDKINT,omitempty"` + SDKDEC string `protobuf:"bytes,6,opt,name=SDKDEC,proto3" json:"SDKDEC,omitempty"` + COIN *v1beta1.Coin `protobuf:"bytes,7,opt,name=COIN,proto3" json:"COIN,omitempty"` + COINS []*v1beta1.Coin `protobuf:"bytes,8,rep,name=COINS,proto3" json:"COINS,omitempty"` +} + +func (x *A) Reset() { + *x = A{} + if protoimpl.UnsafeEnabled { + mi := &file__1_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *A) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*A) ProtoMessage() {} + +// Deprecated: Use A.ProtoReflect.Descriptor instead. +func (*A) Descriptor() ([]byte, []int) { + return file__1_proto_rawDescGZIP(), []int{0} +} + +func (x *A) GetUINT32() uint32 { + if x != nil { + return x.UINT32 + } + return 0 +} + +func (x *A) GetUINT64() uint64 { + if x != nil { + return x.UINT64 + } + return 0 +} + +func (x *A) GetINT32() int32 { + if x != nil { + return x.INT32 + } + return 0 +} + +func (x *A) GetINT64() int64 { + if x != nil { + return x.INT64 + } + return 0 +} + +func (x *A) GetSDKINT() string { + if x != nil { + return x.SDKINT + } + return "" +} + +func (x *A) GetSDKDEC() string { + if x != nil { + return x.SDKDEC + } + return "" +} + +func (x *A) GetCOIN() *v1beta1.Coin { + if x != nil { + return x.COIN + } + return nil +} + +func (x *A) GetCOINS() []*v1beta1.Coin { + if x != nil { + return x.COINS + } + return nil +} + +// B contains fields that are not parseable by SIGN_MODE_TEXTUAL, some fields +// may be moved to A at some point. +type B struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + INT32 int32 `protobuf:"varint,1,opt,name=INT32,proto3" json:"INT32,omitempty"` + SINT32 int32 `protobuf:"zigzag32,2,opt,name=SINT32,proto3" json:"SINT32,omitempty"` + INT64 int64 `protobuf:"varint,3,opt,name=INT64,proto3" json:"INT64,omitempty"` + SING64 int64 `protobuf:"zigzag64,4,opt,name=SING64,proto3" json:"SING64,omitempty"` + SFIXED32 int32 `protobuf:"fixed32,5,opt,name=SFIXED32,proto3" json:"SFIXED32,omitempty"` + FIXED32 uint32 `protobuf:"fixed32,6,opt,name=FIXED32,proto3" json:"FIXED32,omitempty"` + FLOAT float32 `protobuf:"fixed32,7,opt,name=FLOAT,proto3" json:"FLOAT,omitempty"` + SFIXED64 int64 `protobuf:"fixed64,8,opt,name=SFIXED64,proto3" json:"SFIXED64,omitempty"` + FIXED64 uint64 `protobuf:"fixed64,9,opt,name=FIXED64,proto3" json:"FIXED64,omitempty"` + DOUBLE float64 `protobuf:"fixed64,10,opt,name=DOUBLE,proto3" json:"DOUBLE,omitempty"` + MAP map[string]*B `protobuf:"bytes,11,rep,name=MAP,proto3" json:"MAP,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *B) Reset() { + *x = B{} + if protoimpl.UnsafeEnabled { + mi := &file__1_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *B) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*B) ProtoMessage() {} + +// Deprecated: Use B.ProtoReflect.Descriptor instead. +func (*B) Descriptor() ([]byte, []int) { + return file__1_proto_rawDescGZIP(), []int{1} +} + +func (x *B) GetINT32() int32 { + if x != nil { + return x.INT32 + } + return 0 +} + +func (x *B) GetSINT32() int32 { + if x != nil { + return x.SINT32 + } + return 0 +} + +func (x *B) GetINT64() int64 { + if x != nil { + return x.INT64 + } + return 0 +} + +func (x *B) GetSING64() int64 { + if x != nil { + return x.SING64 + } + return 0 +} + +func (x *B) GetSFIXED32() int32 { + if x != nil { + return x.SFIXED32 + } + return 0 +} + +func (x *B) GetFIXED32() uint32 { + if x != nil { + return x.FIXED32 + } + return 0 +} + +func (x *B) GetFLOAT() float32 { + if x != nil { + return x.FLOAT + } + return 0 +} + +func (x *B) GetSFIXED64() int64 { + if x != nil { + return x.SFIXED64 + } + return 0 +} + +func (x *B) GetFIXED64() uint64 { + if x != nil { + return x.FIXED64 + } + return 0 +} + +func (x *B) GetDOUBLE() float64 { + if x != nil { + return x.DOUBLE + } + return 0 +} + +func (x *B) GetMAP() map[string]*B { + if x != nil { + return x.MAP + } + return nil +} + +var File__1_proto protoreflect.FileDescriptor + +var file__1_proto_rawDesc = []byte{ + 0x0a, 0x07, 0x31, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, + 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, + 0x61, 0x73, 0x65, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x63, 0x6f, 0x69, 0x6e, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8f, 0x02, 0x0a, 0x01, 0x41, 0x12, 0x16, 0x0a, 0x06, + 0x55, 0x49, 0x4e, 0x54, 0x33, 0x32, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x55, 0x49, + 0x4e, 0x54, 0x33, 0x32, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x49, 0x4e, 0x54, 0x36, 0x34, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x55, 0x49, 0x4e, 0x54, 0x36, 0x34, 0x12, 0x14, 0x0a, 0x05, + 0x49, 0x4e, 0x54, 0x33, 0x32, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x49, 0x4e, 0x54, + 0x33, 0x32, 0x12, 0x14, 0x0a, 0x05, 0x49, 0x4e, 0x54, 0x36, 0x34, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x05, 0x49, 0x4e, 0x54, 0x36, 0x34, 0x12, 0x26, 0x0a, 0x06, 0x53, 0x44, 0x4b, 0x49, + 0x4e, 0x54, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0e, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x49, 0x6e, 0x74, 0x52, 0x06, 0x53, 0x44, 0x4b, 0x49, 0x4e, 0x54, + 0x12, 0x26, 0x0a, 0x06, 0x53, 0x44, 0x4b, 0x44, 0x45, 0x43, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, + 0x42, 0x0e, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x44, 0x65, 0x63, + 0x52, 0x06, 0x53, 0x44, 0x4b, 0x44, 0x45, 0x43, 0x12, 0x2d, 0x0a, 0x04, 0x43, 0x4f, 0x49, 0x4e, + 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, + 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, + 0x6e, 0x52, 0x04, 0x43, 0x4f, 0x49, 0x4e, 0x12, 0x2f, 0x0a, 0x05, 0x43, 0x4f, 0x49, 0x4e, 0x53, + 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, + 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, + 0x6e, 0x52, 0x05, 0x43, 0x4f, 0x49, 0x4e, 0x53, 0x22, 0xd4, 0x02, 0x0a, 0x01, 0x42, 0x12, 0x14, + 0x0a, 0x05, 0x49, 0x4e, 0x54, 0x33, 0x32, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x49, + 0x4e, 0x54, 0x33, 0x32, 0x12, 0x16, 0x0a, 0x06, 0x53, 0x49, 0x4e, 0x54, 0x33, 0x32, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x11, 0x52, 0x06, 0x53, 0x49, 0x4e, 0x54, 0x33, 0x32, 0x12, 0x14, 0x0a, 0x05, + 0x49, 0x4e, 0x54, 0x36, 0x34, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x49, 0x4e, 0x54, + 0x36, 0x34, 0x12, 0x16, 0x0a, 0x06, 0x53, 0x49, 0x4e, 0x47, 0x36, 0x34, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x12, 0x52, 0x06, 0x53, 0x49, 0x4e, 0x47, 0x36, 0x34, 0x12, 0x1a, 0x0a, 0x08, 0x53, 0x46, + 0x49, 0x58, 0x45, 0x44, 0x33, 0x32, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0f, 0x52, 0x08, 0x53, 0x46, + 0x49, 0x58, 0x45, 0x44, 0x33, 0x32, 0x12, 0x18, 0x0a, 0x07, 0x46, 0x49, 0x58, 0x45, 0x44, 0x33, + 0x32, 0x18, 0x06, 0x20, 0x01, 0x28, 0x07, 0x52, 0x07, 0x46, 0x49, 0x58, 0x45, 0x44, 0x33, 0x32, + 0x12, 0x14, 0x0a, 0x05, 0x46, 0x4c, 0x4f, 0x41, 0x54, 0x18, 0x07, 0x20, 0x01, 0x28, 0x02, 0x52, + 0x05, 0x46, 0x4c, 0x4f, 0x41, 0x54, 0x12, 0x1a, 0x0a, 0x08, 0x53, 0x46, 0x49, 0x58, 0x45, 0x44, + 0x36, 0x34, 0x18, 0x08, 0x20, 0x01, 0x28, 0x10, 0x52, 0x08, 0x53, 0x46, 0x49, 0x58, 0x45, 0x44, + 0x36, 0x34, 0x12, 0x18, 0x0a, 0x07, 0x46, 0x49, 0x58, 0x45, 0x44, 0x36, 0x34, 0x18, 0x09, 0x20, + 0x01, 0x28, 0x06, 0x52, 0x07, 0x46, 0x49, 0x58, 0x45, 0x44, 0x36, 0x34, 0x12, 0x16, 0x0a, 0x06, + 0x44, 0x4f, 0x55, 0x42, 0x4c, 0x45, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x01, 0x52, 0x06, 0x44, 0x4f, + 0x55, 0x42, 0x4c, 0x45, 0x12, 0x1d, 0x0a, 0x03, 0x4d, 0x41, 0x50, 0x18, 0x0b, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x0b, 0x2e, 0x42, 0x2e, 0x4d, 0x41, 0x50, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x03, + 0x4d, 0x41, 0x50, 0x1a, 0x3a, 0x0a, 0x08, 0x4d, 0x41, 0x50, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, + 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, + 0x79, 0x12, 0x18, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x02, 0x2e, 0x42, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x2a, + 0x1f, 0x0a, 0x0b, 0x45, 0x6e, 0x75, 0x6d, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x07, + 0x0a, 0x03, 0x4f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x54, 0x77, 0x6f, 0x10, 0x01, + 0x42, 0x33, 0x42, 0x06, 0x31, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x27, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x74, 0x78, 0x2f, 0x74, 0x65, + 0x78, 0x74, 0x75, 0x61, 0x6c, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x74, + 0x65, 0x73, 0x74, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file__1_proto_rawDescOnce sync.Once + file__1_proto_rawDescData = file__1_proto_rawDesc +) + +func file__1_proto_rawDescGZIP() []byte { + file__1_proto_rawDescOnce.Do(func() { + file__1_proto_rawDescData = protoimpl.X.CompressGZIP(file__1_proto_rawDescData) + }) + return file__1_proto_rawDescData +} + +var file__1_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file__1_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file__1_proto_goTypes = []interface{}{ + (Enumeration)(0), // 0: Enumeration + (*A)(nil), // 1: A + (*B)(nil), // 2: B + nil, // 3: B.MAPEntry + (*v1beta1.Coin)(nil), // 4: cosmos.base.v1beta1.Coin +} +var file__1_proto_depIdxs = []int32{ + 4, // 0: A.COIN:type_name -> cosmos.base.v1beta1.Coin + 4, // 1: A.COINS:type_name -> cosmos.base.v1beta1.Coin + 3, // 2: B.MAP:type_name -> B.MAPEntry + 2, // 3: B.MAPEntry.value:type_name -> B + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name +} + +func init() { file__1_proto_init() } +func file__1_proto_init() { + if File__1_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file__1_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*A); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file__1_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*B); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file__1_proto_rawDesc, + NumEnums: 1, + NumMessages: 3, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file__1_proto_goTypes, + DependencyIndexes: file__1_proto_depIdxs, + EnumInfos: file__1_proto_enumTypes, + MessageInfos: file__1_proto_msgTypes, + }.Build() + File__1_proto = out.File + file__1_proto_rawDesc = nil + file__1_proto_goTypes = nil + file__1_proto_depIdxs = nil +} diff --git a/tx/textual/internal/testpb/Makefile b/tx/textual/internal/testpb/Makefile new file mode 100644 index 0000000000..f102fd503e --- /dev/null +++ b/tx/textual/internal/testpb/Makefile @@ -0,0 +1,2 @@ +codegen: + @(buf generate) diff --git a/tx/textual/internal/testpb/buf.gen.yaml b/tx/textual/internal/testpb/buf.gen.yaml new file mode 100644 index 0000000000..137c21bccb --- /dev/null +++ b/tx/textual/internal/testpb/buf.gen.yaml @@ -0,0 +1,15 @@ +version: v1 +managed: + enabled: true + go_package_prefix: + default: cosmossdk.io/tx/textual/internal/testpb + except: + - buf.build/googleapis/googleapis + - buf.build/cosmos/gogo-proto + - buf.build/cosmos/cosmos-proto + override: + buf.build/cosmos/cosmos-sdk: cosmossdk.io/api +plugins: + - name: go-pulsar + out: . + opt: paths=source_relative diff --git a/tx/textual/internal/testpb/buf.lock b/tx/textual/internal/testpb/buf.lock new file mode 100644 index 0000000000..a7e9b6df8b --- /dev/null +++ b/tx/textual/internal/testpb/buf.lock @@ -0,0 +1,17 @@ +# Generated by buf. DO NOT EDIT. +version: v1 +deps: + - remote: buf.build + owner: cosmos + repository: cosmos-proto + branch: main + commit: 1935555c206d4afb9e94615dfd0fad31 + digest: b1-TNqW6xj2Pjha5Uoj9a-5uOeRo4mwswKfyqMcN3I_gZ0= + create_time: 2021-12-02T22:04:00.31049Z + - remote: buf.build + owner: cosmos + repository: gogo-proto + branch: main + commit: bee5511075b7499da6178d9e4aaa628b + digest: b1-rrBIustouD-S80cVoZ_rM0qJsmei9AgbXy9GPQu6vxg= + create_time: 2021-12-02T20:01:17.069307Z diff --git a/tx/textual/internal/testpb/buf.yaml b/tx/textual/internal/testpb/buf.yaml new file mode 100644 index 0000000000..5aee45ac2b --- /dev/null +++ b/tx/textual/internal/testpb/buf.yaml @@ -0,0 +1,12 @@ +version: v1 +deps: + - buf.build/cosmos/cosmos-proto + - buf.build/cosmos/gogo-proto +lint: + use: + - DEFAULT + except: + - PACKAGE_VERSION_SUFFIX +breaking: + ignore: + - testpb diff --git a/tx/textual/valuerenderer/dec.go b/tx/textual/valuerenderer/dec.go new file mode 100644 index 0000000000..688ef73c23 --- /dev/null +++ b/tx/textual/valuerenderer/dec.go @@ -0,0 +1,56 @@ +package valuerenderer + +import ( + "context" + "fmt" + "io" + "strings" + + "google.golang.org/protobuf/reflect/protoreflect" +) + +const thousandSeparator string = "'" + +type decValueRenderer struct{} + +var _ ValueRenderer = decValueRenderer{} + +func (vr decValueRenderer) Format(_ context.Context, v protoreflect.Value, w io.Writer) error { + formatted, err := formatDecimal(v.String()) + if err != nil { + return err + } + + _, err = w.Write([]byte(formatted)) + return err +} + +func (vr decValueRenderer) Parse(_ context.Context, r io.Reader) (protoreflect.Value, error) { + panic("implement me") +} + +// formatDecimal formats a decimal into a value-rendered string. This function +// operates with string manipulation (instead of manipulating the sdk.Dec +// object). +func formatDecimal(v string) (string, error) { + parts := strings.Split(v, ".") + intPart, err := formatInteger(parts[0]) + if err != nil { + return "", err + } + + if len(parts) > 2 { + return "", fmt.Errorf("invalid decimal %s", v) + } + + if len(parts) == 1 { + return intPart, nil + } + + decPart := strings.TrimRight(parts[1], "0") + if len(decPart) == 0 { + return intPart, nil + } + + return intPart + "." + decPart, nil +} diff --git a/tx/textual/valuerenderer/int.go b/tx/textual/valuerenderer/int.go new file mode 100644 index 0000000000..2770cce13f --- /dev/null +++ b/tx/textual/valuerenderer/int.go @@ -0,0 +1,48 @@ +package valuerenderer + +import ( + "context" + "io" + "strings" + + "google.golang.org/protobuf/reflect/protoreflect" +) + +type intValueRenderer struct{} + +var _ ValueRenderer = intValueRenderer{} + +func (vr intValueRenderer) Format(_ context.Context, v protoreflect.Value, w io.Writer) error { + formatted, err := formatInteger(v.String()) + if err != nil { + return err + } + + _, err = w.Write([]byte(formatted)) + return err +} + +func (vr intValueRenderer) Parse(_ context.Context, r io.Reader) (protoreflect.Value, error) { + panic("implement me") +} + +// formatInteger formats an integer into a value-rendered string. This function +// operates with string manipulation (instead of manipulating the int or sdk.Int +// object). +func formatInteger(v string) (string, error) { + if v[0] == '-' { + v = v[1:] + } + if len(v) > 1 { + v = strings.TrimLeft(v, "0") + + } + + startOffset := 3 + for outputIndex := len(v); outputIndex > startOffset; { + outputIndex -= 3 + v = v[:outputIndex] + thousandSeparator + v[outputIndex:] + } + + return v, nil +} diff --git a/tx/textual/valuerenderer/types.go b/tx/textual/valuerenderer/types.go new file mode 100644 index 0000000000..21ca059cb2 --- /dev/null +++ b/tx/textual/valuerenderer/types.go @@ -0,0 +1,20 @@ +package valuerenderer + +import ( + "context" + "io" + + "google.golang.org/protobuf/reflect/protoreflect" +) + +// ValueRenderer defines an interface to produce formatted output for all +// protobuf types as well as parse a string into those protobuf types. +// +// The notion of "value renderer" is defined in ADR-050, and that ADR provides +// a default spec for value renderers. However, we define it as an interface +// here, so that optionally more value renderers could be built, for example, a +// separate one for a different language. +type ValueRenderer interface { + Format(context.Context, protoreflect.Value, io.Writer) error + Parse(context.Context, io.Reader) (protoreflect.Value, error) +} diff --git a/tx/textual/valuerenderer/valuerenderer.go b/tx/textual/valuerenderer/valuerenderer.go new file mode 100644 index 0000000000..3c51a396b8 --- /dev/null +++ b/tx/textual/valuerenderer/valuerenderer.go @@ -0,0 +1,69 @@ +package valuerenderer + +import ( + "fmt" + + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" + + cosmos_proto "github.com/cosmos/cosmos-proto" +) + +type Textual struct { + scalars map[string]ValueRenderer +} + +func NewTextual() Textual { + return Textual{} +} + +// GetValueRenderer returns the value renderer for the given FieldDescriptor. +func (r Textual) GetValueRenderer(fd protoreflect.FieldDescriptor) (ValueRenderer, error) { + switch { + // Scalars, such as sdk.Int and sdk.Dec. + case fd.Kind() == protoreflect.StringKind && proto.GetExtension(fd.Options(), cosmos_proto.E_Scalar) != "": + { + scalar, ok := proto.GetExtension(fd.Options(), cosmos_proto.E_Scalar).(string) + if !ok || scalar == "" { + return nil, fmt.Errorf("got extension option %s of type %T", scalar, scalar) + } + + if r.scalars == nil { + r.init() + } + + vr := r.scalars[scalar] + if vr == nil { + return nil, fmt.Errorf("got empty value renderer for scalar %s", scalar) + } + + return vr, nil + } + + // Integers + case fd.Kind() == protoreflect.Uint32Kind || + fd.Kind() == protoreflect.Uint64Kind || + fd.Kind() == protoreflect.Int32Kind || + fd.Kind() == protoreflect.Int64Kind: + { + return intValueRenderer{}, nil + } + + default: + return nil, fmt.Errorf("value renderers cannot format value of type %s", fd.Kind()) + } +} + +func (r *Textual) init() { + if r.scalars == nil { + r.scalars = map[string]ValueRenderer{} + r.scalars["cosmos.Int"] = intValueRenderer{} + r.scalars["cosmos.Dec"] = decValueRenderer{} + } +} + +// DefineScalar adds a value renderer to the given Cosmos scalar. +func (r *Textual) DefineScalar(scalar string, vr ValueRenderer) { + r.init() + r.scalars[scalar] = vr +} diff --git a/tx/textual/valuerenderer/valuerenderer_test.go b/tx/textual/valuerenderer/valuerenderer_test.go new file mode 100644 index 0000000000..41924d4ed5 --- /dev/null +++ b/tx/textual/valuerenderer/valuerenderer_test.go @@ -0,0 +1,145 @@ +package valuerenderer_test + +import ( + "context" + "encoding/json" + "fmt" + "io/ioutil" + "strconv" + "strings" + "testing" + + "github.com/stretchr/testify/require" + "google.golang.org/protobuf/reflect/protoreflect" + + "cosmossdk.io/math" + "cosmossdk.io/tx/textual/internal/testpb" + "cosmossdk.io/tx/textual/valuerenderer" +) + +func TestFormatInteger(t *testing.T) { + type integerTest []string + var testcases []integerTest + raw, err := ioutil.ReadFile("../internal/testdata/integers.json") + require.NoError(t, err) + err = json.Unmarshal(raw, &testcases) + require.NoError(t, err) + + for _, tc := range testcases { + // Parse test case strings as protobuf uint64 + i, err := strconv.ParseUint(tc[0], 10, 64) + if err == nil { + r, err := valueRendererOf(i) + require.NoError(t, err) + b := new(strings.Builder) + err = r.Format(context.Background(), protoreflect.ValueOf(i), b) + require.NoError(t, err) + + require.Equal(t, tc[1], b.String()) + } + + // Parse test case strings as protobuf uint32 + i, err = strconv.ParseUint(tc[0], 10, 32) + if err == nil { + r, err := valueRendererOf(i) + require.NoError(t, err) + b := new(strings.Builder) + err = r.Format(context.Background(), protoreflect.ValueOf(i), b) + require.NoError(t, err) + + require.Equal(t, tc[1], b.String()) + } + + // Parse test case strings as sdk.Ints + sdkInt, ok := math.NewIntFromString(tc[0]) + if ok { + r, err := valueRendererOf(sdkInt) + require.NoError(t, err) + b := new(strings.Builder) + err = r.Format(context.Background(), protoreflect.ValueOf(tc[0]), b) + require.NoError(t, err) + + require.Equal(t, tc[1], b.String()) + } + } +} + +func TestFormatDecimal(t *testing.T) { + type decimalTest []string + var testcases []decimalTest + raw, err := ioutil.ReadFile("../internal/testdata/decimals.json") + require.NoError(t, err) + err = json.Unmarshal(raw, &testcases) + require.NoError(t, err) + + for _, tc := range testcases { + d, err := math.LegacyNewDecFromStr(tc[0]) + require.NoError(t, err) + r, err := valueRendererOf(d) + require.NoError(t, err) + b := new(strings.Builder) + err = r.Format(context.Background(), protoreflect.ValueOf(tc[0]), b) + require.NoError(t, err) + + require.Equal(t, tc[1], b.String()) + } +} + +func TestGetADR050ValueRenderer(t *testing.T) { + testcases := []struct { + name string + v interface{} + expErr bool + }{ + {"uint32", uint32(1), false}, + {"uint64", uint64(1), false}, + {"sdk.Int", math.NewInt(1), false}, + {"sdk.Dec", math.LegacyNewDec(1), false}, + {"float32", float32(1), true}, + {"float64", float64(1), true}, + } + + for _, tc := range testcases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + _, err := valueRendererOf(tc.v) + if tc.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + +// valueRendererOf is like GetADR050ValueRenderer, but taking a Go type +// as input instead of a protoreflect.FieldDescriptor. +func valueRendererOf(v interface{}) (valuerenderer.ValueRenderer, error) { + a, b := (&testpb.A{}).ProtoReflect().Descriptor().Fields(), (&testpb.B{}).ProtoReflect().Descriptor().Fields() + + textual := valuerenderer.NewTextual() + switch v := v.(type) { + // Valid types for SIGN_MODE_TEXTUAL + case uint32: + return textual.GetValueRenderer(a.ByName(protoreflect.Name("UINT32"))) + case uint64: + return textual.GetValueRenderer(a.ByName(protoreflect.Name("UINT64"))) + case int32: + return textual.GetValueRenderer(a.ByName(protoreflect.Name("INT32"))) + case int64: + return textual.GetValueRenderer(a.ByName(protoreflect.Name("INT64"))) + case math.Int: + return textual.GetValueRenderer(a.ByName(protoreflect.Name("SDKINT"))) + case math.LegacyDec: + return textual.GetValueRenderer(a.ByName(protoreflect.Name("SDKDEC"))) + + // Invalid types for SIGN_MODE_TEXTUAL + case float32: + return textual.GetValueRenderer(b.ByName(protoreflect.Name("FLOAT"))) + case float64: + return textual.GetValueRenderer(b.ByName(protoreflect.Name("FLOAT"))) + + default: + return nil, fmt.Errorf("value %s of type %T not recognized", v, v) + } +}