adding informantion about the service worker version on the setting page
This commit is contained in:
parent
4a0512884d
commit
e0e33a88db
@ -571,7 +571,13 @@ export interface DepositInfo {
|
||||
export interface ExchangesListRespose {
|
||||
exchanges: ExchangeListItem[];
|
||||
}
|
||||
|
||||
export interface WalletCoreVersion {
|
||||
hash: string | undefined;
|
||||
version: string;
|
||||
exchange: string;
|
||||
merchant: string;
|
||||
bank: string;
|
||||
}
|
||||
export interface KnownBankAccounts {
|
||||
accounts: { [payto: string]: PaytoUri };
|
||||
}
|
||||
|
@ -5,6 +5,17 @@ import json from "@rollup/plugin-json";
|
||||
import builtins from "builtin-modules";
|
||||
import pkg from "./package.json";
|
||||
import sourcemaps from "rollup-plugin-sourcemaps";
|
||||
import replace from '@rollup/plugin-replace';
|
||||
import path from "path"
|
||||
import fs from "fs"
|
||||
|
||||
const BASE = process.cwd()
|
||||
|
||||
let GIT_ROOT = BASE
|
||||
while (!fs.existsSync(path.join(GIT_ROOT, '.git')) && GIT_ROOT !== '/') {
|
||||
GIT_ROOT = path.join(GIT_ROOT, '../')
|
||||
}
|
||||
const GIT_HASH = GIT_ROOT === '/' ? undefined : git_hash()
|
||||
|
||||
const nodeEntryPoint = {
|
||||
input: "lib/index.node.js",
|
||||
@ -21,6 +32,10 @@ const nodeEntryPoint = {
|
||||
}),
|
||||
|
||||
sourcemaps(),
|
||||
replace({
|
||||
'__VERSION__': `"${pkg.version}"`,
|
||||
'__GIT_HASH__': `"${GIT_HASH}"`,
|
||||
}),
|
||||
|
||||
commonjs({
|
||||
include: [/node_modules/, /dist/],
|
||||
@ -61,3 +76,12 @@ const browserEntryPoint = {
|
||||
};
|
||||
|
||||
export default [nodeEntryPoint, browserEntryPoint];
|
||||
|
||||
function git_hash() {
|
||||
const rev = fs.readFileSync(path.join(GIT_ROOT, '.git', 'HEAD')).toString().trim().split(/.*[: ]/).slice(-1)[0];
|
||||
if (rev.indexOf('/') === -1) {
|
||||
return rev;
|
||||
} else {
|
||||
return fs.readFileSync(path.join(GIT_ROOT, '.git', rev)).toString().trim();
|
||||
}
|
||||
}
|
||||
|
@ -86,6 +86,7 @@ import {
|
||||
TalerErrorCode,
|
||||
URL,
|
||||
WalletNotification,
|
||||
WalletCoreVersion,
|
||||
} from "@gnu-taler/taler-util";
|
||||
import { TalerCryptoInterface } from "./crypto/cryptoImplementation.js";
|
||||
import {
|
||||
@ -206,6 +207,7 @@ import {
|
||||
} from "./util/promiseUtils.js";
|
||||
import { DbAccess, GetReadWriteAccess } from "./util/query.js";
|
||||
import { TimerAPI, TimerGroup } from "./util/timer.js";
|
||||
import { WALLET_BANK_INTEGRATION_PROTOCOL_VERSION, WALLET_EXCHANGE_PROTOCOL_VERSION, WALLET_MERCHANT_PROTOCOL_VERSION } from "./versions.js";
|
||||
import { WalletCoreApiClient } from "./wallet-api-types.js";
|
||||
|
||||
const builtinAuditors: AuditorTrustRecord[] = [
|
||||
@ -714,6 +716,11 @@ export async function getClientFromWalletState(
|
||||
return client;
|
||||
}
|
||||
|
||||
declare const __VERSION__: string;
|
||||
declare const __GIT_HASH__: string;
|
||||
|
||||
const VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "dev";
|
||||
const GIT_HASH = typeof __GIT_HASH__ !== "undefined" ? __GIT_HASH__ : undefined;
|
||||
/**
|
||||
* Implementation of the "wallet-core" API.
|
||||
*/
|
||||
@ -1064,6 +1071,16 @@ async function dispatchRequestInternal(
|
||||
await acceptPeerPullPayment(ws, req);
|
||||
return {};
|
||||
}
|
||||
case "getVersion": {
|
||||
const version: WalletCoreVersion = {
|
||||
hash: GIT_HASH,
|
||||
version: VERSION,
|
||||
exchange: WALLET_EXCHANGE_PROTOCOL_VERSION,
|
||||
merchant: WALLET_MERCHANT_PROTOCOL_VERSION,
|
||||
bank: WALLET_BANK_INTEGRATION_PROTOCOL_VERSION,
|
||||
}
|
||||
return version;
|
||||
}
|
||||
}
|
||||
throw TalerError.fromDetail(
|
||||
TalerErrorCode.WALLET_CORE_API_OPERATION_UNKNOWN,
|
||||
|
@ -46,7 +46,7 @@ export type MessageFromBackend = {
|
||||
type: NotificationType;
|
||||
};
|
||||
|
||||
export interface WalletVersion {
|
||||
export interface WalletWebExVersion {
|
||||
version_name?: string | undefined;
|
||||
version: string;
|
||||
}
|
||||
@ -120,7 +120,7 @@ export interface PlatformAPI {
|
||||
/**
|
||||
* Get the wallet version from manifest
|
||||
*/
|
||||
getWalletVersion(): WalletVersion;
|
||||
getWalletWebExVersion(): WalletWebExVersion;
|
||||
|
||||
/**
|
||||
* Backend API
|
||||
|
@ -31,7 +31,7 @@ const api: PlatformAPI = {
|
||||
isFirefox,
|
||||
findTalerUriInActiveTab,
|
||||
getPermissionsApi,
|
||||
getWalletVersion,
|
||||
getWalletWebExVersion,
|
||||
listenToWalletBackground,
|
||||
notifyWhenAppIsReady,
|
||||
openWalletPage,
|
||||
@ -338,7 +338,7 @@ interface WalletVersion {
|
||||
version: string;
|
||||
}
|
||||
|
||||
function getWalletVersion(): WalletVersion {
|
||||
function getWalletWebExVersion(): WalletVersion {
|
||||
const manifestData = chrome.runtime.getManifest();
|
||||
return manifestData;
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ const api: PlatformAPI = {
|
||||
removeHostPermissions: async () => false,
|
||||
requestHostPermissions: async () => false,
|
||||
}),
|
||||
getWalletVersion: () => ({
|
||||
getWalletWebExVersion: () => ({
|
||||
version: "none",
|
||||
}),
|
||||
notifyWhenAppIsReady: (fn: () => void) => {
|
||||
|
@ -30,16 +30,32 @@ export default {
|
||||
},
|
||||
};
|
||||
|
||||
const version = {
|
||||
coreVersion: {
|
||||
exchange: "12:0:0",
|
||||
merchant: "2:0:1",
|
||||
bank: "0:0:0",
|
||||
hash: "d439c3e1bc743f2aa47de4457953dba6ecb0e20f",
|
||||
version: "0.9.0-dev.1",
|
||||
},
|
||||
webexVersion: {
|
||||
version: "0.9.0.13",
|
||||
hash: "d439c3e1bc743f2aa47de4457953dba6ecb0e20f",
|
||||
},
|
||||
};
|
||||
|
||||
export const AllOff = createExample(TestedComponent, {
|
||||
deviceName: "this-is-the-device-name",
|
||||
permissionToggle: { value: false, button: {} },
|
||||
setDeviceName: () => Promise.resolve(),
|
||||
...version,
|
||||
});
|
||||
|
||||
export const OneChecked = createExample(TestedComponent, {
|
||||
deviceName: "this-is-the-device-name",
|
||||
permissionToggle: { value: false, button: {} },
|
||||
setDeviceName: () => Promise.resolve(),
|
||||
...version,
|
||||
});
|
||||
|
||||
export const WithOneExchange = createExample(TestedComponent, {
|
||||
@ -59,6 +75,7 @@ export const WithOneExchange = createExample(TestedComponent, {
|
||||
paytoUris: ["payto://x-taler-bank/bank.rpi.sebasjm.com/exchangeminator"],
|
||||
} as any, //TODO: complete with auditors, wireInfo and denominations
|
||||
],
|
||||
...version,
|
||||
});
|
||||
|
||||
export const WithExchangeInDifferentState = createExample(TestedComponent, {
|
||||
@ -99,4 +116,5 @@ export const WithExchangeInDifferentState = createExample(TestedComponent, {
|
||||
paytoUris: ["payto://x-taler-bank/bank.rpi.sebasjm.com/exchangeminator"],
|
||||
},
|
||||
],
|
||||
...version,
|
||||
});
|
||||
|
@ -14,7 +14,7 @@
|
||||
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
import { ExchangeListItem } from "@gnu-taler/taler-util";
|
||||
import { ExchangeListItem, WalletCoreVersion } from "@gnu-taler/taler-util";
|
||||
import { Fragment, h, VNode } from "preact";
|
||||
import { Checkbox } from "../components/Checkbox.js";
|
||||
import { ErrorTalerOperation } from "../components/ErrorTalerOperation.js";
|
||||
@ -38,26 +38,39 @@ import { ToggleHandler } from "../mui/handlers.js";
|
||||
import { Pages } from "../NavigationBar.js";
|
||||
import { buildTermsOfServiceStatus } from "../utils/index.js";
|
||||
import * as wxApi from "../wxApi.js";
|
||||
import { platform } from "../platform/api.js";
|
||||
|
||||
const GIT_HASH = typeof __GIT_HASH__ !== "undefined" ? __GIT_HASH__ : undefined;
|
||||
|
||||
export function SettingsPage(): VNode {
|
||||
const permissionToggle = useExtendedPermissions();
|
||||
const { devMode, toggleDevMode } = useDevContext();
|
||||
const { name, update } = useBackupDeviceName();
|
||||
const webex = platform.getWalletWebExVersion();
|
||||
|
||||
const exchangesHook = useAsyncAsHook(wxApi.listExchanges);
|
||||
const exchangesHook = useAsyncAsHook(async () => {
|
||||
const list = await wxApi.listExchanges();
|
||||
const version = await wxApi.getVersion();
|
||||
return { exchanges: list.exchanges, version };
|
||||
});
|
||||
const { exchanges, version } =
|
||||
!exchangesHook || exchangesHook.hasError
|
||||
? { exchanges: [], version: undefined }
|
||||
: exchangesHook.response;
|
||||
|
||||
return (
|
||||
<SettingsView
|
||||
knownExchanges={
|
||||
!exchangesHook || exchangesHook.hasError
|
||||
? []
|
||||
: exchangesHook.response.exchanges
|
||||
}
|
||||
knownExchanges={exchanges}
|
||||
deviceName={name}
|
||||
setDeviceName={update}
|
||||
permissionToggle={permissionToggle}
|
||||
developerMode={devMode}
|
||||
toggleDeveloperMode={toggleDevMode}
|
||||
webexVersion={{
|
||||
version: webex.version,
|
||||
hash: GIT_HASH,
|
||||
}}
|
||||
coreVersion={version}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@ -69,14 +82,19 @@ export interface ViewProps {
|
||||
developerMode: boolean;
|
||||
toggleDeveloperMode: () => Promise<void>;
|
||||
knownExchanges: Array<ExchangeListItem>;
|
||||
coreVersion: WalletCoreVersion | undefined;
|
||||
webexVersion: {
|
||||
version: string;
|
||||
hash: string | undefined;
|
||||
};
|
||||
}
|
||||
const VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "dev";
|
||||
const GIT_HASH = typeof __GIT_HASH__ !== "undefined" ? __GIT_HASH__ : undefined;
|
||||
|
||||
export function SettingsView({
|
||||
knownExchanges,
|
||||
permissionToggle,
|
||||
developerMode,
|
||||
coreVersion,
|
||||
webexVersion,
|
||||
toggleDeveloperMode,
|
||||
}: ViewProps): VNode {
|
||||
const { i18n, lang, supportedLang, changeLanguage } = useTranslationContext();
|
||||
@ -216,16 +234,42 @@ export function SettingsView({
|
||||
<SubTitle>
|
||||
<i18n.Translate>Version</i18n.Translate>
|
||||
</SubTitle>
|
||||
<Part
|
||||
title={<i18n.Translate>Release</i18n.Translate>}
|
||||
text={<span>{VERSION}</span>}
|
||||
/>
|
||||
{GIT_HASH && (
|
||||
{coreVersion && (
|
||||
<Part
|
||||
title={<i18n.Translate>Hash</i18n.Translate>}
|
||||
text={<span>{GIT_HASH}</span>}
|
||||
title={<i18n.Translate>Wallet Core</i18n.Translate>}
|
||||
text={
|
||||
<span>
|
||||
{coreVersion.version}{" "}
|
||||
<JustInDevMode>{coreVersion.hash}</JustInDevMode>
|
||||
</span>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
<Part
|
||||
title={<i18n.Translate>Web Extension</i18n.Translate>}
|
||||
text={
|
||||
<span>
|
||||
{webexVersion.version}{" "}
|
||||
<JustInDevMode>{webexVersion.hash}</JustInDevMode>
|
||||
</span>
|
||||
}
|
||||
/>
|
||||
{coreVersion && (
|
||||
<JustInDevMode>
|
||||
<Part
|
||||
title={<i18n.Translate>Exchange compatibility</i18n.Translate>}
|
||||
text={<span>{coreVersion.exchange}</span>}
|
||||
/>
|
||||
<Part
|
||||
title={<i18n.Translate>Merchant compatibility</i18n.Translate>}
|
||||
text={<span>{coreVersion.merchant}</span>}
|
||||
/>
|
||||
<Part
|
||||
title={<i18n.Translate>Bank compatibility</i18n.Translate>}
|
||||
text={<span>{coreVersion.bank}</span>}
|
||||
/>
|
||||
</JustInDevMode>
|
||||
)}
|
||||
</section>
|
||||
</Fragment>
|
||||
);
|
||||
|
@ -65,6 +65,7 @@ import {
|
||||
SetWalletDeviceIdRequest,
|
||||
TransactionsResponse,
|
||||
WalletDiagnostics,
|
||||
WalletCoreVersion,
|
||||
WithdrawUriInfoResponse,
|
||||
} from "@gnu-taler/taler-util";
|
||||
import {
|
||||
@ -77,7 +78,7 @@ import {
|
||||
} from "@gnu-taler/taler-wallet-core";
|
||||
import type { DepositGroupFees } from "@gnu-taler/taler-wallet-core/src/operations/deposits";
|
||||
import type { ExchangeWithdrawDetails } from "@gnu-taler/taler-wallet-core/src/operations/withdraw";
|
||||
import { platform, MessageFromBackend } from "./platform/api.js";
|
||||
import { platform, MessageFromBackend, WalletWebExVersion } from "./platform/api.js";
|
||||
|
||||
/**
|
||||
*
|
||||
@ -249,6 +250,9 @@ export function listKnownCurrencies(): Promise<ListOfKnownCurrencies> {
|
||||
export function listExchanges(): Promise<ExchangesListRespose> {
|
||||
return callBackend("listExchanges", {});
|
||||
}
|
||||
export function getVersion(): Promise<WalletCoreVersion> {
|
||||
return callBackend("getVersion", {});
|
||||
}
|
||||
export function listKnownBankAccounts(
|
||||
currency?: string,
|
||||
): Promise<KnownBankAccounts> {
|
||||
|
@ -71,7 +71,7 @@ const walletInit: OpenedPromise<void> = openPromise<void>();
|
||||
const logger = new Logger("wxBackend.ts");
|
||||
|
||||
async function getDiagnostics(): Promise<WalletDiagnostics> {
|
||||
const manifestData = platform.getWalletVersion();
|
||||
const manifestData = platform.getWalletWebExVersion();
|
||||
const errors: string[] = [];
|
||||
let firefoxIdbProblem = false;
|
||||
let dbOutdated = false;
|
||||
|
Loading…
Reference in New Issue
Block a user