wallet-core: remove legacy operation names
This commit is contained in:
parent
edd3a39a0c
commit
359b9860a6
@ -2090,12 +2090,12 @@ export interface CheckPeerPushDebitResponse {
|
||||
amountEffective: AmountString;
|
||||
}
|
||||
|
||||
export interface InitiatePeerPushPaymentRequest {
|
||||
export interface InitiatePeerPushDebitRequest {
|
||||
exchangeBaseUrl?: string;
|
||||
partialContractTerms: PeerContractTerms;
|
||||
}
|
||||
|
||||
export interface InitiatePeerPushPaymentResponse {
|
||||
export interface InitiatePeerPushDebitResponse {
|
||||
exchangeBaseUrl: string;
|
||||
pursePub: string;
|
||||
mergePriv: string;
|
||||
@ -2104,11 +2104,11 @@ export interface InitiatePeerPushPaymentResponse {
|
||||
transactionId: string;
|
||||
}
|
||||
|
||||
export const codecForInitiatePeerPushPaymentRequest =
|
||||
(): Codec<InitiatePeerPushPaymentRequest> =>
|
||||
buildCodecForObject<InitiatePeerPushPaymentRequest>()
|
||||
export const codecForInitiatePeerPushDebitRequest =
|
||||
(): Codec<InitiatePeerPushDebitRequest> =>
|
||||
buildCodecForObject<InitiatePeerPushDebitRequest>()
|
||||
.property("partialContractTerms", codecForPeerContractTerms())
|
||||
.build("InitiatePeerPushPaymentRequest");
|
||||
.build("InitiatePeerPushDebitRequest");
|
||||
|
||||
export interface PreparePeerPushCredit {
|
||||
talerUri: string;
|
||||
|
@ -50,8 +50,8 @@ import {
|
||||
getRandomBytes,
|
||||
InitiatePeerPullCreditRequest,
|
||||
InitiatePeerPullCreditResponse,
|
||||
InitiatePeerPushPaymentRequest,
|
||||
InitiatePeerPushPaymentResponse,
|
||||
InitiatePeerPushDebitRequest,
|
||||
InitiatePeerPushDebitResponse,
|
||||
j2s,
|
||||
Logger,
|
||||
parsePayPullUri,
|
||||
@ -653,10 +653,10 @@ export async function processPeerPushDebit(
|
||||
/**
|
||||
* Initiate sending a peer-to-peer push payment.
|
||||
*/
|
||||
export async function initiatePeerPushPayment(
|
||||
export async function initiatePeerPushDebit(
|
||||
ws: InternalWalletState,
|
||||
req: InitiatePeerPushPaymentRequest,
|
||||
): Promise<InitiatePeerPushPaymentResponse> {
|
||||
req: InitiatePeerPushDebitRequest,
|
||||
): Promise<InitiatePeerPushDebitResponse> {
|
||||
const instructedAmount = Amounts.parseOrThrow(
|
||||
req.partialContractTerms.amount,
|
||||
);
|
||||
|
@ -54,7 +54,7 @@ import {
|
||||
confirmPeerPullDebit,
|
||||
confirmPeerPushCredit,
|
||||
initiatePeerPullPayment,
|
||||
initiatePeerPushPayment,
|
||||
initiatePeerPushDebit,
|
||||
preparePeerPullDebit,
|
||||
preparePeerPushCredit,
|
||||
} from "./pay-peer.js";
|
||||
@ -532,7 +532,7 @@ export async function runIntegrationTest2(
|
||||
|
||||
await ws.runUntilDone();
|
||||
|
||||
const peerPushInit = await initiatePeerPushPayment(ws, {
|
||||
const peerPushInit = await initiatePeerPushDebit(ws, {
|
||||
partialContractTerms: {
|
||||
amount: `${currency}:1`,
|
||||
summary: "Payment Peer Push Test",
|
||||
|
@ -67,8 +67,8 @@ import {
|
||||
InitResponse,
|
||||
InitiatePeerPullCreditRequest,
|
||||
InitiatePeerPullCreditResponse,
|
||||
InitiatePeerPushPaymentRequest,
|
||||
InitiatePeerPushPaymentResponse,
|
||||
InitiatePeerPushDebitRequest,
|
||||
InitiatePeerPushDebitResponse,
|
||||
IntegrationTestArgs,
|
||||
KnownBankAccounts,
|
||||
ListKnownBankAccountsRequest,
|
||||
@ -671,8 +671,8 @@ export type CheckPeerPushDebitOp = {
|
||||
*/
|
||||
export type InitiatePeerPushDebitOp = {
|
||||
op: WalletApiOperation.InitiatePeerPushDebit;
|
||||
request: InitiatePeerPushPaymentRequest;
|
||||
response: InitiatePeerPushPaymentResponse;
|
||||
request: InitiatePeerPushDebitRequest;
|
||||
response: InitiatePeerPushDebitResponse;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -80,7 +80,7 @@ import {
|
||||
codecForGetWithdrawalDetailsForUri,
|
||||
codecForImportDbRequest,
|
||||
codecForInitiatePeerPullPaymentRequest,
|
||||
codecForInitiatePeerPushPaymentRequest,
|
||||
codecForInitiatePeerPushDebitRequest,
|
||||
codecForIntegrationTestArgs,
|
||||
codecForIntegrationTestV2Args,
|
||||
codecForListKnownBankAccounts,
|
||||
@ -202,7 +202,7 @@ import {
|
||||
confirmPeerPullDebit,
|
||||
confirmPeerPushCredit,
|
||||
initiatePeerPullPayment,
|
||||
initiatePeerPushPayment,
|
||||
initiatePeerPushDebit,
|
||||
preparePeerPullDebit,
|
||||
preparePeerPushCredit,
|
||||
processPeerPullCredit,
|
||||
@ -1443,8 +1443,8 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>(
|
||||
return await checkPeerPushDebit(ws, req);
|
||||
}
|
||||
case WalletApiOperation.InitiatePeerPushDebit: {
|
||||
const req = codecForInitiatePeerPushPaymentRequest().decode(payload);
|
||||
return await initiatePeerPushPayment(ws, req);
|
||||
const req = codecForInitiatePeerPushDebitRequest().decode(payload);
|
||||
return await initiatePeerPushDebit(ws, req);
|
||||
}
|
||||
case WalletApiOperation.PreparePeerPushCredit: {
|
||||
const req = codecForPreparePeerPushCreditRequest().decode(payload);
|
||||
@ -1502,23 +1502,6 @@ 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.
|
||||
@ -1529,8 +1512,6 @@ export async function handleCoreApiRequest(
|
||||
id: string,
|
||||
payload: unknown,
|
||||
): Promise<CoreApiResponse> {
|
||||
operation = translateLegacyOperationNames(operation);
|
||||
|
||||
try {
|
||||
const result = await dispatchRequestInternal(ws, operation as any, payload);
|
||||
return {
|
||||
|
Loading…
Reference in New Issue
Block a user