Skip to content

Commit

Permalink
Register missing amino codec of x/token, x/collection, x/wasm a…
Browse files Browse the repository at this point in the history
…nd `x/foundation` (#745)

* fix: implement Amino serialization for x/token

Signed-off-by: zemyblue <[email protected]>

* fix: implement Amino serialization for x/collection

Signed-off-by: zemyblue <[email protected]>

* fix: implement Amino serialization for x/foundation, x/stakingplus

Signed-off-by: zemyblue <[email protected]>

* fix: conflict msgs

Signed-off-by: zemyblue <[email protected]>

* fix: change x/wasm amino to using legacyCdc

Signed-off-by: zemyblue <[email protected]>

* fix: change conflict amino msgName with x/token and x/collection.

Signed-off-by: zemyblue <[email protected]>

* chore: add more unittest

Signed-off-by: zemyblue <[email protected]>

* chore: update changelog

Signed-off-by: zemyblue <[email protected]>

* fix: apply the changes of `x/foundation`

Signed-off-by: zemyblue <[email protected]>

* chore: remove redundant code.

Signed-off-by: zemyblue <[email protected]>

* fix: apply feedback.

Signed-off-by: zemyblue <[email protected]>

* fix: remove unused amino codec type, `Change` of `x/collection`

Signed-off-by: zemyblue <[email protected]>

* fix: remove unused amino codec type, `MintNFTParam` of `x/collection`

Signed-off-by: zemyblue <[email protected]>

Signed-off-by: zemyblue <[email protected]>
  • Loading branch information
zemyblue authored Oct 25, 2022
1 parent e25624d commit f7d1830
Show file tree
Hide file tree
Showing 16 changed files with 1,552 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (amino) [\#736](https://github.com/line/lbm-sdk/pull/736) apply the missing amino codec registratoin of cosmos-sdk
* (x/foundation) [\#744](https://github.com/line/lbm-sdk/pull/744) revisit foundation operator
* (store,x/wasm) [\#742](https://github.com/line/lbm-sdk/pull/742) fix to add error message in GetByteCode()
* (amino) [\#745](https://github.com/line/lbm-sdk/pull/745) apply the missing amino codec of `x/token`, `x/collection`, `x/wasm` and `x/foundation`

### Bug Fixes
* (x/wasm) [\#453](https://github.com/line/lbm-sdk/pull/453) modify wasm grpc query api path
Expand Down
47 changes: 47 additions & 0 deletions x/collection/codec.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,42 @@
package collection

import (
"github.com/line/lbm-sdk/codec"
"github.com/line/lbm-sdk/codec/legacy"
"github.com/line/lbm-sdk/codec/types"
cryptocodec "github.com/line/lbm-sdk/crypto/codec"
sdk "github.com/line/lbm-sdk/types"
"github.com/line/lbm-sdk/types/msgservice"
authzcodec "github.com/line/lbm-sdk/x/authz/codec"
govcodec "github.com/line/lbm-sdk/x/gov/codec"
)

// RegisterLegacyAminoCodec registers concrete types on the LegacyAmino codec
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
legacy.RegisterAminoMsg(cdc, &MsgTransferFT{}, "lbm-sdk/MsgTransferFT")
legacy.RegisterAminoMsg(cdc, &MsgTransferFTFrom{}, "lbm-sdk/MsgTransferFTFrom")
legacy.RegisterAminoMsg(cdc, &MsgTransferNFT{}, "lbm-sdk/MsgTransferNFT")
legacy.RegisterAminoMsg(cdc, &MsgTransferNFTFrom{}, "lbm-sdk/MsgTransferNFTFrom")
legacy.RegisterAminoMsg(cdc, &MsgApprove{}, "lbm-sdk/collection/MsgApprove") // Changed msgName due to conflict with `x/token`
legacy.RegisterAminoMsg(cdc, &MsgDisapprove{}, "lbm-sdk/MsgDisapprove")
legacy.RegisterAminoMsg(cdc, &MsgCreateContract{}, "lbm-sdk/MsgCreateContract")
legacy.RegisterAminoMsg(cdc, &MsgIssueFT{}, "lbm-sdk/MsgIssueFT")
legacy.RegisterAminoMsg(cdc, &MsgIssueNFT{}, "lbm-sdk/MsgIssueNFT")
legacy.RegisterAminoMsg(cdc, &MsgMintFT{}, "lbm-sdk/MsgMintFT")
legacy.RegisterAminoMsg(cdc, &MsgMintNFT{}, "lbm-sdk/MsgMintNFT")
legacy.RegisterAminoMsg(cdc, &MsgBurnFT{}, "lbm-sdk/MsgBurnFT")
legacy.RegisterAminoMsg(cdc, &MsgBurnFTFrom{}, "lbm-sdk/MsgBurnFTFrom")
legacy.RegisterAminoMsg(cdc, &MsgBurnNFT{}, "lbm-sdk/MsgBurnNFT")
legacy.RegisterAminoMsg(cdc, &MsgBurnNFTFrom{}, "lbm-sdk/MsgBurnNFTFrom")
legacy.RegisterAminoMsg(cdc, &MsgModify{}, "lbm-sdk/collection/MsgModify") // Changed msgName due to conflict with `x/token`
legacy.RegisterAminoMsg(cdc, &MsgGrantPermission{}, "lbm-sdk/collection/MsgGrantPermission") // Changed msgName due to conflict with `x/token`
legacy.RegisterAminoMsg(cdc, &MsgRevokePermission{}, "lbm-sdk/collection/MsgRevokePermission") // Changed msgName due to conflict with `x/token`
legacy.RegisterAminoMsg(cdc, &MsgAttach{}, "lbm-sdk/MsgAttach")
legacy.RegisterAminoMsg(cdc, &MsgDetach{}, "lbm-sdk/MsgDetach")
legacy.RegisterAminoMsg(cdc, &MsgAttachFrom{}, "lbm-sdk/MsgAttachFrom")
legacy.RegisterAminoMsg(cdc, &MsgDetachFrom{}, "lbm-sdk/MsgDetachFrom")
}

func RegisterInterfaces(registry types.InterfaceRegistry) {
registry.RegisterImplementations((*sdk.Msg)(nil),
&MsgCreateContract{},
Expand Down Expand Up @@ -48,3 +79,19 @@ func RegisterInterfaces(registry types.InterfaceRegistry) {

msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}

var (
amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewAminoCodec(amino)
)

func init() {
RegisterLegacyAminoCodec(amino)
cryptocodec.RegisterCrypto(amino)
sdk.RegisterLegacyAminoCodec(amino)

// Register all Amino interfaces and concrete types on the authz and gov Amino codec so that this can later be
// used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances
RegisterLegacyAminoCodec(authzcodec.Amino)
RegisterLegacyAminoCodec(govcodec.Amino)
}
3 changes: 3 additions & 0 deletions x/collection/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ const (

// StoreKey defines the primary module store key
StoreKey = ModuleName

// RouterKey defines the module's message routing key
RouterKey = ModuleName
)
Loading

0 comments on commit f7d1830

Please sign in to comment.