Skip to content

Commit

Permalink
added call authentication for kwil cli
Browse files Browse the repository at this point in the history
minor bug fix with shorthand authentication flag
  • Loading branch information
brennanjl authored and Yaiba committed Sep 4, 2023
1 parent e1e9e67 commit 919a24d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
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

0 comments on commit 919a24d

Please sign in to comment.