From d219e4614fc30c3992a7b0a8a8639fa629ce90f4 Mon Sep 17 00:00:00 2001 From: Ezerous Date: Mon, 8 Apr 2019 21:43:20 +0300 Subject: [PATCH] Refactoring --- app/src/redux/actions/drizzleUtilsActions.js | 1 - app/src/redux/actions/web3UtilsActions.js | 1 + app/src/redux/sagas/orbitSaga.js | 6 +++--- app/src/redux/sagas/rootSaga.js | 4 ++-- app/src/redux/sagas/transactionsSaga.js | 4 ++-- app/src/redux/sagas/userSaga.js | 6 +++--- .../sagas/{drizzleUtilsSaga.js => web3UtilsSaga.js} | 12 ++++++------ app/src/utils/{drizzleUtils.js => web3Utils.js} | 0 8 files changed, 17 insertions(+), 17 deletions(-) delete mode 100644 app/src/redux/actions/drizzleUtilsActions.js create mode 100644 app/src/redux/actions/web3UtilsActions.js rename app/src/redux/sagas/{drizzleUtilsSaga.js => web3UtilsSaga.js} (71%) rename app/src/utils/{drizzleUtils.js => web3Utils.js} (100%) diff --git a/app/src/redux/actions/drizzleUtilsActions.js b/app/src/redux/actions/drizzleUtilsActions.js deleted file mode 100644 index 2581b2a..0000000 --- a/app/src/redux/actions/drizzleUtilsActions.js +++ /dev/null @@ -1 +0,0 @@ -export const DRIZZLE_UTILS_SAGA_INITIALIZED = 'DRIZZLE_UTILS_SAGA_INITIALIZED'; diff --git a/app/src/redux/actions/web3UtilsActions.js b/app/src/redux/actions/web3UtilsActions.js new file mode 100644 index 0000000..bebdd3c --- /dev/null +++ b/app/src/redux/actions/web3UtilsActions.js @@ -0,0 +1 @@ +export const WEB3_UTILS_SAGA_INITIALIZED = 'WEB3_UTILS_SAGA_INITIALIZED'; diff --git a/app/src/redux/sagas/orbitSaga.js b/app/src/redux/sagas/orbitSaga.js index 8a32e88..b817414 100644 --- a/app/src/redux/sagas/orbitSaga.js +++ b/app/src/redux/sagas/orbitSaga.js @@ -1,12 +1,12 @@ import { all, call, put, select, take, takeEvery, takeLatest } from 'redux-saga/effects'; import isEqual from 'lodash.isequal'; -import { forumContract, getCurrentAccount } from './drizzleUtilsSaga'; +import { forumContract, getCurrentAccount } from './web3UtilsSaga'; import { createTempDatabases, loadDatabases, orbitSagaOpen } from '../../utils/orbitUtils'; -import { DRIZZLE_UTILS_SAGA_INITIALIZED } from '../actions/drizzleUtilsActions'; +import { WEB3_UTILS_SAGA_INITIALIZED } from '../actions/web3UtilsActions'; import { ADD_PEER_DATABASE, PEER_DATABASE_ADDED, DATABASES_CREATED, @@ -106,7 +106,7 @@ function* updatePeersState() { function* orbitSaga() { yield all([ - take(DRIZZLE_UTILS_SAGA_INITIALIZED), + take(WEB3_UTILS_SAGA_INITIALIZED), take(IPFS_INITIALIZED) ]); yield takeLatest(ACCOUNT_CHANGED, getOrbitDBInfo); diff --git a/app/src/redux/sagas/rootSaga.js b/app/src/redux/sagas/rootSaga.js index 2a9ecac..a51edd9 100644 --- a/app/src/redux/sagas/rootSaga.js +++ b/app/src/redux/sagas/rootSaga.js @@ -1,6 +1,6 @@ import { all, fork } from 'redux-saga/effects'; import { drizzleSagas } from 'drizzle'; -import drizzleUtilsSaga from './drizzleUtilsSaga'; +import web3UtilsSaga from './web3UtilsSaga'; import userSaga from './userSaga'; import orbitSaga from './orbitSaga'; import transactionsSaga from './transactionsSaga'; @@ -9,7 +9,7 @@ import eventSaga from './eventSaga'; export default function* root() { const sagas = [ ...drizzleSagas, - drizzleUtilsSaga, + web3UtilsSaga, orbitSaga, userSaga, eventSaga, diff --git a/app/src/redux/sagas/transactionsSaga.js b/app/src/redux/sagas/transactionsSaga.js index 990c2d7..dca9b5c 100644 --- a/app/src/redux/sagas/transactionsSaga.js +++ b/app/src/redux/sagas/transactionsSaga.js @@ -2,7 +2,7 @@ import { call, select, take, takeEvery } from 'redux-saga/effects'; import { drizzle } from '../../index'; import { orbitSagaPut } from '../../utils/orbitUtils'; -import { DRIZZLE_UTILS_SAGA_INITIALIZED } from '../actions/drizzleUtilsActions'; +import { WEB3_UTILS_SAGA_INITIALIZED } from '../actions/web3UtilsActions'; import { CONTRACT_EVENT_FIRED } from './eventSaga'; const transactionsHistory = Object.create(null); @@ -73,7 +73,7 @@ function* handleError() { } function* transactionsSaga() { - yield take(DRIZZLE_UTILS_SAGA_INITIALIZED); + yield take(WEB3_UTILS_SAGA_INITIALIZED); yield takeEvery('INIT_TRANSACTION', initTransaction); yield takeEvery(CONTRACT_EVENT_FIRED, handleEvent); yield takeEvery('TX_ERROR', handleError); diff --git a/app/src/redux/sagas/userSaga.js b/app/src/redux/sagas/userSaga.js index d3edcf5..3a15ad5 100644 --- a/app/src/redux/sagas/userSaga.js +++ b/app/src/redux/sagas/userSaga.js @@ -1,7 +1,7 @@ import { call, put, select, take, takeEvery } from 'redux-saga/effects'; -import { forumContract, getCurrentAccount } from './drizzleUtilsSaga'; -import { DRIZZLE_UTILS_SAGA_INITIALIZED } from '../actions/drizzleUtilsActions'; +import { forumContract, getCurrentAccount } from './web3UtilsSaga'; +import { WEB3_UTILS_SAGA_INITIALIZED } from '../actions/web3UtilsActions'; import { ACCOUNT_CHANGED, AUTH_USER_DATA_UPDATED, @@ -61,7 +61,7 @@ function* getUserState() { } function* userSaga() { - yield take(DRIZZLE_UTILS_SAGA_INITIALIZED); + yield take(WEB3_UTILS_SAGA_INITIALIZED); yield takeEvery(ACCOUNTS_FETCHED, updateUserData); } diff --git a/app/src/redux/sagas/drizzleUtilsSaga.js b/app/src/redux/sagas/web3UtilsSaga.js similarity index 71% rename from app/src/redux/sagas/drizzleUtilsSaga.js rename to app/src/redux/sagas/web3UtilsSaga.js index 3e6bab4..caaea81 100644 --- a/app/src/redux/sagas/drizzleUtilsSaga.js +++ b/app/src/redux/sagas/web3UtilsSaga.js @@ -1,8 +1,8 @@ import { call, put, select, takeLatest } from 'redux-saga/effects'; -import { getContractInstance, getWeb3 } from '../../utils/drizzleUtils'; +import { getContractInstance, getWeb3 } from '../../utils/web3Utils'; import Forum from '../../contracts/Forum'; -import { DRIZZLE_UTILS_SAGA_INITIALIZED } from '../actions/drizzleUtilsActions'; +import { WEB3_UTILS_SAGA_INITIALIZED } from '../actions/web3UtilsActions'; import { DRIZZLE_INITIALIZED } from '../actions/drizzleActions'; const accounts = state => state.accounts; @@ -16,10 +16,10 @@ function* init() { }); initFlag = true; yield put({ - type: DRIZZLE_UTILS_SAGA_INITIALIZED, ...[] + type: WEB3_UTILS_SAGA_INITIALIZED, ...[] }); } - else console.warn('Attempted to reinitialize drizzleUtilsSaga!'); + else console.warn('Attempted to reinitialize web3UtilsSaga!'); } // If the method below proves to be problematic/ineffective (i.e. getting current account @@ -29,10 +29,10 @@ function* getCurrentAccount() { return (yield select(accounts))[0]; } -function* drizzleUtilsSaga() { +function* web3UtilsSaga() { yield takeLatest(DRIZZLE_INITIALIZED, init); } export { web3, forumContract, getCurrentAccount }; -export default drizzleUtilsSaga; +export default web3UtilsSaga; diff --git a/app/src/utils/drizzleUtils.js b/app/src/utils/web3Utils.js similarity index 100% rename from app/src/utils/drizzleUtils.js rename to app/src/utils/web3Utils.js