fix: transfor from backup proporsal status to purchase status and fix denom query

This commit is contained in:
Sebastian 2022-10-21 12:24:23 -03:00
parent f4b92578b0
commit 892b3b500a
No known key found for this signature in database
GPG Key ID: BE4FF68352439FC1

View File

@ -588,8 +588,22 @@ export async function importBackup(
case BackupProposalStatus.Paid:
proposalStatus = PurchaseStatus.Paid;
break;
default:
throw Error();
case BackupProposalStatus.Proposed:
proposalStatus = PurchaseStatus.Proposed;
break;
case BackupProposalStatus.PermanentlyFailed:
proposalStatus = PurchaseStatus.PaymentAbortFinished;
break;
case BackupProposalStatus.Refused:
proposalStatus = PurchaseStatus.ProposalRefused;
break;
case BackupProposalStatus.Repurchase:
proposalStatus = PurchaseStatus.RepurchaseDetected;
break;
default: {
const error: never = backupPurchase.proposal_status;
throw Error(`backup status ${error} is not handled`);
}
}
if (!existingPurchase) {
const refunds: { [refundKey: string]: WalletRefundItem } = {};
@ -744,7 +758,10 @@ export async function importBackup(
for (const oldCoin of backupRefreshGroup.old_coins) {
const c = await tx.coins.get(oldCoin.coin_pub);
checkBackupInvariant(!!c);
const d = await tx.denominations.get(c.denomPubHash);
const d = await tx.denominations.get([
c.exchangeBaseUrl,
c.denomPubHash,
]);
checkBackupInvariant(!!d);
if (oldCoin.refresh_session) {