-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: hermes support for non-local chains (#41)
* feat: hermes support for non-local chains * feat: hermes support for non local chains * fix: sidebar links
- Loading branch information
Showing
9 changed files
with
250 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
package relayer | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/hanchon/hanchond/playground/hermes" | ||
"github.com/hanchon/hanchond/playground/sql" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// represents the addChainConfigCmd command | ||
var addChainConfigCmd = &cobra.Command{ | ||
Use: "add-chain-config", | ||
Args: cobra.ExactArgs(0), | ||
Short: "Add chain config to hermes, it is ignored if the chain id already exists", | ||
Run: func(cmd *cobra.Command, _ []string) { | ||
_ = sql.InitDBFromCmd(cmd) | ||
|
||
h := hermes.NewHermes() | ||
fmt.Println("Relayer initialized") | ||
|
||
chainID, err := cmd.Flags().GetString("chainid") | ||
if err != nil || chainID == "" { | ||
fmt.Println("missing chainid value") | ||
os.Exit(1) | ||
} | ||
|
||
p26657, err := cmd.Flags().GetString("p26657") | ||
if err != nil || chainID == "" { | ||
fmt.Println("missing p26657 value") | ||
os.Exit(1) | ||
} | ||
|
||
p9090, err := cmd.Flags().GetString("p9090") | ||
if err != nil || chainID == "" { | ||
fmt.Println("missing p9090 value") | ||
os.Exit(1) | ||
} | ||
|
||
keyname, err := cmd.Flags().GetString("keyname") | ||
if err != nil || chainID == "" { | ||
fmt.Println("missing keyname value") | ||
os.Exit(1) | ||
} | ||
|
||
keymnemonic, err := cmd.Flags().GetString("keymnemonic") | ||
if err != nil || chainID == "" { | ||
fmt.Println("missing keymnemonic value") | ||
os.Exit(1) | ||
} | ||
|
||
prefix, err := cmd.Flags().GetString("prefix") | ||
if err != nil || chainID == "" { | ||
fmt.Println("missing prefix value") | ||
os.Exit(1) | ||
} | ||
|
||
denom, err := cmd.Flags().GetString("denom") | ||
if err != nil || chainID == "" { | ||
fmt.Println("missing denom value") | ||
os.Exit(1) | ||
} | ||
|
||
isEvm, err := cmd.Flags().GetBool("is-evm") | ||
if err != nil || chainID == "" { | ||
fmt.Println("missing is-evm value") | ||
os.Exit(1) | ||
} | ||
|
||
switch isEvm { | ||
case false: | ||
fmt.Println("Adding a NOT EVM chain") | ||
if err := h.AddCosmosChain( | ||
chainID, | ||
p26657, | ||
p9090, | ||
keyname, | ||
keymnemonic, | ||
prefix, | ||
denom, | ||
); err != nil { | ||
fmt.Println("error adding first chain to the relayer:", err.Error()) | ||
os.Exit(1) | ||
} | ||
case true: | ||
fmt.Println("Adding a EVM chain") | ||
if err := h.AddEvmosChain( | ||
chainID, | ||
p26657, | ||
p9090, | ||
keyname, | ||
keymnemonic, | ||
prefix, | ||
denom, | ||
); err != nil { | ||
fmt.Println("error adding first chain to the relayer:", err.Error()) | ||
os.Exit(1) | ||
} | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
RelayerCmd.AddCommand(addChainConfigCmd) | ||
addChainConfigCmd.Flags().String("chainid", "", "Chain-id, i.e., evmos_9001-2") | ||
addChainConfigCmd.Flags().String("p26657", "", "Endpoint where the port 26657 is exposed, i.e., http://localhost:26657") | ||
addChainConfigCmd.Flags().String("p9090", "", "Endpoint where the port 9090 is exposed, i.e., http://localhost:9090") | ||
addChainConfigCmd.Flags().String("keyname", "", "Key name, it's used to identify the files inside hermes, i.e., relayerkey") | ||
addChainConfigCmd.Flags().String("keymnemonic", "", "Key mnemonic, mnemonic for the wallet") | ||
addChainConfigCmd.Flags().String("prefix", "", "Prefix for the bech32 address, i.e, osmo") | ||
addChainConfigCmd.Flags().String("denom", "", "Denom of the base token, i.e, aevmos") | ||
addChainConfigCmd.Flags().Bool("is-evm", false, "If the chain is evm compatible, this is used to determinate the type of wallet.") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package relayer | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/hanchon/hanchond/playground/hermes" | ||
"github.com/hanchon/hanchond/playground/sql" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// represents the createChannelCmd command | ||
var createChannelCmd = &cobra.Command{ | ||
Use: "create-channel [chain_id] [chain_id]", | ||
Args: cobra.ExactArgs(2), | ||
Short: "Create an IBC channel between two chains. The chains must be previously registered", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
_ = sql.InitDBFromCmd(cmd) | ||
|
||
h := hermes.NewHermes() | ||
fmt.Println("Relayer initialized") | ||
|
||
chain1 := args[0] | ||
chain2 := args[1] | ||
|
||
fmt.Println("Calling create channel") | ||
err := h.CreateChannel(chain1, chain2) | ||
if err != nil { | ||
fmt.Println("error creating channel", err.Error()) | ||
os.Exit(1) | ||
} | ||
fmt.Println("Channel created") | ||
}, | ||
} | ||
|
||
func init() { | ||
RelayerCmd.AddCommand(createChannelCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package relayer | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/hanchon/hanchond/playground/filesmanager" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// RelayerCmd represents the relayer command | ||
var RelayerCmd = &cobra.Command{ | ||
Use: "relayer", | ||
Aliases: []string{"r"}, | ||
Short: "Relayer related functions", | ||
Run: func(cmd *cobra.Command, _ []string) { | ||
filesmanager.SetHomeFolderFromCobraFlags(cmd) | ||
_ = cmd.Help() | ||
os.Exit(0) | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Add Chain Configuration | ||
|
||
To run a relayer between two chains, first you need to set up the configuration for both chains. | ||
|
||
If you are running with just local chains, the `hermesAddChannel` command takes care of everything. But if you need to communicate with chains that are outside the networks created by `hanchond`, you need to manually add both chains and call the `create-channel` command. | ||
|
||
## Parameters | ||
|
||
To add a configuration you must send the following parameters as flags: | ||
|
||
- `chainid`: Chain-id, i.e., `evmos_9001-2` | ||
- `p26657`: Endpoint where the port 26657 is exposed, i.e., `http://localhost:26657` | ||
- `p9090`: Endpoint where the port 9090 is exposed, i.e., `http://localhost:9090` | ||
- `keyname`: Key name, it's used to identify the files inside Hermes, i.e., `relayerkey` | ||
- `keymnemonic`: Key mnemonic, mnemonic for the wallet | ||
- `prefix`: Prefix for the bech32 address, i.e, `osmo` | ||
- `denom`: Denomination of the base token, i.e, `aevmos` | ||
- `is-evm`: If the chain is EVM compatible, this is used to determinate the type of wallet. | ||
|
||
```bash | ||
hanchond playground relayer add-chain-config \ | ||
--chainid=evmos_9001-2 \ | ||
--p26657=http://localhost:26657 \ | ||
--p9090=http://localhost:9090 \ | ||
--keyname=evmosrelayer \ | ||
--keymnemonic="attend recipe own funny garden fiber glad inherit loud skull kangaroo swing license visual learn explain economy best news sibling float video disorder prepare" \ | ||
--prefix="evmos" \ | ||
--denom="aevmos" \ | ||
--is-evm=true | ||
|
||
Relayer initialized | ||
Adding a EVM chain | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Create a Channel | ||
|
||
To send IBC transactions between two chains, an IBC channel must be created. | ||
|
||
After adding the two chain configs using the `addChainConfig` command, the `createChannel` command can be used. | ||
|
||
```bash | ||
hanchond playground relayer create-channel evmos_9001-1 cosmoshub-1 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters