diff options
Diffstat (limited to 'packages/taler-util/src/wallet-types.ts')
-rw-r--r-- | packages/taler-util/src/wallet-types.ts | 441 |
1 files changed, 260 insertions, 181 deletions
diff --git a/packages/taler-util/src/wallet-types.ts b/packages/taler-util/src/wallet-types.ts index 7b6da8a40..66b1e9769 100644 --- a/packages/taler-util/src/wallet-types.ts +++ b/packages/taler-util/src/wallet-types.ts @@ -48,11 +48,13 @@ import { } from "./codec.js"; import { CurrencySpecification, + TalerMerchantApi, TemplateParams, WithdrawalOperationStatus, + canonicalizeBaseUrl, } from "./index.js"; import { VersionMatchResult } from "./libtool-version.js"; -import { PaytoUri } from "./payto.js"; +import { PaytoString, PaytoUri, codecForPaytoString } from "./payto.js"; import { AgeCommitmentProof } from "./taler-crypto.js"; import { TalerErrorCode } from "./taler-error-codes.js"; import { @@ -62,6 +64,7 @@ import { CoinEnvelope, DenomKeyType, DenominationPubKey, + EddsaPrivateKeyString, ExchangeAuditor, ExchangeWireAccount, InternationalizedString, @@ -148,6 +151,27 @@ function codecForTombstoneIdStr(): Codec<TombstoneIdStr> { }; } +export function codecForCanonBaseUrl(): Codec<string> { + return { + decode(x: any, c?: Context): string { + if (typeof x === "string") { + const canon = canonicalizeBaseUrl(x); + if (x !== canon) { + throw new DecodingError( + `expected canonicalized base URL at ${renderContext( + c, + )} but got value '${x}'`, + ); + } + return x; + } + throw new DecodingError( + `expected base URL at ${renderContext(c)} but got type ${typeof x}`, + ); + }, + }; +} + /** * Response for the create reserve request to the wallet. */ @@ -205,11 +229,13 @@ interface GetPlanForWalletInitiatedOperation { export interface ConvertAmountRequest { amount: AmountString; type: TransactionAmountMode; + depositPaytoUri: PaytoString; } export const codecForConvertAmountRequest = buildCodecForObject<ConvertAmountRequest>() .property("amount", codecForAmountString()) + .property("depositPaytoUri", codecForPaytoString()) .property( "type", codecForEither( @@ -293,15 +319,10 @@ interface GetPlanForPaymentRequest extends GetPlanToCompleteOperation { maxDepositFee: AmountString; } -// interface GetPlanForTipRequest extends GetPlanForOperationBase { -// type: TransactionType.Tip; -// } -// interface GetPlanForRefundRequest extends GetPlanForOperationBase { -// type: TransactionType.Refund; -// } interface GetPlanForPullDebitRequest extends GetPlanToCompleteOperation { type: TransactionType.PeerPullDebit; } + interface GetPlanForPushCreditRequest extends GetPlanToCompleteOperation { type: TransactionType.PeerPushCredit; } @@ -462,13 +483,14 @@ export interface GetCurrencySpecificationResponse { export interface BuiltinExchange { exchangeBaseUrl: string; - currencyHint?: string; + currencyHint: string; } export interface PartialWalletRunConfig { builtin?: Partial<WalletRunConfig["builtin"]>; testing?: Partial<WalletRunConfig["testing"]>; features?: Partial<WalletRunConfig["features"]>; + lazyTaskLoop?: Partial<WalletRunConfig["lazyTaskLoop"]>; } export interface WalletRunConfig { @@ -503,6 +525,16 @@ export interface WalletRunConfig { features: { allowHttp: boolean; }; + + /** + * Start processing tasks only when explicitly required, even after + * init has been called. + * + * Useful when the wallet is started to make single read-only request, + * as otherwise wallet-core starts making network request and process + * unrelated pending tasks. + */ + lazyTaskLoop: boolean; } export interface InitRequest { @@ -579,6 +611,11 @@ export enum CoinStatus { Fresh = "fresh", /** + * Coin was lost as the denomination is not usable anymore. + */ + DenomLoss = "denom-loss", + + /** * Fresh, but currently marked as "suspended", thus won't be used * for spending. Used for testing. */ @@ -739,71 +776,6 @@ export interface PrepareRefundResult { info: OrderShortInfo; } -export interface PrepareTipResult { - /** - * Unique ID for the tip assigned by the wallet. - * Typically different from the merchant-generated tip ID. - * - * @deprecated use transactionId instead - */ - walletRewardId: string; - - /** - * Tip transaction ID. - */ - transactionId: TransactionIdStr; - - /** - * Has the tip already been accepted? - */ - accepted: boolean; - - /** - * Amount that the merchant gave. - */ - rewardAmountRaw: AmountString; - - /** - * Amount that arrived at the wallet. - * Might be lower than the raw amount due to fees. - */ - rewardAmountEffective: AmountString; - - /** - * Base URL of the merchant backend giving then tip. - */ - merchantBaseUrl: string; - - /** - * Base URL of the exchange that is used to withdraw the tip. - * Determined by the merchant, the wallet/user has no choice here. - */ - exchangeBaseUrl: string; - - /** - * Time when the tip will expire. After it expired, it can't be picked - * up anymore. - */ - expirationTimestamp: TalerProtocolTimestamp; -} - -export interface AcceptTipResponse { - transactionId: TransactionIdStr; - next_url?: string; -} - -export const codecForPrepareTipResult = (): Codec<PrepareTipResult> => - buildCodecForObject<PrepareTipResult>() - .property("accepted", codecForBoolean()) - .property("rewardAmountRaw", codecForAmountString()) - .property("rewardAmountEffective", codecForAmountString()) - .property("exchangeBaseUrl", codecForString()) - .property("merchantBaseUrl", codecForString()) - .property("expirationTimestamp", codecForTimestamp) - .property("walletRewardId", codecForString()) - .property("transactionId", codecForTransactionIdStr()) - .build("PrepareRewardResult"); - export interface BenchmarkResult { time: { [s: string]: number }; repetitions: number; @@ -1014,7 +986,9 @@ export interface PreparePayResultAlreadyConfirmed { export interface BankWithdrawDetails { status: WithdrawalOperationStatus; - amount: AmountJson; + currency: string; + amount: AmountJson | undefined; + wireFee: AmountJson | undefined; senderWire?: string; suggestedExchange?: string; confirmTransferUrl?: string; @@ -1057,7 +1031,7 @@ export interface TalerErrorDetail { /** * Minimal information needed about a planchet for unblinding a signature. * - * Can be a withdrawal/tipping/refresh planchet. + * Can be a withdrawal/refresh planchet. */ export interface PlanchetUnblindInfo { denomPub: DenominationPubKey; @@ -1392,7 +1366,7 @@ export interface ShortExchangeListItem { export interface ExchangeListItem { exchangeBaseUrl: string; masterPub: string | undefined; - currency: string | undefined; + currency: string; paytoUris: string[]; tosStatus: ExchangeTosStatus; exchangeEntryStatus: ExchangeEntryStatus; @@ -1410,7 +1384,7 @@ export interface ExchangeListItem { */ noFees: boolean; - scopeInfo: ScopeInfo | undefined; + scopeInfo: ScopeInfo; lastUpdateTimestamp: TalerPreciseTimestamp | undefined; @@ -1464,7 +1438,7 @@ export const codecForFeesByOperations = (): Codec< export const codecForExchangeFullDetails = (): Codec<ExchangeFullDetails> => buildCodecForObject<ExchangeFullDetails>() .property("currency", codecForString()) - .property("exchangeBaseUrl", codecForString()) + .property("exchangeBaseUrl", codecForCanonBaseUrl()) .property("paytoUris", codecForList(codecForString())) .property("auditors", codecForList(codecForExchangeAuditor())) .property("wireInfo", codecForWireInfo()) @@ -1478,8 +1452,8 @@ export const codecForExchangeFullDetails = (): Codec<ExchangeFullDetails> => export const codecForExchangeListItem = (): Codec<ExchangeListItem> => buildCodecForObject<ExchangeListItem>() - .property("currency", codecOptional(codecForString())) - .property("exchangeBaseUrl", codecForString()) + .property("currency", codecForString()) + .property("exchangeBaseUrl", codecForCanonBaseUrl()) .property("masterPub", codecOptional(codecForString())) .property("paytoUris", codecForList(codecForString())) .property("tosStatus", codecForAny()) @@ -1583,6 +1557,8 @@ export interface DenomSelectionState { totalCoinValue: AmountString; totalWithdrawCost: AmountString; selectedDenoms: DenomSelItem[]; + earliestDepositExpiration: TalerProtocolTimestamp; + hasDenomWithAgeRestriction: boolean; } /** @@ -1616,16 +1592,6 @@ export interface ExchangeWithdrawalDetails { 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. * @@ -1711,7 +1677,7 @@ export interface TestPayArgs { export const codecForTestPayArgs = (): Codec<TestPayArgs> => buildCodecForObject<TestPayArgs>() - .property("merchantBaseUrl", codecForString()) + .property("merchantBaseUrl", codecForCanonBaseUrl()) .property("merchantAuthToken", codecOptional(codecForString())) .property("amount", codecForAmountString()) .property("summary", codecForString()) @@ -1729,12 +1695,12 @@ export interface IntegrationTestArgs { export const codecForIntegrationTestArgs = (): Codec<IntegrationTestArgs> => buildCodecForObject<IntegrationTestArgs>() - .property("exchangeBaseUrl", codecForString()) - .property("merchantBaseUrl", codecForString()) + .property("exchangeBaseUrl", codecForCanonBaseUrl()) + .property("merchantBaseUrl", codecForCanonBaseUrl()) .property("merchantAuthToken", codecOptional(codecForString())) .property("amountToSpend", codecForAmountString()) .property("amountToWithdraw", codecForAmountString()) - .property("corebankApiBaseUrl", codecForString()) + .property("corebankApiBaseUrl", codecForCanonBaseUrl()) .build("IntegrationTestArgs"); export interface IntegrationTestV2Args { @@ -1746,10 +1712,10 @@ export interface IntegrationTestV2Args { export const codecForIntegrationTestV2Args = (): Codec<IntegrationTestV2Args> => buildCodecForObject<IntegrationTestV2Args>() - .property("exchangeBaseUrl", codecForString()) - .property("merchantBaseUrl", codecForString()) + .property("exchangeBaseUrl", codecForCanonBaseUrl()) + .property("merchantBaseUrl", codecForCanonBaseUrl()) .property("merchantAuthToken", codecOptional(codecForString())) - .property("corebankApiBaseUrl", codecForString()) + .property("corebankApiBaseUrl", codecForCanonBaseUrl()) .build("IntegrationTestV2Args"); export interface GetExchangeEntryByUrlRequest { @@ -1759,7 +1725,7 @@ export interface GetExchangeEntryByUrlRequest { export const codecForGetExchangeEntryByUrlRequest = (): Codec<GetExchangeEntryByUrlRequest> => buildCodecForObject<GetExchangeEntryByUrlRequest>() - .property("exchangeBaseUrl", codecForString()) + .property("exchangeBaseUrl", codecForCanonBaseUrl()) .build("GetExchangeEntryByUrlRequest"); export type GetExchangeEntryByUrlResponse = ExchangeListItem; @@ -1771,15 +1737,12 @@ export interface AddExchangeRequest { * @deprecated use a separate API call to start a forced exchange update instead */ forceUpdate?: boolean; - - masterPub?: string; } export const codecForAddExchangeRequest = (): Codec<AddExchangeRequest> => buildCodecForObject<AddExchangeRequest>() - .property("exchangeBaseUrl", codecForString()) + .property("exchangeBaseUrl", codecForCanonBaseUrl()) .property("forceUpdate", codecOptional(codecForBoolean())) - .property("masterPub", codecOptional(codecForString())) .build("AddExchangeRequest"); export interface UpdateExchangeEntryRequest { @@ -1790,7 +1753,7 @@ export interface UpdateExchangeEntryRequest { export const codecForUpdateExchangeEntryRequest = (): Codec<UpdateExchangeEntryRequest> => buildCodecForObject<UpdateExchangeEntryRequest>() - .property("exchangeBaseUrl", codecForString()) + .property("exchangeBaseUrl", codecForCanonBaseUrl()) .property("force", codecOptional(codecForBoolean())) .build("UpdateExchangeEntryRequest"); @@ -1801,7 +1764,7 @@ export interface GetExchangeResourcesRequest { export const codecForGetExchangeResourcesRequest = (): Codec<GetExchangeResourcesRequest> => buildCodecForObject<GetExchangeResourcesRequest>() - .property("exchangeBaseUrl", codecForString()) + .property("exchangeBaseUrl", codecForCanonBaseUrl()) .build("GetExchangeResourcesRequest"); export interface GetExchangeResourcesResponse { @@ -1815,7 +1778,7 @@ export interface DeleteExchangeRequest { export const codecForDeleteExchangeRequest = (): Codec<DeleteExchangeRequest> => buildCodecForObject<DeleteExchangeRequest>() - .property("exchangeBaseUrl", codecForString()) + .property("exchangeBaseUrl", codecForCanonBaseUrl()) .property("purge", codecOptional(codecForBoolean())) .build("DeleteExchangeRequest"); @@ -1826,7 +1789,7 @@ export interface ForceExchangeUpdateRequest { export const codecForForceExchangeUpdateRequest = (): Codec<AddExchangeRequest> => buildCodecForObject<AddExchangeRequest>() - .property("exchangeBaseUrl", codecForString()) + .property("exchangeBaseUrl", codecForCanonBaseUrl()) .build("AddExchangeRequest"); export interface GetExchangeTosRequest { @@ -1837,7 +1800,7 @@ export interface GetExchangeTosRequest { export const codecForGetExchangeTosRequest = (): Codec<GetExchangeTosRequest> => buildCodecForObject<GetExchangeTosRequest>() - .property("exchangeBaseUrl", codecForString()) + .property("exchangeBaseUrl", codecForCanonBaseUrl()) .property("acceptedFormat", codecOptional(codecForList(codecForString()))) .property("acceptLanguage", codecOptional(codecForString())) .build("GetExchangeTosRequest"); @@ -1846,44 +1809,109 @@ export interface AcceptManualWithdrawalRequest { exchangeBaseUrl: string; amount: AmountString; restrictAge?: number; + + /** + * Instead of generating a fresh, random reserve key pair, + * use the provided reserve private key. + * + * Use with caution. Usage of this field may be restricted + * to developer mode. + */ + forceReservePriv?: EddsaPrivateKeyString; } export const codecForAcceptManualWithdrawalRequest = (): Codec<AcceptManualWithdrawalRequest> => buildCodecForObject<AcceptManualWithdrawalRequest>() - .property("exchangeBaseUrl", codecForString()) + .property("exchangeBaseUrl", codecForCanonBaseUrl()) .property("amount", codecForAmountString()) .property("restrictAge", codecOptional(codecForNumber())) + .property("forceReservePriv", codecOptional(codecForString())) .build("AcceptManualWithdrawalRequest"); export interface GetWithdrawalDetailsForAmountRequest { exchangeBaseUrl: string; amount: AmountString; restrictAge?: number; + + /** + * ID provided by the client to cancel the request. + * + * If the same request is made again with the same clientCancellationId, + * all previous requests are cancelled. + * + * The cancelled request will receive an error response with + * an error code that indicates the cancellation. + * + * The cancellation is best-effort, responses might still arrive. + */ + clientCancellationId?: string; +} + +export interface PrepareBankIntegratedWithdrawalRequest { + talerWithdrawUri: string; } +export const codecForPrepareBankIntegratedWithdrawalRequest = + (): Codec<PrepareBankIntegratedWithdrawalRequest> => + buildCodecForObject<PrepareBankIntegratedWithdrawalRequest>() + .property("talerWithdrawUri", codecForString()) + .build("PrepareBankIntegratedWithdrawalRequest"); + +export interface PrepareBankIntegratedWithdrawalResponse { + transactionId: TransactionIdStr; + info: WithdrawUriInfoResponse; +} + +export interface ConfirmWithdrawalRequest { + transactionId: string; + exchangeBaseUrl: string; + amount: AmountString; + forcedDenomSel?: ForcedDenomSel; + restrictAge?: number; +} + +export const codecForConfirmWithdrawalRequestRequest = + (): Codec<ConfirmWithdrawalRequest> => + buildCodecForObject<ConfirmWithdrawalRequest>() + .property("transactionId", codecForString()) + .property("amount", codecForAmountString()) + .property("exchangeBaseUrl", codecForCanonBaseUrl()) + .property("forcedDenomSel", codecForAny()) + .property("restrictAge", codecOptional(codecForNumber())) + .build("ConfirmWithdrawalRequest"); + export interface AcceptBankIntegratedWithdrawalRequest { talerWithdrawUri: string; exchangeBaseUrl: string; forcedDenomSel?: ForcedDenomSel; + /** + * Amount to withdraw. + * If the bank's withdrawal operation uses a fixed amount, + * this field must either be left undefined or its value must match + * the amount from the withdrawal operation. + */ + amount?: AmountString; restrictAge?: number; } export const codecForAcceptBankIntegratedWithdrawalRequest = (): Codec<AcceptBankIntegratedWithdrawalRequest> => buildCodecForObject<AcceptBankIntegratedWithdrawalRequest>() - .property("exchangeBaseUrl", codecForString()) + .property("exchangeBaseUrl", codecForCanonBaseUrl()) .property("talerWithdrawUri", codecForString()) .property("forcedDenomSel", codecForAny()) + .property("amount", codecOptional(codecForAmountString())) .property("restrictAge", codecOptional(codecForNumber())) .build("AcceptBankIntegratedWithdrawalRequest"); export const codecForGetWithdrawalDetailsForAmountRequest = (): Codec<GetWithdrawalDetailsForAmountRequest> => buildCodecForObject<GetWithdrawalDetailsForAmountRequest>() - .property("exchangeBaseUrl", codecForString()) + .property("exchangeBaseUrl", codecForCanonBaseUrl()) .property("amount", codecForAmountString()) .property("restrictAge", codecOptional(codecForNumber())) + .property("clientCancellationId", codecOptional(codecForString())) .build("GetWithdrawalDetailsForAmountRequest"); export interface AcceptExchangeTosRequest { @@ -1893,7 +1921,7 @@ export interface AcceptExchangeTosRequest { export const codecForAcceptExchangeTosRequest = (): Codec<AcceptExchangeTosRequest> => buildCodecForObject<AcceptExchangeTosRequest>() - .property("exchangeBaseUrl", codecForString()) + .property("exchangeBaseUrl", codecForCanonBaseUrl()) .build("AcceptExchangeTosRequest"); export interface ForgetExchangeTosRequest { @@ -1903,7 +1931,7 @@ export interface ForgetExchangeTosRequest { export const codecForForgetExchangeTosRequest = (): Codec<ForgetExchangeTosRequest> => buildCodecForObject<ForgetExchangeTosRequest>() - .property("exchangeBaseUrl", codecForString()) + .property("exchangeBaseUrl", codecForCanonBaseUrl()) .build("ForgetExchangeTosRequest"); export interface AcceptRefundRequest { @@ -1927,8 +1955,10 @@ export const codecForApplyRefundFromPurchaseIdRequest = export interface GetWithdrawalDetailsForUriRequest { talerWithdrawUri: string; + /** + * @deprecated not used + */ restrictAge?: number; - notifyChangeFromPendingTimeoutMs?: number; } export const codecForGetWithdrawalDetailsForUri = @@ -1936,10 +1966,6 @@ export const codecForGetWithdrawalDetailsForUri = buildCodecForObject<GetWithdrawalDetailsForUriRequest>() .property("talerWithdrawUri", codecForString()) .property("restrictAge", codecOptional(codecForNumber())) - .property( - "notifyChangeFromPendingTimeoutMs", - codecOptional(codecForNumber()), - ) .build("GetWithdrawalDetailsForUriRequest"); export interface ListKnownBankAccountsRequest { @@ -1985,13 +2011,16 @@ export const codecForAbortProposalRequest = (): Codec<AbortProposalRequest> => .build("AbortProposalRequest"); export interface GetContractTermsDetailsRequest { - proposalId: string; + // @deprecated use transaction id + proposalId?: string; + transactionId?: string; } export const codecForGetContractTermsDetails = (): Codec<GetContractTermsDetailsRequest> => buildCodecForObject<GetContractTermsDetailsRequest>() - .property("proposalId", codecForString()) + .property("proposalId", codecOptional(codecForString())) + .property("transactionId", codecOptional(codecForString())) .build("GetContractTermsDetails"); export interface PreparePayRequest { @@ -2009,7 +2038,7 @@ export interface SharePaymentRequest { } export const codecForSharePaymentRequest = (): Codec<SharePaymentRequest> => buildCodecForObject<SharePaymentRequest>() - .property("merchantBaseUrl", codecForString()) + .property("merchantBaseUrl", codecForCanonBaseUrl()) .property("orderId", codecForString()) .build("SharePaymentRequest"); @@ -2021,6 +2050,21 @@ export const codecForSharePaymentResult = (): Codec<SharePaymentResult> => .property("privatePayUri", codecForString()) .build("SharePaymentResult"); +export interface CheckPayTemplateRequest { + talerPayTemplateUri: string; +} + +export type CheckPayTemplateReponse = { + templateDetails: TalerMerchantApi.WalletTemplateDetails; + supportedCurrencies: string[]; +}; + +export const codecForCheckPayTemplateRequest = + (): Codec<CheckPayTemplateRequest> => + buildCodecForObject<CheckPayTemplateRequest>() + .property("talerPayTemplateUri", codecForString()) + .build("CheckPayTemplateRequest"); + export interface PreparePayTemplateRequest { talerPayTemplateUri: string; templateParams?: TemplateParams; @@ -2158,9 +2202,9 @@ export const codecForWithdrawTestBalance = (): Codec<WithdrawTestBalanceRequest> => buildCodecForObject<WithdrawTestBalanceRequest>() .property("amount", codecForAmountString()) - .property("exchangeBaseUrl", codecForString()) + .property("exchangeBaseUrl", codecForCanonBaseUrl()) .property("forcedDenomSel", codecForAny()) - .property("corebankApiBaseUrl", codecForString()) + .property("corebankApiBaseUrl", codecForCanonBaseUrl()) .build("WithdrawTestBalanceRequest"); export interface SetCoinSuspendedRequest { @@ -2175,13 +2219,24 @@ export const codecForSetCoinSuspendedRequest = .property("suspended", codecForBoolean()) .build("SetCoinSuspendedRequest"); +export interface RefreshCoinSpec { + coinPub: string; + amount?: AmountString; +} + +export const codecForRefreshCoinSpec = (): Codec<RefreshCoinSpec> => + buildCodecForObject<RefreshCoinSpec>() + .property("amount", codecForAmountString()) + .property("coinPub", codecForString()) + .build("ForceRefreshRequest"); + export interface ForceRefreshRequest { - coinPubList: string[]; + refreshCoinSpecs: RefreshCoinSpec[]; } export const codecForForceRefreshRequest = (): Codec<ForceRefreshRequest> => buildCodecForObject<ForceRefreshRequest>() - .property("coinPubList", codecForList(codecForString())) + .property("refreshCoinSpecs", codecForList(codecForRefreshCoinSpec())) .build("ForceRefreshRequest"); export interface PrepareRefundRequest { @@ -2210,32 +2265,6 @@ export const codecForStartRefundQueryRequest = .property("transactionId", codecForTransactionIdStr()) .build("StartRefundQueryRequest"); -export interface PrepareRewardRequest { - talerRewardUri: string; -} - -export const codecForPrepareRewardRequest = (): Codec<PrepareRewardRequest> => - buildCodecForObject<PrepareRewardRequest>() - .property("talerRewardUri", codecForString()) - .build("PrepareRewardRequest"); - -export interface AcceptRewardRequest { - /** - * @deprecated use transactionId - */ - walletRewardId?: string; - /** - * it will be required when "walletRewardId" is removed - */ - transactionId?: TransactionIdStr; -} - -export const codecForAcceptTipRequest = (): Codec<AcceptRewardRequest> => - buildCodecForObject<AcceptRewardRequest>() - .property("walletRewardId", codecOptional(codecForString())) - .property("transactionId", codecOptional(codecForTransactionIdStr())) - .build("AcceptRewardRequest"); - export interface FailTransactionRequest { transactionId: TransactionIdStr; } @@ -2333,7 +2362,8 @@ export interface WithdrawUriInfoResponse { operationId: string; status: WithdrawalOperationStatus; confirmTransferUrl?: string; - amount: AmountString; + currency: string; + amount: AmountString | undefined; defaultExchangeBaseUrl?: string; possibleExchanges: ExchangeListItem[]; } @@ -2352,8 +2382,9 @@ export const codecForWithdrawUriInfoResponse = codecForConstString("confirmed"), ), ) - .property("amount", codecForAmountString()) - .property("defaultExchangeBaseUrl", codecOptional(codecForString())) + .property("amount", codecOptional(codecForAmountString())) + .property("currency", codecForString()) + .property("defaultExchangeBaseUrl", codecOptional(codecForCanonBaseUrl())) .property("possibleExchanges", codecForList(codecForExchangeListItem())) .build("WithdrawUriInfoResponse"); @@ -2596,30 +2627,30 @@ export const codecForWithdrawFakebankRequest = .build("WithdrawFakebankRequest"); export interface ActiveTask { - id: string; + taskId: string; transaction: TransactionIdStr | undefined; firstTry: AbsoluteTime | undefined; nextTry: AbsoluteTime | undefined; - counter: number | undefined; + retryCounter: number | undefined; lastError: TalerErrorDetail | undefined; } -export interface GetActiveTasks { +export interface GetActiveTasksResponse { tasks: ActiveTask[]; } export const codecForActiveTask = (): Codec<ActiveTask> => buildCodecForObject<ActiveTask>() - .property("id", codecForString()) + .property("taskId", codecForString()) .property("transaction", codecOptional(codecForTransactionIdStr())) - .property("counter", codecForNumber()) - .property("firstTry", codecForAbsoluteTime) - .property("nextTry", codecForAbsoluteTime) - .property("lastError", codecForTalerErrorDetail()) + .property("retryCounter", codecOptional(codecForNumber())) + .property("firstTry", codecOptional(codecForAbsoluteTime)) + .property("nextTry", codecOptional(codecForAbsoluteTime)) + .property("lastError", codecOptional(codecForTalerErrorDetail())) .build("ActiveTask"); -export const codecForGetActiveTasks = (): Codec<GetActiveTasks> => - buildCodecForObject<GetActiveTasks>() +export const codecForGetActiveTasks = (): Codec<GetActiveTasksResponse> => + buildCodecForObject<GetActiveTasksResponse>() .property("tasks", codecForList(codecForActiveTask())) .build("GetActiveTasks"); @@ -2657,8 +2688,16 @@ export interface TestPayResult { } export interface SelectedCoin { + denomPubHash: string; coinPub: string; contribution: AmountString; + exchangeBaseUrl: string; +} + +export interface SelectedProspectiveCoin { + denomPubHash: string; + contribution: AmountString; + exchangeBaseUrl: string; } /** @@ -2679,6 +2718,20 @@ export interface PayCoinSelection { customerDepositFees: AmountString; } +export interface ProspectivePayCoinSelection { + prospectiveCoins: SelectedProspectiveCoin[]; + + /** + * How much of the wire fees is the customer paying? + */ + customerWireFees: AmountString; + + /** + * How much of the deposit fees is the customer paying? + */ + customerDepositFees: AmountString; +} + export interface CheckPeerPushDebitRequest { /** * Preferred exchange to use for the p2p payment. @@ -2696,7 +2749,7 @@ export interface CheckPeerPushDebitRequest { export const codecForCheckPeerPushDebitRequest = (): Codec<CheckPeerPushDebitRequest> => buildCodecForObject<CheckPeerPushDebitRequest>() - .property("exchangeBaseUrl", codecOptional(codecForString())) + .property("exchangeBaseUrl", codecOptional(codecForCanonBaseUrl())) .property("amount", codecForAmountString()) .build("CheckPeerPushDebitRequest"); @@ -2835,7 +2888,7 @@ export const codecForPreparePeerPullPaymentRequest = (): Codec<CheckPeerPullCreditRequest> => buildCodecForObject<CheckPeerPullCreditRequest>() .property("amount", codecForAmountString()) - .property("exchangeBaseUrl", codecOptional(codecForString())) + .property("exchangeBaseUrl", codecOptional(codecForCanonBaseUrl())) .build("CheckPeerPullCreditRequest"); export interface CheckPeerPullCreditResponse { @@ -2858,7 +2911,7 @@ export const codecForInitiatePeerPullPaymentRequest = (): Codec<InitiatePeerPullCreditRequest> => buildCodecForObject<InitiatePeerPullCreditRequest>() .property("partialContractTerms", codecForPeerContractTerms()) - .property("exchangeBaseUrl", codecOptional(codecForString())) + .property("exchangeBaseUrl", codecOptional(codecForCanonBaseUrl())) .build("InitiatePeerPullCreditRequest"); export interface InitiatePeerPullCreditResponse { @@ -2873,6 +2926,20 @@ export interface InitiatePeerPullCreditResponse { transactionId: TransactionIdStr; } +export interface CanonicalizeBaseUrlRequest { + url: string; +} + +export const codecForCanonicalizeBaseUrlRequest = + (): Codec<CanonicalizeBaseUrlRequest> => + buildCodecForObject<CanonicalizeBaseUrlRequest>() + .property("url", codecForString()) + .build("CanonicalizeBaseUrlRequest"); + +export interface CanonicalizeBaseUrlResponse { + url: string; +} + export interface ValidateIbanRequest { iban: string; } @@ -2987,6 +3054,18 @@ export interface TestingWaitTransactionRequest { txState: TransactionState; } +export interface TestingGetReserveHistoryRequest { + reservePub: string; + exchangeBaseUrl: string; +} + +export const codecForTestingGetReserveHistoryRequest = + (): Codec<TestingGetReserveHistoryRequest> => + buildCodecForObject<TestingGetReserveHistoryRequest>() + .property("reservePub", codecForString()) + .property("exchangeBaseUrl", codecForString()) + .build("TestingGetReserveHistoryRequest"); + export interface TestingGetDenomStatsRequest { exchangeBaseUrl: string; } @@ -3000,7 +3079,7 @@ export interface TestingGetDenomStatsResponse { export const codecForTestingGetDenomStatsRequest = (): Codec<TestingGetDenomStatsRequest> => buildCodecForObject<TestingGetDenomStatsRequest>() - .property("exchangeBaseUrl", codecForString()) + .property("exchangeBaseUrl", codecForCanonBaseUrl()) .build("TestingGetDenomStatsRequest"); export interface WithdrawalExchangeAccountDetails { @@ -3120,7 +3199,7 @@ export const codecForAddGlobalCurrencyExchangeRequest = (): Codec<AddGlobalCurrencyExchangeRequest> => buildCodecForObject<AddGlobalCurrencyExchangeRequest>() .property("currency", codecForString()) - .property("exchangeBaseUrl", codecForString()) + .property("exchangeBaseUrl", codecForCanonBaseUrl()) .property("exchangeMasterPub", codecForString()) .build("AddGlobalCurrencyExchangeRequest"); @@ -3134,7 +3213,7 @@ export const codecForRemoveGlobalCurrencyExchangeRequest = (): Codec<RemoveGlobalCurrencyExchangeRequest> => buildCodecForObject<RemoveGlobalCurrencyExchangeRequest>() .property("currency", codecForString()) - .property("exchangeBaseUrl", codecForString()) + .property("exchangeBaseUrl", codecForCanonBaseUrl()) .property("exchangeMasterPub", codecForString()) .build("RemoveGlobalCurrencyExchangeRequest"); @@ -3148,7 +3227,7 @@ export const codecForAddGlobalCurrencyAuditorRequest = (): Codec<AddGlobalCurrencyAuditorRequest> => buildCodecForObject<AddGlobalCurrencyAuditorRequest>() .property("currency", codecForString()) - .property("auditorBaseUrl", codecForString()) + .property("auditorBaseUrl", codecForCanonBaseUrl()) .property("auditorPub", codecForString()) .build("AddGlobalCurrencyAuditorRequest"); @@ -3162,20 +3241,10 @@ export const codecForRemoveGlobalCurrencyAuditorRequest = (): Codec<RemoveGlobalCurrencyAuditorRequest> => buildCodecForObject<RemoveGlobalCurrencyAuditorRequest>() .property("currency", codecForString()) - .property("auditorBaseUrl", codecForString()) + .property("auditorBaseUrl", codecForCanonBaseUrl()) .property("auditorPub", codecForString()) .build("RemoveGlobalCurrencyAuditorRequest"); -export interface RetryLoopOpts { - /** - * Stop the retry loop when all lifeness-giving pending operations - * are done. - * - * Defaults to false. - */ - stopWhenDone?: boolean; -} - /** * Information about one provider. * @@ -3281,3 +3350,13 @@ export const codecForSyncTermsOfServiceResponse = .property("annual_fee", codecForAmountString()) .property("version", codecForString()) .build("SyncTermsOfServiceResponse"); + +export interface HintNetworkAvailabilityRequest { + isNetworkAvailable: boolean; +} + +export const codecForHintNetworkAvailabilityRequest = + (): Codec<HintNetworkAvailabilityRequest> => + buildCodecForObject<HintNetworkAvailabilityRequest>() + .property("isNetworkAvailable", codecForBoolean()) + .build("HintNetworkAvailabilityRequest"); |