diff options
author | Sebastian <sebasjm@gmail.com> | 2024-03-19 23:02:24 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2024-03-19 23:02:24 -0300 |
commit | c09caa5fdca91fb6ded6b2ce8caf1620c0273b80 (patch) | |
tree | 70d73ec63630b13fe83e738d606e2f4eabf5d235 /packages/taler-util/src/taler-types.ts | |
parent | 630f53f8a5721b2f5f2d43772aa4de7146df58fc (diff) | |
download | wallet-core-c09caa5fdca91fb6ded6b2ce8caf1620c0273b80.tar.xz |
wip, found #8653
Diffstat (limited to 'packages/taler-util/src/taler-types.ts')
-rw-r--r-- | packages/taler-util/src/taler-types.ts | 106 |
1 files changed, 3 insertions, 103 deletions
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 |