Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve resource handling #24

Merged
merged 2 commits into from
Feb 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[[constraint]]
name = "github.com/zondax/ledger-go"
version = "v0.7.0"
version = "v0.8.0"

[prune]
go-tests = true
Expand Down
2 changes: 1 addition & 1 deletion common.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package ledger_cosmos_go

import (
"fmt"
"encoding/binary"
"fmt"
)

type VersionInfo struct {
Expand Down
12 changes: 9 additions & 3 deletions user_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ package ledger_cosmos_go

import (
"fmt"
"github.com/zondax/ledger-go"
"math"

"github.com/zondax/ledger-go"
)

const (
Expand All @@ -40,11 +41,12 @@ const (
RequiredVersionPatch = 0
)

// User app
// LedgerCosmos represents a connection to the Cosmos app in a Ledger Nano S device
type LedgerCosmos struct {
api *ledger_go.Ledger
}

// FindLedgerCosmosUserApp finds a Cosmos app running in a device
func FindLedgerCosmosUserApp() (*LedgerCosmos, error) {
ledgerApi, err := ledger_go.FindLedger()

Expand All @@ -61,12 +63,16 @@ func FindLedgerCosmosUserApp() (*LedgerCosmos, error) {
}

if appVersion.Major < RequiredVersionMajor {
return nil, fmt.Errorf("Version not supported")
return nil, fmt.Errorf("version not supported")
}

return &ledgerCosmosUserApp, err
}

func (ledger *LedgerCosmos) Close() error {
return ledger.api.Close()
}

func (ledger *LedgerCosmos) GetVersion() (*VersionInfo, error) {
message := []byte{userCLA, userINSGetVersion, 0, 0, 0}
response, err := ledger.api.Exchange(message)
Expand Down
3 changes: 2 additions & 1 deletion validator_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
package ledger_cosmos_go

import (
"github.com/zondax/ledger-go"
"fmt"
"math"

"github.com/zondax/ledger-go"
)

const (
Expand Down