diff --git a/js/src/util/constants.js b/js/src/util/constants.js index 10ff21cde..4a5548de9 100644 --- a/js/src/util/constants.js +++ b/js/src/util/constants.js @@ -21,9 +21,12 @@ const MAX_GAS_ESTIMATION = '50000000'; const NULL_ADDRESS = '0000000000000000000000000000000000000000'; +const DOMAIN = '.web3.site'; + export { DEFAULT_GAS, DEFAULT_GASPRICE, MAX_GAS_ESTIMATION, - NULL_ADDRESS + NULL_ADDRESS, + DOMAIN }; diff --git a/js/src/util/dapplink.js b/js/src/util/dapplink.js index 1a73d184f..e2b249b03 100644 --- a/js/src/util/dapplink.js +++ b/js/src/util/dapplink.js @@ -16,7 +16,9 @@ import base32 from 'base32.js'; -const BASE_URL = '.web.web3.site'; +import { DOMAIN } from './constants'; + +const BASE_URL = `.web${DOMAIN}`; const ENCODER_OPTS = { type: 'crockford' }; export function encodePath (token, url) { diff --git a/js/src/views/Application/Extension/store.js b/js/src/views/Application/Extension/store.js index 40a3f09e7..965598f03 100644 --- a/js/src/views/Application/Extension/store.js +++ b/js/src/views/Application/Extension/store.js @@ -21,6 +21,8 @@ import { action, computed, observable } from 'mobx'; import store from 'store'; import browser from 'useragent.js/lib/browser'; +import { DOMAIN } from '~/util/constants'; + const A_DAY = 24 * 60 * 60 * 1000; const NEXT_DISPLAY = '_parity::extensionWarning::nextDisplay'; @@ -68,6 +70,19 @@ export default class Store { installExtension = () => { this.setInstalling(true); + if (window.location.hostname.toString().endsWith(DOMAIN)) { + return this.inlineInstall() + .catch((error) => { + console.warn('Unable to perform direct install', error); + window.open(EXTENSION_PAGE, '_blank'); + }); + } + + window.open(EXTENSION_PAGE, '_blank'); + return Promise.resolve(true); + } + + inlineInstall = () => { return new Promise((resolve, reject) => { const link = document.createElement('link'); @@ -80,10 +95,6 @@ export default class Store { } else { reject(new Error('Direct installation failed.')); } - }) - .catch((error) => { - console.warn('Unable to perform direct install', error); - window.open(EXTENSION_PAGE, '_blank'); }); } }