exportDb call to the wallet-core

This commit is contained in:
Sebastian 2021-12-01 14:57:37 -03:00
parent 3587766046
commit 0f8e9b67dd
No known key found for this signature in database
GPG Key ID: BE4FF68352439FC1
2 changed files with 9 additions and 2 deletions

View File

@ -46,7 +46,10 @@ export function DeveloperPage(): VNode {
return <View status={status} return <View status={status}
timedOut={timedOut} timedOut={timedOut}
operations={operations} operations={operations}
onDownloadDatabase={async () => "content"} onDownloadDatabase={async () => {
const db = await wxApi.exportDB()
return JSON.stringify(db)
}}
/>; />;
} }
@ -81,7 +84,7 @@ export function View({ status, timedOut, operations, onDownloadDatabase }: Props
<br /> <br />
<button onClick={onExportDatabase}>export database</button> <button onClick={onExportDatabase}>export database</button>
{downloadedDatabase && <div> {downloadedDatabase && <div>
Database exported at <Time timestamp={{t_ms: downloadedDatabase.time.getTime()}} format="yyyy/MM/dd HH:mm:ss" /> <a href={`data:text/plain;charset=utf-8;base64,${Buffer.from(downloadedDatabase.content).toString('base64')}`} download={`taler-wallet-database-${format(downloadedDatabase.time, 'yyyy/MM/dd_HH:mm')}.json`}>click here</a> to download Database exported at <Time timestamp={{t_ms: downloadedDatabase.time.getTime()}} format="yyyy/MM/dd HH:mm:ss" /> <a href={`data:text/plain;charset=utf-8;base64,${btoa(downloadedDatabase.content)}`} download={`taler-wallet-database-${format(downloadedDatabase.time, 'yyyy/MM/dd_HH:mm')}.json`}>click here</a> to download
</div>} </div>}
<br /> <br />
<Diagnostics diagnostics={status} timedOut={timedOut} /> <Diagnostics diagnostics={status} timedOut={timedOut} />

View File

@ -355,6 +355,10 @@ export function acceptTip(req: AcceptTipRequest): Promise<void> {
return callBackend("acceptTip", req); return callBackend("acceptTip", req);
} }
export function exportDB(): Promise<any> {
return callBackend("exportDb", {});
}
export function onUpdateNotification(messageTypes: Array<NotificationType>, doCallback: () => void): () => void { export function onUpdateNotification(messageTypes: Array<NotificationType>, doCallback: () => void): () => void {
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
const port = chrome.runtime.connect({ name: "notifications" }); const port = chrome.runtime.connect({ name: "notifications" });