[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] branch master updated: respond with contract terms a
From: |
gnunet |
Subject: |
[taler-wallet-core] branch master updated: respond with contract terms as JSON (instead of string) in the wallet API |
Date: |
Thu, 30 Jul 2020 21:04:36 +0200 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository wallet-core.
The following commit(s) were added to refs/heads/master by this push:
new 119c1c70 respond with contract terms as JSON (instead of string) in
the wallet API
119c1c70 is described below
commit 119c1c708f9922e3e92ff592dcf08a1bd4f2f2e4
Author: Florian Dold <florian.dold@gmail.com>
AuthorDate: Fri Jul 31 00:34:31 2020 +0530
respond with contract terms as JSON (instead of string) in the wallet API
---
src/operations/pay.ts | 10 +++++-----
src/types/walletTypes.ts | 8 ++++----
src/wallet.ts | 2 +-
src/webex/pages/pay.tsx | 4 +---
4 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/src/operations/pay.ts b/src/operations/pay.ts
index 4a8c2144..9cbda5ba 100644
--- a/src/operations/pay.ts
+++ b/src/operations/pay.ts
@@ -924,7 +924,7 @@ export async function preparePayForUri(
logger.info("not confirming payment, insufficient coins");
return {
status: PreparePayResultType.InsufficientBalance,
- contractTerms: d.contractTermsRaw,
+ contractTerms: JSON.parse(d.contractTermsRaw),
proposalId: proposal.proposalId,
};
}
@@ -935,7 +935,7 @@ export async function preparePayForUri(
return {
status: PreparePayResultType.PaymentPossible,
- contractTerms: d.contractTermsRaw,
+ contractTerms: JSON.parse(d.contractTermsRaw),
proposalId: proposal.proposalId,
amountEffective: Amounts.stringify(costInfo.totalCost),
amountRaw: Amounts.stringify(res.paymentAmount),
@@ -957,20 +957,20 @@ export async function preparePayForUri(
const r = await submitPay(ws, proposalId);
return {
status: PreparePayResultType.AlreadyConfirmed,
- contractTerms: purchase.contractTermsRaw,
+ contractTerms: JSON.parse(purchase.contractTermsRaw),
paid: true,
nextUrl: r.nextUrl,
};
} else if (!purchase.timestampFirstSuccessfulPay) {
return {
status: PreparePayResultType.AlreadyConfirmed,
- contractTerms: purchase.contractTermsRaw,
+ contractTerms: JSON.parse(purchase.contractTermsRaw),
paid: false,
};
} else if (purchase.paymentSubmitPending) {
return {
status: PreparePayResultType.AlreadyConfirmed,
- contractTerms: purchase.contractTermsRaw,
+ contractTerms: JSON.parse(purchase.contractTermsRaw),
paid: false,
};
}
diff --git a/src/types/walletTypes.ts b/src/types/walletTypes.ts
index 9f0bfaf3..767b4c70 100644
--- a/src/types/walletTypes.ts
+++ b/src/types/walletTypes.ts
@@ -329,7 +329,7 @@ export type PreparePayResult =
export interface PreparePayResultPaymentPossible {
status: PreparePayResultType.PaymentPossible;
proposalId: string;
- contractTerms: string;
+ contractTerms: Record<string, unknown>;
amountRaw: string;
amountEffective: string;
}
@@ -337,12 +337,12 @@ export interface PreparePayResultPaymentPossible {
export interface PreparePayResultInsufficientBalance {
status: PreparePayResultType.InsufficientBalance;
proposalId: string;
- contractTerms: any;
+ contractTerms: Record<string, unknown>;
}
export interface PreparePayResultAlreadyConfirmed {
status: PreparePayResultType.AlreadyConfirmed;
- contractTerms: any;
+ contractTerms: Record<string, unknown>;
paid: boolean;
// Only specified if paid.
nextUrl?: string;
@@ -368,7 +368,7 @@ export interface AcceptWithdrawalResponse {
* Details about a purchase, including refund status.
*/
export interface PurchaseDetails {
- contractTerms: any;
+ contractTerms: Record<string, undefined>;
hasRefund: boolean;
totalRefundAmount: AmountJson;
totalRefundAndRefreshFees: AmountJson;
diff --git a/src/wallet.ts b/src/wallet.ts
index 09a3fcb4..758336c5 100644
--- a/src/wallet.ts
+++ b/src/wallet.ts
@@ -791,7 +791,7 @@ export class Wallet {
]).amount;
const totalFees = totalRefundFees;
return {
- contractTerms: purchase.contractTermsRaw,
+ contractTerms: JSON.parse(purchase.contractTermsRaw),
hasRefund: purchase.timestampLastRefundStatus !== undefined,
totalRefundAmount: totalRefundAmount,
totalRefundAndRefreshFees: totalFees,
diff --git a/src/webex/pages/pay.tsx b/src/webex/pages/pay.tsx
index d255ab6e..ce44c004 100644
--- a/src/webex/pages/pay.tsx
+++ b/src/webex/pages/pay.tsx
@@ -74,9 +74,7 @@ function TalerPayDialog({ talerPayUri }: { talerPayUri:
string }): JSX.Element {
let contractTerms: ContractTerms;
try {
- contractTerms = codecForContractTerms().decode(
- JSON.parse(payStatus.contractTerms),
- );
+ contractTerms = codecForContractTerms().decode(payStatus.contractTerms);
} catch (e) {
// This should never happen, as the wallet is supposed to check the
contract terms
// before storing them.
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-wallet-core] branch master updated: respond with contract terms as JSON (instead of string) in the wallet API,
gnunet <=