Skip to content

Commit

Permalink
fix amino signing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
harish551 committed Dec 4, 2023
1 parent bcb7e6b commit b6adfb9
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 52 deletions.
15 changes: 15 additions & 0 deletions proto/OmniFlix/streampay/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ syntax = "proto3";
package OmniFlix.streampay.v1;

import "cosmos/msg/v1/msg.proto";
import "amino/amino.proto";
import "OmniFlix/streampay/v1/params.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/base/v1beta1/coin.proto";
Expand All @@ -13,6 +14,8 @@ option go_package = "github.com/OmniFlix/streampay/x/streampay/types";

// Msg defines the Msg service.
service Msg {
option (cosmos.msg.v1.service) = true;

rpc StreamSend(MsgStreamSend) returns (MsgStreamSendResponse);
rpc StopStream(MsgStopStream) returns (MsgStopStreamResponse);
rpc ClaimStreamedAmount(MsgClaimStreamedAmount) returns (MsgClaimStreamedAmountResponse);
Expand All @@ -26,6 +29,10 @@ service Msg {


message MsgStreamSend {
option (cosmos.msg.v1.signer) = "sender";
option (amino.name) = "OmniFlix/streampay/MsgStreamSend";
option (gogoproto.equal) = false;

string sender = 1;
string recipient = 2;
cosmos.base.v1beta1.Coin amount = 3 [
Expand All @@ -46,13 +53,21 @@ message MsgStreamSendResponse {
}

message MsgStopStream {
option (cosmos.msg.v1.signer) = "sender";
option (amino.name) = "OmniFlix/streampay/MsgStopStream";
option (gogoproto.equal) = false;

string stream_id = 1 [(gogoproto.moretags) = "yaml:\"stream_id\""];
string sender = 2;
}

message MsgStopStreamResponse {}

message MsgClaimStreamedAmount {
option (cosmos.msg.v1.signer) = "claimer";
option (amino.name) = "OmniFlix/streampay/MsgClaimStream";
option (gogoproto.equal) = false;

string stream_id = 1 [(gogoproto.moretags) = "yaml:\"stream_id\""];
string claimer = 2;
}
Expand Down
14 changes: 8 additions & 6 deletions x/streampay/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,29 @@ package types
import (
"github.com/OmniFlix/streampay/v2/x/streampay/exported"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec"
govcodec "github.com/cosmos/cosmos-sdk/x/gov/codec"
)

const (
AminoTypeStreamSendMsg = "OmniFlix/streampay/MsgStreamSend"
AminoTypeStopStreamMsg = "OmniFlix/streampay/MsgStopStream"
AminoTypeClaimStreamedAmountMsg = "OmniFlix/streampay/MsgClaimStreamedAmount"
AminoTypeClaimStreamedAmountMsg = "OmniFlix/streampay/MsgClaimStream"
AminoTypeStreamPayment = "OmniFlix/streampay/StreamPayment"
AminoTypeUpdateParamsMsg = "OmniFlix/streampay/MsgUpdateParams"
AminoTypeParams = "OmniFlix/streampay/Params"
)

func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&MsgStreamSend{}, AminoTypeStreamSendMsg, nil)
cdc.RegisterConcrete(&MsgStopStream{}, AminoTypeStopStreamMsg, nil)
cdc.RegisterConcrete(&MsgClaimStreamedAmount{}, AminoTypeClaimStreamedAmountMsg, nil)
cdc.RegisterConcrete(&MsgUpdateParams{}, AminoTypeUpdateParamsMsg, nil)
legacy.RegisterAminoMsg(cdc, &MsgStreamSend{}, AminoTypeStreamSendMsg)
legacy.RegisterAminoMsg(cdc, &MsgStopStream{}, AminoTypeStopStreamMsg)
legacy.RegisterAminoMsg(cdc, &MsgClaimStreamedAmount{}, AminoTypeClaimStreamedAmountMsg)
legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, AminoTypeUpdateParamsMsg)

cdc.RegisterInterface((*exported.StreamPaymentI)(nil), nil)
cdc.RegisterConcrete(&StreamPayment{}, AminoTypeStreamPayment, nil)
Expand Down Expand Up @@ -54,10 +56,10 @@ var (
func init() {
RegisterLegacyAminoCodec(amino)
cryptocodec.RegisterCrypto(amino)
amino.Seal()

// Register all Amino interfaces and concrete types on the authz Amino codec
// so that this can later be used to properly serialize MsgGrant and MsgExec
// instances.
RegisterLegacyAminoCodec(authzcodec.Amino)
RegisterLegacyAminoCodec(govcodec.Amino)
}
97 changes: 51 additions & 46 deletions x/streampay/types/tx.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b6adfb9

Please sign in to comment.