From c09caa5fdca91fb6ded6b2ce8caf1620c0273b80 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Tue, 19 Mar 2024 23:02:24 -0300 Subject: wip, found #8653 --- packages/taler-util/src/MerchantApiClient.ts | 7 +- packages/taler-util/src/http-client/types.ts | 2 +- packages/taler-util/src/merchant-api-types.ts | 26 +------ packages/taler-util/src/taler-types.ts | 106 +------------------------- packages/taler-util/src/wallet-types.ts | 14 ++-- 5 files changed, 15 insertions(+), 140 deletions(-) (limited to 'packages/taler-util/src') diff --git a/packages/taler-util/src/MerchantApiClient.ts b/packages/taler-util/src/MerchantApiClient.ts index a71887940..65827849d 100644 --- a/packages/taler-util/src/MerchantApiClient.ts +++ b/packages/taler-util/src/MerchantApiClient.ts @@ -18,6 +18,7 @@ import { codecForAny } from "./codec.js"; import { TalerMerchantApi, codecForMerchantConfig, + codecForMerchantOrderPrivateStatusResponse, } from "./http-client/types.js"; import { HttpStatusCode } from "./http-status-codes.js"; import { @@ -30,12 +31,10 @@ import { LibtoolVersion } from "./libtool-version.js"; import { Logger } from "./logging.js"; import { MerchantInstancesResponse, - MerchantOrderPrivateStatusResponse, MerchantPostOrderRequest, MerchantPostOrderResponse, MerchantTemplateAddDetails, - codecForMerchantOrderPrivateStatusResponse, - codecForMerchantPostOrderResponse, + codecForMerchantPostOrderResponse } from "./merchant-api-types.js"; import { FailCasesByMethod, @@ -258,7 +257,7 @@ export class MerchantApiClient { async queryPrivateOrderStatus( query: PrivateOrderStatusQuery, - ): Promise { + ): Promise { const reqUrl = new URL(`private/orders/${query.orderId}`, this.baseUrl); if (query.sessionId) { reqUrl.searchParams.set("session_id", query.sessionId); diff --git a/packages/taler-util/src/http-client/types.ts b/packages/taler-util/src/http-client/types.ts index b53566304..67719ddd9 100644 --- a/packages/taler-util/src/http-client/types.ts +++ b/packages/taler-util/src/http-client/types.ts @@ -606,7 +606,7 @@ export const codecForExchange = (): Codec => .property("master_pub", codecForString()) .property("priority", codecForNumber()) .property("url", codecForString()) - .build("ExchangeHandle"); + .build("TalerMerchantApi.Exchange"); export const codecForContractTerms = (): Codec => buildCodecForObject() diff --git a/packages/taler-util/src/merchant-api-types.ts b/packages/taler-util/src/merchant-api-types.ts index 838bfa99d..6d5570b61 100644 --- a/packages/taler-util/src/merchant-api-types.ts +++ b/packages/taler-util/src/merchant-api-types.ts @@ -40,6 +40,8 @@ import { codecForAmountString, codecForAny, codecForBoolean, + codecForCheckPaymentClaimedResponse, + codecForCheckPaymentUnpaidResponse, codecForConstString, codecForExchangeWireAccount, codecForList, @@ -112,30 +114,6 @@ export const codecForMerchantCheckPaymentPaidResponse = .property("refund_details", codecForAny()) .build("CheckPaymentPaidResponse"); -export const codecForCheckPaymentUnpaidResponse = - (): Codec => - buildCodecForObject() - .property("order_status", codecForConstString("unpaid")) - .property("taler_pay_uri", codecForString()) - .property("order_status_url", codecForString()) - .property("already_paid_order_id", codecOptional(codecForString())) - .build("CheckPaymentPaidResponse"); - -export const codecForCheckPaymentClaimedResponse = - (): Codec => - buildCodecForObject() - .property("order_status", codecForConstString("claimed")) - .property("contract_terms", codecForMerchantContractTerms()) - .build("CheckPaymentClaimedResponse"); - -export const codecForMerchantOrderPrivateStatusResponse = - (): Codec => - buildCodecForUnion() - .discriminateOn("order_status") - .alternative("paid", codecForMerchantCheckPaymentPaidResponse()) - .alternative("unpaid", codecForCheckPaymentUnpaidResponse()) - .alternative("claimed", codecForCheckPaymentClaimedResponse()) - .build("MerchantOrderPrivateStatusResponse"); export type MerchantOrderPrivateStatusResponse = | MerchantCheckPaymentPaidResponse diff --git a/packages/taler-util/src/taler-types.ts b/packages/taler-util/src/taler-types.ts index e8a6fca7a..7a386b108 100644 --- a/packages/taler-util/src/taler-types.ts +++ b/packages/taler-util/src/taler-types.ts @@ -46,6 +46,7 @@ import { CurrencySpecification, codecForCurrencySpecificiation, codecForEither, + codecForProduct, } from "./index.js"; import { Edx25519PublicKeyEnc } from "./taler-crypto.js"; import { @@ -306,18 +307,6 @@ export interface ExchangeHandle { // The exchange's base URL. url: string; - // How much would the merchant like to use this exchange. - // The wallet should use a suitable exchange with high - // priority. The following priority values are used, but - // it should be noted that they are NOT in any way normative. - // - // 0: likely it will not work (recently seen with account - // restriction that would be bad for this merchant) - // 512: merchant does not know, might be down (merchant - // did not yet get /wire response). - // 1024: good choice (recently confirmed working) - priority: Integer; - // Master public key of the exchange. master_pub: EddsaPublicKeyString; } @@ -486,7 +475,7 @@ export interface MerchantContractTerms { // Total price for the transaction. // The exchange will subtract deposit fees from that amount // before transferring it to the merchant. - amount: AmountString; + amount: string; // Nonce generated by the wallet and echoed by the merchant // in this field when the proposal is generated. @@ -568,7 +557,7 @@ export interface MerchantContractTerms { // Maximum total deposit fee accepted by the merchant for this contract. // Overrides defaults of the merchant instance. - max_fee: AmountString; + max_fee: string; // Extra data that is only interpreted by the merchant frontend. // Useful when the merchant needs to store extra information on a @@ -1394,7 +1383,6 @@ export const codecForAuditor = (): Codec => export const codecForExchangeHandle = (): Codec => buildCodecForObject() .property("master_pub", codecForString()) - .property("priority", codecForNumber()) .property("url", codecForString()) .build("ExchangeHandle"); @@ -1426,27 +1414,10 @@ export const codecForMerchantInfo = (): Codec => .property("jurisdiction", codecOptional(codecForLocation())) .build("MerchantInfo"); -export const codecForTax = (): Codec => - buildCodecForObject() - .property("name", codecForString()) - .property("tax", codecForAmountString()) - .build("Tax"); export const codecForInternationalizedString = (): Codec => codecForMap(codecForString()); -export const codecForProduct = (): Codec => - buildCodecForObject() - .property("product_id", codecOptional(codecForString())) - .property("description", codecForString()) - .property( - "description_i18n", - codecOptional(codecForInternationalizedString()), - ) - .property("quantity", codecOptional(codecForNumber())) - .property("unit", codecOptional(codecForString())) - .property("price", codecOptional(codecForAmountString())) - .build("Tax"); export const codecForMerchantContractTerms = (): Codec => buildCodecForObject() @@ -1663,40 +1634,6 @@ export const codecForExchangeRevealResponse = .property("ev_sigs", codecForList(codecForExchangeRevealItem())) .build("ExchangeRevealResponse"); -export const codecForMerchantCoinRefundSuccessStatus = - (): Codec => - buildCodecForObject() - .property("type", codecForConstString("success")) - .property("coin_pub", codecForString()) - .property("exchange_status", codecForConstNumber(200)) - .property("exchange_sig", codecForString()) - .property("rtransaction_id", codecForNumber()) - .property("refund_amount", codecForAmountString()) - .property("exchange_pub", codecForString()) - .property("execution_time", codecForTimestamp) - .build("MerchantCoinRefundSuccessStatus"); - -export const codecForMerchantCoinRefundFailureStatus = - (): Codec => - buildCodecForObject() - .property("type", codecForConstString("failure")) - .property("coin_pub", codecForString()) - .property("exchange_status", codecForNumber()) - .property("rtransaction_id", codecForNumber()) - .property("refund_amount", codecForAmountString()) - .property("exchange_code", codecOptional(codecForNumber())) - .property("exchange_reply", codecOptional(codecForAny())) - .property("execution_time", codecForTimestamp) - .build("MerchantCoinRefundFailureStatus"); - -export const codecForMerchantCoinRefundStatus = - (): Codec => - buildCodecForUnion() - .discriminateOn("type") - .alternative("success", codecForMerchantCoinRefundSuccessStatus()) - .alternative("failure", codecForMerchantCoinRefundFailureStatus()) - .build("MerchantCoinRefundStatus"); - export const codecForMerchantOrderStatusPaid = (): Codec => buildCodecForObject() @@ -1706,13 +1643,6 @@ export const codecForMerchantOrderStatusPaid = .property("refunded", codecForBoolean()) .build("MerchantOrderStatusPaid"); -export const codecForMerchantOrderRefundPickupResponse = - (): Codec => - buildCodecForObject() - .property("merchant_pub", codecForString()) - .property("refund_amount", codecForAmountString()) - .property("refunds", codecForList(codecForMerchantCoinRefundStatus())) - .build("MerchantOrderRefundPickupResponse"); export const codecForMerchantOrderStatusUnpaid = (): Codec => @@ -1751,36 +1681,6 @@ export interface AbortResponse { refunds: MerchantAbortPayRefundStatus[]; } -export const codecForMerchantAbortPayRefundSuccessStatus = - (): Codec => - buildCodecForObject() - .property("exchange_pub", codecForString()) - .property("exchange_sig", codecForString()) - .property("exchange_status", codecForConstNumber(200)) - .property("type", codecForConstString("success")) - .build("MerchantAbortPayRefundSuccessStatus"); - -export const codecForMerchantAbortPayRefundFailureStatus = - (): Codec => - buildCodecForObject() - .property("exchange_code", codecForNumber()) - .property("exchange_reply", codecForAny()) - .property("exchange_status", codecForNumber()) - .property("type", codecForConstString("failure")) - .build("MerchantAbortPayRefundFailureStatus"); - -export const codecForMerchantAbortPayRefundStatus = - (): Codec => - buildCodecForUnion() - .discriminateOn("type") - .alternative("success", codecForMerchantAbortPayRefundSuccessStatus()) - .alternative("failure", codecForMerchantAbortPayRefundFailureStatus()) - .build("MerchantAbortPayRefundStatus"); - -export const codecForAbortResponse = (): Codec => - buildCodecForObject() - .property("refunds", codecForList(codecForMerchantAbortPayRefundStatus())) - .build("AbortResponse"); export type MerchantAbortPayRefundStatus = | MerchantAbortPayRefundSuccessStatus diff --git a/packages/taler-util/src/wallet-types.ts b/packages/taler-util/src/wallet-types.ts index 4ebaa3668..61b9e1b59 100644 --- a/packages/taler-util/src/wallet-types.ts +++ b/packages/taler-util/src/wallet-types.ts @@ -628,11 +628,11 @@ export interface CoinDumpJson { withdrawal_reserve_pub: string | undefined; coin_status: CoinStatus; spend_allocation: - | { - id: string; - amount: AmountString; - } - | undefined; + | { + id: string; + amount: AmountString; + } + | undefined; /** * Information about the age restriction */ @@ -831,7 +831,7 @@ export const codecForPreparePayResultPaymentPossible = ) .build("PreparePayResultPaymentPossible"); -export interface BalanceDetails {} +export interface BalanceDetails { } /** * Detailed reason for why the wallet's balance is insufficient. @@ -2947,7 +2947,6 @@ export interface WalletContractData { summary: string; summaryI18n: { [lang_tag: string]: string } | undefined; autoRefund: TalerProtocolDuration | undefined; - wireFeeAmortization: number; payDeadline: TalerProtocolTimestamp; refundDeadline: TalerProtocolTimestamp; allowedExchanges: AllowedExchangeInfo[]; @@ -2955,7 +2954,6 @@ export interface WalletContractData { wireMethod: string; wireInfoHash: string; maxDepositFee: AmountString; - minimumAge?: number; } export interface TestingWaitTransactionRequest { -- cgit v1.2.3