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