Repository: vegaprotocol/vegawallet
Pull request #532 (2022-03-30 15:14:07)

Remove unused chan in AutomaticConsent policy

github-actions[bot]: Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>
github-actions[bot]: Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>
github-actions[bot]: Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>
github-actions[bot]: Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>
github-actions[bot]: Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>
github-actions[bot]: Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>
github-actions[bot]: Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>
github-actions[bot]: Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>
github-actions[bot]: Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ba7b56c..31e35b7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,7 +3,7 @@
 ## Unreleased (0.14.0)
 
 ### 🚨 Breaking changes
-- [497](https://github.com/vegaprotocol/vegawallet/issues/497) - Add ability to confirm the signing of a transaction
+- [497](https://github.com/vegaprotocol/vegawallet/issues/497) - Add ability to confirm the signing of a transaction. To keep running the service with automatic consent, `--automatic-consent` flag is now required.
 
 ### 🗑️  Deprecation
 - [](https://github.com/vegaprotocol/vegawallet/pull/) -
@@ -17,6 +17,7 @@
 ### 🐛 Fixes
 - [521](https://github.com/vegaprotocol/vegawallet/pull/521) - Update `protos` repository to get last validation updates on commands
 - [523](https://github.com/vegaprotocol/vegawallet/pull/521) - Add link in `README` to direct people to desktop wallet app
+- [529](https://github.com/vegaprotocol/vegawallet/pull/529) - Ensure log files can be created on Windows.
 
 
 ## 0.13.2
diff --git a/cmd/logger.go b/cmd/logger.go
index 3d26b68..2762e75 100644
--- a/cmd/logger.go
+++ b/cmd/logger.go
@@ -163,8 +163,8 @@ func isSupportedLogLevel(level string) bool {
 // newWinFileSink creates a log sink on Windows machines as zap, by default,
 // doesn't support Windows paths. A workaround is to create a fake winfile
 // scheme and register it with zap instead. This workaround is taken from
-// the Github issue at https://github.com/uber-go/zap/issues/621
+// the GitHub issue at https://github.com/uber-go/zap/issues/621.
 func newWinFileSink(u *url.URL) (zap.Sink, error) {
-	// Remove leading slash left by url.Parse()
-	return os.OpenFile(u.Path[1:], os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644)
+	// Remove leading slash left by url.Parse().
+	return os.OpenFile(u.Path[1:], os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0o644) // nolint:gomnd
 }
diff --git a/cmd/service_run.go b/cmd/service_run.go
index e81b6cf..a7d250b 100644
--- a/cmd/service_run.go
+++ b/cmd/service_run.go
@@ -223,19 +223,19 @@ func RunService(w io.Writer, rf *RootFlags, f *RunServiceFlags) error {
 		cliLog.Info("TTY detected")
 		if f.EnableAutomaticConsent {
 			cliLog.Info("Automatic consent enabled")
-			policy = service.NewAutomaticConsentPolicy(pendingConsents)
+			policy = service.NewAutomaticConsentPolicy()
 		} else {
 			cliLog.Info("Explicit consent enabled")
 			policy = service.NewExplicitConsentPolicy(pendingConsents)
 		}
-
 	} else {
+		cliLog.Info("No TTY detected")
 		if !f.EnableAutomaticConsent {
 			cliLog.Error("Explicit consent can't be used when no TTY is attached to the process")
 			return ErrEnableAutomaticConsentFlagIsRequiredWithoutTTY
 		}
 		cliLog.Info("Automatic consent enabled")
-		policy = service.NewAutomaticConsentPolicy(pendingConsents)
+		policy = service.NewAutomaticConsentPolicy()
 	}
 
 	srv, err := service.NewService(svcLog.Named("api"), cfg, handler, auth, forwarder, policy)
diff --git a/service/policies.go b/service/policies.go
index 8eda614..a304269 100644
--- a/service/policies.go
+++ b/service/policies.go
@@ -25,14 +25,10 @@ type Policy interface {
 	Ask(tx *v1.SubmitTransactionRequest) (bool, error)
 }
 
-type AutomaticConsentPolicy struct {
-	pendingEvents chan ConsentRequest
-}
+type AutomaticConsentPolicy struct{}
 
-func NewAutomaticConsentPolicy(pending chan ConsentRequest) Policy {
-	return &AutomaticConsentPolicy{
-		pendingEvents: pending,
-	}
+func NewAutomaticConsentPolicy() Policy {
+	return &AutomaticConsentPolicy{}
 }
 
 func (p *AutomaticConsentPolicy) Ask(_ *v1.SubmitTransactionRequest) (bool, error) {


Test patch:
diff --git a/service/service_test.go b/service/service_test.go
index efec53d..d230707 100644
--- a/service/service_test.go
+++ b/service/service_test.go
@@ -56,7 +56,7 @@ func getTestService(t *testing.T, consentPolicy string) *testService {
 	var policy service.Policy
 	switch consentPolicy {
 	case "automatic":
-		policy = service.NewAutomaticConsentPolicy(pendingConsents)
+		policy = service.NewAutomaticConsentPolicy()
 	case "manual":
 		policy = mocks.NewMockConsentPolicy(pendingConsents)
 	default: