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 (
- :