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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 26 additions and 72 deletions

47
js/package-lock.json generated
View File

@ -49,11 +49,11 @@
"dev": true "dev": true
}, },
"@parity/dapp-dapp-methods": { "@parity/dapp-dapp-methods": {
"version": "github:js-dist-paritytech/dapp-dapp-methods#eb583c91c657d60767fa47b7a97aba76d9535e76", "version": "github:js-dist-paritytech/dapp-dapp-methods#7245089a8e83274372cde3c9406ae155e2083f84",
"dev": true, "dev": true,
"requires": { "requires": {
"@parity/api": "2.1.5", "@parity/api": "2.1.5",
"@parity/shared": "2.2.9", "@parity/shared": "2.2.12",
"@parity/ui": "2.2.15", "@parity/ui": "2.2.15",
"lodash": "4.17.4", "lodash": "4.17.4",
"mobx": "3.3.2", "mobx": "3.3.2",
@ -76,7 +76,7 @@
"requires": { "requires": {
"@parity/api": "2.1.5", "@parity/api": "2.1.5",
"@parity/etherscan": "2.1.3", "@parity/etherscan": "2.1.3",
"@parity/shared": "2.2.9", "@parity/shared": "2.2.12",
"bignumber.js": "3.0.1", "bignumber.js": "3.0.1",
"brace": "0.9.0", "brace": "0.9.0",
"date-difference": "1.0.0", "date-difference": "1.0.0",
@ -578,7 +578,7 @@
"requires": { "requires": {
"@parity/api": "2.1.5", "@parity/api": "2.1.5",
"@parity/etherscan": "2.1.3", "@parity/etherscan": "2.1.3",
"@parity/shared": "2.2.9", "@parity/shared": "2.2.12",
"bignumber.js": "3.0.1", "bignumber.js": "3.0.1",
"brace": "0.9.0", "brace": "0.9.0",
"date-difference": "1.0.0", "date-difference": "1.0.0",
@ -1098,17 +1098,6 @@
"version": "github:paritytech/dapp-tokenreg#a347041854eec61fd9a416b9c9d7bd1bda6b9c3d", "version": "github:paritytech/dapp-tokenreg#a347041854eec61fd9a416b9c9d7bd1bda6b9c3d",
"dev": true "dev": true
}, },
"@parity/dapp-vaults": {
"version": "github:paritytech/dapp-vaults#1bd5de3994227e6b733e7b3e985117a59f0ad638",
"dev": true
},
"@parity/dapp-web": {
"version": "github:paritytech/dapp-web#6ea1fe0c7c0d01c43788dbf6a11d1573a443ce1d",
"dev": true,
"requires": {
"base32.js": "0.1.0"
}
},
"@parity/etherscan": { "@parity/etherscan": {
"version": "2.1.3", "version": "2.1.3",
"resolved": "https://registry.npmjs.org/@parity/etherscan/-/etherscan-2.1.3.tgz", "resolved": "https://registry.npmjs.org/@parity/etherscan/-/etherscan-2.1.3.tgz",
@ -1151,9 +1140,9 @@
"version": "github:paritytech/plugin-signer-qr#c16423de5b8a8f68ebd5f1e78e084fa959329a9f" "version": "github:paritytech/plugin-signer-qr#c16423de5b8a8f68ebd5f1e78e084fa959329a9f"
}, },
"@parity/shared": { "@parity/shared": {
"version": "2.2.9", "version": "2.2.12",
"resolved": "https://registry.npmjs.org/@parity/shared/-/shared-2.2.9.tgz", "resolved": "https://registry.npmjs.org/@parity/shared/-/shared-2.2.12.tgz",
"integrity": "sha512-bbzfcFNt0XsO9oJj3ySPfMgFAcPtFJElHbEXTm4xU4xntADoSIYuWtvonq2uULxA1LQ1O+1hGpyagQ8OZ+YoqQ==", "integrity": "sha512-2ANbEOkWoqOf5ytE0K5pq7ZeqS7PVuiIwrhyxDgn8dQhpFiDLHro7pQirIEDZ8LzZK6g6V+HU38sagn6dYSRIQ==",
"requires": { "requires": {
"@parity/ledger": "2.1.2", "@parity/ledger": "2.1.2",
"eventemitter3": "2.0.3", "eventemitter3": "2.0.3",
@ -1209,13 +1198,13 @@
} }
}, },
"@parity/ui": { "@parity/ui": {
"version": "3.0.14", "version": "3.0.16",
"resolved": "https://registry.npmjs.org/@parity/ui/-/ui-3.0.14.tgz", "resolved": "https://registry.npmjs.org/@parity/ui/-/ui-3.0.16.tgz",
"integrity": "sha512-TCbGtzzVlouSdEVJQzIKEu/9j4vQntRF/qx6K/WsvZYqYjvD6Ar2V+0guNT2QY0EunMoOlzb0s5yEUHDLcU9Jg==", "integrity": "sha512-yGQ8k2/oNxu0GyJ6eQS1AUk1O1XR//oXfaHPEBa0VuJIB7gY9lPrkG7CSNpazOrTCfhdCHgpjGe3WR5lbv0HiQ==",
"requires": { "requires": {
"@parity/api": "2.1.5", "@parity/api": "2.1.5",
"@parity/etherscan": "2.1.3", "@parity/etherscan": "2.1.3",
"@parity/shared": "2.2.9", "@parity/shared": "2.2.12",
"babel-runtime": "6.26.0", "babel-runtime": "6.26.0",
"bignumber.js": "4.1.0", "bignumber.js": "4.1.0",
"brace": "0.11.0", "brace": "0.11.0",
@ -1237,7 +1226,7 @@
"react-dom": "16.1.1", "react-dom": "16.1.1",
"react-dropzone": "4.2.3", "react-dropzone": "4.2.3",
"react-element-to-jsx-string": "13.1.0", "react-element-to-jsx-string": "13.1.0",
"react-event-listener": "0.5.1", "react-event-listener": "0.5.2",
"react-intl": "2.4.0", "react-intl": "2.4.0",
"react-markdown": "3.0.2", "react-markdown": "3.0.2",
"react-portal": "4.0.0", "react-portal": "4.0.0",
@ -2997,12 +2986,6 @@
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
}, },
"base32.js": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/base32.js/-/base32.js-0.1.0.tgz",
"integrity": "sha1-tYLexpPC8R6JPPBk7mrFthMaIgI=",
"dev": true
},
"base64-js": { "base64-js": {
"version": "1.2.1", "version": "1.2.1",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.2.1.tgz", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.2.1.tgz",
@ -13690,9 +13673,9 @@
"dev": true "dev": true
}, },
"react-event-listener": { "react-event-listener": {
"version": "0.5.1", "version": "0.5.2",
"resolved": "https://registry.npmjs.org/react-event-listener/-/react-event-listener-0.5.1.tgz", "resolved": "https://registry.npmjs.org/react-event-listener/-/react-event-listener-0.5.2.tgz",
"integrity": "sha1-ujYHbke8N8Wmf/XM1Kn/DxViEEA=", "integrity": "sha512-E22Sc/PtzVWw/fRidkEy1ZNnpSMJARUVV/5LymsDe4NjIHzNcVpNLV/R2Kt40NN8X6tu/X5p2inCny7vqd97mg==",
"requires": { "requires": {
"babel-runtime": "6.26.0", "babel-runtime": "6.26.0",
"fbjs": "0.8.16", "fbjs": "0.8.16",

View File

@ -55,8 +55,6 @@
"@parity/dapp-signaturereg": "paritytech/dapp-signaturereg", "@parity/dapp-signaturereg": "paritytech/dapp-signaturereg",
"@parity/dapp-tokendeploy": "paritytech/dapp-tokendeploy", "@parity/dapp-tokendeploy": "paritytech/dapp-tokendeploy",
"@parity/dapp-tokenreg": "paritytech/dapp-tokenreg", "@parity/dapp-tokenreg": "paritytech/dapp-tokenreg",
"@parity/dapp-vaults": "paritytech/dapp-vaults",
"@parity/dapp-web": "paritytech/dapp-web",
"babel-cli": "6.26.0", "babel-cli": "6.26.0",
"babel-core": "6.26.0", "babel-core": "6.26.0",
"babel-eslint": "7.1.1", "babel-eslint": "7.1.1",
@ -147,8 +145,8 @@
"@parity/plugin-signer-default": "paritytech/plugin-signer-default", "@parity/plugin-signer-default": "paritytech/plugin-signer-default",
"@parity/plugin-signer-hardware": "paritytech/plugin-signer-hardware", "@parity/plugin-signer-hardware": "paritytech/plugin-signer-hardware",
"@parity/plugin-signer-qr": "paritytech/plugin-signer-qr", "@parity/plugin-signer-qr": "paritytech/plugin-signer-qr",
"@parity/shared": "^2.2.9", "@parity/shared": "^2.2.12",
"@parity/ui": "^3.0.14", "@parity/ui": "^3.0.16",
"keythereum": "1.0.2", "keythereum": "1.0.2",
"lodash.flatten": "4.4.0", "lodash.flatten": "4.4.0",
"lodash.omitby": "4.6.0", "lodash.omitby": "4.6.0",

View File

@ -19,7 +19,6 @@ import { observer } from 'mobx-react';
import { FormattedMessage } from 'react-intl'; import { FormattedMessage } from 'react-intl';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import Api from '@parity/api';
import builtinDapps from '@parity/shared/lib/config/dappsBuiltin.json'; import builtinDapps from '@parity/shared/lib/config/dappsBuiltin.json';
import viewsDapps from '@parity/shared/lib/config/dappsViews.json'; import viewsDapps from '@parity/shared/lib/config/dappsViews.json';
import DappsStore from '@parity/shared/lib/mobx/dappsStore'; 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'; import styles from './dapp.css';
const internalDapps = [] const internalDapps = [].concat(viewsDapps, builtinDapps);
.concat(viewsDapps, builtinDapps)
.map((app) => {
if (app.id && app.id.substr(0, 2) !== '0x') {
app.id = Api.util.sha3(app.id);
}
return app;
});
@observer @observer
export default class Dapp extends Component { export default class Dapp extends Component {
@ -130,13 +121,9 @@ export default class Dapp extends Component {
dapphost = ''; dapphost = '';
} }
const appId = this.context.api.util.isHex(app.id)
? app.id
: this.context.api.sha3(app.url);
src = window.location.protocol === 'file:' src = window.location.protocol === 'file:'
? `dapps/${appId}/index.html` ? `dapps/${app.id}/index.html`
: `${dapphost}/dapps/${appId}/index.html`; : `${dapphost}/dapps/${app.id}/index.html`;
break; break;
} }

View File

@ -18,7 +18,6 @@ import { action, computed, observable } from 'mobx';
import store from 'store'; import store from 'store';
import { sha3 } from '@parity/api/lib/util/sha3'; import { sha3 } from '@parity/api/lib/util/sha3';
import { isHex } from '@parity/api/lib/util/types';
import { methodGroupFromMethod } from './methodGroups'; import { methodGroupFromMethod } from './methodGroups';
@ -100,7 +99,7 @@ export default class Store {
this.requests = { ...this.requests }; 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 => { getMethodFromRequest = requestId => {
const { data: { method, params } } = this.requests[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(' ') }> <div className={ [styles.card, className].join(' ') }>
<Container <Container
className={ styles.content } className={ styles.content }
link={ link={ `/${app.id}` }
app.url === 'web'
? '/web'
: `/${app.id}`
}
> >
<DappIcon <DappIcon
app={ app } app={ app }

View File

@ -28,8 +28,6 @@ function initProvider () {
if (appId === 'dapps') { if (appId === 'dapps') {
appId = path[2]; appId = path[2];
} else if (!Api.util.isHex(appId)) {
appId = Api.util.sha3(appId);
} }
const ethereum = new Api.Provider.PostMessage(appId); const ethereum = new Api.Provider.PostMessage(appId);

View File

@ -17,7 +17,6 @@
import * as mobx from 'mobx'; import * as mobx from 'mobx';
import flatten from 'lodash.flatten'; import flatten from 'lodash.flatten';
import { sha3 } from '@parity/api/lib/util/sha3';
import VisibleStore from '@parity/shared/lib/mobx/dappsStore'; import VisibleStore from '@parity/shared/lib/mobx/dappsStore';
import RequestStore from './DappRequests/store'; import RequestStore from './DappRequests/store';
@ -58,8 +57,7 @@ export default function execute (appId, method, params, callback) {
return true; return true;
case 'shell_loadApp': case 'shell_loadApp':
const [_loadId, loadParams] = params; const [loadId, loadParams] = params;
const loadId = _loadId.substr(0, 2) !== '0x' ? sha3(_loadId) : _loadId;
const loadUrl = `/${loadId}/${loadParams || ''}`; const loadUrl = `/${loadId}/${loadParams || ''}`;
window.location.hash = loadUrl; window.location.hash = loadUrl;

View File

@ -15,7 +15,6 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
const Api = require('@parity/api');
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
const rimraf = require('rimraf'); const rimraf = require('rimraf');
@ -213,16 +212,12 @@ module.exports = {
return null; return null;
} }
const destination = Api.util.isHex(dapp.id)
? dapp.id
: Api.util.sha3(dapp.url);
if (!fs.existsSync(path.join(dir, 'dist'))) { if (!fs.existsSync(path.join(dir, 'dist'))) {
rimraf.sync(path.join(dir, 'node_modules')); rimraf.sync(path.join(dir, 'node_modules'));
return { return {
from: path.join(dir), from: path.join(dir),
to: `dapps/${destination}/` to: `dapps/${dapp.id}/`
}; };
} }
@ -236,11 +231,11 @@ module.exports = {
.filter((from) => fs.existsSync(from)) .filter((from) => fs.existsSync(from))
.map((from) => ({ .map((from) => ({
from, from,
to: `dapps/${destination}/` to: `dapps/${dapp.id}/`
})) }))
.concat({ .concat({
from: path.join(dir, 'dist'), from: path.join(dir, 'dist'),
to: `dapps/${destination}/dist/` to: `dapps/${dapp.id}/dist/`
}); });
}) })
.filter((copy) => copy) .filter((copy) => copy)