summaryrefslogtreecommitdiff
path: root/packages/taler-util/src
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2024-03-19 23:02:24 -0300
committerSebastian <sebasjm@gmail.com>2024-03-19 23:02:24 -0300
commitc09caa5fdca91fb6ded6b2ce8caf1620c0273b80 (patch)
tree70d73ec63630b13fe83e738d606e2f4eabf5d235 /packages/taler-util/src
parent630f53f8a5721b2f5f2d43772aa4de7146df58fc (diff)
downloadwallet-core-c09caa5fdca91fb6ded6b2ce8caf1620c0273b80.tar.gz
wallet-core-c09caa5fdca91fb6ded6b2ce8caf1620c0273b80.tar.bz2
wallet-core-c09caa5fdca91fb6ded6b2ce8caf1620c0273b80.zip
wip, found #8653
Diffstat (limited to 'packages/taler-util/src')
-rw-r--r--packages/taler-util/src/MerchantApiClient.ts7
-rw-r--r--packages/taler-util/src/http-client/types.ts2
-rw-r--r--packages/taler-util/src/merchant-api-types.ts26
-rw-r--r--packages/taler-util/src/taler-types.ts106
-rw-r--r--packages/taler-util/src/wallet-types.ts14
5 files changed, 15 insertions, 140 deletions
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<MerchantOrderPrivateStatusResponse> {
+ ): Promise<TalerMerchantApi.MerchantOrderStatusResponse> {
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<TalerMerchantApi.Exchange> =>
.property("master_pub", codecForString())
.property("priority", codecForNumber())
.property("url", codecForString())
- .build("ExchangeHandle");
+ .build("TalerMerchantApi.Exchange");
export const codecForContractTerms = (): Codec<TalerMerchantApi.ContractTerms> =>
buildCodecForObject<TalerMerchantApi.ContractTerms>()
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<CheckPaymentUnpaidResponse> =>
- buildCodecForObject<CheckPaymentUnpaidResponse>()
- .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<CheckPaymentClaimedResponse> =>
- buildCodecForObject<CheckPaymentClaimedResponse>()
- .property("order_status", codecForConstString("claimed"))
- .property("contract_terms", codecForMerchantContractTerms())
- .build("CheckPaymentClaimedResponse");
-
-export const codecForMerchantOrderPrivateStatusResponse =
- (): Codec<MerchantOrderPrivateStatusResponse> =>
- buildCodecForUnion<MerchantOrderPrivateStatusResponse>()
- .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<ExchangeAuditor> =>
export const codecForExchangeHandle = (): Codec<ExchangeHandle> =>
buildCodecForObject<ExchangeHandle>()
.property("master_pub", codecForString())
- .property("priority", codecForNumber())
.property("url", codecForString())
.build("ExchangeHandle");
@@ -1426,27 +1414,10 @@ export const codecForMerchantInfo = (): Codec<MerchantInfo> =>
.property("jurisdiction", codecOptional(codecForLocation()))
.build("MerchantInfo");
-export const codecForTax = (): Codec<Tax> =>
- buildCodecForObject<Tax>()
- .property("name", codecForString())
- .property("tax", codecForAmountString())
- .build("Tax");
export const codecForInternationalizedString =
(): Codec<InternationalizedString> => codecForMap(codecForString());
-export const codecForProduct = (): Codec<Product> =>
- buildCodecForObject<Product>()
- .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<MerchantContractTerms> =>
buildCodecForObject<MerchantContractTerms>()
@@ -1663,40 +1634,6 @@ export const codecForExchangeRevealResponse =
.property("ev_sigs", codecForList(codecForExchangeRevealItem()))
.build("ExchangeRevealResponse");
-export const codecForMerchantCoinRefundSuccessStatus =
- (): Codec<MerchantCoinRefundSuccessStatus> =>
- buildCodecForObject<MerchantCoinRefundSuccessStatus>()
- .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<MerchantCoinRefundFailureStatus> =>
- buildCodecForObject<MerchantCoinRefundFailureStatus>()
- .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<MerchantCoinRefundStatus> =>
- buildCodecForUnion<MerchantCoinRefundStatus>()
- .discriminateOn("type")
- .alternative("success", codecForMerchantCoinRefundSuccessStatus())
- .alternative("failure", codecForMerchantCoinRefundFailureStatus())
- .build("MerchantCoinRefundStatus");
-
export const codecForMerchantOrderStatusPaid =
(): Codec<MerchantOrderStatusPaid> =>
buildCodecForObject<MerchantOrderStatusPaid>()
@@ -1706,13 +1643,6 @@ export const codecForMerchantOrderStatusPaid =
.property("refunded", codecForBoolean())
.build("MerchantOrderStatusPaid");
-export const codecForMerchantOrderRefundPickupResponse =
- (): Codec<MerchantOrderRefundResponse> =>
- buildCodecForObject<MerchantOrderRefundResponse>()
- .property("merchant_pub", codecForString())
- .property("refund_amount", codecForAmountString())
- .property("refunds", codecForList(codecForMerchantCoinRefundStatus()))
- .build("MerchantOrderRefundPickupResponse");
export const codecForMerchantOrderStatusUnpaid =
(): Codec<MerchantOrderStatusUnpaid> =>
@@ -1751,36 +1681,6 @@ export interface AbortResponse {
refunds: MerchantAbortPayRefundStatus[];
}
-export const codecForMerchantAbortPayRefundSuccessStatus =
- (): Codec<MerchantAbortPayRefundSuccessStatus> =>
- buildCodecForObject<MerchantAbortPayRefundSuccessStatus>()
- .property("exchange_pub", codecForString())
- .property("exchange_sig", codecForString())
- .property("exchange_status", codecForConstNumber(200))
- .property("type", codecForConstString("success"))
- .build("MerchantAbortPayRefundSuccessStatus");
-
-export const codecForMerchantAbortPayRefundFailureStatus =
- (): Codec<MerchantAbortPayRefundFailureStatus> =>
- buildCodecForObject<MerchantAbortPayRefundFailureStatus>()
- .property("exchange_code", codecForNumber())
- .property("exchange_reply", codecForAny())
- .property("exchange_status", codecForNumber())
- .property("type", codecForConstString("failure"))
- .build("MerchantAbortPayRefundFailureStatus");
-
-export const codecForMerchantAbortPayRefundStatus =
- (): Codec<MerchantAbortPayRefundStatus> =>
- buildCodecForUnion<MerchantAbortPayRefundStatus>()
- .discriminateOn("type")
- .alternative("success", codecForMerchantAbortPayRefundSuccessStatus())
- .alternative("failure", codecForMerchantAbortPayRefundFailureStatus())
- .build("MerchantAbortPayRefundStatus");
-
-export const codecForAbortResponse = (): Codec<AbortResponse> =>
- buildCodecForObject<AbortResponse>()
- .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 {