diff options
author | Florian Dold <florian@dold.me> | 2023-02-20 01:44:28 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-02-20 01:44:28 +0100 |
commit | 803d1bf7a7aa6b38771510b0d762d40c5487422b (patch) | |
tree | 3020bc28cc7f95e32fc1fcb5fd5f5706220c195f /packages/taler-wallet-core/src/wallet.ts | |
parent | fddc6eb4f21e7b85f089d5bf532580c3da874d54 (diff) | |
download | wallet-core-803d1bf7a7aa6b38771510b0d762d40c5487422b.tar.xz |
wallet-core: rename ops with support for old names
Diffstat (limited to 'packages/taler-wallet-core/src/wallet.ts')
-rw-r--r-- | packages/taler-wallet-core/src/wallet.ts | 44 |
1 files changed, 34 insertions, 10 deletions
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 { |