Skip to content

Commit 51f19e6

Browse files
committed
Add Code account check to Swap RPC
1 parent 73ea989 commit 51f19e6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pkg/code/server/transaction/swap.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@ func (s *transactionServer) Swap(streamer transactionpb.Transaction_SwapServer)
9292
// Section: Antispam
9393
//
9494

95+
ownerManagemntState, err := common.GetOwnerManagementState(ctx, s.data, owner)
96+
if err != nil {
97+
log.WithError(err).Warn("failure getting owner management state")
98+
return handleSwapError(streamer, err)
99+
}
100+
if ownerManagemntState != common.OwnerManagementStateCodeAccount {
101+
return handleSwapError(streamer, NewSwapDeniedError("not a code account"))
102+
}
103+
95104
allow, err := s.antispamGuard.AllowSwap(ctx, owner, fromMint, toMint)
96105
if err != nil {
97106
return handleSwapError(streamer, err)

0 commit comments

Comments
 (0)