2017-06-26 22:27:55 +00:00
|
|
|
// @flow
|
|
|
|
import { takeEvery, call, put, select } from 'redux-saga/effects';
|
|
|
|
import { delay } from 'redux-saga';
|
2017-07-03 23:59:27 +00:00
|
|
|
import type { Effect } from 'redux-saga/effects';
|
2017-06-26 22:27:55 +00:00
|
|
|
import { cacheEnsAddress } from 'actions/ens';
|
|
|
|
import type { ResolveEnsNameAction } from 'actions/ens';
|
|
|
|
import { getEnsAddress } from 'selectors/ens';
|
2017-07-04 00:20:47 +00:00
|
|
|
import { donationAddressMap } from 'config/data';
|
2017-07-03 23:59:27 +00:00
|
|
|
function* resolveEns(action?: ResolveEnsNameAction) {
|
|
|
|
if (!action) return;
|
2017-06-26 22:27:55 +00:00
|
|
|
const ensName = action.payload;
|
|
|
|
// FIXME Add resolve logic
|
|
|
|
//// _ens.getAddress(scope.addressDrtv.ensAddressField, function(data) {
|
|
|
|
// if (data.error) uiFuncs.notifier.danger(data.msg);
|
|
|
|
// else if (data.data == '0x0000000000000000000000000000000000000000' || data.data == '0x') {
|
|
|
|
// setValue('0x0000000000000000000000000000000000000000');
|
|
|
|
// scope.addressDrtv.derivedAddress = '0x0000000000000000000000000000000000000000';
|
|
|
|
// scope.addressDrtv.showDerivedAddress = true;
|
|
|
|
// } else {
|
|
|
|
// setValue(data.data);
|
|
|
|
// scope.addressDrtv.derivedAddress = ethUtil.toChecksumAddress(data.data);
|
|
|
|
// scope.addressDrtv.showDerivedAddress = true;
|
|
|
|
|
2017-07-04 00:20:47 +00:00
|
|
|
const cachedEnsAddress = yield select(getEnsAddress, ensName);
|
2017-06-26 22:27:55 +00:00
|
|
|
|
2017-07-04 00:20:47 +00:00
|
|
|
if (cachedEnsAddress) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
yield call(delay, 1000);
|
|
|
|
yield put(cacheEnsAddress(ensName, donationAddressMap.ETH));
|
2017-06-26 22:27:55 +00:00
|
|
|
}
|
|
|
|
|
2017-07-03 23:59:27 +00:00
|
|
|
export default function* notificationsSaga(): Generator<Effect, void, any> {
|
2017-06-26 22:27:55 +00:00
|
|
|
yield takeEvery('ENS_RESOLVE', resolveEns);
|
2017-07-04 02:18:16 +00:00
|
|
|
export default function* notificationsSaga() {
|
|
|
|
yield takeEvery('ENS_RESOLVE', resolveEns);
|
2017-06-26 22:27:55 +00:00
|
|
|
export default function* notificationsSaga() {
|
2017-07-04 00:20:47 +00:00
|
|
|
yield takeEvery('ENS_RESOLVE', resolveEns);
|
2017-06-26 22:27:55 +00:00
|
|
|
}
|