Skip to content

Commit 2d4cfe5

Browse files
committed
Merge branch 'sprint' into 'master'
Sprint to Master Closes OP-166 and OP-162 See merge request open-platform/api!172
2 parents 579ee50 + e8b433b commit 2d4cfe5

113 files changed

Lines changed: 3809 additions & 3509 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitlab-ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ contract-tests:
6262
alias: ganache
6363
image: openplatform/truffle
6464
script:
65+
- apk --no-cache add make g++ python && npm i web3-utils
6566
- export RPC_HOST="ganache"
6667
- cd src/test/truffle && truffle test
6768

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
### Added
9+
- Show events on scaffold page
10+
- Updates events in realtime
11+
- Show message on current token expired
12+
- Smart contract optimization
13+
14+
### Removed
15+
- Remove field description from scaffold
816

917
## [2.3.0] - 2018-06-29
1018
### Added

build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
plugins {
22
id 'jacoco'
33
id "idea"
4-
id "org.jetbrains.kotlin.jvm" version "1.2.50"
5-
id "org.jetbrains.kotlin.kapt" version "1.2.50"
6-
id "org.jetbrains.kotlin.plugin.spring" version "1.2.50"
7-
id "org.jetbrains.kotlin.plugin.jpa" version "1.2.50"
8-
id "org.springframework.boot" version "2.0.2.RELEASE"
4+
id "org.jetbrains.kotlin.jvm" version "1.2.51"
5+
id "org.jetbrains.kotlin.kapt" version "1.2.51"
6+
id "org.jetbrains.kotlin.plugin.spring" version "1.2.51"
7+
id "org.jetbrains.kotlin.plugin.jpa" version "1.2.51"
8+
id "org.springframework.boot" version "2.0.3.RELEASE"
99
}
1010

1111
apply plugin: "io.spring.dependency-management"

frontend/.vscode/settings.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

frontend/package-lock.json

Lines changed: 35 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,45 @@
11
{
2-
"name": "client",
3-
"version": "0.1.0",
4-
"private": true,
5-
"proxy": {
6-
"/oauth2/authorization/google": {
7-
"target": "http://localhost:8080"
8-
},
9-
"/api/*": {
10-
"target": "http://localhost:8080"
11-
}
2+
"name": "client",
3+
"version": "0.1.0",
4+
"private": true,
5+
"proxy": {
6+
"/oauth2": {
7+
"target": "http://localhost:8080"
128
},
13-
"dependencies": {
14-
"axios": "^0.16.2",
15-
"ethjs": "^0.4.0",
16-
"ethjs-unit": "^0.1.6",
17-
"moment": "^2.22.2",
18-
"react": "^16.4.1",
19-
"react-copy-to-clipboard": "^5.0.1",
20-
"react-dates": "^17.0.0",
21-
"react-dom": "^16.4.1",
22-
"react-redux": "^5.0.5",
23-
"react-router-dom": "^4.1.1",
24-
"react-scripts": "^1.1.4",
25-
"react-semantic-redux-form": "^1.2.6",
26-
"react-table": "^6.8.6",
27-
"redux": "^3.7.1",
28-
"redux-form": "^7.0.1",
29-
"redux-thunk": "^2.2.0",
30-
"semantic-ui-react": "^0.78.2",
31-
"styled-components": "^3.3.3",
32-
"web3": "^1.0.0-beta.34",
33-
"websocket": "^1.0.26"
34-
},
35-
"scripts": {
36-
"start": "react-scripts start",
37-
"build": "react-scripts build",
38-
"test": "react-scripts test --env=jsdom",
39-
"eject": "react-scripts eject"
40-
},
41-
"devDependencies": {
42-
"lodash": "^4.17.10"
9+
"/api/*": {
10+
"target": "http://localhost:8080"
4311
}
12+
},
13+
"dependencies": {
14+
"axios": "^0.16.2",
15+
"ethjs": "^0.4.0",
16+
"ethjs-unit": "^0.1.6",
17+
"ethjs-util": "^0.1.6",
18+
"moment": "^2.22.2",
19+
"react": "^16.4.1",
20+
"react-copy-to-clipboard": "^5.0.1",
21+
"react-dates": "^17.0.0",
22+
"react-dom": "^16.4.1",
23+
"react-redux": "^5.0.5",
24+
"react-router-dom": "^4.1.1",
25+
"react-scripts": "^1.1.4",
26+
"react-semantic-redux-form": "^1.2.6",
27+
"react-table": "^6.8.6",
28+
"redux": "^3.7.1",
29+
"redux-form": "^7.0.1",
30+
"redux-thunk": "^2.2.0",
31+
"semantic-ui-react": "^0.81.3",
32+
"styled-components": "^3.3.3",
33+
"web3": "^1.0.0-beta.34",
34+
"websocket": "^1.0.26"
35+
},
36+
"scripts": {
37+
"start": "react-scripts start",
38+
"build": "react-scripts build",
39+
"test": "react-scripts test --env=jsdom",
40+
"eject": "react-scripts eject"
41+
},
42+
"devDependencies": {
43+
"lodash": "^4.17.10"
44+
}
4445
}

frontend/src/App.js

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { Component } from 'react';
2-
import { Route, Switch } from 'react-router-dom';
2+
import { Route, Switch, Redirect } from 'react-router-dom';
33
import { fetchGlobalProperties } from './actions/global-properties';
44
import { fetchUser } from './actions/index';
55
import { connect } from 'react-redux';
@@ -10,34 +10,31 @@ import { Container } from 'semantic-ui-react';
1010
import './css/main.css';
1111

1212
class App extends Component {
13-
componentDidMount() {
14-
this.fetchUser();
15-
this.props.fetchGlobalProperties();
13+
async componentDidMount() {
14+
await this.props.fetchUser();
15+
await this.props.fetchGlobalProperties();
1616
}
1717

18-
async fetchUser() {
19-
try {
20-
await this.props.fetchUser();
21-
} catch (e) {
22-
// if 404 then
23-
// this.props.history.push('/');
24-
}
25-
}
26-
27-
render() {
18+
renderAuthorizedContent = () => {
2819
const { auth, globalProperties } = this.props;
29-
30-
if (!auth || !globalProperties) {
20+
if (!auth.isAuthorized || !globalProperties.network.id) {
3121
return null;
3222
}
3323

3424
return (
35-
<Container>
25+
<Switch>
26+
<Route path="/scaffolds" component={Scaffolds} />
27+
<Route path="/keys" component={Keys} />
28+
<Redirect from="*" to="/scaffolds" />
29+
</Switch>
30+
);
31+
};
32+
33+
render() {
34+
return (
35+
<Container style={{ paddingTop: '10px', paddingBottom: '50px' }}>
3636
<Header />
37-
<Switch>
38-
<Route path="/scaffolds" component={Scaffolds} />
39-
<Route path="/keys" component={Keys} />
40-
</Switch>
37+
{this.renderAuthorizedContent()}
4138
</Container>
4239
);
4340
}

frontend/src/actions/apiRequest.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import axios from 'axios';
2+
import { setAuthorized } from '.';
3+
import { parseApiError } from '../utils/parseApiError';
4+
5+
export const request = (method, url, data, params) => async dispatch => {
6+
try {
7+
const { data: response, headers } = await axios({
8+
method,
9+
url,
10+
params,
11+
data
12+
});
13+
14+
if (!headers['content-type'].includes('application/json')) {
15+
dispatch(setAuthorized(false));
16+
const error = { message: 'Api request finished without application/json content-type' };
17+
throw error;
18+
}
19+
20+
return response;
21+
} catch (e) {
22+
const response = e.response || {};
23+
const status = response.status;
24+
25+
if (status === 401 || status === 403) {
26+
dispatch(setAuthorized(false));
27+
}
28+
29+
throw parseApiError(e);
30+
}
31+
};
32+
33+
export const apiGet = (url, params) => async dispatch => await dispatch(request('get', url, {}, params));
34+
35+
export const apiPost = (url, data) => async dispatch => await dispatch(request('post', url, data, {}));
36+
37+
export const apiPatch = (url, data) => async dispatch => await dispatch(request('patch', url, data, {}));
38+
39+
export const apiPut = (url, data) => async dispatch => await dispatch(request('put', url, data, {}));
40+
41+
export const apiDelete = (url, data) => async dispatch => await dispatch(request('delete', url, data));
Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
import axios from 'axios';
2-
import {LOAD_SCAFFOLD_FIELDS, SET_SCAFFOLD_TEMPLATES} from './types';
3-
import {sortBy} from 'lodash';
1+
import { LOAD_SCAFFOLD_FIELDS, SET_SCAFFOLD_TEMPLATES } from './types';
2+
import { sortBy } from 'lodash';
3+
import { getTemplatesPath } from '../utils/apiPathes';
4+
import { apiGet, apiPost } from './apiRequest';
45

5-
export const setTemplate = (fields) => async dispatch => {
6-
dispatch({type: LOAD_SCAFFOLD_FIELDS, payload: fields});
6+
export const setTemplate = fields => async dispatch => {
7+
dispatch({ type: LOAD_SCAFFOLD_FIELDS, payload: fields });
78
};
89

910
export const fetchTemplates = () => async dispatch => {
10-
const result = await axios.get('/api/scaffolds/templates');
11-
dispatch({type: SET_SCAFFOLD_TEMPLATES, payload: sortBy(result.data, 'name')})
11+
const data = await dispatch(apiGet(getTemplatesPath()));
12+
dispatch({ type: SET_SCAFFOLD_TEMPLATES, payload: sortBy(data, 'name') });
1213
};
1314

14-
export const saveTemplate = (values) => async dispatch => {
15-
const result = await axios.post('/api/scaffolds/templates', {...values});
15+
export const saveTemplate = values => async dispatch => {
16+
const result = await dispatch(apiPost(getTemplatesPath(), { ...values }));
1617
dispatch(fetchTemplates());
1718
return result;
1819
};

0 commit comments

Comments
 (0)