wallet-core: implement request to return sample transactions

This commit is contained in:
Florian Dold 2023-05-25 12:19:00 +02:00
parent 0b4d900088
commit a4112bae9e
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
2 changed files with 14 additions and 1 deletions

View File

@ -133,6 +133,7 @@ export enum WalletApiOperation {
AddExchange = "addExchange", AddExchange = "addExchange",
GetTransactions = "getTransactions", GetTransactions = "getTransactions",
GetTransactionById = "getTransactionById", GetTransactionById = "getTransactionById",
TestingGetSampleTransactions = "testingGetSampleTransactions",
ListExchanges = "listExchanges", ListExchanges = "listExchanges",
ListKnownBankAccounts = "listKnownBankAccounts", ListKnownBankAccounts = "listKnownBankAccounts",
AddKnownBankAccounts = "addKnownBankAccounts", AddKnownBankAccounts = "addKnownBankAccounts",
@ -285,6 +286,15 @@ export type GetTransactionsOp = {
response: TransactionsResponse; response: TransactionsResponse;
}; };
/**
* Get sample transactions.
*/
export type TestingGetSampleTransactionsOp = {
op: WalletApiOperation.TestingGetSampleTransactions;
request: EmptyObject;
response: TransactionsResponse;
};
export type GetTransactionByIdOp = { export type GetTransactionByIdOp = {
op: WalletApiOperation.GetTransactionById; op: WalletApiOperation.GetTransactionById;
request: TransactionByIdRequest; request: TransactionByIdRequest;
@ -932,6 +942,7 @@ export type WalletOperations = {
[WalletApiOperation.GetBalances]: GetBalancesOp; [WalletApiOperation.GetBalances]: GetBalancesOp;
[WalletApiOperation.GetBalanceDetail]: GetBalancesDetailOp; [WalletApiOperation.GetBalanceDetail]: GetBalancesDetailOp;
[WalletApiOperation.GetTransactions]: GetTransactionsOp; [WalletApiOperation.GetTransactions]: GetTransactionsOp;
[WalletApiOperation.TestingGetSampleTransactions]: TestingGetSampleTransactionsOp;
[WalletApiOperation.GetTransactionById]: GetTransactionByIdOp; [WalletApiOperation.GetTransactionById]: GetTransactionByIdOp;
[WalletApiOperation.RetryPendingNow]: RetryPendingNowOp; [WalletApiOperation.RetryPendingNow]: RetryPendingNowOp;
[WalletApiOperation.GetPendingOperations]: GetPendingTasksOp; [WalletApiOperation.GetPendingOperations]: GetPendingTasksOp;

View File

@ -113,6 +113,7 @@ import {
j2s, j2s,
parsePayTemplateUri, parsePayTemplateUri,
parsePaytoUri, parsePaytoUri,
sampleWalletCoreTransactions,
validateIban, validateIban,
} from "@gnu-taler/taler-util"; } from "@gnu-taler/taler-util";
import { import {
@ -1241,6 +1242,8 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>(
await setCoinSuspended(ws, req.coinPub, req.suspended); await setCoinSuspended(ws, req.coinPub, req.suspended);
return {}; return {};
} }
case WalletApiOperation.TestingGetSampleTransactions:
return { transactions: sampleWalletCoreTransactions };
case WalletApiOperation.ForceRefresh: { case WalletApiOperation.ForceRefresh: {
const req = codecForForceRefreshRequest().decode(payload); const req = codecForForceRefreshRequest().decode(payload);
if (req.coinPubList.length == 0) { if (req.coinPubList.length == 0) {
@ -1507,7 +1510,6 @@ export function getVersion(ws: InternalWalletState): WalletCoreVersion {
return version; return version;
} }
/** /**
* Handle a request to the wallet-core API. * Handle a request to the wallet-core API.
*/ */