-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
89735b0
commit 02e5d44
Showing
10 changed files
with
523 additions
and
222 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package cmd | ||
|
||
const FLAG_HOME = "home" |
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,92 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"os" | ||
|
||
"github.com/JackalLabs/mulberry/relay" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func RootCMD() *cobra.Command { | ||
r := &cobra.Command{ | ||
Use: "mulberry", | ||
Short: "Mulberry is a Jackal EVM Relay", | ||
Long: `Mulberry is a Jackal EVM Relay that delivers packets from | ||
EVM chains to the Jackal network ot bridge storage capabilities cross-chain.`, | ||
} | ||
|
||
r.AddCommand(StartCMD(), WalletCMD()) | ||
|
||
r.PersistentFlags().String(FLAG_HOME, "$HOME/.mulberry", "where the mulberry config can be found") | ||
|
||
return r | ||
} | ||
|
||
func StartCMD() *cobra.Command { | ||
r := &cobra.Command{ | ||
Use: "start", | ||
Short: "Starts the Mulberry Relay service", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
home, err := getHome(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
a, err := relay.MakeApp(home) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
log.Print("Starting relay...") | ||
|
||
return a.Start() | ||
}, | ||
} | ||
|
||
return r | ||
} | ||
|
||
func WalletCMD() *cobra.Command { | ||
r := &cobra.Command{ | ||
Use: "wallet", | ||
Short: "Commands to manage the internal wallet", | ||
} | ||
r.AddCommand(AddressCMD()) | ||
|
||
return r | ||
} | ||
|
||
func getHome(cmd *cobra.Command) (string, error) { | ||
home, err := cmd.Flags().GetString(FLAG_HOME) | ||
if err != nil { | ||
return home, err | ||
} | ||
|
||
return os.ExpandEnv(home), nil | ||
} | ||
|
||
func AddressCMD() *cobra.Command { | ||
r := &cobra.Command{ | ||
Use: "address", | ||
Short: "View the relay address", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
home, err := getHome(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
a, err := relay.MakeApp(home) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
fmt.Printf("Wallet Address: %s\n", a.Address()) | ||
|
||
return nil | ||
}, | ||
} | ||
|
||
return r | ||
} |
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,54 @@ | ||
package config | ||
|
||
import ( | ||
_ "github.com/mitchellh/mapstructure" | ||
"gopkg.in/yaml.v3" | ||
) | ||
|
||
type Config struct { | ||
JackalConfig JackalConfig `yaml:"jackal_config" mapstructure:"jackal_config"` | ||
NetworksConfig []NetworkConfig `yaml:"networks_config" mapstructure:"networks_config"` | ||
} | ||
|
||
type JackalConfig struct { | ||
RPC string `yaml:"rpc" mapstructure:"rpc"` | ||
GRPC string `yaml:"grpc" mapstructure:"grpc"` | ||
SeedFile string `yaml:"seed_file" mapstructure:"seed_file"` | ||
Contract string `yaml:"contract" mapstructure:"contract"` | ||
} | ||
|
||
type NetworkConfig struct { | ||
Name string `yaml:"name" mapstructure:"name"` | ||
RPC string `yaml:"rpc" mapstructure:"rpc"` | ||
Contract string `yaml:"contract" mapstructure:"contract"` | ||
ChainID int64 `yaml:"chain_id" mapstructure:"chain_id"` | ||
} | ||
|
||
func DefaultConfig() Config { | ||
return Config{ | ||
JackalConfig: JackalConfig{ | ||
RPC: "https://testnet-rpc.jackalprotocol.com:443", | ||
GRPC: "jackal-testnet-grpc.polkachu.com:17590", | ||
SeedFile: "seed.json", | ||
Contract: "jkl1tjaqmxerltfqgxwp5p9sdwr9hncmdvevg9mllac2qjqfrjte6wkqwnq3h9", | ||
}, | ||
NetworksConfig: []NetworkConfig{ | ||
{ | ||
Name: "Ethereum Sepolia", | ||
RPC: "wss://ethereum-sepolia-rpc.publicnode.com", | ||
Contract: "0x730fdF2ee985Ac0F7792f90cb9e1E5485d340208", | ||
ChainID: 11155111, | ||
}, | ||
{ | ||
Name: "Base Sepolia", | ||
RPC: "wss://base-sepolia-rpc.publicnode.com", | ||
Contract: "0x20738B8eaB736f24c7881bA48263ee60Eb2a0A2a", | ||
ChainID: 84532, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func (c Config) Export() ([]byte, error) { | ||
return yaml.Marshal(c) | ||
} |
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
Oops, something went wrong.