diff --git a/app/ledger.js b/app/ledger.js index 8ac9dfc9cc5..270fbe343fb 100644 --- a/app/ledger.js +++ b/app/ledger.js @@ -53,6 +53,7 @@ const appStore = require('../js/stores/appStore') const eventStore = require('../js/stores/eventStore') const rulesolver = require('./extensions/brave/content/scripts/pageInformation.js') const ledgerUtil = require('./common/lib/ledgerUtil') +const base64Encode = require('../js/lib/base64').encode // TBD: remove these post beta [MTR] const logPath = 'ledger-log.json' @@ -286,6 +287,18 @@ if (ipc) { if (balanceTimeoutId) clearTimeout(balanceTimeoutId) balanceTimeoutId = setTimeout(getBalance, 5 * msecs.second) }) + + ipc.on(messages.OPEN_LEDGER_TRANSACTION_CSV, (event, viewingIds, csvFilename) => { + if (client) { + let txCsvText = client._getTransactionCSVText(viewingIds) + let txCsvTextDataURI = 'data:text/csv;base64,' + base64Encode(txCsvText) + + const win = electron.BrowserWindow.getFocusedWindow() + if (win && win.webContents) { + win.webContents.downloadURL(txCsvTextDataURI) + } + } + }) } /* diff --git a/js/about/aboutActions.js b/js/about/aboutActions.js index cde4175a0be..91647ebded9 100644 --- a/js/about/aboutActions.js +++ b/js/about/aboutActions.js @@ -176,6 +176,10 @@ const AboutActions = { ipc.send(messages.LEDGER_CREATE_WALLET) }, + receiptLinkClick: function (viewingId, receiptFileName) { + ipc.send(messages.OPEN_LEDGER_TRANSACTION_CSV, viewingId, receiptFileName) + }, + setLedgerEnabled: function (enabled) { ipc.send(messages.LEDGER_ENABLE, enabled) }, diff --git a/js/about/preferences.js b/js/about/preferences.js index 31b96301a5d..ccd3ca32073 100644 --- a/js/about/preferences.js +++ b/js/about/preferences.js @@ -471,6 +471,7 @@ class PaymentHistory extends ImmutableComponent {