diff --git a/js/src/modals/Transfer/Details/details.js b/js/src/modals/Transfer/Details/details.js index f7cc70ad4..decd69c3c 100644 --- a/js/src/modals/Transfer/Details/details.js +++ b/js/src/modals/Transfer/Details/details.js @@ -123,7 +123,13 @@ export default class Details extends Component { .map((balance, index) => { const token = balance.token; const isEth = index === 0; - const imagesrc = token.image || images[token.address] || imageUnknown; + let imagesrc = token.image; + if (!imagesrc) { + imagesrc = + images[token.address] + ? `${api.dappsUrl}${images[token.address]}` + : imageUnknown; + } let value = 0; if (isEth) { diff --git a/js/src/redux/providers/imagesReducer.js b/js/src/redux/providers/imagesReducer.js index 15745932d..396576cc8 100644 --- a/js/src/redux/providers/imagesReducer.js +++ b/js/src/redux/providers/imagesReducer.js @@ -17,8 +17,6 @@ import { handleActions } from 'redux-actions'; import { bytesToHex } from '../../api/util/format'; -import { parityNode } from '../../environment'; - const ZERO = '0x0000000000000000000000000000000000000000000000000000000000000000'; const initialState = { @@ -28,7 +26,7 @@ const initialState = { export function hashToImageUrl (hashArray) { const hash = hashArray ? bytesToHex(hashArray) : ZERO; - return hash === ZERO ? null : `${parityNode}/api/content/${hash.substr(2)}`; + return hash === ZERO ? null : `/api/content/${hash.substr(2)}`; } export default handleActions({ diff --git a/js/src/redux/providers/status.js b/js/src/redux/providers/status.js index 658f54197..21712f2a9 100644 --- a/js/src/redux/providers/status.js +++ b/js/src/redux/providers/status.js @@ -16,8 +16,6 @@ import { statusBlockNumber, statusCollection, statusLogs } from './statusActions'; -import { parityNode } from '../../environment'; - export default class Status { constructor (store, api) { this._api = api; @@ -65,7 +63,7 @@ export default class Status { setTimeout(this._pollPing, timeout); }; - fetch(`${parityNode}/api/ping`, { method: 'GET' }) + fetch('/', { method: 'HEAD' }) .then((response) => dispatch(!!response.ok)) .catch(() => dispatch(false)); } diff --git a/js/src/secureApi.js b/js/src/secureApi.js index 545cfd459..d577e7185 100644 --- a/js/src/secureApi.js +++ b/js/src/secureApi.js @@ -25,6 +25,8 @@ export default class SecureApi extends Api { this._isConnecting = true; this._connectState = 0; this._needsToken = false; + this._dappsPort = 8080; + this._signerPort = 8180; this._followConnection(); } @@ -50,7 +52,7 @@ export default class SecureApi extends Api { case 0: if (isConnected) { this._isConnecting = false; - return this.setToken(); + return this.connectSuccess(); } else if (lastError) { this.updateToken('initial', 1); } @@ -79,7 +81,7 @@ export default class SecureApi extends Api { case 2: if (isConnected) { this._isConnecting = false; - return this.setToken(); + return this.connectSuccess(); } else if (lastError) { return setManual(); } @@ -89,12 +91,38 @@ export default class SecureApi extends Api { nextTick(); } + connectSuccess () { + this.setToken(); + + Promise + .all([ + this.ethcore.dappsPort(), + this.ethcore.signerPort() + ]) + .then(([dappsPort, signerPort]) => { + this._dappsPort = dappsPort.toNumber(); + this._signerPort = signerPort.toNumber(); + }); + } + updateToken (token, connectedState = 0) { this._connectState = connectedState; this._transport.updateToken(token.replace(/[^a-zA-Z0-9]/g, '')); this._followConnection(); } + get dappsPort () { + return this._dappsPort; + } + + get dappsUrl () { + return `http://127.0.0.1:${this._dappsPort}`; + } + + get signerPort () { + return this._signerPort; + } + get isConnecting () { return this._isConnecting; } diff --git a/js/src/ui/Balance/balance.js b/js/src/ui/Balance/balance.js index b6f786648..22b9fc1ae 100644 --- a/js/src/ui/Balance/balance.js +++ b/js/src/ui/Balance/balance.js @@ -47,7 +47,13 @@ class Balance extends Component { const value = token.format ? new BigNumber(balance.value).div(new BigNumber(token.format)).toFormat(3) : api.util.fromWei(balance.value).toFormat(3); - const imagesrc = token.image || images[token.address] || unknownImage; + let imagesrc = token.image; + if (!imagesrc) { + imagesrc = + images[token.address] + ? `${api.dappsUrl}${images[token.address]}` + : unknownImage; + } return (
- :
 
; + let image =
 
; + + if (app.image) { + image = ; + } else if (app.iconUrl) { + image = ; + } return ( diff --git a/js/src/views/Dapps/registry.js b/js/src/views/Dapps/registry.js index 57668c651..8975f2091 100644 --- a/js/src/views/Dapps/registry.js +++ b/js/src/views/Dapps/registry.js @@ -16,8 +16,6 @@ import BigNumber from 'bignumber.js'; -import { parityNode } from '../../environment'; - const builtinApps = [ { id: '0xf9f2d620c2e08f83e45555247146c62185e4ab7cf82a4b9002a265a0d020348f', @@ -76,6 +74,12 @@ const networkApps = [ } ]; +function getHost (api) { + return process.env.NODE_ENV === 'production' + ? api.dappsUrl + : ''; +} + export function fetchAvailable (api) { // TODO: Since we don't have an extensive GithubHint app, get the value somehow // RESULT: 0x22cd66e1b05882c0fa17a16d252d3b3ee2238ccbac8153f69a35c83f02ca76ee @@ -84,8 +88,7 @@ export function fetchAvailable (api) { // .then((sha3) => { // console.log('archive', sha3); // }); - - return fetch(`${parityNode}/api/apps`) + return fetch(`${getHost(api)}/api/apps`) .then((response) => { return response.ok ? response.json() @@ -134,8 +137,8 @@ export function fetchAvailable (api) { }); } -export function fetchManifest (app, contentHash) { - return fetch(`${parityNode}/${contentHash}/manifest.json`) +export function fetchManifest (api, app, contentHash) { + return fetch(`${getHost(api)}/${contentHash}/manifest.json`) .then((response) => { return response.ok ? response.json() diff --git a/js/src/views/Settings/Proxy/proxy.js b/js/src/views/Settings/Proxy/proxy.js index 8c68a8cfe..db32d3461 100644 --- a/js/src/views/Settings/Proxy/proxy.js +++ b/js/src/views/Settings/Proxy/proxy.js @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -import React, { Component } from 'react'; +import React, { Component, PropTypes } from 'react'; import { Container, ContainerTitle } from '../../../ui'; @@ -22,8 +22,13 @@ import layout from '../layout.css'; import styles from './proxy.css'; export default class Proxy extends Component { + static contextTypes = { + api: PropTypes.object.isRequired + } + render () { - const proxyurl = 'http://127.0.0.1:8080/proxy/proxy.pac'; + const { dappsUrl } = this.context.api; + const proxyurl = `${dappsUrl}/proxy/proxy.pac`; return (