Skip to content

Commit

Permalink
Merge branch 'main' into 483-investigate-module-simulations
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurentMontBlanc committed Nov 27, 2024
2 parents 7988c35 + 75cb64d commit 751f152
Show file tree
Hide file tree
Showing 17 changed files with 435 additions and 315 deletions.
48 changes: 28 additions & 20 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package config

import (
"encoding/json"
"errors"
"os"
"sync"

Expand Down Expand Up @@ -91,54 +92,61 @@ func (config *Config) SetPlanetmintConfig(planetmintconfig interface{}) {
}
}

// GetValidatorAddress retrieves the validator address through multiple methods
func (config *Config) GetValidatorAddress() string {
// Check environment variable first
if envAddr := os.Getenv(ValAddr); envAddr != "" {
return envAddr
// GetNodeAddress retrieves the validator address through multiple methods
func (config *Config) GetNodeAddress() (address string) {
var err error
// Check environment variable first <- this is used for test cases only
if address = os.Getenv(ValAddr); address != "" {
return
}

libConfig := lib.GetConfig()

// Handle no Trust Wallet connected scenario
if libConfig.GetSerialPort() == "" {
return getDefaultValidatorAddress(libConfig)
address, err = getKeyringAddress(libConfig)
} else { // Handle Trust Wallet connected scenario
address, err = getTrustWalletAddress(libConfig)
}

// Handle Trust Wallet connected scenario
return getTrustWalletValidatorAddress(libConfig)
if err != nil {
msg := "Cannot get node address. Please configure a Trust Wallet or define at least one key pair in the utilized keyring."
newError := errors.New(msg + ": " + err.Error())
panic(newError)
}
return address
}

// getDefaultValidatorAddress retrieves the default validator address
func getDefaultValidatorAddress(libConfig *lib.Config) string {
// getKeyringAddress retrieves the default validator address
func getKeyringAddress(libConfig *lib.Config) (address string, err error) {
defaultRecord, err := libConfig.GetDefaultValidatorRecord()
if err != nil {
logger.GetLogger(logger.ERROR).Error("msg", err.Error())
return ""
return
}

addr, err := defaultRecord.GetAddress()
if err != nil {
logger.GetLogger(logger.ERROR).Error("msg", err.Error())
return ""
return
}

return addr.String()
address = addr.String()
return
}

// getTrustWalletValidatorAddress retrieves validator address from Trust Wallet
func getTrustWalletValidatorAddress(libConfig *lib.Config) string {
// getTrustWalletAddress retrieves validator address from Trust Wallet
func getTrustWalletAddress(libConfig *lib.Config) (address string, err error) {
connector, err := trustwallet.NewTrustWalletConnector(libConfig.GetSerialPort())
if err != nil {
logger.GetLogger(logger.ERROR).Error("msg", err.Error())
return ""
return
}

keys, err := connector.GetPlanetmintKeys()
if err != nil {
logger.GetLogger(logger.ERROR).Error("msg", err.Error())
return ""
return
}

return keys.PlanetmintAddress
address = keys.PlanetmintAddress
return
}
80 changes: 44 additions & 36 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@ go 1.22

require (
cosmossdk.io/api v0.3.1
cosmossdk.io/core v0.5.1
cosmossdk.io/depinject v1.1.0
cosmossdk.io/depinject v1.0.0-alpha.4
cosmossdk.io/errors v1.0.1
cosmossdk.io/math v1.2.0
cosmossdk.io/math v1.4.0
cosmossdk.io/simapp v0.0.0-20230323161446-0af178d721ff
github.com/btcsuite/btcd v0.24.0
github.com/btcsuite/btcd/btcutil v1.1.5
github.com/cometbft/cometbft v0.37.4
github.com/cometbft/cometbft v0.37.5
github.com/cometbft/cometbft-db v0.8.0
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/cosmos-sdk v0.47.8
github.com/cosmos/cosmos-sdk v0.47.14
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/gogoproto v1.7.0
github.com/cosmos/ibc-go/v7 v7.4.0
Expand All @@ -29,27 +28,28 @@ require (
github.com/rddl-network/go-utils v0.2.3
github.com/rddl-network/rddl-claim-service v0.3.2
github.com/rddl-network/rddl-claim-service/client v0.0.6
github.com/rddl-network/shamir-coordinator-service v0.7.8
github.com/rddl-network/shamir-coordinator-service v0.7.7
github.com/rddl-network/shamir-coordinator-service/client v0.1.0
github.com/spf13/cast v1.6.0
github.com/spf13/cobra v1.7.0
github.com/spf13/cobra v1.8.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.9.0
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142
google.golang.org/grpc v1.67.1
google.golang.org/protobuf v1.35.1
google.golang.org/genproto/googleapis/api v0.0.0-20240123012728-ef4313101c80
google.golang.org/grpc v1.62.1
gopkg.in/yaml.v2 v2.4.0
gotest.tools v2.2.0+incompatible
sigs.k8s.io/yaml v1.4.0
)

require (
cloud.google.com/go v0.111.0 // indirect
cloud.google.com/go/compute/metadata v0.5.0 // indirect
cloud.google.com/go v0.112.0 // indirect
cloud.google.com/go/compute v1.23.3 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/iam v1.1.5 // indirect
cloud.google.com/go/storage v1.35.1 // indirect
cosmossdk.io/log v1.3.0 // indirect
cloud.google.com/go/storage v1.36.0 // indirect
cosmossdk.io/core v0.5.1 // indirect
cosmossdk.io/log v1.4.1 // indirect
cosmossdk.io/tools/rosetta v0.2.1 // indirect
filippo.io/edwards25519 v1.0.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
Expand All @@ -64,7 +64,7 @@ require (
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chzyer/readline v1.5.1 // indirect
github.com/cockroachdb/apd/v2 v2.0.2 // indirect
github.com/cockroachdb/errors v1.10.0 // indirect
Expand All @@ -89,19 +89,19 @@ require (
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/dvsekhvalnov/jose2go v1.6.0 // indirect
github.com/felixge/httpsnoop v1.0.2 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/getsentry/sentry-go v0.23.0 // indirect
github.com/ghodss/yaml v1.0.0 // 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.6.0 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-logr/stdr v1.2.2 // 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
github.com/golang/glog v1.2.2 // indirect
github.com/golang/glog v1.2.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/btree v1.1.2 // indirect
Expand Down Expand Up @@ -130,7 +130,7 @@ require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/klauspost/compress v1.16.7 // indirect
github.com/klauspost/compress v1.17.0 // 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
Expand Down Expand Up @@ -159,11 +159,13 @@ require (
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/rs/cors v1.8.3 // indirect
github.com/rs/zerolog v1.31.0 // indirect
github.com/rs/zerolog v1.33.0 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sasha-s/go-deadlock v0.3.1 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/viper v1.16.0 // indirect
github.com/spf13/viper v1.18.2 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
github.com/tidwall/btree v1.6.0 // indirect
Expand All @@ -173,21 +175,27 @@ require (
go.bug.st/serial v1.6.2 // indirect
go.etcd.io/bbolt v1.3.7 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/otel v1.19.0 // indirect
go.opentelemetry.io/otel/metric v1.19.0 // indirect
go.opentelemetry.io/otel/trace v1.19.0 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/term v0.24.0 // indirect
golang.org/x/text v0.18.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect
go.opentelemetry.io/otel v1.21.0 // indirect
go.opentelemetry.io/otel/metric v1.21.0 // indirect
go.opentelemetry.io/otel/trace v1.21.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/api v0.152.0 // indirect
google.golang.org/genproto v0.0.0-20240102182953-50ed04b92917 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect
google.golang.org/api v0.155.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
nhooyr.io/websocket v1.8.6 // indirect
Expand Down
Loading

0 comments on commit 751f152

Please sign in to comment.