diff options
author | Florian Dold <florian@dold.me> | 2023-09-13 16:08:51 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-09-14 19:18:01 +0200 |
commit | f4587c44fd6a6d76384cd671550890255c3fe650 (patch) | |
tree | f3eab7032e7ec4a6e49ffdf85ea57e3874b84130 /packages/taler-wallet-core/src/operations/reward.ts | |
parent | 59ef010b0e1f1eaf938a20a46f52d7c94af7b10d (diff) | |
download | wallet-core-f4587c44fd6a6d76384cd671550890255c3fe650.tar.xz |
wallet-core: use typed microsecond timestamps in DB
Diffstat (limited to 'packages/taler-wallet-core/src/operations/reward.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/reward.ts | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/packages/taler-wallet-core/src/operations/reward.ts b/packages/taler-wallet-core/src/operations/reward.ts index 6ae021174..3681dc4f5 100644 --- a/packages/taler-wallet-core/src/operations/reward.ts +++ b/packages/taler-wallet-core/src/operations/reward.ts @@ -50,6 +50,8 @@ import { DenominationRecord, RewardRecord, RewardRecordStatus, + timestampPreciseFromDb, + timestampPreciseToDb, } from "../db.js"; import { makeErrorDetail } from "@gnu-taler/taler-util"; import { InternalWalletState } from "../internal-wallet-state.js"; @@ -203,7 +205,7 @@ export async function prepareTip( exchangeBaseUrl: tipPickupStatus.exchange_url, next_url: tipPickupStatus.next_url, merchantBaseUrl: res.merchantBaseUrl, - createdTimestamp: TalerPreciseTimestamp.now(), + createdTimestamp: timestampPreciseToDb(TalerPreciseTimestamp.now()), merchantRewardId: res.merchantRewardId, rewardAmountEffective: Amounts.stringify(selectedDenoms.totalCoinValue), denomsSel: selectedDenoms, @@ -411,7 +413,7 @@ export async function processTip( return; } const oldTxState = computeRewardTransactionStatus(tr); - tr.pickedUpTimestamp = TalerPreciseTimestamp.now(); + tr.pickedUpTimestamp = timestampPreciseToDb(TalerPreciseTimestamp.now()); tr.status = RewardRecordStatus.Done; await tx.rewards.put(tr); const newTxState = computeRewardTransactionStatus(tr); @@ -448,7 +450,9 @@ export async function acceptTip( return { tipRecord }; } const oldTxState = computeRewardTransactionStatus(tipRecord); - tipRecord.acceptedTimestamp = TalerPreciseTimestamp.now(); + tipRecord.acceptedTimestamp = timestampPreciseToDb( + TalerPreciseTimestamp.now(), + ); tipRecord.status = RewardRecordStatus.PendingPickup; await tx.rewards.put(tipRecord); const newTxState = computeRewardTransactionStatus(tipRecord); |