diff --git a/commands/proposal_submission.go b/commands/proposal_submission.go index 0387fde88e..2d48d2426a 100644 --- a/commands/proposal_submission.go +++ b/commands/proposal_submission.go @@ -36,7 +36,11 @@ import ( const ReferenceMaxLen int = 100 -var validAccountTypes = map[vegapb.AccountType]struct{}{ +var validFromAccountTypesForPAP = map[vegapb.AccountType]struct{}{ + vegapb.AccountType_ACCOUNT_TYPE_BUY_BACK_FEES: {}, +} + +var validToAccountTypesForPAP = map[vegapb.AccountType]struct{}{ vegapb.AccountType_ACCOUNT_TYPE_GLOBAL_INSURANCE: {}, vegapb.AccountType_ACCOUNT_TYPE_GLOBAL_REWARD: {}, vegapb.AccountType_ACCOUNT_TYPE_NETWORK_TREASURY: {}, @@ -435,13 +439,13 @@ func checkAutomatedPurchaseConfig(newAutoPurchase *vegapb.ProposalTerms_NewProto if change.FromAccountType == vegapb.AccountType_ACCOUNT_TYPE_UNSPECIFIED { errs.AddForProperty("proposal_submission.terms.change.protocol_automated_purchase.changes.from_account_type", ErrIsRequired) } - if _, ok := validAccountTypes[change.FromAccountType]; !ok { + if _, ok := validFromAccountTypesForPAP[change.FromAccountType]; !ok { errs.AddForProperty("proposal_submission.terms.change.protocol_automated_purchase.changes.from_account_type", ErrIsNotValid) } if change.ToAccountType == vegapb.AccountType_ACCOUNT_TYPE_UNSPECIFIED { errs.AddForProperty("proposal_submission.terms.change.protocol_automated_purchase.changes.to_account_type", ErrIsRequired) } - if _, ok := validAccountTypes[change.ToAccountType]; !ok { + if _, ok := validToAccountTypesForPAP[change.ToAccountType]; !ok { errs.AddForProperty("proposal_submission.terms.change.protocol_automated_purchase.changes.to_account_type", ErrIsNotValid) } if len(change.MarketId) == 0 { diff --git a/commands/proposal_submission_pap_test.go b/commands/proposal_submission_pap_test.go index 674f0f7395..0130f1d40d 100644 --- a/commands/proposal_submission_pap_test.go +++ b/commands/proposal_submission_pap_test.go @@ -63,11 +63,8 @@ func TestSubmissionOfNewPAPWithoutFromAssetFails(t *testing.T) { } func TestSubmissionOfNewPAPInvalidFromAccountTypeFails(t *testing.T) { - validAccountTypes := map[types.AccountType]struct{}{ - types.AccountType_ACCOUNT_TYPE_GLOBAL_INSURANCE: {}, - types.AccountType_ACCOUNT_TYPE_GLOBAL_REWARD: {}, - types.AccountType_ACCOUNT_TYPE_NETWORK_TREASURY: {}, - types.AccountType_ACCOUNT_TYPE_BUY_BACK_FEES: {}, + validFromAccountTypes := map[types.AccountType]struct{}{ + types.AccountType_ACCOUNT_TYPE_BUY_BACK_FEES: {}, } for tp := range types.AccountType_name { err := checkProposalSubmission(&commandspb.ProposalSubmission{ @@ -81,7 +78,7 @@ func TestSubmissionOfNewPAPInvalidFromAccountTypeFails(t *testing.T) { }, }, }) - _, ok := validAccountTypes[types.AccountType(tp)] + _, ok := validFromAccountTypes[types.AccountType(tp)] if !ok { if tp == 0 { assert.Contains(t, err.Get("proposal_submission.terms.change.protocol_automated_purchase.changes.from_account_type"), commands.ErrIsRequired)