fixme in wire status

This commit is contained in:
Sebastian 2023-04-24 12:13:55 -03:00
parent ab49083257
commit e4bf114f60
No known key found for this signature in database
GPG Key ID: 173909D1A5F66069

View File

@ -441,7 +441,7 @@ export async function processDepositGroup(
let updatedTxStatus: DepositElementStatus | undefined = undefined; let updatedTxStatus: DepositElementStatus | undefined = undefined;
type ValueOf<T> = T[keyof T]; type ValueOf<T> = T[keyof T];
let newWiredTransaction: let newWiredCoin:
| { | {
id: string; id: string;
value: ValueOf<NonNullable<DepositGroupRecord["trackingState"]>>; value: ValueOf<NonNullable<DepositGroupRecord["trackingState"]>>;
@ -484,7 +484,7 @@ export async function processDepositGroup(
const raw = Amounts.parseOrThrow(track.coin_contribution); const raw = Amounts.parseOrThrow(track.coin_contribution);
const wireFee = Amounts.parseOrThrow(fee.wireFee); const wireFee = Amounts.parseOrThrow(fee.wireFee);
newWiredTransaction = { newWiredCoin = {
value: { value: {
amountRaw: Amounts.stringify(raw), amountRaw: Amounts.stringify(raw),
wireFee: Amounts.stringify(wireFee), wireFee: Amounts.stringify(wireFee),
@ -513,13 +513,20 @@ export async function processDepositGroup(
if (updatedTxStatus !== undefined) { if (updatedTxStatus !== undefined) {
dg.transactionPerCoin[i] = updatedTxStatus; dg.transactionPerCoin[i] = updatedTxStatus;
} }
if (newWiredTransaction) { if (newWiredCoin) {
/**
* FIXME: if there is a new wire information from the exchange
* it should add up to the previous tracking states.
*
* This may loose information by overriding prev state.
*
* And: add checks to integration tests
*/
if (!dg.trackingState) { if (!dg.trackingState) {
dg.trackingState = {}; dg.trackingState = {};
} }
dg.trackingState[newWiredTransaction.id] = dg.trackingState[newWiredCoin.id] = newWiredCoin.value;
newWiredTransaction.value;
} }
await tx.depositGroups.put(dg); await tx.depositGroups.put(dg);
}); });