From ce1cc346bbfcb26beaf6abf46e4bc32d286b49ad Mon Sep 17 00:00:00 2001 From: vd <34808607+vadim-di@users.noreply.github.com> Date: Sat, 28 Sep 2019 04:15:07 +1000 Subject: [PATCH 1/9] 111 --- eosc/cmd/common.go | 24 +++--------------------- go.mod | 2 ++ 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/eosc/cmd/common.go b/eosc/cmd/common.go index 68773877..b860d581 100644 --- a/eosc/cmd/common.go +++ b/eosc/cmd/common.go @@ -20,7 +20,6 @@ import ( "github.com/eoscanada/eosc/cli" eosvault "github.com/eoscanada/eosc/vault" "github.com/spf13/viper" - "github.com/tidwall/gjson" "github.com/tidwall/sjson" ) @@ -114,28 +113,11 @@ func getCoreSymbol() eos.Symbol { } func initCoreSymbol() error { - resp, err := getAPI().GetTableRows(eos.GetTableRowsRequest{ - Code: "eosio", - Scope: "eosio", - Table: "rammarket", - JSON: true, - }) - + result := "1.2345 EOS" + asset, err := eos.NewAsset(result) if err != nil { - return fmt.Errorf("unable to fetch table: %s", err) - } - - result := gjson.GetBytes(resp.Rows, "0.quote.balance") - if !result.Exists() { - return errors.New("table has not expected format") + zap.Error(err) } - - asset, err := eos.NewAsset(result.String()) - if !result.Exists() { - return fmt.Errorf("quote balance asset %q is not valid: %s", result.String(), err) - } - - zlog.Debug("Retrieved core symbol from API, using it as default core symbol", zap.Stringer("symbol", asset.Symbol)) coreSymbol = asset.Symbol return nil } diff --git a/go.mod b/go.mod index bd1560a6..f4ef7113 100644 --- a/go.mod +++ b/go.mod @@ -36,3 +36,5 @@ require ( google.golang.org/appengine v0.0.0-20150527042145-b667a5000b08 // indirect gopkg.in/olivere/elastic.v3 v3.0.75 ) + +go 1.13 From 84837e26bf6c0b58d9979312c4e21879f28ece88 Mon Sep 17 00:00:00 2001 From: vd <34808607+vadim-di@users.noreply.github.com> Date: Sat, 28 Sep 2019 04:52:10 +1000 Subject: [PATCH 2/9] 112 --- eosc/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eosc/main.go b/eosc/main.go index fc3249b2..6de23585 100644 --- a/eosc/main.go +++ b/eosc/main.go @@ -7,7 +7,7 @@ import ( _ "github.com/eoscanada/eos-go/system" _ "github.com/eoscanada/eos-go/token" - "github.com/eoscanada/eosc/eosc/cmd" + "github.com/vadim-di/eosc/eosc/cmd" ) var version = "dev" From afe3fefab3550286829b81e92afe9b3805731a54 Mon Sep 17 00:00:00 2001 From: vd <34808607+vadim-di@users.noreply.github.com> Date: Sat, 28 Sep 2019 04:54:42 +1000 Subject: [PATCH 3/9] Update main.go --- eosc/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eosc/main.go b/eosc/main.go index fc3249b2..6de23585 100644 --- a/eosc/main.go +++ b/eosc/main.go @@ -7,7 +7,7 @@ import ( _ "github.com/eoscanada/eos-go/system" _ "github.com/eoscanada/eos-go/token" - "github.com/eoscanada/eosc/eosc/cmd" + "github.com/vadim-di/eosc/eosc/cmd" ) var version = "dev" From 28694608522c4a56b610368a9717d89c117e2b03 Mon Sep 17 00:00:00 2001 From: vd <34808607+vadim-di@users.noreply.github.com> Date: Sat, 28 Sep 2019 06:40:50 +1000 Subject: [PATCH 4/9] 113 --- eosc/cmd/common.go | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/eosc/cmd/common.go b/eosc/cmd/common.go index b860d581..82e071b4 100644 --- a/eosc/cmd/common.go +++ b/eosc/cmd/common.go @@ -11,8 +11,6 @@ import ( "strings" "time" - "go.uber.org/zap" - yaml2json "github.com/bronze1man/go-yaml2json" "github.com/eoscanada/eos-go" "github.com/eoscanada/eos-go/ecc" @@ -87,41 +85,18 @@ func getAPI() *eos.API { return api } -var coreSymbolIsCached bool var coreSymbol eos.Symbol func getCoreSymbol() eos.Symbol { - if coreSymbolIsCached { - return coreSymbol - } + coreSymbol = eos.Symbol{Precision: 4, Symbol: "EOS"} - // In the event of a failure, we do not want to re-perform an API call, - // so let's record the fact that getCoreSymbol is cached right here. - // The init core symbol will take care of setting an approriate core - // symbol from global flag and reporting the error. - coreSymbolIsCached = true - if err := initCoreSymbol(); err != nil { - coreSymbol = eos.EOSSymbol - zlog.Debug( - "unable to retrieve core symbol from API, falling back to default", - zap.Error(err), - zap.Stringer("default", coreSymbol), - ) + if viper.GetString("transfer-cmd-contract") == "bntbntbntbnt" { + coreSymbol = eos.Symbol{Precision: 10, Symbol: "BNT"} } return coreSymbol } -func initCoreSymbol() error { - result := "1.2345 EOS" - asset, err := eos.NewAsset(result) - if err != nil { - zap.Error(err) - } - coreSymbol = asset.Symbol - return nil -} - func sanitizeAPIURL(input string) string { return strings.TrimRight(input, "/") } From ec8bec8c035113fd090f0ff1982f632397a8a8f0 Mon Sep 17 00:00:00 2001 From: vd <34808607+vadim-di@users.noreply.github.com> Date: Sat, 28 Sep 2019 15:01:14 +1000 Subject: [PATCH 5/9] 114 --- eosc/cmd/common.go | 12 +++++------- eosc/cmd/root.go | 3 ++- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/eosc/cmd/common.go b/eosc/cmd/common.go index 82e071b4..395883e1 100644 --- a/eosc/cmd/common.go +++ b/eosc/cmd/common.go @@ -85,16 +85,14 @@ func getAPI() *eos.API { return api } -var coreSymbol eos.Symbol +var sym string +var dec uint8 func getCoreSymbol() eos.Symbol { - coreSymbol = eos.Symbol{Precision: 4, Symbol: "EOS"} + sym = viper.GetString("global-core-symbol") + dec = uint8(viper.GetInt("global-core-decimals")) - if viper.GetString("transfer-cmd-contract") == "bntbntbntbnt" { - coreSymbol = eos.Symbol{Precision: 10, Symbol: "BNT"} - } - - return coreSymbol + return eos.Symbol{Precision: dec, Symbol: sym} } func sanitizeAPIURL(input string) string { diff --git a/eosc/cmd/root.go b/eosc/cmd/root.go index f28b2978..476563bb 100644 --- a/eosc/cmd/root.go +++ b/eosc/cmd/root.go @@ -43,7 +43,8 @@ func Execute() { func init() { cobra.OnInitialize(initConfig) - RootCmd.PersistentFlags().StringP("core-symbol", "c", "", "Core symbol to use for all commands (default inferred from API if possible, 4,EOS otherwise)") + RootCmd.PersistentFlags().StringP("core-symbol", "c", "EOS", "Core symbol to use for all commands (default EOS)") + RootCmd.PersistentFlags().StringP("core-decimals", "s", "4", "Core symbol decimals (default 4)") RootCmd.PersistentFlags().BoolP("debug", "", false, "Enables verbose API debug messages") RootCmd.PersistentFlags().StringP("vault-file", "", "./eosc-vault.json", "Wallet file that contains encrypted key material") RootCmd.PersistentFlags().StringSliceP("wallet-url", "", []string{}, "Base URL to wallet endpoint. You can pass this multiple times to use the multi-signer (will use each wallet to sign multi-sig transactions).") From 06b984edc9df3fe7b67898d06f8cbd513023ada6 Mon Sep 17 00:00:00 2001 From: vd <34808607+vadim-di@users.noreply.github.com> Date: Sat, 28 Sep 2019 15:41:12 +1000 Subject: [PATCH 6/9] 115 --- eosc/cmd/root.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/eosc/cmd/root.go b/eosc/cmd/root.go index 476563bb..495395ee 100644 --- a/eosc/cmd/root.go +++ b/eosc/cmd/root.go @@ -44,10 +44,10 @@ func init() { cobra.OnInitialize(initConfig) RootCmd.PersistentFlags().StringP("core-symbol", "c", "EOS", "Core symbol to use for all commands (default EOS)") - RootCmd.PersistentFlags().StringP("core-decimals", "s", "4", "Core symbol decimals (default 4)") + RootCmd.PersistentFlags().IntP("core-decimals", "s", 4, "Core symbol decimals (default 4)") RootCmd.PersistentFlags().BoolP("debug", "", false, "Enables verbose API debug messages") RootCmd.PersistentFlags().StringP("vault-file", "", "./eosc-vault.json", "Wallet file that contains encrypted key material") - RootCmd.PersistentFlags().StringSliceP("wallet-url", "", []string{}, "Base URL to wallet endpoint. You can pass this multiple times to use the multi-signer (will use each wallet to sign multi-sig transactions).") + RootCmd.PersistentFlags().StringSliceP("wallet-url", "", []string{"http://127.0.0.1:6666"}, "Base URL to wallet endpoint (default http://127.0.0.1:6666)") RootCmd.PersistentFlags().StringP("api-url", "u", "https://mainnet.eoscanada.com", "API endpoint of eos.io blockchain node") RootCmd.PersistentFlags().StringSliceP("permission", "p", []string{}, "Permission to sign transactions with. Optionally specify more than one, or separate by comma") RootCmd.PersistentFlags().StringSliceP("http-header", "H", []string{}, "HTTP header to add to a request. Optionally repeat this option to specify multiple headers") @@ -55,11 +55,11 @@ func init() { RootCmd.PersistentFlags().StringP("write-transaction", "", "", "Do not broadcast the transaction produced, but write it in json to the given filename instead.") RootCmd.PersistentFlags().StringP("offline-head-block", "", "", "Provide a recent block ID (long-form hex) for TaPoS. Use all --offline options to sign transactions offline.") RootCmd.PersistentFlags().StringP("offline-chain-id", "", "", "Chain ID to sign transaction with. Use all --offline- options to sign transactions offline.") - RootCmd.PersistentFlags().StringSliceP("offline-sign-key", "", []string{}, "Public key to use to sign transaction. Must be in your vault or wallet. Use all --offline- options to sign transactions offline.") + RootCmd.PersistentFlags().StringSliceP("offline-sign-key", "", []string{}, "Public key to use to sign transaction. Must be in your vault or wallet.") RootCmd.PersistentFlags().BoolP("skip-sign", "", false, "Do not sign the transaction. Use with --write-transaction.") RootCmd.PersistentFlags().IntP("expiration", "", 30, "Set time before transaction expires, in seconds. Defaults to 30 seconds.") RootCmd.PersistentFlags().IntP("delay-sec", "", 0, "Set time to wait before transaction is executed, in seconds. Defaults to 0 second.") - RootCmd.PersistentFlags().BoolP("sudo-wrap", "", false, "Wrap the transaction in a eosio.sudo exec. Useful to BPs, with --write-transaction and --skip-sign to then submit as a multisig proposition.") + RootCmd.PersistentFlags().BoolP("sudo-wrap", "", false, "Wrap the transaction in a eosio.sudo exec.") } func initConfig() { From 1eb3a31eb1bcb00c851d576f4fa15b0ab5b3e1c2 Mon Sep 17 00:00:00 2001 From: vd <34808607+vadim-di@users.noreply.github.com> Date: Sat, 28 Sep 2019 15:52:13 +1000 Subject: [PATCH 7/9] 116 --- eosc/cmd/root.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/eosc/cmd/root.go b/eosc/cmd/root.go index 495395ee..2fbad8db 100644 --- a/eosc/cmd/root.go +++ b/eosc/cmd/root.go @@ -43,23 +43,23 @@ func Execute() { func init() { cobra.OnInitialize(initConfig) - RootCmd.PersistentFlags().StringP("core-symbol", "c", "EOS", "Core symbol to use for all commands (default EOS)") - RootCmd.PersistentFlags().IntP("core-decimals", "s", 4, "Core symbol decimals (default 4)") - RootCmd.PersistentFlags().BoolP("debug", "", false, "Enables verbose API debug messages") - RootCmd.PersistentFlags().StringP("vault-file", "", "./eosc-vault.json", "Wallet file that contains encrypted key material") - RootCmd.PersistentFlags().StringSliceP("wallet-url", "", []string{"http://127.0.0.1:6666"}, "Base URL to wallet endpoint (default http://127.0.0.1:6666)") + RootCmd.PersistentFlags().StringP("core-symbol", "S", "EOS", "Core symbol to use for all commands") + RootCmd.PersistentFlags().IntP("core-decimals", "D", 4, "Core symbol decimals") + RootCmd.PersistentFlags().BoolP("debug", "v", false, "Enables verbose API debug messages") + RootCmd.PersistentFlags().StringP("vault-file", "W", "./eosc-vault.json", "Wallet file that contains encrypted key material") + RootCmd.PersistentFlags().StringSliceP("wallet-url", "", []string{"http://127.0.0.1:6666"}, "Base URL to wallet endpoint") RootCmd.PersistentFlags().StringP("api-url", "u", "https://mainnet.eoscanada.com", "API endpoint of eos.io blockchain node") RootCmd.PersistentFlags().StringSliceP("permission", "p", []string{}, "Permission to sign transactions with. Optionally specify more than one, or separate by comma") RootCmd.PersistentFlags().StringSliceP("http-header", "H", []string{}, "HTTP header to add to a request. Optionally repeat this option to specify multiple headers") RootCmd.PersistentFlags().StringP("kms-gcp-keypath", "", "", "Path to the cryptoKeys within a keyRing on GCP") - RootCmd.PersistentFlags().StringP("write-transaction", "", "", "Do not broadcast the transaction produced, but write it in json to the given filename instead.") - RootCmd.PersistentFlags().StringP("offline-head-block", "", "", "Provide a recent block ID (long-form hex) for TaPoS. Use all --offline options to sign transactions offline.") - RootCmd.PersistentFlags().StringP("offline-chain-id", "", "", "Chain ID to sign transaction with. Use all --offline- options to sign transactions offline.") - RootCmd.PersistentFlags().StringSliceP("offline-sign-key", "", []string{}, "Public key to use to sign transaction. Must be in your vault or wallet.") - RootCmd.PersistentFlags().BoolP("skip-sign", "", false, "Do not sign the transaction. Use with --write-transaction.") - RootCmd.PersistentFlags().IntP("expiration", "", 30, "Set time before transaction expires, in seconds. Defaults to 30 seconds.") - RootCmd.PersistentFlags().IntP("delay-sec", "", 0, "Set time to wait before transaction is executed, in seconds. Defaults to 0 second.") - RootCmd.PersistentFlags().BoolP("sudo-wrap", "", false, "Wrap the transaction in a eosio.sudo exec.") + RootCmd.PersistentFlags().StringP("write-transaction", "", "", "Do not broadcast the transaction produced, but write it in json to the given filename instead") + RootCmd.PersistentFlags().StringP("offline-head-block", "B", "", "Provide a recent block ID (long-form hex) for TaPoS. Use all --offline options to sign transactions offline") + RootCmd.PersistentFlags().StringP("offline-chain-id", "C", "", "Chain ID to sign transaction with. Use all --offline- options to sign transactions offline") + RootCmd.PersistentFlags().StringSliceP("offline-sign-key", "K", []string{}, "Public key to use to sign transaction. Must be in your vault or wallet") + RootCmd.PersistentFlags().BoolP("skip-sign", "", false, "Do not sign the transaction. Use with --write-transaction") + RootCmd.PersistentFlags().IntP("expiration", "", 30, "Set time before transaction expires, in seconds") + RootCmd.PersistentFlags().IntP("delay-sec", "", 0, "Set time to wait before transaction is executed, in seconds. Default 0") + RootCmd.PersistentFlags().BoolP("sudo-wrap", "", false, "Wrap the transaction in a eosio.sudo exec") } func initConfig() { From dd0e053aaf657f0fc111d34a58841b8da8406a6e Mon Sep 17 00:00:00 2001 From: vd <34808607+vadim-di@users.noreply.github.com> Date: Tue, 1 Oct 2019 23:07:02 +1000 Subject: [PATCH 8/9] Update main.go --- eosc/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eosc/main.go b/eosc/main.go index 6de23585..fc3249b2 100644 --- a/eosc/main.go +++ b/eosc/main.go @@ -7,7 +7,7 @@ import ( _ "github.com/eoscanada/eos-go/system" _ "github.com/eoscanada/eos-go/token" - "github.com/vadim-di/eosc/eosc/cmd" + "github.com/eoscanada/eosc/eosc/cmd" ) var version = "dev" From 24ae53c6cfdf8c758964fb35c9b8951b9136891f Mon Sep 17 00:00:00 2001 From: vd <34808607+vadim-di@users.noreply.github.com> Date: Tue, 1 Oct 2019 23:10:21 +1000 Subject: [PATCH 9/9] Update go.mod --- go.mod | 2 -- 1 file changed, 2 deletions(-) diff --git a/go.mod b/go.mod index f4ef7113..bd1560a6 100644 --- a/go.mod +++ b/go.mod @@ -36,5 +36,3 @@ require ( google.golang.org/appengine v0.0.0-20150527042145-b667a5000b08 // indirect gopkg.in/olivere/elastic.v3 v3.0.75 ) - -go 1.13