verboseDetails for pay and withdraw
This commit is contained in:
parent
a76219b8de
commit
c5906abf10
@ -186,4 +186,8 @@ export async function runIntegrationTest(args: IntegrationTestArgs) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
await myWallet.runUntilDone();
|
await myWallet.runUntilDone();
|
||||||
|
|
||||||
|
const history = await myWallet.getHistory();
|
||||||
|
|
||||||
|
console.log("history after integration test:", JSON.stringify(history, undefined, 2));
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,8 @@ import {
|
|||||||
TipRecord,
|
TipRecord,
|
||||||
ProposalStatus,
|
ProposalStatus,
|
||||||
ProposalRecord,
|
ProposalRecord,
|
||||||
|
PlanchetRecord,
|
||||||
|
CoinRecord,
|
||||||
} from "../types/dbTypes";
|
} from "../types/dbTypes";
|
||||||
import * as Amounts from "../util/amounts";
|
import * as Amounts from "../util/amounts";
|
||||||
import { AmountJson } from "../util/amounts";
|
import { AmountJson } from "../util/amounts";
|
||||||
@ -33,6 +35,8 @@ import {
|
|||||||
OrderShortInfo,
|
OrderShortInfo,
|
||||||
ReserveType,
|
ReserveType,
|
||||||
ReserveCreationDetail,
|
ReserveCreationDetail,
|
||||||
|
VerbosePayCoinDetails,
|
||||||
|
VerboseWithdrawDetails,
|
||||||
} from "../types/history";
|
} from "../types/history";
|
||||||
import { assertUnreachable } from "../util/assertUnreachable";
|
import { assertUnreachable } from "../util/assertUnreachable";
|
||||||
import { TransactionHandle, Store } from "../util/query";
|
import { TransactionHandle, Store } from "../util/query";
|
||||||
@ -203,6 +207,22 @@ export async function getHistory(
|
|||||||
|
|
||||||
tx.iter(Stores.withdrawalSession).forEach(wsr => {
|
tx.iter(Stores.withdrawalSession).forEach(wsr => {
|
||||||
if (wsr.timestampFinish) {
|
if (wsr.timestampFinish) {
|
||||||
|
const cs: PlanchetRecord[] = [];
|
||||||
|
wsr.planchets.forEach((x) => {
|
||||||
|
if (x) {
|
||||||
|
cs.push(x);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const verboseDetails: VerboseWithdrawDetails = {
|
||||||
|
coins: cs.map((x) => ({
|
||||||
|
value: Amounts.toString(x.coinValue),
|
||||||
|
denomPub: x.denomPub,
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
const coins = cs.map((x) => ({
|
||||||
|
value: x.coinValue
|
||||||
|
}));
|
||||||
|
|
||||||
history.push({
|
history.push({
|
||||||
type: HistoryEventType.Withdrawn,
|
type: HistoryEventType.Withdrawn,
|
||||||
withdrawSessionId: wsr.withdrawSessionId,
|
withdrawSessionId: wsr.withdrawSessionId,
|
||||||
@ -215,6 +235,7 @@ export async function getHistory(
|
|||||||
exchangeBaseUrl: wsr.exchangeBaseUrl,
|
exchangeBaseUrl: wsr.exchangeBaseUrl,
|
||||||
timestamp: wsr.timestampFinish,
|
timestamp: wsr.timestampFinish,
|
||||||
withdrawalSource: wsr.source,
|
withdrawalSource: wsr.source,
|
||||||
|
verboseDetails,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -234,6 +255,29 @@ export async function getHistory(
|
|||||||
if (!orderShortInfo) {
|
if (!orderShortInfo) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const coins: {
|
||||||
|
value: string,
|
||||||
|
contribution: string;
|
||||||
|
denomPub: string;
|
||||||
|
}[] = [];
|
||||||
|
for (const x of purchase.payReq.coins) {
|
||||||
|
const c = await tx.get(Stores.coins, x.coin_pub);
|
||||||
|
if (!c) {
|
||||||
|
// FIXME: what to do here??
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const d = await tx.get(Stores.denominations, [c.exchangeBaseUrl, c.denomPub]);
|
||||||
|
if (!d) {
|
||||||
|
// FIXME: what to do here??
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
coins.push({
|
||||||
|
contribution: x.contribution,
|
||||||
|
denomPub: c.denomPub,
|
||||||
|
value: Amounts.toString(d.value),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const verboseDetails: VerbosePayCoinDetails = { coins };
|
||||||
const amountPaidWithFees = Amounts.sum(
|
const amountPaidWithFees = Amounts.sum(
|
||||||
purchase.payReq.coins.map(x => Amounts.parseOrThrow(x.contribution)),
|
purchase.payReq.coins.map(x => Amounts.parseOrThrow(x.contribution)),
|
||||||
).amount;
|
).amount;
|
||||||
@ -246,6 +290,7 @@ export async function getHistory(
|
|||||||
timestamp: pe.timestamp,
|
timestamp: pe.timestamp,
|
||||||
numCoins: purchase.payReq.coins.length,
|
numCoins: purchase.payReq.coins.length,
|
||||||
amountPaidWithFees: Amounts.toString(amountPaidWithFees),
|
amountPaidWithFees: Amounts.toString(amountPaidWithFees),
|
||||||
|
verboseDetails,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ import { ReserveTransaction } from "./ReserveTransaction";
|
|||||||
import { WithdrawalSource } from "./dbTypes";
|
import { WithdrawalSource } from "./dbTypes";
|
||||||
import { Timestamp } from "../util/time";
|
import { Timestamp } from "../util/time";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type tags for the history event types.
|
* Type tags for the history event types.
|
||||||
*/
|
*/
|
||||||
@ -466,6 +465,15 @@ export interface HistoryPaymentAbortedEvent {
|
|||||||
amountLost: string;
|
amountLost: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface VerbosePayCoinDetails {
|
||||||
|
coins:
|
||||||
|
{
|
||||||
|
value: string,
|
||||||
|
contribution: string;
|
||||||
|
denomPub: string;
|
||||||
|
}[],
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* History event to indicate that a payment has been (re-)submitted
|
* History event to indicate that a payment has been (re-)submitted
|
||||||
* to the merchant.
|
* to the merchant.
|
||||||
@ -501,6 +509,8 @@ export interface HistoryPaymentSent {
|
|||||||
* Session ID that the payment was (re-)submitted under.
|
* Session ID that the payment was (re-)submitted under.
|
||||||
*/
|
*/
|
||||||
sessionId: string | undefined;
|
sessionId: string | undefined;
|
||||||
|
|
||||||
|
verboseDetails: VerbosePayCoinDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -575,6 +585,13 @@ export interface HistoryRefreshedEvent {
|
|||||||
refreshGroupId: string;
|
refreshGroupId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface VerboseWithdrawDetails {
|
||||||
|
coins: {
|
||||||
|
value: string;
|
||||||
|
denomPub: string;
|
||||||
|
}[];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A withdrawal has completed.
|
* A withdrawal has completed.
|
||||||
*/
|
*/
|
||||||
@ -604,6 +621,8 @@ export interface HistoryWithdrawnEvent {
|
|||||||
* Amount that actually was added to the wallet's balance.
|
* Amount that actually was added to the wallet's balance.
|
||||||
*/
|
*/
|
||||||
amountWithdrawnEffective: string;
|
amountWithdrawnEffective: string;
|
||||||
|
|
||||||
|
verboseDetails: VerboseWithdrawDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user