-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* initial claim scaffolding * fix scaffolded * message scaffold * fix message scaffold * message type tests * implement message * fix keeper * keeper test * format * add initial claim in config.yml
- Loading branch information
Showing
34 changed files
with
1,948 additions
and
107 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
syntax = "proto3"; | ||
package tendermint.spn.claim; | ||
|
||
option go_package = "github.com/tendermint/spn/x/claim/types"; | ||
|
||
message InitialClaim { | ||
bool enabled = 1; | ||
uint64 missionID = 2; | ||
} |
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
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,38 @@ | ||
package cli | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/cosmos/cosmos-sdk/client" | ||
"github.com/cosmos/cosmos-sdk/client/flags" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/tendermint/spn/x/claim/types" | ||
) | ||
|
||
func CmdShowInitialClaim() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "show-initial-claim", | ||
Short: "shows information about initial claim", | ||
Long: "shows if initial claim is enabled and what is the mission ID completed by initial claim", | ||
Args: cobra.NoArgs, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
clientCtx := client.GetClientContextFromCmd(cmd) | ||
|
||
queryClient := types.NewQueryClient(clientCtx) | ||
|
||
params := &types.QueryGetInitialClaimRequest{} | ||
|
||
res, err := queryClient.InitialClaim(context.Background(), params) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return clientCtx.PrintProto(res) | ||
}, | ||
} | ||
|
||
flags.AddQueryFlagsToCmd(cmd) | ||
|
||
return cmd | ||
} |
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,37 @@ | ||
package cli | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/client" | ||
"github.com/cosmos/cosmos-sdk/client/flags" | ||
"github.com/cosmos/cosmos-sdk/client/tx" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/tendermint/spn/x/claim/types" | ||
) | ||
|
||
func CmdClaimInitial() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "claim-initial", | ||
Short: "claim the initial airdrop allocation", | ||
Args: cobra.NoArgs, | ||
RunE: func(cmd *cobra.Command, args []string) (err error) { | ||
|
||
clientCtx, err := client.GetClientTxContext(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
msg := types.NewMsgClaimInitial( | ||
clientCtx.GetFromAddress().String(), | ||
) | ||
if err := msg.ValidateBasic(); err != nil { | ||
return err | ||
} | ||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) | ||
}, | ||
} | ||
|
||
flags.AddTxFlagsToCmd(cmd) | ||
|
||
return cmd | ||
} |
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,25 @@ | ||
package keeper | ||
|
||
import ( | ||
"context" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"google.golang.org/grpc/codes" | ||
"google.golang.org/grpc/status" | ||
|
||
"github.com/tendermint/spn/x/claim/types" | ||
) | ||
|
||
func (k Keeper) InitialClaim(c context.Context, req *types.QueryGetInitialClaimRequest) (*types.QueryGetInitialClaimResponse, error) { | ||
if req == nil { | ||
return nil, status.Error(codes.InvalidArgument, "invalid request") | ||
} | ||
ctx := sdk.UnwrapSDKContext(c) | ||
|
||
val, found := k.GetInitialClaim(ctx) | ||
if !found { | ||
return nil, status.Error(codes.NotFound, "not found") | ||
} | ||
|
||
return &types.QueryGetInitialClaimResponse{InitialClaim: val}, 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package keeper_test | ||
|
||
import ( | ||
"testing" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/stretchr/testify/require" | ||
"google.golang.org/grpc/codes" | ||
"google.golang.org/grpc/status" | ||
|
||
testkeeper "github.com/tendermint/spn/testutil/keeper" | ||
"github.com/tendermint/spn/testutil/nullify" | ||
"github.com/tendermint/spn/x/claim/types" | ||
) | ||
|
||
func TestInitialClaimQuery(t *testing.T) { | ||
ctx, tk, _ := testkeeper.NewTestSetup(t) | ||
wctx := sdk.WrapSDKContext(ctx) | ||
item := createTestInitialClaim(tk.ClaimKeeper, ctx) | ||
for _, tc := range []struct { | ||
desc string | ||
request *types.QueryGetInitialClaimRequest | ||
response *types.QueryGetInitialClaimResponse | ||
err error | ||
}{ | ||
{ | ||
desc: "First", | ||
request: &types.QueryGetInitialClaimRequest{}, | ||
response: &types.QueryGetInitialClaimResponse{InitialClaim: item}, | ||
}, | ||
{ | ||
desc: "InvalidRequest", | ||
err: status.Error(codes.InvalidArgument, "invalid request"), | ||
}, | ||
} { | ||
t.Run(tc.desc, func(t *testing.T) { | ||
response, err := tk.ClaimKeeper.InitialClaim(wctx, tc.request) | ||
if tc.err != nil { | ||
require.ErrorIs(t, err, tc.err) | ||
} else { | ||
require.NoError(t, err) | ||
require.Equal(t, | ||
nullify.Fill(tc.response), | ||
nullify.Fill(response), | ||
) | ||
} | ||
}) | ||
} | ||
} |
Oops, something went wrong.