fix: implement Amino serialization for x/authz and x/feegrant (#11224)

* fix: Add RegisterLegacyAminoCodec for authz/feegrant

* add module name

* Fix GetSignByes, add tests

* removed module names from registered messages to match other modules

* added interfaces and concrete types registration

* unseal amino instances to allow external grant and authorization registration

* fixed messages tests

* allow to register external types into authz modulecdc

* use legacy.Cdc instead of ModuleCdc inside x/authz

* move the legacy.Cdc initialization outside init function

* added serialization docs

* Update docs/core/encoding.md

Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>

* added the Ledger specification

* fixed tests

Co-authored-by: Amaury M <1293565+amaurym@users.noreply.github.com>
This commit is contained in:
Riccardo Montagnin
2022-02-22 12:03:01 +01:00
committed by GitHub
co-authored by Amaury
parent a8f31c914b
commit 81cfc6cc85
23 changed files with 233 additions and 12 deletions
+18
View File
@@ -67,6 +67,24 @@ Note, there are length-prefixed variants of the above functionality and this is
typically used for when the data needs to be streamed or grouped together
(e.g. `ResponseDeliverTx.Data`)
#### Authz authorizations
Since the `MsgExec` message type can contain different messages instances, it is important that developers
add the following code inside the `init` method of their module's `codec.go` file:
```go
import "github.com/cosmos/cosmos-sdk/codec/legacy"
init() {
// Register all Amino interfaces and concrete types on the global Amino codec so that this can later be
// used to properly serialize x/authz MsgExec instances
RegisterLegacyAminoCodec(legacy.Cdc)
}
```
This will allow the `x/authz` module to properly serialize and de-serializes `MsgExec` instances using Amino,
which is required when signing this kind of messages using a Ledger.
### Gogoproto
Modules are encouraged to utilize Protobuf encoding for their respective types. In the Cosmos SDK, we use the [Gogoproto](https://github.com/gogo/protobuf) specific implementation of the Protobuf spec that offers speed and DX improvements compared to the official [Google protobuf implementation](https://github.com/protocolbuffers/protobuf).