rename tip->reward in URI

This commit is contained in:
Florian Dold 2023-08-03 19:03:24 +02:00
parent 0b5d0cdc71
commit 57e86b759e
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
8 changed files with 25 additions and 25 deletions

View File

@ -21,7 +21,7 @@ import {
parsePayUri, parsePayUri,
parseRefundUri, parseRefundUri,
parseRestoreUri, parseRestoreUri,
parseTipUri, parseRewardUri,
parseWithdrawExchangeUri, parseWithdrawExchangeUri,
parseWithdrawUri, parseWithdrawUri,
stringifyPayPushUri, stringifyPayPushUri,
@ -161,7 +161,7 @@ test("taler refund uri parsing with instance", (t) => {
test("taler tip pickup uri", (t) => { test("taler tip pickup uri", (t) => {
const url1 = "taler://tip/merchant.example.com/tipid"; const url1 = "taler://tip/merchant.example.com/tipid";
const r1 = parseTipUri(url1); const r1 = parseRewardUri(url1);
if (!r1) { if (!r1) {
t.fail(); t.fail();
return; return;
@ -171,7 +171,7 @@ test("taler tip pickup uri", (t) => {
test("taler tip pickup uri with instance", (t) => { test("taler tip pickup uri with instance", (t) => {
const url1 = "taler://tip/merchant.example.com/instances/tipm/tipid"; const url1 = "taler://tip/merchant.example.com/instances/tipm/tipid";
const r1 = parseTipUri(url1); const r1 = parseRewardUri(url1);
if (!r1) { if (!r1) {
t.fail(); t.fail();
return; return;
@ -182,7 +182,7 @@ test("taler tip pickup uri with instance", (t) => {
test("taler tip pickup uri with instance and prefix", (t) => { test("taler tip pickup uri with instance and prefix", (t) => {
const url1 = "taler://tip/merchant.example.com/my/pfx/tipm/tipid"; const url1 = "taler://tip/merchant.example.com/my/pfx/tipm/tipid";
const r1 = parseTipUri(url1); const r1 = parseRewardUri(url1);
if (!r1) { if (!r1) {
t.fail(); t.fail();
return; return;

View File

@ -26,7 +26,7 @@ export type TalerUri =
| PayPushUriResult | PayPushUriResult
| BackupRestoreUri | BackupRestoreUri
| RefundUriResult | RefundUriResult
| TipUriResult | RewardUriResult
| WithdrawUriResult | WithdrawUriResult
| ExchangeUri | ExchangeUri
| WithdrawExchangeUri | WithdrawExchangeUri
@ -60,8 +60,8 @@ export interface RefundUriResult {
orderId: string; orderId: string;
} }
export interface TipUriResult { export interface RewardUriResult {
type: TalerUriAction.Tip; type: TalerUriAction.Reward;
merchantBaseUrl: string; merchantBaseUrl: string;
merchantTipId: string; merchantTipId: string;
} }
@ -167,7 +167,7 @@ export enum TalerUriAction {
Pay = "pay", Pay = "pay",
Withdraw = "withdraw", Withdraw = "withdraw",
Refund = "refund", Refund = "refund",
Tip = "tip", Reward = "reward",
PayPull = "pay-pull", PayPull = "pay-pull",
PayPush = "pay-push", PayPush = "pay-push",
PayTemplate = "pay-template", PayTemplate = "pay-template",
@ -212,7 +212,7 @@ const parsers: { [A in TalerUriAction]: Parser } = {
[TalerUriAction.PayTemplate]: parsePayTemplateUri, [TalerUriAction.PayTemplate]: parsePayTemplateUri,
[TalerUriAction.Restore]: parseRestoreUri, [TalerUriAction.Restore]: parseRestoreUri,
[TalerUriAction.Refund]: parseRefundUri, [TalerUriAction.Refund]: parseRefundUri,
[TalerUriAction.Tip]: parseTipUri, [TalerUriAction.Reward]: parseRewardUri,
[TalerUriAction.Withdraw]: parseWithdrawUri, [TalerUriAction.Withdraw]: parseWithdrawUri,
[TalerUriAction.DevExperiment]: parseDevExperimentUri, [TalerUriAction.DevExperiment]: parseDevExperimentUri,
[TalerUriAction.Exchange]: parseExchangeUri, [TalerUriAction.Exchange]: parseExchangeUri,
@ -255,8 +255,8 @@ export function stringifyTalerUri(uri: TalerUri): string {
case TalerUriAction.Refund: { case TalerUriAction.Refund: {
return stringifyRefundUri(uri); return stringifyRefundUri(uri);
} }
case TalerUriAction.Tip: { case TalerUriAction.Reward: {
return stringifyTipUri(uri); return stringifyRewardUri(uri);
} }
case TalerUriAction.Withdraw: { case TalerUriAction.Withdraw: {
return stringifyWithdrawUri(uri); return stringifyWithdrawUri(uri);
@ -394,11 +394,11 @@ export function parsePayPullUri(s: string): PayPullUriResult | undefined {
} }
/** /**
* Parse a taler[+http]://tip URI. * Parse a taler[+http]://reward URI.
* Return undefined if not passed a valid URI. * Return undefined if not passed a valid URI.
*/ */
export function parseTipUri(s: string): TipUriResult | undefined { export function parseRewardUri(s: string): RewardUriResult | undefined {
const pi = parseProtoInfo(s, "tip"); const pi = parseProtoInfo(s, "reward");
if (!pi) { if (!pi) {
return undefined; return undefined;
} }
@ -416,7 +416,7 @@ export function parseTipUri(s: string): TipUriResult | undefined {
); );
return { return {
type: TalerUriAction.Tip, type: TalerUriAction.Reward,
merchantBaseUrl, merchantBaseUrl,
merchantTipId: tipId, merchantTipId: tipId,
}; };
@ -699,12 +699,12 @@ export function stringifyRefundUri({
const { proto, path } = getUrlInfo(merchantBaseUrl); const { proto, path } = getUrlInfo(merchantBaseUrl);
return `${proto}://refund/${path}${orderId}`; return `${proto}://refund/${path}${orderId}`;
} }
export function stringifyTipUri({ export function stringifyRewardUri({
merchantBaseUrl, merchantBaseUrl,
merchantTipId, merchantTipId,
}: Omit<TipUriResult, "type">): string { }: Omit<RewardUriResult, "type">): string {
const { proto, path } = getUrlInfo(merchantBaseUrl); const { proto, path } = getUrlInfo(merchantBaseUrl);
return `${proto}://tip/${path}${merchantTipId}`; return `${proto}://reward/${path}${merchantTipId}`;
} }
export function stringifyExchangeUri({ export function stringifyExchangeUri({

View File

@ -651,7 +651,7 @@ walletCli
alwaysYes: args.handleUri.autoYes, alwaysYes: args.handleUri.autoYes,
}); });
break; break;
case TalerUriAction.Tip: { case TalerUriAction.Reward: {
const res = await wallet.client.call(WalletApiOperation.PrepareReward, { const res = await wallet.client.call(WalletApiOperation.PrepareReward, {
talerRewardUri: uri, talerRewardUri: uri,
}); });

View File

@ -31,7 +31,7 @@ import {
j2s, j2s,
Logger, Logger,
NotificationType, NotificationType,
parseTipUri, parseRewardUri,
PrepareTipResult, PrepareTipResult,
TalerErrorCode, TalerErrorCode,
TalerPreciseTimestamp, TalerPreciseTimestamp,
@ -141,7 +141,7 @@ export async function prepareTip(
ws: InternalWalletState, ws: InternalWalletState,
talerTipUri: string, talerTipUri: string,
): Promise<PrepareTipResult> { ): Promise<PrepareTipResult> {
const res = parseTipUri(talerTipUri); const res = parseRewardUri(talerTipUri);
if (!res) { if (!res) {
throw Error("invalid taler://tip URI"); throw Error("invalid taler://tip URI");
} }

View File

@ -146,7 +146,7 @@ const talerUriActionToPageName: {
} = { } = {
[TalerUriAction.Withdraw]: "ctaWithdraw", [TalerUriAction.Withdraw]: "ctaWithdraw",
[TalerUriAction.Pay]: "ctaPay", [TalerUriAction.Pay]: "ctaPay",
[TalerUriAction.Tip]: "ctaTips", [TalerUriAction.Reward]: "ctaTips",
[TalerUriAction.Refund]: "ctaRefund", [TalerUriAction.Refund]: "ctaRefund",
[TalerUriAction.PayPull]: "ctaInvoicePay", [TalerUriAction.PayPull]: "ctaInvoicePay",
[TalerUriAction.PayPush]: "ctaTransferPickup", [TalerUriAction.PayPush]: "ctaTransferPickup",

View File

@ -279,7 +279,7 @@ function openWalletURIFromPopup(uri: TalerUri): void {
`static/wallet.html#/cta/pay?talerUri=${encodeURIComponent(talerUri)}`, `static/wallet.html#/cta/pay?talerUri=${encodeURIComponent(talerUri)}`,
); );
break; break;
case TalerUriAction.Tip: case TalerUriAction.Reward:
url = chrome.runtime.getURL( url = chrome.runtime.getURL(
`static/wallet.html#/cta/tip?talerUri=${encodeURIComponent(talerUri)}`, `static/wallet.html#/cta/tip?talerUri=${encodeURIComponent(talerUri)}`,
); );

View File

@ -65,7 +65,7 @@ function ContentByUriType({
</Button> </Button>
</div> </div>
); );
case TalerUriAction.Tip: case TalerUriAction.Reward:
return ( return (
<div> <div>
<p> <p>

View File

@ -66,7 +66,7 @@ export function AddNewActionView({ onCancel }: Props): VNode {
return <i18n.Translate>Open pay page</i18n.Translate>; return <i18n.Translate>Open pay page</i18n.Translate>;
case TalerUriAction.Refund: case TalerUriAction.Refund:
return <i18n.Translate>Open refund page</i18n.Translate>; return <i18n.Translate>Open refund page</i18n.Translate>;
case TalerUriAction.Tip: case TalerUriAction.Reward:
return <i18n.Translate>Open tip page</i18n.Translate>; return <i18n.Translate>Open tip page</i18n.Translate>;
case TalerUriAction.Withdraw: case TalerUriAction.Withdraw:
return <i18n.Translate>Open withdraw page</i18n.Translate>; return <i18n.Translate>Open withdraw page</i18n.Translate>;