wallet-core: remove legacy operation names

This commit is contained in:
Florian Dold 2023-05-11 14:29:55 +02:00
parent edd3a39a0c
commit 359b9860a6
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
5 changed files with 21 additions and 40 deletions

View File

@ -2090,12 +2090,12 @@ export interface CheckPeerPushDebitResponse {
amountEffective: AmountString; amountEffective: AmountString;
} }
export interface InitiatePeerPushPaymentRequest { export interface InitiatePeerPushDebitRequest {
exchangeBaseUrl?: string; exchangeBaseUrl?: string;
partialContractTerms: PeerContractTerms; partialContractTerms: PeerContractTerms;
} }
export interface InitiatePeerPushPaymentResponse { export interface InitiatePeerPushDebitResponse {
exchangeBaseUrl: string; exchangeBaseUrl: string;
pursePub: string; pursePub: string;
mergePriv: string; mergePriv: string;
@ -2104,11 +2104,11 @@ export interface InitiatePeerPushPaymentResponse {
transactionId: string; transactionId: string;
} }
export const codecForInitiatePeerPushPaymentRequest = export const codecForInitiatePeerPushDebitRequest =
(): Codec<InitiatePeerPushPaymentRequest> => (): Codec<InitiatePeerPushDebitRequest> =>
buildCodecForObject<InitiatePeerPushPaymentRequest>() buildCodecForObject<InitiatePeerPushDebitRequest>()
.property("partialContractTerms", codecForPeerContractTerms()) .property("partialContractTerms", codecForPeerContractTerms())
.build("InitiatePeerPushPaymentRequest"); .build("InitiatePeerPushDebitRequest");
export interface PreparePeerPushCredit { export interface PreparePeerPushCredit {
talerUri: string; talerUri: string;

View File

@ -50,8 +50,8 @@ import {
getRandomBytes, getRandomBytes,
InitiatePeerPullCreditRequest, InitiatePeerPullCreditRequest,
InitiatePeerPullCreditResponse, InitiatePeerPullCreditResponse,
InitiatePeerPushPaymentRequest, InitiatePeerPushDebitRequest,
InitiatePeerPushPaymentResponse, InitiatePeerPushDebitResponse,
j2s, j2s,
Logger, Logger,
parsePayPullUri, parsePayPullUri,
@ -653,10 +653,10 @@ export async function processPeerPushDebit(
/** /**
* Initiate sending a peer-to-peer push payment. * Initiate sending a peer-to-peer push payment.
*/ */
export async function initiatePeerPushPayment( export async function initiatePeerPushDebit(
ws: InternalWalletState, ws: InternalWalletState,
req: InitiatePeerPushPaymentRequest, req: InitiatePeerPushDebitRequest,
): Promise<InitiatePeerPushPaymentResponse> { ): Promise<InitiatePeerPushDebitResponse> {
const instructedAmount = Amounts.parseOrThrow( const instructedAmount = Amounts.parseOrThrow(
req.partialContractTerms.amount, req.partialContractTerms.amount,
); );

View File

@ -54,7 +54,7 @@ import {
confirmPeerPullDebit, confirmPeerPullDebit,
confirmPeerPushCredit, confirmPeerPushCredit,
initiatePeerPullPayment, initiatePeerPullPayment,
initiatePeerPushPayment, initiatePeerPushDebit,
preparePeerPullDebit, preparePeerPullDebit,
preparePeerPushCredit, preparePeerPushCredit,
} from "./pay-peer.js"; } from "./pay-peer.js";
@ -532,7 +532,7 @@ export async function runIntegrationTest2(
await ws.runUntilDone(); await ws.runUntilDone();
const peerPushInit = await initiatePeerPushPayment(ws, { const peerPushInit = await initiatePeerPushDebit(ws, {
partialContractTerms: { partialContractTerms: {
amount: `${currency}:1`, amount: `${currency}:1`,
summary: "Payment Peer Push Test", summary: "Payment Peer Push Test",

View File

@ -67,8 +67,8 @@ import {
InitResponse, InitResponse,
InitiatePeerPullCreditRequest, InitiatePeerPullCreditRequest,
InitiatePeerPullCreditResponse, InitiatePeerPullCreditResponse,
InitiatePeerPushPaymentRequest, InitiatePeerPushDebitRequest,
InitiatePeerPushPaymentResponse, InitiatePeerPushDebitResponse,
IntegrationTestArgs, IntegrationTestArgs,
KnownBankAccounts, KnownBankAccounts,
ListKnownBankAccountsRequest, ListKnownBankAccountsRequest,
@ -671,8 +671,8 @@ export type CheckPeerPushDebitOp = {
*/ */
export type InitiatePeerPushDebitOp = { export type InitiatePeerPushDebitOp = {
op: WalletApiOperation.InitiatePeerPushDebit; op: WalletApiOperation.InitiatePeerPushDebit;
request: InitiatePeerPushPaymentRequest; request: InitiatePeerPushDebitRequest;
response: InitiatePeerPushPaymentResponse; response: InitiatePeerPushDebitResponse;
}; };
/** /**

View File

@ -80,7 +80,7 @@ import {
codecForGetWithdrawalDetailsForUri, codecForGetWithdrawalDetailsForUri,
codecForImportDbRequest, codecForImportDbRequest,
codecForInitiatePeerPullPaymentRequest, codecForInitiatePeerPullPaymentRequest,
codecForInitiatePeerPushPaymentRequest, codecForInitiatePeerPushDebitRequest,
codecForIntegrationTestArgs, codecForIntegrationTestArgs,
codecForIntegrationTestV2Args, codecForIntegrationTestV2Args,
codecForListKnownBankAccounts, codecForListKnownBankAccounts,
@ -202,7 +202,7 @@ import {
confirmPeerPullDebit, confirmPeerPullDebit,
confirmPeerPushCredit, confirmPeerPushCredit,
initiatePeerPullPayment, initiatePeerPullPayment,
initiatePeerPushPayment, initiatePeerPushDebit,
preparePeerPullDebit, preparePeerPullDebit,
preparePeerPushCredit, preparePeerPushCredit,
processPeerPullCredit, processPeerPullCredit,
@ -1443,8 +1443,8 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>(
return await checkPeerPushDebit(ws, req); return await checkPeerPushDebit(ws, req);
} }
case WalletApiOperation.InitiatePeerPushDebit: { case WalletApiOperation.InitiatePeerPushDebit: {
const req = codecForInitiatePeerPushPaymentRequest().decode(payload); const req = codecForInitiatePeerPushDebitRequest().decode(payload);
return await initiatePeerPushPayment(ws, req); return await initiatePeerPushDebit(ws, req);
} }
case WalletApiOperation.PreparePeerPushCredit: { case WalletApiOperation.PreparePeerPushCredit: {
const req = codecForPreparePeerPushCreditRequest().decode(payload); const req = codecForPreparePeerPushCreditRequest().decode(payload);
@ -1502,23 +1502,6 @@ export function getVersion(ws: InternalWalletState): WalletCoreVersion {
return version; 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. * Handle a request to the wallet-core API.
@ -1529,8 +1512,6 @@ export async function handleCoreApiRequest(
id: string, id: string,
payload: unknown, payload: unknown,
): Promise<CoreApiResponse> { ): Promise<CoreApiResponse> {
operation = translateLegacyOperationNames(operation);
try { try {
const result = await dispatchRequestInternal(ws, operation as any, payload); const result = await dispatchRequestInternal(ws, operation as any, payload);
return { return {