wallet-core: use more numeric fields
This commit is contained in:
parent
7d6bcd42ea
commit
a398959670
@ -65,6 +65,8 @@ import { Event, IDBDatabase } from "@gnu-taler/idb-bridge";
|
||||
* - Every record that has a corresponding transaction item must have
|
||||
* an index for a mandatory timestamp field.
|
||||
* - Optional fields should be avoided, use "T | undefined" instead.
|
||||
* - Do all records have some obvious, indexed field that can
|
||||
* be used for range queries?
|
||||
*
|
||||
* @author Florian Dold <dold@taler.net>
|
||||
*/
|
||||
@ -99,8 +101,8 @@ export const WALLET_DB_MINOR_VERSION = 1;
|
||||
export namespace OperationStatusRange {
|
||||
export const ACTIVE_START = 10;
|
||||
export const ACTIVE_END = 29;
|
||||
export const DORMANT_START = 40;
|
||||
export const DORMANT_END = 59;
|
||||
export const DORMANT_START = 50;
|
||||
export const DORMANT_END = 69;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -148,7 +150,7 @@ export interface ReserveBankInfo {
|
||||
* URL that the user can be redirected to, and allows
|
||||
* them to confirm (or abort) the bank-integrated withdrawal.
|
||||
*/
|
||||
confirmUrl?: string;
|
||||
confirmUrl: string | undefined;
|
||||
|
||||
/**
|
||||
* Exchange payto URI that the bank will use to fund the reserve.
|
||||
@ -162,14 +164,14 @@ export interface ReserveBankInfo {
|
||||
*
|
||||
* Set to undefined if that hasn't happened yet.
|
||||
*/
|
||||
timestampReserveInfoPosted?: TalerProtocolTimestamp;
|
||||
timestampReserveInfoPosted: TalerProtocolTimestamp | undefined;
|
||||
|
||||
/**
|
||||
* Time when the reserve was confirmed by the bank.
|
||||
*
|
||||
* Set to undefined if not confirmed yet.
|
||||
*/
|
||||
timestampBankConfirmed?: TalerProtocolTimestamp;
|
||||
timestampBankConfirmed: TalerProtocolTimestamp | undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -195,6 +197,8 @@ export interface AuditorTrustRecord {
|
||||
/**
|
||||
* UIDs for the operation of adding this auditor
|
||||
* as a trusted auditor.
|
||||
*
|
||||
* (Used for backup/sync merging and tombstones.)
|
||||
*/
|
||||
uids: string[];
|
||||
}
|
||||
@ -232,15 +236,17 @@ export enum DenominationVerificationStatus {
|
||||
/**
|
||||
* Verification was delayed.
|
||||
*/
|
||||
Unverified = "unverified",
|
||||
Unverified = OperationStatusRange.ACTIVE_START,
|
||||
|
||||
/**
|
||||
* Verified as valid.
|
||||
*/
|
||||
VerifiedGood = "verified-good",
|
||||
VerifiedGood = OperationStatusRange.DORMANT_START,
|
||||
|
||||
/**
|
||||
* Verified as invalid.
|
||||
*/
|
||||
VerifiedBad = "verified-bad",
|
||||
VerifiedBad = OperationStatusRange.DORMANT_START + 1,
|
||||
}
|
||||
|
||||
export interface DenomFees {
|
||||
@ -705,13 +711,16 @@ export interface CoinRecord {
|
||||
|
||||
/**
|
||||
* Information about what the coin has been allocated for.
|
||||
* Used to prevent allocation of the same coin for two different payments.
|
||||
*
|
||||
* Used for:
|
||||
* - Diagnostics
|
||||
* - Idempotency of applying a coin selection (e.g. after re-selection)
|
||||
*/
|
||||
allocation?: CoinAllocation;
|
||||
allocation: CoinAllocation | undefined;
|
||||
|
||||
maxAge: number;
|
||||
|
||||
ageCommitmentProof?: AgeCommitmentProof;
|
||||
ageCommitmentProof: AgeCommitmentProof | undefined;
|
||||
}
|
||||
|
||||
export interface CoinAllocation {
|
||||
@ -801,7 +810,7 @@ export interface ProposalRecord {
|
||||
/**
|
||||
* Session ID we got when downloading the contract.
|
||||
*/
|
||||
downloadSessionId?: string;
|
||||
downloadSessionId: string | undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -875,19 +884,19 @@ export interface TipRecord {
|
||||
}
|
||||
|
||||
export enum RefreshCoinStatus {
|
||||
Pending = "pending",
|
||||
Finished = "finished",
|
||||
Pending = OperationStatusRange.ACTIVE_START,
|
||||
Finished = OperationStatusRange.DORMANT_START,
|
||||
|
||||
/**
|
||||
* The refresh for this coin has been frozen, because of a permanent error.
|
||||
* More info in lastErrorPerCoin.
|
||||
*/
|
||||
Frozen = "frozen",
|
||||
Frozen = OperationStatusRange.DORMANT_START + 1,
|
||||
}
|
||||
|
||||
export enum OperationStatus {
|
||||
Finished = "finished",
|
||||
Pending = "pending",
|
||||
Finished = OperationStatusRange.DORMANT_START,
|
||||
Pending = OperationStatusRange.ACTIVE_START,
|
||||
}
|
||||
|
||||
export interface RefreshGroupRecord {
|
||||
|
@ -285,6 +285,10 @@ export async function importCoin(
|
||||
coinSource,
|
||||
// FIXME!
|
||||
maxAge: AgeRestriction.AGE_UNRESTRICTED,
|
||||
// FIXME!
|
||||
ageCommitmentProof: undefined,
|
||||
// FIXME!
|
||||
allocation: undefined,
|
||||
};
|
||||
if (coinRecord.status === CoinStatus.Fresh) {
|
||||
await makeCoinAvailable(ws, tx, coinRecord);
|
||||
@ -655,6 +659,8 @@ export async function importBackup(
|
||||
repurchaseProposalId: backupProposal.repurchase_proposal_id,
|
||||
download,
|
||||
proposalStatus,
|
||||
// FIXME!
|
||||
downloadSessionId: undefined,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -28,8 +28,6 @@ import {
|
||||
BackupProviderStateTag,
|
||||
RefreshCoinStatus,
|
||||
OperationStatus,
|
||||
WithdrawalGroupRecord,
|
||||
WithdrawalGroupStatus,
|
||||
OperationStatusRange,
|
||||
} from "../db.js";
|
||||
import {
|
||||
|
@ -682,6 +682,7 @@ async function refreshReveal(
|
||||
coinEvHash: pc.coinEvHash,
|
||||
maxAge: pc.maxAge,
|
||||
ageCommitmentProof: pc.ageCommitmentProof,
|
||||
allocation: undefined,
|
||||
};
|
||||
|
||||
coins.push(coin);
|
||||
|
@ -320,6 +320,7 @@ export async function processTip(
|
||||
coinEvHash: planchet.coinEvHash,
|
||||
maxAge: AgeRestriction.AGE_UNRESTRICTED,
|
||||
ageCommitmentProof: planchet.ageCommitmentProof,
|
||||
allocation: undefined,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -834,6 +834,7 @@ async function processPlanchetVerifyAndStoreCoin(
|
||||
},
|
||||
maxAge: planchet.maxAge,
|
||||
ageCommitmentProof: planchet.ageCommitmentProof,
|
||||
allocation: undefined,
|
||||
};
|
||||
|
||||
const planchetCoinPub = planchet.coinPub;
|
||||
@ -1832,6 +1833,8 @@ export async function acceptWithdrawalFromUri(
|
||||
exchangePaytoUri,
|
||||
talerWithdrawUri: req.talerWithdrawUri,
|
||||
confirmUrl: withdrawInfo.confirmTransferUrl,
|
||||
timestampBankConfirmed: undefined,
|
||||
timestampReserveInfoPosted: undefined,
|
||||
},
|
||||
},
|
||||
restrictAge: req.restrictAge,
|
||||
|
Loading…
Reference in New Issue
Block a user