Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
oasis-core-ledger: Add a basic device listing tool
Browse files Browse the repository at this point in the history
  • Loading branch information
Yawning committed Jul 23, 2020
1 parent 3a9e365 commit 413a802
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ledger-signer/ledger-signer.so
oasis-core-ledger
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
include common.mk

# Set all target as the default target.
all: build-plugin
all: build build-plugin

# Build.
build:
@$(ECHO) "$(MAGENTA)*** Building Go code...$(OFF)"
@$(GO) build -v ./...
@$(GO) build -v .

# Build plugin.
build-plugin:
Expand Down
17 changes: 17 additions & 0 deletions cmd/list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package cmd

import (
"github.com/spf13/cobra"

"github.com/oasisprotocol/oasis-core-ledger/internal"
)

var listCmd = &cobra.Command{
Use: "list_devices",
Short: "list available devices by address",
Run: doList,
}

func doList(cmd *cobra.Command, args []string) {
internal.ListOasisDevices(internal.ListingDerivationPath)
}
56 changes: 56 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Package cmd implements the oasis-core-ledger tool.
package cmd

import (
// "fmt"

"github.com/spf13/cobra"
// flag "github.com/spf13/pflag"
// "github.com/spf13/viper"
// "github.com/oasisprotocol/oasis-core/go/common/logging"
// "github.com/oasisprotocol/oasis-core/go/oasis-node/cmd/common"
)

// const cfgLogLevel = "log.level"

var rootCmd = &cobra.Command{
Use: "oasis-core-ledger",
Short: "Oasis Ledger Tool",
Version: "0.0.1",
}

// rootFlags = flag.NewFlagSet("", flag.ContinueOnError)

// RootCommand returns the root (top level) cobra.Command.
func RootCommand() *cobra.Command {
return rootCmd
}

// Execute spawns the main entry point after handling the command line arguments.
func Execute() {
// Blah, The fact that oasis-core imports the ledger library causes
// issues, re-enable logging once the ledger support has been purged.
/*
var logLevel logging.Level
if err := logLevel.Set(viper.GetString(cfgLogLevel)); err != nil {
common.EarlyLogAndExit(fmt.Errorf("root: failed to set log level: %w", err))
}
if err := rootCmd.Execute(); err != nil {
common.EarlyLogAndExit(err)
}
*/
_ = rootCmd.Execute()
}

func init() { // nolint: gochecknoinits
/*
logLevel := logging.LevelInfo
rootFlags.Var(&logLevel, cfgLogLevel, "log level")
_ = viper.BindPFlags(rootFlags)
rootCmd.PersistentFlags().AddFlagSet(rootFlags)
*/

// Register all of the sub-commands.
rootCmd.AddCommand(listCmd)
}
7 changes: 7 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@ module github.com/oasisprotocol/oasis-core-ledger

go 1.14

// Updates the version used in spf13/cobra (dependency via tendermint) as
// there is no release yet with the fix. Remove once an updated release of
// spf13/cobra exists and tendermint is updated to include it.
// https://github.com/spf13/cobra/issues/1091
replace github.com/gorilla/websocket => github.com/gorilla/websocket v1.4.2

require (
github.com/oasisprotocol/oasis-core/go v0.0.0-20200623153002-9e61aea5195b
github.com/spf13/cobra v1.0.0
github.com/stretchr/testify v1.6.1
github.com/zondax/ledger-go v0.12.0
)
5 changes: 2 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,6 @@ github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99/go.mod h1:wJfORR
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
Expand Down Expand Up @@ -279,6 +276,7 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
github.com/huin/goupnp v1.0.0/go.mod h1:n9v9KO1tAxYH82qOn+UTIFQDmx5n1Zxd/ClZDMX7Bnc=
github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
github.com/ipfs/go-cid v0.0.1/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM=
Expand Down Expand Up @@ -709,6 +707,7 @@ github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
github.com/spf13/cobra v1.0.0 h1:6m/oheQuQ13N9ks4hubMG6BnvwOeaJrqSPLahSnczz8=
github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
Expand Down
10 changes: 10 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Package main implements the oasis-core-ledger CLI tool.
package main

import (
"github.com/oasisprotocol/oasis-core-ledger/cmd"
)

func main() {
cmd.Execute()
}

0 comments on commit 413a802

Please sign in to comment.