wallet-core: implement explicit updateExchangeEntry request
This commit is contained in:
parent
e54df1f167
commit
671bbf2954
@ -1601,6 +1601,15 @@ export const codecForAddExchangeRequest = (): Codec<AddExchangeRequest> =>
|
||||
.property("masterPub", codecOptional(codecForString()))
|
||||
.build("AddExchangeRequest");
|
||||
|
||||
export interface UpdateExchangeEntryRequest {
|
||||
exchangeBaseUrl: string;
|
||||
}
|
||||
|
||||
export const codecForUpdateExchangeEntryRequest = (): Codec<UpdateExchangeEntryRequest> =>
|
||||
buildCodecForObject<UpdateExchangeEntryRequest>()
|
||||
.property("exchangeBaseUrl", codecForString())
|
||||
.build("UpdateExchangeEntryRequest");
|
||||
|
||||
export interface ForceExchangeUpdateRequest {
|
||||
exchangeBaseUrl: string;
|
||||
}
|
||||
|
@ -110,6 +110,7 @@ import {
|
||||
TransactionsRequest,
|
||||
TransactionsResponse,
|
||||
TxIdResponse,
|
||||
UpdateExchangeEntryRequest,
|
||||
UserAttentionByIdRequest,
|
||||
UserAttentionsCountResponse,
|
||||
UserAttentionsRequest,
|
||||
@ -222,6 +223,7 @@ export enum WalletApiOperation {
|
||||
CreateStoredBackup = "createStoredBackup",
|
||||
DeleteStoredBackup = "deleteStoredBackup",
|
||||
RecoverStoredBackup = "recoverStoredBackup",
|
||||
UpdateExchangeEntry = "updateExchangeEntry",
|
||||
}
|
||||
|
||||
// group: Initialization
|
||||
@ -557,6 +559,15 @@ export type AddExchangeOp = {
|
||||
response: EmptyObject;
|
||||
};
|
||||
|
||||
/**
|
||||
* Update an exchange entry.
|
||||
*/
|
||||
export type UpdateExchangeEntryOp = {
|
||||
op: WalletApiOperation.UpdateExchangeEntry;
|
||||
request: UpdateExchangeEntryRequest;
|
||||
response: EmptyObject;
|
||||
};
|
||||
|
||||
export type ListKnownBankAccountsOp = {
|
||||
op: WalletApiOperation.ListKnownBankAccounts;
|
||||
request: ListKnownBankAccountsRequest;
|
||||
@ -1125,6 +1136,7 @@ export type WalletOperations = {
|
||||
[WalletApiOperation.ListStoredBackups]: ListStoredBackupsOp;
|
||||
[WalletApiOperation.DeleteStoredBackup]: DeleteStoredBackupOp;
|
||||
[WalletApiOperation.RecoverStoredBackup]: RecoverStoredBackupsOp;
|
||||
[WalletApiOperation.UpdateExchangeEntry]: UpdateExchangeEntryOp;
|
||||
};
|
||||
|
||||
export type WalletCoreRequestType<
|
||||
|
@ -128,6 +128,7 @@ import {
|
||||
codecForTestingSetTimetravelRequest,
|
||||
setDangerousTimetravel,
|
||||
TestingWaitTransactionRequest,
|
||||
codecForUpdateExchangeEntryRequest,
|
||||
} from "@gnu-taler/taler-util";
|
||||
import type { HttpRequestLibrary } 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: {
|
||||
await withdrawTestBalance(ws, {
|
||||
amount: "TESTKUDOS:10",
|
||||
bankAccessApiBaseUrl:
|
||||
"https://bank.test.taler.net/",
|
||||
bankAccessApiBaseUrl: "https://bank.test.taler.net/",
|
||||
exchangeBaseUrl: "https://exchange.test.taler.net/",
|
||||
});
|
||||
return {
|
||||
@ -1122,6 +1122,11 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>(
|
||||
});
|
||||
return {};
|
||||
}
|
||||
case WalletApiOperation.UpdateExchangeEntry: {
|
||||
const req = codecForUpdateExchangeEntryRequest().decode(payload);
|
||||
await updateExchangeFromUrl(ws, req.exchangeBaseUrl, {});
|
||||
return {};
|
||||
}
|
||||
case WalletApiOperation.ListExchanges: {
|
||||
return await getExchanges(ws);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user