51 | );
52 | }
53 | }
54 |
55 | ErrorView.propTypes = {
56 | errormsg: PropTypes.any
57 | };
58 |
59 | const mapStateToProps = ({ errors }) => {
60 | const { errormsg } = errors;
61 | return { errormsg };
62 | };
63 |
64 | export default connect(mapStateToProps, {})(ErrorView);
65 |
--------------------------------------------------------------------------------
/lib/components/EventItem/index.js:
--------------------------------------------------------------------------------
1 | 'use babel'
2 | // Copyright 2018 Etheratom Authors
3 | // This file is part of Etheratom.
4 |
5 | // Etheratom is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // Etheratom is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with Etheratom. If not, see .
17 | import React from 'react';
18 | import ReactJson from 'react-json-view';
19 | import { Collapse } from 'react-collapse';
20 | import PropTypes from 'prop-types';
21 |
22 | class EventItem extends React.Component {
23 | constructor(props) {
24 | super(props);
25 | this.state = {
26 | isOpened: false,
27 | toggleBtnStyle: 'btn icon icon-unfold inline-block-tight',
28 | toggleBtnTxt: 'Expand'
29 | };
30 | this._toggleCollapse = this._toggleCollapse.bind(this);
31 | }
32 | _toggleCollapse() {
33 | const { isOpened } = this.state;
34 | this.setState({ isOpened: !isOpened });
35 | if(!isOpened) {
36 | this.setState({
37 | toggleBtnStyle: 'btn btn-success icon icon-fold inline-block-tight',
38 | toggleBtnTxt: 'Collapse'
39 | });
40 | } else {
41 | this.setState({
42 | toggleBtnStyle: 'btn icon icon-unfold inline-block-tight',
43 | toggleBtnTxt: 'Expand'
44 | });
45 | }
46 | }
47 | render() {
48 | const { event } = this.props;
49 | const { isOpened, toggleBtnStyle, toggleBtnTxt } = this.state;
50 | return (
51 |
52 |
60 |
61 |
69 |
70 |
71 | );
72 | }
73 | }
74 |
75 | EventItem.propTypes = {
76 | event: PropTypes.object
77 | };
78 |
79 | export default EventItem;
80 |
--------------------------------------------------------------------------------
/lib/components/Events/index.js:
--------------------------------------------------------------------------------
1 | 'use babel'
2 | // Copyright 2018 Etheratom Authors
3 | // This file is part of Etheratom.
4 |
5 | // Etheratom is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // Etheratom is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with Etheratom. If not, see .
17 | import React from 'react';
18 | import { connect } from 'react-redux';
19 | import EventItem from '../EventItem';
20 | import PropTypes from 'prop-types';
21 |
22 | class Events extends React.Component {
23 | constructor(props) {
24 | super(props);
25 | this.helpers = props.helpers;
26 | }
27 | render() {
28 | const { events } = this.props;
29 | const events_ = events.slice();
30 | events_.reverse();
31 | return (
32 |
128 | );
129 | }
130 | }
131 |
132 | FunctionABI.propTypes = {
133 | helpers: PropTypes.any.isRequired,
134 | contractName: PropTypes.string,
135 | interfaces: PropTypes.object,
136 | updateInterface: PropTypes.func,
137 | coinbase: PropTypes.string,
138 | password: PropTypes.string,
139 | instances: PropTypes.object,
140 | contracts: PropTypes.object
141 | };
142 |
143 | const mapStateToProps = ({ contract, account }) => {
144 | const { compiled, interfaces, contracts } = contract;
145 | const { coinbase, password } = account;
146 | return { compiled, interfaces, contracts, coinbase, password };
147 | };
148 |
149 | export default connect(mapStateToProps, { updateInterface })(FunctionABI);
150 |
--------------------------------------------------------------------------------
/lib/components/GasInput/index.js:
--------------------------------------------------------------------------------
1 | 'use babel'
2 | // Copyright 2018 Etheratom Authors
3 | // This file is part of Etheratom.
4 |
5 | // Etheratom is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // Etheratom is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with Etheratom. If not, see .
17 | import React from 'react';
18 | import { connect } from 'react-redux';
19 | import PropTypes from 'prop-types';
20 |
21 | class GasInput extends React.Component {
22 | constructor(props) {
23 | super(props);
24 | this.state = {
25 | gas: props.gas
26 | };
27 | }
28 | UNSAFE_componentWillReceiveProps(nextProps) {
29 | const { gas } = nextProps;
30 | this.setState({ gas });
31 | }
32 | render() {
33 | const { gasLimit } = this.props;
34 | const { contractName } = this.props;
35 | return (
36 |
47 | );
48 | }
49 | }
50 |
51 | GasInput.propTypes = {
52 | contractName: PropTypes.string,
53 | interfaces: PropTypes.arrayOf(PropTypes.object),
54 | onChange: PropTypes.func,
55 | gasLimit: PropTypes.number,
56 | gas: PropTypes.number
57 | };
58 |
59 | const mapStateToProps = ({ contract }) => {
60 | const { compiled, gasLimit } = contract;
61 | return { compiled, gasLimit };
62 | };
63 |
64 | export default connect(mapStateToProps, {})(GasInput);
65 |
--------------------------------------------------------------------------------
/lib/components/InputsForm/index.js:
--------------------------------------------------------------------------------
1 | 'use babel'
2 | // Copyright 2018 Etheratom Authors
3 | // This file is part of Etheratom.
4 |
5 | // Etheratom is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // Etheratom is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with Etheratom. If not, see .
17 | import React from 'react';
18 | import { connect } from 'react-redux';
19 | import { setParamsInput } from '../../actions';
20 | import PropTypes from 'prop-types';
21 |
22 | class InputsForm extends React.Component {
23 | constructor(props) {
24 | super(props);
25 | this._handleChange = this._handleChange.bind(this);
26 | }
27 | _handleChange(input, event) {
28 | input.value = event.target.value;
29 | }
30 | render() {
31 | const { contractName, abi } = this.props;
32 | return (
33 |
50 | );
51 | }
52 | }
53 |
54 | InputsForm.propTypes = {
55 | onSubmit: PropTypes.func,
56 | contractName: PropTypes.string,
57 | abi: PropTypes.object
58 | };
59 |
60 | const mapStateToProps = ({ contract }) => {
61 | const { compiled } = contract;
62 | return { compiled };
63 | };
64 |
65 | export default connect(mapStateToProps, { setParamsInput })(InputsForm);
66 |
--------------------------------------------------------------------------------
/lib/components/LoaderView/index.js:
--------------------------------------------------------------------------------
1 | 'use babel';
2 | // Copyright 2018 Etheratom Authors
3 | // This file is part of Etheratom.
4 |
5 | // Etheratom is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // Etheratom is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with Etheratom. If not, see .
17 | import React from 'react';
18 | import { connect } from 'react-redux';
19 | import PropTypes from 'prop-types';
20 | import ScaleLoader from 'react-spinners/ScaleLoader';
21 |
22 | const loaderContainerStyle = {
23 | textAlign: 'center',
24 | justifyContent: 'center'
25 | };
26 |
27 | class LoaderView extends React.Component {
28 | constructor(props) {
29 | super(props);
30 | this.store = this.props.store;
31 | }
32 | stateChange() {
33 | }
34 | componentDidUpdate() {
35 |
36 | }
37 | componentWillReceiveProps() {
38 |
39 | }
40 | render() {
41 | const { clients } = this.props;
42 | const { hasConnection } = clients[0];
43 |
44 | // alert(hasConnection);
45 |
46 | return (
47 |
146 | );
147 | }
148 | }
149 |
150 | TxAnalyzer.propTypes = {
151 | helpers: PropTypes.any.isRequired,
152 | pendingTransactions: PropTypes.array,
153 | txAnalysis: PropTypes.any
154 | };
155 |
156 | const mapStateToProps = ({ eventReducer }) => {
157 | const { pendingTransactions, txAnalysis } = eventReducer;
158 | return { pendingTransactions, txAnalysis };
159 | };
160 |
161 | export default connect(mapStateToProps, {})(TxAnalyzer);
162 |
--------------------------------------------------------------------------------
/lib/components/VersionSelector/index.js:
--------------------------------------------------------------------------------
1 | 'use babel'
2 | // Copyright 2018 Etheratom Authors
3 | // This file is part of Etheratom.
4 |
5 | // Etheratom is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // Etheratom is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with Etheratom. If not, see .
17 | import React from 'react';
18 | import PropTypes from 'prop-types';
19 | import { connect } from 'react-redux';
20 | import axios from 'axios';
21 |
22 | class VersionSelector extends React.Component {
23 | constructor(props) {
24 | super(props);
25 | this.state = {
26 | availableVersions: [],
27 | selectedVersion: '',
28 | };
29 | this._handleVersionSelector = this._handleVersionSelector.bind(this);
30 | }
31 | async _handleVersionSelector(event) {
32 | const selectedVersion = event.target.value;
33 | await this.setState({ selectedVersion });
34 | atom.config.set('etheratom.versionSelector', selectedVersion);
35 | }
36 | async componentDidMount() {
37 | this.fetchVersionList();
38 | }
39 |
40 | async fetchVersionList() {
41 | const versions = await axios.get('https://ethereum.github.io/solc-bin/bin/list.json');
42 | this.setState({
43 | availableVersions: versions.data.releases,
44 | selectedVersion: atom.config.get('etheratom.versionSelector'),
45 | });
46 | }
47 | render() {
48 | const { availableVersions } = this.state;
49 | return (
50 |
51 |
52 |
61 |
62 |
63 | );
64 | }
65 | }
66 |
67 | VersionSelector.propTypes = {
68 | selectedVersion: PropTypes.string
69 | };
70 |
71 | const mapStateToProps = ({ contract }) => {
72 | const { selectedVersion } = contract;
73 | return { selectedVersion };
74 | };
75 |
76 | export default connect(mapStateToProps, {})(VersionSelector);
77 |
--------------------------------------------------------------------------------
/lib/ethereum-interface-view.js:
--------------------------------------------------------------------------------
1 | 'use babel'
2 | // Copyright 2018 Etheratom Authors
3 | // This file is part of Etheratom.
4 |
5 | // Etheratom is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // Etheratom is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with Etheratom. If not, see .
17 | import { CompositeDisposable } from 'atom';
18 | export class AtomSolidityView {
19 | constructor() {
20 | this.element = document.createElement;
21 | this.element = document.createElement('atom-panel');
22 | this.element.classList.add('etheratom-panel');
23 | let att = null;
24 |
25 | // empty div to handle resize
26 | let resizeNode = document.createElement('div');
27 | resizeNode.onmousedown = this.handleMouseDown.bind(this);
28 | resizeNode.classList.add('etheratom-panel-resize-handle');
29 | resizeNode.setAttribute('ref', 'resizehandle');
30 | this.element.appendChild(resizeNode);
31 |
32 | let mainNode = document.createElement('div');
33 | mainNode.classList.add('etheratom');
34 | mainNode.classList.add('native-key-bindings');
35 | mainNode.setAttribute('tabindex', '-1');
36 |
37 | let message = document.createElement('div');
38 | message.textContent = 'Etheratom IDE';
39 | message.classList.add('compiler-info');
40 | message.classList.add('block');
41 | message.classList.add('highlight-info');
42 | mainNode.appendChild(message);
43 |
44 | let compilerNode = document.createElement('div');
45 | att = document.createAttribute('id');
46 | att.value = 'client-options';
47 | compilerNode.setAttributeNode(att);
48 | mainNode.appendChild(compilerNode);
49 |
50 | let loaderNode = document.createElement('div');
51 | att = document.createAttribute('id');
52 | att.value = 'loader';
53 | loaderNode.setAttributeNode(att);
54 | mainNode.appendChild(loaderNode);
55 |
56 | let versionNode = document.createElement('div');
57 | att = document.createAttribute('id');
58 | att.value = 'version_selector';
59 | versionNode.setAttributeNode(att);
60 | mainNode.appendChild(versionNode);
61 |
62 | let accountsNode = document.createElement('div');
63 | att = document.createAttribute('id');
64 | att.value = 'accounts-list';
65 | accountsNode.setAttributeNode(att);
66 | mainNode.appendChild(accountsNode);
67 |
68 | let buttonNode = document.createElement('div');
69 | att = document.createAttribute('id');
70 | att.value = 'common-buttons';
71 | buttonNode.setAttributeNode(att);
72 | buttonNode.classList.add('block');
73 |
74 | let compileButton = document.createElement('div');
75 | att = document.createAttribute('id');
76 | att.value = 'compile_btn';
77 | compileButton.setAttributeNode(att);
78 | compileButton.classList.add('inline-block');
79 |
80 | buttonNode.appendChild(compileButton);
81 | mainNode.appendChild(buttonNode);
82 |
83 | let tabNode = document.createElement('div');
84 | att = document.createAttribute('id');
85 | att.value = 'tab_view';
86 | tabNode.setAttributeNode(att);
87 | mainNode.appendChild(tabNode);
88 |
89 | let errorNode = document.createElement('div');
90 | att = document.createAttribute('id');
91 | att.value = 'compiled-error';
92 | errorNode.setAttributeNode(att);
93 | errorNode.classList.add('compiled-error');
94 | mainNode.appendChild(errorNode);
95 |
96 | // Finally append mainNode to element
97 | this.element.appendChild(mainNode);
98 |
99 | this.handleMouseDown = this.handleMouseDown.bind(this);
100 | this.handleMouseMove = this.handleMouseMove.bind(this);
101 | this.handleMouseUp = this.handleMouseUp.bind(this);
102 | this.dispose = this.dispose.bind(this);
103 | this.getElement = this.getElement.bind(this);
104 | this.destroy = this.destroy.bind(this);
105 | }
106 | handleMouseDown(e) {
107 | if (this.subscriptions != null) {
108 | this.subscriptions.dispose();
109 | }
110 |
111 | const mouseUpHandler = (e) => this.handleMouseUp(e);
112 | const mouseMoveHandler = (e) => this.handleMouseMove(e);
113 | window.addEventListener('mousemove', mouseMoveHandler);
114 | window.addEventListener('mouseup', mouseUpHandler);
115 |
116 | this.subscriptions = new CompositeDisposable({
117 | dispose: () => {
118 | window.removeEventListener('mousemove', mouseMoveHandler);
119 | }
120 | }, {
121 | dispose: () => {
122 | window.removeEventListener('mouseup', mouseUpHandler);
123 | }
124 | });
125 | }
126 | handleMouseMove(e) {
127 | // Currently only vertical panel is working, may be later I should add horizontal panel
128 | const width = this.element.getBoundingClientRect().right - e.pageX;
129 | const vwidth = window.innerWidth;
130 | const vw = (width / vwidth) * 100 + 'vw';
131 | this.element.style.width = vw;
132 | }
133 | handleMouseUp(e) {
134 | if (this.subscriptions) {
135 | this.subscriptions.dispose();
136 | }
137 | }
138 | getElement() {
139 | return this.element;
140 | }
141 | dispose() {
142 | this.destroy();
143 | }
144 | destroy() {
145 | return this.element.remove();
146 | }
147 | }
148 |
--------------------------------------------------------------------------------
/lib/ethereum-interface.js:
--------------------------------------------------------------------------------
1 | 'use babel'
2 | // Copyright 2018 Etheratom Authors
3 | // This file is part of Etheratom.
4 |
5 | // Etheratom is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // Etheratom is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with Etheratom. If not, see .
17 | import { AtomSolidityView } from './ethereum-interface-view';
18 | import Web3Env from './web3/web3';
19 | import configureStore from './helpers/configureStore';
20 | import { CompositeDisposable } from 'atom';
21 |
22 | export class Etheratom {
23 | constructor(props) {
24 | this.subscriptions = new CompositeDisposable();
25 | this.atomSolidityView = new AtomSolidityView();
26 | this.modalPanel = null;
27 | this.loaded = false;
28 | this.store = configureStore();
29 | }
30 | activate() {
31 | require('atom-package-deps').install('etheratom', true)
32 | .then(function() {
33 | console.log('All dependencies installed, good to go');
34 | });
35 | this.subscriptions.add(atom.commands.add('atom-workspace', {
36 | 'eth-interface:toggle': ((_this) => {
37 | return function() {
38 | _this.toggleView();
39 | };
40 | })(this),
41 | 'eth-interface:activate': ((_this) => {
42 | return function() {
43 | _this.toggleView();
44 | };
45 | })(this)
46 | }));
47 | this.modalPanel = atom.workspace.addRightPanel({
48 | item: this.atomSolidityView.getElement(),
49 | visible: false
50 | });
51 | // Initiate env
52 | this.load();
53 | }
54 | deactivate() {
55 | this.modalPanel.destroy();
56 | this.subscriptions.dispose();
57 | this.atomSolidityView.destroy();
58 | }
59 | load() {
60 | this.loadWeb3();
61 | this.loaded = true;
62 | }
63 | loadWeb3() {
64 | if (this.Web3Interface) {
65 | return this.Web3Interface;
66 | }
67 | this.Web3Interface = new Web3Env(this.store);
68 | this.subscriptions.add(this.Web3Interface);
69 | return this.Web3Interface;
70 | }
71 | toggleView() {
72 | if (this.modalPanel.isVisible()) {
73 | return this.modalPanel.hide();
74 | } else {
75 | return this.modalPanel.show();
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/lib/helpers/compiler-imports.js:
--------------------------------------------------------------------------------
1 | 'use babel'
2 | // Copyright 2018 Etheratom Authors
3 | // This file is part of Etheratom.
4 |
5 | // Etheratom is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // Etheratom is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with Etheratom. If not, see .
17 |
18 | /*eslint no-useless-escape: "warn"*/
19 | /*eslint node/no-deprecated-api: "warn" */
20 | import axios from 'axios';
21 | import path from 'path';
22 | import url from 'url';
23 | import validUrl from 'valid-url';
24 | import fs from 'fs';
25 |
26 | async function handleGithubCall(fullpath, repoPath, path, filename, fileRoot) {
27 | return await axios({
28 | method: 'get',
29 | url: 'https://api.github.com/repos/' + repoPath + '/contents/' + path,
30 | responseType: 'json'
31 | }).then(function(response) {
32 | if ('content' in response.data) {
33 | const buf = Buffer.from(response.data.content, 'base64');
34 | fileRoot = fullpath.substring(0, fullpath.lastIndexOf('/'));
35 | fileRoot = fileRoot + '/';
36 | const resp = { filename, content: buf.toString('UTF-8'), fileRoot };
37 | return resp;
38 | } else {
39 | throw 'Content not received!';
40 | }
41 | });
42 | }
43 | async function handleNodeModulesImport(pathString, filename, fileRoot) {
44 | const o = { encoding: 'UTF-8' };
45 | var modulesDir = fileRoot;
46 |
47 | while (true) {
48 | var p = path.join(modulesDir, 'node_modules', pathString, filename);
49 | try {
50 | const content = fs.readFileSync(p, o);
51 | fileRoot = path.join(modulesDir, 'node_modules', pathString);
52 | const response = { filename, content, fileRoot };
53 | return response;
54 | }
55 | catch (err) {
56 | console.log(err);
57 | }
58 |
59 | // Recurse outwards until impossible
60 | var oldModulesDir = modulesDir;
61 | modulesDir = path.join(modulesDir, '..');
62 | if (modulesDir === oldModulesDir) {
63 | break;
64 | }
65 | }
66 |
67 | }
68 | async function handleLocalImport(pathString, filename, fileRoot) {
69 | // if no relative/absolute path given then search in node_modules folder
70 | if (pathString && pathString.indexOf('.') !== 0 && pathString.indexOf('/') !== 0) {
71 | return handleNodeModulesImport(pathString, filename, fileRoot);
72 | }
73 | else {
74 | const o = { encoding: 'UTF-8' };
75 | const p = pathString ? path.resolve(fileRoot, pathString, filename) : path.resolve(fileRoot, filename);
76 | const content = fs.readFileSync(p, o);
77 | fileRoot = pathString ? path.resolve(fileRoot, pathString) : fileRoot;
78 | const response = { filename, content, fileRoot };
79 | return response;
80 | }
81 | }
82 | async function getHandlers() {
83 | return [
84 | {
85 | type: 'local',
86 | match: /(^(?!(?:http:\/\/)|(?:https:\/\/)?(?:www.)?(?:github.com)))(^\/*[\w+-_/]*\/)*?(\w+\.sol)/g,
87 | handle: async(match, fileRoot) => { return await handleLocalImport(match[2], match[3], fileRoot); }
88 | },
89 | {
90 | type: 'github',
91 | match: /^(https?:\/\/)?(www.)?github.com\/([^/]*\/[^/]*)(.*\/(\w+\.sol))/g,
92 | handle: async(match, fileRoot) => {
93 | return await handleGithubCall(match[0], match[3], match[4], match[5], fileRoot);
94 | }
95 | }
96 | ];
97 | }
98 | async function resolveImports(fileRoot, sourcePath) {
99 | const handlers = await getHandlers();
100 | let response = {};
101 | for (const handler of handlers) {
102 | try {
103 | // here we are trying to find type of import path github/swarm/ipfs/local
104 | const match = handler.match.exec(sourcePath);
105 | if (match) {
106 | response = await handler.handle(match, fileRoot);
107 | break;
108 | }
109 | } catch (e) {
110 | throw e;
111 | }
112 | }
113 | return response;
114 | }
115 | export async function combineSource(fileRoot, sources) {
116 | let fn, importLine, ir;
117 | var matches = [];
118 | ir = /^(?:import){1}(.+){0,1}\s['"](.+)['"];/gm;
119 | let match = null;
120 | for (const fileName of Object.keys(sources)) {
121 | const source = sources[fileName].content;
122 | while ((match = ir.exec(source))) {
123 | matches.push(match);
124 | }
125 | for (let match of matches) {
126 | importLine = match[0];
127 | const extra = match[1] ? match[1] : '';
128 | if (validUrl.isUri(fileRoot)) {
129 | fn = url.URL.resolve(fileRoot, match[2]);
130 | } else {
131 | fn = match[2];
132 | }
133 | try {
134 | // resolve anything other than remix_tests.sol & tests.sol
135 | if (fn.localeCompare('remix_tests.sol') != 0 && fn.localeCompare('tests.sol') != 0) {
136 | let subSorce = {};
137 | const response = await resolveImports(fileRoot, fn);
138 | sources[fileName].content = sources[fileName].content.replace(importLine, 'import' + extra + ' \'' + response.filename + '\';');
139 | subSorce[response.filename] = { content: response.content };
140 | sources = Object.assign(await combineSource(response.fileRoot, subSorce), sources);
141 | }
142 | } catch (e) {
143 | throw e;
144 | }
145 | }
146 | }
147 | return sources;
148 | }
149 |
--------------------------------------------------------------------------------
/lib/helpers/configureStore.js:
--------------------------------------------------------------------------------
1 | 'use babel'
2 | // Copyright 2018 Etheratom Authors
3 | // This file is part of Etheratom.
4 |
5 | // Etheratom is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // Etheratom is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with Etheratom. If not, see .
17 | import etheratomReducers from '../reducers';
18 | import logger from 'redux-logger';
19 | import ReduxThunk from 'redux-thunk';
20 | import { createStore, applyMiddleware } from 'redux';
21 |
22 | export default function configureStore(initialState) {
23 | const middleWares = [ReduxThunk];
24 | if(atom.inDevMode()) {
25 | middleWares.push(logger);
26 | }
27 | const store = createStore(
28 | etheratomReducers,
29 | initialState,
30 | applyMiddleware(...middleWares)
31 | );
32 | return store;
33 | }
34 |
--------------------------------------------------------------------------------
/lib/helpers/uiHelpers.js:
--------------------------------------------------------------------------------
1 | 'use babel'
2 | // Copyright 2018 Etheratom Authors
3 | // This file is part of Etheratom.
4 |
5 | // Etheratom is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // Etheratom is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with Etheratom. If not, see .
17 | import { MessagePanelView, PlainMessageView } from 'atom-message-panel';
18 |
19 | export function showPanelError(err_message) {
20 | let messages;
21 | messages = new MessagePanelView({ title: 'Etheratom report' });
22 | messages.attach();
23 | messages.add(new PlainMessageView({ message: err_message, className: 'red-message' }));
24 | }
25 |
--------------------------------------------------------------------------------
/lib/reducers/AccountReducer.js:
--------------------------------------------------------------------------------
1 | 'use babel'
2 | // Copyright 2018 Etheratom Authors
3 | // This file is part of Etheratom.
4 |
5 | // Etheratom is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // Etheratom is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with Etheratom. If not, see .
17 | import { SET_COINBASE, SET_PASSWORD, SET_ACCOUNTS, SET_BALANCE } from '../actions/types';
18 | const INITIAL_STATE = {
19 | coinbase: '',
20 | password: false,
21 | accounts: [],
22 | balance: 0.00,
23 | };
24 | export default (state = INITIAL_STATE, action) => {
25 | switch (action.type) {
26 | case SET_COINBASE:
27 | return { ...state, coinbase: action.payload };
28 | case SET_PASSWORD:
29 | return { ...state, password: action.payload.password };
30 | case SET_ACCOUNTS:
31 | return { ...state, accounts: action.payload };
32 | case SET_BALANCE:
33 | return { ...state, balance: action.payload };
34 | default:
35 | return state;
36 | }
37 | };
38 |
--------------------------------------------------------------------------------
/lib/reducers/ClientReducer.js:
--------------------------------------------------------------------------------
1 | 'use babel'
2 | // Copyright 2018 Etheratom Authors
3 | // This file is part of Etheratom.
4 |
5 | // Etheratom is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // Etheratom is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with Etheratom. If not, see .
17 | import { SET_CONNECTION_STATUS, IS_WS_PROVIDER, IS_HTTP_PROVIDER, FIRST_TIME_CHECK_ENABLE } from '../actions/types';
18 | const INITIAL_STATE = {
19 | clients: [
20 | {
21 | provider: 'web3',
22 | desc: 'Backend ethereum node',
23 | hasConnection: false,
24 | firstTimeCheck: true,
25 | isWsProvider: false,
26 | isHttpProvider: false,
27 | }
28 | ]
29 | };
30 | export default (state = INITIAL_STATE, action) => {
31 | switch (action.type) {
32 | case SET_CONNECTION_STATUS:
33 | return { ...state, clients: action.payload };
34 | case FIRST_TIME_CHECK_ENABLE:
35 | // TODO: modify only one key:value
36 | return { ...state, clients: action.payload };
37 | case IS_WS_PROVIDER:
38 | return { ...state, clients: action.payload };
39 | case IS_HTTP_PROVIDER:
40 | return { ...state, clients: action.payload };
41 | default:
42 | return state;
43 | }
44 | };
45 |
--------------------------------------------------------------------------------
/lib/reducers/ContractReducer.js:
--------------------------------------------------------------------------------
1 | 'use babel'
2 | // Copyright 2018 Etheratom Authors
3 | // This file is part of Etheratom.
4 |
5 | // Etheratom is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // Etheratom is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with Etheratom. If not, see .
17 | import {
18 | SET_SOURCES,
19 | SET_COMPILING,
20 | SET_DEPLOYED,
21 | SET_COMPILED,
22 | RESET_COMPILED,
23 | RESET_CONTRACTS,
24 | SET_INSTANCE,
25 | SET_PARAMS,
26 | ADD_INTERFACE,
27 | UPDATE_INTERFACE,
28 | UPDATE_OPTIONS,
29 | ADD_TX_HASH,
30 | SET_GAS_LIMIT,
31 | SET_GAS_ESTIMATE
32 | } from '../actions/types';
33 | const INITIAL_STATE = {
34 | compiled: null,
35 | compiling: false,
36 | deployed: false,
37 | interfaces: null,
38 | contracts: null,
39 | instances: null,
40 | gasLimit: 0,
41 | gasEstimate: 90000
42 | };
43 | export default (state = INITIAL_STATE, action) => {
44 | switch (action.type) {
45 | case SET_SOURCES:
46 | return { ...state, sources: action.payload };
47 | case SET_COMPILING:
48 | return { ...state, compiling: action.payload };
49 | case SET_DEPLOYED:
50 | return { ...state, deployed: { ...state.deployed, [action.payload.contractName]: action.payload.deployed } };
51 | case SET_COMPILED:
52 | return { ...state, compiled: action.payload };
53 | case RESET_CONTRACTS:
54 | return { ...INITIAL_STATE };
55 | case RESET_COMPILED:
56 | return { ...state, compiled: null, deployed: false, interfaces: null, instances: null };
57 | case SET_INSTANCE:
58 | return { ...state, instances: { ...state.instances, [action.payload.contractName]: action.payload.instance } };
59 | case SET_PARAMS:
60 | return { ...state, interfaces: { ...state.interfaces, [action.payload.contractName]: { interface: action.payload.interface } } };
61 | case ADD_INTERFACE:
62 | return { ...state, interfaces: { ...state.interfaces, [action.payload.contractName]: { interface: action.payload.interface } } };
63 | case UPDATE_INTERFACE:
64 | return { ...state, interfaces: { ...state.interfaces, [action.payload.contractName]: { interface: action.payload.interface } } };
65 | case UPDATE_OPTIONS:
66 | // We want to access contracts like following:
67 | // contracts[myContract].options, contracts[myContract].methods, contracts[myContract].events
68 | return {
69 | ...state,
70 | contracts: {
71 | ...state.contracts,
72 | [action.payload.contractName]: {
73 | options: action.payload.options,
74 | transactionHash: (state.contracts && state.contracts[action.payload.contractName]) ? state.contracts[action.payload.contractName].transactionHash : null
75 | }
76 | }
77 | };
78 | case ADD_TX_HASH:
79 | return {
80 | ...state,
81 | contracts: {
82 | ...state.contracts,
83 | [action.payload.contractName]: {
84 | transactionHash: action.payload.transactionHash,
85 | options: state.contracts[action.payload.contractName].options
86 | }
87 | }
88 | };
89 | case SET_GAS_LIMIT:
90 | return { ...state, gasLimit: action.payload };
91 | case SET_GAS_ESTIMATE:
92 | return { ...state, gasEstimate: action.payload.gasEstimate };
93 | default:
94 | return state;
95 | }
96 | };
97 |
--------------------------------------------------------------------------------
/lib/reducers/ErrorReducer.js:
--------------------------------------------------------------------------------
1 | 'use babel'
2 | // Copyright 2018 Etheratom Authors
3 | // This file is part of Etheratom.
4 |
5 | // Etheratom is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // Etheratom is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with Etheratom. If not, see .
17 | import { SET_ERRORS, RESET_ERRORS } from '../actions/types';
18 | const INITIAL_STATE = {
19 | errormsg: [],
20 | };
21 | export default (state = INITIAL_STATE, action) => {
22 | switch (action.type) {
23 | case SET_ERRORS:
24 | return { ...state, errormsg: action.payload };
25 | case RESET_ERRORS:
26 | return { ...INITIAL_STATE };
27 | default:
28 | return state;
29 | }
30 | };
31 |
--------------------------------------------------------------------------------
/lib/reducers/EventReducer.js:
--------------------------------------------------------------------------------
1 | 'use babel'
2 | // Copyright 2018 Etheratom Authors
3 | // This file is part of Etheratom.
4 |
5 | // Etheratom is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // Etheratom is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with Etheratom. If not, see .
17 | import { ADD_PENDING_TRANSACTION, ADD_EVENTS, SET_EVENTS, TEXT_ANALYSIS } from '../actions/types';
18 | const INITIAL_STATE = {
19 | pendingTransactions: [],
20 | events: [],
21 | txAnalysis: {}
22 | };
23 | export default (state = INITIAL_STATE, action) => {
24 | switch (action.type) {
25 | case ADD_PENDING_TRANSACTION:
26 | return { ...state, pendingTransactions: [...state.pendingTransactions, action.payload] };
27 | case ADD_EVENTS:
28 | return { ...state, events: [...state.events, action.payload] };
29 | case SET_EVENTS:
30 | return { ...state, events: [] };
31 | case TEXT_ANALYSIS:
32 | return { ...state, txAnalysis: action.payload };
33 | default:
34 | return state;
35 | }
36 | };
37 |
--------------------------------------------------------------------------------
/lib/reducers/FilesReducer.js:
--------------------------------------------------------------------------------
1 | 'use babel'
2 | // Copyright 2018 Etheratom Authors
3 | // This file is part of Etheratom.
4 |
5 | // Etheratom is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // Etheratom is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with Etheratom. If not, see .
17 | import {
18 | SET_SOURCES,
19 | RESET_SOURCES
20 | } from '../actions/types';
21 |
22 | const INITIAL_STATE = {
23 | sources: {}
24 | };
25 |
26 | export default (state = INITIAL_STATE, action) => {
27 | switch (action.type) {
28 | case SET_SOURCES:
29 | return { ...state, sources: action.payload };
30 | case RESET_SOURCES:
31 | return { ...INITIAL_STATE };
32 | default:
33 | return state;
34 | }
35 | };
36 |
--------------------------------------------------------------------------------
/lib/reducers/NodeReducer.js:
--------------------------------------------------------------------------------
1 | 'use babel'
2 | // Copyright 2018 Etheratom Authors
3 | // This file is part of Etheratom.
4 |
5 | // Etheratom is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // Etheratom is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with Etheratom. If not, see .
17 | import { SET_SYNC_STATUS, SET_SYNCING, SET_MINING, SET_HASH_RATE } from '../actions/types';
18 | const INITIAL_STATE = {
19 | syncing: false,
20 | status: {},
21 | mining: false,
22 | hashRate: 0
23 | };
24 | export default (state = INITIAL_STATE, action) => {
25 | switch (action.type) {
26 | case SET_SYNCING:
27 | return { ...state, syncing: action.payload };
28 | case SET_SYNC_STATUS:
29 | return { ...state, status: action.payload };
30 | case SET_MINING:
31 | return { ...state, mining: action.payload };
32 | case SET_HASH_RATE:
33 | return { ...state, hashRate: action.payload };
34 | default:
35 | return state;
36 | }
37 | };
38 |
--------------------------------------------------------------------------------
/lib/reducers/index.js:
--------------------------------------------------------------------------------
1 | 'use babel'
2 | // Copyright 2018 Etheratom Authors
3 | // This file is part of Etheratom.
4 |
5 | // Etheratom is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // Etheratom is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with Etheratom. If not, see .
17 | import { combineReducers } from 'redux';
18 | import FilesReducer from './FilesReducer';
19 | import ContractReducer from './ContractReducer';
20 | import AccountReducer from './AccountReducer';
21 | import ErrorReducer from './ErrorReducer';
22 | import EventReducer from './EventReducer';
23 | import ClientReducer from './ClientReducer';
24 | import NodeReducer from './NodeReducer';
25 |
26 | export default combineReducers({
27 | files: FilesReducer,
28 | contract: ContractReducer,
29 | account: AccountReducer,
30 | errors: ErrorReducer,
31 | eventReducer: EventReducer,
32 | clientReducer: ClientReducer,
33 | node: NodeReducer
34 | });
35 |
--------------------------------------------------------------------------------
/lib/web3/view.js:
--------------------------------------------------------------------------------
1 | 'use babel'
2 | // Copyright 2018 Etheratom Authors
3 | // This file is part of Etheratom.
4 |
5 | // Etheratom is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // Etheratom is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with Etheratom. If not, see .
17 | import React from 'react';
18 | import ReactDOM from 'react-dom';
19 | import Web3Helpers from './methods';
20 | import TabView from '../components/TabView';
21 | import CoinbaseView from '../components/CoinbaseView';
22 | import VersionSelector from '../components/VersionSelector';
23 | import CompileBtn from '../components/CompileBtn';
24 | import { SET_ACCOUNTS, SET_COINBASE } from '../actions/types';
25 | import LoaderView from '../components/LoaderView';
26 |
27 | export default class View {
28 | constructor(store) {
29 | this.Accounts = [];
30 | this.coinbase = null;
31 | this.store = store;
32 | this.helpers = new Web3Helpers(this.store);
33 | }
34 | async createCoinbaseView() {
35 | try {
36 | await this.helpers.getAccounts();
37 | ReactDOM.render(, document.getElementById('accounts-list'));
38 | } catch (e) {
39 | console.log(e);
40 | this.helpers.showPanelError('No account exists! Please create one.');
41 | this.store.dispatch({ type: SET_ACCOUNTS, payload: [] });
42 | this.store.dispatch({ type: SET_COINBASE, payload: '0x00' });
43 | ReactDOM.render(, document.getElementById('accounts-list'));
44 |
45 | throw e;
46 | }
47 | }
48 | createButtonsView() {
49 | ReactDOM.render(
50 |