Skip to content

Commit

Permalink
feat(#242): First generated txs
Browse files Browse the repository at this point in the history
  • Loading branch information
lxgr-linux committed Dec 16, 2024
1 parent 884412c commit 66852ee
Show file tree
Hide file tree
Showing 28 changed files with 4,049 additions and 22 deletions.
40 changes: 40 additions & 0 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66806,6 +66806,24 @@ definitions:
NOTE: The amount field is an Int which implements the custom method
signatures required by gogoproto.
description: Period defines a length of time and amount of coins that will vest.
decentralcardgame.cardchain.cardchain.MsgCardSaveContentResponse:
type: object
properties:
airdropClaimed:
type: boolean
decentralcardgame.cardchain.cardchain.MsgCardSchemeBuyResponse:
type: object
properties:
cardId:
type: string
format: uint64
decentralcardgame.cardchain.cardchain.MsgCardVoteResponse:
type: object
properties:
airdropClaimed:
type: boolean
decentralcardgame.cardchain.cardchain.MsgUserCreateResponse:
type: object
decentralcardgame.cardchain.cardchain.Params:
type: object
description: Params defines the parameters for the module.
Expand All @@ -66816,6 +66834,28 @@ definitions:
description: params holds all the parameters of this module.
type: object
description: QueryParamsResponse is response type for the Query/Params RPC method.
decentralcardgame.cardchain.cardchain.SingleVote:
type: object
properties:
cardId:
type: string
format: uint64
voteType:
type: string
enum:
- fairEnough
- inappropriate
- overpowered
- underpowered
default: fairEnough
decentralcardgame.cardchain.cardchain.VoteType:
type: string
enum:
- fairEnough
- inappropriate
- overpowered
- underpowered
default: fairEnough
ibc.applications.interchain_accounts.controller.v1.MsgRegisterInterchainAccountResponse:
type: object
properties:
Expand Down
6 changes: 3 additions & 3 deletions gen.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/sh

#ignite scaffold message UserCreate newUser:string alias:string
#ignite scaffold message CardSchemeBuy bid:coin --response cardId:uint
#ignite scaffold message CardSaveContent cardId:uint content:string notes:string artist:string balanceAnchor:bool --response airdropClaimed:bool
ignite scaffold message UserCreate newUser:string alias:string
ignite scaffold message CardSchemeBuy bid:coin --response cardId:uint
ignite scaffold message CardSaveContent cardId:uint content:string notes:string artist:string balanceAnchor:bool --response airdropClaimed:bool
ignite scaffold message CardVote vote:SingleVote --response airdropClaimed:bool
44 changes: 43 additions & 1 deletion proto/cardchain/cardchain/tx.proto
Original file line number Diff line number Diff line change
@@ -1,7 +1,49 @@
syntax = "proto3";

package decentralcardgame.cardchain.cardchain;

option go_package = "github.com/DecentralCardGame/cardchain/x/cardchain/types";

import "cardchain/cardchain/voting.proto";
import "cosmos/base/v1beta1/coin.proto";
import "gogoproto/gogo.proto";

// Msg defines the Msg service.
service Msg {}
service Msg {
rpc UserCreate(MsgUserCreate) returns (MsgUserCreateResponse);
rpc CardSchemeBuy(MsgCardSchemeBuy) returns (MsgCardSchemeBuyResponse);
rpc CardSaveContent(MsgCardSaveContent) returns (MsgCardSaveContentResponse);
rpc CardVote(MsgCardVote) returns (MsgCardVoteResponse);
}
message MsgUserCreate {
string creator = 1;
string newUser = 2;
string alias = 3;
}

message MsgUserCreateResponse {}

message MsgCardSchemeBuy {
string creator = 1;
cosmos.base.v1beta1.Coin bid = 2 [ (gogoproto.nullable) = false ];
}

message MsgCardSchemeBuyResponse { uint64 cardId = 1; }

message MsgCardSaveContent {
string creator = 1;
uint64 cardId = 2;
string content = 3;
string notes = 4;
string artist = 5;
bool balanceAnchor = 6;
}

message MsgCardSaveContentResponse { bool airdropClaimed = 1; }

message MsgCardVote {
string creator = 1;
SingleVote vote = 2;
}

message MsgCardVoteResponse { bool airdropClaimed = 1; }
6 changes: 5 additions & 1 deletion x/cardchain/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ func GetTxCmd() *cobra.Command {
RunE: client.ValidateCmd,
}

// this line is used by starport scaffolding # 1
cmd.AddCommand(CmdUserCreate())
cmd.AddCommand(CmdCardSchemeBuy())
cmd.AddCommand(CmdCardSaveContent())
cmd.AddCommand(CmdCardVote())
// this line is used by starport scaffolding # 1

return cmd
}
57 changes: 57 additions & 0 deletions x/cardchain/client/cli/tx_card_save_content.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package cli

import (
"strconv"

"github.com/DecentralCardGame/cardchain/x/cardchain/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/spf13/cast"
"github.com/spf13/cobra"
)

var _ = strconv.Itoa(0)

func CmdCardSaveContent() *cobra.Command {
cmd := &cobra.Command{
Use: "card-save-content [card-id] [content] [notes] [artist] [balance-anchor]",
Short: "Broadcast message CardSaveContent",
Args: cobra.ExactArgs(5),
RunE: func(cmd *cobra.Command, args []string) (err error) {
argCardId, err := cast.ToUint64E(args[0])
if err != nil {
return err
}
argContent := args[1]
argNotes := args[2]
argArtist := args[3]
argBalanceAnchor, err := cast.ToBoolE(args[4])
if err != nil {
return err
}

clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

msg := types.NewMsgCardSaveContent(
clientCtx.GetFromAddress().String(),
argCardId,
argContent,
argNotes,
argArtist,
argBalanceAnchor,
)
if err := msg.ValidateBasic(); err != nil {
return err
}
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}

flags.AddTxFlagsToCmd(cmd)

return cmd
}
46 changes: 46 additions & 0 deletions x/cardchain/client/cli/tx_card_scheme_buy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package cli

import (
"strconv"

"github.com/DecentralCardGame/cardchain/x/cardchain/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/spf13/cobra"
)

var _ = strconv.Itoa(0)

func CmdCardSchemeBuy() *cobra.Command {
cmd := &cobra.Command{
Use: "card-scheme-buy [bid]",
Short: "Broadcast message CardSchemeBuy",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) (err error) {
argBid, err := sdk.ParseCoinNormalized(args[0])
if err != nil {
return err
}

clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

msg := types.NewMsgCardSchemeBuy(
clientCtx.GetFromAddress().String(),
argBid,
)
if err := msg.ValidateBasic(); err != nil {
return err
}
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}

flags.AddTxFlagsToCmd(cmd)

return cmd
}
48 changes: 48 additions & 0 deletions x/cardchain/client/cli/tx_card_vote.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package cli

import (
"strconv"

"encoding/json"
"github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/DecentralCardGame/cardchain/x/cardchain/types"
)

var _ = strconv.Itoa(0)

func CmdCardVote() *cobra.Command {
cmd := &cobra.Command{
Use: "card-vote [vote]",
Short: "Broadcast message CardVote",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) (err error) {
argVote := new(types.SingleVote)
err = json.Unmarshal([]byte(args[0]), argVote)
if err != nil {
return err
}

clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

msg := types.NewMsgCardVote(
clientCtx.GetFromAddress().String(),
argVote,

)
if err := msg.ValidateBasic(); err != nil {
return err
}
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}

flags.AddTxFlagsToCmd(cmd)

return cmd
}
44 changes: 44 additions & 0 deletions x/cardchain/client/cli/tx_user_create.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package cli

import (
"strconv"

"github.com/DecentralCardGame/cardchain/x/cardchain/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/spf13/cobra"
)

var _ = strconv.Itoa(0)

func CmdUserCreate() *cobra.Command {
cmd := &cobra.Command{
Use: "user-create [new-user] [alias]",
Short: "Broadcast message UserCreate",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) (err error) {
argNewUser := args[0]
argAlias := args[1]

clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

msg := types.NewMsgUserCreate(
clientCtx.GetFromAddress().String(),
argNewUser,
argAlias,
)
if err := msg.ValidateBasic(); err != nil {
return err
}
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}

flags.AddTxFlagsToCmd(cmd)

return cmd
}
17 changes: 17 additions & 0 deletions x/cardchain/keeper/msg_server_card_save_content.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package keeper

import (
"context"

"github.com/DecentralCardGame/cardchain/x/cardchain/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)

func (k msgServer) CardSaveContent(goCtx context.Context, msg *types.MsgCardSaveContent) (*types.MsgCardSaveContentResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)

// TODO: Handling the message
_ = ctx

return &types.MsgCardSaveContentResponse{}, nil
}
17 changes: 17 additions & 0 deletions x/cardchain/keeper/msg_server_card_scheme_buy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package keeper

import (
"context"

"github.com/DecentralCardGame/cardchain/x/cardchain/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)

func (k msgServer) CardSchemeBuy(goCtx context.Context, msg *types.MsgCardSchemeBuy) (*types.MsgCardSchemeBuyResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)

// TODO: Handling the message
_ = ctx

return &types.MsgCardSchemeBuyResponse{}, nil
}
18 changes: 18 additions & 0 deletions x/cardchain/keeper/msg_server_card_vote.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package keeper

import (
"context"

"github.com/DecentralCardGame/cardchain/x/cardchain/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)


func (k msgServer) CardVote(goCtx context.Context, msg *types.MsgCardVote) (*types.MsgCardVoteResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)

// TODO: Handling the message
_ = ctx

return &types.MsgCardVoteResponse{}, nil
}
Loading

0 comments on commit 66852ee

Please sign in to comment.