This commit is contained in:
Florian Dold 2020-08-12 15:48:02 +05:30
parent 6d2d65bf63
commit 56f5a1e3ab
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
4 changed files with 80 additions and 23 deletions

View File

@ -39,6 +39,8 @@ import {
codecForString, codecForString,
Duration, Duration,
CoreApiResponse, CoreApiResponse,
PreparePayResult,
PreparePayRequest,
} from "taler-wallet-core"; } from "taler-wallet-core";
import { URL } from "url"; import { URL } from "url";
import axios from "axios"; import axios from "axios";
@ -1140,4 +1142,8 @@ export class WalletCli {
`taler-wallet-cli --no-throttle --wallet-db ${wdb} run-pending`, `taler-wallet-cli --no-throttle --wallet-db ${wdb} run-pending`,
); );
} }
async preparePay(req: PreparePayRequest): Promise<PreparePayResult> {
throw Error("not implemented");
}
} }

View File

@ -27,7 +27,11 @@
/** /**
* Imports. * Imports.
*/ */
import { AmountJson, codecForAmountJson } from "../util/amounts"; import {
AmountJson,
codecForAmountJson,
codecForAmountString,
} from "../util/amounts";
import * as LibtoolVersion from "../util/libtoolVersion"; import * as LibtoolVersion from "../util/libtoolVersion";
import { import {
ExchangeRecord, ExchangeRecord,
@ -42,8 +46,10 @@ import {
Codec, Codec,
makeCodecForList, makeCodecForList,
codecForBoolean, codecForBoolean,
makeCodecForConstString,
codecForAny,
} from "../util/codec"; } from "../util/codec";
import { AmountString } from "./talerTypes"; import { AmountString, codecForContractTerms } from "./talerTypes";
import { TransactionError } from "./transactions"; import { TransactionError } from "./transactions";
/** /**
@ -351,6 +357,48 @@ export const enum PreparePayResultType {
AlreadyConfirmed = "already-confirmed", AlreadyConfirmed = "already-confirmed",
} }
export const codecForPreparePayResultPaymentPossible = (): Codec<
PreparePayResultPaymentPossible
> =>
makeCodecForObject<PreparePayResultPaymentPossible>()
.property("amountEffective", codecForAmountString())
.property("amountRaw", codecForAmountString())
.property("contractTerms", codecForAny)
.property("proposalId", codecForString)
.property(
"status",
makeCodecForConstString(PreparePayResultType.PaymentPossible),
)
.build("PreparePayResultPaymentPossible");
export const codecForPreparePayResultInsufficientBalance = (): Codec<
PreparePayResultInsufficientBalance
> =>
makeCodecForObject<PreparePayResultInsufficientBalance>()
.property("amountRaw", codecForAmountString())
.property("contractTerms", codecForAny)
.property("proposalId", codecForString)
.property(
"status",
makeCodecForConstString(PreparePayResultType.InsufficientBalance),
)
.build("PreparePayResultInsufficientBalance");
export const codecForPreparePayResultAlreadyConfirmed = (): Codec<
PreparePayResultAlreadyConfirmed
> =>
makeCodecForObject<PreparePayResultAlreadyConfirmed>()
.property(
"status",
makeCodecForConstString(PreparePayResultType.AlreadyConfirmed),
)
.property("amountEffective", codecForAmountString())
.property("amountRaw", codecForAmountString())
.property("nextUrl", codecForString)
.property("paid", codecForBoolean)
.property("contractTerms", codecForAny)
.build("PreparePayResultAlreadyConfirmed");
export type PreparePayResult = export type PreparePayResult =
| PreparePayResultInsufficientBalance | PreparePayResultInsufficientBalance
| PreparePayResultAlreadyConfirmed | PreparePayResultAlreadyConfirmed

View File

@ -27,6 +27,7 @@ import {
codecForNumber, codecForNumber,
Codec, Codec,
} from "./codec"; } from "./codec";
import { AmountString } from "../types/talerTypes";
/** /**
* Number of fractional units that one value unit represents. * Number of fractional units that one value unit represents.
@ -73,6 +74,8 @@ export const codecForAmountJson = (): Codec<AmountJson> =>
.property("fraction", codecForNumber) .property("fraction", codecForNumber)
.build("AmountJson"); .build("AmountJson");
export const codecForAmountString = (): Codec<AmountString> => codecForString;
/** /**
* Result of a possibly overflowing operation. * Result of a possibly overflowing operation.
*/ */

View File

@ -31,30 +31,30 @@ import {
import { Amounts } from "./util/amounts"; import { Amounts } from "./util/amounts";
import { OperationErrorDetails } from "./types/walletTypes"; import { OperationErrorDetails } from "./types/walletTypes";
interface AddExchangeRequest { export interface AddExchangeRequest {
exchangeBaseUrl: string; exchangeBaseUrl: string;
} }
const codecForAddExchangeRequest = (): Codec<AddExchangeRequest> => export const codecForAddExchangeRequest = (): Codec<AddExchangeRequest> =>
makeCodecForObject<AddExchangeRequest>() makeCodecForObject<AddExchangeRequest>()
.property("exchangeBaseUrl", codecForString) .property("exchangeBaseUrl", codecForString)
.build("AddExchangeRequest"); .build("AddExchangeRequest");
interface GetExchangeTosRequest { export interface GetExchangeTosRequest {
exchangeBaseUrl: string; exchangeBaseUrl: string;
} }
const codecForGetExchangeTosRequest = (): Codec<GetExchangeTosRequest> => export const codecForGetExchangeTosRequest = (): Codec<GetExchangeTosRequest> =>
makeCodecForObject<GetExchangeTosRequest>() makeCodecForObject<GetExchangeTosRequest>()
.property("exchangeBaseUrl", codecForString) .property("exchangeBaseUrl", codecForString)
.build("GetExchangeTosRequest"); .build("GetExchangeTosRequest");
interface AcceptManualWithdrawalRequest { export interface AcceptManualWithdrawalRequest {
exchangeBaseUrl: string; exchangeBaseUrl: string;
amount: string; amount: string;
} }
const codecForAcceptManualWithdrawalRequet = (): Codec< export const codecForAcceptManualWithdrawalRequet = (): Codec<
AcceptManualWithdrawalRequest AcceptManualWithdrawalRequest
> => > =>
makeCodecForObject<AcceptManualWithdrawalRequest>() makeCodecForObject<AcceptManualWithdrawalRequest>()
@ -62,17 +62,17 @@ const codecForAcceptManualWithdrawalRequet = (): Codec<
.property("amount", codecForString) .property("amount", codecForString)
.build("AcceptManualWithdrawalRequest"); .build("AcceptManualWithdrawalRequest");
interface GetWithdrawalDetailsForAmountRequest { export interface GetWithdrawalDetailsForAmountRequest {
exchangeBaseUrl: string; exchangeBaseUrl: string;
amount: string; amount: string;
} }
interface AcceptBankIntegratedWithdrawalRequest { export interface AcceptBankIntegratedWithdrawalRequest {
talerWithdrawUri: string; talerWithdrawUri: string;
exchangeBaseUrl: string; exchangeBaseUrl: string;
} }
const codecForAcceptBankIntegratedWithdrawalRequest = (): Codec< export const codecForAcceptBankIntegratedWithdrawalRequest = (): Codec<
AcceptBankIntegratedWithdrawalRequest AcceptBankIntegratedWithdrawalRequest
> => > =>
makeCodecForObject<AcceptBankIntegratedWithdrawalRequest>() makeCodecForObject<AcceptBankIntegratedWithdrawalRequest>()
@ -80,7 +80,7 @@ const codecForAcceptBankIntegratedWithdrawalRequest = (): Codec<
.property("talerWithdrawUri", codecForString) .property("talerWithdrawUri", codecForString)
.build("AcceptBankIntegratedWithdrawalRequest"); .build("AcceptBankIntegratedWithdrawalRequest");
const codecForGetWithdrawalDetailsForAmountRequest = (): Codec< export const codecForGetWithdrawalDetailsForAmountRequest = (): Codec<
GetWithdrawalDetailsForAmountRequest GetWithdrawalDetailsForAmountRequest
> => > =>
makeCodecForObject<GetWithdrawalDetailsForAmountRequest>() makeCodecForObject<GetWithdrawalDetailsForAmountRequest>()
@ -88,47 +88,47 @@ const codecForGetWithdrawalDetailsForAmountRequest = (): Codec<
.property("amount", codecForString) .property("amount", codecForString)
.build("GetWithdrawalDetailsForAmountRequest"); .build("GetWithdrawalDetailsForAmountRequest");
interface AcceptExchangeTosRequest { export interface AcceptExchangeTosRequest {
exchangeBaseUrl: string; exchangeBaseUrl: string;
etag: string; etag: string;
} }
const codecForAcceptExchangeTosRequest = (): Codec<AcceptExchangeTosRequest> => export const codecForAcceptExchangeTosRequest = (): Codec<AcceptExchangeTosRequest> =>
makeCodecForObject<AcceptExchangeTosRequest>() makeCodecForObject<AcceptExchangeTosRequest>()
.property("exchangeBaseUrl", codecForString) .property("exchangeBaseUrl", codecForString)
.property("etag", codecForString) .property("etag", codecForString)
.build("AcceptExchangeTosRequest"); .build("AcceptExchangeTosRequest");
interface ApplyRefundRequest { export interface ApplyRefundRequest {
talerRefundUri: string; talerRefundUri: string;
} }
const codecForApplyRefundRequest = (): Codec<ApplyRefundRequest> => export const codecForApplyRefundRequest = (): Codec<ApplyRefundRequest> =>
makeCodecForObject<ApplyRefundRequest>() makeCodecForObject<ApplyRefundRequest>()
.property("talerRefundUri", codecForString) .property("talerRefundUri", codecForString)
.build("ApplyRefundRequest"); .build("ApplyRefundRequest");
interface GetWithdrawalDetailsForUriRequest { export interface GetWithdrawalDetailsForUriRequest {
talerWithdrawUri: string; talerWithdrawUri: string;
} }
const codecForGetWithdrawalDetailsForUri = (): Codec< export const codecForGetWithdrawalDetailsForUri = (): Codec<
GetWithdrawalDetailsForUriRequest GetWithdrawalDetailsForUriRequest
> => > =>
makeCodecForObject<GetWithdrawalDetailsForUriRequest>() makeCodecForObject<GetWithdrawalDetailsForUriRequest>()
.property("talerWithdrawUri", codecForString) .property("talerWithdrawUri", codecForString)
.build("GetWithdrawalDetailsForUriRequest"); .build("GetWithdrawalDetailsForUriRequest");
interface AbortProposalRequest { export interface AbortProposalRequest {
proposalId: string; proposalId: string;
} }
const codecForAbortProposalRequest = (): Codec<AbortProposalRequest> => export const codecForAbortProposalRequest = (): Codec<AbortProposalRequest> =>
makeCodecForObject<AbortProposalRequest>() makeCodecForObject<AbortProposalRequest>()
.property("proposalId", codecForString) .property("proposalId", codecForString)
.build("AbortProposalRequest"); .build("AbortProposalRequest");
interface PreparePayRequest { export interface PreparePayRequest {
talerPayUri: string; talerPayUri: string;
} }
@ -137,12 +137,12 @@ const codecForPreparePayRequest = (): Codec<PreparePayRequest> =>
.property("talerPayUri", codecForString) .property("talerPayUri", codecForString)
.build("PreparePay"); .build("PreparePay");
interface ConfirmPayRequest { export interface ConfirmPayRequest {
proposalId: string; proposalId: string;
sessionId?: string; sessionId?: string;
} }
const codecForConfirmPayRequest = (): Codec<ConfirmPayRequest> => export const codecForConfirmPayRequest = (): Codec<ConfirmPayRequest> =>
makeCodecForObject<ConfirmPayRequest>() makeCodecForObject<ConfirmPayRequest>()
.property("proposalId", codecForString) .property("proposalId", codecForString)
.property("sessionId", makeCodecOptional(codecForString)) .property("sessionId", makeCodecOptional(codecForString))