-wallet-core: merge DenominationInfo and DenomInfo
This commit is contained in:
parent
16e7814445
commit
183c836614
@ -682,21 +682,6 @@ const codecForWireInfo = (): Codec<WireInfo> =>
|
||||
.property("accounts", codecForList(codecForExchangeAccount()))
|
||||
.build("codecForWireInfo");
|
||||
|
||||
const codecForDenominationInfo = (): Codec<DenominationInfo> =>
|
||||
buildCodecForObject<DenominationInfo>()
|
||||
.property("denomPubHash", codecForString())
|
||||
.property("value", codecForAmountJson())
|
||||
.property("feeWithdraw", codecForAmountJson())
|
||||
.property("feeDeposit", codecForAmountJson())
|
||||
.property("feeRefresh", codecForAmountJson())
|
||||
.property("feeRefund", codecForAmountJson())
|
||||
.property("stampStart", codecForTimestamp)
|
||||
.property("stampExpireWithdraw", codecForTimestamp)
|
||||
.property("stampExpireLegal", codecForTimestamp)
|
||||
.property("stampExpireDeposit", codecForTimestamp)
|
||||
.property("exchangeBaseUrl", codecForString())
|
||||
.build("codecForDenominationInfo");
|
||||
|
||||
export interface DenominationInfo {
|
||||
/**
|
||||
* Value of one coin of the denomination.
|
||||
@ -709,6 +694,8 @@ export interface DenominationInfo {
|
||||
*/
|
||||
denomPubHash: string;
|
||||
|
||||
denomPub: DenominationPubKey;
|
||||
|
||||
/**
|
||||
* Fee for withdrawing.
|
||||
*/
|
||||
|
@ -44,10 +44,10 @@ import {
|
||||
PeerContractTerms,
|
||||
Location,
|
||||
WireInfo,
|
||||
DenominationInfo,
|
||||
} from "@gnu-taler/taler-util";
|
||||
import { RetryInfo, RetryTags } from "./util/retries.js";
|
||||
import { Event, IDBDatabase } from "@gnu-taler/idb-bridge";
|
||||
import { DenomInfo } from "./internal-wallet-state.js";
|
||||
|
||||
/**
|
||||
* Name of the Taler database. This is effectively the major
|
||||
@ -330,7 +330,7 @@ export namespace DenominationRecord {
|
||||
};
|
||||
}
|
||||
|
||||
export function toDenomInfo(d: DenominationRecord): DenomInfo {
|
||||
export function toDenomInfo(d: DenominationRecord): DenominationInfo {
|
||||
return {
|
||||
denomPub: d.denomPub,
|
||||
denomPubHash: d.denomPubHash,
|
||||
|
@ -125,14 +125,6 @@ export interface RecoupOperations {
|
||||
): Promise<void>;
|
||||
}
|
||||
|
||||
export type DenomInfo = DenominationInfo & {
|
||||
/**
|
||||
* The denomination public key.
|
||||
*/
|
||||
denomPub: DenominationPubKey;
|
||||
}
|
||||
|
||||
|
||||
export type NotificationListener = (n: WalletNotification) => void;
|
||||
|
||||
/**
|
||||
@ -184,7 +176,7 @@ export interface InternalWalletState {
|
||||
}>,
|
||||
exchangeBaseUrl: string,
|
||||
denomPubHash: string,
|
||||
): Promise<DenomInfo | undefined>;
|
||||
): Promise<DenominationInfo | undefined>;
|
||||
|
||||
db: DbAccess<typeof WalletStoresV1>;
|
||||
http: HttpRequestLibrary;
|
||||
|
@ -53,8 +53,6 @@ import {
|
||||
DenominationVerificationStatus,
|
||||
ExchangeDetailsRecord,
|
||||
ExchangeRecord,
|
||||
OperationAttemptResult,
|
||||
OperationAttemptResultType,
|
||||
WalletStoresV1,
|
||||
} from "../db.js";
|
||||
import { TalerError } from "../errors.js";
|
||||
@ -66,7 +64,7 @@ import {
|
||||
readSuccessResponseTextOrThrow,
|
||||
} from "../util/http.js";
|
||||
import { DbAccess, GetReadOnlyAccess } from "../util/query.js";
|
||||
import { RetryInfo, runOperationHandlerForResult } from "../util/retries.js";
|
||||
import { OperationAttemptResult, OperationAttemptResultType, RetryInfo, runOperationHandlerForResult } from "../util/retries.js";
|
||||
import { WALLET_EXCHANGE_PROTOCOL_VERSION } from "../versions.js";
|
||||
import { guardOperationException } from "./common.js";
|
||||
|
||||
|
@ -25,6 +25,7 @@ import {
|
||||
codecForExchangeRevealResponse,
|
||||
CoinPublicKey,
|
||||
CoinPublicKeyString,
|
||||
DenominationInfo,
|
||||
DenomKeyType,
|
||||
Duration,
|
||||
durationFromSpec,
|
||||
@ -42,7 +43,6 @@ import {
|
||||
NotificationType,
|
||||
RefreshGroupId,
|
||||
RefreshReason,
|
||||
TalerErrorDetail,
|
||||
TalerProtocolTimestamp,
|
||||
URL,
|
||||
} from "@gnu-taler/taler-util";
|
||||
@ -64,7 +64,6 @@ import {
|
||||
} from "../db.js";
|
||||
import { TalerError } from "../errors.js";
|
||||
import {
|
||||
DenomInfo,
|
||||
EXCHANGE_COINS_LOCK,
|
||||
InternalWalletState,
|
||||
} from "../internal-wallet-state.js";
|
||||
@ -74,9 +73,11 @@ import {
|
||||
} from "../util/http.js";
|
||||
import { checkDbInvariant } from "../util/invariants.js";
|
||||
import { GetReadWriteAccess } from "../util/query.js";
|
||||
import { OperationAttemptResult, OperationAttemptResultType, RetryInfo, runOperationHandlerForResult } from "../util/retries.js";
|
||||
import { makeCoinAvailable, Wallet } from "../wallet.js";
|
||||
import { guardOperationException } from "./common.js";
|
||||
import {
|
||||
OperationAttemptResult,
|
||||
OperationAttemptResultType,
|
||||
} from "../util/retries.js";
|
||||
import { makeCoinAvailable } from "../wallet.js";
|
||||
import { updateExchangeFromUrl } from "./exchanges.js";
|
||||
import {
|
||||
isWithdrawableDenom,
|
||||
@ -98,7 +99,7 @@ const logger = new Logger("refresh.ts");
|
||||
*/
|
||||
export function getTotalRefreshCost(
|
||||
denoms: DenominationRecord[],
|
||||
refreshedDenom: DenomInfo,
|
||||
refreshedDenom: DenominationInfo,
|
||||
amountLeft: AmountJson,
|
||||
): AmountJson {
|
||||
const withdrawAmount = Amounts.sub(
|
||||
|
@ -92,6 +92,7 @@ import {
|
||||
FeeDescription,
|
||||
TalerErrorDetail,
|
||||
codecForTransactionByIdRequest,
|
||||
DenominationInfo,
|
||||
} from "@gnu-taler/taler-util";
|
||||
import { TalerCryptoInterface } from "./crypto/cryptoImplementation.js";
|
||||
import {
|
||||
@ -115,7 +116,6 @@ import {
|
||||
} from "./errors.js";
|
||||
import { createDenominationTimeline } from "./index.browser.js";
|
||||
import {
|
||||
DenomInfo,
|
||||
ExchangeOperations,
|
||||
InternalWalletState,
|
||||
MerchantInfo,
|
||||
@ -746,7 +746,7 @@ async function getExchangeDetailedInfo(
|
||||
return;
|
||||
}
|
||||
|
||||
const denominations: DenomInfo[] = denominationRecords.map((x) =>
|
||||
const denominations: DenominationInfo[] = denominationRecords.map((x) =>
|
||||
DenominationRecord.toDenomInfo(x),
|
||||
);
|
||||
|
||||
@ -1572,7 +1572,7 @@ class InternalWalletStateImpl implements InternalWalletState {
|
||||
};
|
||||
|
||||
// FIXME: Use an LRU cache here.
|
||||
private denomCache: Record<string, DenomInfo> = {};
|
||||
private denomCache: Record<string, DenominationInfo> = {};
|
||||
|
||||
/**
|
||||
* Promises that are waiting for a particular resource.
|
||||
@ -1606,7 +1606,7 @@ class InternalWalletStateImpl implements InternalWalletState {
|
||||
}>,
|
||||
exchangeBaseUrl: string,
|
||||
denomPubHash: string,
|
||||
): Promise<DenomInfo | undefined> {
|
||||
): Promise<DenominationInfo | undefined> {
|
||||
const key = `${exchangeBaseUrl}:${denomPubHash}`;
|
||||
const cached = this.denomCache[key];
|
||||
if (cached) {
|
||||
|
Loading…
Reference in New Issue
Block a user