Skip to content

Commit

Permalink
remove ledger init
Browse files Browse the repository at this point in the history
  • Loading branch information
amritkumarj committed Jan 16, 2024
1 parent 05fc1b0 commit 03944d7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
16 changes: 0 additions & 16 deletions tm2/pkg/crypto/ledger/ledger_real.go

This file was deleted.

14 changes: 10 additions & 4 deletions tm2/pkg/crypto/ledger/ledger_secp256k1.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/btcsuite/btcd/btcec/v2/ecdsa"
secp "github.com/decred/dcrd/dcrec/secp256k1/v4"

ledger "github.com/cosmos/ledger-cosmos-go"
"github.com/gnolang/gno/tm2/pkg/amino"
"github.com/gnolang/gno/tm2/pkg/crypto"
"github.com/gnolang/gno/tm2/pkg/crypto/hd"
Expand All @@ -18,7 +19,6 @@ import (

// discoverLedger defines a function to be invoked at runtime for discovering
// a connected Ledger device.
var discoverLedger discoverLedgerFn

type (
// discoverLedgerFn defines a Ledger discovery function that returns a
Expand Down Expand Up @@ -68,6 +68,15 @@ func NewPrivKeyLedgerSecp256k1Unsafe(path hd.BIP44Params) (crypto.PrivKey, error
return PrivKeyLedgerSecp256k1{pubKey, path}, nil
}

func discoverLedger() (LedgerSECP256K1, error) {
device, err := ledger.FindLedgerCosmosUserApp()
if err != nil {
return nil, err
}

return device, nil
}

// NewPrivKeyLedgerSecp256k1 will generate a new key and store the public key for later use.
// The request will require user confirmation and will show account and index in the device
func NewPrivKeyLedgerSecp256k1(path hd.BIP44Params, hrp string) (crypto.PrivKey, string, error) {
Expand Down Expand Up @@ -196,9 +205,6 @@ func convertDERtoBER(signatureDER []byte) ([]byte, error) {
}

func getLedgerDevice() (LedgerSECP256K1, error) {
if discoverLedger == nil {
return nil, errors.New("no Ledger discovery function defined")
}

device, err := discoverLedger()
if err != nil {
Expand Down

0 comments on commit 03944d7

Please sign in to comment.