codec
This commit is contained in:
parent
6d2d65bf63
commit
56f5a1e3ab
@ -39,6 +39,8 @@ import {
|
||||
codecForString,
|
||||
Duration,
|
||||
CoreApiResponse,
|
||||
PreparePayResult,
|
||||
PreparePayRequest,
|
||||
} from "taler-wallet-core";
|
||||
import { URL } from "url";
|
||||
import axios from "axios";
|
||||
@ -1140,4 +1142,8 @@ export class WalletCli {
|
||||
`taler-wallet-cli --no-throttle --wallet-db ${wdb} run-pending`,
|
||||
);
|
||||
}
|
||||
|
||||
async preparePay(req: PreparePayRequest): Promise<PreparePayResult> {
|
||||
throw Error("not implemented");
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,11 @@
|
||||
/**
|
||||
* Imports.
|
||||
*/
|
||||
import { AmountJson, codecForAmountJson } from "../util/amounts";
|
||||
import {
|
||||
AmountJson,
|
||||
codecForAmountJson,
|
||||
codecForAmountString,
|
||||
} from "../util/amounts";
|
||||
import * as LibtoolVersion from "../util/libtoolVersion";
|
||||
import {
|
||||
ExchangeRecord,
|
||||
@ -42,8 +46,10 @@ import {
|
||||
Codec,
|
||||
makeCodecForList,
|
||||
codecForBoolean,
|
||||
makeCodecForConstString,
|
||||
codecForAny,
|
||||
} from "../util/codec";
|
||||
import { AmountString } from "./talerTypes";
|
||||
import { AmountString, codecForContractTerms } from "./talerTypes";
|
||||
import { TransactionError } from "./transactions";
|
||||
|
||||
/**
|
||||
@ -351,6 +357,48 @@ export const enum PreparePayResultType {
|
||||
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 =
|
||||
| PreparePayResultInsufficientBalance
|
||||
| PreparePayResultAlreadyConfirmed
|
||||
|
@ -27,6 +27,7 @@ import {
|
||||
codecForNumber,
|
||||
Codec,
|
||||
} from "./codec";
|
||||
import { AmountString } from "../types/talerTypes";
|
||||
|
||||
/**
|
||||
* Number of fractional units that one value unit represents.
|
||||
@ -73,6 +74,8 @@ export const codecForAmountJson = (): Codec<AmountJson> =>
|
||||
.property("fraction", codecForNumber)
|
||||
.build("AmountJson");
|
||||
|
||||
export const codecForAmountString = (): Codec<AmountString> => codecForString;
|
||||
|
||||
/**
|
||||
* Result of a possibly overflowing operation.
|
||||
*/
|
||||
|
@ -31,30 +31,30 @@ import {
|
||||
import { Amounts } from "./util/amounts";
|
||||
import { OperationErrorDetails } from "./types/walletTypes";
|
||||
|
||||
interface AddExchangeRequest {
|
||||
export interface AddExchangeRequest {
|
||||
exchangeBaseUrl: string;
|
||||
}
|
||||
|
||||
const codecForAddExchangeRequest = (): Codec<AddExchangeRequest> =>
|
||||
export const codecForAddExchangeRequest = (): Codec<AddExchangeRequest> =>
|
||||
makeCodecForObject<AddExchangeRequest>()
|
||||
.property("exchangeBaseUrl", codecForString)
|
||||
.build("AddExchangeRequest");
|
||||
|
||||
interface GetExchangeTosRequest {
|
||||
export interface GetExchangeTosRequest {
|
||||
exchangeBaseUrl: string;
|
||||
}
|
||||
|
||||
const codecForGetExchangeTosRequest = (): Codec<GetExchangeTosRequest> =>
|
||||
export const codecForGetExchangeTosRequest = (): Codec<GetExchangeTosRequest> =>
|
||||
makeCodecForObject<GetExchangeTosRequest>()
|
||||
.property("exchangeBaseUrl", codecForString)
|
||||
.build("GetExchangeTosRequest");
|
||||
|
||||
interface AcceptManualWithdrawalRequest {
|
||||
export interface AcceptManualWithdrawalRequest {
|
||||
exchangeBaseUrl: string;
|
||||
amount: string;
|
||||
}
|
||||
|
||||
const codecForAcceptManualWithdrawalRequet = (): Codec<
|
||||
export const codecForAcceptManualWithdrawalRequet = (): Codec<
|
||||
AcceptManualWithdrawalRequest
|
||||
> =>
|
||||
makeCodecForObject<AcceptManualWithdrawalRequest>()
|
||||
@ -62,17 +62,17 @@ const codecForAcceptManualWithdrawalRequet = (): Codec<
|
||||
.property("amount", codecForString)
|
||||
.build("AcceptManualWithdrawalRequest");
|
||||
|
||||
interface GetWithdrawalDetailsForAmountRequest {
|
||||
export interface GetWithdrawalDetailsForAmountRequest {
|
||||
exchangeBaseUrl: string;
|
||||
amount: string;
|
||||
}
|
||||
|
||||
interface AcceptBankIntegratedWithdrawalRequest {
|
||||
export interface AcceptBankIntegratedWithdrawalRequest {
|
||||
talerWithdrawUri: string;
|
||||
exchangeBaseUrl: string;
|
||||
}
|
||||
|
||||
const codecForAcceptBankIntegratedWithdrawalRequest = (): Codec<
|
||||
export const codecForAcceptBankIntegratedWithdrawalRequest = (): Codec<
|
||||
AcceptBankIntegratedWithdrawalRequest
|
||||
> =>
|
||||
makeCodecForObject<AcceptBankIntegratedWithdrawalRequest>()
|
||||
@ -80,7 +80,7 @@ const codecForAcceptBankIntegratedWithdrawalRequest = (): Codec<
|
||||
.property("talerWithdrawUri", codecForString)
|
||||
.build("AcceptBankIntegratedWithdrawalRequest");
|
||||
|
||||
const codecForGetWithdrawalDetailsForAmountRequest = (): Codec<
|
||||
export const codecForGetWithdrawalDetailsForAmountRequest = (): Codec<
|
||||
GetWithdrawalDetailsForAmountRequest
|
||||
> =>
|
||||
makeCodecForObject<GetWithdrawalDetailsForAmountRequest>()
|
||||
@ -88,47 +88,47 @@ const codecForGetWithdrawalDetailsForAmountRequest = (): Codec<
|
||||
.property("amount", codecForString)
|
||||
.build("GetWithdrawalDetailsForAmountRequest");
|
||||
|
||||
interface AcceptExchangeTosRequest {
|
||||
export interface AcceptExchangeTosRequest {
|
||||
exchangeBaseUrl: string;
|
||||
etag: string;
|
||||
}
|
||||
|
||||
const codecForAcceptExchangeTosRequest = (): Codec<AcceptExchangeTosRequest> =>
|
||||
export const codecForAcceptExchangeTosRequest = (): Codec<AcceptExchangeTosRequest> =>
|
||||
makeCodecForObject<AcceptExchangeTosRequest>()
|
||||
.property("exchangeBaseUrl", codecForString)
|
||||
.property("etag", codecForString)
|
||||
.build("AcceptExchangeTosRequest");
|
||||
|
||||
interface ApplyRefundRequest {
|
||||
export interface ApplyRefundRequest {
|
||||
talerRefundUri: string;
|
||||
}
|
||||
|
||||
const codecForApplyRefundRequest = (): Codec<ApplyRefundRequest> =>
|
||||
export const codecForApplyRefundRequest = (): Codec<ApplyRefundRequest> =>
|
||||
makeCodecForObject<ApplyRefundRequest>()
|
||||
.property("talerRefundUri", codecForString)
|
||||
.build("ApplyRefundRequest");
|
||||
|
||||
interface GetWithdrawalDetailsForUriRequest {
|
||||
export interface GetWithdrawalDetailsForUriRequest {
|
||||
talerWithdrawUri: string;
|
||||
}
|
||||
|
||||
const codecForGetWithdrawalDetailsForUri = (): Codec<
|
||||
export const codecForGetWithdrawalDetailsForUri = (): Codec<
|
||||
GetWithdrawalDetailsForUriRequest
|
||||
> =>
|
||||
makeCodecForObject<GetWithdrawalDetailsForUriRequest>()
|
||||
.property("talerWithdrawUri", codecForString)
|
||||
.build("GetWithdrawalDetailsForUriRequest");
|
||||
|
||||
interface AbortProposalRequest {
|
||||
export interface AbortProposalRequest {
|
||||
proposalId: string;
|
||||
}
|
||||
|
||||
const codecForAbortProposalRequest = (): Codec<AbortProposalRequest> =>
|
||||
export const codecForAbortProposalRequest = (): Codec<AbortProposalRequest> =>
|
||||
makeCodecForObject<AbortProposalRequest>()
|
||||
.property("proposalId", codecForString)
|
||||
.build("AbortProposalRequest");
|
||||
|
||||
interface PreparePayRequest {
|
||||
export interface PreparePayRequest {
|
||||
talerPayUri: string;
|
||||
}
|
||||
|
||||
@ -137,12 +137,12 @@ const codecForPreparePayRequest = (): Codec<PreparePayRequest> =>
|
||||
.property("talerPayUri", codecForString)
|
||||
.build("PreparePay");
|
||||
|
||||
interface ConfirmPayRequest {
|
||||
export interface ConfirmPayRequest {
|
||||
proposalId: string;
|
||||
sessionId?: string;
|
||||
}
|
||||
|
||||
const codecForConfirmPayRequest = (): Codec<ConfirmPayRequest> =>
|
||||
export const codecForConfirmPayRequest = (): Codec<ConfirmPayRequest> =>
|
||||
makeCodecForObject<ConfirmPayRequest>()
|
||||
.property("proposalId", codecForString)
|
||||
.property("sessionId", makeCodecOptional(codecForString))
|
||||
|
Loading…
Reference in New Issue
Block a user