taler-util: remove deprecated function

This commit is contained in:
Florian Dold 2023-05-11 14:16:48 +02:00
parent 1d718dda1d
commit edd3a39a0c
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
3 changed files with 49 additions and 110 deletions

View File

@ -19,11 +19,9 @@
* @author Sebastian Javier Marchano (sebasjm)
*/
import { buildPayto, classifyTalerUri } from "@gnu-taler/taler-util";
import { useTranslationContext } from "@gnu-taler/web-util/browser";
import { h, VNode } from "preact";
import { useState } from "preact/hooks";
import { AsyncButton } from "../../../../components/exception/AsyncButton.js";
import { QR } from "../../../../components/exception/QR.js";
import {
FormErrors,

View File

@ -168,66 +168,6 @@ export enum TalerUriAction {
DevExperiment = "dev-experiment",
}
/**
* Classify a taler:// URI.
* @deprecated use parseTalerUri
*/
export function classifyTalerUri(s: string): TalerUriType {
const sl = s.toLowerCase();
if (sl.startsWith("taler://restore/")) {
return TalerUriType.TalerRecovery;
}
if (sl.startsWith("taler+http://restore/")) {
return TalerUriType.TalerRecovery;
}
if (sl.startsWith("taler://pay/")) {
return TalerUriType.TalerPay;
}
if (sl.startsWith("taler+http://pay/")) {
return TalerUriType.TalerPay;
}
if (sl.startsWith("taler://pay-template/")) {
return TalerUriType.TalerPayTemplate;
}
if (sl.startsWith("taler+http://pay-template/")) {
return TalerUriType.TalerPayTemplate;
}
if (sl.startsWith("taler://tip/")) {
return TalerUriType.TalerTip;
}
if (sl.startsWith("taler+http://tip/")) {
return TalerUriType.TalerTip;
}
if (sl.startsWith("taler://refund/")) {
return TalerUriType.TalerRefund;
}
if (sl.startsWith("taler+http://refund/")) {
return TalerUriType.TalerRefund;
}
if (sl.startsWith("taler://withdraw/")) {
return TalerUriType.TalerWithdraw;
}
if (sl.startsWith("taler+http://withdraw/")) {
return TalerUriType.TalerWithdraw;
}
if (sl.startsWith(`taler://${talerActionPayPush}/`)) {
return TalerUriType.TalerPayPush;
}
if (sl.startsWith(`taler+http://${talerActionPayPush}/`)) {
return TalerUriType.TalerPayPush;
}
if (sl.startsWith(`taler://${talerActionPayPull}/`)) {
return TalerUriType.TalerPayPull;
}
if (sl.startsWith(`taler+http://${talerActionPayPull}/`)) {
return TalerUriType.TalerPayPull;
}
if (sl.startsWith("taler://dev-experiment/")) {
return TalerUriType.TalerDevExperiment;
}
return TalerUriType.Unknown;
}
interface TalerUriProtoInfo {
innerProto: "http" | "https";
rest: string;

View File

@ -21,7 +21,6 @@ import {
AbsoluteTime,
addPaytoQueryParams,
AgeRestriction,
classifyTalerUri,
codecForList,
codecForString,
CoreApiResponse,
@ -32,13 +31,14 @@ import {
j2s,
Logger,
parsePaytoUri,
parseTalerUri,
PreparePayResultType,
RecoveryMergeStrategy,
sampleWalletCoreTransactions,
setDangerousTimetravel,
setGlobalLogLevelFromString,
summarizeTalerErrorDetail,
TalerUriType,
TalerUriAction,
WalletNotification,
} from "@gnu-taler/taler-util";
import { clk } from "@gnu-taler/taler-util/clk";
@ -639,70 +639,68 @@ walletCli
} else {
uri = await readlinePrompt("Taler URI: ");
}
const uriType = classifyTalerUri(uri);
switch (uriType) {
case TalerUriType.TalerPay:
const parsedTalerUri = parseTalerUri(uri);
if (!parsedTalerUri) {
throw Error("invalid taler URI");
}
switch (parsedTalerUri.type) {
case TalerUriAction.Pay:
await doPay(wallet.client, uri, {
alwaysYes: args.handleUri.autoYes,
});
break;
case TalerUriType.TalerTip:
{
const res = await wallet.client.call(
WalletApiOperation.PrepareTip,
{
talerTipUri: uri,
},
);
console.log("tip status", res);
await wallet.client.call(WalletApiOperation.AcceptTip, {
walletTipId: res.walletTipId,
});
}
case TalerUriAction.Tip: {
const res = await wallet.client.call(WalletApiOperation.PrepareTip, {
talerTipUri: uri,
});
console.log("tip status", res);
await wallet.client.call(WalletApiOperation.AcceptTip, {
walletTipId: res.walletTipId,
});
break;
case TalerUriType.TalerRefund:
}
case TalerUriAction.Refund:
await wallet.client.call(WalletApiOperation.StartRefundQueryForUri, {
talerRefundUri: uri,
});
break;
case TalerUriType.TalerWithdraw:
{
const withdrawInfo = await wallet.client.call(
WalletApiOperation.GetWithdrawalDetailsForUri,
{
talerWithdrawUri: uri,
restrictAge: args.handleUri.restrictAge,
},
case TalerUriAction.Withdraw: {
const withdrawInfo = await wallet.client.call(
WalletApiOperation.GetWithdrawalDetailsForUri,
{
talerWithdrawUri: uri,
restrictAge: args.handleUri.restrictAge,
},
);
console.log("withdrawInfo", withdrawInfo);
const selectedExchange =
args.handleUri.withdrawalExchange ??
withdrawInfo.defaultExchangeBaseUrl;
if (!selectedExchange) {
console.error(
"no exchange specified for withdrawal (and no exchange suggested by the bank)",
);
console.log("withdrawInfo", withdrawInfo);
const selectedExchange =
args.handleUri.withdrawalExchange ??
withdrawInfo.defaultExchangeBaseUrl;
if (!selectedExchange) {
console.error(
"no exchange specified for withdrawal (and no exchange suggested by the bank)",
);
processExit(1);
return;
}
const res = await wallet.client.call(
WalletApiOperation.AcceptBankIntegratedWithdrawal,
{
exchangeBaseUrl: selectedExchange,
talerWithdrawUri: uri,
},
);
console.log("accept withdrawal response", res);
processExit(1);
return;
}
const res = await wallet.client.call(
WalletApiOperation.AcceptBankIntegratedWithdrawal,
{
exchangeBaseUrl: selectedExchange,
talerWithdrawUri: uri,
},
);
console.log("accept withdrawal response", res);
break;
case TalerUriType.TalerDevExperiment: {
}
case TalerUriAction.DevExperiment: {
await wallet.client.call(WalletApiOperation.ApplyDevExperiment, {
devExperimentUri: uri,
});
break;
}
default:
console.log(`URI type (${uriType}) not handled`);
console.log(`URI type (${parsedTalerUri}) not handled`);
break;
}
return;
@ -1683,3 +1681,6 @@ async function read(stream: NodeJS.ReadStream) {
export function main() {
walletCli.run();
}
function classifyTalerUri(uri: string) {
throw new Error("Function not implemented.");
}