-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added key generation ability to roller init (#6)
- Loading branch information
1 parent
e3a93ed
commit de1e2c0
Showing
5 changed files
with
1,054 additions
and
11 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,14 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var configCmd = &cobra.Command{ | ||
Use: "config", | ||
Short: "Commands for setting up and managing rollapp configuration files.", | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(configCmd) | ||
} |
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,74 @@ | ||
package cmd | ||
|
||
import ( | ||
"os" | ||
"path" | ||
"path/filepath" | ||
|
||
"github.com/cosmos/cosmos-sdk/crypto/hd" | ||
"github.com/cosmos/cosmos-sdk/crypto/keyring" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
const hubRPC string = "https://rpc-hub-35c.dymension.xyz:443" | ||
const lightNodeEndpointFlag = "light-node-endpoint" | ||
const evmCoinType uint32 = 60 | ||
const rollappConfigDir string = ".rollapp" | ||
const relayerConfigDir string = ".relayer" | ||
const hubChainId string = "internal-devnet" | ||
const relayerKeysDirName string = "keys" | ||
|
||
func createKey(relativePath string, keyId string, coinType ...uint32) (keyring.Info, error) { | ||
const cosmosDefaultCointype uint32 = 118 | ||
var coinTypeVal = cosmosDefaultCointype | ||
if len(coinType) != 0 { | ||
coinTypeVal = coinType[0] | ||
} | ||
rollappAppName := "rollapp" | ||
kr, err := keyring.New( | ||
rollappAppName, | ||
keyring.BackendTest, | ||
filepath.Join(os.Getenv("HOME"), relativePath), | ||
nil, | ||
) | ||
if err != nil { | ||
return nil, err | ||
} | ||
bip44Params := hd.NewFundraiserParams(0, coinTypeVal, 0) | ||
info, _, err := kr.NewMnemonic(keyId, keyring.English, bip44Params.String(), "", hd.Secp256k1) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return info, nil | ||
} | ||
|
||
func generateRollappKeys() (keyring.Info, error) { | ||
return createKey(".rollapp", "rollapp_sequencer") | ||
} | ||
|
||
var initCmd = &cobra.Command{ | ||
Use: "init <chain-id>", | ||
Short: "Initialize a rollapp configuration on your local machine", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
createKey(rollappConfigDir, "hub_sequencer") | ||
createKey(rollappConfigDir, "rollapp_sequencer", evmCoinType) | ||
relayerRollappDir := path.Join(relayerConfigDir, relayerKeysDirName, args[0]) | ||
relayerHubDir := path.Join(relayerConfigDir, relayerKeysDirName, hubChainId) | ||
createKey(relayerHubDir, "relayer-hub-key") | ||
createKey(relayerRollappDir, "relayer-rollapp-key", evmCoinType) | ||
if !cmd.Flags().Changed(lightNodeEndpointFlag) { | ||
createKey(".light_node", "my-celes-key") | ||
} | ||
}, | ||
Args: cobra.ExactArgs(1), | ||
} | ||
|
||
func init() { | ||
configCmd.AddCommand(initCmd) | ||
initCmd.Flags().StringP("hub-rpc", "", hubRPC, "Dymension Hub rpc endpoint") | ||
initCmd.Flags().StringP(lightNodeEndpointFlag, "", "", "The data availability light node endpoint. Runs an Arabica Celestia light node if not provided.") | ||
initCmd.Flags().StringP("denom", "", "", "The rollapp token smallest denominator, for example `wei` in Ethereum.") | ||
initCmd.Flags().StringP("key-prefix", "", "", "The `bech32` prefix of the rollapp keys.") | ||
initCmd.Flags().StringP("rollapp-binary", "", "", "The rollapp binary. Should be passed only if you built a custom rollapp.") | ||
initCmd.Flags().Int64P("decimals", "", 18, "The number of decimal places a rollapp token supports.") | ||
} |
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 |
---|---|---|
@@ -1,9 +1,110 @@ | ||
module github.com/dymensionxyz/roller | ||
|
||
go 1.20 | ||
go 1.18 | ||
|
||
require ( | ||
github.com/dymensionxyz/dymension v0.2.0-beta | ||
github.com/gogo/protobuf v1.3.3 // indirect | ||
github.com/inconshreveable/mousetrap v1.1.0 // indirect | ||
github.com/spf13/cobra v1.7.0 // indirect | ||
github.com/spf13/cobra v1.7.0 | ||
github.com/spf13/pflag v1.0.5 // indirect | ||
) | ||
|
||
require github.com/cosmos/cosmos-sdk v0.45.10 | ||
|
||
require ( | ||
filippo.io/edwards25519 v1.0.0-beta.2 // indirect | ||
github.com/99designs/keyring v1.1.6 // indirect | ||
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect | ||
github.com/DataDog/zstd v1.4.5 // indirect | ||
github.com/armon/go-metrics v0.4.0 // indirect | ||
github.com/beorn7/perks v1.0.1 // indirect | ||
github.com/bgentry/speakeasy v0.1.0 // indirect | ||
github.com/btcsuite/btcd v0.22.1 // indirect | ||
github.com/cespare/xxhash v1.1.0 // indirect | ||
github.com/cespare/xxhash/v2 v2.1.2 // indirect | ||
github.com/confio/ics23/go v0.7.0 // indirect | ||
github.com/cosmos/btcutil v1.0.4 // indirect | ||
github.com/cosmos/go-bip39 v1.0.0 // indirect | ||
github.com/cosmos/gorocksdb v1.2.0 // indirect | ||
github.com/cosmos/iavl v0.19.3 // indirect | ||
github.com/cosmos/ibc-go/v3 v3.4.0 // indirect | ||
github.com/cosmos/ledger-cosmos-go v0.11.1 // indirect | ||
github.com/cosmos/ledger-go v0.9.2 // indirect | ||
github.com/danieljoos/wincred v1.0.2 // indirect | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/dgraph-io/badger/v2 v2.2007.2 // indirect | ||
github.com/dgraph-io/ristretto v0.0.3 // indirect | ||
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect | ||
github.com/dustin/go-humanize v1.0.1-0.20200219035652-afde56e7acac // indirect | ||
github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b // indirect | ||
github.com/fsnotify/fsnotify v1.5.4 // indirect | ||
github.com/go-kit/kit v0.12.0 // indirect | ||
github.com/go-kit/log v0.2.1 // indirect | ||
github.com/go-logfmt/logfmt v0.5.1 // indirect | ||
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect | ||
github.com/golang/protobuf v1.5.2 // indirect | ||
github.com/golang/snappy v0.0.3 // indirect | ||
github.com/google/btree v1.0.0 // indirect | ||
github.com/gorilla/mux v1.8.0 // indirect | ||
github.com/gorilla/websocket v1.5.0 // indirect | ||
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect | ||
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect | ||
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect | ||
github.com/gtank/merlin v0.1.1 // indirect | ||
github.com/gtank/ristretto255 v0.1.2 // indirect | ||
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect | ||
github.com/hashicorp/golang-lru v0.5.4 // indirect | ||
github.com/hashicorp/hcl v1.0.0 // indirect | ||
github.com/hdevalence/ed25519consensus v0.0.0-20210204194344-59a8610d2b87 // indirect | ||
github.com/jmhodges/levigo v1.0.0 // indirect | ||
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d // indirect | ||
github.com/libp2p/go-buffer-pool v0.1.0 // indirect | ||
github.com/magiconair/properties v1.8.6 // indirect | ||
github.com/mattn/go-isatty v0.0.16 // indirect | ||
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect | ||
github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 // indirect | ||
github.com/mitchellh/go-homedir v1.1.0 // indirect | ||
github.com/mitchellh/mapstructure v1.5.0 // indirect | ||
github.com/mtibben/percent v0.2.1 // indirect | ||
github.com/pelletier/go-toml v1.9.5 // indirect | ||
github.com/pelletier/go-toml/v2 v2.0.5 // indirect | ||
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect | ||
github.com/pkg/errors v0.9.1 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
github.com/prometheus/client_golang v1.12.2 // indirect | ||
github.com/prometheus/client_model v0.2.0 // indirect | ||
github.com/prometheus/common v0.34.0 // indirect | ||
github.com/prometheus/procfs v0.7.3 // indirect | ||
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect | ||
github.com/regen-network/cosmos-proto v0.3.1 // indirect | ||
github.com/sasha-s/go-deadlock v0.3.1 // indirect | ||
github.com/spf13/afero v1.8.2 // indirect | ||
github.com/spf13/cast v1.5.0 // indirect | ||
github.com/spf13/jwalterweatherman v1.1.0 // indirect | ||
github.com/spf13/viper v1.13.0 // indirect | ||
github.com/stretchr/testify v1.8.1 // indirect | ||
github.com/subosito/gotenv v1.4.1 // indirect | ||
github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca // indirect | ||
github.com/tendermint/btcd v0.1.1 // indirect | ||
github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 // indirect | ||
github.com/tendermint/go-amino v0.16.0 // indirect | ||
github.com/tendermint/tendermint v0.34.22 // indirect | ||
github.com/tendermint/tm-db v0.6.7 // indirect | ||
github.com/zondax/hid v0.9.0 // indirect | ||
go.etcd.io/bbolt v1.3.6 // indirect | ||
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect | ||
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect | ||
golang.org/x/net v0.0.0-20221014081412-f15817d10f9b // indirect | ||
golang.org/x/sys v0.0.0-20220818161305-2296e01440c6 // indirect | ||
golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 // indirect | ||
golang.org/x/text v0.4.0 // indirect | ||
google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 // indirect | ||
google.golang.org/grpc v1.51.0 // indirect | ||
google.golang.org/protobuf v1.28.1 // 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 | ||
) | ||
|
||
replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 |
Oops, something went wrong.