Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added call authentication for kwil cli #250

Merged
merged 1 commit into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions cmd/kwil-cli/cmds/database/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

func callCmd() *cobra.Command {
var action string
authenticate := new(bool)

cmd := &cobra.Command{
Use: "call",
Expand Down Expand Up @@ -40,7 +41,7 @@ OR
'$name:satoshi' '$age:32' --dbid=x1234 --action=create_user `,
RunE: func(cmd *cobra.Command, args []string) error {
return common.DialClient(cmd.Context(), 0, func(ctx context.Context, client *client.Client, conf *config.KwilCliConfig) error {
return common.DialClient(cmd.Context(), 0, func(ctx context.Context, clnt *client.Client, conf *config.KwilCliConfig) error {
dbid, err := getSelectedDbid(cmd, conf)
if err != nil {
return fmt.Errorf("target database not properly specified: %w", err)
Expand All @@ -53,7 +54,7 @@ OR
return fmt.Errorf("error getting inputs: %w", err)
}

actionStructure, err := getAction(ctx, client, dbid, lowerName)
actionStructure, err := getAction(ctx, clnt, dbid, lowerName)
if err != nil {
return fmt.Errorf("error getting action: %w", err)
}
Expand All @@ -67,7 +68,7 @@ OR
tuples = append(tuples, []any{})
}

res, err := client.CallAction(ctx, dbid, lowerName, tuples[0])
res, err := clnt.CallAction(ctx, dbid, lowerName, tuples[0], client.Authenticated(*authenticate))
if err != nil {
return fmt.Errorf("error executing action: %w", err)
}
Expand All @@ -90,6 +91,7 @@ OR
cmd.Flags().StringP(ownerFlag, "o", "", "the database owner")
cmd.Flags().StringP(dbidFlag, "i", "", "the database id")
cmd.Flags().StringVarP(&action, actionNameFlag, "a", "", "the action name (required)")
authenticate = cmd.Flags().Bool("authenticate", false, "whether to authenticate the action call")

cmd.MarkFlagRequired(actionNameFlag)
return cmd
Expand Down
2 changes: 1 addition & 1 deletion cmd/kwil-cli/cmds/database/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ A wallet can be specified with the --owner flag, otherwise the default wallet is
}

if len(dbs) == 0 {
fmt.Printf("No databases found for address '%x'.\n", owner)
fmt.Printf("No databases found for '%x'.\n", owner)
} else {
fmt.Printf("Databases belonging to '%x':\n", owner)
}
Expand Down