-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix/ST-365: Fix tx msg decode (#371)
* make v1_1 proto compatible with stratos-chain v11 msgs. v1 proto compatible with stratos-chain v12 msgs. * update go.mod
- Loading branch information
1 parent
114001a
commit 2534ff1
Showing
13 changed files
with
7,242 additions
and
9 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
syntax = "proto3"; | ||
package stratos.register.v1_1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "google/protobuf/any.proto"; | ||
import "cosmos_proto/cosmos.proto"; | ||
import "amino/amino.proto"; | ||
|
||
option (gogoproto.equal_all) = true; | ||
option go_package = "github.com/stratosnet/stratos-chain/x/register/types/v1_1"; | ||
|
||
|
||
message Description { | ||
option (gogoproto.goproto_stringer) = true; | ||
|
||
string moniker = 1 [ | ||
(gogoproto.jsontag) = "moniker", | ||
(gogoproto.moretags) = "yaml:\"moniker\"" | ||
]; | ||
string identity = 2 [ | ||
(gogoproto.jsontag) = "identity", | ||
(gogoproto.moretags) = "yaml:\"identity\",omitempty" | ||
]; | ||
string website = 3 [ | ||
(gogoproto.jsontag) = "website", | ||
(gogoproto.moretags) = "yaml:\"website\",omitempty" | ||
]; | ||
string security_contact = 4 [ | ||
(gogoproto.jsontag) = "security_contact", | ||
(gogoproto.moretags) = "yaml:\"security_contact\",omitempty"]; | ||
string details = 5 [ | ||
(gogoproto.jsontag) = "details", | ||
(gogoproto.moretags) = "yaml:\"details\",omitempty"]; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,156 @@ | ||
syntax = "proto3"; | ||
package stratos.register.v1_1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "cosmos_proto/cosmos.proto"; | ||
import "amino/amino.proto"; | ||
import "cosmos/msg/v1/msg.proto"; | ||
import "cosmos/base/v1beta1/coin.proto"; | ||
import "google/protobuf/any.proto"; | ||
import "stratos/register/v1_1/register.proto"; | ||
|
||
option (gogoproto.equal_all) = true; | ||
option go_package = "github.com/stratosnet/stratos-chain/x/register/types/v1_1"; | ||
|
||
// MsgCreateResourceNode encapsulates an MsgCreateResourceNodeTx transaction as an SDK message. | ||
message MsgCreateResourceNode { | ||
option (cosmos.msg.v1.signer) = "owner_address"; | ||
option (amino.name) = "stratos/MsgCreateResourceNode"; | ||
|
||
string network_address = 1 [ | ||
(cosmos_proto.scalar) = "cosmos.AddressString", | ||
(gogoproto.jsontag) = "network_address", | ||
(gogoproto.moretags) = "yaml:\"network_address\"" | ||
]; | ||
google.protobuf.Any pubkey = 2 [ | ||
(cosmos_proto.accepts_interface) = "cosmos.crypto.PubKey", | ||
(gogoproto.jsontag) = "pubkey", | ||
(gogoproto.moretags) = "yaml:\"pubkey\"" | ||
]; | ||
cosmos.base.v1beta1.Coin value = 3 [ | ||
(gogoproto.nullable) = false, | ||
(amino.dont_omitempty) = true, | ||
(gogoproto.jsontag) = "value", | ||
(gogoproto.moretags) = "yaml:\"value\"" | ||
]; | ||
string owner_address = 4 [ | ||
(cosmos_proto.scalar) = "cosmos.AddressString", | ||
(gogoproto.jsontag) = "owner_address", | ||
(gogoproto.moretags) = "yaml:\"owner_address\"" | ||
]; | ||
Description description = 5 [ | ||
(gogoproto.nullable) = false, | ||
(amino.dont_omitempty) = true, | ||
(gogoproto.jsontag) = "description", | ||
(gogoproto.moretags) = "yaml:\"description\"" | ||
]; | ||
uint32 node_type = 6 [ | ||
(gogoproto.jsontag) = "node_type", | ||
(gogoproto.moretags) = "yaml:\"node_type\"" | ||
]; | ||
string beneficiary_address = 7 [ | ||
(cosmos_proto.scalar) = "cosmos.AddressString", | ||
(gogoproto.jsontag) = "beneficiary_address", | ||
(gogoproto.moretags) = "yaml:\"beneficiary_address\"" | ||
]; | ||
} | ||
|
||
// MsgCreateMetaNode encapsulates an MsgCreateMetaNodeTx transaction as an SDK message. | ||
message MsgCreateMetaNode { | ||
option (cosmos.msg.v1.signer) = "owner_address"; | ||
option (amino.name) = "stratos/MsgCreateMetaNode"; | ||
|
||
string network_address = 1 [ | ||
(cosmos_proto.scalar) = "cosmos.AddressString", | ||
(gogoproto.jsontag) = "network_address", | ||
(gogoproto.moretags) = "yaml:\"network_address\"" | ||
]; | ||
google.protobuf.Any pubkey = 2 [ | ||
(cosmos_proto.accepts_interface) = "cosmos.crypto.PubKey", | ||
(gogoproto.jsontag) = "pubkey", | ||
(gogoproto.moretags) = "yaml:\"pubkey\"" | ||
]; | ||
cosmos.base.v1beta1.Coin value = 3 [ | ||
(gogoproto.nullable) = false, | ||
(amino.dont_omitempty) = true, | ||
(gogoproto.jsontag) = "value", | ||
(gogoproto.moretags) = "yaml:\"value\"" | ||
]; | ||
string owner_address = 4 [ | ||
(cosmos_proto.scalar) = "cosmos.AddressString", | ||
(gogoproto.jsontag) = "owner_address", | ||
(gogoproto.moretags) = "yaml:\"owner_address\"" | ||
]; | ||
Description description = 5 [ | ||
(gogoproto.nullable) = false, | ||
(amino.dont_omitempty) = true, | ||
(gogoproto.jsontag) = "description", | ||
(gogoproto.moretags) = "yaml:\"description\"" | ||
]; | ||
string beneficiary_address = 6 [ | ||
(cosmos_proto.scalar) = "cosmos.AddressString", | ||
(gogoproto.jsontag) = "beneficiary_address", | ||
(gogoproto.moretags) = "yaml:\"beneficiary_address\"" | ||
]; | ||
} | ||
|
||
// MsgUpdateResourceNode defines a SDK message for updating an existing resource node. | ||
message MsgUpdateResourceNode { | ||
option (cosmos.msg.v1.signer) = "owner_address"; | ||
option (amino.name) = "stratos/MsgUpdateResourceNode"; | ||
|
||
Description description = 1 [ | ||
(gogoproto.nullable) = false, | ||
(amino.dont_omitempty) = true, | ||
(gogoproto.jsontag) = "description", | ||
(gogoproto.moretags) = "yaml:\"description\"" | ||
]; | ||
string network_address = 2 [ | ||
(cosmos_proto.scalar) = "cosmos.AddressString", | ||
(gogoproto.jsontag) = "network_address", | ||
(gogoproto.moretags) = "yaml:\"network_address\"" | ||
]; | ||
string owner_address = 3 [ | ||
(cosmos_proto.scalar) = "cosmos.AddressString", | ||
(gogoproto.jsontag) = "owner_address", | ||
(gogoproto.moretags) = "yaml:\"owner_address\"" | ||
]; | ||
uint32 node_type = 4 [ | ||
(gogoproto.jsontag) = "node_type", | ||
(gogoproto.moretags) = "yaml:\"node_type\"" | ||
]; | ||
string beneficiary_address = 5 [ | ||
(cosmos_proto.scalar) = "cosmos.AddressString", | ||
(gogoproto.jsontag) = "beneficiary_address", | ||
(gogoproto.moretags) = "yaml:\"beneficiary_address\"" | ||
]; | ||
} | ||
|
||
// MsgUpdateMetaNode defines a SDK message for updating an existing meta node. | ||
message MsgUpdateMetaNode { | ||
option (cosmos.msg.v1.signer) = "owner_address"; | ||
option (amino.name) = "stratos/MsgUpdateMetaNode"; | ||
|
||
Description description = 1 [ | ||
(gogoproto.nullable) = false, | ||
(amino.dont_omitempty) = true, | ||
(gogoproto.jsontag) = "description", | ||
(gogoproto.moretags) = "yaml:\"description\"" | ||
]; | ||
string network_address = 2 [ | ||
(cosmos_proto.scalar) = "cosmos.AddressString", | ||
(gogoproto.jsontag) = "network_address", | ||
(gogoproto.moretags) = "yaml:\"network_address\"" | ||
]; | ||
string owner_address = 3 [ | ||
(cosmos_proto.scalar) = "cosmos.AddressString", | ||
(gogoproto.jsontag) = "owner_address", | ||
(gogoproto.moretags) = "yaml:\"owner_address\"" | ||
]; | ||
string beneficiary_address = 4 [ | ||
(cosmos_proto.scalar) = "cosmos.AddressString", | ||
(gogoproto.jsontag) = "beneficiary_address", | ||
(gogoproto.moretags) = "yaml:\"beneficiary_address\"" | ||
]; | ||
} | ||
|
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 |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package v1_1 | ||
|
||
import ( | ||
codectypes "github.com/cosmos/cosmos-sdk/codec/types" | ||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
var ( | ||
_ sdk.Msg = &MsgCreateResourceNode{} | ||
_ sdk.Msg = &MsgUpdateResourceNode{} | ||
_ sdk.Msg = &MsgCreateMetaNode{} | ||
_ sdk.Msg = &MsgUpdateMetaNode{} | ||
) | ||
|
||
// ValidateBasic validity check for the CreateResourceNode | ||
func (msg MsgCreateResourceNode) ValidateBasic() error { | ||
return nil | ||
} | ||
|
||
func (msg MsgCreateResourceNode) GetSigners() []sdk.AccAddress { | ||
// Owner pays the tx fees | ||
addr, err := sdk.AccAddressFromBech32(msg.GetOwnerAddress()) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return []sdk.AccAddress{addr.Bytes()} | ||
} | ||
|
||
// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces | ||
func (msg MsgCreateResourceNode) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { | ||
var pk cryptotypes.PubKey | ||
return unpacker.UnpackAny(msg.Pubkey, &pk) | ||
} | ||
|
||
// ValidateBasic implements the sdk.Msg interface. | ||
func (msg MsgUpdateResourceNode) ValidateBasic() error { | ||
return nil | ||
} | ||
|
||
// GetSigners implements the sdk.Msg interface. | ||
func (msg MsgUpdateResourceNode) GetSigners() []sdk.AccAddress { | ||
addr, err := sdk.AccAddressFromBech32(msg.OwnerAddress) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return []sdk.AccAddress{addr.Bytes()} | ||
} | ||
|
||
func (msg MsgCreateMetaNode) ValidateBasic() error { | ||
return nil | ||
} | ||
|
||
func (msg MsgCreateMetaNode) GetSigners() []sdk.AccAddress { | ||
// Owner pays the tx fees | ||
addr, err := sdk.AccAddressFromBech32(msg.GetOwnerAddress()) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return []sdk.AccAddress{addr.Bytes()} | ||
|
||
} | ||
|
||
// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces | ||
func (msg MsgCreateMetaNode) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { | ||
var pk cryptotypes.PubKey | ||
return unpacker.UnpackAny(msg.Pubkey, &pk) | ||
} | ||
|
||
// GetSigners implements the sdk.Msg interface. | ||
func (msg MsgUpdateMetaNode) GetSigners() []sdk.AccAddress { | ||
addr, err := sdk.AccAddressFromBech32(msg.OwnerAddress) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return []sdk.AccAddress{addr.Bytes()} | ||
} | ||
|
||
// ValidateBasic implements the sdk.Msg interface. | ||
func (msg MsgUpdateMetaNode) ValidateBasic() error { | ||
return nil | ||
} |
Oops, something went wrong.