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

feat: Add missing cli for fungible module #1426

Merged
merged 16 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from 12 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
2 changes: 0 additions & 2 deletions common/common.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions docs/cli/zetacored/zetacored_tx_fungible.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ zetacored tx fungible [flags]
* [zetacored tx fungible update-contract-bytecode](zetacored_tx_fungible_update-contract-bytecode.md) - Broadcast message UpdateContractBytecode
* [zetacored tx fungible update-system-contract](zetacored_tx_fungible_update-system-contract.md) - Broadcast message UpdateSystemContract
* [zetacored tx fungible update-zrc20-liquidity-cap](zetacored_tx_fungible_update-zrc20-liquidity-cap.md) - Broadcast message UpdateZRC20LiquidityCap
* [zetacored tx fungible update-zrc20-paused-status](zetacored_tx_fungible_update-zrc20-paused-status.md) - Broadcast message UpdateZRC20PausedStatus
* [zetacored tx fungible update-zrc20-withdraw-fee](zetacored_tx_fungible_update-zrc20-withdraw-fee.md) - Broadcast message UpdateZRC20WithdrawFee

Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# tx fungible update-zrc20-paused-status

Broadcast message UpdateZRC20PausedStatus

```
zetacored tx fungible update-zrc20-paused-status [contractAddress1, contractAddress2, ...] [pausedStatus] [flags]
```

### Examples

```
zetacored tx fungible update-zrc20-paused-status "0xece40cbB54d65282c4623f141c4a8a0bE7D6AdEc, 0xece40cbB54d65282c4623f141c4a8a0bEjgksncf" 0
```

### Options

```
-a, --account-number uint The account number of the signing account (offline mode only)
--aux Generate aux signer data instead of sending a tx
-b, --broadcast-mode string Transaction broadcasting mode (sync|async|block)
--dry-run ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it (when enabled, the local Keybase is not accessible)
--fee-granter string Fee granter grants fees for the transaction
--fee-payer string Fee payer pays fees for the transaction instead of deducting from the signer
--fees string Fees to pay along with transaction; eg: 10uatom
--from string Name or address of private key with which to sign
--gas string gas limit to set per-transaction; set to "auto" to calculate sufficient gas automatically. Note: "auto" option doesn't always report accurate results. Set a valid coin value to adjust the result. Can be used instead of "fees". (default 200000)
--gas-adjustment float adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored (default 1)
--gas-prices string Gas prices in decimal format to determine the transaction fee (e.g. 0.1uatom)
--generate-only Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase only accessed when providing a key name)
-h, --help help for update-zrc20-paused-status
--keyring-backend string Select keyring's backend (os|file|kwallet|pass|test|memory)
--keyring-dir string The client Keyring directory; if omitted, the default 'home' directory will be used
--ledger Use a connected Ledger device
--node string [host]:[port] to tendermint rpc interface for this chain
--note string Note to add a description to the transaction (previously --memo)
--offline Offline mode (does not allow any online functionality)
-o, --output string Output format (text|json)
-s, --sequence uint The sequence number of the signing account (offline mode only)
--sign-mode string Choose sign mode (direct|amino-json|direct-aux), this is an advanced feature
--timeout-height uint Set a block timeout height to prevent the tx from being committed past a certain height
--tip string Tip is the amount that is going to be transferred to the fee payer on the target chain. This flag is only valid when used with --aux, and is ignored if the target chain didn't enable the TipDecorator
-y, --yes Skip tx broadcasting prompt confirmation
```

### Options inherited from parent commands

```
--chain-id string The network chain ID
--home string directory for config and data
--log_format string The logging format (json|plain)
--log_level string The logging level (trace|debug|info|warn|error|fatal|panic)
--trace print out full stack trace on errors
```

### SEE ALSO

* [zetacored tx fungible](zetacored_tx_fungible.md) - fungible transactions subcommands

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# tx fungible update-zrc20-withdraw-fee

Broadcast message UpdateZRC20WithdrawFee

```
zetacored tx fungible update-zrc20-withdraw-fee [contractAddress] [newWithdrawFee] [newGasLimit] [flags]
```

### Options

```
-a, --account-number uint The account number of the signing account (offline mode only)
--aux Generate aux signer data instead of sending a tx
-b, --broadcast-mode string Transaction broadcasting mode (sync|async|block)
--dry-run ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it (when enabled, the local Keybase is not accessible)
--fee-granter string Fee granter grants fees for the transaction
--fee-payer string Fee payer pays fees for the transaction instead of deducting from the signer
--fees string Fees to pay along with transaction; eg: 10uatom
--from string Name or address of private key with which to sign
--gas string gas limit to set per-transaction; set to "auto" to calculate sufficient gas automatically. Note: "auto" option doesn't always report accurate results. Set a valid coin value to adjust the result. Can be used instead of "fees". (default 200000)
--gas-adjustment float adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored (default 1)
--gas-prices string Gas prices in decimal format to determine the transaction fee (e.g. 0.1uatom)
--generate-only Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase only accessed when providing a key name)
-h, --help help for update-zrc20-withdraw-fee
--keyring-backend string Select keyring's backend (os|file|kwallet|pass|test|memory)
--keyring-dir string The client Keyring directory; if omitted, the default 'home' directory will be used
--ledger Use a connected Ledger device
--node string [host]:[port] to tendermint rpc interface for this chain
--note string Note to add a description to the transaction (previously --memo)
--offline Offline mode (does not allow any online functionality)
-o, --output string Output format (text|json)
-s, --sequence uint The sequence number of the signing account (offline mode only)
--sign-mode string Choose sign mode (direct|amino-json|direct-aux), this is an advanced feature
--timeout-height uint Set a block timeout height to prevent the tx from being committed past a certain height
--tip string Tip is the amount that is going to be transferred to the fee payer on the target chain. This flag is only valid when used with --aux, and is ignored if the target chain didn't enable the TipDecorator
-y, --yes Skip tx broadcasting prompt confirmation
```

### Options inherited from parent commands

```
--chain-id string The network chain ID
--home string directory for config and data
--log_format string The logging format (json|plain)
--log_level string The logging level (trace|debug|info|warn|error|fatal|panic)
--trace print out full stack trace on errors
```

### SEE ALSO

* [zetacored tx fungible](zetacored_tx_fungible.md) - fungible transactions subcommands

4 changes: 3 additions & 1 deletion x/fungible/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ func GetTxCmd() *cobra.Command {
CmdDeployFungibleCoinZRC4(),
CmdRemoveForeignCoin(),
CmdUpdateZRC20LiquidityCap(),
CmdUpdateSystemContract(),
CmdUpdateContractBytecode(),
CmdUpdateSystemContract(),
CmdUpdateZRC20PausedStatus(),
CmdUpdateZRC20WithdrawFee(),
)

return cmd
Expand Down
3 changes: 0 additions & 3 deletions x/fungible/client/cli/tx_update_contract_bytecode.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ func CmdUpdateContractBytecode() *cobra.Command {
args[0],
args[1],
)
if err := msg.ValidateBasic(); err != nil {
return err
}
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}
Expand Down
56 changes: 56 additions & 0 deletions x/fungible/client/cli/tx_update_zrc20_paused_status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package cli

import (
"strconv"
"strings"

cosmoserrors "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/spf13/cobra"
"github.com/zeta-chain/zetacore/x/fungible/types"
)

func CmdUpdateZRC20PausedStatus() *cobra.Command {
cmd := &cobra.Command{
Use: "update-zrc20-paused-status [contractAddress1, contractAddress2, ...] [pausedStatus]",
Short: "Broadcast message UpdateZRC20PausedStatus",
Example: `zetacored tx fungible update-zrc20-paused-status "0xece40cbB54d65282c4623f141c4a8a0bE7D6AdEc, 0xece40cbB54d65282c4623f141c4a8a0bEjgksncf" 0 `,
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) (err error) {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

contractAddressList := strings.Split(strings.TrimSpace(args[0]), ",")

action, err := strconv.ParseUint(args[1], 10, 32)
if err != nil {
return err
}
if (action != 0) && (action != 1) {
return cosmoserrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid action (%d)", action)
}

pausedStatus := types.UpdatePausedStatusAction_PAUSE
if action == 1 {
pausedStatus = types.UpdatePausedStatusAction_UNPAUSE
}

msg := types.NewMsgUpdateZRC20PausedStatus(
clientCtx.GetFromAddress().String(),
contractAddressList,
pausedStatus,
)

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}

flags.AddTxFlagsToCmd(cmd)

return cmd
}
43 changes: 43 additions & 0 deletions x/fungible/client/cli/tx_update_zrc20_withdraw_fee.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package cli

import (
sdkmath "cosmossdk.io/math"
"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/zeta-chain/zetacore/x/fungible/types"
)

func CmdUpdateZRC20WithdrawFee() *cobra.Command {
cmd := &cobra.Command{
Use: "update-zrc20-withdraw-fee [contractAddress] [newWithdrawFee] [newGasLimit]",
Short: "Broadcast message UpdateZRC20WithdrawFee",
Args: cobra.ExactArgs(3),
RunE: func(cmd *cobra.Command, args []string) (err error) {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

contractAddress := args[0]

newWithdrawFee := sdkmath.NewUintFromString(args[1])

newGasLimit := sdkmath.NewUintFromString(args[2])

msg := types.NewMsgUpdateZRC20WithdrawFee(
clientCtx.GetFromAddress().String(),
contractAddress,
newWithdrawFee,
newGasLimit,
)

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}

flags.AddTxFlagsToCmd(cmd)

return cmd
}
Loading