From 6acddd6d70abc568e4b3740f56662691278aa645 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Fri, 14 Oct 2022 18:40:04 +0200 Subject: wallet-core: get rid of duplicated withdrawal info API --- packages/taler-util/src/walletTypes.ts | 124 ++++++++++++++++++++++++++++----- 1 file changed, 106 insertions(+), 18 deletions(-) (limited to 'packages/taler-util') diff --git a/packages/taler-util/src/walletTypes.ts b/packages/taler-util/src/walletTypes.ts index d0765ae31..0891f5cf9 100644 --- a/packages/taler-util/src/walletTypes.ts +++ b/packages/taler-util/src/walletTypes.ts @@ -68,6 +68,7 @@ import { BackupRecovery } from "./backupTypes.js"; import { PaytoUri } from "./payto.js"; import { TalerErrorCode } from "./taler-error-codes.js"; import { AgeCommitmentProof } from "./talerCrypto.js"; +import { VersionMatchResult } from "./libtool-version.js"; /** * Response for the create reserve request to the wallet. @@ -692,6 +693,7 @@ export interface ExchangeGlobalFees { signature: string; } + const codecForExchangeAccount = (): Codec => buildCodecForObject() .property("payto_uri", codecForString()) @@ -929,6 +931,110 @@ export interface ManualWithdrawalDetails { * Ways to pay the exchange. */ paytoUris: string[]; + + /** + * If the exchange supports age-restricted coins it will return + * the array of ages. + */ + ageRestrictionOptions?: number[]; +} + +/** + * Selected denominations withn some extra info. + */ + export interface DenomSelectionState { + totalCoinValue: AmountJson; + totalWithdrawCost: AmountJson; + selectedDenoms: { + denomPubHash: string; + count: number; + }[]; +} + +/** + * Information about what will happen doing a withdrawal. + * + * Sent to the wallet frontend to be rendered and shown to the user. + */ + export interface ExchangeWithdrawalDetails { + exchangePaytoUris: string[]; + + /** + * Filtered wire info to send to the bank. + */ + exchangeWireAccounts: string[]; + + /** + * Selected denominations for withdraw. + */ + selectedDenoms: DenomSelectionState; + + /** + * Does the wallet know about an auditor for + * the exchange that the reserve. + */ + isAudited: boolean; + + /** + * Did the user already accept the current terms of service for the exchange? + */ + termsOfServiceAccepted: boolean; + + /** + * The exchange is trusted directly. + */ + isTrusted: boolean; + + /** + * The earliest deposit expiration of the selected coins. + */ + earliestDepositExpiration: TalerProtocolTimestamp; + + /** + * Number of currently offered denominations. + */ + numOfferedDenoms: number; + + /** + * Public keys of trusted auditors for the currency we're withdrawing. + */ + trustedAuditorPubs: string[]; + + /** + * Result of checking the wallet's version + * against the exchange's version. + * + * Older exchanges don't return version information. + */ + versionMatch: VersionMatchResult | undefined; + + /** + * Libtool-style version string for the exchange or "unknown" + * for older exchanges. + */ + exchangeVersion: string; + + /** + * Libtool-style version string for the wallet. + */ + walletVersion: string; + + /** + * Amount that will be subtracted from the reserve's balance. + */ + withdrawalAmountRaw: AmountString; + + /** + * Amount that will actually be added to the wallet's balance. + */ + withdrawalAmountEffective: AmountString; + + /** + * If the exchange supports age-restricted coins it will return + * the array of ages. + * + */ + ageRestrictionOptions?: number[]; } export interface GetExchangeTosResult { @@ -1142,24 +1248,6 @@ export const codecForForgetKnownBankAccounts = .property("payto", codecForString()) .build("ForgetKnownBankAccountsRequest"); -export interface GetExchangeWithdrawalInfo { - exchangeBaseUrl: string; - amount: AmountJson; - tosAcceptedFormat?: string[]; - ageRestricted?: number; -} - -export const codecForGetExchangeWithdrawalInfo = - (): Codec => - buildCodecForObject() - .property("exchangeBaseUrl", codecForString()) - .property("amount", codecForAmountJson()) - .property( - "tosAcceptedFormat", - codecOptional(codecForList(codecForString())), - ) - .build("GetExchangeWithdrawalInfo"); - export interface AbortProposalRequest { proposalId: string; } -- cgit v1.2.3