Skip to content

Commit eb01d08

Browse files
UI: MetaDEx cancel support in transaction history
1 parent b06db65 commit eb01d08

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

src/qt/txhistorydialog.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -186,19 +186,23 @@ int TXHistoryDialog::PopulateHistoryMap()
186186
htxo.blockByteOffset = pendingWTx->nOrderPos;
187187
}
188188
htxo.valid = true; // all pending transactions are assumed to be valid while awaiting confirmation since all pending are outbound and we wouldn't let them be sent if invalid
189+
htxo.address = senderAddress; // always sender, all pending are outbound
190+
if (isPropertyDivisible(propertyId)) {
191+
htxo.amount = "-" + FormatDivisibleShortMP(amount) + getTokenLabel(propertyId);
192+
} else {
193+
htxo.amount = "-" + FormatIndivisibleMP(amount) + getTokenLabel(propertyId);
194+
} // pending always outbound
189195
if (p_pending->type == MSC_TYPE_SIMPLE_SEND) {
190196
htxo.txType = "Send";
191197
htxo.fundsMoved = true;
192-
} // we don't have a CMPTransaction class here so manually set the type for now
193-
if (p_pending->type == MSC_TYPE_METADEX_TRADE
194-
|| p_pending->type == MSC_TYPE_METADEX_CANCEL_PRICE
195-
|| p_pending->type == MSC_TYPE_METADEX_CANCEL_PAIR
196-
|| p_pending->type == MSC_TYPE_METADEX_CANCEL_ECOSYSTEM) {
198+
} else if (p_pending->type == MSC_TYPE_METADEX_TRADE) {
197199
htxo.txType = "MetaDEx Trade";
198200
htxo.fundsMoved = false;
201+
} else if (p_pending->type == MSC_TYPE_METADEX_CANCEL_PRICE || p_pending->type == MSC_TYPE_METADEX_CANCEL_PAIR || p_pending->type == MSC_TYPE_METADEX_CANCEL_ECOSYSTEM) {
202+
htxo.txType = "MetaDEx Cancel";
203+
htxo.fundsMoved = false;
204+
htxo.amount = "N/A";
199205
} // send and metadex trades are the only supported outbound txs (thus only possible pending) for now
200-
htxo.address = senderAddress; // always sender, all pending are outbound
201-
if(isPropertyDivisible(propertyId)) {htxo.amount = "-"+FormatDivisibleShortMP(amount)+getTokenLabel(propertyId);} else {htxo.amount="-"+FormatIndivisibleMP(amount)+getTokenLabel(propertyId);} // pending always outbound
202206
txHistoryMap.insert(std::make_pair(txid, htxo));
203207
nProcessed += 1; // increase our counter so we don't go crazy on a wallet with too many transactions and lock up UI
204208
}
@@ -382,6 +386,11 @@ int TXHistoryDialog::PopulateHistoryMap()
382386
// alerts are valid and thus display a wacky value attempting to decode amount - whilst no users should ever see this, be clean and N/A the wacky value
383387
if ((!valid) || (displayType == "Unknown")) { displayAmount = "N/A"; }
384388
} else { if ((fundsMoved) && (IsMyAddress(senderAddress))) { displayAmount = "-" + displayAmount; } }
389+
// override amount on MetaDEx cancels, they don't carry an explicit amount
390+
if (mp_obj.getType() == MSC_TYPE_METADEX_CANCEL_PRICE || mp_obj.getType() == MSC_TYPE_METADEX_CANCEL_PAIR || mp_obj.getType() == MSC_TYPE_METADEX_CANCEL_ECOSYSTEM) {
391+
displayAmount = "N/A";
392+
}
393+
385394
// create a HistoryTXObject and add to map
386395
HistoryTXObject htxo;
387396
htxo.blockHeight = blockHeight;
@@ -592,11 +601,11 @@ std::string TXHistoryDialog::shrinkTxType(int txType, bool *fundsMoved)
592601
case MSC_TYPE_AUTOMATIC_DISPENSARY: displayType = "Auto Dispense"; break;
593602
case MSC_TYPE_TRADE_OFFER: displayType = "DEx Trade"; *fundsMoved = false; break;
594603
case MSC_TYPE_ACCEPT_OFFER_BTC: displayType = "DEx Accept"; *fundsMoved = false; break;
595-
case MSC_TYPE_METADEX_TRADE:
604+
case MSC_TYPE_METADEX_TRADE: displayType = "MetaDEx Trade"; *fundsMoved = false; break;
596605
case MSC_TYPE_METADEX_CANCEL_PRICE:
597606
case MSC_TYPE_METADEX_CANCEL_PAIR:
598607
case MSC_TYPE_METADEX_CANCEL_ECOSYSTEM:
599-
displayType = "MetaDEx Trade"; *fundsMoved = false; break;
608+
displayType = "MetaDEx Cancel"; *fundsMoved = false; break;
600609
case MSC_TYPE_CREATE_PROPERTY_FIXED: displayType = "Create Property"; break;
601610
case MSC_TYPE_CREATE_PROPERTY_VARIABLE: displayType = "Create Property"; break;
602611
case MSC_TYPE_PROMOTE_PROPERTY: displayType = "Promo Property"; break;

0 commit comments

Comments
 (0)