wallet-core: return versions in init response

This commit is contained in:
Florian Dold 2022-10-19 15:36:57 +02:00
parent 81d6f2c796
commit f697b20a91
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
3 changed files with 24 additions and 12 deletions

View File

@ -115,6 +115,10 @@ export interface Balance {
requiresUserInput: boolean; requiresUserInput: boolean;
} }
export interface InitResponse {
versionInfo: WalletCoreVersion;
}
export interface BalancesResponse { export interface BalancesResponse {
balances: Balance[]; balances: Balance[];
} }

View File

@ -65,6 +65,7 @@ import {
InitiatePeerPullPaymentResponse, InitiatePeerPullPaymentResponse,
InitiatePeerPushPaymentRequest, InitiatePeerPushPaymentRequest,
InitiatePeerPushPaymentResponse, InitiatePeerPushPaymentResponse,
InitResponse,
IntegrationTestArgs, IntegrationTestArgs,
KnownBankAccounts, KnownBankAccounts,
ListKnownBankAccountsRequest, ListKnownBankAccountsRequest,
@ -91,6 +92,7 @@ import {
TransactionsRequest, TransactionsRequest,
TransactionsResponse, TransactionsResponse,
WalletBackupContentV1, WalletBackupContentV1,
WalletCoreVersion,
WalletCurrencyInfo, WalletCurrencyInfo,
WithdrawFakebankRequest, WithdrawFakebankRequest,
WithdrawTestBalanceRequest, WithdrawTestBalanceRequest,
@ -183,13 +185,13 @@ export enum WalletApiOperation {
export type InitWalletOp = { export type InitWalletOp = {
op: WalletApiOperation.InitWallet; op: WalletApiOperation.InitWallet;
request: {}; request: {};
response: {}; response: InitResponse;
}; };
export type GetVersionOp = { export type GetVersionOp = {
op: WalletApiOperation.GetVersion; op: WalletApiOperation.GetVersion;
request: {}; request: {};
response: {}; response: WalletCoreVersion;
}; };
// group: Basic Wallet Information // group: Basic Wallet Information

View File

@ -996,7 +996,9 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>(
bankAccessApiBaseUrl: "https://bank.test.taler.net/", bankAccessApiBaseUrl: "https://bank.test.taler.net/",
exchangeBaseUrl: "https://exchange.test.taler.net/", exchangeBaseUrl: "https://exchange.test.taler.net/",
}); });
return {}; return {
versionInfo: getVersion(ws),
};
} }
case WalletApiOperation.WithdrawTestBalance: { case WalletApiOperation.WithdrawTestBalance: {
const req = codecForWithdrawTestBalance().decode(payload); const req = codecForWithdrawTestBalance().decode(payload);
@ -1367,15 +1369,7 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>(
return {}; return {};
} }
case WalletApiOperation.GetVersion: { case WalletApiOperation.GetVersion: {
const version: WalletCoreVersion = { return getVersion(ws);
hash: GIT_HASH,
version: VERSION,
exchange: WALLET_EXCHANGE_PROTOCOL_VERSION,
merchant: WALLET_MERCHANT_PROTOCOL_VERSION,
bank: WALLET_BANK_INTEGRATION_PROTOCOL_VERSION,
devMode: ws.devModeActive,
};
return version;
} }
} }
throw TalerError.fromDetail( throw TalerError.fromDetail(
@ -1387,6 +1381,18 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>(
); );
} }
export function getVersion(ws: InternalWalletState): WalletCoreVersion {
const version: WalletCoreVersion = {
hash: GIT_HASH,
version: VERSION,
exchange: WALLET_EXCHANGE_PROTOCOL_VERSION,
merchant: WALLET_MERCHANT_PROTOCOL_VERSION,
bank: WALLET_BANK_INTEGRATION_PROTOCOL_VERSION,
devMode: ws.devModeActive,
};
return version;
}
/** /**
* Handle a request to the wallet-core API. * Handle a request to the wallet-core API.
*/ */