Skip to content

Commit

Permalink
client/core,webserver: show match revoked status
Browse files Browse the repository at this point in the history
Supplement core.Match with an Active field, set via MatchIsActive.

Update (*orderReader).hasLiveMatches to consult the Active field instead
of just comparing Status < MakerRedeemed.

Update (*matchReader).StatusString with text for revoked matches.
When revoked and also active show "Revoked - Refund PENDING".
When revoked and not active, show if it was refunded, (auto)redeemed,
or simply complete when no txns are needed.
  • Loading branch information
chappjc committed Nov 13, 2021
1 parent 28473de commit c2169a7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 2 additions & 0 deletions client/core/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ type RegisterForm struct {
type Match struct {
MatchID dex.Bytes `json:"matchID"`
Status order.MatchStatus `json:"status"`
Active bool `json:"active"`
Revoked bool `json:"revoked"`
Rate uint64 `json:"rate"`
Qty uint64 `json:"qty"`
Expand Down Expand Up @@ -257,6 +258,7 @@ func matchFromMetaMatchWithConfs(ord order.Order, metaMatch *db.MetaMatch, swapC
match := &Match{
MatchID: userMatch.MatchID[:],
Status: userMatch.Status,
Active: db.MatchIsActive(userMatch, proof),
Revoked: proof.IsRevoked(),
Rate: userMatch.Rate,
Qty: userMatch.Quantity,
Expand Down
19 changes: 17 additions & 2 deletions client/webserver/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ func (ord *orderReader) sumTo(filter func(match *core.Match) bool) uint64 {
// hasLiveMatches will be true if there are any matches < MakerRedeemed.
func (ord *orderReader) hasLiveMatches() bool {
for _, match := range ord.Matches {
if match.Status < order.MakerRedeemed {
if match.Active {
return true
}
}
Expand Down Expand Up @@ -466,6 +466,21 @@ func newMatchReader(match *core.Match, ord *orderReader) *matchReader {

// StatusString is a formatted string of the match status.
func (m *matchReader) StatusString() string {
if m.Revoked {
// When revoked, match status is less important than pending action if
// still active, or the outcome if inactive.
switch {
case m.Active:
return "Revoked - Refund PENDING" // could auto-redeem too, but we are waiting
case m.Refund != nil:
return "Revoked - Refunded"
// TODO: show refund txid on /order page
case m.Redeem != nil:
return "Revoked - Redeemed"
} // otherwise no txns needed to retire
return "Revoked - Complete"
}

switch m.Status {
case order.NewlyMatched:
return "(0 / 4) Newly Matched"
Expand All @@ -481,7 +496,7 @@ func (m *matchReader) StatusString() string {
case order.MatchComplete:
return "Match Complete"
}
return "Unknown Order Status"
return "Unknown Match Status"
}

// RateString is the formatted match rate, with units.
Expand Down

0 comments on commit c2169a7

Please sign in to comment.