Skip to content

Commit

Permalink
Merge pull request #38 from LATOKEN/feature-full-swap-status
Browse files Browse the repository at this point in the history
Feature full swap status
  • Loading branch information
arout2 authored Oct 3, 2022
2 parents b71fa66 + b4da118 commit 08af407
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/service/storage/swap.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,19 @@ 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
}

return swap, nil
}

// GetSwapByTxHash ...
func (d *DataBase) GetSwapByTxHash(txHash string) (*Swap, error) {
swap := &Swap{}
if err := d.db.Where("tx_hash = ?", txHash).
Find(&swap).Error; err != nil {
return nil, err
}
Expand Down

0 comments on commit 08af407

Please sign in to comment.