Skip to content

Commit

Permalink
Merge pull request #219 from DecentralCardGame/214-early-access
Browse files Browse the repository at this point in the history
214 early access
  • Loading branch information
lxgr-linux authored May 3, 2024
2 parents ae1a824 + c0e6b72 commit 2de2378
Show file tree
Hide file tree
Showing 31 changed files with 2,544 additions and 333 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Test CD

on:
push:
branches:
- development

jobs:
run_pull:
name: run pull
runs-on: ubuntu-latest
steps:
- name: install liefer
run: |
go install github.com/lxgr-linux/liefer@latest
- name: deploy
run: |
~/go/bin/liefer deliver devnet development ${{ secrets.LIEFER_PRIVKEY }} --address ${{ secrets.LXGR_HOST }}:8080
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ func getGovProposalHandlers() []govclient.ProposalHandler {
cardchainclient.CopyrightProposalHandler,
cardchainclient.MatchReporterProposalHandler,
cardchainclient.SetProposalHandler,
cardchainclient.EarlyAccessProposalHandler,
featureflagclient.ProposalHandler,
// this line is used by starport scaffolding # stargate/app/govProposalHandler
)
Expand Down
31 changes: 31 additions & 0 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34184,6 +34184,15 @@ paths:
items:
type: string
format: uint64
earlyAccess:
type: object
properties:
active:
type: boolean
invitedByUser:
type: string
invitedUser:
type: string
default:
description: An unexpected error response.
schema:
Expand Down Expand Up @@ -68859,6 +68868,15 @@ definitions:
- openCouncil
- startedCouncil
default: available
DecentralCardGame.cardchain.cardchain.EarlyAccess:
type: object
properties:
active:
type: boolean
invitedByUser:
type: string
invitedUser:
type: string
DecentralCardGame.cardchain.cardchain.IgnoreMatches:
type: object
properties:
Expand Down Expand Up @@ -69063,10 +69081,14 @@ definitions:
type: object
DecentralCardGame.cardchain.cardchain.MsgCreateuserResponse:
type: object
DecentralCardGame.cardchain.cardchain.MsgDisinviteEarlyAccessResponse:
type: object
DecentralCardGame.cardchain.cardchain.MsgDonateToCardResponse:
type: object
DecentralCardGame.cardchain.cardchain.MsgFinalizeSetResponse:
type: object
DecentralCardGame.cardchain.cardchain.MsgInviteEarlyAccessResponse:
type: object
DecentralCardGame.cardchain.cardchain.MsgMultiVoteCardResponse:
type: object
DecentralCardGame.cardchain.cardchain.MsgOpenBoosterPackResponse:
Expand Down Expand Up @@ -69828,6 +69850,15 @@ definitions:
items:
type: string
format: uint64
earlyAccess:
type: object
properties:
active:
type: boolean
invitedByUser:
type: string
invitedUser:
type: string
DecentralCardGame.cardchain.cardchain.VoteType:
type: string
enum:
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/cosmos/cosmos-sdk v0.46.15
github.com/cosmos/ibc-go/v6 v6.1.0
github.com/gogo/protobuf v1.3.3
github.com/golang/protobuf v1.5.3
github.com/golang/protobuf v1.5.4
github.com/gorilla/mux v1.8.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/spf13/cast v1.5.0
Expand Down Expand Up @@ -161,7 +161,7 @@ require (
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20240116215550-a9fa1716bcac // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe // indirect
google.golang.org/protobuf v1.32.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
nhooyr.io/websocket v1.8.7 // indirect
Expand Down
9 changes: 5 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1493,8 +1493,8 @@ github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.3-0.20201103224600-674baa8c7fc3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
Expand Down Expand Up @@ -1702,6 +1702,7 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t
github.com/grpc-ecosystem/grpc-gateway v1.12.1/go.mod h1:8XEsbTttt/W+VvjtQhLACqCisSPWTxCZ7sBRjU6iH9c=
github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM=
github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645/go.mod h1:6iZfnjpejD4L/4DwD7NryNaJyCQdzwWwH2MWhCA90Kw=
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU=
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0=
Expand Down Expand Up @@ -3893,8 +3894,8 @@ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
11 changes: 11 additions & 0 deletions proto/cardchain/cardchain/early_access_proposal.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
syntax = "proto3";
package decentralcardgame.cardchain.cardchain;

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

message EarlyAccessProposal {
string title = 1;
string description = 2;
string link = 3;
repeated string users = 4;
}
26 changes: 21 additions & 5 deletions proto/cardchain/cardchain/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ service Msg {
rpc SetUserBiography (MsgSetUserBiography ) returns (MsgSetUserBiographyResponse );

// this line is used by starport scaffolding # proto/tx/rpc
rpc MultiVoteCard (MsgMultiVoteCard) returns (MsgMultiVoteCardResponse);
rpc OpenMatch (MsgOpenMatch ) returns (MsgOpenMatchResponse );
rpc SetSetName (MsgSetSetName ) returns (MsgSetSetNameResponse );
rpc ChangeAlias (MsgChangeAlias ) returns (MsgChangeAliasResponse );
rpc MultiVoteCard (MsgMultiVoteCard ) returns (MsgMultiVoteCardResponse );
rpc OpenMatch (MsgOpenMatch ) returns (MsgOpenMatchResponse );
rpc SetSetName (MsgSetSetName ) returns (MsgSetSetNameResponse );
rpc ChangeAlias (MsgChangeAlias ) returns (MsgChangeAliasResponse );
rpc InviteEarlyAccess (MsgInviteEarlyAccess ) returns (MsgInviteEarlyAccessResponse );
rpc DisinviteEarlyAccess (MsgDisinviteEarlyAccess) returns (MsgDisinviteEarlyAccessResponse);
}
message MsgCreateuser {
string creator = 1;
Expand All @@ -74,7 +76,7 @@ message MsgBuyCardScheme {
cosmos.base.v1beta1.Coin bid = 2 [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin"];

/*
string bid = 2;
string bid = 2;
*/}

message MsgBuyCardSchemeResponse {
Expand Down Expand Up @@ -407,3 +409,17 @@ message MsgChangeAlias {

message MsgChangeAliasResponse {}

message MsgInviteEarlyAccess {
string creator = 1;
string user = 2;
}

message MsgInviteEarlyAccessResponse {}

message MsgDisinviteEarlyAccess {
string creator = 1;
string user = 2;
}

message MsgDisinviteEarlyAccessResponse {}

7 changes: 7 additions & 0 deletions proto/cardchain/cardchain/user.proto
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ message User {
string biography = 12;
repeated uint64 votableCards = 13;
repeated uint64 votedCards = 14;
EarlyAccess earlyAccess = 15;
}

enum CouncilStatus {
Expand All @@ -28,6 +29,12 @@ enum CouncilStatus {
startedCouncil = 3;
}

message EarlyAccess {
bool active = 1;
string invitedByUser = 2;
string invitedUser = 3;
}

message BoosterPack {
uint64 setId = 1;
int64 timeStamp = 2;
Expand Down
14 changes: 10 additions & 4 deletions scripts/migrate_with_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
__location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))

gameserver_addr = ["cc1z94z55n2rr4rmjf4ea0m7ykgh9a8urwzrlsxt4", "cc1ch66e3f0szxy8q976rsq5y07esmgdqzj70dfpu"]
early_access_addr = ["cc14km80077s0hch3sh38wh2hfk7kxfau4456r3ej"]
alpha_creator = "cc14km80077s0hch3sh38wh2hfk7kxfau4456r3ej"
del_cards = [] # [370, 346, 258]

Expand Down Expand Up @@ -43,15 +44,14 @@
# this loads the old genesis file
with open(file_path_old, "r") as file:
old_dict = json.load(file)
#old_dict = json.loads(file.read().replace("collection", "set").replace("Collection", "Set"))
# old_dict = json.loads(file.read().replace("collection", "set").replace("Collection", "Set"))

# this loads the new genesis file
with open(file_path_new, "r") as file:
new_dict = json.load(file)


# delete all sets
#old_dict["app_state"]["cardchain"]["sets"] = []
# old_dict["app_state"]["cardchain"]["sets"] = []


params = new_dict["app_state"]["cardchain"]["params"]
Expand Down Expand Up @@ -122,10 +122,16 @@
break

# Remove deprecated voteRights from users
for user in new_dict["app_state"]["cardchain"]["users"]:
for addr, user in zip(new_dict["app_state"]["cardchain"]["addresses"], new_dict["app_state"]["cardchain"]["users"]):
if "voteRights" in user:
del user["voteRights"]
user["boosterPacks"] = [pack for pack in user["boosterPacks"] if pack["setId"] not in ["0", "2"]] # turn of later
user["earlyAccess"] = user.get(
"earlyAccess",
{"active": False, "invitedUser": "", "invitedByUser": ""}
) # add earlyAccess
if addr in early_access_addr:
user["earlyAccess"]["active"] = True

with open(file_path_new, "w") as file:
json.dump(new_dict, file, indent=2)
64 changes: 64 additions & 0 deletions x/cardchain/client/cli/submit_early_access_proposal.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package cli

import (
"strconv"
"strings"

"github.com/DecentralCardGame/Cardchain/x/cardchain/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/tx"
sdk "github.com/cosmos/cosmos-sdk/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/spf13/cobra"
)

var _ = strconv.Itoa(0)

func CmdSubmitEarlyAccessProposal() *cobra.Command {
cmd := &cobra.Command{
Use: "early-access-proposal [deposit] [description] [link] [users...]",
Short: "Propose EarlyAccessProposal",
Args: cobra.MinimumNArgs(4),
RunE: func(cmd *cobra.Command, args []string) (err error) {
argDeposit := args[0]
argDescription := args[1]
argLink := args[2]

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

users := args[3:]

for _, addr := range users {
_, err = sdk.AccAddressFromBech32(addr)
if err != nil {
return err
}
}

from := clientCtx.GetFromAddress()
proposal := types.EarlyAccessProposal{
Title: "Early access proposal for: " + strings.Join(users, ", "),
Description: argDescription,
Link: argLink,
Users: users,
}

deposit, err := sdk.ParseCoinsNormalized(argDeposit)
if err != nil {
return err
}

msg, err := govtypes.NewMsgSubmitProposal(&proposal, deposit, from)
if err != nil {
return err
}

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}

return cmd
}
2 changes: 2 additions & 0 deletions x/cardchain/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ func GetTxCmd() *cobra.Command {
cmd.AddCommand(CmdMsgOpenMatch())
cmd.AddCommand(CmdSetSetName())
cmd.AddCommand(CmdChangeAlias())
cmd.AddCommand(CmdInviteEarlyAccess())
cmd.AddCommand(CmdDisinviteEarlyAccess())
// this line is used by starport scaffolding # 1

return cmd
Expand Down
42 changes: 42 additions & 0 deletions x/cardchain/client/cli/tx_disinvite_early_access.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
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 CmdDisinviteEarlyAccess() *cobra.Command {
cmd := &cobra.Command{
Use: "disinvite-early-access [user]",
Short: "Broadcast message disinviteEarlyAccess",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) (err error) {
argUser := args[0]

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

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

flags.AddTxFlagsToCmd(cmd)

return cmd
}
Loading

0 comments on commit 2de2378

Please sign in to comment.