aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-02-20 01:44:28 +0100
committerFlorian Dold <florian@dold.me>2023-02-20 01:44:28 +0100
commit803d1bf7a7aa6b38771510b0d762d40c5487422b (patch)
tree3020bc28cc7f95e32fc1fcb5fd5f5706220c195f
parentfddc6eb4f21e7b85f089d5bf532580c3da874d54 (diff)
wallet-core: rename ops with support for old names
-rw-r--r--packages/taler-util/src/wallet-types.ts10
-rw-r--r--packages/taler-wallet-core/src/operations/pay-peer.ts8
-rw-r--r--packages/taler-wallet-core/src/wallet-api-types.ts28
-rw-r--r--packages/taler-wallet-core/src/wallet.ts44
4 files changed, 53 insertions, 37 deletions
diff --git a/packages/taler-util/src/wallet-types.ts b/packages/taler-util/src/wallet-types.ts
index dc683a232..86db8bdcc 100644
--- a/packages/taler-util/src/wallet-types.ts
+++ b/packages/taler-util/src/wallet-types.ts
@@ -2044,7 +2044,7 @@ export interface CheckPeerPushDebitRequest {
amount: AmountString;
}
-export const codecForPreparePeerPushPaymentRequest =
+export const codecForCheckPeerPushDebitRequest =
(): Codec<CheckPeerPushDebitRequest> =>
buildCodecForObject<CheckPeerPushDebitRequest>()
.property("exchangeBaseUrl", codecOptional(codecForString()))
@@ -2076,7 +2076,7 @@ export const codecForInitiatePeerPushPaymentRequest =
.property("partialContractTerms", codecForPeerContractTerms())
.build("InitiatePeerPushPaymentRequest");
-export interface CheckPeerPushPaymentRequest {
+export interface PreparePeerPushCredit {
talerUri: string;
}
@@ -2103,9 +2103,9 @@ export interface PreparePeerPullDebitResponse {
peerPullPaymentIncomingId: string;
}
-export const codecForCheckPeerPushPaymentRequest =
- (): Codec<CheckPeerPushPaymentRequest> =>
- buildCodecForObject<CheckPeerPushPaymentRequest>()
+export const codecForPreparePeerPushCreditRequest =
+ (): Codec<PreparePeerPushCredit> =>
+ buildCodecForObject<PreparePeerPushCredit>()
.property("talerUri", codecForString())
.build("CheckPeerPushPaymentRequest");
diff --git a/packages/taler-wallet-core/src/operations/pay-peer.ts b/packages/taler-wallet-core/src/operations/pay-peer.ts
index ed4e57eea..ef2c19c33 100644
--- a/packages/taler-wallet-core/src/operations/pay-peer.ts
+++ b/packages/taler-wallet-core/src/operations/pay-peer.ts
@@ -30,7 +30,7 @@ import {
buildCodecForObject,
PreparePeerPullDebitRequest,
PreparePeerPullDebitResponse,
- CheckPeerPushPaymentRequest,
+ PreparePeerPushCredit,
CheckPeerPushPaymentResponse,
Codec,
codecForAmountString,
@@ -387,7 +387,7 @@ export async function getTotalPeerPaymentCost(
});
}
-export async function preparePeerPushPayment(
+export async function checkPeerPushDebit(
ws: InternalWalletState,
req: CheckPeerPushDebitRequest,
): Promise<CheckPeerPushDebitResponse> {
@@ -622,7 +622,7 @@ export const codecForExchangePurseStatus = (): Codec<ExchangePurseStatus> =>
export async function preparePeerPushCredit(
ws: InternalWalletState,
- req: CheckPeerPushPaymentRequest,
+ req: PreparePeerPushCredit,
): Promise<CheckPeerPushPaymentResponse> {
const uri = parsePayPushUri(req.talerUri);
@@ -898,7 +898,7 @@ export async function processPeerPushCredit(
};
}
-export async function acceptPeerPushPayment(
+export async function confirmPeerPushPayment(
ws: InternalWalletState,
req: ConfirmPeerPushCreditRequest,
): Promise<AcceptPeerPushPaymentResponse> {
diff --git a/packages/taler-wallet-core/src/wallet-api-types.ts b/packages/taler-wallet-core/src/wallet-api-types.ts
index 67e9169cf..39d3f3d1f 100644
--- a/packages/taler-wallet-core/src/wallet-api-types.ts
+++ b/packages/taler-wallet-core/src/wallet-api-types.ts
@@ -44,7 +44,7 @@ import {
BalancesResponse,
PreparePeerPullDebitRequest,
PreparePeerPullDebitResponse,
- CheckPeerPushPaymentRequest,
+ PreparePeerPushCredit,
CheckPeerPushPaymentResponse,
CoinDumpJson,
ConfirmPayRequest,
@@ -183,22 +183,14 @@ export enum WalletApiOperation {
WithdrawFakebank = "withdrawFakebank",
ImportDb = "importDb",
ExportDb = "exportDb",
- // FIXME: Also rename enum value
- CheckPeerPushDebit = "preparePeerPushPayment",
- // FIXME: Also rename enum value
- InitiatePeerPushDebit = "initiatePeerPushPayment",
- // FIXME: Also rename enum value
- PreparePeerPushCredit = "checkPeerPushPayment",
- // FIXME: Also rename enum value
- ConfirmPeerPushCredit = "acceptPeerPushPayment",
- // FIXME: Also rename enum value
- CheckPeerPullCredit = "preparePeerPullPayment",
- // FIXME: Also rename enum value
- InitiatePeerPullCredit = "initiatePeerPullPayment",
- // FIXME: Also rename enum value
- PreparePeerPullDebit = "checkPeerPullPayment",
- // FIXME: Also rename enum value
- ConfirmPeerPullDebit = "acceptPeerPullPayment",
+ PreparePeerPushCredit = "preparePeerPushCredit",
+ CheckPeerPushDebit = "checkPeerPushDebit",
+ InitiatePeerPushDebit = "initiatePeerPushDebit",
+ ConfirmPeerPushCredit = "confirmPeerPushCredit",
+ CheckPeerPullCredit = "checkPeerPullCredit",
+ InitiatePeerPullCredit = "initiatePeerPullCredit",
+ PreparePeerPullDebit = "preparePeerPullDebit",
+ ConfirmPeerPullDebit = "confirmPeerPullDebit",
ClearDb = "clearDb",
Recycle = "recycle",
SetDevMode = "setDevMode",
@@ -622,7 +614,7 @@ export type InitiatePeerPushDebitOp = {
*/
export type PreparePeerPushCreditOp = {
op: WalletApiOperation.PreparePeerPushCredit;
- request: CheckPeerPushPaymentRequest;
+ request: PreparePeerPushCredit;
response: CheckPeerPushPaymentResponse;
};
diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts
index b7ba1a386..4b979c861 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -30,7 +30,7 @@ import {
codecForAcceptExchangeTosRequest,
codecForAcceptManualWithdrawalRequet,
codecForAcceptPeerPullPaymentRequest,
- codecForAcceptPeerPushPaymentRequest,
+ codecForAcceptPeerPushPaymentRequest as codecForConfirmPeerPushPaymentRequest,
codecForAcceptTipRequest,
codecForAddExchangeRequest,
codecForAddKnownBankAccounts,
@@ -39,7 +39,7 @@ import {
codecForApplyRefundFromPurchaseIdRequest,
codecForApplyRefundRequest,
codecForCheckPeerPullPaymentRequest,
- codecForCheckPeerPushPaymentRequest,
+ codecForPreparePeerPushCreditRequest,
codecForConfirmPayRequest,
codecForCreateDepositGroupRequest,
codecForDeleteTransactionRequest,
@@ -61,7 +61,7 @@ import {
codecForPreparePayRequest,
codecForPreparePayTemplateRequest,
codecForPreparePeerPullPaymentRequest,
- codecForPreparePeerPushPaymentRequest,
+ codecForCheckPeerPushDebitRequest,
codecForPrepareRefundRequest,
codecForPrepareTipRequest,
codecForRetryTransactionRequest,
@@ -196,13 +196,13 @@ import {
} from "./operations/pay-merchant.js";
import {
acceptIncomingPeerPullPayment,
- acceptPeerPushPayment,
+ confirmPeerPushPayment,
preparePeerPullCredit,
preparePeerPushCredit,
initiatePeerPullPayment,
initiatePeerPushPayment,
checkPeerPullPaymentInitiation,
- preparePeerPushPayment,
+ checkPeerPushDebit,
processPeerPullCredit,
processPeerPushInitiation,
processPeerPullDebit,
@@ -1428,21 +1428,25 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>(
await importDb(ws.db.idbHandle(), req.dump);
return [];
}
+ case WalletApiOperation.CheckPeerPushDebit: {
+ const req = codecForCheckPeerPushDebitRequest().decode(payload);
+ return await checkPeerPushDebit(ws, req);
+ }
case WalletApiOperation.PreparePeerPushCredit: {
- const req = codecForPreparePeerPushPaymentRequest().decode(payload);
- return await preparePeerPushPayment(ws, req);
+ const req = codecForPreparePeerPushCreditRequest().decode(payload);
+ return await preparePeerPushCredit(ws, req);
}
case WalletApiOperation.InitiatePeerPushDebit: {
const req = codecForInitiatePeerPushPaymentRequest().decode(payload);
return await initiatePeerPushPayment(ws, req);
}
case WalletApiOperation.PreparePeerPushCredit: {
- const req = codecForCheckPeerPushPaymentRequest().decode(payload);
+ const req = codecForPreparePeerPushCreditRequest().decode(payload);
return await preparePeerPushCredit(ws, req);
}
case WalletApiOperation.ConfirmPeerPushCredit: {
- const req = codecForAcceptPeerPushPaymentRequest().decode(payload);
- return await acceptPeerPushPayment(ws, req);
+ const req = codecForConfirmPeerPushPaymentRequest().decode(payload);
+ return await confirmPeerPushPayment(ws, req);
}
case WalletApiOperation.CheckPeerPullCredit: {
const req = codecForPreparePeerPullPaymentRequest().decode(payload);
@@ -1497,6 +1501,24 @@ export function getVersion(ws: InternalWalletState): WalletCoreVersion {
return version;
}
+function translateLegacyOperationNames(operation: string): string {
+ switch (operation) {
+ case "initiatePeerPullPayment":
+ return WalletApiOperation.InitiatePeerPullCredit.toString();
+ case "initiatePeerPushPayment":
+ return WalletApiOperation.InitiatePeerPushDebit.toString();
+ case "checkPeerPullPayment":
+ return WalletApiOperation.PreparePeerPullDebit.toString();
+ case "acceptPeerPullPayment":
+ return WalletApiOperation.ConfirmPeerPullDebit.toString();
+ case "checkPeerPushPayment":
+ return WalletApiOperation.PreparePeerPushCredit.toString();
+ case "acceptPeerPushPayment":
+ return WalletApiOperation.ConfirmPeerPushCredit.toString();
+ }
+ return operation;
+}
+
/**
* Handle a request to the wallet-core API.
*/
@@ -1506,6 +1528,8 @@ export async function handleCoreApiRequest(
id: string,
payload: unknown,
): Promise<CoreApiResponse> {
+ operation = translateLegacyOperationNames(operation);
+
try {
const result = await dispatchRequestInternal(ws, operation as any, payload);
return {