MyCrypto/common/sagas/ens.js

35 lines
1.5 KiB
JavaScript
Raw Normal View History

2017-06-26 22:27:55 +00:00
// @flow
import { takeEvery, call, put, select } from 'redux-saga/effects';
import { delay } from 'redux-saga';
import { cacheEnsAddress } from 'actions/ens';
import type { ResolveEnsNameAction } from 'actions/ens';
import { getEnsAddress } from 'selectors/ens';
import { donationAddressMap } from 'config/data';
2017-06-26 22:27:55 +00:00
function* resolveEns(action: ResolveEnsNameAction) {
2017-07-02 05:49:06 +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-06-26 22:27:55 +00:00
2017-07-02 05:49:06 +00:00
const cachedEnsAddress = yield select(getEnsAddress, ensName);
2017-06-26 22:27:55 +00:00
2017-07-02 05:49:06 +00:00
if (cachedEnsAddress) {
return;
}
yield call(delay, 1000);
yield put(cacheEnsAddress(ensName, donationAddressMap.ETH));
2017-06-26 22:27:55 +00:00
}
export default function* notificationsSaga() {
2017-07-02 05:49:06 +00:00
yield takeEvery('ENS_RESOLVE', resolveEns);
2017-06-26 22:27:55 +00:00
}