gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] 01/02: validation


From: gnunet
Subject: [taler-wallet-core] 01/02: validation
Date: Tue, 01 Sep 2020 17:07:56 +0200

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository wallet-core.

commit 7f4ebca0c4330805ea8f3821dba075b34dd2be58
Author: Florian Dold <florian.dold@gmail.com>
AuthorDate: Tue Sep 1 19:56:08 2020 +0530

    validation
---
 .../taler-wallet-core/src/operations/refund.ts     | 15 +----------
 packages/taler-wallet-core/src/types/talerTypes.ts | 12 ++++-----
 .../taler-wallet-core/src/types/walletTypes.ts     | 30 +++++++++++++++++++---
 packages/taler-wallet-core/src/util/codec.ts       | 20 ++++++++-------
 4 files changed, 45 insertions(+), 32 deletions(-)

diff --git a/packages/taler-wallet-core/src/operations/refund.ts 
b/packages/taler-wallet-core/src/operations/refund.ts
index 787d2bb4..373e17a1 100644
--- a/packages/taler-wallet-core/src/operations/refund.ts
+++ b/packages/taler-wallet-core/src/operations/refund.ts
@@ -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.
diff --git a/packages/taler-wallet-core/src/types/talerTypes.ts 
b/packages/taler-wallet-core/src/types/talerTypes.ts
index b9e7fae4..b1061a1a 100644
--- a/packages/taler-wallet-core/src/types/talerTypes.ts
+++ b/packages/taler-wallet-core/src/types/talerTypes.ts
@@ -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<
diff --git a/packages/taler-wallet-core/src/types/walletTypes.ts 
b/packages/taler-wallet-core/src/types/walletTypes.ts
index 89c8b4a8..dbaefae3 100644
--- a/packages/taler-wallet-core/src/types/walletTypes.ts
+++ b/packages/taler-wallet-core/src/types/walletTypes.ts
@@ -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");
diff --git a/packages/taler-wallet-core/src/util/codec.ts 
b/packages/taler-wallet-core/src/util/codec.ts
index 111abc38..741a5b17 100644
--- a/packages/taler-wallet-core/src/util/codec.ts
+++ b/packages/taler-wallet-core/src/util/codec.ts
@@ -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}`,
+      );
+    },
+  }
 };
 
 /**

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]