conflicts in action and saga

This commit is contained in:
Jonathan Rainville 2018-08-31 16:44:43 -04:00 committed by Pascal Precht
parent b945b87d4d
commit 7080be9fb1
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
5 changed files with 28 additions and 7 deletions

View File

@ -200,6 +200,13 @@ export const files = {
failure: (error) => action(FILES[FAILURE], {error}) failure: (error) => action(FILES[FAILURE], {error})
}; };
export const ETH_GAS = createRequestTypes('ETH_GAS');
export const ethGas = {
request: () => action(ETH_GAS[REQUEST]),
success: (gasStats) => action(ETH_GAS[SUCCESS], {gasStats: [gasStats]}),
failure: (error) => action(ETH_GAS[FAILURE], {error})
};
// Web Socket // Web Socket
export const WATCH_NEW_PROCESS_LOGS = 'WATCH_NEW_PROCESS_LOGS'; export const WATCH_NEW_PROCESS_LOGS = 'WATCH_NEW_PROCESS_LOGS';
export const WATCH_NEW_CONTRACT_LOGS = 'WATCH_NEW_CONTRACT_LOGS'; export const WATCH_NEW_CONTRACT_LOGS = 'WATCH_NEW_CONTRACT_LOGS';

View File

@ -1,8 +1,9 @@
import axios from "axios"; import axios from "axios";
import constants from '../constants'; import constants from '../constants';
function get(path, params) { function get(path, params, endpoint) {
return axios.get(constants.httpEndpoint + path, params) console.log('GET ', (endpoint || constants.httpEndpoint) + path);
return axios.get((endpoint || constants.httpEndpoint) + path, params)
.then((response) => { .then((response) => {
return {response, error: null}; return {response, error: null};
}).catch((error) => { }).catch((error) => {
@ -108,6 +109,10 @@ export function fetchContractFile(payload) {
return get('/files/contracts', {params: payload}); return get('/files/contracts', {params: payload});
} }
export function getEthGasAPI() {
return get('/json/ethgasAPI.json', {}, 'https://ethgasstation.info');
}
export function fetchLastFiddle() { export function fetchLastFiddle() {
return get('/files/lastfiddle', {params: 'temp'}); return get('/files/lastfiddle', {params: 'temp'});
} }

View File

@ -3,7 +3,7 @@ import {connect} from 'react-redux';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import {withRouter} from 'react-router-dom'; import {withRouter} from 'react-router-dom';
import {contractProfile as contractProfileAction, contractDeploy as contractDeployAction} from '../actions'; import {contractProfile as contractProfileAction, contractDeploy as contractDeployAction, ethGas as ethGasAction} from '../actions';
import ContractFunctions from '../components/ContractFunctions'; import ContractFunctions from '../components/ContractFunctions';
import DataWrapper from "../components/DataWrapper"; import DataWrapper from "../components/DataWrapper";
import {getContractProfile, getContractDeploys} from "../reducers/selectors"; import {getContractProfile, getContractDeploys} from "../reducers/selectors";
@ -11,6 +11,7 @@ import {getContractProfile, getContractDeploys} from "../reducers/selectors";
class ContractDeploymentContainer extends Component { class ContractDeploymentContainer extends Component {
componentDidMount() { componentDidMount() {
this.props.fetchContractProfile(this.props.match.params.contractName); this.props.fetchContractProfile(this.props.match.params.contractName);
this.props.fetchEthGas();
} }
render() { render() {
@ -49,6 +50,7 @@ export default withRouter(connect(
mapStateToProps, mapStateToProps,
{ {
fetchContractProfile: contractProfileAction.request, fetchContractProfile: contractProfileAction.request,
postContractDeploy: contractDeployAction.post postContractDeploy: contractDeployAction.post,
fetchEthGas: ethGasAction.request
} }
)(ContractDeploymentContainer)); )(ContractDeploymentContainer));

View File

@ -24,7 +24,8 @@ const entitiesDefaultState = {
versions: [], versions: [],
plugins: [], plugins: [],
ensRecords: [], ensRecords: [],
files: [] files: [],
gasStats: []
}; };
const sorter = { const sorter = {

View File

@ -6,7 +6,7 @@ import {all, call, fork, put, takeEvery, take} from 'redux-saga/effects';
const {account, accounts, block, blocks, transaction, transactions, processes, commands, processLogs, const {account, accounts, block, blocks, transaction, transactions, processes, commands, processLogs,
contracts, contract, contractProfile, messageSend, versions, plugins, messageListen, fiddle, contracts, contract, contractProfile, messageSend, versions, plugins, messageListen, fiddle,
fiddleDeploy, ensRecord, ensRecords, contractLogs, contractFile, contractFunction, contractDeploy, fiddleDeploy, ensRecord, ensRecords, contractLogs, contractFile, contractFunction, contractDeploy,
fiddleFile, files} = actions; fiddleFile, files, ethGas} = actions;
function *doRequest(entity, apiFn, payload) { function *doRequest(entity, apiFn, payload) {
const {response, error} = yield call(apiFn, payload); const {response, error} = yield call(apiFn, payload);
@ -42,6 +42,7 @@ export const sendMessage = doRequest.bind(null, messageSend, api.sendMessage);
export const fetchEnsRecord = doRequest.bind(null, ensRecord, api.fetchEnsRecord); export const fetchEnsRecord = doRequest.bind(null, ensRecord, api.fetchEnsRecord);
export const postEnsRecord = doRequest.bind(null, ensRecords, api.postEnsRecord); export const postEnsRecord = doRequest.bind(null, ensRecords, api.postEnsRecord);
export const fetchFiles = doRequest.bind(null, files, api.fetchFiles); export const fetchFiles = doRequest.bind(null, files, api.fetchFiles);
export const fetchEthGas = doRequest.bind(null, ethGas, api.getEthGasAPI);
export function *watchFetchTransaction() { export function *watchFetchTransaction() {
yield takeEvery(actions.TRANSACTION[actions.REQUEST], fetchTransaction); yield takeEvery(actions.TRANSACTION[actions.REQUEST], fetchTransaction);
@ -151,6 +152,10 @@ export function *watchFetchFiles() {
yield takeEvery(actions.FILES[actions.REQUEST], fetchFiles); yield takeEvery(actions.FILES[actions.REQUEST], fetchFiles);
} }
export function *watchFetchEthGas() {
yield takeEvery(actions.ETH_GAS[actions.REQUEST], fetchEthGas);
}
function createChannel(socket) { function createChannel(socket) {
return eventChannel(emit => { return eventChannel(emit => {
socket.onmessage = ((message) => { socket.onmessage = ((message) => {
@ -242,6 +247,7 @@ export default function *root() {
fork(watchFetchLastFiddleSuccess), fork(watchFetchLastFiddleSuccess),
fork(watchFetchEnsRecord), fork(watchFetchEnsRecord),
fork(watchPostEnsRecords), fork(watchPostEnsRecords),
fork(watchFetchFiles) fork(watchFetchFiles),
fork(watchFetchEthGas)
]); ]);
} }