From 0c70cee503f84198a2e1de2d8ae9ae3bacf29802 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Mon, 24 Apr 2017 13:21:22 +0200 Subject: [PATCH] Contracts & Contract develop as dapp --- js/src/config/dappsViews.json | 55 +++++++++++++++---- js/src/index.js | 8 +-- js/src/routes.js | 37 ++----------- .../contractDevelop.css} | 0 .../contractDevelop.js} | 10 ++-- js/src/views/ContractDevelop/index.js | 44 +++++++++++++++ js/src/views/ContractDevelop/package.json | 19 +++++++ .../index.js => ContractDevelop/parity.js} | 6 +- .../store.js} | 6 +- js/src/views/Contracts/contracts.js | 18 +----- js/src/views/Contracts/index.js | 30 +++++++++- js/src/views/Contracts/package.json | 19 +++++++ js/src/views/Contracts/parity.js | 21 +++++++ js/src/views/Settings/Views/defaults.js | 9 +-- js/src/views/index.js | 2 - 15 files changed, 198 insertions(+), 86 deletions(-) rename js/src/views/{WriteContract/writeContract.css => ContractDevelop/contractDevelop.css} (100%) rename js/src/views/{WriteContract/writeContract.js => ContractDevelop/contractDevelop.js} (98%) create mode 100644 js/src/views/ContractDevelop/index.js create mode 100644 js/src/views/ContractDevelop/package.json rename js/src/views/{WriteContract/index.js => ContractDevelop/parity.js} (92%) rename js/src/views/{WriteContract/writeContractStore.js => ContractDevelop/store.js} (98%) create mode 100644 js/src/views/Contracts/package.json create mode 100644 js/src/views/Contracts/parity.js diff --git a/js/src/config/dappsViews.json b/js/src/config/dappsViews.json index 07477c7ac..6db59c776 100644 --- a/js/src/config/dappsViews.json +++ b/js/src/config/dappsViews.json @@ -21,6 +21,28 @@ "visible": true, "secure": true }, + { + "id": "contracts", + "url": "contracts", + "src": "Contracts", + "name": "Contracts", + "description": "Display the contracts added to the addressbook", + "author": "Parity Team ", + "version": "2.0.0", + "visible": true, + "secure": true + }, + { + "id": "develop", + "url": "develop", + "src": "ContractDevelop", + "name": "Contract Development", + "description": "Create new contracts", + "author": "Parity Team ", + "version": "2.0.0", + "visible": true, + "secure": true + }, { "id": "home", "url": "home", @@ -32,6 +54,28 @@ "visible": true, "secure": true }, + { + "id": "home", + "url": "home", + "src": "Home", + "name": "Home", + "description": "Display the status of the node, recently accessed applications, accounts and news", + "author": "Parity Team ", + "version": "2.0.0", + "visible": true, + "secure": true + }, + { + "id": "settings", + "url": "settings", + "src": "Settings", + "name": "Settings", + "description": "Allows the configuraion of all Parity & Parity-UI related options", + "author": "Parity Team ", + "version": "2.0.0", + "visible": true, + "secure": true + }, { "id": "status", "url": "status", @@ -53,16 +97,5 @@ "version": "2.0.0", "visible": true, "secure": true - }, - { - "id": "settings", - "url": "settings", - "src": "Settings", - "name": "Settings", - "description": "Allows the configuraion of all Parity & Parity-UI related options", - "author": "Parity Team ", - "version": "2.0.0", - "visible": true, - "secure": true } ] diff --git a/js/src/index.js b/js/src/index.js index 1ac4b5e84..bf6a3e8cf 100644 --- a/js/src/index.js +++ b/js/src/index.js @@ -74,9 +74,7 @@ window.secureApi = api; ReactDOM.render( - + , document.querySelector('#container') @@ -89,9 +87,7 @@ if (module.hot) { ReactDOM.render( - + , document.querySelector('#container') diff --git a/js/src/routes.js b/js/src/routes.js index 899ab789b..0462db23f 100644 --- a/js/src/routes.js +++ b/js/src/routes.js @@ -15,7 +15,7 @@ // along with Parity. If not, see . import HistoryStore from '~/mobx/historyStore'; -import { Application, Contract, Contracts, Dapp, Dapps, Signer, Web, WriteContract } from '~/views'; +import { Application, Dapp, Dapps, Signer, Web } from '~/views'; import builtinDapps from '~/config/dappsBuiltin.json'; import viewsDapps from '~/config/dappsViews.json'; @@ -24,23 +24,6 @@ const dapps = [].concat(viewsDapps, builtinDapps); // const accountsHistory = HistoryStore.get('accounts'); const dappsHistory = HistoryStore.get('dapps'); -function handleDeprecatedRoute (nextState, replace) { - const { address } = nextState.params; - const redirectMap = { - account: 'accounts', - address: 'addresses', - contract: 'contracts' - }; - - const oldRoute = nextState.routes[0].path; - const newRoute = Object.keys(redirectMap).reduce((newRoute, key) => { - return newRoute.replace(new RegExp(`^/${key}`), '/' + redirectMap[key]); - }, oldRoute); - - console.warn(`Route "${oldRoute}" is deprecated. Please use "${newRoute}"`); - replace(newRoute.replace(':address', address)); -} - function redirectTo (path) { return (nextState, replace) => { replace(path); @@ -64,26 +47,16 @@ function redirectTo (path) { // } // ]; -const contractsRoutes = [ - { path: 'develop', component: WriteContract }, - { path: ':address', component: Contract } -]; +// const contractsRoutes = [ +// { path: ':address', component: Contract } +// ]; const routes = [ - // Backward Compatible routes - { path: '/contract/:address', onEnter: handleDeprecatedRoute }, - { path: '/', onEnter: redirectTo('/apps') }, - { path: '/auth', onEnter: redirectTo('/apps') }, - { path: '/settings', onEnter: redirectTo('/settings/views') } + { path: '/auth', onEnter: redirectTo('/apps') } ]; const childRoutes = [ - { - path: 'contracts', - indexRoute: { component: Contracts }, - childRoutes: contractsRoutes - }, { path: 'app/:id', component: Dapp, diff --git a/js/src/views/WriteContract/writeContract.css b/js/src/views/ContractDevelop/contractDevelop.css similarity index 100% rename from js/src/views/WriteContract/writeContract.css rename to js/src/views/ContractDevelop/contractDevelop.css diff --git a/js/src/views/WriteContract/writeContract.js b/js/src/views/ContractDevelop/contractDevelop.js similarity index 98% rename from js/src/views/WriteContract/writeContract.js rename to js/src/views/ContractDevelop/contractDevelop.js index 77e039bb4..a1ac8210e 100644 --- a/js/src/views/WriteContract/writeContract.js +++ b/js/src/views/ContractDevelop/contractDevelop.js @@ -28,18 +28,18 @@ import { CancelIcon, ListIcon, SaveIcon, SendIcon, SettingsIcon } from '~/ui/Ico import Editor from '~/ui/Editor'; import { DeployContract, SaveContract, LoadContract } from '~/modals'; -import WriteContractStore from './writeContractStore'; -import styles from './writeContract.css'; +import ContractDevelopStore from './store'; +import styles from './contractDevelop.css'; @observer -class WriteContract extends Component { +class ContractDevelop extends Component { static propTypes = { accounts: PropTypes.object.isRequired, worker: PropTypes.object, workerError: PropTypes.any }; - store = WriteContractStore.get(); + store = ContractDevelopStore.get(); state = { resizing: false, @@ -733,4 +733,4 @@ function mapStateToProps (state) { export default connect( mapStateToProps, null -)(WriteContract); +)(ContractDevelop); diff --git a/js/src/views/ContractDevelop/index.js b/js/src/views/ContractDevelop/index.js new file mode 100644 index 000000000..aef47fecc --- /dev/null +++ b/js/src/views/ContractDevelop/index.js @@ -0,0 +1,44 @@ +// 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 ReactDOM from 'react-dom'; +import React from 'react'; +import { hashHistory } from 'react-router'; + +import injectTapEventPlugin from 'react-tap-event-plugin'; +injectTapEventPlugin(); + +import { api } from './parity'; + +import { initStore } from '~/redux'; +import ContextProvider from '~/ui/ContextProvider'; +import muiTheme from '~/ui/Theme'; + +import ContractDevelop from './contractDevelop'; + +import '~/../assets/fonts/Roboto/font.css'; +import '~/../assets/fonts/RobotoMono/font.css'; + +import './contractDevelop.css'; + +const store = initStore(api, hashHistory); + +ReactDOM.render( + + + , + document.querySelector('#container') +); diff --git a/js/src/views/ContractDevelop/package.json b/js/src/views/ContractDevelop/package.json new file mode 100644 index 000000000..51d4b6309 --- /dev/null +++ b/js/src/views/ContractDevelop/package.json @@ -0,0 +1,19 @@ +{ + "name": "@parity/view-contract-develop", + "description": "Parity contract development interface", + "version": "0.0.0", + "main": "index.js", + "author": "Parity Team ", + "maintainers": [], + "contributors": [], + "license": "GPL-3.0", + "repository": { + "type": "git", + "url": "git+https://github.com/paritytech/parity.git" + }, + "keywords": [], + "scripts": {}, + "devDependencies": {}, + "dependencies": {}, + "peerDependencies": {} +} diff --git a/js/src/views/WriteContract/index.js b/js/src/views/ContractDevelop/parity.js similarity index 92% rename from js/src/views/WriteContract/index.js rename to js/src/views/ContractDevelop/parity.js index 34bd4faee..7118ce087 100644 --- a/js/src/views/WriteContract/index.js +++ b/js/src/views/ContractDevelop/parity.js @@ -14,4 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -export default from './writeContract'; +const api = window.parent.secureApi; + +export { + api +}; diff --git a/js/src/views/WriteContract/writeContractStore.js b/js/src/views/ContractDevelop/store.js similarity index 98% rename from js/src/views/WriteContract/writeContractStore.js rename to js/src/views/ContractDevelop/store.js index b10a8e0ef..cf2154548 100644 --- a/js/src/views/WriteContract/writeContractStore.js +++ b/js/src/views/ContractDevelop/store.js @@ -25,7 +25,7 @@ import { sha3 } from '@parity/api/util/sha3'; import SolidityUtils from '~/util/solidity'; const SOLIDITY_LIST_URL = 'https://raw.githubusercontent.com/ethereum/solc-bin/gh-pages/bin/list.json'; -const WRITE_CONTRACT_STORE_KEY = '_parity::writeContractStore'; +const WRITE_CONTRACT_STORE_KEY = '_parity::contractDevelop'; const SNIPPETS = { snippet0: { @@ -76,7 +76,7 @@ const SNIPPETS = { let instance = null; -export default class WriteContractStore { +export default class ContractDevelopStore { @observable sourcecode = ''; @observable compiled = false; @@ -119,7 +119,7 @@ export default class WriteContractStore { static get () { if (!instance) { - instance = new WriteContractStore(); + instance = new ContractDevelopStore(); } return instance; diff --git a/js/src/views/Contracts/contracts.js b/js/src/views/Contracts/contracts.js index 52ed7cdae..f6a72bb21 100644 --- a/js/src/views/Contracts/contracts.js +++ b/js/src/views/Contracts/contracts.js @@ -16,7 +16,6 @@ import React, { Component, PropTypes } from 'react'; import { FormattedMessage } from 'react-intl'; -import { Link } from 'react-router'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; import { uniq, isEqual } from 'lodash'; @@ -24,7 +23,7 @@ import { uniq, isEqual } from 'lodash'; import { AddContract, DeployContract } from '~/modals'; import { setVisibleAccounts } from '~/redux/providers/personalActions'; import { Actionbar, ActionbarSearch, ActionbarSort, Button, Page } from '~/ui'; -import { AddIcon, DevelopIcon } from '~/ui/Icons'; +import { AddIcon } from '~/ui/Icons'; import List from '../Accounts/List'; @@ -171,21 +170,6 @@ class Contracts extends Component { } onClick={ this.onDeployContract } />, - -