diff --git a/client/tx/search.go b/client/tx/search.go index 158dafa72..422f48276 100644 --- a/client/tx/search.go +++ b/client/tx/search.go @@ -32,7 +32,7 @@ func SearchTxCmd(cdc *codec.Codec) *cobra.Command { Long: strings.TrimSpace(` Search for transactions that match exactly the given tags. For example: -$ gaiacli query txs --tags :&: +$ gaiacli query txs --tags ':&:' `), RunE: func(cmd *cobra.Command, args []string) error { tagsStr := viper.GetString(flagTags) @@ -48,7 +48,10 @@ $ gaiacli query txs --tags :&: for _, tag := range tags { if !strings.Contains(tag, ":") { return fmt.Errorf("%s should be of the format :", tagsStr) + } else if strings.Count(tag, ":") > 1 { + return fmt.Errorf("%s should only contain one : pair", tagsStr) } + keyValue := strings.Split(tag, ":") tag = fmt.Sprintf("%s='%s'", keyValue[0], keyValue[1]) tmTags = append(tmTags, tag) diff --git a/docs/gaia/gaiacli.md b/docs/gaia/gaiacli.md index 4bf93b2fb..5c10e4898 100644 --- a/docs/gaia/gaiacli.md +++ b/docs/gaia/gaiacli.md @@ -193,8 +193,18 @@ gaiacli tx broadcast --node= signedSendTx.json You can use the transaction search command to query for transactions that match a specific set of `tags`, which are added on every transaction. +Each tag is conformed by a key-value pair in the form of `:`. Tags can also be combined to query for a more specific result using the `&` symbol. + +The command for querying transactions using a `tag` is the following: + ```bash -gaiacli query txs --tags=:&: +gaiacli query txs --tags=':' +``` + +And for using multiple `tags`: + +```bash +gaiacli query txs --tags=':&:' ``` ::: tip Note