From 983d14761eb1c33f4a59211b132f8485b7998bda Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 7 Mar 2024 19:27:41 +0100 Subject: -rewards are gone! --- .../paths/instance/reserves/details/RewardInfo.tsx | 22 ++++++---- packages/taler-util/src/taleruri.test.ts | 46 -------------------- packages/taler-util/src/taleruri.ts | 50 ---------------------- .../src/NavigationBar.tsx | 1 - .../src/platform/chrome.ts | 3 -- .../src/popup/TalerActionFound.tsx | 1 - 6 files changed, 14 insertions(+), 109 deletions(-) diff --git a/packages/auditor-backoffice-ui/src/paths/instance/reserves/details/RewardInfo.tsx b/packages/auditor-backoffice-ui/src/paths/instance/reserves/details/RewardInfo.tsx index 780068a91..491028695 100644 --- a/packages/auditor-backoffice-ui/src/paths/instance/reserves/details/RewardInfo.tsx +++ b/packages/auditor-backoffice-ui/src/paths/instance/reserves/details/RewardInfo.tsx @@ -13,12 +13,14 @@ You should have received a copy of the GNU General Public License along with GNU Taler; see the file COPYING. If not, see */ -import { stringifyRewardUri } from "@gnu-taler/taler-util"; import { format } from "date-fns"; import { Fragment, h, VNode } from "preact"; import { useBackendContext } from "../../../../context/backend.js"; import { MerchantBackend } from "../../../../declaration.js"; -import { datetimeFormatForSettings, useSettings } from "../../../../hooks/useSettings.js"; +import { + datetimeFormatForSettings, + useSettings, +} from "../../../../hooks/useSettings.js"; type Entity = MerchantBackend.Rewards.RewardDetails; @@ -28,10 +30,14 @@ interface Props { amount: string; } -export function RewardInfo({ id: merchantRewardId, amount, entity }: Props): VNode { - const { url: backendURL } = useBackendContext() +export function RewardInfo({ + id: merchantRewardId, + amount, + entity, +}: Props): VNode { + const { url: backendURL } = useBackendContext(); const [settings] = useSettings(); - const rewardURL = stringifyRewardUri({ merchantBaseUrl: backendURL, merchantRewardId }) + const rewardURL = "not-supported"; return (
@@ -74,9 +80,9 @@ export function RewardInfo({ id: merchantRewardId, amount, entity }: Props): VNo !entity.expiration || entity.expiration.t_s === "never" ? "never" : format( - entity.expiration.t_s * 1000, - datetimeFormatForSettings(settings), - ) + entity.expiration.t_s * 1000, + datetimeFormatForSettings(settings), + ) } />

diff --git a/packages/taler-util/src/taleruri.test.ts b/packages/taler-util/src/taleruri.test.ts index 2ff401abc..ab7a27af6 100644 --- a/packages/taler-util/src/taleruri.test.ts +++ b/packages/taler-util/src/taleruri.test.ts @@ -24,7 +24,6 @@ import { parsePayUri, parseRefundUri, parseRestoreUri, - parseRewardUri, parseWithdrawExchangeUri, parseWithdrawUri, stringifyDevExperimentUri, @@ -34,7 +33,6 @@ import { stringifyPayUri, stringifyRefundUri, stringifyRestoreUri, - stringifyRewardUri, stringifyWithdrawExchange, stringifyWithdrawUri, } from "./taleruri.js"; @@ -218,50 +216,6 @@ test("taler refund URI (stringify)", (t) => { t.deepEqual(url, "taler://refund/merchant.test/instance/pepe/123/"); }); -/** - * 5.4 action: reward https://lsd.gnunet.org/lsd0006/#name-action-tip - */ - -test("taler reward pickup uri", (t) => { - const url1 = "taler://reward/merchant.example.com/tipid"; - const r1 = parseRewardUri(url1); - if (!r1) { - t.fail(); - return; - } - t.is(r1.merchantBaseUrl, "https://merchant.example.com/"); -}); - -test("taler reward pickup uri with instance", (t) => { - const url1 = "taler://reward/merchant.example.com/instances/tipm/tipid/"; - const r1 = parseRewardUri(url1); - if (!r1) { - t.fail(); - return; - } - t.is(r1.merchantBaseUrl, "https://merchant.example.com/instances/tipm/"); - t.is(r1.merchantRewardId, "tipid"); -}); - -test("taler reward pickup uri with instance and prefix", (t) => { - const url1 = "taler://reward/merchant.example.com/my/pfx/tipm/tipid/"; - const r1 = parseRewardUri(url1); - if (!r1) { - t.fail(); - return; - } - t.is(r1.merchantBaseUrl, "https://merchant.example.com/my/pfx/tipm/"); - t.is(r1.merchantRewardId, "tipid"); -}); - -test("taler reward URI (stringify)", (t) => { - const url = stringifyRewardUri({ - merchantBaseUrl: "https://merchant.test/instance/pepe/", - merchantRewardId: "123", - }); - t.deepEqual(url, "taler://reward/merchant.test/instance/pepe/123/"); -}); - /** * 5.5 action: pay-push https://lsd.gnunet.org/lsd0006/#name-action-pay-push */ diff --git a/packages/taler-util/src/taleruri.ts b/packages/taler-util/src/taleruri.ts index 15464b981..9717a7d71 100644 --- a/packages/taler-util/src/taleruri.ts +++ b/packages/taler-util/src/taleruri.ts @@ -39,7 +39,6 @@ export type TalerUri = | PayPushUriResult | BackupRestoreUri | RefundUriResult - | RewardUriResult | WithdrawUriResult | WithdrawExchangeUri; @@ -97,12 +96,6 @@ export interface RefundUriResult { orderId: string; } -export interface RewardUriResult { - type: TalerUriAction.Reward; - merchantBaseUrl: string; - merchantRewardId: string; -} - export interface PayPushUriResult { type: TalerUriAction.PayPush; exchangeBaseUrl: string; @@ -188,7 +181,6 @@ export enum TalerUriAction { Pay = "pay", Withdraw = "withdraw", Refund = "refund", - Reward = "reward", PayPull = "pay-pull", PayPush = "pay-push", PayTemplate = "pay-template", @@ -231,7 +223,6 @@ const parsers: { [A in TalerUriAction]: Parser } = { [TalerUriAction.PayTemplate]: parsePayTemplateUri, [TalerUriAction.Restore]: parseRestoreUri, [TalerUriAction.Refund]: parseRefundUri, - [TalerUriAction.Reward]: parseRewardUri, [TalerUriAction.Withdraw]: parseWithdrawUri, [TalerUriAction.DevExperiment]: parseDevExperimentUri, [TalerUriAction.WithdrawExchange]: parseWithdrawExchangeUri, @@ -272,9 +263,6 @@ export function stringifyTalerUri(uri: TalerUri): string { case TalerUriAction.Refund: { return stringifyRefundUri(uri); } - case TalerUriAction.Reward: { - return stringifyRewardUri(uri); - } case TalerUriAction.Withdraw: { return stringifyWithdrawUri(uri); } @@ -404,36 +392,6 @@ export function parsePayPullUri(s: string): PayPullUriResult | undefined { }; } -/** - * Parse a taler[+http]://reward URI. - * Return undefined if not passed a valid URI. - */ -export function parseRewardUri(s: string): RewardUriResult | undefined { - const pi = parseProtoInfo(s, "reward"); - if (!pi) { - return undefined; - } - const c = pi?.rest.split("?"); - const parts = c[0].split("/"); - if (parts.length < 2) { - return undefined; - } - const host = parts[0].toLowerCase(); - const unused = parts[parts.length - 1]; - const rewardId = parts[parts.length - 2]; - const pathSegments = parts.slice(1, parts.length - 2); - const hostAndSegments = [host, ...pathSegments].join("/"); - const merchantBaseUrl = canonicalizeBaseUrl( - `${pi.innerProto}://${hostAndSegments}/`, - ); - - return { - type: TalerUriAction.Reward, - merchantBaseUrl, - merchantRewardId: rewardId, - }; -} - export function parseWithdrawExchangeUri( s: string, ): WithdrawExchangeUri | undefined { @@ -613,14 +571,6 @@ export function stringifyRefundUri({ return `${proto}://refund/${path}${orderId}/`; } -export function stringifyRewardUri({ - merchantBaseUrl, - merchantRewardId, -}: Omit): string { - const { proto, path } = getUrlInfo(merchantBaseUrl); - return `${proto}://reward/${path}${merchantRewardId}/`; -} - export function stringifyWithdrawUri({ bankIntegrationApiBaseUrl, withdrawalOperationId, diff --git a/packages/taler-wallet-webextension/src/NavigationBar.tsx b/packages/taler-wallet-webextension/src/NavigationBar.tsx index 0f74963bc..78a526997 100644 --- a/packages/taler-wallet-webextension/src/NavigationBar.tsx +++ b/packages/taler-wallet-webextension/src/NavigationBar.tsx @@ -152,7 +152,6 @@ const talerUriActionToPageName: { [TalerUriAction.PayTemplate]: "ctaPayTemplate", [TalerUriAction.WithdrawExchange]: "ctaWithdrawManual", [TalerUriAction.DevExperiment]: undefined, - [TalerUriAction.Reward]: undefined, }; export function getPathnameForTalerURI(talerUri: string): string | undefined { diff --git a/packages/taler-wallet-webextension/src/platform/chrome.ts b/packages/taler-wallet-webextension/src/platform/chrome.ts index 7b133969f..8c418d3c8 100644 --- a/packages/taler-wallet-webextension/src/platform/chrome.ts +++ b/packages/taler-wallet-webextension/src/platform/chrome.ts @@ -224,9 +224,6 @@ function openWalletURIFromPopup(uri: TalerUri): void { case TalerUriAction.DevExperiment: logger.warn(`taler://dev-experiment URIs are not allowed in headers`); return; - case TalerUriAction.Reward: - logger.warn(`taler://reward not supported anymore`); - break; default: { const error: never = uri; logger.warn( diff --git a/packages/taler-wallet-webextension/src/popup/TalerActionFound.tsx b/packages/taler-wallet-webextension/src/popup/TalerActionFound.tsx index 4251a1632..11a888412 100644 --- a/packages/taler-wallet-webextension/src/popup/TalerActionFound.tsx +++ b/packages/taler-wallet-webextension/src/popup/TalerActionFound.tsx @@ -82,7 +82,6 @@ function ContentByUriType({ case TalerUriAction.PayPull: case TalerUriAction.PayPush: case TalerUriAction.Restore: - case TalerUriAction.Reward: return null; default: { const error: never = uri; -- cgit v1.2.3