wallet-core: fixup for legacy peer-push-debit transaction
This commit is contained in:
parent
339080e014
commit
dd9e4555ba
@ -118,7 +118,7 @@ export const CURRENT_DB_CONFIG_KEY = "currentMainDbName";
|
|||||||
* backwards-compatible way or object stores and indices
|
* backwards-compatible way or object stores and indices
|
||||||
* are added.
|
* are added.
|
||||||
*/
|
*/
|
||||||
export const WALLET_DB_MINOR_VERSION = 5;
|
export const WALLET_DB_MINOR_VERSION = 6;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ranges for operation status fields.
|
* Ranges for operation status fields.
|
||||||
@ -2606,6 +2606,17 @@ export const walletDbFixups: FixupDescription[] = [
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "PeerPushPaymentInitiationRecord_ALL_removeLegacyTx",
|
||||||
|
async fn(tx): Promise<void> {
|
||||||
|
await tx.peerPushPaymentInitiations.iter().forEachAsync(async (pi) => {
|
||||||
|
// Remove legacy transactions that don't have the totalCost field yet.
|
||||||
|
if (!pi.totalCost) {
|
||||||
|
await tx.peerPushPaymentInitiations.delete(pi.pursePub);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const logger = new Logger("db.ts");
|
const logger = new Logger("db.ts");
|
||||||
@ -2613,11 +2624,13 @@ const logger = new Logger("db.ts");
|
|||||||
export async function applyFixups(
|
export async function applyFixups(
|
||||||
db: DbAccess<typeof WalletStoresV1>,
|
db: DbAccess<typeof WalletStoresV1>,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
logger.trace("applying fixups");
|
||||||
await db.mktxAll().runReadWrite(async (tx) => {
|
await db.mktxAll().runReadWrite(async (tx) => {
|
||||||
for (const fixupInstruction of walletDbFixups) {
|
for (const fixupInstruction of walletDbFixups) {
|
||||||
|
logger.trace(`checking fixup ${fixupInstruction.name}`);
|
||||||
const fixupRecord = await tx.fixups.get(fixupInstruction.name);
|
const fixupRecord = await tx.fixups.get(fixupInstruction.name);
|
||||||
if (fixupRecord) {
|
if (fixupRecord) {
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
logger.info(`applying DB fixup ${fixupInstruction.name}`);
|
logger.info(`applying DB fixup ${fixupInstruction.name}`);
|
||||||
await fixupInstruction.fn(tx);
|
await fixupInstruction.fn(tx);
|
||||||
|
@ -1580,6 +1580,8 @@ export async function checkPeerPullPaymentInitiation(
|
|||||||
// Select an exchange where we have money in the specified currency
|
// Select an exchange where we have money in the specified currency
|
||||||
// FIXME: How do we handle regional currency scopes here? Is it an additional input?
|
// FIXME: How do we handle regional currency scopes here? Is it an additional input?
|
||||||
|
|
||||||
|
logger.trace("checking peer-pull-credit fees");
|
||||||
|
|
||||||
const currency = Amounts.currencyOf(req.amount);
|
const currency = Amounts.currencyOf(req.amount);
|
||||||
let exchangeUrl;
|
let exchangeUrl;
|
||||||
if (req.exchangeBaseUrl) {
|
if (req.exchangeBaseUrl) {
|
||||||
@ -1592,6 +1594,8 @@ export async function checkPeerPullPaymentInitiation(
|
|||||||
throw Error("no exchange found for initiating a peer pull payment");
|
throw Error("no exchange found for initiating a peer pull payment");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.trace(`found ${exchangeUrl} as preferred exchange`);
|
||||||
|
|
||||||
const wi = await getExchangeWithdrawalInfo(
|
const wi = await getExchangeWithdrawalInfo(
|
||||||
ws,
|
ws,
|
||||||
exchangeUrl,
|
exchangeUrl,
|
||||||
@ -1599,6 +1603,8 @@ export async function checkPeerPullPaymentInitiation(
|
|||||||
undefined,
|
undefined,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
logger.trace(`got withdrawal info`);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
exchangeBaseUrl: exchangeUrl,
|
exchangeBaseUrl: exchangeUrl,
|
||||||
amountEffective: wi.withdrawalAmountEffective,
|
amountEffective: wi.withdrawalAmountEffective,
|
||||||
|
Loading…
Reference in New Issue
Block a user