From fdbd55d2bde0961a4c1ff26b04e442459ab782b0 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 3 Aug 2023 18:35:07 +0200 Subject: -towards tip->reward rename --- packages/taler-util/src/backup-types.ts | 4 +-- packages/taler-util/src/http-impl.node.ts | 22 ++++++++++++++-- packages/taler-util/src/merchant-api-types.ts | 14 +++++----- packages/taler-util/src/transactions-types.ts | 8 +++--- packages/taler-util/src/wallet-types.ts | 38 +++++++++++++-------------- 5 files changed, 52 insertions(+), 34 deletions(-) (limited to 'packages/taler-util') diff --git a/packages/taler-util/src/backup-types.ts b/packages/taler-util/src/backup-types.ts index 2920838dd..0211ff740 100644 --- a/packages/taler-util/src/backup-types.ts +++ b/packages/taler-util/src/backup-types.ts @@ -499,7 +499,7 @@ export interface BackupRecoupGroup { export enum BackupCoinSourceType { Withdraw = "withdraw", Refresh = "refresh", - Tip = "tip", + Reward = "reward", } /** @@ -546,7 +546,7 @@ export interface BackupRefreshCoinSource { * Metadata about a coin obtained from a tip. */ export interface BackupTipCoinSource { - type: BackupCoinSourceType.Tip; + type: BackupCoinSourceType.Reward; /** * Wallet's identifier for the tip that this coin diff --git a/packages/taler-util/src/http-impl.node.ts b/packages/taler-util/src/http-impl.node.ts index 639043201..07648a28d 100644 --- a/packages/taler-util/src/http-impl.node.ts +++ b/packages/taler-util/src/http-impl.node.ts @@ -183,7 +183,16 @@ export class HttpLibImpl implements HttpRequestLibrary { resolve(resp); }); res.on("error", (e) => { - reject(e); + const err = TalerError.fromDetail( + TalerErrorCode.WALLET_UNEXPECTED_REQUEST_ERROR, + { + requestUrl: url, + requestMethod: method, + httpStatusCode: 0, + }, + `Error in HTTP response handler: ${e.message}`, + ); + reject(err); }); }; @@ -197,7 +206,16 @@ export class HttpLibImpl implements HttpRequestLibrary { } req.on("error", (e: Error) => { - reject(e); + const err = TalerError.fromDetail( + TalerErrorCode.WALLET_UNEXPECTED_REQUEST_ERROR, + { + requestUrl: url, + requestMethod: method, + httpStatusCode: 0, + }, + `Error in HTTP request: ${e.message}`, + ); + reject(err); }); if (reqBody) { diff --git a/packages/taler-util/src/merchant-api-types.ts b/packages/taler-util/src/merchant-api-types.ts index d7a5cf576..9f00173f2 100644 --- a/packages/taler-util/src/merchant-api-types.ts +++ b/packages/taler-util/src/merchant-api-types.ts @@ -290,22 +290,22 @@ export interface ReserveStatusEntry { active: boolean; } -export interface TipCreateConfirmation { +export interface RewardCreateConfirmation { // Unique tip identifier for the tip that was created. - tip_id: string; + reward_id: string; // taler://tip URI for the tip - taler_tip_uri: string; + taler_reward_uri: string; // URL that will directly trigger processing // the tip when the browser is redirected to it - tip_status_url: string; + reward_status_url: string; - // when does the tip expire - tip_expiration: AbsoluteTime; + // when does the reward expire + reward_expiration: AbsoluteTime; } -export interface TipCreateRequest { +export interface RewardCreateRequest { // Amount that the customer should be tipped amount: AmountString; diff --git a/packages/taler-util/src/transactions-types.ts b/packages/taler-util/src/transactions-types.ts index a498d3471..2d278e3e8 100644 --- a/packages/taler-util/src/transactions-types.ts +++ b/packages/taler-util/src/transactions-types.ts @@ -186,7 +186,7 @@ export type Transaction = | TransactionWithdrawal | TransactionPayment | TransactionRefund - | TransactionTip + | TransactionReward | TransactionRefresh | TransactionDeposit | TransactionPeerPullCredit @@ -201,7 +201,7 @@ export enum TransactionType { Payment = "payment", Refund = "refund", Refresh = "refresh", - Tip = "tip", + Reward = "reward", Deposit = "deposit", PeerPushDebit = "peer-push-debit", PeerPushCredit = "peer-push-credit", @@ -591,8 +591,8 @@ export interface TransactionRefund extends TransactionCommon { paymentInfo: RefundPaymentInfo | undefined; } -export interface TransactionTip extends TransactionCommon { - type: TransactionType.Tip; +export interface TransactionReward extends TransactionCommon { + type: TransactionType.Reward; // Raw amount of the tip, without extra fees that apply amountRaw: AmountString; diff --git a/packages/taler-util/src/wallet-types.ts b/packages/taler-util/src/wallet-types.ts index 5151b8aae..38e5787ba 100644 --- a/packages/taler-util/src/wallet-types.ts +++ b/packages/taler-util/src/wallet-types.ts @@ -605,7 +605,7 @@ export interface PrepareTipResult { * * @deprecated use transactionId instead */ - walletTipId: string; + walletRewardId: string; /** * Tip transaction ID. @@ -620,13 +620,13 @@ export interface PrepareTipResult { /** * Amount that the merchant gave. */ - tipAmountRaw: AmountString; + rewardAmountRaw: AmountString; /** * Amount that arrived at the wallet. * Might be lower than the raw amount due to fees. */ - tipAmountEffective: AmountString; + rewardAmountEffective: AmountString; /** * Base URL of the merchant backend giving then tip. @@ -654,14 +654,14 @@ export interface AcceptTipResponse { export const codecForPrepareTipResult = (): Codec => buildCodecForObject() .property("accepted", codecForBoolean()) - .property("tipAmountRaw", codecForAmountString()) - .property("tipAmountEffective", codecForAmountString()) + .property("rewardAmountRaw", codecForAmountString()) + .property("rewardAmountEffective", codecForAmountString()) .property("exchangeBaseUrl", codecForString()) .property("merchantBaseUrl", codecForString()) .property("expirationTimestamp", codecForTimestamp) - .property("walletTipId", codecForString()) + .property("walletRewardId", codecForString()) .property("transactionId", codecForString()) - .build("PrepareTipResult"); + .build("PrepareRewardResult"); export interface BenchmarkResult { time: { [s: string]: number }; @@ -1933,23 +1933,23 @@ export const codecForStartRefundQueryRequest = .property("transactionId", codecForTransactionIdStr()) .build("StartRefundQueryRequest"); -export interface PrepareTipRequest { - talerTipUri: string; +export interface PrepareRewardRequest { + talerRewardUri: string; } -export const codecForPrepareTipRequest = (): Codec => - buildCodecForObject() - .property("talerTipUri", codecForString()) - .build("PrepareTipRequest"); +export const codecForPrepareRewardRequest = (): Codec => + buildCodecForObject() + .property("talerRewardUri", codecForString()) + .build("PrepareRewardRequest"); -export interface AcceptTipRequest { - walletTipId: string; +export interface AcceptRewardRequest { + walletRewardId: string; } -export const codecForAcceptTipRequest = (): Codec => - buildCodecForObject() - .property("walletTipId", codecForString()) - .build("AcceptTipRequest"); +export const codecForAcceptTipRequest = (): Codec => + buildCodecForObject() + .property("walletRewardId", codecForString()) + .build("AcceptRewardRequest"); export interface FailTransactionRequest { transactionId: TransactionIdStr; -- cgit v1.2.3