wallet-core: implement explicit updateExchangeEntry request

This commit is contained in:
Florian Dold 2023-10-02 22:48:29 +02:00
parent e54df1f167
commit 671bbf2954
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
3 changed files with 28 additions and 2 deletions

View File

@ -1601,6 +1601,15 @@ export const codecForAddExchangeRequest = (): Codec<AddExchangeRequest> =>
.property("masterPub", codecOptional(codecForString())) .property("masterPub", codecOptional(codecForString()))
.build("AddExchangeRequest"); .build("AddExchangeRequest");
export interface UpdateExchangeEntryRequest {
exchangeBaseUrl: string;
}
export const codecForUpdateExchangeEntryRequest = (): Codec<UpdateExchangeEntryRequest> =>
buildCodecForObject<UpdateExchangeEntryRequest>()
.property("exchangeBaseUrl", codecForString())
.build("UpdateExchangeEntryRequest");
export interface ForceExchangeUpdateRequest { export interface ForceExchangeUpdateRequest {
exchangeBaseUrl: string; exchangeBaseUrl: string;
} }

View File

@ -110,6 +110,7 @@ import {
TransactionsRequest, TransactionsRequest,
TransactionsResponse, TransactionsResponse,
TxIdResponse, TxIdResponse,
UpdateExchangeEntryRequest,
UserAttentionByIdRequest, UserAttentionByIdRequest,
UserAttentionsCountResponse, UserAttentionsCountResponse,
UserAttentionsRequest, UserAttentionsRequest,
@ -222,6 +223,7 @@ export enum WalletApiOperation {
CreateStoredBackup = "createStoredBackup", CreateStoredBackup = "createStoredBackup",
DeleteStoredBackup = "deleteStoredBackup", DeleteStoredBackup = "deleteStoredBackup",
RecoverStoredBackup = "recoverStoredBackup", RecoverStoredBackup = "recoverStoredBackup",
UpdateExchangeEntry = "updateExchangeEntry",
} }
// group: Initialization // group: Initialization
@ -557,6 +559,15 @@ export type AddExchangeOp = {
response: EmptyObject; response: EmptyObject;
}; };
/**
* Update an exchange entry.
*/
export type UpdateExchangeEntryOp = {
op: WalletApiOperation.UpdateExchangeEntry;
request: UpdateExchangeEntryRequest;
response: EmptyObject;
};
export type ListKnownBankAccountsOp = { export type ListKnownBankAccountsOp = {
op: WalletApiOperation.ListKnownBankAccounts; op: WalletApiOperation.ListKnownBankAccounts;
request: ListKnownBankAccountsRequest; request: ListKnownBankAccountsRequest;
@ -1125,6 +1136,7 @@ export type WalletOperations = {
[WalletApiOperation.ListStoredBackups]: ListStoredBackupsOp; [WalletApiOperation.ListStoredBackups]: ListStoredBackupsOp;
[WalletApiOperation.DeleteStoredBackup]: DeleteStoredBackupOp; [WalletApiOperation.DeleteStoredBackup]: DeleteStoredBackupOp;
[WalletApiOperation.RecoverStoredBackup]: RecoverStoredBackupsOp; [WalletApiOperation.RecoverStoredBackup]: RecoverStoredBackupsOp;
[WalletApiOperation.UpdateExchangeEntry]: UpdateExchangeEntryOp;
}; };
export type WalletCoreRequestType< export type WalletCoreRequestType<

View File

@ -128,6 +128,7 @@ import {
codecForTestingSetTimetravelRequest, codecForTestingSetTimetravelRequest,
setDangerousTimetravel, setDangerousTimetravel,
TestingWaitTransactionRequest, TestingWaitTransactionRequest,
codecForUpdateExchangeEntryRequest,
} from "@gnu-taler/taler-util"; } from "@gnu-taler/taler-util";
import type { HttpRequestLibrary } from "@gnu-taler/taler-util/http"; import type { HttpRequestLibrary } from "@gnu-taler/taler-util/http";
import { readSuccessResponseJsonOrThrow } from "@gnu-taler/taler-util/http"; import { readSuccessResponseJsonOrThrow } from "@gnu-taler/taler-util/http";
@ -1071,8 +1072,7 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>(
case WalletApiOperation.WithdrawTestkudos: { case WalletApiOperation.WithdrawTestkudos: {
await withdrawTestBalance(ws, { await withdrawTestBalance(ws, {
amount: "TESTKUDOS:10", amount: "TESTKUDOS:10",
bankAccessApiBaseUrl: bankAccessApiBaseUrl: "https://bank.test.taler.net/",
"https://bank.test.taler.net/",
exchangeBaseUrl: "https://exchange.test.taler.net/", exchangeBaseUrl: "https://exchange.test.taler.net/",
}); });
return { return {
@ -1122,6 +1122,11 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>(
}); });
return {}; return {};
} }
case WalletApiOperation.UpdateExchangeEntry: {
const req = codecForUpdateExchangeEntryRequest().decode(payload);
await updateExchangeFromUrl(ws, req.exchangeBaseUrl, {});
return {};
}
case WalletApiOperation.ListExchanges: { case WalletApiOperation.ListExchanges: {
return await getExchanges(ws); return await getExchanges(ws);
} }