-deletion
This commit is contained in:
parent
bd9904f6a0
commit
a6d78f12df
@ -338,6 +338,8 @@ export enum TombstoneTag {
|
|||||||
DeleteRefund = "delete-refund",
|
DeleteRefund = "delete-refund",
|
||||||
DeletePeerPullDebit = "delete-peer-pull-debit",
|
DeletePeerPullDebit = "delete-peer-pull-debit",
|
||||||
DeletePeerPushDebit = "delete-peer-push-debit",
|
DeletePeerPushDebit = "delete-peer-push-debit",
|
||||||
|
DeletePeerPullCredit = "delete-peer-pull-credit",
|
||||||
|
DeletePeerPushCredit = "delete-peer-push-credit",
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1413,11 +1413,70 @@ export async function deleteTransaction(
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const { type, args: rest } = parseId("txn", transactionId);
|
const { type, args: rest } = parseId("txn", transactionId);
|
||||||
|
|
||||||
if (
|
if (type === TransactionType.PeerPushCredit) {
|
||||||
type === TransactionType.Withdrawal ||
|
const peerPushPaymentIncomingId = rest[0];
|
||||||
type === TransactionType.PeerPullCredit ||
|
await ws.db
|
||||||
type === TransactionType.PeerPushCredit
|
.mktx((x) => [
|
||||||
) {
|
x.withdrawalGroups,
|
||||||
|
x.peerPushPaymentIncoming,
|
||||||
|
x.tombstones,
|
||||||
|
])
|
||||||
|
.runReadWrite(async (tx) => {
|
||||||
|
const pushInc = await tx.peerPushPaymentIncoming.get(
|
||||||
|
peerPushPaymentIncomingId,
|
||||||
|
);
|
||||||
|
if (!pushInc) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (pushInc.withdrawalGroupId) {
|
||||||
|
const withdrawalGroupId = pushInc.withdrawalGroupId;
|
||||||
|
const withdrawalGroupRecord = await tx.withdrawalGroups.get(
|
||||||
|
withdrawalGroupId,
|
||||||
|
);
|
||||||
|
if (withdrawalGroupRecord) {
|
||||||
|
await tx.withdrawalGroups.delete(withdrawalGroupId);
|
||||||
|
await tx.tombstones.put({
|
||||||
|
id: TombstoneTag.DeleteWithdrawalGroup + ":" + withdrawalGroupId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await tx.peerPushPaymentIncoming.delete(peerPushPaymentIncomingId);
|
||||||
|
await tx.tombstones.put({
|
||||||
|
id:
|
||||||
|
TombstoneTag.DeletePeerPushCredit + ":" + peerPushPaymentIncomingId,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else if (type === TransactionType.PeerPullCredit) {
|
||||||
|
const pursePub = rest[0];
|
||||||
|
await ws.db
|
||||||
|
.mktx((x) => [
|
||||||
|
x.withdrawalGroups,
|
||||||
|
x.peerPullPaymentInitiations,
|
||||||
|
x.tombstones,
|
||||||
|
])
|
||||||
|
.runReadWrite(async (tx) => {
|
||||||
|
const pullIni = await tx.peerPullPaymentInitiations.get(pursePub);
|
||||||
|
if (!pullIni) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (pullIni.withdrawalGroupId) {
|
||||||
|
const withdrawalGroupId = pullIni.withdrawalGroupId;
|
||||||
|
const withdrawalGroupRecord = await tx.withdrawalGroups.get(
|
||||||
|
withdrawalGroupId,
|
||||||
|
);
|
||||||
|
if (withdrawalGroupRecord) {
|
||||||
|
await tx.withdrawalGroups.delete(withdrawalGroupId);
|
||||||
|
await tx.tombstones.put({
|
||||||
|
id: TombstoneTag.DeleteWithdrawalGroup + ":" + withdrawalGroupId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await tx.peerPullPaymentInitiations.delete(pursePub);
|
||||||
|
await tx.tombstones.put({
|
||||||
|
id: TombstoneTag.DeletePeerPullCredit + ":" + pursePub,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else if (type === TransactionType.Withdrawal) {
|
||||||
const withdrawalGroupId = rest[0];
|
const withdrawalGroupId = rest[0];
|
||||||
await ws.db
|
await ws.db
|
||||||
.mktx((x) => [x.withdrawalGroups, x.tombstones])
|
.mktx((x) => [x.withdrawalGroups, x.tombstones])
|
||||||
|
Loading…
Reference in New Issue
Block a user