Skip to content

Commit

Permalink
multinet config
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMarstonConnell committed Sep 16, 2024
1 parent 89735b0 commit 02e5d44
Show file tree
Hide file tree
Showing 10 changed files with 523 additions and 222 deletions.
3 changes: 3 additions & 0 deletions cmd/flags.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package cmd

const FLAG_HOME = "home"
92 changes: 92 additions & 0 deletions cmd/root.go
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
}
54 changes: 54 additions & 0 deletions config/config.go
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)
}
50 changes: 24 additions & 26 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@ module github.com/JackalLabs/mulberry
go 1.23.0

require (
github.com/CosmWasm/wasmd v0.32.0
github.com/cosmos/cosmos-sdk v0.45.17
github.com/cosmos/go-bip39 v1.0.0
github.com/desmos-labs/cosmos-go-wallet v0.0.0-00010101000000-000000000000
github.com/ethereum/go-ethereum v1.13.15
github.com/jackalLabs/canine-chain/v4 v4.1.0-beta.2
github.com/joho/godotenv v1.5.1
github.com/mitchellh/mapstructure v1.5.0
github.com/spf13/cobra v1.7.0
github.com/spf13/viper v1.16.0
gopkg.in/yaml.v3 v3.0.1
)

require (
Expand All @@ -18,7 +23,6 @@ require (
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.1 // indirect
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect
github.com/CosmWasm/wasmd v0.32.0 // indirect
github.com/CosmWasm/wasmvm v1.2.6 // indirect
github.com/DataDog/zstd v1.5.2 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
Expand All @@ -45,7 +49,6 @@ require (
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/cosmos-db v0.0.0-20221226095112-f3c38ecb5e32 // indirect
github.com/cosmos/cosmos-proto v1.0.0-beta.3 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/gogoproto v1.4.12 // indirect
github.com/cosmos/gorocksdb v1.2.0 // indirect
github.com/cosmos/iavl v0.19.5 // indirect
Expand All @@ -55,7 +58,7 @@ require (
github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect
github.com/creachadair/taskgroup v0.3.2 // indirect
github.com/danieljoos/wincred v1.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/deckarep/golang-set/v2 v2.1.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
Expand All @@ -67,8 +70,8 @@ require (
github.com/dvsekhvalnov/jose2go v1.5.0 // indirect
github.com/ecies/go/v2 v2.0.6 // indirect
github.com/ethereum/c-kzg-4844 v0.4.0 // indirect
github.com/felixge/httpsnoop v1.0.2 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/getsentry/sentry-go v0.18.0 // indirect
github.com/go-kit/kit v0.12.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
Expand All @@ -78,8 +81,8 @@ require (
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/gogo/gateway v1.1.0 // indirect
github.com/gogo/protobuf v1.3.3 // indirect
github.com/golang/glog v1.1.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/glog v1.2.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/go-cmp v0.6.0 // indirect
Expand All @@ -102,27 +105,25 @@ require (
github.com/improbable-eng/grpc-web v0.15.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/klauspost/compress v1.16.3 // indirect
github.com/klauspost/compress v1.17.2 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/lib/pq v1.10.7 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/linxGnu/grocksdb v1.7.10 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 // indirect
github.com/minio/highwayhash v1.0.2 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/mtibben/percent v0.2.1 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.16.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
Expand All @@ -135,14 +136,12 @@ require (
github.com/rs/zerolog v1.29.1 // indirect
github.com/sasha-s/go-deadlock v0.3.1 // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
github.com/spf13/afero v1.9.2 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/cobra v1.7.0 // indirect
github.com/spf13/afero v1.10.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.14.0 // indirect
github.com/stretchr/testify v1.8.4 // indirect
github.com/subosito/gotenv v1.4.1 // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/supranational/blst v0.3.11 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect
Expand All @@ -160,20 +159,19 @@ require (
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.19.0 // indirect
google.golang.org/genproto v0.0.0-20231211222908-989df2bf70f3 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231120223509-83a465c0220f // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0 // indirect
google.golang.org/genproto v0.0.0-20240102182953-50ed04b92917 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240108191215-35c7eff3a6b1 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240108191215-35c7eff3a6b1 // indirect
google.golang.org/grpc v1.61.1 // indirect
google.golang.org/protobuf v1.32.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
nhooyr.io/websocket v1.8.7 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)
Expand Down
Loading

0 comments on commit 02e5d44

Please sign in to comment.