Remove extraneous id hashing (#7269)

* Remove extraenous id hashing

* Update with latest js-shared
This commit is contained in:
Jaco Greeff
2017-12-12 12:09:24 +01:00
committed by GitHub
parent 11b0cb8da8
commit 777bce8a13
8 changed files with 26 additions and 72 deletions

View File

@@ -19,7 +19,6 @@ 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';
@@ -27,15 +26,7 @@ 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 {
@@ -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;
}

View File

@@ -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';
@@ -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];

View File

@@ -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 }

View File

@@ -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);

View File

@@ -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';
@@ -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;