diff --git a/node/go.mod b/node/go.mod index 0a254d3..b29356e 100644 --- a/node/go.mod +++ b/node/go.mod @@ -74,7 +74,8 @@ require ( github.com/go-kit/kit v0.12.0 // indirect github.com/go-kit/log v0.2.1 // indirect github.com/go-logfmt/logfmt v0.6.0 // indirect - github.com/gobwas/ws v1.1.0 // indirect + github.com/gobwas/httphead v0.1.0 // indirect + github.com/gobwas/pool v0.2.1 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gogo/googleapis v1.4.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect @@ -93,7 +94,6 @@ require ( github.com/hashicorp/go-immutable-radix v1.3.1 // indirect github.com/hashicorp/go-metrics v0.5.1 // indirect github.com/hashicorp/go-plugin v1.5.2 // indirect - github.com/hashicorp/go-uuid v1.0.2 // indirect github.com/hashicorp/golang-lru v1.0.2 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/hashicorp/yamux v0.1.1 // indirect diff --git a/node/go.sum b/node/go.sum index c720f34..95ddda3 100644 --- a/node/go.sum +++ b/node/go.sum @@ -284,10 +284,13 @@ github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/me github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU= +github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM= github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og= +github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= github.com/gobwas/ws v1.1.0 h1:7RFti/xnNkMJnrK7D1yQ/iCIB5OrrY/54/H930kIbHA= +github.com/gobwas/ws v1.1.0/go.mod h1:nzvNcVha5eUziGrbxFCo6qFIojQHjJV5cLYIbezhfL0= github.com/goccy/go-json v0.9.11 h1:/pAaQDLHEoCq/5FFmSKBswWmK6H0e8g4159Kc/X/nqk= github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0= @@ -430,6 +433,7 @@ github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdv github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2IGE= +github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= @@ -611,6 +615,7 @@ github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144T github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= +github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o= github.com/petermattis/goid v0.0.0-20230904192822-1876fd5063bc h1:8bQZVK1X6BJR/6nYUPxQEP+ReTsceJTKizeuwjWOPUA= diff --git a/node/keys.go b/node/keys.go index e04863a..e79e316 100644 --- a/node/keys.go +++ b/node/keys.go @@ -3,19 +3,21 @@ package node import ( "context" "fmt" - "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" petritypes "github.com/skip-mev/petri/types" "github.com/skip-mev/petri/util" "github.com/skip-mev/petri/wallet" - "os" - "path" ) func (n *Node) CreateWallet(ctx context.Context, name string) (petritypes.WalletI, error) { - keyWallet, err := wallet.NewGeneratedWallet(name, n.chain.GetConfig().Bech32Prefix) // todo: fix this to depend on WalletI + coinType, err := hd.NewParamsFromPath(n.chain.GetConfig().CoinType) + + if err != nil { + return nil, err + } + + keyWallet, err := wallet.NewGeneratedWallet(name, n.chain.GetConfig().Bech32Prefix, coinType) // todo: fix this to depend on WalletI if err != nil { return nil, err @@ -62,18 +64,3 @@ func (n *Node) KeyBech32(ctx context.Context, name, bech string) (string, error) return util.CleanDockerOutput(stdout), nil } - -func (n *Node) GetLocalKeyring(ctx context.Context, containerKeyringDir, localDirectory string) (keyring.Keyring, error) { - localDirectory = path.Join(localDirectory) - - err := n.Task.DownloadDir(ctx, containerKeyringDir, path.Join(localDirectory, "keyring-test")) - if err != nil { - return nil, err - } - - registry := codectypes.NewInterfaceRegistry() - cryptocodec.RegisterInterfaces(registry) - cdc := codec.NewProtoCodec(registry) - - return keyring.New("", keyring.BackendTest, localDirectory, os.Stdin, cdc) -} diff --git a/types/wallet.go b/types/wallet.go index 7f7fcdd..7d21b8c 100644 --- a/types/wallet.go +++ b/types/wallet.go @@ -9,4 +9,5 @@ type WalletI interface { FormattedAddressWithPrefix(prefix string) string PublicKey() (cryptotypes.PubKey, error) PrivateKey() (cryptotypes.PrivKey, error) + Mnemonic() string } diff --git a/wallet/cosmos.go b/wallet/cosmos.go index 0c20e4f..44caa5f 100644 --- a/wallet/cosmos.go +++ b/wallet/cosmos.go @@ -10,6 +10,7 @@ import ( ) type CosmosWallet struct { + mnemonic string privKey cryptotypes.PrivKey keyName string bech32Prefix string @@ -33,6 +34,7 @@ func NewWallet(keyname string, mnemonic string, bech32Prefix string, hdPath *hd. privKey := hd.Secp256k1.Generate()(derivedPrivKey) return &CosmosWallet{ + mnemonic: mnemonic, privKey: privKey, keyName: keyname, bech32Prefix: bech32Prefix, @@ -83,3 +85,7 @@ func (w *CosmosWallet) PrivateKey() (cryptotypes.PrivKey, error) { func (w *CosmosWallet) SigningAlgo() string { return "secp256k1" } + +func (w *CosmosWallet) Mnemonic() string { + return w.mnemonic +}