From 36d908c19bdd77fcd5efa9b5ce1dedf498213d76 Mon Sep 17 00:00:00 2001
From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com>
Date: Mon, 18 Sep 2023 17:18:51 +0200
Subject: [PATCH] feat: add query qgb evm address by valoper address command
(backport #2524) (#2527)
This is an automatic backport of pull request #2524 done by
[Mergify](https://mergify.com).
---
Mergify commands and options
More conditions and actions can be found in the
[documentation](https://docs.mergify.com/).
You can also trigger Mergify actions by commenting on this pull request:
- `@Mergifyio refresh` will re-evaluate the rules
- `@Mergifyio rebase` will rebase this PR on its base branch
- `@Mergifyio update` will merge the base branch into this PR
- `@Mergifyio backport ` will backport this PR on
`` branch
Additionally, on Mergify [dashboard](https://dashboard.mergify.com) you
can:
- look at your merge queues
- generate the Mergify configuration with the config editor.
Finally, you can contact us on https://mergify.com
Co-authored-by: CHAMI Rachid
---
x/qgb/client/query.go | 31 ++++++++++++++++++++++++++++++-
x/qgb/types/errors.go | 1 +
2 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/x/qgb/client/query.go b/x/qgb/client/query.go
index 1ba2ec12d8..5a45b6d1b7 100644
--- a/x/qgb/client/query.go
+++ b/x/qgb/client/query.go
@@ -24,7 +24,7 @@ func GetQueryCmd() *cobra.Command {
RunE: client.ValidateCmd,
}
- cmd.AddCommand(CmdQueryAttestationByNonce())
+ cmd.AddCommand(CmdQueryAttestationByNonce(), CmdQueryEVMAddress())
return cmd
}
@@ -76,6 +76,35 @@ func CmdQueryAttestationByNonce() *cobra.Command {
return cmd
}
+func CmdQueryEVMAddress() *cobra.Command {
+ cmd := &cobra.Command{
+ Use: "evm ",
+ Short: "query the evm address corresponding to a validator bech32 valoper address",
+ Args: cobra.ExactArgs(1),
+ RunE: func(cmd *cobra.Command, args []string) error {
+ clientCtx := client.GetClientContextFromCmd(cmd)
+ queryClient := types.NewQueryClient(clientCtx)
+
+ res, err := queryClient.EVMAddress(
+ cmd.Context(),
+ &types.QueryEVMAddressRequest{ValidatorAddress: args[0]},
+ )
+ if err != nil {
+ return err
+ }
+ if res.EvmAddress == "" {
+ return types.ErrEVMAddressNotFound
+ }
+ fmt.Println(res.EvmAddress)
+ return nil
+ },
+ }
+
+ flags.AddQueryFlagsToCmd(cmd)
+
+ return cmd
+}
+
// unmarshallAttestation unmarshal a wrapper protobuf `Any` type to an `AttestationRequestI`.
func unmarshallAttestation(attestation *codectypes.Any) (types.AttestationRequestI, error) {
var unmarshalledAttestation types.AttestationRequestI
diff --git a/x/qgb/types/errors.go b/x/qgb/types/errors.go
index 626d76eed7..fdb73e33da 100644
--- a/x/qgb/types/errors.go
+++ b/x/qgb/types/errors.go
@@ -26,4 +26,5 @@ var (
ErrUnknownAttestationType = errors.Register(ModuleName, 35, "unknown attestation type")
ErrEVMAddressNotHex = errors.Register(ModuleName, 36, "the provided evm address is not a valid hex address")
ErrEVMAddressAlreadyExists = errors.Register(ModuleName, 37, "the provided evm address already exists")
+ ErrEVMAddressNotFound = errors.Register(ModuleName, 38, "EVM address not found")
)