-include more info in refresh tx
This commit is contained in:
parent
bb8bf3cb55
commit
12fc0b3f2a
@ -865,6 +865,7 @@ export enum TransactionStatus {
|
|||||||
* Additional information about the reason of a refresh.
|
* Additional information about the reason of a refresh.
|
||||||
*/
|
*/
|
||||||
export interface RefreshReasonDetails {
|
export interface RefreshReasonDetails {
|
||||||
|
originatingTransactionId?: string;
|
||||||
proposalId?: string;
|
proposalId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,12 @@ import {
|
|||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
import { CryptoDispatcher } from "./crypto/workers/crypto-dispatcher.js";
|
import { CryptoDispatcher } from "./crypto/workers/crypto-dispatcher.js";
|
||||||
import { TalerCryptoInterface } from "./crypto/cryptoImplementation.js";
|
import { TalerCryptoInterface } from "./crypto/cryptoImplementation.js";
|
||||||
import { ExchangeDetailsRecord, ExchangeRecord, WalletStoresV1 } from "./db.js";
|
import {
|
||||||
|
ExchangeDetailsRecord,
|
||||||
|
ExchangeRecord,
|
||||||
|
RefreshReasonDetails,
|
||||||
|
WalletStoresV1,
|
||||||
|
} from "./db.js";
|
||||||
import { PendingOperationsResponse } from "./pending-types.js";
|
import { PendingOperationsResponse } from "./pending-types.js";
|
||||||
import { AsyncOpMemoMap, AsyncOpMemoSingle } from "./util/asyncMemo.js";
|
import { AsyncOpMemoMap, AsyncOpMemoSingle } from "./util/asyncMemo.js";
|
||||||
import { HttpRequestLibrary } from "./util/http.js";
|
import { HttpRequestLibrary } from "./util/http.js";
|
||||||
@ -89,6 +94,7 @@ export interface RefreshOperations {
|
|||||||
currency: string,
|
currency: string,
|
||||||
oldCoinPubs: CoinRefreshRequest[],
|
oldCoinPubs: CoinRefreshRequest[],
|
||||||
reason: RefreshReason,
|
reason: RefreshReason,
|
||||||
|
reasonDetails?: RefreshReasonDetails,
|
||||||
): Promise<RefreshGroupId>;
|
): Promise<RefreshGroupId>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,6 +188,9 @@ export async function spendCoins(
|
|||||||
Amounts.currencyOf(csi.contributions[0]),
|
Amounts.currencyOf(csi.contributions[0]),
|
||||||
refreshCoinPubs,
|
refreshCoinPubs,
|
||||||
RefreshReason.PayMerchant,
|
RefreshReason.PayMerchant,
|
||||||
|
{
|
||||||
|
originatingTransactionId: csi.allocationId,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,6 +60,7 @@ import {
|
|||||||
RefreshCoinStatus,
|
RefreshCoinStatus,
|
||||||
RefreshGroupRecord,
|
RefreshGroupRecord,
|
||||||
RefreshOperationStatus,
|
RefreshOperationStatus,
|
||||||
|
RefreshReasonDetails,
|
||||||
WalletStoresV1,
|
WalletStoresV1,
|
||||||
} from "../db.js";
|
} from "../db.js";
|
||||||
import { TalerError } from "../errors.js";
|
import { TalerError } from "../errors.js";
|
||||||
@ -853,6 +854,7 @@ export async function createRefreshGroup(
|
|||||||
currency: string,
|
currency: string,
|
||||||
oldCoinPubs: CoinRefreshRequest[],
|
oldCoinPubs: CoinRefreshRequest[],
|
||||||
reason: RefreshReason,
|
reason: RefreshReason,
|
||||||
|
reasonDetails?: RefreshReasonDetails,
|
||||||
): Promise<RefreshGroupId> {
|
): Promise<RefreshGroupId> {
|
||||||
const refreshGroupId = encodeCrock(getRandomBytes(32));
|
const refreshGroupId = encodeCrock(getRandomBytes(32));
|
||||||
|
|
||||||
@ -940,6 +942,7 @@ export async function createRefreshGroup(
|
|||||||
statusPerCoin: oldCoinPubs.map(() => RefreshCoinStatus.Pending),
|
statusPerCoin: oldCoinPubs.map(() => RefreshCoinStatus.Pending),
|
||||||
oldCoinPubs: oldCoinPubs.map((x) => x.coinPub),
|
oldCoinPubs: oldCoinPubs.map((x) => x.coinPub),
|
||||||
lastErrorPerCoin: {},
|
lastErrorPerCoin: {},
|
||||||
|
reasonDetails,
|
||||||
reason,
|
reason,
|
||||||
refreshGroupId,
|
refreshGroupId,
|
||||||
refreshSessionPerCoin: oldCoinPubs.map(() => undefined),
|
refreshSessionPerCoin: oldCoinPubs.map(() => undefined),
|
||||||
|
@ -600,7 +600,10 @@ function buildTransactionForRefresh(
|
|||||||
refreshGroupRecord.currency,
|
refreshGroupRecord.currency,
|
||||||
refreshGroupRecord.inputPerCoin,
|
refreshGroupRecord.inputPerCoin,
|
||||||
).amount;
|
).amount;
|
||||||
const outputAmount = Amounts.sumOrZero(refreshGroupRecord.currency, refreshGroupRecord.estimatedOutputPerCoin).amount;
|
const outputAmount = Amounts.sumOrZero(
|
||||||
|
refreshGroupRecord.currency,
|
||||||
|
refreshGroupRecord.estimatedOutputPerCoin,
|
||||||
|
).amount;
|
||||||
return {
|
return {
|
||||||
type: TransactionType.Refresh,
|
type: TransactionType.Refresh,
|
||||||
refreshReason: refreshGroupRecord.reason,
|
refreshReason: refreshGroupRecord.reason,
|
||||||
@ -612,6 +615,8 @@ function buildTransactionForRefresh(
|
|||||||
),
|
),
|
||||||
refreshInputAmount: Amounts.stringify(inputAmount),
|
refreshInputAmount: Amounts.stringify(inputAmount),
|
||||||
refreshOutputAmount: Amounts.stringify(outputAmount),
|
refreshOutputAmount: Amounts.stringify(outputAmount),
|
||||||
|
originatingTransactionId:
|
||||||
|
refreshGroupRecord.reasonDetails?.originatingTransactionId,
|
||||||
extendedStatus:
|
extendedStatus:
|
||||||
refreshGroupRecord.operationStatus === RefreshOperationStatus.Finished ||
|
refreshGroupRecord.operationStatus === RefreshOperationStatus.Finished ||
|
||||||
refreshGroupRecord.operationStatus ===
|
refreshGroupRecord.operationStatus ===
|
||||||
|
Loading…
Reference in New Issue
Block a user