-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- legacy message type compatibility with upstream types
- Loading branch information
1 parent
4ca2078
commit 1d8d596
Showing
13 changed files
with
580 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,73 @@ | ||
package types | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/cosmos/cosmos-sdk/codec" | ||
"github.com/cosmos/cosmos-sdk/codec/legacy" | ||
"github.com/cosmos/cosmos-sdk/x/authz" | ||
) | ||
|
||
// Wrapper type for backward compatibility | ||
type LegacyMsgGrant struct { | ||
authz.MsgGrant | ||
} | ||
|
||
// Wrapper type for backward compatibility | ||
type LegacyMsgRevoke struct { | ||
authz.MsgRevoke | ||
} | ||
|
||
// Wrapper type for backward compatibility | ||
type LegacyMsgExec struct { | ||
authz.MsgExec | ||
} | ||
|
||
// Wrapper type for backward compatibility | ||
type LegacyGenericAuthorization struct { | ||
authz.GenericAuthorization | ||
} | ||
|
||
func (l LegacyMsgGrant) MarshalJSON() ([]byte, error) { | ||
return json.Marshal(l.MsgGrant) | ||
} | ||
|
||
func (l *LegacyMsgGrant) UnmarshalJSON(data []byte) error { | ||
return json.Unmarshal(data, &l.MsgGrant) | ||
} | ||
|
||
func (l LegacyMsgRevoke) MarshalJSON() ([]byte, error) { | ||
return json.Marshal(l.MsgRevoke) | ||
} | ||
|
||
func (l *LegacyMsgRevoke) UnmarshalJSON(data []byte) error { | ||
return json.Unmarshal(data, &l.MsgRevoke) | ||
} | ||
|
||
func (l LegacyMsgExec) MarshalJSON() ([]byte, error) { | ||
return json.Marshal(l.MsgExec) | ||
} | ||
|
||
func (l *LegacyMsgExec) UnmarshalJSON(data []byte) error { | ||
return json.Unmarshal(data, &l.MsgExec) | ||
} | ||
|
||
func (l LegacyGenericAuthorization) MarshalJSON() ([]byte, error) { | ||
return json.Marshal(l.GenericAuthorization) | ||
} | ||
|
||
func (l *LegacyGenericAuthorization) UnmarshalJSON(data []byte) error { | ||
return json.Unmarshal(data, &l.GenericAuthorization) | ||
} | ||
|
||
// RegisterLegacyAminoCodec registers the necessary x/authz interfaces and concrete types | ||
// on the provided LegacyAmino codec. These types are used for Amino JSON serialization. | ||
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { | ||
legacy.RegisterAminoMsg(cdc, &authz.MsgGrant{}, "msgauth/MsgGrantAuthorization") | ||
legacy.RegisterAminoMsg(cdc, &authz.MsgRevoke{}, "msgauth/MsgRevokeAuthorization") | ||
legacy.RegisterAminoMsg(cdc, &authz.MsgExec{}, "msgauth/MsgExecAuthorized") | ||
authz.RegisterLegacyAminoCodec(cdc) | ||
|
||
legacy.RegisterAminoMsg(cdc, &LegacyMsgGrant{}, "msgauth/MsgGrantAuthorization") | ||
legacy.RegisterAminoMsg(cdc, &LegacyMsgRevoke{}, "msgauth/MsgRevokeAuthorization") | ||
legacy.RegisterAminoMsg(cdc, &LegacyMsgExec{}, "msgauth/MsgExecAuthorized") | ||
|
||
cdc.RegisterInterface((*authz.Authorization)(nil), nil) | ||
cdc.RegisterConcrete(&authz.GenericAuthorization{}, "msgauth/GenericAuthorization", nil) | ||
cdc.RegisterConcrete(&LegacyGenericAuthorization{}, "msgauth/GenericAuthorization", nil) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.