Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Remove extraneous id hashing (#7269)
Browse files Browse the repository at this point in the history
* Remove extraenous id hashing

* Update with latest js-shared
  • Loading branch information
jacogr committed Dec 12, 2017
1 parent 11b0cb8 commit 777bce8
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 72 deletions.
47 changes: 15 additions & 32 deletions js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@
"@parity/dapp-signaturereg": "paritytech/dapp-signaturereg",
"@parity/dapp-tokendeploy": "paritytech/dapp-tokendeploy",
"@parity/dapp-tokenreg": "paritytech/dapp-tokenreg",
"@parity/dapp-vaults": "paritytech/dapp-vaults",
"@parity/dapp-web": "paritytech/dapp-web",
"babel-cli": "6.26.0",
"babel-core": "6.26.0",
"babel-eslint": "7.1.1",
Expand Down Expand Up @@ -147,8 +145,8 @@
"@parity/plugin-signer-default": "paritytech/plugin-signer-default",
"@parity/plugin-signer-hardware": "paritytech/plugin-signer-hardware",
"@parity/plugin-signer-qr": "paritytech/plugin-signer-qr",
"@parity/shared": "^2.2.9",
"@parity/ui": "^3.0.14",
"@parity/shared": "^2.2.12",
"@parity/ui": "^3.0.16",
"keythereum": "1.0.2",
"lodash.flatten": "4.4.0",
"lodash.omitby": "4.6.0",
Expand Down
19 changes: 3 additions & 16 deletions js/src/Dapp/dapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,14 @@ import { observer } from 'mobx-react';
import { FormattedMessage } from 'react-intl';
import PropTypes from 'prop-types';

import Api from '@parity/api';
import builtinDapps from '@parity/shared/lib/config/dappsBuiltin.json';
import viewsDapps from '@parity/shared/lib/config/dappsViews.json';
import DappsStore from '@parity/shared/lib/mobx/dappsStore';
import HistoryStore from '@parity/shared/lib/mobx/historyStore';

import styles from './dapp.css';

const internalDapps = []
.concat(viewsDapps, builtinDapps)
.map((app) => {
if (app.id && app.id.substr(0, 2) !== '0x') {
app.id = Api.util.sha3(app.id);
}

return app;
});
const internalDapps = [].concat(viewsDapps, builtinDapps);

@observer
export default class Dapp extends Component {
Expand Down Expand Up @@ -130,13 +121,9 @@ export default class Dapp extends Component {
dapphost = '';
}

const appId = this.context.api.util.isHex(app.id)
? app.id
: this.context.api.sha3(app.url);

src = window.location.protocol === 'file:'
? `dapps/${appId}/index.html`
: `${dapphost}/dapps/${appId}/index.html`;
? `dapps/${app.id}/index.html`
: `${dapphost}/dapps/${app.id}/index.html`;
break;
}

Expand Down
3 changes: 1 addition & 2 deletions js/src/DappRequests/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { action, computed, observable } from 'mobx';
import store from 'store';

import { sha3 } from '@parity/api/lib/util/sha3';
import { isHex } from '@parity/api/lib/util/types';

import { methodGroupFromMethod } from './methodGroups';

Expand Down Expand Up @@ -100,7 +99,7 @@ export default class Store {
this.requests = { ...this.requests };
};

getPermissionId = (method, appId) => `${method}:${isHex(appId) ? appId : sha3(appId)}`; // Create an id to identify permissions based on method and appId
getPermissionId = (method, appId) => `${method}:${appId}`; // Create an id to identify permissions based on method and appId

getMethodFromRequest = requestId => {
const { data: { method, params } } = this.requests[requestId];
Expand Down
6 changes: 1 addition & 5 deletions js/src/Dapps/DappCard/dappCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@ export default class DappCard extends Component {
<div className={ [styles.card, className].join(' ') }>
<Container
className={ styles.content }
link={
app.url === 'web'
? '/web'
: `/${app.id}`
}
link={ `/${app.id}` }
>
<DappIcon
app={ app }
Expand Down
2 changes: 0 additions & 2 deletions js/src/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ function initProvider () {

if (appId === 'dapps') {
appId = path[2];
} else if (!Api.util.isHex(appId)) {
appId = Api.util.sha3(appId);
}

const ethereum = new Api.Provider.PostMessage(appId);
Expand Down
4 changes: 1 addition & 3 deletions js/src/shellMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import * as mobx from 'mobx';
import flatten from 'lodash.flatten';

import { sha3 } from '@parity/api/lib/util/sha3';
import VisibleStore from '@parity/shared/lib/mobx/dappsStore';

import RequestStore from './DappRequests/store';
Expand Down Expand Up @@ -58,8 +57,7 @@ export default function execute (appId, method, params, callback) {
return true;

case 'shell_loadApp':
const [_loadId, loadParams] = params;
const loadId = _loadId.substr(0, 2) !== '0x' ? sha3(_loadId) : _loadId;
const [loadId, loadParams] = params;
const loadUrl = `/${loadId}/${loadParams || ''}`;

window.location.hash = loadUrl;
Expand Down
11 changes: 3 additions & 8 deletions js/webpack/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

const Api = require('@parity/api');
const fs = require('fs');
const path = require('path');
const rimraf = require('rimraf');
Expand Down Expand Up @@ -213,16 +212,12 @@ module.exports = {
return null;
}

const destination = Api.util.isHex(dapp.id)
? dapp.id
: Api.util.sha3(dapp.url);

if (!fs.existsSync(path.join(dir, 'dist'))) {
rimraf.sync(path.join(dir, 'node_modules'));

return {
from: path.join(dir),
to: `dapps/${destination}/`
to: `dapps/${dapp.id}/`
};
}

Expand All @@ -236,11 +231,11 @@ module.exports = {
.filter((from) => fs.existsSync(from))
.map((from) => ({
from,
to: `dapps/${destination}/`
to: `dapps/${dapp.id}/`
}))
.concat({
from: path.join(dir, 'dist'),
to: `dapps/${destination}/dist/`
to: `dapps/${dapp.id}/dist/`
});
})
.filter((copy) => copy)
Expand Down

0 comments on commit 777bce8

Please sign in to comment.