diff --git a/module/x/gravity/client/cli/query.go b/module/x/gravity/client/cli/query.go index e5c5a9bca..e7004c5f2 100644 --- a/module/x/gravity/client/cli/query.go +++ b/module/x/gravity/client/cli/query.go @@ -6,6 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" "github.com/peggyjv/gravity-bridge/module/x/gravity/types" "github.com/spf13/cobra" @@ -76,30 +77,24 @@ func CmdParams() *cobra.Command { func CmdSignerSetTx() *cobra.Command { cmd := &cobra.Command{ Use: "signer-set-tx [nonce]", - Args: cobra.MaximumNArgs(1), - Short: "", // TODO(levi) provide short description + Args: cobra.ExactArgs(1), + Short: "query an individual signer set transaction by its nonce", RunE: func(cmd *cobra.Command, args []string) error { clientCtx, queryClient, err := newContextAndQueryClient(cmd) if err != nil { return err } - var nonce uint64 - - if len(args) > 0 { - if nonce, err = parseNonce(args[0]); err != nil { - return err - } - } - - req := types.SignerSetTxRequest{ - SignerSetNonce: nonce, + nonce, err := parseNonce(args[0]) + if err != nil { + return err } - res, err := queryClient.SignerSetTx(cmd.Context(), &req) + res, err := queryClient.SignerSetTx(cmd.Context(), &types.SignerSetTxRequest{SignerSetNonce: nonce}) if err != nil { return err } + return clientCtx.PrintProto(res) }, } @@ -111,36 +106,29 @@ func CmdSignerSetTx() *cobra.Command { func CmdBatchTx() *cobra.Command { cmd := &cobra.Command{ Use: "batch-tx [contract-address] [nonce]", - Args: cobra.RangeArgs(1, 2), - Short: "", // TODO(levi) provide short description + Args: cobra.ExactArgs(2), + Short: "query an outgoing batch by its contract address and nonce", RunE: func(cmd *cobra.Command, args []string) error { clientCtx, queryClient, err := newContextAndQueryClient(cmd) if err != nil { return err } - var ( // args - contractAddress string - nonce uint64 - ) - - contractAddress, err = parseContractAddress(args[0]) + contractAddress, err := parseContractAddress(args[0]) if err != nil { return nil } - if len(args) == 2 { - if nonce, err = parseNonce(args[1]); err != nil { - return err - } + nonce, err := parseNonce(args[1]) + if err != nil { + return err } - req := types.BatchTxRequest{ + res, err := queryClient.BatchTx(cmd.Context(), &types.BatchTxRequest{ TokenContract: contractAddress, BatchNonce: nonce, - } + }) - res, err := queryClient.BatchTx(cmd.Context(), &req) if err != nil { return err } @@ -157,24 +145,26 @@ func CmdContractCallTx() *cobra.Command { cmd := &cobra.Command{ Use: "contract-call-tx [invalidation-scope] [invalidation-nonce]", Args: cobra.ExactArgs(2), - Short: "", // TODO(levi) provide short description + Short: "query an outgoing contract call by scope and nonce", RunE: func(cmd *cobra.Command, args []string) error { clientCtx, queryClient, err := newContextAndQueryClient(cmd) if err != nil { return err } - var ( // args - invalidationScope []byte // TODO(levi) init and validate from args[0] - invalidationNonce uint64 // TODO(levi) init and validate from args[1] - ) + // TODO: validate this scope somehow + invalidationScope := []byte(args[0]) - req := types.ContractCallTxRequest{ + invalidationNonce, err := parseNonce(args[1]) + if err != nil { + return err + } + + res, err := queryClient.ContractCallTx(cmd.Context(), &types.ContractCallTxRequest{ InvalidationScope: invalidationScope, InvalidationNonce: invalidationNonce, - } + }) - res, err := queryClient.ContractCallTx(cmd.Context(), &req) if err != nil { return err } @@ -189,27 +179,21 @@ func CmdContractCallTx() *cobra.Command { func CmdSignerSetTxs() *cobra.Command { cmd := &cobra.Command{ - Use: "signer-set-txs (count)", + Use: "signer-set-txs", Args: cobra.NoArgs, - Short: "", // TODO(levi) provide short description + Short: "query all the signer set transactions from the chain", // TODO(levi) provide short description RunE: func(cmd *cobra.Command, args []string) error { clientCtx, queryClient, err := newContextAndQueryClient(cmd) if err != nil { return err } - // // var count int64 - // if len(args) > 0 { - // if count, err = parseCount(args[0]); err != nil { - // return err - // } - // } - - req := types.SignerSetTxsRequest{ - // Count: count, + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err } - res, err := queryClient.SignerSetTxs(cmd.Context(), &req) + res, err := queryClient.SignerSetTxs(cmd.Context(), &types.SignerSetTxsRequest{Pagination: pageReq}) if err != nil { return err } @@ -219,6 +203,7 @@ func CmdSignerSetTxs() *cobra.Command { } flags.AddQueryFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "signer-set-txs") return cmd } @@ -226,16 +211,19 @@ func CmdBatchTxs() *cobra.Command { cmd := &cobra.Command{ Use: "batch-txs", Args: cobra.NoArgs, - Short: "", // TODO(levi) provide short description + Short: "query all the batch transactions from the chain", RunE: func(cmd *cobra.Command, args []string) error { clientCtx, queryClient, err := newContextAndQueryClient(cmd) if err != nil { return err } - req := types.BatchTxsRequest{} + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } - res, err := queryClient.BatchTxs(cmd.Context(), &req) + res, err := queryClient.BatchTxs(cmd.Context(), &types.BatchTxsRequest{Pagination: pageReq}) if err != nil { return err } @@ -245,6 +233,7 @@ func CmdBatchTxs() *cobra.Command { } flags.AddQueryFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "batch-txs") return cmd } @@ -252,16 +241,19 @@ func CmdContractCallTxs() *cobra.Command { cmd := &cobra.Command{ Use: "contract-call-txs", Args: cobra.NoArgs, - Short: "", // TODO(levi) provide short description + Short: "query all contract call transactions from the chain", RunE: func(cmd *cobra.Command, args []string) error { clientCtx, queryClient, err := newContextAndQueryClient(cmd) if err != nil { return err } - req := types.ContractCallTxsRequest{} + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } - res, err := queryClient.ContractCallTxs(cmd.Context(), &req) + res, err := queryClient.ContractCallTxs(cmd.Context(), &types.ContractCallTxsRequest{Pagination: pageReq}) if err != nil { return err } @@ -271,29 +263,29 @@ func CmdContractCallTxs() *cobra.Command { } flags.AddQueryFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "contract-call-txs") return cmd } func CmdSignerSetTxConfirmations() *cobra.Command { cmd := &cobra.Command{ Use: "signer-set-tx-ethereum-signatures [nonce]", - Args: cobra.ExactArgs(2), - Short: "", // TODO(levi) provide short description + Args: cobra.ExactArgs(1), + Short: "query signer set transaction signatures from the validators identified by nonce", RunE: func(cmd *cobra.Command, args []string) error { clientCtx, queryClient, err := newContextAndQueryClient(cmd) if err != nil { return err } - var ( // args - nonce uint64 // TODO(levi) init and validate from args[0] - ) - - req := types.SignerSetTxConfirmationsRequest{ - SignerSetNonce: nonce, + nonce, err := parseNonce(args[0]) + if err != nil { + return err } - res, err := queryClient.SignerSetTxConfirmations(cmd.Context(), &req) + res, err := queryClient.SignerSetTxConfirmations(cmd.Context(), &types.SignerSetTxConfirmationsRequest{ + SignerSetNonce: nonce, + }) if err != nil { return err } @@ -309,34 +301,29 @@ func CmdSignerSetTxConfirmations() *cobra.Command { func CmdBatchTxConfirmations() *cobra.Command { cmd := &cobra.Command{ Use: "batch-tx-ethereum-signatures [nonce] [contract-address]", - Args: cobra.MinimumNArgs(2), - Short: "", // TODO(levi) provide short description + Args: cobra.ExactArgs(2), + Short: "query signatures for a given batch transaction identified by nonce and contract", RunE: func(cmd *cobra.Command, args []string) error { clientCtx, queryClient, err := newContextAndQueryClient(cmd) if err != nil { return err } - var ( // args - nonce uint64 - contractAddress string - ) - - if nonce, err = parseNonce(args[0]); err != nil { + nonce, err := parseNonce(args[0]) + if err != nil { return err } - contractAddress, err = parseContractAddress(args[1]) + contractAddress, err := parseContractAddress(args[1]) if err != nil { return nil } - req := types.BatchTxConfirmationsRequest{ + res, err := queryClient.BatchTxConfirmations(cmd.Context(), &types.BatchTxConfirmationsRequest{ BatchNonce: nonce, TokenContract: contractAddress, - } + }) - res, err := queryClient.BatchTxConfirmations(cmd.Context(), &req) if err != nil { return err } @@ -353,24 +340,26 @@ func CmdContractCallTxConfirmations() *cobra.Command { cmd := &cobra.Command{ Use: "contract-call-tx-ethereum-signatures [invalidation-scope] [invalidation-nonce]", Args: cobra.MinimumNArgs(2), - Short: "", // TODO(levi) provide short description + Short: "query signatures for a given contract call transaction identified by invalidation nonce and invalidation scope", RunE: func(cmd *cobra.Command, args []string) error { clientCtx, queryClient, err := newContextAndQueryClient(cmd) if err != nil { return err } - var ( // args - invalidationScope []byte // TODO(levi) init and validate from args[0] - invalidationNonce uint64 // TODO(levi) init and validate from args[1] - ) + // TODO: some sort of validation here? + invalidationScope := []byte(args[0]) + + invalidationNonce, err := parseNonce(args[1]) + if err != nil { + return err + } - req := types.ContractCallTxConfirmationsRequest{ + res, err := queryClient.ContractCallTxConfirmations(cmd.Context(), &types.ContractCallTxConfirmationsRequest{ InvalidationNonce: invalidationNonce, InvalidationScope: invalidationScope, - } + }) - res, err := queryClient.ContractCallTxConfirmations(cmd.Context(), &req) if err != nil { return err } @@ -385,24 +374,24 @@ func CmdContractCallTxConfirmations() *cobra.Command { func CmdUnsignedSignerSetTxs() *cobra.Command { cmd := &cobra.Command{ - Use: "pending-signer-set-tx-ethereum-signatures [validator-or-orchestrator-address]", + Use: "pending-signer-set-tx-ethereum-signatures [validator-or-orchestrator-acc-address]", Args: cobra.ExactArgs(1), - Short: "", // TODO(levi) provide short description + Short: "query signatures for any pending signer set transactions given a validator or orchestrator address (sdk.AccAddress format)", RunE: func(cmd *cobra.Command, args []string) error { clientCtx, queryClient, err := newContextAndQueryClient(cmd) if err != nil { return err } - var ( // args - address string // TODO(levi) init and validate from args[0] - ) - - req := types.UnsignedSignerSetTxsRequest{ - Address: address, + address, err := sdk.AccAddressFromBech32(args[0]) + if err != nil { + return err } - res, err := queryClient.UnsignedSignerSetTxs(cmd.Context(), &req) + res, err := queryClient.UnsignedSignerSetTxs(cmd.Context(), &types.UnsignedSignerSetTxsRequest{ + Address: address.String(), + }) + if err != nil { return err } @@ -417,24 +406,24 @@ func CmdUnsignedSignerSetTxs() *cobra.Command { func CmdUnsignedBatchTxs() *cobra.Command { cmd := &cobra.Command{ - Use: "pending-batch-tx-ethereum-signatures [address]", + Use: "pending-batch-tx-ethereum-signatures [validator-or-orchestrator-acc-address]", Args: cobra.ExactArgs(1), - Short: "", // TODO(levi) provide short description + Short: "query signatures for any pending batch transactions given a validator or orchestrator address (sdk.AccAddress format)", RunE: func(cmd *cobra.Command, args []string) error { clientCtx, queryClient, err := newContextAndQueryClient(cmd) if err != nil { return err } - var ( // args - address string // TODO(levi) init and validate from args[0] - ) - - req := types.UnsignedBatchTxsRequest{ - Address: address, + address, err := sdk.AccAddressFromBech32(args[0]) + if err != nil { + return err } - res, err := queryClient.UnsignedBatchTxs(cmd.Context(), &req) + res, err := queryClient.UnsignedBatchTxs(cmd.Context(), &types.UnsignedBatchTxsRequest{ + Address: address.String(), + }) + if err != nil { return err } @@ -449,24 +438,24 @@ func CmdUnsignedBatchTxs() *cobra.Command { func CmdUnsignedContractCallTxs() *cobra.Command { cmd := &cobra.Command{ - Use: "pending-contract-call-tx-ethereum-signatures [address]", + Use: "pending-contract-call-tx-ethereum-signatures [validator-or-orchestrator-acc-address]", Args: cobra.ExactArgs(1), - Short: "", // TODO(levi) provide short description + Short: "query signatures for any pending contract call transactions given a validator or orchestrator address (sdk.AccAddress format)", RunE: func(cmd *cobra.Command, args []string) error { clientCtx, queryClient, err := newContextAndQueryClient(cmd) if err != nil { return err } - var ( // args - address string // TODO(levi) init and validate from args[0] - ) - - req := types.UnsignedContractCallTxsRequest{ - Address: address, + address, err := sdk.AccAddressFromBech32(args[0]) + if err != nil { + return err } - res, err := queryClient.UnsignedContractCallTxs(cmd.Context(), &req) + res, err := queryClient.UnsignedContractCallTxs(cmd.Context(), &types.UnsignedContractCallTxsRequest{ + Address: address.String(), + }) + if err != nil { return err } @@ -481,24 +470,24 @@ func CmdUnsignedContractCallTxs() *cobra.Command { func CmdLastSubmittedEthereumEvent() *cobra.Command { cmd := &cobra.Command{ - Use: "last-submitted-ethereum-event [address]", + Use: "last-submitted-ethereum-event [validator-or-orchestrator-acc-address]", Args: cobra.ExactArgs(1), - Short: "", // TODO(levi) provide short description + Short: "query for the last event nonce that was submitted by a given validator", RunE: func(cmd *cobra.Command, args []string) error { clientCtx, queryClient, err := newContextAndQueryClient(cmd) if err != nil { return err } - var ( // args - address string // TODO(levi) init and validate from args[0] - ) - - req := types.LastSubmittedEthereumEventRequest{ - Address: address, // TODO(levi) what kind of address is this?? + address, err := sdk.AccAddressFromBech32(args[0]) + if err != nil { + return err } - res, err := queryClient.LastSubmittedEthereumEvent(cmd.Context(), &req) + res, err := queryClient.LastSubmittedEthereumEvent(cmd.Context(), &types.LastSubmittedEthereumEventRequest{ + Address: address.String(), + }) + if err != nil { return err } @@ -511,20 +500,19 @@ func CmdLastSubmittedEthereumEvent() *cobra.Command { return cmd } +// TODO: this looks broken func CmdBatchTxFees() *cobra.Command { cmd := &cobra.Command{ Use: "batch-tx-fees", Args: cobra.NoArgs, - Short: "", // TODO(levi) provide short description + Short: "query amount of fees for any unrelayed batches", RunE: func(cmd *cobra.Command, args []string) error { clientCtx, queryClient, err := newContextAndQueryClient(cmd) if err != nil { return err } - req := types.BatchTxFeesRequest{} - - res, err := queryClient.BatchTxFees(cmd.Context(), &req) + res, err := queryClient.BatchTxFees(cmd.Context(), &types.BatchTxFeesRequest{}) if err != nil { return err } @@ -541,22 +529,22 @@ func CmdERC20ToDenom() *cobra.Command { cmd := &cobra.Command{ Use: "erc20-to-denom [erc20]", Args: cobra.ExactArgs(1), - Short: "", // TODO(levi) provide short description + Short: "given an erc20 contract address return the cosmos denom", RunE: func(cmd *cobra.Command, args []string) error { clientCtx, queryClient, err := newContextAndQueryClient(cmd) if err != nil { return err } - var ( // args - erc20 string // TODO(levi) init and validate from args[0] - ) - - req := types.ERC20ToDenomRequest{ - Erc20: erc20, // TODO(levi) is this an ethereum address?? + contract, err := parseContractAddress(args[0]) + if err != nil { + return err } - res, err := queryClient.ERC20ToDenom(cmd.Context(), &req) + res, err := queryClient.ERC20ToDenom(cmd.Context(), &types.ERC20ToDenomRequest{ + Erc20: contract, + }) + if err != nil { return err } @@ -573,22 +561,21 @@ func CmdDenomToERC20() *cobra.Command { cmd := &cobra.Command{ Use: "denom-to-erc20 [denom]", Args: cobra.ExactArgs(1), - Short: "", // TODO(levi) provide short description + Short: "given a cosmos denom return an erc20 contract address", RunE: func(cmd *cobra.Command, args []string) error { clientCtx, queryClient, err := newContextAndQueryClient(cmd) if err != nil { return err } - var ( // args - denom string // TODO(levi) init and validate from args[0] - ) - - req := types.DenomToERC20Request{ - Denom: denom, // TODO(levi) do we validate denoms?? if so, how? + if err := sdk.ValidateDenom(args[0]); err != nil { + return err } - res, err := queryClient.DenomToERC20(cmd.Context(), &req) + res, err := queryClient.DenomToERC20(cmd.Context(), &types.DenomToERC20Request{ + Denom: args[0], + }) + if err != nil { return err } @@ -605,22 +592,28 @@ func CmdUnbatchedSendToEthereums() *cobra.Command { cmd := &cobra.Command{ Use: "unbatched-send-to-ethereums [sender-address]", Args: cobra.MaximumNArgs(1), - Short: "", // TODO(levi) provide short description + Short: "query all unbatched send to ethereum messages", RunE: func(cmd *cobra.Command, args []string) error { clientCtx, queryClient, err := newContextAndQueryClient(cmd) if err != nil { return err } - var ( // args - senderAddress string // TODO(levi) init and validate from args[0] - ) + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } - req := types.UnbatchedSendToEthereumsRequest{ - SenderAddress: senderAddress, // TODO(levi) is this an ethereum address?? + sender, err := sdk.AccAddressFromBech32(args[0]) + if err != nil { + return err } - res, err := queryClient.UnbatchedSendToEthereums(cmd.Context(), &req) + res, err := queryClient.UnbatchedSendToEthereums(cmd.Context(), &types.UnbatchedSendToEthereumsRequest{ + SenderAddress: sender.String(), + Pagination: pageReq, + }) + if err != nil { return err } @@ -630,6 +623,7 @@ func CmdUnbatchedSendToEthereums() *cobra.Command { } flags.AddQueryFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "unbatched-send-to-ethereums") return cmd } @@ -637,20 +631,22 @@ func CmdDelegateKeysByValidator() *cobra.Command { cmd := &cobra.Command{ Use: "delegate-keys-by-validator [validator-address]", Args: cobra.ExactArgs(1), - Short: "", // TODO(levi) provide short description + Short: "query which public keys/addresses a validator has delegated to", RunE: func(cmd *cobra.Command, args []string) error { clientCtx, queryClient, err := newContextAndQueryClient(cmd) if err != nil { return err } - validatorAddress := args[0] - - req := types.DelegateKeysByValidatorRequest{ - ValidatorAddress: validatorAddress, + validatorAddress, err := sdk.ValAddressFromBech32(args[0]) + if err != nil { + return err } - res, err := queryClient.DelegateKeysByValidator(cmd.Context(), &req) + res, err := queryClient.DelegateKeysByValidator(cmd.Context(), &types.DelegateKeysByValidatorRequest{ + ValidatorAddress: validatorAddress.String(), + }) + if err != nil { return err } @@ -667,20 +663,20 @@ func CmdDelegateKeysByEthereumSigner() *cobra.Command { cmd := &cobra.Command{ Use: "delegate-keys-by-ethereum-signer [ethereum-signer]", Args: cobra.ExactArgs(1), - Short: "", // TODO(levi) provide short description + Short: "query the valdiator and orchestartor keys for a given ethsigner", RunE: func(cmd *cobra.Command, args []string) error { clientCtx, queryClient, err := newContextAndQueryClient(cmd) if err != nil { return err } - ethereumSigner := args[0] // TODO(levi) init and validate from args[0] - - req := types.DelegateKeysByEthereumSignerRequest{ - EthereumSigner: ethereumSigner, + if !common.IsHexAddress(args[0]) { + return fmt.Errorf("address is not an etheruem address") } - res, err := queryClient.DelegateKeysByEthereumSigner(cmd.Context(), &req) + res, err := queryClient.DelegateKeysByEthereumSigner(cmd.Context(), &types.DelegateKeysByEthereumSignerRequest{ + EthereumSigner: args[0], + }) if err != nil { return err } @@ -697,20 +693,22 @@ func CmdDelegateKeysByOrchestrator() *cobra.Command { cmd := &cobra.Command{ Use: "delegate-keys-by-orchestrator [orchestrator-address]", Args: cobra.ExactArgs(1), - Short: "", // TODO(levi) provide short description + Short: "query the validator and eth signer keys for a given orchestrator address", RunE: func(cmd *cobra.Command, args []string) error { clientCtx, queryClient, err := newContextAndQueryClient(cmd) if err != nil { return err } - orcAddr := args[0] - - req := types.DelegateKeysByOrchestratorRequest{ - OrchestratorAddress: orcAddr, + orcAddr, err := sdk.AccAddressFromBech32(args[0]) + if err != nil { + return err } - res, err := queryClient.DelegateKeysByOrchestrator(cmd.Context(), &req) + res, err := queryClient.DelegateKeysByOrchestrator(cmd.Context(), &types.DelegateKeysByOrchestratorRequest{ + OrchestratorAddress: orcAddr.String(), + }) + if err != nil { return err } @@ -723,21 +721,18 @@ func CmdDelegateKeysByOrchestrator() *cobra.Command { return cmd } - func CmdDelegateKeys() *cobra.Command { cmd := &cobra.Command{ Use: "all-delegate-keys", Args: cobra.NoArgs, - Short: "", // TODO(levi) provide short description + Short: "query all delegate keys tracked by the chain", RunE: func(cmd *cobra.Command, args []string) error { clientCtx, queryClient, err := newContextAndQueryClient(cmd) if err != nil { return err } - req := types.DelegateKeysRequest{} - - res, err := queryClient.DelegateKeys(cmd.Context(), &req) + res, err := queryClient.DelegateKeys(cmd.Context(), &types.DelegateKeysRequest{}) if err != nil { return err } @@ -750,7 +745,6 @@ func CmdDelegateKeys() *cobra.Command { return cmd } - func newContextAndQueryClient(cmd *cobra.Command) (client.Context, types.QueryClient, error) { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { diff --git a/module/x/gravity/client/cli/tx.go b/module/x/gravity/client/cli/tx.go index b949c73cd..b2629b181 100644 --- a/module/x/gravity/client/cli/tx.go +++ b/module/x/gravity/client/cli/tx.go @@ -2,6 +2,7 @@ package cli import ( "fmt" + "strconv" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" @@ -68,6 +69,7 @@ func CmdSendToEthereum() *cobra.Command { if err = msg.ValidateBasic(); err != nil { return err } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) }, } @@ -78,9 +80,9 @@ func CmdSendToEthereum() *cobra.Command { func CmdCancelSendToEthereum() *cobra.Command { cmd := &cobra.Command{ - Use: "cancel-send-to-etheruem [id]", // TODO(levi) this argument name is vague (but matches what we call it everywhere) + Use: "cancel-send-to-etheruem [id]", Args: cobra.ExactArgs(2), - Short: "", // TODO(levi) provide short description + Short: "Cancel ethereum send by id", RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -92,14 +94,16 @@ func CmdCancelSendToEthereum() *cobra.Command { return fmt.Errorf("must pass from flag") } - var ( // args - id uint64 // TODO(levi) init from args[0] - ) + id, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return err + } msg := types.NewMsgCancelSendToEthereum(id, from) if err = msg.ValidateBasic(); err != nil { return err } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) }, } @@ -112,17 +116,18 @@ func CmdRequestBatchTx() *cobra.Command { cmd := &cobra.Command{ Use: "request-batch-tx [denom] [signer]", Args: cobra.ExactArgs(2), - Short: "", // TODO(levi) provide short description + Short: "Request batch transaction for denom by signer", RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err } - var ( - denom string // TODO(levi) init and validate from args[0] - signer sdk.AccAddress // TODO(levi) init and validate from args[1] - ) + denom := args[0] + signer, err := sdk.AccAddressFromHex(args[1]) + if err != nil { + return err + } msg := types.NewMsgRequestBatchTx(denom, signer) if err = msg.ValidateBasic(); err != nil { @@ -147,15 +152,18 @@ func CmdSetDelegateKeys() *cobra.Command { return err } - valAddr, err := sdk.ValAddressFromHex(args[0]) + valAddr, err := sdk.ValAddressFromBech32(args[0]) + if err != nil { + return err + } + orcAddr, err := sdk.AccAddressFromBech32(args[1]) if err != nil { return err } - orcAddr, err := sdk.AccAddressFromHex(args[1]) + ethAddr, err := parseContractAddress(args[2]) if err != nil { return err } - ethAddr := args[2] msg := types.NewMsgDelegateKeys(valAddr, orcAddr, ethAddr) if err = msg.ValidateBasic(); err != nil { @@ -168,43 +176,3 @@ func CmdSetDelegateKeys() *cobra.Command { flags.AddTxFlagsToCmd(cmd) return cmd } - -// func CmdUnsafeETHPrivKey() *cobra.Command { -// return &cobra.Command{ -// Use: "gen-eth-key", -// Short: "Generate and print a new ecdsa key", -// RunE: func(cmd *cobra.Command, args []string) error { -// key, err := ethCrypto.GenerateKey() -// if err != nil { -// return sdkerrors.Wrap(err, "can not generate key") -// } -// k := "0x" + hex.EncodeToString(ethCrypto.FromECDSA(key)) -// println(k) -// return nil -// }, -// } -// } - -// func CmdUnsafeETHAddr() *cobra.Command { -// return &cobra.Command{ -// Use: "eth-address", -// Short: "Print address for an ECDSA eth key", -// Args: cobra.ExactArgs(1), -// RunE: func(cmd *cobra.Command, args []string) error { -// privKeyString := args[0][2:] -// privateKey, err := ethCrypto.HexToECDSA(privKeyString) -// if err != nil { -// log.Fatal(err) -// } -// // You've got to do all this to get an Eth address from the private key -// publicKey := privateKey.Public() -// publicKeyECDSA, ok := publicKey.(*ecdsa.PublicKey) -// if !ok { -// log.Fatal("error casting public key to ECDSA") -// } -// ethAddress := ethCrypto.PubkeyToAddress(*publicKeyECDSA).Hex() -// println(ethAddress) -// return nil -// }, -// } -// } diff --git a/module/x/gravity/keeper/grpc_query.go b/module/x/gravity/keeper/grpc_query.go index afacd1024..fceb70fb6 100644 --- a/module/x/gravity/keeper/grpc_query.go +++ b/module/x/gravity/keeper/grpc_query.go @@ -283,6 +283,9 @@ func (k Keeper) BatchTxFees(c context.Context, req *types.BatchTxFeesRequest) (* ctx := sdk.UnwrapSDKContext(c) res := &types.BatchTxFeesResponse{} + // TODO: is this what we want here? + // Should this calculation return a + // map[contract_address]fees or something similar? k.IterateOutgoingTxsByType(ctx, types.BatchTxPrefixByte, func(key []byte, otx types.OutgoingTx) bool { btx, _ := otx.(*types.BatchTx) for _, tx := range btx.Transactions { @@ -411,4 +414,3 @@ func (k Keeper) DelegateKeys(c context.Context, req *types.DelegateKeysRequest) } return res, nil } -