Skip to content

Commit

Permalink
stratos chain supports ledger-stratos app
Browse files Browse the repository at this point in the history
  • Loading branch information
WangLiStratos committed Jul 13, 2023
1 parent 46c5abd commit 840520d
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 21 deletions.
16 changes: 10 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
#!/usr/bin/make -f

BUILDDIR ?= $(CURDIR)/build
LEDGER_ENABLED ?= false

APP_VER := v0.10.0
COMMIT := $(GIT_COMMIT_HASH)
TEST_DOCKER_REPO=stratos-chain-e2e

BUILD_ARGS=-o $(BUILDDIR)/
ifeq ($(LEDGER_ENABLED),true)
BUILD_ARGS += -tags "ledger"
endif

ifeq ($(COMMIT),)
VERSION := $(APP_VER)
else
Expand All @@ -14,12 +20,10 @@ endif

ldflags= -X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION)

BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)'
BUILD_FLAGS += -ldflags '$(ldflags)'

BUILD_TARGETS := build install

build: BUILD_ARGS=-o $(BUILDDIR)/

$(BUILD_TARGETS): go.sum $(BUILDDIR)/
# go $@ -mod=readonly $(BUILD_ARGS) $(VERSION) ./cmd/...
go $@ $(BUILD_ARGS) $(BUILD_FLAGS) ./cmd/...
Expand All @@ -29,13 +33,13 @@ $(BUILDDIR)/:
mkdir -p $(BUILDDIR)/

build-linux: go.sum
LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build
GOOS=linux GOARCH=amd64 $(MAKE) build

build-mac: go.sum
LEDGER_ENABLED=false GOOS=darwin GOARCH=amd64 $(MAKE) build
GOOS=darwin GOARCH=amd64 $(MAKE) build

build-windows: go.sum
LEDGER_ENABLED=false GOOS=windows GOARCH=amd64 $(MAKE) build
GOOS=windows GOARCH=amd64 $(MAKE) build

clean:
rm -rf $(BUILDDIR)/
Expand Down
16 changes: 7 additions & 9 deletions client/keys/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
"fmt"
"sort"

"github.com/spf13/cobra"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/input"
Expand All @@ -19,7 +17,7 @@ import (
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/go-bip39"

"github.com/spf13/cobra"
stratoshd "github.com/stratosnet/stratos-chain/crypto/hd"
stratos "github.com/stratosnet/stratos-chain/types"
)
Expand Down Expand Up @@ -97,12 +95,13 @@ func runAddCmdPrepare(cmd *cobra.Command, args []string) error {

/*
input
- bip39 mnemonic
- bip39 passphrase
- bip44 path
- local encryption password
- bip39 mnemonic
- bip39 passphrase
- bip44 path
- local encryption password
output
- armor encrypted private key (saved to file)
- armor encrypted private key (saved to file)
*/
func RunAddCmd(ctx client.Context, cmd *cobra.Command, args []string, inBuf *bufio.Reader) error {
var err error
Expand Down Expand Up @@ -207,7 +206,6 @@ func RunAddCmd(ctx client.Context, cmd *cobra.Command, args []string, inBuf *buf
// If we're using ledger, only thing we need is the path and the bech32 prefix.
if useLedger {
bech32PrefixAccAddr := sdk.GetConfig().GetBech32AccountAddrPrefix()

info, err := kb.SaveLedgerKey(name, algo, bech32PrefixAccAddr, coinType, account, index)
if err != nil {
return err
Expand Down
4 changes: 4 additions & 0 deletions cmd/stchaind/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import (
"go/doc/comment"
"os"

"github.com/cosmos/cosmos-sdk/crypto/ledger"
"github.com/cosmos/cosmos-sdk/server"
svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/stratosnet/stratos-chain/crypto/ethsecp256k1"

"github.com/stratosnet/stratos-chain/app"
stratos "github.com/stratosnet/stratos-chain/types"
Expand All @@ -20,6 +23,7 @@ var (

func main() {
registerDenoms()
ledger.InitLedger(ethsecp256k1.MakePubKey, signing.SignMode_SIGN_MODE_DIRECT)

rootCmd, _ := NewRootCmd()
if err := svrcmd.Execute(rootCmd, app.DefaultNodeHome); err != nil {
Expand Down
5 changes: 5 additions & 0 deletions crypto/ethsecp256k1/ethsecp256k1.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/types"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/ethereum/go-ethereum/crypto"
Expand Down Expand Up @@ -52,6 +53,10 @@ func GenerateKey() (*PrivKey, error) {
}, nil
}

func MakePubKey(key []byte) types.PubKey {
return &PubKey{Key: key}
}

// Bytes returns the byte representation of the ECDSA Private Key.
func (privKey PrivKey) Bytes() []byte {
bz := make([]byte, len(privKey.Key))
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ require (
github.com/cosmos/btcutil v1.0.4 // indirect
github.com/cosmos/gorocksdb v1.2.0 // indirect
github.com/cosmos/iavl v0.19.4 // indirect
github.com/cosmos/ledger-cosmos-go v0.12.2 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/creachadair/taskgroup v0.3.2 // indirect
github.com/danieljoos/wincred v1.1.2 // indirect
Expand Down Expand Up @@ -152,6 +151,7 @@ require (
github.com/spf13/afero v1.9.2 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4 // indirect
github.com/stratosnet/ledger-stratos-go v0.0.0-20230713133005-366e079804c5 // indirect
github.com/subosito/gotenv v1.4.1 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
Expand Down Expand Up @@ -179,7 +179,8 @@ require (
replace (
github.com/99designs/keyring => github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76
github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0
github.com/cosmos/cosmos-sdk => github.com/stratosnet/cosmos-sdk v0.45.12-0.20230124002546-fd8c3abd07d5
github.com/cosmos/cosmos-sdk => github.com/stratosnet/cosmos-sdk v0.45.12-0.20230713152540-f99adebc0fc6
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
github.com/stratosnet/ledger-stratos-go => ../ledger-stratos-go
google.golang.org/grpc => google.golang.org/grpc v1.33.2
)
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,6 @@ github.com/cosmos/ibc-go/v3 v3.0.0 h1:XUNplHVS51Q2gMnTFsFsH9QJ7flsovMamnltKbEgPQ
github.com/cosmos/ibc-go/v3 v3.0.0/go.mod h1:Mb+1NXiPOLd+CPFlOC6BKeAUaxXlhuWenMmRiUiSmwY=
github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76 h1:DdzS1m6o/pCqeZ8VOAit/gyATedRgjvkVI+UCrLpyuU=
github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76/go.mod h1:0mkLWIoZuQ7uBoospo5Q9zIpqq6rYCPJDSUdeCJvPM8=
github.com/cosmos/ledger-cosmos-go v0.12.2 h1:/XYaBlE2BJxtvpkHiBm97gFGSGmYGKunKyF3nNqAXZA=
github.com/cosmos/ledger-cosmos-go v0.12.2/go.mod h1:ZcqYgnfNJ6lAXe4HPtWgarNEY+B74i+2/8MhZw4ziiI=
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
Expand Down Expand Up @@ -820,8 +818,8 @@ github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4 h1:Gb2Tyox57N
github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q=
github.com/steakknife/bloomfilter v0.0.0-20180922174646-6819c0d2a570/go.mod h1:8OR4w3TdeIHIh1g6EMY5p0gVNOovcWC+1vpc7naMuAw=
github.com/steakknife/hamming v0.0.0-20180906055917-c99c65617cd3/go.mod h1:hpGUWaI9xL8pRQCTXQgocU38Qw1g0Us7n5PxxTwTCYU=
github.com/stratosnet/cosmos-sdk v0.45.12-0.20230124002546-fd8c3abd07d5 h1:WjTdRjQkoPKDtp2gaGu9s/Cv5QC4ahRI9VRuex+XvQE=
github.com/stratosnet/cosmos-sdk v0.45.12-0.20230124002546-fd8c3abd07d5/go.mod h1:p8Nf05bzxH7rGhbEuC0L+GEX4Fwvq3MgYFbdTlprZLc=
github.com/stratosnet/cosmos-sdk v0.45.12-0.20230713152540-f99adebc0fc6 h1:EqDJTn54K30Qv0fGckpsMMtF+0Q8lopnN2jG9jB3sXE=
github.com/stratosnet/cosmos-sdk v0.45.12-0.20230713152540-f99adebc0fc6/go.mod h1:DrJq/JWiycsYMFZXwWbNlHDN1xN5/B4RtaTe+um1QMY=
github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI=
Expand Down

0 comments on commit 840520d

Please sign in to comment.