Skip to content

Commit

Permalink
add update deny list command
Browse files Browse the repository at this point in the history
  • Loading branch information
nullpointer0x00 committed Jul 10, 2023
1 parent ab1eaab commit 373d0ee
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions x/marker/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func NewTxCmd() *cobra.Command {
GetCmdUpdateRequiredAttributes(),
GetCmdUpdateForcedTransfer(),
GetCmdSetAccountData(),
GetCmdUpdateSendDenyListRequest(),

Check warning on line 87 in x/marker/client/cli/tx.go

View check run for this annotation

Codecov / codecov/patch

x/marker/client/cli/tx.go#L87

Added line #L87 was not covered by tests
)
return txCmd
}
Expand Down Expand Up @@ -1050,6 +1051,53 @@ func GetCmdUpdateForcedTransfer() *cobra.Command {
return cmd
}

// GetCmdUpdateSendDenyListRequest implements the update deny list command
func GetCmdUpdateSendDenyListRequest() *cobra.Command {
cmd := &cobra.Command{
Use: "update-deny-list <denom>",
Aliases: []string{"udl", "deny-list", "deny"},
Args: cobra.ExactArgs(1),
Short: "Update list of addresses for a restricted marker that are allowed to execute transfers",
Long: strings.TrimSpace(`Update list of addresses for a restricted marker that are allowed to execute transfers.
`),
Example: fmt.Sprintf(`$ %s tx marker update-deny-list hotdogcoin --%s=bech32addr1,bech32addrs2,... --%s=bech32addr1,bech32addrs2,...`,
version.AppName,
FlagAdd,
FlagRemove,
),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}
flagSet := cmd.Flags()

msg := &types.MsgUpdateSendDenyListRequest{Denom: args[0]}

msg.AddDeniedAddresses, err = flagSet.GetStringSlice(FlagAdd)
if err != nil {
return fmt.Errorf("incorrect value for %s flag. Accepted: comma delimited list of bech32 addresses Error: %w", FlagAdd, err)
}

Check warning on line 1080 in x/marker/client/cli/tx.go

View check run for this annotation

Codecov / codecov/patch

x/marker/client/cli/tx.go#L1055-L1080

Added lines #L1055 - L1080 were not covered by tests

msg.RemoveDeniedAddresses, err = flagSet.GetStringSlice(FlagRemove)
if err != nil {
return fmt.Errorf("incorrect value for %s flag. Accepted: comma delimited list of bech32 addresses Error: %w", FlagRemove, err)
}

Check warning on line 1085 in x/marker/client/cli/tx.go

View check run for this annotation

Codecov / codecov/patch

x/marker/client/cli/tx.go#L1082-L1085

Added lines #L1082 - L1085 were not covered by tests

authSetter := func(authority string) {
msg.Authority = authority
}

Check warning on line 1089 in x/marker/client/cli/tx.go

View check run for this annotation

Codecov / codecov/patch

x/marker/client/cli/tx.go#L1087-L1089

Added lines #L1087 - L1089 were not covered by tests

return generateOrBroadcastOptGovProp(clientCtx, flagSet, authSetter, msg)

Check warning on line 1091 in x/marker/client/cli/tx.go

View check run for this annotation

Codecov / codecov/patch

x/marker/client/cli/tx.go#L1091

Added line #L1091 was not covered by tests
},
}
cmd.Flags().StringSlice(FlagAdd, []string{}, "comma delimited list of bech32 addresses to be added to restricted marker transfer deny list")
cmd.Flags().StringSlice(FlagRemove, []string{}, "comma delimited list of bech32 addresses to be removed removed from restricted marker deny list")
addOptGovPropFlags(cmd)
flags.AddTxFlagsToCmd(cmd)
return cmd

Check warning on line 1098 in x/marker/client/cli/tx.go

View check run for this annotation

Codecov / codecov/patch

x/marker/client/cli/tx.go#L1094-L1098

Added lines #L1094 - L1098 were not covered by tests
}

// GetCmdSetAccountData returns a CLI command for setting a marker's account data.
func GetCmdSetAccountData() *cobra.Command {
cmd := &cobra.Command{
Expand Down

0 comments on commit 373d0ee

Please sign in to comment.