From 5426455d2ce1863add74df93a8683b47516d87c8 Mon Sep 17 00:00:00 2001 From: sideninja Date: Wed, 12 May 2021 12:24:22 +0200 Subject: [PATCH 01/44] fix argsJSON flag in docs --- docs/build-transactions.md | 2 +- docs/execute-scripts.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/build-transactions.md b/docs/build-transactions.md index 7a50772c5..2b2cca6e6 100644 --- a/docs/build-transactions.md +++ b/docs/build-transactions.md @@ -124,7 +124,7 @@ The `Type` must be the same as type in the transaction source code for that argu ### Arguments JSON -- Flag: `--argsJSON` +- Flag: `--args-json` - Valid inputs: arguments in JSON-Cadence form. Arguments passed to the Cadence transaction in Cadence JSON format. diff --git a/docs/execute-scripts.md b/docs/execute-scripts.md index 0e27d26e5..3000762ef 100644 --- a/docs/execute-scripts.md +++ b/docs/execute-scripts.md @@ -42,7 +42,7 @@ The `Type` must be the same as type in the script source code for that argument. ### Arguments JSON -- Flag: `--argsJSON` +- Flag: `--args-json` - Valid inputs: arguments in JSON-Cadence form. Arguments passed to the Cadence script in `Type:Value` format. From 75649f208f3e7e519da716271a92146d50ae7a83 Mon Sep 17 00:00:00 2001 From: Gregor Gololicic <75445744+sideninja@users.noreply.github.com> Date: Wed, 12 May 2021 17:30:10 +0200 Subject: [PATCH 02/44] Update CONTRIBUTING.md add guideline on too much result data --- CONTRIBUTING.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 332dee36c..dbd4e978c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -242,6 +242,9 @@ Default command response should be to the stdout and not saved to a file. Anytim the output to be saved to a file we should explicitly specify so by using `--save filename.txt` flag and providing the path. +Result output should include only information that is commonly used and releavant, +don't use too much of user screen drowning what’s truly important, +instead provide a way to include that data when the user requests by having include, exclude flags. ``` Address 179b6b1cb6755e31 From a670914a32f8fbe9ed4a2d253b0f6b7d5b68984d Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Thu, 13 May 2021 17:01:44 +0200 Subject: [PATCH 03/44] avoid warning in local dev --- internal/command/command.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/command/command.go b/internal/command/command.go index ea8ff954c..d798af234 100644 --- a/internal/command/command.go +++ b/internal/command/command.go @@ -394,7 +394,12 @@ func checkVersion(logger output.Logger) { body, _ := ioutil.ReadAll(resp.Body) latestVersion := strings.TrimSpace(string(body)) - if latestVersion != build.Semver() { + currentVersion := build.Semver() + if currentVersion == "undefined" { + return // avoid warning in local development + } + + if currentVersion != latestVersion { logger.Info(fmt.Sprintf( "\n⚠️ Version warning: a new version of Flow CLI is available (%s).\n"+ "Read the installation guide for upgrade instructions: https://docs.onflow.org/flow-cli/install", From 8096f2143a61158e8681e1467bc2d5c1b49bd240 Mon Sep 17 00:00:00 2001 From: Gregor Gololicic <75445744+sideninja@users.noreply.github.com> Date: Thu, 13 May 2021 19:02:58 +0200 Subject: [PATCH 04/44] Update CONTRIBUTING.md Co-authored-by: Peter Siemens --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dbd4e978c..642d7fb35 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -242,7 +242,7 @@ Default command response should be to the stdout and not saved to a file. Anytim the output to be saved to a file we should explicitly specify so by using `--save filename.txt` flag and providing the path. -Result output should include only information that is commonly used and releavant, +Result output should include only information that is commonly used and relevant, don't use too much of user screen drowning what’s truly important, instead provide a way to include that data when the user requests by having include, exclude flags. From d8510b9d90aeb48898132e7a0e658555df72f14c Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Mon, 17 May 2021 12:01:59 +0200 Subject: [PATCH 05/44] contains field exclude/include methods --- internal/command/result.go | 14 ++++++++++++++ pkg/flowcli/util/utilities.go | 24 +++++++++++++----------- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/internal/command/result.go b/internal/command/result.go index 994e7d462..067b3d221 100644 --- a/internal/command/result.go +++ b/internal/command/result.go @@ -18,8 +18,22 @@ package command +import ( + "github.com/onflow/flow-cli/pkg/flowcli/util" +) + type Result interface { String() string Oneliner() string JSON() interface{} } + +// FieldIncluded checks if field should be included in the result by checking if included flags contains field +func FieldIncluded(included []string, field string) bool { + return util.ContainsStringInsensitive(included, field) +} + +// FieldExcluded checks if field should be excluded from the result by checking the flags +func FieldExcluded(excluded []string, field string) bool { + return util.ContainsStringInsensitive(excluded, field) +} diff --git a/pkg/flowcli/util/utilities.go b/pkg/flowcli/util/utilities.go index 6831d5b49..c5047f956 100644 --- a/pkg/flowcli/util/utilities.go +++ b/pkg/flowcli/util/utilities.go @@ -22,6 +22,7 @@ import ( "bytes" "fmt" "io/ioutil" + "strings" "text/tabwriter" "github.com/fatih/color" @@ -80,8 +81,8 @@ func ConvertSigAndHashAlgo( return sigAlgo, hashAlgo, nil } -// StringContains returns true if the slice contains the given string. -func StringContains(s []string, e string) bool { +// ContainsString returns true if the slice contains the given string. +func ContainsString(s []string, e string) bool { for _, a := range s { if a == e { return true @@ -91,6 +92,16 @@ func StringContains(s []string, e string) bool { return false } +func ContainsStringInsensitive(haystack []string, needle string) bool { + for _, n := range haystack { + if strings.ToLower(n) == needle { + return true + } + } + + return false +} + // GetAddressNetwork returns the chain ID for an address. func GetAddressNetwork(address flow.Address) (flow.ChainID, error) { networks := []flow.ChainID{ @@ -111,15 +122,6 @@ func CreateTabWriter(b *bytes.Buffer) *tabwriter.Writer { return tabwriter.NewWriter(b, 0, 8, 1, '\t', tabwriter.AlignRight) } -func ContainsString(s []string, e string) bool { - for _, a := range s { - if a == e { - return true - } - } - return false -} - func ParseAddress(value string) (flow.Address, bool) { address := flow.HexToAddress(value) From 00ad67b38a79943eabf6a4d1cf0b9e532f503045 Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Mon, 17 May 2021 12:02:43 +0200 Subject: [PATCH 06/44] transactions exclude include --- internal/transactions/transactions.go | 68 ++++++++++++++++++--------- 1 file changed, 47 insertions(+), 21 deletions(-) diff --git a/internal/transactions/transactions.go b/internal/transactions/transactions.go index d19575fc5..84e87f73d 100644 --- a/internal/transactions/transactions.go +++ b/internal/transactions/transactions.go @@ -23,6 +23,8 @@ import ( "encoding/json" "fmt" + "github.com/onflow/flow-cli/internal/command" + jsoncdc "github.com/onflow/cadence/encoding/json" "github.com/onflow/flow-go-sdk" "github.com/spf13/cobra" @@ -47,9 +49,11 @@ func init() { // TransactionResult represent result from all account commands type TransactionResult struct { - result *flow.TransactionResult - tx *flow.Transaction - code bool + result *flow.TransactionResult + tx *flow.Transaction + code bool + include []string + exclude []string } // JSON convert result to JSON @@ -117,21 +121,35 @@ func (r *TransactionResult) String() string { _, _ = fmt.Fprintf(writer, "\nNo Envelope Signatures\n") } + // todo add exclude flags + for i, e := range r.tx.PayloadSignatures { - _, _ = fmt.Fprintf(writer, "\nPayload Signature %v:\n", i) - _, _ = fmt.Fprintf(writer, " Address\t%s\n", e.Address) - _, _ = fmt.Fprintf(writer, " Signature\t%x\n", e.Signature) - _, _ = fmt.Fprintf(writer, " Key Index\t%d\n", e.KeyIndex) + if command.FieldIncluded(r.include, "signatures") { + _, _ = fmt.Fprintf(writer, "\nPayload Signature %v:\n", i) + _, _ = fmt.Fprintf(writer, " Address\t%s\n", e.Address) + _, _ = fmt.Fprintf(writer, " Signature\t%x\n", e.Signature) + _, _ = fmt.Fprintf(writer, " Key Index\t%d\n", e.KeyIndex) + } else { + _, _ = fmt.Fprintf(writer, "\nPayload Signature %v: %s", i, e.Address) + } } for i, e := range r.tx.EnvelopeSignatures { - _, _ = fmt.Fprintf(writer, "\nEnvelope Signature %v:\n", i) - _, _ = fmt.Fprintf(writer, " Address\t%s\n", e.Address) - _, _ = fmt.Fprintf(writer, " Signature\t%x\n", e.Signature) - _, _ = fmt.Fprintf(writer, " Key Index\t%d\n", e.KeyIndex) + if command.FieldIncluded(r.include, "signatures") { + _, _ = fmt.Fprintf(writer, "\nEnvelope Signature %v:\n", i) + _, _ = fmt.Fprintf(writer, " Address\t%s\n", e.Address) + _, _ = fmt.Fprintf(writer, " Signature\t%x\n", e.Signature) + _, _ = fmt.Fprintf(writer, " Key Index\t%d\n", e.KeyIndex) + } else { + _, _ = fmt.Fprintf(writer, "\nEnvelope Signature %v: %s", i, e.Address) + } } - if r.result != nil { + if !command.FieldIncluded(r.include, "signatures") { + _, _ = fmt.Fprintf(writer, "\nSignatures (minimized, use --include signatures)") + } + + if !command.FieldExcluded(r.exclude, "events") { e := events.EventResult{ Events: r.result.Events, } @@ -145,19 +163,27 @@ func (r *TransactionResult) String() string { } if r.tx.Script != nil { - if len(r.tx.Arguments) == 0 { - _, _ = fmt.Fprintf(writer, "\n\nArguments\tNo arguments\n") - } else { - _, _ = fmt.Fprintf(writer, "\n\nArguments (%d):\n", len(r.tx.Arguments)) - for i, argument := range r.tx.Arguments { - _, _ = fmt.Fprintf(writer, " - Argument %d: %s\n", i, argument) + if command.FieldIncluded(r.include, "code") { + if len(r.tx.Arguments) == 0 { + _, _ = fmt.Fprintf(writer, "\n\nArguments\tNo arguments\n") + } else { + _, _ = fmt.Fprintf(writer, "\n\nArguments (%d):\n", len(r.tx.Arguments)) + for i, argument := range r.tx.Arguments { + _, _ = fmt.Fprintf(writer, " - Argument %d: %s\n", i, argument) + } } - } - _, _ = fmt.Fprintf(writer, "\nCode\n\n%s\n", r.tx.Script) + _, _ = fmt.Fprintf(writer, "\nCode\n\n%s\n", r.tx.Script) + } else { + _, _ = fmt.Fprint(writer, "\n\nCode (hidden, use --include code)") + } } - _, _ = fmt.Fprintf(writer, "\n\nPayload:\n%x", r.tx.Encode()) + if command.FieldIncluded(r.include, "payload") { + _, _ = fmt.Fprintf(writer, "\n\nPayload:\n%x", r.tx.Encode()) + } else { + _, _ = fmt.Fprint(writer, "\n\nPayload (hidden, use --include payload)") + } _ = writer.Flush() return b.String() From be91bcd0e59e24c4b5b988ee2a0853dcfdfe43c5 Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Mon, 17 May 2021 12:02:57 +0200 Subject: [PATCH 07/44] refactor name --- pkg/flowcli/project/project.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/flowcli/project/project.go b/pkg/flowcli/project/project.go index e153974f7..e89d43146 100644 --- a/pkg/flowcli/project/project.go +++ b/pkg/flowcli/project/project.go @@ -219,7 +219,7 @@ func (p *Project) AccountNamesForNetwork(network string) []string { for _, account := range p.accounts { if len(p.conf.Deployments.GetByAccountAndNetwork(account.name, network)) > 0 { - if !util.StringContains(names, account.name) { + if !util.ContainsString(names, account.name) { names = append(names, account.name) } } From 76ed0e7d1bf3c5e6bd747458738d49efe1c41dc8 Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Mon, 17 May 2021 12:08:24 +0200 Subject: [PATCH 08/44] add exclude include flags to tx --- internal/transactions/get.go | 18 +++++++++++++----- internal/transactions/send-signed.go | 8 ++++++-- internal/transactions/send.go | 8 ++++++-- internal/transactions/transactions.go | 4 +--- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/internal/transactions/get.go b/internal/transactions/get.go index 60dc5b4f9..ad44855ca 100644 --- a/internal/transactions/get.go +++ b/internal/transactions/get.go @@ -28,8 +28,10 @@ import ( ) type flagsGet struct { - Sealed bool `default:"true" flag:"sealed" info:"Wait for a sealed result"` - Code bool `default:"false" flag:"code" info:"Display transaction code"` + Sealed bool `default:"true" flag:"sealed" info:"Wait for a sealed result"` + Code bool `default:"false" flag:"code" info:"⚠️ Deprecated: use include flag"` + Include []string `default:"" flag:"include" info:"Fields to include in the output"` + Exclude []string `default:"" flag:"exclude" info:"Fields to exclude from the output (events)"` } var getFlags = flagsGet{} @@ -53,6 +55,10 @@ var GetCommand = &command.Command{ fmt.Println("⚠️ DEPRECATION WARNING: use \"flow transactions get\" instead") } + if getFlags.Code { + fmt.Println("⚠️ DEPRECATION WARNING: use include flag instead") + } + tx, result, err := services.Transactions.GetStatus( args[0], // transaction id getFlags.Sealed, @@ -62,9 +68,11 @@ var GetCommand = &command.Command{ } return &TransactionResult{ - result: result, - tx: tx, - code: getFlags.Code, + result: result, + tx: tx, + code: getFlags.Code, + include: getFlags.Include, + exclude: getFlags.Exclude, }, nil }, } diff --git a/internal/transactions/send-signed.go b/internal/transactions/send-signed.go index 0dbac74df..7b2c3e49a 100644 --- a/internal/transactions/send-signed.go +++ b/internal/transactions/send-signed.go @@ -26,6 +26,8 @@ import ( ) type flagsSendSigned struct { + Include []string `default:"" flag:"include" info:"Fields to include in the output"` + Exclude []string `default:"" flag:"exclude" info:"Fields to exclude from the output"` } var sendSignedFlags = flagsSendSigned{} @@ -53,8 +55,10 @@ var SendSignedCommand = &command.Command{ } return &TransactionResult{ - result: result, - tx: tx, + result: result, + tx: tx, + include: getFlags.Include, + exclude: getFlags.Exclude, }, nil }, } diff --git a/internal/transactions/send.go b/internal/transactions/send.go index 5b861229f..a68aa1f85 100644 --- a/internal/transactions/send.go +++ b/internal/transactions/send.go @@ -32,6 +32,8 @@ type flagsSend struct { Arg []string `default:"" flag:"arg" info:"argument in Type:Value format"` Signer string `default:"emulator-account" flag:"signer" info:"Account name from configuration used to sign the transaction"` GasLimit uint64 `default:"1000" flag:"gas-limit" info:"transaction gas limit"` + Include []string `default:"" flag:"include" info:"Fields to include in the output"` + Exclude []string `default:"" flag:"exclude" info:"Fields to exclude from the output"` Code string `default:"" flag:"code" info:"⚠️ Deprecated: use filename argument"` Results bool `default:"" flag:"results" info:"⚠️ Deprecated: all transactions will provide result"` Args string `default:"" flag:"args" info:"⚠️ Deprecated: use arg or args-json flag"` @@ -86,8 +88,10 @@ var SendCommand = &command.Command{ } return &TransactionResult{ - result: result, - tx: tx, + result: result, + tx: tx, + include: getFlags.Include, + exclude: getFlags.Exclude, }, nil }, } diff --git a/internal/transactions/transactions.go b/internal/transactions/transactions.go index 84e87f73d..a1fb38f9b 100644 --- a/internal/transactions/transactions.go +++ b/internal/transactions/transactions.go @@ -121,8 +121,6 @@ func (r *TransactionResult) String() string { _, _ = fmt.Fprintf(writer, "\nNo Envelope Signatures\n") } - // todo add exclude flags - for i, e := range r.tx.PayloadSignatures { if command.FieldIncluded(r.include, "signatures") { _, _ = fmt.Fprintf(writer, "\nPayload Signature %v:\n", i) @@ -163,7 +161,7 @@ func (r *TransactionResult) String() string { } if r.tx.Script != nil { - if command.FieldIncluded(r.include, "code") { + if command.FieldIncluded(r.include, "code") || r.code { if len(r.tx.Arguments) == 0 { _, _ = fmt.Fprintf(writer, "\n\nArguments\tNo arguments\n") } else { From 1921d7e3a696d7a14d9bee7e9df6f6360382f5aa Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Mon, 17 May 2021 13:06:47 +0200 Subject: [PATCH 09/44] accounts add include flag support --- internal/accounts/accounts.go | 29 +++++++++++++++++++--------- internal/accounts/contract-add.go | 6 ++++-- internal/accounts/contract-remove.go | 6 ++++-- internal/accounts/contract-update.go | 6 ++++-- internal/accounts/create.go | 2 ++ internal/accounts/get.go | 10 ++++++++-- 6 files changed, 42 insertions(+), 17 deletions(-) diff --git a/internal/accounts/accounts.go b/internal/accounts/accounts.go index ed4bb1ca5..0d3a4e937 100644 --- a/internal/accounts/accounts.go +++ b/internal/accounts/accounts.go @@ -22,6 +22,8 @@ import ( "bytes" "fmt" + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/cadence" "github.com/onflow/flow-go-sdk" "github.com/spf13/cobra" @@ -48,6 +50,7 @@ func init() { type AccountResult struct { *flow.Account showCode bool + include []string } // JSON convert result to JSON @@ -97,24 +100,32 @@ func (r *AccountResult) String() string { _, _ = fmt.Fprintf(writer, "\tSignature Algorithm\t %s\n", key.SigAlgo) _, _ = fmt.Fprintf(writer, "\tHash Algorithm\t %s\n", key.HashAlgo) _, _ = fmt.Fprintf(writer, "\tRevoked \t %t\n", key.Revoked) - fmt.Fprintf(writer, "\tSequence Number \t %d\n", key.SequenceNumber) - fmt.Fprintf(writer, "\tIndex \t %d\n", key.Index) - fmt.Fprintf(writer, "\n") + _, _ = fmt.Fprintf(writer, "\tSequence Number \t %d\n", key.SequenceNumber) + _, _ = fmt.Fprintf(writer, "\tIndex \t %d\n", key.Index) + _, _ = fmt.Fprintf(writer, "\n") + + // only show up to 3 keys and then show label to expand more info + if i == 3 && !command.FieldIncluded(r.include, "keys") { + _, _ = fmt.Fprint(writer, "...keys minimized, use --include keys flag if you want to view all\n\n") + break + } } - fmt.Fprintf(writer, "Contracts Deployed: %d\n", len(r.Contracts)) + _, _ = fmt.Fprintf(writer, "Contracts Deployed: %d\n", len(r.Contracts)) for name := range r.Contracts { - fmt.Fprintf(writer, "Contract: '%s'\n", name) + _, _ = fmt.Fprintf(writer, "Contract: '%s'\n", name) } - if r.showCode { + if r.showCode || command.FieldIncluded(r.include, "contracts") { for name, code := range r.Contracts { - fmt.Fprintf(writer, "Contracts '%s':\n", name) - fmt.Fprintln(writer, string(code)) + _, _ = fmt.Fprintf(writer, "Contracts '%s':\n", name) + _, _ = fmt.Fprintln(writer, string(code)) } + } else { + _, _ = fmt.Fprint(writer, "\n\nContracts (hidden, use --include contracts)") } - writer.Flush() + _ = writer.Flush() return b.String() } diff --git a/internal/accounts/contract-add.go b/internal/accounts/contract-add.go index 19643c5f8..34f9006b7 100644 --- a/internal/accounts/contract-add.go +++ b/internal/accounts/contract-add.go @@ -28,8 +28,9 @@ import ( ) type flagsAddContract struct { - Signer string `default:"emulator-account" flag:"signer" info:"Account name from configuration used to sign the transaction"` - Results bool `default:"false" flag:"results" info:"⚠️ Deprecated: results are provided by default"` + Signer string `default:"emulator-account" flag:"signer" info:"Account name from configuration used to sign the transaction"` + Results bool `default:"false" flag:"results" info:"⚠️ Deprecated: results are provided by default"` + Include []string `default:"" flag:"include" info:"Fields to include in the output"` } var addContractFlags = flagsAddContract{} @@ -66,6 +67,7 @@ var AddContractCommand = &command.Command{ return &AccountResult{ Account: account, showCode: false, + include: addContractFlags.Include, }, nil }, } diff --git a/internal/accounts/contract-remove.go b/internal/accounts/contract-remove.go index e41787c44..9cc16c547 100644 --- a/internal/accounts/contract-remove.go +++ b/internal/accounts/contract-remove.go @@ -28,8 +28,9 @@ import ( ) type flagsRemoveContract struct { - Signer string `default:"emulator-account" flag:"signer" info:"Account name from configuration used to sign the transaction"` - Results bool `default:"false" flag:"results" info:"⚠️ Deprecated: results are provided by default"` + Signer string `default:"emulator-account" flag:"signer" info:"Account name from configuration used to sign the transaction"` + Results bool `default:"false" flag:"results" info:"⚠️ Deprecated: results are provided by default"` + Include []string `default:"" flag:"include" info:"Fields to include in the output"` } var flagsRemove = flagsRemoveContract{} @@ -63,6 +64,7 @@ var RemoveCommand = &command.Command{ return &AccountResult{ Account: account, showCode: false, + include: flagsRemove.Include, }, nil }, } diff --git a/internal/accounts/contract-update.go b/internal/accounts/contract-update.go index a411ef952..9e23337f0 100644 --- a/internal/accounts/contract-update.go +++ b/internal/accounts/contract-update.go @@ -28,8 +28,9 @@ import ( ) type flagsUpdateContract struct { - Signer string `default:"emulator-account" flag:"signer" info:"Account name from configuration used to sign the transaction"` - Results bool `default:"false" flag:"results" info:"⚠️ Deprecated: results are provided by default"` + Signer string `default:"emulator-account" flag:"signer" info:"Account name from configuration used to sign the transaction"` + Results bool `default:"false" flag:"results" info:"⚠️ Deprecated: results are provided by default"` + Include []string `default:"" flag:"include" info:"Fields to include in the output"` } var updateFlags = flagsUpdateContract{} @@ -65,6 +66,7 @@ var UpdateCommand = &command.Command{ return &AccountResult{ Account: account, showCode: false, + include: updateFlags.Include, }, nil }, } diff --git a/internal/accounts/create.go b/internal/accounts/create.go index feb5ecfb7..27e5a3d7c 100644 --- a/internal/accounts/create.go +++ b/internal/accounts/create.go @@ -35,6 +35,7 @@ type flagsCreate struct { HashAlgo string `default:"SHA3_256" flag:"hash-algo" info:"Hash used for the digest"` Contracts []string `flag:"contract" info:"Contract to be deployed during account creation. "` Results bool `default:"false" flag:"results" info:"⚠️ Deprecated: results are provided by default"` + Include []string `default:"" flag:"include" info:"Fields to include in the output"` } var createFlags = flagsCreate{} @@ -71,6 +72,7 @@ var CreateCommand = &command.Command{ return &AccountResult{ Account: account, + include: createFlags.Include, }, nil }, } diff --git a/internal/accounts/get.go b/internal/accounts/get.go index 26433c52a..4c2cac4a8 100644 --- a/internal/accounts/get.go +++ b/internal/accounts/get.go @@ -28,8 +28,9 @@ import ( ) type flagsGet struct { - Contracts bool `default:"false" flag:"contracts" info:"Display contracts deployed to the account"` - Code bool `default:"false" flag:"code" info:"⚠️ Deprecated: use contracts flag instead"` + Contracts bool `default:"false" flag:"contracts" info:"⚠️ Deprecated: use include flag instead"` + Code bool `default:"false" flag:"code" info:"⚠️ Deprecated: use contracts flag instead"` + Include []string `default:"" flag:"include" info:"Fields to include in the output"` } var getFlags = flagsGet{} @@ -52,6 +53,10 @@ var GetCommand = &command.Command{ fmt.Println("⚠️ DEPRECATION WARNING: use contracts flag instead") } + if getFlags.Contracts { + fmt.Println("⚠️ DEPRECATION WARNING: use include contracts flag instead") + } + account, err := services.Accounts.Get(args[0]) // address if err != nil { return nil, err @@ -60,6 +65,7 @@ var GetCommand = &command.Command{ return &AccountResult{ Account: account, showCode: getFlags.Contracts || getFlags.Code, + include: getFlags.Include, }, nil }, } From 5f932ee9d8b79141d15b338034e34ac939987542 Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Mon, 17 May 2021 13:07:17 +0200 Subject: [PATCH 10/44] blocks include flag support --- internal/blocks/blocks.go | 7 +++++-- internal/blocks/get.go | 15 ++++++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/internal/blocks/blocks.go b/internal/blocks/blocks.go index b86a88cc7..892f22d84 100644 --- a/internal/blocks/blocks.go +++ b/internal/blocks/blocks.go @@ -22,6 +22,8 @@ import ( "bytes" "fmt" + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flow-go-sdk" "github.com/onflow/flow-go-sdk/client" "github.com/spf13/cobra" @@ -46,6 +48,7 @@ type BlockResult struct { events []client.BlockEvents collections []*flow.Collection verbose bool + included []string } // JSON convert result to JSON @@ -94,7 +97,7 @@ func (r *BlockResult) String() string { for i, guarantee := range r.block.CollectionGuarantees { _, _ = fmt.Fprintf(writer, " Collection %d:\t%s\n", i, guarantee.CollectionID) - if r.verbose { + if r.verbose || command.FieldIncluded(r.included, "transactions") { for x, tx := range r.collections[i].TransactionIDs { _, _ = fmt.Fprintf(writer, " Transaction %d: %s\n", x, tx) } @@ -108,7 +111,7 @@ func (r *BlockResult) String() string { _, _ = fmt.Fprintf(writer, "%s", e.String()) } - writer.Flush() + _ = writer.Flush() return b.String() } diff --git a/internal/blocks/get.go b/internal/blocks/get.go index f11e99575..2a58691c5 100644 --- a/internal/blocks/get.go +++ b/internal/blocks/get.go @@ -28,11 +28,12 @@ import ( ) type flagsBlocks struct { - Events string `default:"" flag:"events" info:"List events of this type for the block"` - Verbose bool `default:"false" flag:"verbose" info:"Display transactions in block"` - Latest bool `default:"false" flag:"latest" info:"⚠️ No longer supported: use command argument"` - BlockID string `default:"" flag:"id" info:"⚠️ No longer supported: use command argument"` - BlockHeight uint64 `default:"0" flag:"height" info:"⚠️ No longer supported: use command argument"` + Events string `default:"" flag:"events" info:"List events of this type for the block"` + Include []string `default:"" flag:"include" info:"Fields to include in the output"` + Verbose bool `default:"false" flag:"verbose" info:"⚠️ Deprecated: use include transactions flag instead"` + Latest bool `default:"false" flag:"latest" info:"⚠️ No longer supported: use command argument"` + BlockID string `default:"" flag:"id" info:"⚠️ No longer supported: use command argument"` + BlockHeight uint64 `default:"0" flag:"height" info:"⚠️ No longer supported: use command argument"` } var blockFlags = flagsBlocks{} @@ -55,6 +56,10 @@ var GetCommand = &command.Command{ return nil, fmt.Errorf("⚠️ No longer supported: use command argument.") } + if blockFlags.Verbose { + fmt.Println("⚠️ DEPRECATION WARNING: use include transactions flag instead") + } + block, events, collections, err := services.Blocks.GetBlock( args[0], // block id blockFlags.Events, From 3fda5a7ade9e2644f3802a1df4eb93c5115da562 Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Mon, 17 May 2021 13:07:32 +0200 Subject: [PATCH 11/44] add exclude flag to tx --- internal/transactions/send-signed.go | 6 +++--- internal/transactions/send.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/transactions/send-signed.go b/internal/transactions/send-signed.go index 7b2c3e49a..61de3e88f 100644 --- a/internal/transactions/send-signed.go +++ b/internal/transactions/send-signed.go @@ -27,7 +27,7 @@ import ( type flagsSendSigned struct { Include []string `default:"" flag:"include" info:"Fields to include in the output"` - Exclude []string `default:"" flag:"exclude" info:"Fields to exclude from the output"` + Exclude []string `default:"" flag:"exclude" info:"Fields to exclude from the output (events)"` } var sendSignedFlags = flagsSendSigned{} @@ -57,8 +57,8 @@ var SendSignedCommand = &command.Command{ return &TransactionResult{ result: result, tx: tx, - include: getFlags.Include, - exclude: getFlags.Exclude, + include: sendSignedFlags.Include, + exclude: sendSignedFlags.Exclude, }, nil }, } diff --git a/internal/transactions/send.go b/internal/transactions/send.go index a68aa1f85..1dfc07be2 100644 --- a/internal/transactions/send.go +++ b/internal/transactions/send.go @@ -33,7 +33,7 @@ type flagsSend struct { Signer string `default:"emulator-account" flag:"signer" info:"Account name from configuration used to sign the transaction"` GasLimit uint64 `default:"1000" flag:"gas-limit" info:"transaction gas limit"` Include []string `default:"" flag:"include" info:"Fields to include in the output"` - Exclude []string `default:"" flag:"exclude" info:"Fields to exclude from the output"` + Exclude []string `default:"" flag:"exclude" info:"Fields to exclude from the output (events)"` Code string `default:"" flag:"code" info:"⚠️ Deprecated: use filename argument"` Results bool `default:"" flag:"results" info:"⚠️ Deprecated: all transactions will provide result"` Args string `default:"" flag:"args" info:"⚠️ Deprecated: use arg or args-json flag"` @@ -90,8 +90,8 @@ var SendCommand = &command.Command{ return &TransactionResult{ result: result, tx: tx, - include: getFlags.Include, - exclude: getFlags.Exclude, + include: sendFlags.Include, + exclude: sendFlags.Exclude, }, nil }, } From cafb4547cd6efef889ab381c595b267756ef2cd5 Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Mon, 17 May 2021 13:14:47 +0200 Subject: [PATCH 12/44] release root commit From 3b1c862b60aac3c191368e13f60ac0e430cc4448 Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Mon, 17 May 2021 16:40:04 +0200 Subject: [PATCH 13/44] fix detection of imports --- pkg/flowcli/contracts/resolver.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/flowcli/contracts/resolver.go b/pkg/flowcli/contracts/resolver.go index 3963e6114..42d74db4d 100644 --- a/pkg/flowcli/contracts/resolver.go +++ b/pkg/flowcli/contracts/resolver.go @@ -112,8 +112,9 @@ func (r *Resolver) getFileImports() []string { imports := make([]string, 0) for _, importDeclaration := range r.program.ImportDeclarations() { - _, ok := importDeclaration.Location.(common.AddressLocation) - if !ok { + _, isFileImport := importDeclaration.Location.(common.StringLocation) + + if isFileImport { imports = append(imports, importDeclaration.Location.String()) } } From caae4a14c01f5797691fc965e7d3f55091ed912f Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Mon, 17 May 2021 18:25:39 +0200 Subject: [PATCH 14/44] put back decode keys --- internal/keys/keys.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/keys/keys.go b/internal/keys/keys.go index 69b602881..bbe635a77 100644 --- a/internal/keys/keys.go +++ b/internal/keys/keys.go @@ -38,6 +38,7 @@ var Cmd = &cobra.Command{ func init() { GenerateCommand.AddToParent(Cmd) + DecodeCommand.AddToParent(Cmd) } // KeyResult represent result from all account commands From 9802751ff6e44e70d413e24d24fb172ab08062d3 Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Mon, 17 May 2021 18:32:13 +0200 Subject: [PATCH 15/44] added docs --- docs/decode-keys.md | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 docs/decode-keys.md diff --git a/docs/decode-keys.md b/docs/decode-keys.md new file mode 100644 index 000000000..a80a76f40 --- /dev/null +++ b/docs/decode-keys.md @@ -0,0 +1,49 @@ +--- +title: Decode Account Key with the Flow CLI +sidebar_title: Decode Account Keys +description: How to decode rlp encoded key pair from the command line +--- + +The Flow CLI provides a command to decode RLP encoded account key. + +```shell +flow keys decode +``` + +## Example Usage + +```shell +> flow keys decode f847b84084d716c14b051ad6b001624f738f5d302636e6b07cc75e4530af7776a4368a2b586dbefc0564ee28384c2696f178cbed52e62811bcc9ecb59568c996d342db2402038203e8 + +Public Key 84d716c14b051ad6b001624f738f5d302636e6b07cc75e4530af7776a4368a2b586dbefc0564ee28384c2696f178cbed52e62811bcc9ecb59568c996d342db24 +Signature algorithm ECDSA_P256 +Hash algorithm SHA3_256 +Weight 1000 +Revoked false +``` + +## Flags + +### Filter + +- Flag: `--filter` +- Short Flag: `-x` +- Valid inputs: a case-sensitive name of the result property. + +Specify any property name from the result you want to return as the only value. + +### Output + +- Flag: `--output` +- Short Flag: `-o` +- Valid inputs: `json`, `inline` + +Specify the format of the command results. + +### Save + +- Flag: `--save` +- Short Flag: `-s` +- Valid inputs: a path in the current filesystem. + +Specify the filename where you want the result to be saved From 6f3239cc50458e099ba1021f65ed42dee25680a5 Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Mon, 17 May 2021 18:32:20 +0200 Subject: [PATCH 16/44] fixed naming --- internal/keys/decode.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/keys/decode.go b/internal/keys/decode.go index 3c1b07dd7..cf6c34e80 100644 --- a/internal/keys/decode.go +++ b/internal/keys/decode.go @@ -31,10 +31,10 @@ var decodeFlags = flagsDecode{} var DecodeCommand = &command.Command{ Cmd: &cobra.Command{ - Use: "decode ", - Short: "Decode a public account key hex string", + Use: "decode ", + Short: "Decode a rlp encoded account key", Args: cobra.ExactArgs(1), - Example: "flow keys decode 4a22246...31bce1e71a7b6d11", + Example: "flow keys decode f847b8408...2402038203e8", }, Flags: &decodeFlags, Run: func( @@ -43,9 +43,9 @@ var DecodeCommand = &command.Command{ globalFlags command.GlobalFlags, services *services.Services, ) (command.Result, error) { - accountKey, err := services.Keys.Decode( - args[0], // public key - ) + rlpEncoded := args[0] + + accountKey, err := services.Keys.Decode(rlpEncoded) if err != nil { return nil, err } From 6f3ab8485211aa0d332961f76373bcee5cc45026 Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Tue, 18 May 2021 16:00:22 +0200 Subject: [PATCH 17/44] todo refactor --- pkg/flowcli/config/json/account.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/flowcli/config/json/account.go b/pkg/flowcli/config/json/account.go index 02b66205c..dda32c33c 100644 --- a/pkg/flowcli/config/json/account.go +++ b/pkg/flowcli/config/json/account.go @@ -139,6 +139,7 @@ func transformAccountsToJSON(accounts config.Accounts) jsonAccounts { return jsonAccounts } +// TODO(sideninja) refactor keys to use json.RawMessage and decide if unmarshal into simple or advance structure based on that field type jsonAccountSimple struct { Address string `json:"address"` Keys string `json:"keys"` From 5959692a1d1a92abaa321ed0818e205eecc80a80 Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Wed, 19 May 2021 17:28:56 +0200 Subject: [PATCH 18/44] add banner logo --- README.md | 2 ++ logo-cli.svg | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 logo-cli.svg diff --git a/README.md b/README.md index 24f9241d0..a93577416 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +![](./logo-cli.svg) + # Flow CLI The Flow CLI is a command-line interface that provides useful utilities for building Flow applications. diff --git a/logo-cli.svg b/logo-cli.svg new file mode 100644 index 000000000..f0b6f1e9c --- /dev/null +++ b/logo-cli.svg @@ -0,0 +1,23 @@ + + + Group 2 + + + + + CLI + + + + + + + + + + + + + + + \ No newline at end of file From de9858d6985d2c2fda4483f627ee097b0e6d20b3 Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Thu, 20 May 2021 09:39:13 +0200 Subject: [PATCH 19/44] add logs to account --- pkg/flowcli/services/accounts.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pkg/flowcli/services/accounts.go b/pkg/flowcli/services/accounts.go index 52556a4d7..15c5f6aec 100644 --- a/pkg/flowcli/services/accounts.go +++ b/pkg/flowcli/services/accounts.go @@ -343,15 +343,17 @@ func (a *Accounts) addContract( if updateExisting { a.logger.Info(fmt.Sprintf( - "Contract '%s' updated on the account '%s'.", + "Contract '%s' updated on the account '%s'.\nTransaction ID: %s.", contractName, account.Address(), + sentTx.ID().String(), )) } else { a.logger.Info(fmt.Sprintf( - "Contract '%s' deployed to the account '%s'.", + "Contract '%s' deployed to the account '%s'.\nTransaction ID: %s.", contractName, account.Address(), + sentTx.ID().String(), )) } @@ -398,7 +400,12 @@ func (a *Accounts) RemoveContract( } a.logger.StopProgress() - a.logger.Info(fmt.Sprintf("Contract %s removed from account %s\n", contractName, account.Address())) + a.logger.Info(fmt.Sprintf( + "Contract %s removed from account %s.\nTransaction ID: %s.", + contractName, + account.Address(), + sentTx.ID().String(), + )) return a.gateway.GetAccount(account.Address()) } From 1db85d0efe0b0583f30e64e2651c445cf87b2914 Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Thu, 20 May 2021 13:09:19 +0200 Subject: [PATCH 20/44] refactor and extract emoji --- internal/command/command.go | 33 ++++++++++++++------------- internal/keys/keys.go | 4 +++- internal/transactions/transactions.go | 6 +++-- pkg/flowcli/output/emoji.go | 29 +++++++++++++++++++++++ pkg/flowcli/output/logger.go | 2 +- pkg/flowcli/services/project.go | 2 +- 6 files changed, 55 insertions(+), 21 deletions(-) create mode 100644 pkg/flowcli/output/emoji.go diff --git a/internal/command/command.go b/internal/command/command.go index ea8ff954c..f1aa43e2c 100644 --- a/internal/command/command.go +++ b/internal/command/command.go @@ -301,7 +301,7 @@ func outputResult(result string, saveFlag string, formatFlag string, filterFlag Fs: afero.NewOsFs(), } - fmt.Printf("💾 result saved to: %s \n", saveFlag) + fmt.Printf("%s result saved to: %s \n", output.SaveEmoji(), saveFlag) return af.WriteFile(saveFlag, []byte(result), 0644) } @@ -350,32 +350,32 @@ func handleError(description string, err error) { // handle rpc error switch t := err.(type) { case *client.RPCError: - _, _ = fmt.Fprintf(os.Stderr, "❌ Grpc Error: %s \n", t.GRPCStatus().Err().Error()) + _, _ = fmt.Fprintf(os.Stderr, "%s Grpc Error: %s \n", output.ErrorEmoji(), t.GRPCStatus().Err().Error()) default: if errors.Is(err, config.ErrOutdatedFormat) { - _, _ = fmt.Fprintf(os.Stderr, "❌ Config Error: %s \n", err.Error()) - _, _ = fmt.Fprintf(os.Stderr, "🙏 Please reset configuration using: 'flow init --reset'. Read more about new configuration here: https://github.com/onflow/flow-cli/releases/tag/v0.17.0") + _, _ = fmt.Fprintf(os.Stderr, "%s Config Error: %s \n", output.ErrorEmoji(), err.Error()) + _, _ = fmt.Fprintf(os.Stderr, "%s Please reset configuration using: 'flow init --reset'. Read more about new configuration here: https://github.com/onflow/flow-cli/releases/tag/v0.17.0", output.TryEmoji()) } else if strings.Contains(err.Error(), "transport:") { - _, _ = fmt.Fprintf(os.Stderr, "❌ %s \n", strings.Split(err.Error(), "transport:")[1]) - _, _ = fmt.Fprintf(os.Stderr, "🙏 Make sure your emulator is running or connection address is correct.") + _, _ = fmt.Fprintf(os.Stderr, "%s %s \n", output.ErrorEmoji(), strings.Split(err.Error(), "transport:")[1]) + _, _ = fmt.Fprintf(os.Stderr, "%s Make sure your emulator is running or connection address is correct.", output.TryEmoji()) } else if strings.Contains(err.Error(), "NotFound desc =") { - _, _ = fmt.Fprintf(os.Stderr, "❌ Not Found:%s \n", strings.Split(err.Error(), "NotFound desc =")[1]) + _, _ = fmt.Fprintf(os.Stderr, "%s Not Found:%s \n", output.ErrorEmoji(), strings.Split(err.Error(), "NotFound desc =")[1]) } else if strings.Contains(err.Error(), "code = InvalidArgument desc = ") { desc := strings.Split(err.Error(), "code = InvalidArgument desc = ") - _, _ = fmt.Fprintf(os.Stderr, "❌ Invalid argument: %s \n", desc[len(desc)-1]) + _, _ = fmt.Fprintf(os.Stderr, "%s Invalid argument: %s \n", output.ErrorEmoji(), desc[len(desc)-1]) if strings.Contains(err.Error(), "is invalid for chain") { - _, _ = fmt.Fprintf(os.Stderr, "🙏 Check you are connecting to the correct network or account address you use is correct.") + _, _ = fmt.Fprintf(os.Stderr, "%s Check you are connecting to the correct network or account address you use is correct.", output.TryEmoji()) } else { - _, _ = fmt.Fprintf(os.Stderr, "🙏 Check your argument and flags value, you can use --help.") + _, _ = fmt.Fprintf(os.Stderr, "%s Check your argument and flags value, you can use --help.", output.TryEmoji()) } } else if strings.Contains(err.Error(), "invalid signature:") { - _, _ = fmt.Fprintf(os.Stderr, "❌ Invalid signature: %s \n", strings.Split(err.Error(), "invalid signature:")[1]) - _, _ = fmt.Fprintf(os.Stderr, "🙏 Check the signer private key is provided or is in the correct format. If running emulator, make sure it's using the same configuration as this command.") + _, _ = fmt.Fprintf(os.Stderr, "%s Invalid signature: %s \n", output.ErrorEmoji(), strings.Split(err.Error(), "invalid signature:")[1]) + _, _ = fmt.Fprintf(os.Stderr, "%s Check the signer private key is provided or is in the correct format. If running emulator, make sure it's using the same configuration as this command.", output.TryEmoji()) } else if strings.Contains(err.Error(), "signature could not be verified using public key with") { - _, _ = fmt.Fprintf(os.Stderr, "❌ %s: %s \n", description, err) - _, _ = fmt.Fprintf(os.Stderr, "🙏 If you are running emulator locally make sure that the emulator was started with the same config as used in this command. \nTry restarting the emulator.") + _, _ = fmt.Fprintf(os.Stderr, "%s %s: %s \n", output.ErrorEmoji(), description, err) + _, _ = fmt.Fprintf(os.Stderr, "%s If you are running emulator locally make sure that the emulator was started with the same config as used in this command. \nTry restarting the emulator.", output.TryEmoji()) } else { - _, _ = fmt.Fprintf(os.Stderr, "❌ %s: %s", description, err) + _, _ = fmt.Fprintf(os.Stderr, "%s %s: %s", output.ErrorEmoji(), description, err) } } @@ -396,8 +396,9 @@ func checkVersion(logger output.Logger) { if latestVersion != build.Semver() { logger.Info(fmt.Sprintf( - "\n⚠️ Version warning: a new version of Flow CLI is available (%s).\n"+ + "\n%s Version warning: a new version of Flow CLI is available (%s).\n"+ "Read the installation guide for upgrade instructions: https://docs.onflow.org/flow-cli/install", + output.WarningEmoji(), strings.ReplaceAll(string(latestVersion), "\n", ""), )) } diff --git a/internal/keys/keys.go b/internal/keys/keys.go index 69b602881..16986039f 100644 --- a/internal/keys/keys.go +++ b/internal/keys/keys.go @@ -23,6 +23,8 @@ import ( "encoding/hex" "fmt" + "github.com/onflow/flow-cli/pkg/flowcli/output" + "github.com/onflow/flow-go-sdk" "github.com/onflow/flow-go-sdk/crypto" "github.com/spf13/cobra" @@ -65,7 +67,7 @@ func (k *KeyResult) String() string { writer := util.CreateTabWriter(&b) if k.privateKey != nil { - _, _ = fmt.Fprintf(writer, "🔴️ Store private key safely and don't share with anyone! \n") + _, _ = fmt.Fprintf(writer, "%s Store private key safely and don't share with anyone! \n", output.StopEmoji()) _, _ = fmt.Fprintf(writer, "Private Key \t %x \n", k.privateKey.Encode()) } diff --git a/internal/transactions/transactions.go b/internal/transactions/transactions.go index a1fb38f9b..e27d39ff4 100644 --- a/internal/transactions/transactions.go +++ b/internal/transactions/transactions.go @@ -23,6 +23,8 @@ import ( "encoding/json" "fmt" + "github.com/onflow/flow-cli/pkg/flowcli/output" + "github.com/onflow/flow-cli/internal/command" jsoncdc "github.com/onflow/cadence/encoding/json" @@ -94,12 +96,12 @@ func (r *TransactionResult) String() string { if r.result != nil { if r.result.Error != nil { - _, _ = fmt.Fprintf(writer, "❌ Transaction Error \n%s\n\n\n", r.result.Error.Error()) + _, _ = fmt.Fprintf(writer, "%s Transaction Error \n%s\n\n\n", output.ErrorEmoji(), r.result.Error.Error()) } statusBadge := "" if r.result.Status == flow.TransactionStatusSealed { - statusBadge = "✅" + statusBadge = output.OkEmoji() } _, _ = fmt.Fprintf(writer, "Status\t%s %s\n", statusBadge, r.result.Status) } diff --git a/pkg/flowcli/output/emoji.go b/pkg/flowcli/output/emoji.go new file mode 100644 index 000000000..6593d0842 --- /dev/null +++ b/pkg/flowcli/output/emoji.go @@ -0,0 +1,29 @@ +package output + +func ErrorEmoji() string { + return "❌" +} + +func TryEmoji() string { + return "🙏" +} + +func WarningEmoji() string { + return "⚠️" +} + +func SaveEmoji() string { + return "💾" +} + +func StopEmoji() string { + return "🔴️" +} + +func OkEmoji() string { + return "✅" +} + +func SuccessEmoji() string { + return "✨" +} diff --git a/pkg/flowcli/output/logger.go b/pkg/flowcli/output/logger.go index cba9a6c73..01deaec7e 100644 --- a/pkg/flowcli/output/logger.go +++ b/pkg/flowcli/output/logger.go @@ -69,7 +69,7 @@ func (s *StdoutLogger) Debug(msg string) { } func (s *StdoutLogger) Error(msg string) { - s.log(fmt.Sprintf("❌ %s", util.Red(msg)), ErrorLog) + s.log(fmt.Sprintf("%s %s", ErrorEmoji(), util.Red(msg)), ErrorLog) } func (s *StdoutLogger) StartProgress(msg string) { diff --git a/pkg/flowcli/services/project.go b/pkg/flowcli/services/project.go index 021df62dc..f7dd66c56 100644 --- a/pkg/flowcli/services/project.go +++ b/pkg/flowcli/services/project.go @@ -242,7 +242,7 @@ func (p *Project) Deploy(network string, update bool) ([]*contracts.Contract, er } if !deployErr { - p.logger.Info("\n✨ All contracts deployed successfully") + p.logger.Info(fmt.Sprintf("\n%s All contracts deployed successfully", output.SuccessEmoji())) } else { err = fmt.Errorf("failed to deploy contracts") p.logger.Error(err.Error()) From f56476500d02f25198c1742ef055385753bbbd17 Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Thu, 20 May 2021 13:17:44 +0200 Subject: [PATCH 21/44] refactor status for colors and emoji --- internal/status/status.go | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/internal/status/status.go b/internal/status/status.go index 5b1a33ea0..5a00f03fe 100644 --- a/internal/status/status.go +++ b/internal/status/status.go @@ -22,6 +22,8 @@ import ( "bytes" "fmt" + "github.com/onflow/flow-cli/pkg/flowcli/output" + "github.com/spf13/cobra" "github.com/onflow/flow-cli/internal/command" @@ -62,39 +64,31 @@ type Result struct { err error } -const ( - OnlineIcon = "🟢" - OnlineStatus = "ONLINE" - - OfflineIcon = "🔴" - OfflineStatus = "OFFLINE" -) - // getStatus returns string representation for Flow network status. func (r *Result) getStatus() string { if r.err == nil { - return OnlineStatus + return "ONLINE" } - return OfflineStatus + return "OFFLINE" } // getColoredStatus returns colored string representation for Flow network status. func (r *Result) getColoredStatus() string { if r.err == nil { - return util.Green(OnlineStatus) + return output.Green(r.getStatus()) } - return util.Red(OfflineStatus) + return util.Red(output.Red(r.getStatus())) } // getIcon returns emoji icon representing Flow network status. func (r *Result) getIcon() string { if r.err == nil { - return OnlineIcon + return output.GoEmoji() } - return OfflineIcon + return output.StopEmoji() } // String converts result to a string. From 99f6098c829b65f9a1270a29a8774d9ad3730ec3 Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Thu, 20 May 2021 13:18:56 +0200 Subject: [PATCH 22/44] implement own color --- pkg/flowcli/output/colors.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 pkg/flowcli/output/colors.go diff --git a/pkg/flowcli/output/colors.go b/pkg/flowcli/output/colors.go new file mode 100644 index 000000000..a61457745 --- /dev/null +++ b/pkg/flowcli/output/colors.go @@ -0,0 +1,31 @@ +package output + +import ( + "fmt" + "runtime" +) + +var red = "\033[31m" +var green = "\033[32m" +var bold = "\033[1m" +var reset = "\033[0m" + +func printColor(msg string, color string) string { + if runtime.GOOS == "windows" { + return msg + } + + return fmt.Sprintf("%s%s%s", color, msg, reset) +} + +func Red(msg string) string { + return printColor(msg, red) +} + +func Green(msg string) string { + return printColor(msg, green) +} + +func Bold(msg string) string { + return printColor(msg, bold) +} From 1e9a1141cb892d380b9476d5696d7be9ef0dca2d Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Thu, 20 May 2021 13:19:10 +0200 Subject: [PATCH 23/44] refactor color use and remove dependency --- internal/config/init.go | 8 +++++--- internal/status/status.go | 2 +- pkg/flowcli/output/emoji.go | 4 ++++ pkg/flowcli/output/logger.go | 4 +--- pkg/flowcli/services/project.go | 4 ++-- pkg/flowcli/util/utilities.go | 6 ------ 6 files changed, 13 insertions(+), 15 deletions(-) diff --git a/internal/config/init.go b/internal/config/init.go index 0937c0559..990e1f241 100644 --- a/internal/config/init.go +++ b/internal/config/init.go @@ -22,6 +22,8 @@ import ( "bytes" "fmt" + "github.com/onflow/flow-cli/pkg/flowcli/output" + "github.com/spf13/cobra" "github.com/onflow/flow-cli/internal/command" @@ -84,11 +86,11 @@ func (r *InitResult) String() string { account, _ := r.Project.EmulatorServiceAccount() _, _ = fmt.Fprintf(writer, "Configuration initialized\n") - _, _ = fmt.Fprintf(writer, "Service account: %s\n\n", util.Bold("0x"+account.Address().String())) + _, _ = fmt.Fprintf(writer, "Service account: %s\n\n", output.Bold("0x"+account.Address().String())) _, _ = fmt.Fprintf(writer, "Start emulator by running: %s \nReset configuration using: %s\n", - util.Bold("'flow emulator'"), - util.Bold("'flow init --reset'"), + output.Bold("'flow emulator'"), + output.Bold("'flow init --reset'"), ) writer.Flush() diff --git a/internal/status/status.go b/internal/status/status.go index 5a00f03fe..ee1a45095 100644 --- a/internal/status/status.go +++ b/internal/status/status.go @@ -79,7 +79,7 @@ func (r *Result) getColoredStatus() string { return output.Green(r.getStatus()) } - return util.Red(output.Red(r.getStatus())) + return output.Red(output.Red(r.getStatus())) } // getIcon returns emoji icon representing Flow network status. diff --git a/pkg/flowcli/output/emoji.go b/pkg/flowcli/output/emoji.go index 6593d0842..cc86cc500 100644 --- a/pkg/flowcli/output/emoji.go +++ b/pkg/flowcli/output/emoji.go @@ -20,6 +20,10 @@ func StopEmoji() string { return "🔴️" } +func GoEmoji() string { + return "🟢" +} + func OkEmoji() string { return "✅" } diff --git a/pkg/flowcli/output/logger.go b/pkg/flowcli/output/logger.go index 01deaec7e..8e9009871 100644 --- a/pkg/flowcli/output/logger.go +++ b/pkg/flowcli/output/logger.go @@ -20,8 +20,6 @@ package output import ( "fmt" - - "github.com/onflow/flow-cli/pkg/flowcli/util" ) const ( @@ -69,7 +67,7 @@ func (s *StdoutLogger) Debug(msg string) { } func (s *StdoutLogger) Error(msg string) { - s.log(fmt.Sprintf("%s %s", ErrorEmoji(), util.Red(msg)), ErrorLog) + s.log(fmt.Sprintf("%s %s", ErrorEmoji(), output.Red(msg)), ErrorLog) } func (s *StdoutLogger) StartProgress(msg string) { diff --git a/pkg/flowcli/services/project.go b/pkg/flowcli/services/project.go index f7dd66c56..374434403 100644 --- a/pkg/flowcli/services/project.go +++ b/pkg/flowcli/services/project.go @@ -221,7 +221,7 @@ func (p *Project) Deploy(network string, update bool) ([]*contracts.Contract, er } p.logger.StartProgress( - fmt.Sprintf("%s deploying...", util.Bold(contract.Name())), + fmt.Sprintf("%s deploying...", output.Bold(contract.Name())), ) result, err := p.gateway.GetTransactionResult(sentTx, true) @@ -232,7 +232,7 @@ func (p *Project) Deploy(network string, update bool) ([]*contracts.Contract, er if result.Error == nil && !deployErr { p.logger.StopProgress() - fmt.Printf("%s -> 0x%s\n", util.Green(contract.Name()), contract.Target()) + fmt.Printf("%s -> 0x%s\n", output.Green(contract.Name()), contract.Target()) } else { p.logger.StopProgress() p.logger.Error( diff --git a/pkg/flowcli/util/utilities.go b/pkg/flowcli/util/utilities.go index c5047f956..511a2f87b 100644 --- a/pkg/flowcli/util/utilities.go +++ b/pkg/flowcli/util/utilities.go @@ -25,16 +25,10 @@ import ( "strings" "text/tabwriter" - "github.com/fatih/color" - "github.com/onflow/flow-go-sdk" "github.com/onflow/flow-go-sdk/crypto" ) -var Green = color.New(color.FgGreen, color.Bold).SprintfFunc() -var Red = color.New(color.FgRed, color.Bold).SprintfFunc() -var Bold = color.New(color.FgCyan).SprintfFunc() - // LoadFile loads a file by filename. func LoadFile(filename string) ([]byte, error) { var code []byte From 4dec96b1ea85dc9bb87a32dfadc6bec03bc63087 Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Thu, 20 May 2021 13:21:09 +0200 Subject: [PATCH 24/44] version check fix --- internal/command/command.go | 4 ++-- pkg/flowcli/output/logger.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/command/command.go b/internal/command/command.go index f1aa43e2c..35f552d62 100644 --- a/internal/command/command.go +++ b/internal/command/command.go @@ -396,8 +396,8 @@ func checkVersion(logger output.Logger) { if latestVersion != build.Semver() { logger.Info(fmt.Sprintf( - "\n%s Version warning: a new version of Flow CLI is available (%s).\n"+ - "Read the installation guide for upgrade instructions: https://docs.onflow.org/flow-cli/install", + "\n%s Version warning: a new version of Flow CLI is available (%s).\n"+ + " Read the installation guide for upgrade instructions: https://docs.onflow.org/flow-cli/install\n", output.WarningEmoji(), strings.ReplaceAll(string(latestVersion), "\n", ""), )) diff --git a/pkg/flowcli/output/logger.go b/pkg/flowcli/output/logger.go index 8e9009871..3cb717637 100644 --- a/pkg/flowcli/output/logger.go +++ b/pkg/flowcli/output/logger.go @@ -67,7 +67,7 @@ func (s *StdoutLogger) Debug(msg string) { } func (s *StdoutLogger) Error(msg string) { - s.log(fmt.Sprintf("%s %s", ErrorEmoji(), output.Red(msg)), ErrorLog) + s.log(fmt.Sprintf("%s %s", ErrorEmoji(), Red(msg)), ErrorLog) } func (s *StdoutLogger) StartProgress(msg string) { From ef19ca7d311391accede9294828955a831874a6d Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Thu, 20 May 2021 18:01:29 +0200 Subject: [PATCH 25/44] emoji test os --- pkg/flowcli/output/emoji.go | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/pkg/flowcli/output/emoji.go b/pkg/flowcli/output/emoji.go index cc86cc500..b0465cd61 100644 --- a/pkg/flowcli/output/emoji.go +++ b/pkg/flowcli/output/emoji.go @@ -1,33 +1,43 @@ package output +import "runtime" + +func printEmoji(emoji string) string { + if runtime.GOOS == "windows" { + return "" + } + + return emoji +} + func ErrorEmoji() string { - return "❌" + return printEmoji("❌") } func TryEmoji() string { - return "🙏" + return printEmoji("🙏") } func WarningEmoji() string { - return "⚠️" + return printEmoji("⚠️") } func SaveEmoji() string { - return "💾" + return printEmoji("💾") } func StopEmoji() string { - return "🔴️" + return printEmoji("🔴️") } func GoEmoji() string { - return "🟢" + return printEmoji("🟢") } func OkEmoji() string { - return "✅" + return printEmoji("✅") } func SuccessEmoji() string { - return "✨" + return printEmoji("✨") } From 78b1ba255b9bd02f4bb44cb449e6be7410e4d0d7 Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Thu, 20 May 2021 18:23:59 +0200 Subject: [PATCH 26/44] enable config command and remove project init --- internal/config/config.go | 2 +- internal/project/init.go | 60 ------------------------------------- internal/project/project.go | 1 - 3 files changed, 1 insertion(+), 62 deletions(-) delete mode 100644 internal/project/init.go diff --git a/internal/config/config.go b/internal/config/config.go index 6f6a52ef9..7f29371ff 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -29,7 +29,7 @@ var Cmd = &cobra.Command{ } func init() { - //InitCommand.AddToParent(Cmd) + InitCommand.AddToParent(Cmd) Cmd.AddCommand(AddCmd) Cmd.AddCommand(RemoveCmd) } diff --git a/internal/project/init.go b/internal/project/init.go deleted file mode 100644 index 33d6d710a..000000000 --- a/internal/project/init.go +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019-2021 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package project - -import ( - "fmt" - - "github.com/spf13/cobra" - - "github.com/onflow/flow-cli/internal/command" - "github.com/onflow/flow-cli/internal/config" - "github.com/onflow/flow-cli/pkg/flowcli/services" -) - -var initFlag = config.FlagsInit{} - -var InitCommand = &command.Command{ - Cmd: &cobra.Command{ - Use: "init", - Short: "Initialize a new configuration", - Example: "flow project init", - }, - Flags: &initFlag, - Run: func( - cmd *cobra.Command, - args []string, - globalFlags command.GlobalFlags, - services *services.Services, - ) (command.Result, error) { - fmt.Println("⚠️ DEPRECATION WARNING: use \"flow init\" instead") - - proj, err := services.Project.Init( - initFlag.Reset, - initFlag.ServiceKeySigAlgo, - initFlag.ServiceKeyHashAlgo, - initFlag.ServicePrivateKey, - ) - if err != nil { - return nil, err - } - - return &config.InitResult{Project: proj}, nil - }, -} diff --git a/internal/project/project.go b/internal/project/project.go index 1d766474f..ed25a8404 100644 --- a/internal/project/project.go +++ b/internal/project/project.go @@ -29,7 +29,6 @@ var Cmd = &cobra.Command{ } func init() { - InitCommand.AddToParent(Cmd) DeployCommand.AddToParent(Cmd) Cmd.AddCommand(EmulatorCommand) } From 37f6da9fdacc3b623d566b4985487397baf7dd3b Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Thu, 20 May 2021 18:46:13 +0200 Subject: [PATCH 27/44] shortctus workaround --- internal/shortcuts/init.go | 102 +++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 internal/shortcuts/init.go diff --git a/internal/shortcuts/init.go b/internal/shortcuts/init.go new file mode 100644 index 000000000..d48d38a93 --- /dev/null +++ b/internal/shortcuts/init.go @@ -0,0 +1,102 @@ +/* + * Flow CLI + * + * Copyright 2019-2021 Dapper Labs, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package shortcuts + +import ( + "bytes" + "fmt" + "text/tabwriter" + + "github.com/spf13/cobra" + + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flow-cli/pkg/flowcli/project" + "github.com/onflow/flow-cli/pkg/flowcli/services" + "github.com/onflow/flow-cli/pkg/flowcli/util" +) + +// TODO(sideninja) workaround - init needed to be copied in order to work else there is flag duplicate error + +type FlagsInit struct { + ServicePrivateKey string `flag:"service-private-key" info:"Service account private key"` + ServiceKeySigAlgo string `default:"ECDSA_P256" flag:"service-sig-algo" info:"Service account key signature algorithm"` + ServiceKeyHashAlgo string `default:"SHA3_256" flag:"service-hash-algo" info:"Service account key hash algorithm"` + Reset bool `default:"false" flag:"reset" info:"Reset flow.json config file"` +} + +var initFlag = FlagsInit{} + +var InitHotCommand = &command.Command{ + Cmd: &cobra.Command{ + Use: "init", + Short: "Initialize a new configuration", + }, + Flags: &initFlag, + Run: func( + cmd *cobra.Command, + args []string, + globalFlags command.GlobalFlags, + services *services.Services, + ) (command.Result, error) { + proj, err := services.Project.Init( + initFlag.Reset, + initFlag.ServiceKeySigAlgo, + initFlag.ServiceKeyHashAlgo, + initFlag.ServicePrivateKey, + ) + if err != nil { + return nil, err + } + + return &InitResult{proj}, nil + }, +} + +// InitResult result structure +type InitResult struct { + *project.Project +} + +// JSON convert result to JSON +func (r *InitResult) JSON() interface{} { + return r +} + +// String convert result to string +func (r *InitResult) String() string { + var b bytes.Buffer + writer := tabwriter.NewWriter(&b, 0, 8, 1, '\t', tabwriter.AlignRight) + account, _ := r.Project.EmulatorServiceAccount() + + fmt.Fprintf(writer, "Configuration initialized\n") + fmt.Fprintf(writer, "Service account: %s\n\n", util.Bold("0x"+account.Address().String())) + fmt.Fprintf(writer, + "Start emulator by running: %s \nReset configuration using: %s\n", + util.Bold("'flow emulator'"), + util.Bold("'flow init --reset'"), + ) + + writer.Flush() + return b.String() +} + +// Oneliner show result as one liner grep friendly +func (r *InitResult) Oneliner() string { + return "" +} From 110cbb3f335ae380a1672e0b561f41db583c6bee Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Thu, 20 May 2021 18:50:55 +0200 Subject: [PATCH 28/44] enable quick commands --- cmd/flow/main.go | 5 +++-- internal/{shortcuts => quick}/init.go | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) rename internal/{shortcuts => quick}/init.go (99%) diff --git a/cmd/flow/main.go b/cmd/flow/main.go index 22a0dc458..973c6242b 100644 --- a/cmd/flow/main.go +++ b/cmd/flow/main.go @@ -20,6 +20,7 @@ package main import ( + "github.com/onflow/flow-cli/internal/quick" "github.com/spf13/cobra" "github.com/onflow/flow-cli/internal/accounts" @@ -44,8 +45,8 @@ func main() { TraverseChildren: true, } - // hot commands - config.InitCommand.AddToParent(cmd) + // quick commands + quick.InitHotCommand.AddToParent(cmd) // structured commands cmd.AddCommand(cadence.Cmd) diff --git a/internal/shortcuts/init.go b/internal/quick/init.go similarity index 99% rename from internal/shortcuts/init.go rename to internal/quick/init.go index d48d38a93..195bd1697 100644 --- a/internal/shortcuts/init.go +++ b/internal/quick/init.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package shortcuts +package quick import ( "bytes" From 28d225b71d27a2431487ce62212ebfed8c1bb7e9 Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Thu, 20 May 2021 19:47:33 +0200 Subject: [PATCH 29/44] command fix import --- cmd/flow/main.go | 6 ++-- internal/project/init.go | 0 internal/quick/init.go | 59 +++++++--------------------------------- 3 files changed, 13 insertions(+), 52 deletions(-) delete mode 100644 internal/project/init.go diff --git a/cmd/flow/main.go b/cmd/flow/main.go index ff19f5f5d..e6c803707 100644 --- a/cmd/flow/main.go +++ b/cmd/flow/main.go @@ -20,7 +20,6 @@ package main import ( - "github.com/onflow/flow-cli/internal/quick" "github.com/spf13/cobra" "github.com/onflow/flow-cli/internal/accounts" @@ -33,6 +32,7 @@ import ( "github.com/onflow/flow-cli/internal/events" "github.com/onflow/flow-cli/internal/keys" "github.com/onflow/flow-cli/internal/project" + "github.com/onflow/flow-cli/internal/quick" "github.com/onflow/flow-cli/internal/scripts" "github.com/onflow/flow-cli/internal/status" "github.com/onflow/flow-cli/internal/transactions" @@ -47,7 +47,8 @@ func main() { } // quick commands - quick.InitHotCommand.AddToParent(cmd) + quick.InitCommand.AddToParent(cmd) + status.Command.AddToParent(cmd) // structured commands cmd.AddCommand(cadence.Cmd) @@ -59,7 +60,6 @@ func main() { cmd.AddCommand(keys.Cmd) cmd.AddCommand(events.Cmd) cmd.AddCommand(blocks.Cmd) - cmd.AddCommand(status.Cmd) cmd.AddCommand(collections.Cmd) cmd.AddCommand(project.Cmd) cmd.AddCommand(config.Cmd) diff --git a/internal/project/init.go b/internal/project/init.go deleted file mode 100644 index e69de29bb..000000000 diff --git a/internal/quick/init.go b/internal/quick/init.go index 195bd1697..19b4fb90b 100644 --- a/internal/quick/init.go +++ b/internal/quick/init.go @@ -19,33 +19,24 @@ package quick import ( - "bytes" "fmt" - "text/tabwriter" "github.com/spf13/cobra" "github.com/onflow/flow-cli/internal/command" - "github.com/onflow/flow-cli/pkg/flowcli/project" + "github.com/onflow/flow-cli/internal/config" "github.com/onflow/flow-cli/pkg/flowcli/services" - "github.com/onflow/flow-cli/pkg/flowcli/util" ) // TODO(sideninja) workaround - init needed to be copied in order to work else there is flag duplicate error -type FlagsInit struct { - ServicePrivateKey string `flag:"service-private-key" info:"Service account private key"` - ServiceKeySigAlgo string `default:"ECDSA_P256" flag:"service-sig-algo" info:"Service account key signature algorithm"` - ServiceKeyHashAlgo string `default:"SHA3_256" flag:"service-hash-algo" info:"Service account key hash algorithm"` - Reset bool `default:"false" flag:"reset" info:"Reset flow.json config file"` -} - -var initFlag = FlagsInit{} +var initFlag = config.FlagsInit{} -var InitHotCommand = &command.Command{ +var InitCommand = &command.Command{ Cmd: &cobra.Command{ - Use: "init", - Short: "Initialize a new configuration", + Use: "init", + Short: "Initialize a new configuration", + Example: "flow project init", }, Flags: &initFlag, Run: func( @@ -54,8 +45,11 @@ var InitHotCommand = &command.Command{ globalFlags command.GlobalFlags, services *services.Services, ) (command.Result, error) { + fmt.Println("⚠️ DEPRECATION WARNING: use \"flow init\" instead") + proj, err := services.Project.Init( initFlag.Reset, + initFlag.Global, initFlag.ServiceKeySigAlgo, initFlag.ServiceKeyHashAlgo, initFlag.ServicePrivateKey, @@ -64,39 +58,6 @@ var InitHotCommand = &command.Command{ return nil, err } - return &InitResult{proj}, nil + return &config.InitResult{Project: proj}, nil }, } - -// InitResult result structure -type InitResult struct { - *project.Project -} - -// JSON convert result to JSON -func (r *InitResult) JSON() interface{} { - return r -} - -// String convert result to string -func (r *InitResult) String() string { - var b bytes.Buffer - writer := tabwriter.NewWriter(&b, 0, 8, 1, '\t', tabwriter.AlignRight) - account, _ := r.Project.EmulatorServiceAccount() - - fmt.Fprintf(writer, "Configuration initialized\n") - fmt.Fprintf(writer, "Service account: %s\n\n", util.Bold("0x"+account.Address().String())) - fmt.Fprintf(writer, - "Start emulator by running: %s \nReset configuration using: %s\n", - util.Bold("'flow emulator'"), - util.Bold("'flow init --reset'"), - ) - - writer.Flush() - return b.String() -} - -// Oneliner show result as one liner grep friendly -func (r *InitResult) Oneliner() string { - return "" -} From bb9b3f5f0b53451957edd820008331f422d5c026 Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Fri, 21 May 2021 11:55:35 +0200 Subject: [PATCH 30/44] refactor include exclude function --- internal/accounts/accounts.go | 4 ++-- internal/blocks/blocks.go | 2 +- internal/command/result.go | 17 +++++++++-------- internal/transactions/transactions.go | 12 ++++++------ pkg/flowcli/util/utilities.go | 11 ----------- 5 files changed, 18 insertions(+), 28 deletions(-) diff --git a/internal/accounts/accounts.go b/internal/accounts/accounts.go index 0d3a4e937..3f3d8c68d 100644 --- a/internal/accounts/accounts.go +++ b/internal/accounts/accounts.go @@ -105,7 +105,7 @@ func (r *AccountResult) String() string { _, _ = fmt.Fprintf(writer, "\n") // only show up to 3 keys and then show label to expand more info - if i == 3 && !command.FieldIncluded(r.include, "keys") { + if i == 3 && !command.ContainsFlag(r.include, "keys") { _, _ = fmt.Fprint(writer, "...keys minimized, use --include keys flag if you want to view all\n\n") break } @@ -116,7 +116,7 @@ func (r *AccountResult) String() string { _, _ = fmt.Fprintf(writer, "Contract: '%s'\n", name) } - if r.showCode || command.FieldIncluded(r.include, "contracts") { + if r.showCode || command.ContainsFlag(r.include, "contracts") { for name, code := range r.Contracts { _, _ = fmt.Fprintf(writer, "Contracts '%s':\n", name) _, _ = fmt.Fprintln(writer, string(code)) diff --git a/internal/blocks/blocks.go b/internal/blocks/blocks.go index 892f22d84..d0e51733c 100644 --- a/internal/blocks/blocks.go +++ b/internal/blocks/blocks.go @@ -97,7 +97,7 @@ func (r *BlockResult) String() string { for i, guarantee := range r.block.CollectionGuarantees { _, _ = fmt.Fprintf(writer, " Collection %d:\t%s\n", i, guarantee.CollectionID) - if r.verbose || command.FieldIncluded(r.included, "transactions") { + if r.verbose || command.ContainsFlag(r.included, "transactions") { for x, tx := range r.collections[i].TransactionIDs { _, _ = fmt.Fprintf(writer, " Transaction %d: %s\n", x, tx) } diff --git a/internal/command/result.go b/internal/command/result.go index 067b3d221..13723dd40 100644 --- a/internal/command/result.go +++ b/internal/command/result.go @@ -19,7 +19,7 @@ package command import ( - "github.com/onflow/flow-cli/pkg/flowcli/util" + "strings" ) type Result interface { @@ -28,12 +28,13 @@ type Result interface { JSON() interface{} } -// FieldIncluded checks if field should be included in the result by checking if included flags contains field -func FieldIncluded(included []string, field string) bool { - return util.ContainsStringInsensitive(included, field) -} +// ContainsFlag checks if output flag is present for the provided field +func ContainsFlag(flags []string, field string) bool { + for _, n := range flags { + if strings.ToLower(n) == field { + return true + } + } -// FieldExcluded checks if field should be excluded from the result by checking the flags -func FieldExcluded(excluded []string, field string) bool { - return util.ContainsStringInsensitive(excluded, field) + return false } diff --git a/internal/transactions/transactions.go b/internal/transactions/transactions.go index e27d39ff4..e80a87247 100644 --- a/internal/transactions/transactions.go +++ b/internal/transactions/transactions.go @@ -124,7 +124,7 @@ func (r *TransactionResult) String() string { } for i, e := range r.tx.PayloadSignatures { - if command.FieldIncluded(r.include, "signatures") { + if command.ContainsFlag(r.include, "signatures") { _, _ = fmt.Fprintf(writer, "\nPayload Signature %v:\n", i) _, _ = fmt.Fprintf(writer, " Address\t%s\n", e.Address) _, _ = fmt.Fprintf(writer, " Signature\t%x\n", e.Signature) @@ -135,7 +135,7 @@ func (r *TransactionResult) String() string { } for i, e := range r.tx.EnvelopeSignatures { - if command.FieldIncluded(r.include, "signatures") { + if command.ContainsFlag(r.include, "signatures") { _, _ = fmt.Fprintf(writer, "\nEnvelope Signature %v:\n", i) _, _ = fmt.Fprintf(writer, " Address\t%s\n", e.Address) _, _ = fmt.Fprintf(writer, " Signature\t%x\n", e.Signature) @@ -145,11 +145,11 @@ func (r *TransactionResult) String() string { } } - if !command.FieldIncluded(r.include, "signatures") { + if !command.ContainsFlag(r.include, "signatures") { _, _ = fmt.Fprintf(writer, "\nSignatures (minimized, use --include signatures)") } - if !command.FieldExcluded(r.exclude, "events") { + if !command.ContainsFlag(r.exclude, "events") { e := events.EventResult{ Events: r.result.Events, } @@ -163,7 +163,7 @@ func (r *TransactionResult) String() string { } if r.tx.Script != nil { - if command.FieldIncluded(r.include, "code") || r.code { + if command.ContainsFlag(r.include, "code") || r.code { if len(r.tx.Arguments) == 0 { _, _ = fmt.Fprintf(writer, "\n\nArguments\tNo arguments\n") } else { @@ -179,7 +179,7 @@ func (r *TransactionResult) String() string { } } - if command.FieldIncluded(r.include, "payload") { + if command.ContainsFlag(r.include, "payload") { _, _ = fmt.Fprintf(writer, "\n\nPayload:\n%x", r.tx.Encode()) } else { _, _ = fmt.Fprint(writer, "\n\nPayload (hidden, use --include payload)") diff --git a/pkg/flowcli/util/utilities.go b/pkg/flowcli/util/utilities.go index 511a2f87b..f25d57099 100644 --- a/pkg/flowcli/util/utilities.go +++ b/pkg/flowcli/util/utilities.go @@ -22,7 +22,6 @@ import ( "bytes" "fmt" "io/ioutil" - "strings" "text/tabwriter" "github.com/onflow/flow-go-sdk" @@ -86,16 +85,6 @@ func ContainsString(s []string, e string) bool { return false } -func ContainsStringInsensitive(haystack []string, needle string) bool { - for _, n := range haystack { - if strings.ToLower(n) == needle { - return true - } - } - - return false -} - // GetAddressNetwork returns the chain ID for an address. func GetAddressNetwork(address flow.Address) (flow.ChainID, error) { networks := []flow.ChainID{ From 4f4459becf522122f0b46d99b0f1b5da6ec40dca Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Fri, 21 May 2021 12:03:13 +0200 Subject: [PATCH 31/44] add test for resolving imports with bugfix --- pkg/flowcli/contracts/resolver_test.go | 31 +++++++++++++++----------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/pkg/flowcli/contracts/resolver_test.go b/pkg/flowcli/contracts/resolver_test.go index d769d5721..815be1630 100644 --- a/pkg/flowcli/contracts/resolver_test.go +++ b/pkg/flowcli/contracts/resolver_test.go @@ -58,17 +58,22 @@ func TestResolver(t *testing.T) { scripts := [][]byte{ []byte(` import Kibble from "./Kibble.cdc" - import FT from "./FT.cdc" + import FT from "./FT.cdc" pub fun main() {} `), []byte(` import Kibble from "../../tests/Kibble.cdc" - import FT from "../../tests/FT.cdc" + import FT from "../../tests/FT.cdc" pub fun main() {} `), []byte(` import Kibble from "../../tests/Kibble.cdc" - import NFT from "../../tests/NFT.cdc" + import NFT from "../../tests/NFT.cdc" pub fun main() {} - `), + `), []byte(` + import Kibble from "../Kibble.cdc" + import crypto + import Foo from 0x0000000000000001 + pub fun main() {} + `), } resolved := [][]byte{ @@ -89,33 +94,33 @@ func TestResolver(t *testing.T) { t.Run("Import exists", func(t *testing.T) { resolver, err := NewResolver([]byte(` - import Kibble from "./Kibble.cdc" - pub fun main() {} - `)) + import Kibble from "./Kibble.cdc" + pub fun main() {} + `)) assert.NoError(t, err) assert.True(t, resolver.HasFileImports()) }) t.Run("Import doesn't exists", func(t *testing.T) { resolver, err := NewResolver([]byte(` - pub fun main() {} - `)) + pub fun main() {} + `)) assert.NoError(t, err) assert.False(t, resolver.HasFileImports()) resolver, err = NewResolver([]byte(` import Foo from 0xf8d6e0586b0a20c7 - pub fun main() {} - `)) + pub fun main() {} + `)) assert.NoError(t, err) assert.False(t, resolver.HasFileImports()) }) t.Run("Parse imports", func(t *testing.T) { - resolver, err := NewResolver(scripts[0]) + resolver, err := NewResolver(scripts[3]) assert.NoError(t, err) assert.Equal(t, resolver.getFileImports(), []string{ - "./Kibble.cdc", "./FT.cdc", + "../Kibble.cdc", }) }) From ebee9fe3617229b7491265bc5b0c97a809dbafff Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Fri, 21 May 2021 12:03:13 +0200 Subject: [PATCH 32/44] add test for resolving imports with bugfix --- pkg/flowcli/contracts/resolver_test.go | 39 +++++++++++++++++--------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/pkg/flowcli/contracts/resolver_test.go b/pkg/flowcli/contracts/resolver_test.go index d769d5721..2cc671573 100644 --- a/pkg/flowcli/contracts/resolver_test.go +++ b/pkg/flowcli/contracts/resolver_test.go @@ -53,22 +53,28 @@ func TestResolver(t *testing.T) { "./tests/foo.cdc", "./scripts/bar/foo.cdc", "./scripts/bar/foo.cdc", + "./tests/foo.cdc", } scripts := [][]byte{ []byte(` import Kibble from "./Kibble.cdc" - import FT from "./FT.cdc" + import FT from "./FT.cdc" pub fun main() {} `), []byte(` import Kibble from "../../tests/Kibble.cdc" - import FT from "../../tests/FT.cdc" + import FT from "../../tests/FT.cdc" pub fun main() {} `), []byte(` import Kibble from "../../tests/Kibble.cdc" - import NFT from "../../tests/NFT.cdc" + import NFT from "../../tests/NFT.cdc" + pub fun main() {} + `), []byte(` + import Kibble from "./Kibble.cdc" + import crypto + import Foo from 0x0000000000000001 pub fun main() {} - `), + `), } resolved := [][]byte{ @@ -84,38 +90,43 @@ func TestResolver(t *testing.T) { import Kibble from 0x0000000000000001 import NFT from 0x0000000000000004 pub fun main() {} - `), + `), []byte(` + import Kibble from 0x0000000000000001 + import crypto + import Foo from 0x0000000000000001 + pub fun main() {} + `), } t.Run("Import exists", func(t *testing.T) { resolver, err := NewResolver([]byte(` - import Kibble from "./Kibble.cdc" - pub fun main() {} - `)) + import Kibble from "./Kibble.cdc" + pub fun main() {} + `)) assert.NoError(t, err) assert.True(t, resolver.HasFileImports()) }) t.Run("Import doesn't exists", func(t *testing.T) { resolver, err := NewResolver([]byte(` - pub fun main() {} - `)) + pub fun main() {} + `)) assert.NoError(t, err) assert.False(t, resolver.HasFileImports()) resolver, err = NewResolver([]byte(` import Foo from 0xf8d6e0586b0a20c7 - pub fun main() {} - `)) + pub fun main() {} + `)) assert.NoError(t, err) assert.False(t, resolver.HasFileImports()) }) t.Run("Parse imports", func(t *testing.T) { - resolver, err := NewResolver(scripts[0]) + resolver, err := NewResolver(scripts[3]) assert.NoError(t, err) assert.Equal(t, resolver.getFileImports(), []string{ - "./Kibble.cdc", "./FT.cdc", + "./Kibble.cdc", }) }) From 13d56d12df1aa0caed5c40743b007f25583a5c21 Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Fri, 21 May 2021 17:32:54 +0200 Subject: [PATCH 33/44] logo fix --- logo-cli.svg | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/logo-cli.svg b/logo-cli.svg index f0b6f1e9c..7b577d12b 100644 --- a/logo-cli.svg +++ b/logo-cli.svg @@ -1,22 +1,25 @@ - - Group 2 + + Group 3 - - - - CLI - - - - - - - - - - - + + + + + + CLI + + + + + + + + + + + + From 61d6ff1f6c9491722d1c4d47674f99c5a3721438 Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Fri, 21 May 2021 17:32:54 +0200 Subject: [PATCH 34/44] logo fix --- logo-cli.svg | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/logo-cli.svg b/logo-cli.svg index f0b6f1e9c..d1c389e11 100644 --- a/logo-cli.svg +++ b/logo-cli.svg @@ -1,22 +1,25 @@ - - Group 2 + + Group 3 - - - - CLI - - - - - - - - - - - + + + + + + CLI + + + + + + + + + + + + From 582e96aff53eafc0654952f4603d75fd81516a14 Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Fri, 21 May 2021 17:39:25 +0200 Subject: [PATCH 35/44] add missing headers --- pkg/flowcli/output/colors.go | 18 ++++++++++++++++++ pkg/flowcli/output/emoji.go | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/pkg/flowcli/output/colors.go b/pkg/flowcli/output/colors.go index a61457745..8eeffe4fa 100644 --- a/pkg/flowcli/output/colors.go +++ b/pkg/flowcli/output/colors.go @@ -1,3 +1,21 @@ +/* + * Flow CLI + * + * Copyright 2019-2021 Dapper Labs, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package output import ( diff --git a/pkg/flowcli/output/emoji.go b/pkg/flowcli/output/emoji.go index b0465cd61..5a760f8b6 100644 --- a/pkg/flowcli/output/emoji.go +++ b/pkg/flowcli/output/emoji.go @@ -1,3 +1,21 @@ +/* + * Flow CLI + * + * Copyright 2019-2021 Dapper Labs, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package output import "runtime" From f19525f5d17e6714177c0f1406c8a5a594e770ab Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Fri, 21 May 2021 19:49:59 +0200 Subject: [PATCH 36/44] check for nil on result --- internal/transactions/transactions.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/transactions/transactions.go b/internal/transactions/transactions.go index e80a87247..e1d862b49 100644 --- a/internal/transactions/transactions.go +++ b/internal/transactions/transactions.go @@ -149,7 +149,7 @@ func (r *TransactionResult) String() string { _, _ = fmt.Fprintf(writer, "\nSignatures (minimized, use --include signatures)") } - if !command.ContainsFlag(r.exclude, "events") { + if r.result != nil && !command.ContainsFlag(r.exclude, "events") { e := events.EventResult{ Events: r.result.Events, } From 87e7431a3cd9c9054c1a36f9f23574cc85258700 Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Fri, 21 May 2021 20:30:56 +0200 Subject: [PATCH 37/44] remove to lower case due to multi word keys --- internal/command/command.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/command/command.go b/internal/command/command.go index b29567bd0..cba2a4369 100644 --- a/internal/command/command.go +++ b/internal/command/command.go @@ -331,7 +331,7 @@ func filterResultValue(result Result, filter string) (interface{}, error) { possibleFilters = append(possibleFilters, key) } - value := jsonResult[strings.ToLower(filter)] + value := jsonResult[filter] if value == nil { return nil, fmt.Errorf("value for filter: '%s' doesn't exists, possible values to filter by: %s", filter, possibleFilters) From f248260a8b8c44d487a6613d358ef5e4fdc472c3 Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Fri, 21 May 2021 20:50:35 +0200 Subject: [PATCH 38/44] try both normal and lowercase key --- internal/command/command.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/command/command.go b/internal/command/command.go index cba2a4369..e6d3b5b06 100644 --- a/internal/command/command.go +++ b/internal/command/command.go @@ -332,6 +332,9 @@ func filterResultValue(result Result, filter string) (interface{}, error) { } value := jsonResult[filter] + if value == nil { + value = jsonResult[strings.ToLower(filter)] + } if value == nil { return nil, fmt.Errorf("value for filter: '%s' doesn't exists, possible values to filter by: %s", filter, possibleFilters) From faaabe91eba6d0421992b5e5f1c7c8c6b9bba187 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20Mu=CC=88ller?= Date: Fri, 21 May 2021 13:39:02 -0700 Subject: [PATCH 39/44] update to Cadence v0.16.0 and Emulator v0.20.1 --- go.mod | 7 +++---- go.sum | 19 +++++++++++++------ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index 83ba4bf93..1261041a4 100644 --- a/go.mod +++ b/go.mod @@ -7,12 +7,11 @@ require ( github.com/fatih/color v1.7.0 github.com/gosuri/uilive v0.0.4 github.com/joho/godotenv v1.3.0 - github.com/magiconair/properties v1.8.1 // indirect github.com/manifoldco/promptui v0.8.0 - github.com/onflow/cadence v0.15.1 - github.com/onflow/cadence/languageserver v0.15.2 + github.com/onflow/cadence v0.16.0 + github.com/onflow/cadence/languageserver v0.16.0 github.com/onflow/flow-core-contracts/lib/go/templates v0.6.0 - github.com/onflow/flow-emulator v0.19.0 + github.com/onflow/flow-emulator v0.20.1 github.com/onflow/flow-go-sdk v0.20.0-alpha.1 github.com/psiemens/sconfig v0.0.0-20190623041652-6e01eb1354fc github.com/spf13/afero v1.1.2 diff --git a/go.sum b/go.sum index bb33fe97e..7a3c8cbfb 100644 --- a/go.sum +++ b/go.sum @@ -187,6 +187,7 @@ github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1 github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/edsrzf/mmap-go v0.0.0-20160512033002-935e0e8a636c/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= +github.com/ef-ds/deque v1.0.4 h1:iFAZNmveMT9WERAkqLJ+oaABF9AcVQ5AjXem/hroniI= github.com/ef-ds/deque v1.0.4/go.mod h1:gXDnTC3yqvBcHbq2lcExjtAcVrOnJCbMcZXmuj8Z4tg= github.com/elastic/gosigar v0.8.1-0.20180330100440-37f05ff46ffa/go.mod h1:cdorVVzy1fhmEqmtgqkoE3bYtCfSCkVyjTyCIo22xvs= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= @@ -208,8 +209,9 @@ github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVB github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fxamacker/cbor/v2 v2.2.1-0.20201006223149-25f67fca9803 h1:CS/w4nHgzo/lk+H/b5BRnfGRCKw/0DBdRjIRULZWLsg= github.com/fxamacker/cbor/v2 v2.2.1-0.20201006223149-25f67fca9803/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo= +github.com/fxamacker/cbor/v2 v2.2.1-0.20210510192846-c3f3c69e7bc8 h1:bnGFnszovskZqVUvShEj89u5xyiXYj6cQhwy0XUMEfk= +github.com/fxamacker/cbor/v2 v2.2.1-0.20210510192846-c3f3c69e7bc8/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98= @@ -721,22 +723,28 @@ github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXW github.com/olekukonko/tablewriter v0.0.2-0.20190409134802-7e037d187b0c/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/onflow/cadence v0.14.2/go.mod h1:EEXKRNuW5C2E1wRM4fLhfqoTgXohPFieXwOGJubz1Jg= github.com/onflow/cadence v0.15.0/go.mod h1:KMzDF6cIv6nb5PJW9aITaqazbmJX8MMeibFcpPP385M= -github.com/onflow/cadence v0.15.1 h1:JsJVYG51r8pvOfVcG+x+ECO1ucq/0kViac6ZqA1XyaU= github.com/onflow/cadence v0.15.1/go.mod h1:KMzDF6cIv6nb5PJW9aITaqazbmJX8MMeibFcpPP385M= -github.com/onflow/cadence/languageserver v0.15.2 h1:NahnFrirnwBiHXoDwn7Od73BvQ2mpU2x7eKPAMOWnA8= +github.com/onflow/cadence v0.16.0 h1:wjGlR5cb+DOlgwkIfi20NnUNBPTdqcRPzJNXbHQa//Y= +github.com/onflow/cadence v0.16.0/go.mod h1:iR/tZpP+1YhM8iRnOBPiBIs7on5dE3hk2ZfunCRQswE= github.com/onflow/cadence/languageserver v0.15.2/go.mod h1:hQGE8dYH5CfQ1Oe0nXglchgURzZwR3JQhmuXtv4ROHs= +github.com/onflow/cadence/languageserver v0.16.0 h1:hlRxD/u4rHEottzLypJaDRlTyvireJsTw8tZRNe7Fik= +github.com/onflow/cadence/languageserver v0.16.0/go.mod h1:UPV1so9LcMrhj27IegrTucoyS4TLRVjNr4DJqjqBhFA= +github.com/onflow/flow-cli v0.20.3-0.20210512000809-474effb7e7db/go.mod h1:Yh4dgrNiZdXhbU+3UVUmo4gRM0TEBVvhW4ITKVo82dg= github.com/onflow/flow-core-contracts/lib/go/contracts v0.7.2 h1:6+zfvSv03ROULuq27BNC+1CYFQ7tkPtD9l52BwVQjq8= github.com/onflow/flow-core-contracts/lib/go/contracts v0.7.2/go.mod h1:IZ2e7UyLCYmpQ8Kd7k0A32uXqdqfiV1r2sKs5/riblo= github.com/onflow/flow-core-contracts/lib/go/templates v0.6.0 h1:2v10ZSCE4e3TyeDQvKplGJ4/d0X/+xgU2NmeXRmFYRw= github.com/onflow/flow-core-contracts/lib/go/templates v0.6.0 h1:2v10ZSCE4e3TyeDQvKplGJ4/d0X/+xgU2NmeXRmFYRw= github.com/onflow/flow-core-contracts/lib/go/templates v0.6.0/go.mod h1:fLJbjGUHrlHdrjaeRDgKG9nZJ6spiCScc+Q5SARgH38= github.com/onflow/flow-core-contracts/lib/go/templates v0.6.0/go.mod h1:fLJbjGUHrlHdrjaeRDgKG9nZJ6spiCScc+Q5SARgH38= -github.com/onflow/flow-emulator v0.19.0 h1:q2/UTmMuK4zwVnnOak1owFTTS70pYK9qDgoQTI30yGE= github.com/onflow/flow-emulator v0.19.0/go.mod h1:k5un51XlFJavboagCqTxd6x8Gle7lxWlXdUepoNB5fA= +github.com/onflow/flow-emulator v0.20.1 h1:ie+pQzQ3Q6MLKEpxXWdOByBxW83TXyowpkv5JFGT/8c= +github.com/onflow/flow-emulator v0.20.1/go.mod h1:64i4bWoowIJWW+I9KGfDuk9ysiwHfemoLmGBSNjku/U= github.com/onflow/flow-ft/lib/go/contracts v0.5.0 h1:Cg4gHGVblxcejfNNG5Mfj98Wf4zbY76O0Y28QB0766A= github.com/onflow/flow-ft/lib/go/contracts v0.5.0/go.mod h1:1zoTjp1KzNnOPkyqKmWKerUyf0gciw+e6tAEt0Ks3JE= -github.com/onflow/flow-go v0.16.3-0.20210427194927-6050c2a3ae42 h1:oPY+9K2bVcyqPXqjYjeeGGI7iXgKK3Unwx93bTAmlCY= github.com/onflow/flow-go v0.16.3-0.20210427194927-6050c2a3ae42/go.mod h1:9GUEbBhOGDVf91ZJB6QWqVNQkrM3INEudNyDtIttOu0= +github.com/onflow/flow-go v0.17.1/go.mod h1:j8zCo01+2pJL00qpOnwdOqU7spTgOLHFRUp9gsamyNA= +github.com/onflow/flow-go v0.17.2 h1:tZEM49nWAjH2Eq6Sys6Q1YjRIb8FREBjxYxPJX5svS4= +github.com/onflow/flow-go v0.17.2/go.mod h1:j8zCo01+2pJL00qpOnwdOqU7spTgOLHFRUp9gsamyNA= github.com/onflow/flow-go-sdk v0.18.0/go.mod h1:AjXHdxguP/PK5P8tWKHH4jR6oLISTgLoXXQrbQsHY+E= github.com/onflow/flow-go-sdk v0.19.0/go.mod h1:52QZyLwU3p3UZ2FXOy+sRl4JPdtvJoae1spIUBOFxA8= github.com/onflow/flow-go-sdk v0.20.0-alpha.1 h1:zy5viTpSQsfKgaoj9PgDOhoklLkG0Fze4okGFZ21Mus= @@ -842,7 +850,6 @@ github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= github.com/schollz/progressbar/v3 v3.7.6/go.mod h1:Y9mmL2knZj3LUaBDyBEzFdPrymIr08hnlFMZmfxwbx4= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= -github.com/segmentio/fasthash v1.0.2 h1:86fGDl2hB+iSHYlccB/FP9qRGvLNuH/fhEEFn6gnQUs= github.com/segmentio/fasthash v1.0.2/go.mod h1:waKX8l2N8yckOgmSsXJi7x1ZfdKZ4x7KRMzBtS3oedY= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= From c92c378bdedfa9d108707666ca0d8853dc1cfb54 Mon Sep 17 00:00:00 2001 From: Gregor Gololicic <75445744+sideninja@users.noreply.github.com> Date: Mon, 24 May 2021 12:09:50 +0200 Subject: [PATCH 40/44] Revert "Update to Cadence v0.16.0 and Emulator v0.20.1" --- go.mod | 7 ++++--- go.sum | 19 ++++++------------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/go.mod b/go.mod index 1261041a4..83ba4bf93 100644 --- a/go.mod +++ b/go.mod @@ -7,11 +7,12 @@ require ( github.com/fatih/color v1.7.0 github.com/gosuri/uilive v0.0.4 github.com/joho/godotenv v1.3.0 + github.com/magiconair/properties v1.8.1 // indirect github.com/manifoldco/promptui v0.8.0 - github.com/onflow/cadence v0.16.0 - github.com/onflow/cadence/languageserver v0.16.0 + github.com/onflow/cadence v0.15.1 + github.com/onflow/cadence/languageserver v0.15.2 github.com/onflow/flow-core-contracts/lib/go/templates v0.6.0 - github.com/onflow/flow-emulator v0.20.1 + github.com/onflow/flow-emulator v0.19.0 github.com/onflow/flow-go-sdk v0.20.0-alpha.1 github.com/psiemens/sconfig v0.0.0-20190623041652-6e01eb1354fc github.com/spf13/afero v1.1.2 diff --git a/go.sum b/go.sum index 7a3c8cbfb..bb33fe97e 100644 --- a/go.sum +++ b/go.sum @@ -187,7 +187,6 @@ github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1 github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/edsrzf/mmap-go v0.0.0-20160512033002-935e0e8a636c/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= -github.com/ef-ds/deque v1.0.4 h1:iFAZNmveMT9WERAkqLJ+oaABF9AcVQ5AjXem/hroniI= github.com/ef-ds/deque v1.0.4/go.mod h1:gXDnTC3yqvBcHbq2lcExjtAcVrOnJCbMcZXmuj8Z4tg= github.com/elastic/gosigar v0.8.1-0.20180330100440-37f05ff46ffa/go.mod h1:cdorVVzy1fhmEqmtgqkoE3bYtCfSCkVyjTyCIo22xvs= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= @@ -209,9 +208,8 @@ github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVB github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fxamacker/cbor/v2 v2.2.1-0.20201006223149-25f67fca9803 h1:CS/w4nHgzo/lk+H/b5BRnfGRCKw/0DBdRjIRULZWLsg= github.com/fxamacker/cbor/v2 v2.2.1-0.20201006223149-25f67fca9803/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo= -github.com/fxamacker/cbor/v2 v2.2.1-0.20210510192846-c3f3c69e7bc8 h1:bnGFnszovskZqVUvShEj89u5xyiXYj6cQhwy0XUMEfk= -github.com/fxamacker/cbor/v2 v2.2.1-0.20210510192846-c3f3c69e7bc8/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98= @@ -723,28 +721,22 @@ github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXW github.com/olekukonko/tablewriter v0.0.2-0.20190409134802-7e037d187b0c/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/onflow/cadence v0.14.2/go.mod h1:EEXKRNuW5C2E1wRM4fLhfqoTgXohPFieXwOGJubz1Jg= github.com/onflow/cadence v0.15.0/go.mod h1:KMzDF6cIv6nb5PJW9aITaqazbmJX8MMeibFcpPP385M= +github.com/onflow/cadence v0.15.1 h1:JsJVYG51r8pvOfVcG+x+ECO1ucq/0kViac6ZqA1XyaU= github.com/onflow/cadence v0.15.1/go.mod h1:KMzDF6cIv6nb5PJW9aITaqazbmJX8MMeibFcpPP385M= -github.com/onflow/cadence v0.16.0 h1:wjGlR5cb+DOlgwkIfi20NnUNBPTdqcRPzJNXbHQa//Y= -github.com/onflow/cadence v0.16.0/go.mod h1:iR/tZpP+1YhM8iRnOBPiBIs7on5dE3hk2ZfunCRQswE= +github.com/onflow/cadence/languageserver v0.15.2 h1:NahnFrirnwBiHXoDwn7Od73BvQ2mpU2x7eKPAMOWnA8= github.com/onflow/cadence/languageserver v0.15.2/go.mod h1:hQGE8dYH5CfQ1Oe0nXglchgURzZwR3JQhmuXtv4ROHs= -github.com/onflow/cadence/languageserver v0.16.0 h1:hlRxD/u4rHEottzLypJaDRlTyvireJsTw8tZRNe7Fik= -github.com/onflow/cadence/languageserver v0.16.0/go.mod h1:UPV1so9LcMrhj27IegrTucoyS4TLRVjNr4DJqjqBhFA= -github.com/onflow/flow-cli v0.20.3-0.20210512000809-474effb7e7db/go.mod h1:Yh4dgrNiZdXhbU+3UVUmo4gRM0TEBVvhW4ITKVo82dg= github.com/onflow/flow-core-contracts/lib/go/contracts v0.7.2 h1:6+zfvSv03ROULuq27BNC+1CYFQ7tkPtD9l52BwVQjq8= github.com/onflow/flow-core-contracts/lib/go/contracts v0.7.2/go.mod h1:IZ2e7UyLCYmpQ8Kd7k0A32uXqdqfiV1r2sKs5/riblo= github.com/onflow/flow-core-contracts/lib/go/templates v0.6.0 h1:2v10ZSCE4e3TyeDQvKplGJ4/d0X/+xgU2NmeXRmFYRw= github.com/onflow/flow-core-contracts/lib/go/templates v0.6.0 h1:2v10ZSCE4e3TyeDQvKplGJ4/d0X/+xgU2NmeXRmFYRw= github.com/onflow/flow-core-contracts/lib/go/templates v0.6.0/go.mod h1:fLJbjGUHrlHdrjaeRDgKG9nZJ6spiCScc+Q5SARgH38= github.com/onflow/flow-core-contracts/lib/go/templates v0.6.0/go.mod h1:fLJbjGUHrlHdrjaeRDgKG9nZJ6spiCScc+Q5SARgH38= +github.com/onflow/flow-emulator v0.19.0 h1:q2/UTmMuK4zwVnnOak1owFTTS70pYK9qDgoQTI30yGE= github.com/onflow/flow-emulator v0.19.0/go.mod h1:k5un51XlFJavboagCqTxd6x8Gle7lxWlXdUepoNB5fA= -github.com/onflow/flow-emulator v0.20.1 h1:ie+pQzQ3Q6MLKEpxXWdOByBxW83TXyowpkv5JFGT/8c= -github.com/onflow/flow-emulator v0.20.1/go.mod h1:64i4bWoowIJWW+I9KGfDuk9ysiwHfemoLmGBSNjku/U= github.com/onflow/flow-ft/lib/go/contracts v0.5.0 h1:Cg4gHGVblxcejfNNG5Mfj98Wf4zbY76O0Y28QB0766A= github.com/onflow/flow-ft/lib/go/contracts v0.5.0/go.mod h1:1zoTjp1KzNnOPkyqKmWKerUyf0gciw+e6tAEt0Ks3JE= +github.com/onflow/flow-go v0.16.3-0.20210427194927-6050c2a3ae42 h1:oPY+9K2bVcyqPXqjYjeeGGI7iXgKK3Unwx93bTAmlCY= github.com/onflow/flow-go v0.16.3-0.20210427194927-6050c2a3ae42/go.mod h1:9GUEbBhOGDVf91ZJB6QWqVNQkrM3INEudNyDtIttOu0= -github.com/onflow/flow-go v0.17.1/go.mod h1:j8zCo01+2pJL00qpOnwdOqU7spTgOLHFRUp9gsamyNA= -github.com/onflow/flow-go v0.17.2 h1:tZEM49nWAjH2Eq6Sys6Q1YjRIb8FREBjxYxPJX5svS4= -github.com/onflow/flow-go v0.17.2/go.mod h1:j8zCo01+2pJL00qpOnwdOqU7spTgOLHFRUp9gsamyNA= github.com/onflow/flow-go-sdk v0.18.0/go.mod h1:AjXHdxguP/PK5P8tWKHH4jR6oLISTgLoXXQrbQsHY+E= github.com/onflow/flow-go-sdk v0.19.0/go.mod h1:52QZyLwU3p3UZ2FXOy+sRl4JPdtvJoae1spIUBOFxA8= github.com/onflow/flow-go-sdk v0.20.0-alpha.1 h1:zy5viTpSQsfKgaoj9PgDOhoklLkG0Fze4okGFZ21Mus= @@ -850,6 +842,7 @@ github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= github.com/schollz/progressbar/v3 v3.7.6/go.mod h1:Y9mmL2knZj3LUaBDyBEzFdPrymIr08hnlFMZmfxwbx4= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +github.com/segmentio/fasthash v1.0.2 h1:86fGDl2hB+iSHYlccB/FP9qRGvLNuH/fhEEFn6gnQUs= github.com/segmentio/fasthash v1.0.2/go.mod h1:waKX8l2N8yckOgmSsXJi7x1ZfdKZ4x7KRMzBtS3oedY= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= From 76f380bdd90cb557773a10e4d1828da1caada49e Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Mon, 24 May 2021 12:21:06 +0200 Subject: [PATCH 41/44] add tests for decode --- pkg/flowcli/services/keys_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/flowcli/services/keys_test.go b/pkg/flowcli/services/keys_test.go index 372792b60..09edaead0 100644 --- a/pkg/flowcli/services/keys_test.go +++ b/pkg/flowcli/services/keys_test.go @@ -62,4 +62,12 @@ func TestKeys(t *testing.T) { assert.Equal(t, err.Error(), "invalid signature algorithm: JUSTNO") }) + + t.Run("RLP decode keys", func(t *testing.T) { + dkey, err := keys.Decode("f847b84084d716c14b051ad6b001624f738f5d302636e6b07cc75e4530af7776a4368a2b586dbefc0564ee28384c2696f178cbed52e62811bcc9ecb59568c996d342db2402038203e8") + + assert.NoError(t, err) + assert.Equal(t, dkey.PublicKey.String(), "0x84d716c14b051ad6b001624f738f5d302636e6b07cc75e4530af7776a4368a2b586dbefc0564ee28384c2696f178cbed52e62811bcc9ecb59568c996d342db24") + assert.Equal(t, dkey.SigAlgo.String(), "ECDSA_P256") + }) } From ae92e7c2023713d009490ec4442da3153f246e0f Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Mon, 24 May 2021 12:55:54 +0200 Subject: [PATCH 42/44] updated docs --- docs/create-accounts.md | 7 +++ docs/get-accounts.md | 9 +++- docs/get-transactions.md | 81 +++++++++++++++++++++++--------- docs/send-signed-transactions.md | 70 ++++++++++++--------------- docs/send-transactions.md | 58 ++++++++++------------- 5 files changed, 130 insertions(+), 95 deletions(-) diff --git a/docs/create-accounts.md b/docs/create-accounts.md index e2bc77119..a916d4e2c 100644 --- a/docs/create-accounts.md +++ b/docs/create-accounts.md @@ -103,6 +103,13 @@ and pay the account creation fee. Specify one or more contracts to be deployed during account creation. +### Include Fields + +- Flag: `--include` +- Valid inputs: `contracts` + +Specify fields to include in the result output. Applies only to the text output. + ### Host - Flag: `--host` diff --git a/docs/get-accounts.md b/docs/get-accounts.md index 67c83ae17..9d99d725b 100644 --- a/docs/get-accounts.md +++ b/docs/get-accounts.md @@ -49,11 +49,18 @@ Flow [account address](https://docs.onflow.org/concepts/accounts-and-keys/) (pre ## Flags +### Include Fields + +- Flag: `--include` +- Valid inputs: `contracts` + +Specify fields to include in the result output. Applies only to the text output. + ### Contracts - Flag: `--contracts` -Display contracts deployed to the account. +⚠️ Deprecated: use include flag. ### Code ⚠️ No longer supported: use contracts flag instead. diff --git a/docs/get-transactions.md b/docs/get-transactions.md index 7cd04c9ae..8f4373f4a 100644 --- a/docs/get-transactions.md +++ b/docs/get-transactions.md @@ -14,24 +14,50 @@ flow transactions get ## Example Usage ```shell -> flow transactions get ff35821007322405608c0d3da79312617f8d16e118afe63e764b5e68edc96dd5 --host access.mainnet.nodes.onflow.org:9000 - -ID ff35821007322405608c0d3da79312617f8d16e118afe63e764b5e68edc96dd5 -Status SEALED -Payer 12e354a23e4f791d -Events - Index 0 - Type flow.AccountCreated - Tx ID ff35821007322405608c0d3da79312617f8d16e118afe63e764b5e68edc96dd5 - Values - address (Address) 18c4931b5f3c7151 - - Index 1 - Type flow.AccountKeyAdded - Tx ID ff35821007322405608c0d3da79312617f8d16e118afe63e764b5e68edc96dd5 - Values - address (Address) 18c4931b5f3c7151 - publicKey (Unknown) f847b8404c296679364d2...7b168678cc762bc08f342d8d92e0a36e6ecfdcf15850721821823e8 +> flow transactions get 40bc4b100c1930c61381c22e0f4c10a7f5827975ee25715527c1061b8d71e5aa --network mainnet + +Status ✅ SEALED +ID 40bc4b100c1930c61381c22e0f4c10a7f5827975ee25715527c1061b8d71e5aa +Payer 18eb4ee6b3c026d2 +Authorizers [18eb4ee6b3c026d2] + +Proposal Key: + Address 18eb4ee6b3c026d2 + Index 11 + Sequence 17930 + +Payload Signature 0: 18eb4ee6b3c026d2 +Payload Signature 1: 18eb4ee6b3c026d2 +Envelope Signature 0: 18eb4ee6b3c026d2 +Signatures (minimized, use --include signatures) + +Events: + Index 0 + Type A.1654653399040a61.FlowToken.TokensWithdrawn + Tx ID 40bc4b100c1930c61381c22e0f4c10a7f5827975ee25715527c1061b8d71e5aa + Values + - amount (UFix64): 0.00100000 + - from ({}?): 18eb4ee6b3c026d2 + + Index 1 + Type A.1654653399040a61.FlowToken.TokensDeposited + Tx ID 40bc4b100c1930c61381c22e0f4c10a7f5827975ee25715527c1061b8d71e5aa + Values + - amount (UFix64): 0.00100000 + - to ({}?): 5068e27f275c546c + + Index 2 + Type A.18eb4ee6b3c026d2.PrivateReceiverForwarder.PrivateDeposit + Tx ID 40bc4b100c1930c61381c22e0f4c10a7f5827975ee25715527c1061b8d71e5aa + Values + - amount (UFix64): 0.00100000 + - to ({}?): 5068e27f275c546c + + + +Code (hidden, use --include code) + +Payload (hidden, use --include payload) ``` ## Arguments @@ -45,12 +71,18 @@ The first argument is the ID (hash) of the transaction. ## Flags -### Display Transaction Code +### Include Fields + +- Flag: `--include` +- Valid inputs: `code`, `payload`, `signatures` + +Specify fields to include in the result output. Applies only to the text output. + +### Code - Flag: `--code` -- Default: `false` -Indicate whether to print the transaction Cadence code. +⚠️ Deprecated: use include flag. ### Wait for Seal @@ -60,6 +92,13 @@ Indicate whether to print the transaction Cadence code. Indicate whether to wait for the transaction to be sealed before displaying the result. +### Exclude Fields + +- Flag: `--exclude` +- Valid inputs: `events` + +Specify fields to exclude from the result output. Applies only to the text output. + ### Host - Flag: `--host` diff --git a/docs/send-signed-transactions.md b/docs/send-signed-transactions.md index 7d62d9a89..7747c5da5 100644 --- a/docs/send-signed-transactions.md +++ b/docs/send-signed-transactions.md @@ -22,47 +22,25 @@ flow transactions send-signed > flow transactions send-signed ./signed.rlp Status ✅ SEALED -ID b6430b35ba23849a8acb4fa1a4a1d5cce3ed4589111ecbb3984de1b6bd1ba39e -Payer a2c4941b5f3c7151 -Authorizers [a2c4941b5f3c7151] +ID 528332aceb288cdfe4d11d6522aa27bed94fb3266b812cb350eb3526ed489d99 +Payer f8d6e0586b0a20c7 +Authorizers [f8d6e0586b0a20c7] Proposal Key: - Address a2c4941b5f3c7151 + Address f8d6e0586b0a20c7 Index 0 - Sequence 9 + Sequence 0 No Payload Signatures -Envelope Signature 0: - Address a2c4941b5f3c7151 - Signature 5391a6fed0fe...2742048166f9d5c925a8dcb78a6d8c710921d67 - Key Index 0 - +Envelope Signature 0: f8d6e0586b0a20c7 +Signatures (minimized, use --include signatures) Events: None +Code (hidden, use --include code) -Arguments (1): - - Argument 0: {"type":"String","value":"Meow"} - - -Code - -transaction(greeting: String) { - let guest: Address - - prepare(authorizer: AuthAccount) { - self.guest = authorizer.address - } - - execute { - log(greeting.concat(",").concat(self.guest.toString())) - } -} - - -Payload: -f90184f90138...8a9462751237da2742048166f9d5c925a8dcb78a6d8c710921d67 +Payload (hidden, use --include payload) ``` @@ -78,6 +56,28 @@ transaction to be executed. ## Flags +### Include Fields + +- Flag: `--include` +- Valid inputs: `code`, `payload` + +Specify fields to include in the result output. Applies only to the text output. + +### Exclude Fields + +- Flag: `--exclude` +- Valid inputs: `events` + +Specify fields to exclude from the result output. Applies only to the text output. + +### Filter + +- Flag: `--filter` +- Short Flag: `-x` +- Valid inputs: a case-sensitive name of the result property. + +Specify any property name from the result you want to return as the only value. + ### Host - Flag: `--host` @@ -97,14 +97,6 @@ any host defined by the `--network` flag. Specify which network you want the command to use for execution. -### Filter - -- Flag: `--filter` -- Short Flag: `-x` -- Valid inputs: a case-sensitive name of the result property. - -Specify any property name from the result you want to return as the only value. - ### Output - Flag: `--output` diff --git a/docs/send-transactions.md b/docs/send-transactions.md index 1e1ed71be..2d3509f0a 100644 --- a/docs/send-transactions.md +++ b/docs/send-transactions.md @@ -14,52 +14,28 @@ flow transactions send ## Example Usage ```shell -> flow transactions send ./transaction.cdc \ - --args-json '[{"type": "String","value": "Hello World"}]' \ - --signer my-testnet-account +> flow transactions send ./tx.cdc --arg String:Hello Status ✅ SEALED -ID b6430b35ba23849a8acb4fa1a4a1d5cce3ed4589111ecbb3984de1b6bd1ba39e -Payer a2c4941b5f3c7151 -Authorizers [a2c4941b5f3c7151] +ID b04b6bcc3164f5ee6b77fa502c3a682e0db57fc47e5b8a8ef3b56aae50ad49c8 +Payer f8d6e0586b0a20c7 +Authorizers [f8d6e0586b0a20c7] Proposal Key: - Address a2c4941b5f3c7151 + Address f8d6e0586b0a20c7 Index 0 - Sequence 9 + Sequence 0 No Payload Signatures -Envelope Signature 0: - Address a2c4941b5f3c7151 - Signature 5391a6fed0fe...2742048166f9d5c925a8dcb78a6d8c710921d67 - Key Index 0 - +Envelope Signature 0: f8d6e0586b0a20c7 +Signatures (minimized, use --include signatures) Events: None +Code (hidden, use --include code) -Arguments (1): - - Argument 0: {"type":"String","value":"Hello World"} - - -Code - -transaction(greeting: String) { - let guest: Address - - prepare(authorizer: AuthAccount) { - self.guest = authorizer.address - } - - execute { - log(greeting.concat(",").concat(self.guest.toString())) - } -} - - -Payload: -f90184f90138...8a9462751237da2742048166f9d5c925a8dcb78a6d8c710921d67 +Payload (hidden, use --include payload) ``` @@ -87,6 +63,13 @@ transaction to be executed. ## Flags +### Include Fields + +- Flag: `--include` +- Valid inputs: `code`, `payload` + +Specify fields to include in the result output. Applies only to the text output. + ### Code - Flag: `--code` @@ -99,6 +82,13 @@ transaction to be executed. ⚠️ No longer supported: all transactions will provide result. +### Exclude Fields + +- Flag: `--exclude` +- Valid inputs: `events` + +Specify fields to exclude from the result output. Applies only to the text output. + ### Signer - Flag: `--signer` From 54c81e830de3833f2f59f1bab4f4a98ec736e660 Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Mon, 24 May 2021 12:56:11 +0200 Subject: [PATCH 43/44] default build include values to all --- internal/transactions/build.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/transactions/build.go b/internal/transactions/build.go index 0eceefbc5..4123e0d2c 100644 --- a/internal/transactions/build.go +++ b/internal/transactions/build.go @@ -69,7 +69,8 @@ var BuildCommand = &command.Command{ } return &TransactionResult{ - tx: build.FlowTransaction(), + tx: build.FlowTransaction(), + include: []string{"code", "payload", "signatures"}, }, nil }, } From e25549ec4885c80464ea53478a1b94122534e889 Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Mon, 24 May 2021 13:15:03 +0200 Subject: [PATCH 44/44] release notes --- docs/developer-updates/release-notes-v21.md | 72 +++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 docs/developer-updates/release-notes-v21.md diff --git a/docs/developer-updates/release-notes-v21.md b/docs/developer-updates/release-notes-v21.md new file mode 100644 index 000000000..c407dc57b --- /dev/null +++ b/docs/developer-updates/release-notes-v21.md @@ -0,0 +1,72 @@ +## ⬆️ Install or Upgrade + +Follow the [Flow CLI installation guide](https://docs.onflow.org/flow-cli/install/) for instructions on how to install or upgrade the CLI. + + +## 💥 Breaking Changes + +### Flow Go SDK Update +Update Flow Go SDK version from v0.19.0 to v0.20.0. +Read more about new version in the [release notes](https://github.com/onflow/flow-go-sdk/releases/tag/v0.20.0). + +## ⭐ Features + +### New Command To Manage Configuration +Add or remove resources from the configuration using the new `flow config` command. +Usage is possible via interactive prompt or by using flags. Command syntax is as follows: +```js +flow config +``` + +Example for adding an account to the config via interactive prompt: + +```bash +Name: Foo +Address: f8d6e0586b0a20c7 +✔ ECDSA_P256 +✔ SHA3_256 +Private key: 1286...01afc +Key index (Default: 0): 0 + +Account Foo added to the configuration +``` + +Example for adding an account to the config without interactive prompt: + +```bash +./main config add account --address f8d6e0586b0a20c7 --name Foo --private-key 1286...01afc + +Account Foo added to the configuration +``` + +We recommend using manage command to do any changes in the configuration as it will also +validate input values for you and will abstract any changes in the configuration format. + +### Decode Keys +Command for decoding public keys in the RLP encoded format. + +Example of using the command: + +```bash +> flow keys decode f847b84084d716c14b051ad6b001624f738f5d302636e6b07cc75e4530af7776a4368a2b586dbefc0564ee28384c2696f178cbed52e62811bcc9ecb59568c996d342db2402038203e8 + +Public Key 84d716c14b051ad6b001624f738f5d302636e6b07cc75e4530af7776a4368a2b586dbefc0564ee28384c2696f178cbed52e62811bcc9ecb59568c996d342db24 +Signature algorithm ECDSA_P256 +Hash algorithm SHA3_256 +Weight 1000 +Revoked false +``` + +## 🎉 Improvements + +### Include And Exclude Flags +Include and Exclude flags were added to the transaction and account resource thus +allowing you to further specify verbosity of the output. + +### Documentation Changes +Multiple reported documentation fixes. + +## 🐞 Bug Fixes + +### Import Detection Fix +Fix for a reported bug: An error occurs when executing a script that imports a built-in contract (Crypto contract) with Flow CLI command.