From 509038c9870bf8677c51ed413a10ae14178a8e35 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Fri, 15 Dec 2017 17:52:45 +0100 Subject: [PATCH] Fix inject.js & Signer store duplication (#7299) * Remove extension mappings * Remove duplicated pending stores --- js/src/Signer/pendingStore.js | 15 ++++-- js/src/Status/SignerPending/signerPending.js | 2 +- js/src/Status/SignerPending/store.js | 50 -------------------- js/src/inject.js | 4 -- 4 files changed, 12 insertions(+), 59 deletions(-) delete mode 100644 js/src/Status/SignerPending/store.js diff --git a/js/src/Signer/pendingStore.js b/js/src/Signer/pendingStore.js index 074aa202f..c014b935b 100644 --- a/js/src/Signer/pendingStore.js +++ b/js/src/Signer/pendingStore.js @@ -42,11 +42,18 @@ export default class PendingStore { } subscribePending = () => { - this._api.subscribe('signer_requestsToConfirm', (error, pending) => { - if (!error) { - this.setPending(pending); + const callback = (error, pending) => { + if (error) { + return; } - }); + + this.setPending(pending); + }; + + this._api + .subscribe('signer_requestsToConfirm', callback) + .then(() => this._api.signer.requestsToConfirm()) + .then((pending) => callback(null, pending)); } static get (api) { diff --git a/js/src/Status/SignerPending/signerPending.js b/js/src/Status/SignerPending/signerPending.js index 7c8283f40..c73196ef7 100644 --- a/js/src/Status/SignerPending/signerPending.js +++ b/js/src/Status/SignerPending/signerPending.js @@ -26,7 +26,7 @@ import Label from 'semantic-ui-react/dist/commonjs/elements/Label'; import List from 'semantic-ui-react/dist/commonjs/elements/List'; import Popup from 'semantic-ui-react/dist/commonjs/modules/Popup'; -import Store from './store'; +import Store from '../../Signer/pendingStore'; import ParityBarStore from '../../ParityBar/store'; import RequestItem from './RequestItem'; import styles from './signerPending.css'; diff --git a/js/src/Status/SignerPending/store.js b/js/src/Status/SignerPending/store.js deleted file mode 100644 index c2dad5351..000000000 --- a/js/src/Status/SignerPending/store.js +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import { action, observable } from 'mobx'; - -let instance; - -export default class Store { - @observable pending = []; - - constructor (api) { - this._api = api; - this.startSubscription(); - } - - @action setPending = (pending = []) => { - this.pending = pending; - } - - startSubscription () { - this._api.subscribe('signer_requestsToConfirm', (error, pending) => { - if (error) { - return; - } - - this.setPending(pending); - }); - } - - static get (api) { - if (!instance) { - instance = new Store(api); - } - - return instance; - } -} diff --git a/js/src/inject.js b/js/src/inject.js index 4ef5b1d9d..b06ffd396 100644 --- a/js/src/inject.js +++ b/js/src/inject.js @@ -18,8 +18,6 @@ import Api from '@parity/api'; import qs from 'query-string'; import Web3 from 'web3'; -import web3extensions from './web3.extensions'; - function initProvider () { const path = window.location.pathname.split('/'); const query = qs.parse(window.location.search); @@ -67,8 +65,6 @@ function initWeb3 (ethereum) { web3.eth.defaultAccount = accounts[0]; }); - web3extensions(web3).map((extension) => web3._extend(extension)); - window.web3 = web3; }