diff --git a/cmd/common/helpers.go b/cmd/common/helpers.go index 3f62d760..88b09439 100644 --- a/cmd/common/helpers.go +++ b/cmd/common/helpers.go @@ -2,6 +2,7 @@ package common import ( "fmt" + "os" "github.com/spf13/cobra" @@ -11,6 +12,16 @@ import ( "github.com/oasisprotocol/cli/config" ) +// Warnf prints a message to stderr with formatting. +func Warnf(format string, args ...interface{}) { + fmt.Fprintf(os.Stderr, format+"\n", args...) +} + +// Warn prints a message to stderr. +func Warn(msg string) { + fmt.Fprintln(os.Stderr, msg) +} + // CheckForceErr treats error as warning, if --force is provided. func CheckForceErr(err interface{}) { // No error. @@ -20,7 +31,7 @@ func CheckForceErr(err interface{}) { // --force is provided. if IsForce() { - fmt.Printf("Warning: %s\nProceeding by force as requested\n", err) + Warnf("Warning: %s\nProceeding by force as requested", err) return } diff --git a/cmd/common/prompts.go b/cmd/common/prompts.go index 2575dd7c..544bc13f 100644 --- a/cmd/common/prompts.go +++ b/cmd/common/prompts.go @@ -2,11 +2,25 @@ package common import ( "fmt" + "os" "github.com/AlecAivazis/survey/v2" "github.com/spf13/cobra" ) +// SurveyStdio is the standard survey option to direct prompts to stderr. +var SurveyStdio = survey.WithStdio(os.Stdin, os.Stderr, os.Stderr) + +// Ask wraps survey.AskOne while forcing prompts to stderr. +func Ask(p survey.Prompt, response interface{}, opts ...survey.AskOpt) error { + return survey.AskOne(p, response, append([]survey.AskOpt{SurveyStdio}, opts...)...) +} + +// AskMulti wraps survey.Ask while forcing prompts to stderr. +func AskMulti(qs []*survey.Question, response interface{}, opts ...survey.AskOpt) error { + return survey.Ask(qs, response, append([]survey.AskOpt{SurveyStdio}, opts...)...) +} + var ( // PromptPassphrase is the standard passphrase prompt. PromptPassphrase = &survey.Password{ @@ -27,12 +41,12 @@ var ( // Confirm asks the user for confirmation and aborts when rejected. func Confirm(msg, abortMsg string) { if answerYes { - fmt.Printf("? %s Yes\n", msg) + fmt.Fprintf(os.Stderr, "? %s Yes\n", msg) return } var proceed bool - err := survey.AskOne(&survey.Confirm{Message: msg}, &proceed) + err := Ask(&survey.Confirm{Message: msg}, &proceed) cobra.CheckErr(err) if !proceed { cobra.CheckErr(abortMsg) @@ -61,7 +75,7 @@ func AskNewPassphrase() string { }, }, } - err := survey.Ask(questions, &answers) + err := AskMulti(questions, &answers) cobra.CheckErr(err) return answers.Passphrase diff --git a/cmd/common/wallet.go b/cmd/common/wallet.go index 27773c58..67bfdd26 100644 --- a/cmd/common/wallet.go +++ b/cmd/common/wallet.go @@ -2,9 +2,9 @@ package common import ( "fmt" + "os" "strings" - "github.com/AlecAivazis/survey/v2" ethCommon "github.com/ethereum/go-ethereum/common" "github.com/spf13/cobra" @@ -61,9 +61,10 @@ func LoadAccount(cfg *config.Config, name string) wallet.Account { var passphrase string if af.RequiresPassphrase() && !answerYes { // Ask for passphrase to decrypt the account. - fmt.Printf("Unlock your account.\n") + // Use stderr for prompts so they work when stdout is piped. + fmt.Fprintln(os.Stderr, "Unlock your account.") - err = survey.AskOne(PromptPassphrase, &passphrase) + err = Ask(PromptPassphrase, &passphrase) cobra.CheckErr(err) } diff --git a/cmd/network/governance/show.go b/cmd/network/governance/show.go index 06d253d2..f7d652f9 100644 --- a/cmd/network/governance/show.go +++ b/cmd/network/governance/show.go @@ -362,15 +362,11 @@ var ( // Try to figure out the human readable names for all the entities. fromRegistry, err := metadata.EntitiesFromRegistry(ctx) if err != nil { - fmt.Println() - fmt.Printf("Warning: failed to query metadata registry: %v", err) - fmt.Println() + common.Warnf("\nWarning: failed to query metadata registry: %v\n", err) } fromOasisscan, err := metadata.EntitiesFromOasisscan(ctx) if err != nil { - fmt.Println() - fmt.Printf("Warning: failed to query oasisscan: %v", err) - fmt.Println() + common.Warnf("\nWarning: failed to query oasisscan: %v\n", err) } getName := func(addr staking.Address) string { diff --git a/cmd/network/network.go b/cmd/network/network.go index d964a773..bd14f612 100644 --- a/cmd/network/network.go +++ b/cmd/network/network.go @@ -6,6 +6,7 @@ import ( "github.com/oasisprotocol/oasis-sdk/client-sdk/go/config" + "github.com/oasisprotocol/cli/cmd/common" "github.com/oasisprotocol/cli/cmd/network/governance" ) @@ -41,7 +42,7 @@ func networkDetailsFromSurvey(net *config.Network) { Symbol string Decimals uint8 }{} - err := survey.Ask(questions, &answers) + err := common.AskMulti(questions, &answers) cobra.CheckErr(err) net.Description = answers.Description diff --git a/cmd/network/remove.go b/cmd/network/remove.go index ee98bdfa..bbdbe1c1 100644 --- a/cmd/network/remove.go +++ b/cmd/network/remove.go @@ -24,7 +24,7 @@ var rmCmd = &cobra.Command{ } if !common.GetAnswerYes() && len(net.ParaTimes.All) > 0 { - fmt.Printf("WARNING: Network '%s' contains %d ParaTimes.\n", name, len(net.ParaTimes.All)) + common.Warnf("WARNING: Network '%s' contains %d ParaTimes.", name, len(net.ParaTimes.All)) common.Confirm("Are you sure you want to remove the network?", "not removing network") } diff --git a/cmd/network/trust.go b/cmd/network/trust.go index 73285708..163f656e 100644 --- a/cmd/network/trust.go +++ b/cmd/network/trust.go @@ -66,7 +66,7 @@ WARNING: fmt.Println("Trust height: ", trust.Height) fmt.Println("Trust hash: ", trust.Hash) fmt.Println() - fmt.Println("WARNING: Cannot be trusted unless the CLI is connected to the RPC endpoint you control.") + common.Warn("WARNING: Cannot be trusted unless the CLI is connected to the RPC endpoint you control.") } return nil diff --git a/cmd/paratime/add.go b/cmd/paratime/add.go index 637b8cdf..f78aba8e 100644 --- a/cmd/paratime/add.go +++ b/cmd/paratime/add.go @@ -86,7 +86,7 @@ var ( }, } - err := survey.Ask(questions, ¶timeInfo) + err := common.AskMulti(questions, ¶timeInfo) cobra.CheckErr(err) } diff --git a/cmd/paratime/statistics.go b/cmd/paratime/statistics.go index ad11a97d..22a6a344 100644 --- a/cmd/paratime/statistics.go +++ b/cmd/paratime/statistics.go @@ -384,7 +384,7 @@ var statsCmd = &cobra.Command{ if err != nil { // Non-fatal, this is informative and gathering stats is time // consuming. - fmt.Printf("\nWarning: failed to query metadata registry: %v\n", err) + common.Warnf("\nWarning: failed to query metadata registry: %v", err) } stats.prepareEntitiesOutput(entityMetadataLookup) diff --git a/cmd/rofl/build/build.go b/cmd/rofl/build/build.go index ac41d967..79c95c36 100644 --- a/cmd/rofl/build/build.go +++ b/cmd/rofl/build/build.go @@ -312,7 +312,7 @@ func setupBuildEnv(deployment *buildRofl.Deployment, npa *common.NPASelection) { trustRoot, err := fetchTrustRoot(npa, deployment.TrustRoot) if deployment.Debug && err != nil { // Trust root is not mandatory for debug builds. - fmt.Printf("WARNING: no trust root will be provided during compilation: %v\n", err) + common.Warnf("WARNING: no trust root will be provided during compilation: %v", err) return } cobra.CheckErr(err) diff --git a/cmd/rofl/build/sgx.go b/cmd/rofl/build/sgx.go index 976630a9..c287f720 100644 --- a/cmd/rofl/build/sgx.go +++ b/cmd/rofl/build/sgx.go @@ -244,8 +244,8 @@ func sgxSetupBuildEnv(deployment *buildRofl.Deployment, npa *common.NPASelection return nil // No features. case buildModeUnsafe: // Unsafe debug builds. - fmt.Println("WARNING: Building in UNSAFE DEBUG mode with MOCK SGX.") - fmt.Println("WARNING: This build will NOT BE DEPLOYABLE outside local test environments.") + common.Warn("WARNING: Building in UNSAFE DEBUG mode with MOCK SGX.") + common.Warn("WARNING: This build will NOT BE DEPLOYABLE outside local test environments.") os.Setenv("OASIS_UNSAFE_SKIP_AVR_VERIFY", "1") os.Setenv("OASIS_UNSAFE_ALLOW_DEBUG_ENCLAVES", "1") diff --git a/cmd/rofl/build/tdx.go b/cmd/rofl/build/tdx.go index 5fca8ec1..da703949 100644 --- a/cmd/rofl/build/tdx.go +++ b/cmd/rofl/build/tdx.go @@ -54,7 +54,7 @@ func tdxBuildRaw( dep := pkgMeta.FindDependency("oasis-runtime-sdk") switch dep { case nil: - fmt.Println("WARNING: No oasis-runtime-sdk dependency found. Skipping validation of TDX binary.") + common.Warn("WARNING: No oasis-runtime-sdk dependency found. Skipping validation of TDX binary.") default: // Check for presence of TDX feature. if !dep.HasFeature("tdx") { @@ -336,8 +336,8 @@ func tdxSetupBuildEnv(deployment *buildRofl.Deployment, npa *common.NPASelection } case buildModeUnsafe: // Unsafe debug builds. - fmt.Println("WARNING: Building in UNSAFE DEBUG mode with MOCK TDX.") - fmt.Println("WARNING: This build will NOT BE DEPLOYABLE outside local test environments.") + common.Warn("WARNING: Building in UNSAFE DEBUG mode with MOCK TDX.") + common.Warn("WARNING: This build will NOT BE DEPLOYABLE outside local test environments.") os.Setenv("OASIS_UNSAFE_SKIP_AVR_VERIFY", "1") os.Setenv("OASIS_UNSAFE_ALLOW_DEBUG_ENCLAVES", "1") diff --git a/cmd/rofl/common/policy.go b/cmd/rofl/common/policy.go index 4427e7f1..29491ec9 100644 --- a/cmd/rofl/common/policy.go +++ b/cmd/rofl/common/policy.go @@ -1,11 +1,11 @@ package common -import "fmt" +import "github.com/oasisprotocol/cli/cmd/common" // RentRefundWarning is a standardized message shown before renting, topping up, or canceling a machine. const RentRefundWarning = "WARNING: Machine rental is non-refundable. You will not get a refund for the already paid term if you cancel." // PrintRentRefundWarning prints the standardized, user-facing refund policy warning. func PrintRentRefundWarning() { - fmt.Println(RentRefundWarning) + common.Warn(RentRefundWarning) } diff --git a/cmd/rofl/machine/mgmt.go b/cmd/rofl/machine/mgmt.go index ec344a81..df58a425 100644 --- a/cmd/rofl/machine/mgmt.go +++ b/cmd/rofl/machine/mgmt.go @@ -89,7 +89,7 @@ var ( fmt.Printf("Using provider: %s (%s)\n", machine.Provider, providerAddr) fmt.Printf("Canceling machine: %s [%s]\n", machineName, machine.ID) - fmt.Printf("WARNING: Canceling a machine will permanently destroy it including any persistent storage!\n") + common.Warn("WARNING: Canceling a machine will permanently destroy it including any persistent storage!") roflCommon.PrintRentRefundWarning() // Prepare transaction. diff --git a/cmd/rofl/mgmt.go b/cmd/rofl/mgmt.go index e1d3532a..cda231bb 100644 --- a/cmd/rofl/mgmt.go +++ b/cmd/rofl/mgmt.go @@ -417,8 +417,8 @@ var ( cobra.CheckErr(err) } - fmt.Printf("WARNING: Removing this ROFL app will DEREGISTER it, ERASE any on-chain secrets and local configuration!\n") - fmt.Printf("WARNING: THIS ACTION IS IRREVERSIBLE!\n") + common.Warn("WARNING: Removing this ROFL app will DEREGISTER it, ERASE any on-chain secrets and local configuration!") + common.Warn("WARNING: THIS ACTION IS IRREVERSIBLE!") if !common.GetAnswerYes() { common.Confirm(fmt.Sprintf("Remove ROFL app '%s' deployed on network '%s'", appID, npa.NetworkName), "not removing") } diff --git a/cmd/rofl/provider/mgmt.go b/cmd/rofl/provider/mgmt.go index 0f00c160..49c82b7b 100644 --- a/cmd/rofl/provider/mgmt.go +++ b/cmd/rofl/provider/mgmt.go @@ -233,7 +233,7 @@ var ( for _, offer := range existingOffers { offerID, ok := offer.Metadata[provider.SchedulerMetadataOfferKey] if !ok { - fmt.Printf("WARNING: On-chain offer '%s' is missing '%s' metadata, ignoring.\n", offer.ID, provider.SchedulerMetadataOfferKey) + common.Warnf("WARNING: On-chain offer '%s' is missing '%s' metadata, ignoring.", offer.ID, provider.SchedulerMetadataOfferKey) continue } diff --git a/cmd/wallet/export.go b/cmd/wallet/export.go index 54df2aab..2f6d1a62 100644 --- a/cmd/wallet/export.go +++ b/cmd/wallet/export.go @@ -16,7 +16,7 @@ var exportCmd = &cobra.Command{ Run: func(_ *cobra.Command, args []string) { name := args[0] - fmt.Printf("WARNING: Exporting the account will expose secret key material!\n") + common.Warn("WARNING: Exporting the account will expose secret key material!") acc := common.LoadAccount(config.Global(), name) accCfg, _ := common.LoadAccountConfig(config.Global(), name) diff --git a/cmd/wallet/import.go b/cmd/wallet/import.go index 7662056e..4ee7d89f 100644 --- a/cmd/wallet/import.go +++ b/cmd/wallet/import.go @@ -47,7 +47,7 @@ var ( } var kindRaw string - err = survey.AskOne(&survey.Select{ + err = common.Ask(&survey.Select{ Message: "Kind:", Options: supportedKinds, }, &kindRaw) @@ -57,7 +57,7 @@ var ( cobra.CheckErr(err) // Ask for wallet configuration. - afCfg, err = af.GetConfigFromSurvey(&kind) + afCfg, err = af.GetConfigFromSurvey(&kind, common.SurveyStdio) cobra.CheckErr(err) } else { afCfg["algorithm"] = algorithm @@ -88,7 +88,7 @@ var ( Validate: af.DataValidator(kind, afCfg), }, } - err = survey.Ask(questions, &answers) + err = common.AskMulti(questions, &answers) cobra.CheckErr(err) // Ask for passphrase. passphrase = common.AskNewPassphrase() diff --git a/cmd/wallet/remove.go b/cmd/wallet/remove.go index 2d34275f..adaeda50 100644 --- a/cmd/wallet/remove.go +++ b/cmd/wallet/remove.go @@ -2,6 +2,7 @@ package wallet import ( "fmt" + "os" "strings" "github.com/AlecAivazis/survey/v2" @@ -31,15 +32,15 @@ var rmCmd = &cobra.Command{ } if !common.GetAnswerYes() { - fmt.Printf("WARNING: Removing the account will ERASE secret key material!\n") - fmt.Printf("WARNING: THIS ACTION IS IRREVERSIBLE!\n") + fmt.Fprintln(os.Stderr, "WARNING: Removing the account will ERASE secret key material!") + fmt.Fprintln(os.Stderr, "WARNING: THIS ACTION IS IRREVERSIBLE!") var result string confirmText := fmt.Sprintf("I really want to remove accounts: %s", strings.Join(uniqueArgs, ", ")) - prompt := &survey.Input{ + confirmPrompt := &survey.Input{ Message: fmt.Sprintf("Enter '%s' (without quotes) to confirm removal:", confirmText), } - err := survey.AskOne(prompt, &result) + err := common.Ask(confirmPrompt, &result) cobra.CheckErr(err) if result != confirmText { diff --git a/examples/account/allow-paratime.y.out b/examples/account/allow-paratime.y.out index a929a427..9c5a91f5 100644 --- a/examples/account/allow-paratime.y.out +++ b/examples/account/allow-paratime.y.out @@ -12,3 +12,4 @@ Fee: Network: testnet ParaTime: none (consensus layer) Account: oscar +(In case you are using a hardware-based signer you may need to confirm on device.) diff --git a/examples/account/allow.y.out b/examples/account/allow.y.out index 5d4e9ea8..2c3ea136 100644 --- a/examples/account/allow.y.out +++ b/examples/account/allow.y.out @@ -12,3 +12,4 @@ Fee: Network: testnet ParaTime: none (consensus layer) Account: oscar +(In case you are using a hardware-based signer you may need to confirm on device.) diff --git a/examples/account/amend-commission-schedule.y.out b/examples/account/amend-commission-schedule.y.out index 79f2df20..484d3c12 100644 --- a/examples/account/amend-commission-schedule.y.out +++ b/examples/account/amend-commission-schedule.y.out @@ -21,3 +21,4 @@ Fee: Network: testnet ParaTime: none (consensus layer) Account: oscar +(In case you are using a hardware-based signer you may need to confirm on device.) diff --git a/examples/account/burn.y.out b/examples/account/burn.y.out index b9a09467..840dfe71 100644 --- a/examples/account/burn.y.out +++ b/examples/account/burn.y.out @@ -11,3 +11,4 @@ Fee: Network: testnet ParaTime: none (consensus layer) Account: oscar +(In case you are using a hardware-based signer you may need to confirm on device.) diff --git a/examples/account/delegate-paratime.y.out b/examples/account/delegate-paratime.y.out index 39985fed..ea4c83b8 100644 --- a/examples/account/delegate-paratime.y.out +++ b/examples/account/delegate-paratime.y.out @@ -15,3 +15,4 @@ Fee: Network: testnet ParaTime: sapphire Account: oscar +(In case you are using a hardware-based signer you may need to confirm on device.) diff --git a/examples/account/delegate.y.out b/examples/account/delegate.y.out index 1a0da7e7..be6e0d7b 100644 --- a/examples/account/delegate.y.out +++ b/examples/account/delegate.y.out @@ -12,3 +12,4 @@ Fee: Network: testnet ParaTime: none (consensus layer) Account: oscar +(In case you are using a hardware-based signer you may need to confirm on device.) diff --git a/examples/account/deposit-eth.y.out b/examples/account/deposit-eth.y.out index bce88418..0af71590 100644 --- a/examples/account/deposit-eth.y.out +++ b/examples/account/deposit-eth.y.out @@ -15,3 +15,4 @@ Fee: Network: testnet ParaTime: sapphire Account: oscar +(In case you are using a hardware-based signer you may need to confirm on device.) diff --git a/examples/account/deposit-named.y.out b/examples/account/deposit-named.y.out index f7ca6720..d6f82411 100644 --- a/examples/account/deposit-named.y.out +++ b/examples/account/deposit-named.y.out @@ -15,3 +15,4 @@ Fee: Network: testnet ParaTime: sapphire Account: oscar +(In case you are using a hardware-based signer you may need to confirm on device.) diff --git a/examples/account/deposit-oasis.y.out b/examples/account/deposit-oasis.y.out index 8bb18c12..8fd4413c 100644 --- a/examples/account/deposit-oasis.y.out +++ b/examples/account/deposit-oasis.y.out @@ -15,3 +15,4 @@ Fee: Network: testnet ParaTime: sapphire Account: oscar +(In case you are using a hardware-based signer you may need to confirm on device.) diff --git a/examples/account/deposit.y.out b/examples/account/deposit.y.out index c3217ad9..72175000 100644 --- a/examples/account/deposit.y.out +++ b/examples/account/deposit.y.out @@ -15,3 +15,4 @@ Fee: Network: testnet ParaTime: sapphire Account: oscar +(In case you are using a hardware-based signer you may need to confirm on device.) diff --git a/examples/account/entity-deregister.y.out b/examples/account/entity-deregister.y.out index 3b948399..69a4a7d9 100644 --- a/examples/account/entity-deregister.y.out +++ b/examples/account/entity-deregister.y.out @@ -11,3 +11,4 @@ Fee: Network: testnet ParaTime: none (consensus layer) Account: oscar +(In case you are using a hardware-based signer you may need to confirm on device.) diff --git a/examples/account/entity-register.y.out b/examples/account/entity-register.y.out index 1e31185e..be8f1334 100644 --- a/examples/account/entity-register.y.out +++ b/examples/account/entity-register.y.out @@ -25,3 +25,4 @@ Fee: Network: testnet ParaTime: none (consensus layer) Account: oscar +(In case you are using a hardware-based signer you may need to confirm on device.) diff --git a/examples/account/node-unfreeze.y.out b/examples/account/node-unfreeze.y.out index 63dff9df..523933a2 100644 --- a/examples/account/node-unfreeze.y.out +++ b/examples/account/node-unfreeze.y.out @@ -13,3 +13,4 @@ Fee: Network: testnet ParaTime: none (consensus layer) Account: oscar +(In case you are using a hardware-based signer you may need to confirm on device.) diff --git a/examples/account/transfer-eth.y.out b/examples/account/transfer-eth.y.out index 30a88cbd..7af3cae9 100644 --- a/examples/account/transfer-eth.y.out +++ b/examples/account/transfer-eth.y.out @@ -15,3 +15,4 @@ Fee: Network: testnet ParaTime: sapphire Account: orlando +(In case you are using a hardware-based signer you may need to confirm on device.) diff --git a/examples/account/transfer-eth2.y.out b/examples/account/transfer-eth2.y.out index 2659f6b0..c1139ba6 100644 --- a/examples/account/transfer-eth2.y.out +++ b/examples/account/transfer-eth2.y.out @@ -15,3 +15,4 @@ Fee: Network: testnet ParaTime: sapphire Account: eric +(In case you are using a hardware-based signer you may need to confirm on device.) diff --git a/examples/account/transfer-named-no-paratime.y.out b/examples/account/transfer-named-no-paratime.y.out index 7843cde1..58136449 100644 --- a/examples/account/transfer-named-no-paratime.y.out +++ b/examples/account/transfer-named-no-paratime.y.out @@ -12,3 +12,4 @@ Fee: Network: testnet ParaTime: none (consensus layer) Account: orlando +(In case you are using a hardware-based signer you may need to confirm on device.) diff --git a/examples/account/transfer-named.y.out b/examples/account/transfer-named.y.out index b5ddaa5e..25d50a93 100644 --- a/examples/account/transfer-named.y.out +++ b/examples/account/transfer-named.y.out @@ -15,3 +15,4 @@ Fee: Network: testnet ParaTime: sapphire Account: orlando +(In case you are using a hardware-based signer you may need to confirm on device.) diff --git a/examples/account/transfer-subtract-fee.y.out b/examples/account/transfer-subtract-fee.y.out index 974331a9..2ffe3631 100644 --- a/examples/account/transfer-subtract-fee.y.out +++ b/examples/account/transfer-subtract-fee.y.out @@ -15,3 +15,4 @@ Fee: Network: testnet ParaTime: sapphire Account: orlando +(In case you are using a hardware-based signer you may need to confirm on device.) diff --git a/examples/account/undelegate-paratime.y.out b/examples/account/undelegate-paratime.y.out index 542e66a2..273840f3 100644 --- a/examples/account/undelegate-paratime.y.out +++ b/examples/account/undelegate-paratime.y.out @@ -15,3 +15,4 @@ Fee: Network: testnet ParaTime: sapphire Account: oscar +(In case you are using a hardware-based signer you may need to confirm on device.) diff --git a/examples/account/undelegate.y.out b/examples/account/undelegate.y.out index b59d19ed..7fadbfbc 100644 --- a/examples/account/undelegate.y.out +++ b/examples/account/undelegate.y.out @@ -12,3 +12,4 @@ Fee: Network: testnet ParaTime: none (consensus layer) Account: oscar +(In case you are using a hardware-based signer you may need to confirm on device.) diff --git a/examples/account/withdraw-named.y.out b/examples/account/withdraw-named.y.out index 6f58ee58..a6d6737b 100644 --- a/examples/account/withdraw-named.y.out +++ b/examples/account/withdraw-named.y.out @@ -15,3 +15,4 @@ Fee: Network: testnet ParaTime: sapphire Account: oscar +(In case you are using a hardware-based signer you may need to confirm on device.) diff --git a/examples/account/withdraw-oasis.y.out b/examples/account/withdraw-oasis.y.out index a071af06..e3aac46e 100644 --- a/examples/account/withdraw-oasis.y.out +++ b/examples/account/withdraw-oasis.y.out @@ -15,3 +15,4 @@ Fee: Network: testnet ParaTime: sapphire Account: oscar +(In case you are using a hardware-based signer you may need to confirm on device.) diff --git a/examples/account/withdraw.y.out b/examples/account/withdraw.y.out index 4bf14082..871eb874 100644 --- a/examples/account/withdraw.y.out +++ b/examples/account/withdraw.y.out @@ -15,3 +15,4 @@ Fee: Network: testnet ParaTime: sapphire Account: oscar +(In case you are using a hardware-based signer you may need to confirm on device.) diff --git a/examples/addressbook/02-transfer.y.out b/examples/addressbook/02-transfer.y.out index cfc6f13e..f5e17704 100644 --- a/examples/addressbook/02-transfer.y.out +++ b/examples/addressbook/02-transfer.y.out @@ -15,3 +15,4 @@ Fee: Network: mainnet ParaTime: emerald Account: eugene +(In case you are using a hardware-based signer you may need to confirm on device.) diff --git a/examples/transaction/sign.y.out b/examples/transaction/sign.y.out index 38a554bb..4f8c16f2 100644 --- a/examples/transaction/sign.y.out +++ b/examples/transaction/sign.y.out @@ -12,3 +12,4 @@ Fee: Network: testnet ParaTime: none (consensus layer) Account: test:alice +(In case you are using a hardware-based signer you may need to confirm on device.) diff --git a/wallet/file/file.go b/wallet/file/file.go index ecab03ba..e844fad0 100644 --- a/wallet/file/file.go +++ b/wallet/file/file.go @@ -202,7 +202,7 @@ func (af *fileAccountFactory) GetConfigFromFlags() (map[string]interface{}, erro return cfg, nil } -func (af *fileAccountFactory) GetConfigFromSurvey(kind *wallet.ImportKind) (map[string]interface{}, error) { +func (af *fileAccountFactory) GetConfigFromSurvey(kind *wallet.ImportKind, opts ...survey.AskOpt) (map[string]interface{}, error) { // Ask for import details. var answers struct { Algorithm string @@ -238,7 +238,7 @@ func (af *fileAccountFactory) GetConfigFromSurvey(kind *wallet.ImportKind) (map[ }, }) } - err := survey.Ask(questions, &answers) + err := survey.Ask(questions, &answers, opts...) if err != nil { return nil, err } diff --git a/wallet/ledger/ledger.go b/wallet/ledger/ledger.go index f03df821..3ba7415f 100644 --- a/wallet/ledger/ledger.go +++ b/wallet/ledger/ledger.go @@ -59,7 +59,7 @@ func (af *ledgerAccountFactory) GetConfigFromFlags() (map[string]interface{}, er return cfg, nil } -func (af *ledgerAccountFactory) GetConfigFromSurvey(_ *wallet.ImportKind) (map[string]interface{}, error) { +func (af *ledgerAccountFactory) GetConfigFromSurvey(_ *wallet.ImportKind, _ ...survey.AskOpt) (map[string]interface{}, error) { return nil, fmt.Errorf("ledger: import not supported") } diff --git a/wallet/test/test.go b/wallet/test/test.go index 861aad5d..ef1da11b 100644 --- a/wallet/test/test.go +++ b/wallet/test/test.go @@ -45,7 +45,7 @@ func (af *testAccountFactory) GetConfigFromFlags() (map[string]interface{}, erro return nil, nil } -func (af *testAccountFactory) GetConfigFromSurvey(_ *wallet.ImportKind) (map[string]interface{}, error) { +func (af *testAccountFactory) GetConfigFromSurvey(_ *wallet.ImportKind, _ ...survey.AskOpt) (map[string]interface{}, error) { return nil, fmt.Errorf("test: account is built-in") } diff --git a/wallet/wallet.go b/wallet/wallet.go index d9f0554d..cbbdda70 100644 --- a/wallet/wallet.go +++ b/wallet/wallet.go @@ -67,7 +67,7 @@ type Factory interface { GetConfigFromFlags() (map[string]interface{}, error) // GetConfigFromSurvey generates account configuration from survey answers. - GetConfigFromSurvey(kind *ImportKind) (map[string]interface{}, error) + GetConfigFromSurvey(kind *ImportKind, opts ...survey.AskOpt) (map[string]interface{}, error) // DataPrompt returns a survey prompt for entering data when importing the account. DataPrompt(kind ImportKind, cfg map[string]interface{}) survey.Prompt