Skip to content

Commit

Permalink
Merge pull request #37 from LATOKEN/feature-full-swap-status
Browse files Browse the repository at this point in the history
Added all statuses to swap endpoint
  • Loading branch information
arout2 authored Oct 3, 2022
2 parents 5f9181e + b4da118 commit b07ae9b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/service/storage/swap.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ func (d *DataBase) GetSwapBySwapID(swapID string) []*Swap {
// GetSwapByStatus ...
func (d *DataBase) GetSwapByStatus(swapType SwapType, sender, receipt string, amount string, txHash string) (*Swap, error) {
swap := &Swap{}
if err := d.db.Where("type = ? and sender_addr = ? and receiver_addr = ? and out_amount = ? and tx_hash = ? and status in (?)",
swapType, sender, receipt, amount, txHash,
[]SwapStatus{SwapStatusDepositConfirmed, SwapStatusClaimSent, SwapStatusClaimConfirmed, SwapStatusClaimSentFailed, SwapStatusDepositFailed, SwapStatusPassedConfirmed, SwapStatusPassedSent, SwapStatusSpendSent, SwapStatusSpendConfirmed, SwapStatusRejected}).
if err := d.db.Where("type = ? and sender_addr = ? and receiver_addr = ? and out_amount = ? and tx_hash = ?",
swapType, sender, receipt, amount, txHash).
Find(&swap).Error; err != nil {
return nil, err
}
Expand All @@ -48,8 +47,7 @@ func (d *DataBase) GetSwapByStatus(swapType SwapType, sender, receipt string, am
// GetSwapByTxHash ...
func (d *DataBase) GetSwapByTxHash(txHash string) (*Swap, error) {
swap := &Swap{}
if err := d.db.Where("tx_hash = ? and status in (?)", txHash,
[]SwapStatus{SwapStatusDepositConfirmed, SwapStatusClaimSent, SwapStatusClaimConfirmed, SwapStatusClaimSentFailed, SwapStatusDepositFailed, SwapStatusPassedConfirmed, SwapStatusPassedSent, SwapStatusSpendSent, SwapStatusSpendConfirmed, SwapStatusRejected}).
if err := d.db.Where("tx_hash = ?", txHash).
Find(&swap).Error; err != nil {
return nil, err
}
Expand Down

0 comments on commit b07ae9b

Please sign in to comment.