From 3385c38e9f1add97885b3ec32c45632c120c574f Mon Sep 17 00:00:00 2001 From: Miika Turunen Date: Tue, 26 Sep 2017 00:48:38 +0300 Subject: [PATCH 1/5] AGP-299, Link to explorer --- .../dashboard/walletsTxInfo/walletsTxInfo.js | 25 +++++++++++++++++++ .../walletsTxInfo/walletsTxInfo.render.js | 5 ++++ react/src/translate/en.js | 3 ++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/react/src/components/dashboard/walletsTxInfo/walletsTxInfo.js b/react/src/components/dashboard/walletsTxInfo/walletsTxInfo.js index 06aecf3..d566912 100644 --- a/react/src/components/dashboard/walletsTxInfo/walletsTxInfo.js +++ b/react/src/components/dashboard/walletsTxInfo/walletsTxInfo.js @@ -1,5 +1,6 @@ import React from 'react'; import { connect } from 'react-redux'; +import { translate } from '../../../translate/translate'; import { sortByDate } from '../../../util/sort'; import { toggleDashboardTxInfoModal } from '../../../actions/actionCreators'; import Store from '../../../store'; @@ -34,6 +35,29 @@ class WalletsTxInfo extends React.Component { } } + openExplorerWindow(txid) { + const url = 'http://' + this.props.ActiveCoin.coin + '.explorer.supernet.org/tx/' + txid; + const remote = window.require('electron').remote; + const BrowserWindow = remote.BrowserWindow; + + const externalWindow = new BrowserWindow({ + width: 1280, + height: 800, + title: `${translate('INDEX.LOADING')}...`, + icon: remote.getCurrentWindow().iguanaIcon, + webPreferences: { + "nodeIntegration": false + }, + }); + + externalWindow.loadURL(url); + externalWindow.webContents.on('did-finish-load', function() { + setTimeout(function() { + externalWindow.show(); + }, 40); + }); + } + render() { if (this.props && this.props.ActiveCoin.showTransactionInfo && @@ -52,6 +76,7 @@ const mapStateToProps = (state) => { return { ActiveCoin: { mode: state.ActiveCoin.mode, + coin: state.ActiveCoin.coin, txhistory: state.ActiveCoin.txhistory, showTransactionInfo: state.ActiveCoin.showTransactionInfo, activeSection: state.ActiveCoin.activeSection, diff --git a/react/src/components/dashboard/walletsTxInfo/walletsTxInfo.render.js b/react/src/components/dashboard/walletsTxInfo/walletsTxInfo.render.js index d04459e..e6280c0 100644 --- a/react/src/components/dashboard/walletsTxInfo/walletsTxInfo.render.js +++ b/react/src/components/dashboard/walletsTxInfo/walletsTxInfo.render.js @@ -34,6 +34,11 @@ const WalletsTxInfoRender = function(txInfo) { Raw info +
  • + this.openExplorerWindow(txInfo.txid) }> + { translate('INDEX.OPEN_TRANSACTION_IN_EPLORER') } + +
  • diff --git a/react/src/translate/en.js b/react/src/translate/en.js index 5bceaa4..c384f9e 100644 --- a/react/src/translate/en.js +++ b/react/src/translate/en.js @@ -293,7 +293,8 @@ export const _lang = { 'CREATE_INVOICE_QR': 'Create Invoice QR Code', 'QR_CONTENT': 'QR Content', 'CHOOSE_RECEIVING_ADDRESS': 'Choose Address', - 'SAVE_AS_IMAGE': 'Save as Image' + 'SAVE_AS_IMAGE': 'Save as Image', + 'OPEN_TRANSACTION_IN_EPLORER': 'Open transaction in Explorer', }, 'ATOMIC': { 'RAW_OUTPUT': 'Raw Output', From 05e1016b6e1a59aa4eac144a36d7d1c109501c99 Mon Sep 17 00:00:00 2001 From: Miika Turunen Date: Tue, 26 Sep 2017 23:26:10 +0300 Subject: [PATCH 2/5] AGP-299, Add coin name to explorer link --- .../components/dashboard/walletsTxInfo/walletsTxInfo.render.js | 2 +- react/src/translate/en.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/react/src/components/dashboard/walletsTxInfo/walletsTxInfo.render.js b/react/src/components/dashboard/walletsTxInfo/walletsTxInfo.render.js index e6280c0..968a899 100644 --- a/react/src/components/dashboard/walletsTxInfo/walletsTxInfo.render.js +++ b/react/src/components/dashboard/walletsTxInfo/walletsTxInfo.render.js @@ -36,7 +36,7 @@ const WalletsTxInfoRender = function(txInfo) {
  • this.openExplorerWindow(txInfo.txid) }> - { translate('INDEX.OPEN_TRANSACTION_IN_EPLORER') } + { translate('INDEX.OPEN_TRANSACTION_IN_EPLORER', this.props.ActiveCoin.coin) }
  • diff --git a/react/src/translate/en.js b/react/src/translate/en.js index c384f9e..949cb38 100644 --- a/react/src/translate/en.js +++ b/react/src/translate/en.js @@ -294,7 +294,7 @@ export const _lang = { 'QR_CONTENT': 'QR Content', 'CHOOSE_RECEIVING_ADDRESS': 'Choose Address', 'SAVE_AS_IMAGE': 'Save as Image', - 'OPEN_TRANSACTION_IN_EPLORER': 'Open transaction in Explorer', + 'OPEN_TRANSACTION_IN_EPLORER': 'Open transaction in @template@ Explorer', }, 'ATOMIC': { 'RAW_OUTPUT': 'Raw Output', From 2fdc565c8e894f42da2c3218c5e4558c991c03f6 Mon Sep 17 00:00:00 2001 From: Miika Turunen Date: Thu, 28 Sep 2017 23:27:35 +0300 Subject: [PATCH 3/5] AGP-299, button placement change --- .../dashboard/walletsTxInfo/walletsTxInfo.render.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/react/src/components/dashboard/walletsTxInfo/walletsTxInfo.render.js b/react/src/components/dashboard/walletsTxInfo/walletsTxInfo.render.js index 968a899..e2ab0d7 100644 --- a/react/src/components/dashboard/walletsTxInfo/walletsTxInfo.render.js +++ b/react/src/components/dashboard/walletsTxInfo/walletsTxInfo.render.js @@ -34,11 +34,6 @@ const WalletsTxInfoRender = function(txInfo) { Raw info -
  • - this.openExplorerWindow(txInfo.txid) }> - { translate('INDEX.OPEN_TRANSACTION_IN_EPLORER', this.props.ActiveCoin.coin) } - -
  • @@ -159,6 +154,12 @@ const WalletsTxInfoRender = function(txInfo) {
    +
    From d8c82d4791255dee902b8d2743126336b6f5bec8 Mon Sep 17 00:00:00 2001 From: Miika Turunen Date: Tue, 3 Oct 2017 23:01:01 +0300 Subject: [PATCH 5/5] AGP-299, Combine functions --- react/src/actions/actions/getTxDetails.js | 52 +++++-------------- .../dashboard/walletsTxInfo/walletsTxInfo.js | 3 +- 2 files changed, 14 insertions(+), 41 deletions(-) diff --git a/react/src/actions/actions/getTxDetails.js b/react/src/actions/actions/getTxDetails.js index cc032a8..8ea6222 100644 --- a/react/src/actions/actions/getTxDetails.js +++ b/react/src/actions/actions/getTxDetails.js @@ -5,7 +5,7 @@ import Config from '../../config'; export function getTxDetails(coin, txid, type) { return new Promise((resolve, reject) => { - const payload = { + let payload = { mode: null, chain: coin, cmd: 'gettransaction', @@ -13,44 +13,18 @@ export function getTxDetails(coin, txid, type) { txid ], }; - - fetch( - `http://127.0.0.1:${Config.agamaPort}/shepherd/cli`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ payload: payload }) - }, - ) - .catch(function(error) { - console.log(error); - dispatch( - triggerToaster( - 'getTransaction', - 'Error', - 'error' - ) - ); - }) - .then(response => response.json()) - .then(json => { - resolve(json.result ? json.result : json); - }) - }); -} - -export function getRawTxDetails(coin, txid) { - return new Promise((resolve, reject) => { - const payload = { - mode: null, - chain: coin, - cmd: 'getrawtransaction', - params: [ - txid, - 1 - ], - }; + + if(type==='raw') { + payload = { + mode: null, + chain: coin, + cmd: 'getrawtransaction', + params: [ + txid, + 1 + ], + }; + } fetch( `http://127.0.0.1:${Config.agamaPort}/shepherd/cli`, { diff --git a/react/src/components/dashboard/walletsTxInfo/walletsTxInfo.js b/react/src/components/dashboard/walletsTxInfo/walletsTxInfo.js index ae78891..c1914a9 100644 --- a/react/src/components/dashboard/walletsTxInfo/walletsTxInfo.js +++ b/react/src/components/dashboard/walletsTxInfo/walletsTxInfo.js @@ -5,7 +5,6 @@ import { sortByDate } from '../../../util/sort'; import { toggleDashboardTxInfoModal, getTxDetails, - getRawTxDetails, } from '../../../actions/actionCreators'; import Store from '../../../store'; import WalletsTxInfoRender from './walletsTxInfo.render'; @@ -52,7 +51,7 @@ class WalletsTxInfo extends React.Component { } loadRawTxDetails(coin, txid) { - getRawTxDetails(coin, txid) + getTxDetails(coin, txid, 'raw') .then((json) => { this.setState(Object.assign({}, this.state, { rawTxDetails: json,