Skip to content

Commit 9a27337

Browse files
committed
Update swap state errors
1 parent 1a222bb commit 9a27337

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

pkg/code/server/transaction/errors.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ func NewIntentDeniedError(message string) IntentDeniedError {
7373
}
7474
}
7575

76+
func NewIntentDeniedErrorf(format string, args ...any) IntentDeniedError {
77+
return NewIntentDeniedError(fmt.Sprintf(format, args...))
78+
}
79+
7680
func (e IntentDeniedError) Error() string {
7781
return e.message
7882
}

pkg/code/server/transaction/intent_handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2000,7 +2000,7 @@ func validateSwapFunding(ctx context.Context, data code_data.Provider, intentRec
20002000
isIntentReservedForSwap := swapRecord != nil
20012001

20022002
if isIntentReservedForSwap && swapRecord.State != swap.StateCreated {
2003-
return nil, errors.Errorf("unexpected swap state: %s", swapRecord.State)
2003+
return nil, NewIntentDeniedErrorf("swap state is %s", swapRecord.State)
20042004
}
20052005

20062006
// Intent-specific validation for swaps

pkg/code/server/transaction/swap.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ func (s *transactionServer) Swap(streamer transactionpb.Transaction_SwapServer)
532532
}
533533

534534
if swapRecord.State != swap.StateFunded {
535-
return handleSwapError(streamer, NewSwapValidationErrorf("swap state is %s", swapRecord.State))
535+
return handleSwapError(streamer, NewSwapDeniedErrorf("swap state is %s", swapRecord.State))
536536
}
537537

538538
if owner.PublicKey().ToBase58() == swapAuthority.PublicKey().ToBase58() {

0 commit comments

Comments
 (0)