validation
This commit is contained in:
parent
62406304d9
commit
7f4ebca0c4
@ -28,6 +28,7 @@ import {
|
||||
TalerErrorDetails,
|
||||
RefreshReason,
|
||||
CoinPublicKey,
|
||||
ApplyRefundResponse,
|
||||
} from "../types/walletTypes";
|
||||
import {
|
||||
Stores,
|
||||
@ -323,20 +324,6 @@ export interface RefundSummary {
|
||||
amountRefundGone: AmountJson;
|
||||
}
|
||||
|
||||
export interface ApplyRefundResponse {
|
||||
contractTermsHash: string;
|
||||
|
||||
proposalId: string;
|
||||
|
||||
amountEffectivePaid: AmountString;
|
||||
|
||||
amountRefundGranted: AmountString;
|
||||
|
||||
amountRefundGone: AmountString;
|
||||
|
||||
pendingAtExchange: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Accept a refund, return the contract hash for the contract
|
||||
* that was involved in the refund.
|
||||
|
@ -985,7 +985,7 @@ export const codecForBankWithdrawalOperationPostResponse = (): Codec<
|
||||
BankWithdrawalOperationPostResponse
|
||||
> =>
|
||||
buildCodecForObject<BankWithdrawalOperationPostResponse>()
|
||||
.property("transfer_done", codecForBoolean)
|
||||
.property("transfer_done", codecForBoolean())
|
||||
.build("BankWithdrawalOperationPostResponse");
|
||||
|
||||
export type AmountString = string;
|
||||
@ -1189,7 +1189,7 @@ export const codecForProposal = (): Codec<Proposal> =>
|
||||
export const codecForCheckPaymentResponse = (): Codec<CheckPaymentResponse> =>
|
||||
buildCodecForObject<CheckPaymentResponse>()
|
||||
.property("order_status", codecForString())
|
||||
.property("refunded", codecOptional(codecForBoolean))
|
||||
.property("refunded", codecOptional(codecForBoolean()))
|
||||
.property("refunded_amount", codecOptional(codecForString()))
|
||||
.property("contract_terms", codecOptional(codecForAny()))
|
||||
.property("taler_pay_uri", codecOptional(codecForString()))
|
||||
@ -1200,9 +1200,9 @@ export const codecForWithdrawOperationStatusResponse = (): Codec<
|
||||
WithdrawOperationStatusResponse
|
||||
> =>
|
||||
buildCodecForObject<WithdrawOperationStatusResponse>()
|
||||
.property("selection_done", codecForBoolean)
|
||||
.property("transfer_done", codecForBoolean)
|
||||
.property("aborted", codecForBoolean)
|
||||
.property("selection_done", codecForBoolean())
|
||||
.property("transfer_done", codecForBoolean())
|
||||
.property("aborted", codecForBoolean())
|
||||
.property("amount", codecForString())
|
||||
.property("sender_wire", codecOptional(codecForString()))
|
||||
.property("suggested_exchange", codecOptional(codecForString()))
|
||||
@ -1298,7 +1298,7 @@ export const codecForMerchantOrderStatusPaid = (): Codec<
|
||||
> =>
|
||||
buildCodecForObject<MerchantOrderStatusPaid>()
|
||||
.property("refund_amount", codecForString())
|
||||
.property("refunded", codecForBoolean)
|
||||
.property("refunded", codecForBoolean())
|
||||
.build("MerchantOrderStatusPaid");
|
||||
|
||||
export const codecForMerchantOrderRefundPickupResponse = (): Codec<
|
||||
|
@ -180,10 +180,10 @@ export interface BalancesResponse {
|
||||
export const codecForBalance = (): Codec<Balance> =>
|
||||
buildCodecForObject<Balance>()
|
||||
.property("available", codecForString())
|
||||
.property("hasPendingTransactions", codecForBoolean)
|
||||
.property("hasPendingTransactions", codecForBoolean())
|
||||
.property("pendingIncoming", codecForString())
|
||||
.property("pendingOutgoing", codecForString())
|
||||
.property("requiresUserInput", codecForBoolean)
|
||||
.property("requiresUserInput", codecForBoolean())
|
||||
.build("Balance");
|
||||
|
||||
export const codecForBalancesResponse = (): Codec<BalancesResponse> =>
|
||||
@ -413,7 +413,7 @@ export const codecForPreparePayResultAlreadyConfirmed = (): Codec<
|
||||
)
|
||||
.property("amountEffective", codecForAmountString())
|
||||
.property("amountRaw", codecForAmountString())
|
||||
.property("paid", codecForBoolean)
|
||||
.property("paid", codecForBoolean())
|
||||
.property("contractTerms", codecForAny())
|
||||
.property("contractTermsHash", codecForString())
|
||||
.build("PreparePayResultAlreadyConfirmed");
|
||||
@ -843,3 +843,27 @@ export const codecForWithdrawTestBalance = (): Codec<
|
||||
.property("bankBaseUrl", codecForString())
|
||||
.property("exchangeBaseUrl", codecForString())
|
||||
.build("WithdrawTestBalanceRequest");
|
||||
|
||||
export interface ApplyRefundResponse {
|
||||
contractTermsHash: string;
|
||||
|
||||
proposalId: string;
|
||||
|
||||
amountEffectivePaid: AmountString;
|
||||
|
||||
amountRefundGranted: AmountString;
|
||||
|
||||
amountRefundGone: AmountString;
|
||||
|
||||
pendingAtExchange: boolean;
|
||||
}
|
||||
|
||||
export const codecForApplyRefundResponse = (): Codec<ApplyRefundResponse> =>
|
||||
buildCodecForObject<ApplyRefundResponse>()
|
||||
.property("amountEffectivePaid", codecForAmountString())
|
||||
.property("amountRefundGone", codecForAmountString())
|
||||
.property("amountRefundGranted", codecForAmountString())
|
||||
.property("contractTermsHash", codecForString())
|
||||
.property("pendingAtExchange", codecForBoolean())
|
||||
.property("proposalId", codecForString())
|
||||
.build("ApplyRefundResponse");
|
||||
|
@ -292,15 +292,17 @@ export function codecForNumber(): Codec<number> {
|
||||
/**
|
||||
* Return a codec for a value that must be a number.
|
||||
*/
|
||||
export const codecForBoolean: Codec<boolean> = {
|
||||
decode(x: any, c?: Context): boolean {
|
||||
if (typeof x === "boolean") {
|
||||
return x;
|
||||
}
|
||||
throw new DecodingError(
|
||||
`expected boolean at ${renderContext(c)} but got ${typeof x}`,
|
||||
);
|
||||
},
|
||||
export function codecForBoolean(): Codec<boolean> {
|
||||
return {
|
||||
decode(x: any, c?: Context): boolean {
|
||||
if (typeof x === "boolean") {
|
||||
return x;
|
||||
}
|
||||
throw new DecodingError(
|
||||
`expected boolean at ${renderContext(c)} but got ${typeof x}`,
|
||||
);
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user