Skip to content

Commit 38d8586

Browse files
committed
Account type is now considered for OpenAccounts no-op check
1 parent 0039a7a commit 38d8586

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pkg/code/server/transaction/intent_handler.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,29 +108,32 @@ func (h *OpenAccountsIntentHandler) IsNoop(ctx context.Context, intentRecord *in
108108
}
109109

110110
var authorityToCheck *common.Account
111+
var expectedAccountType commonpb.AccountType
111112
var err error
112113
switch typedMetadata.AccountSet {
113114
case transactionpb.OpenAccountsMetadata_USER:
114115
authorityToCheck, err = common.NewAccountFromPublicKeyString(intentRecord.InitiatorOwnerAccount)
115116
if err != nil {
116117
return false, err
117118
}
119+
expectedAccountType = commonpb.AccountType_PRIMARY
118120
case transactionpb.OpenAccountsMetadata_POOL:
119121
authorityToCheck, err = common.NewAccountFromProto(actions[0].GetOpenAccount().Authority)
120122
if err != nil {
121123
return false, err
122124
}
125+
expectedAccountType = commonpb.AccountType_POOL
123126
default:
124127
return false, NewIntentValidationErrorf("unsupported account set: %s", typedMetadata.AccountSet)
125128
}
126129

127-
_, err = h.data.GetAccountInfoByAuthorityAddress(ctx, authorityToCheck.PublicKey().ToBase58())
130+
accountInfoRecord, err := h.data.GetAccountInfoByAuthorityAddress(ctx, authorityToCheck.PublicKey().ToBase58())
128131
if err == account.ErrAccountInfoNotFound {
129132
return false, nil
130133
} else if err != nil {
131134
return false, err
132135
}
133-
return true, nil
136+
return accountInfoRecord.AccountType == expectedAccountType, nil
134137
}
135138

136139
func (h *OpenAccountsIntentHandler) GetBalanceLocks(ctx context.Context, intentRecord *intent.Record, metadata *transactionpb.Metadata) ([]*intentBalanceLock, error) {

0 commit comments

Comments
 (0)