[FEATURE] Hide scheduling when sending tokens.

This commit is contained in:
Daniel Kmak 2018-04-06 15:47:15 +02:00 committed by GitHub
parent 6596f70e7b
commit ac0a398a9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 3 deletions

View File

@ -19,7 +19,11 @@ import translate from 'translations';
import { AppState } from 'reducers';
import { NonStandardTransaction } from './components';
import { getOffline, getNetworkConfig } from 'selectors/config';
import { getCurrentSchedulingToggle, ICurrentSchedulingToggle } from 'selectors/transaction';
import {
getCurrentSchedulingToggle,
ICurrentSchedulingToggle,
getUnit
} from 'selectors/transaction';
const QueryWarning: React.SFC<{}> = () => (
<WhenQueryExists
@ -103,7 +107,7 @@ class FieldsClass extends Component<StateProps> {
}
export const Fields = connect((state: AppState) => ({
schedulingAvailable: getNetworkConfig(state).name === 'Kovan',
schedulingAvailable: getNetworkConfig(state).name === 'Kovan' && getUnit(state) === 'ETH',
shouldDisplay: !isAnyOfflineWithWeb3(state),
offline: getOffline(state),
useScheduling: getCurrentSchedulingToggle(state).value

View File

@ -1,6 +1,6 @@
import { select, call, put, takeEvery } from 'redux-saga/effects';
import { SagaIterator } from 'redux-saga';
import { SetUnitMetaAction, TypeKeys } from 'actions/transaction';
import { SetUnitMetaAction, TypeKeys, setSchedulingToggle } from 'actions/transaction';
import {
getTokenTo,
getTokenValue,
@ -84,6 +84,13 @@ export function* handleSetUnitMeta({ payload: currentUnit }: SetUnitMetaAction):
};
// need to set meta fields for tokenTo and tokenValue
if (etherToToken) {
yield put(
setSchedulingToggle({
raw: 'false',
value: false
})
);
return yield put(
swapEtherToToken({
...basePayload,

View File

@ -22,6 +22,7 @@ import { handleSetUnitMeta } from 'sagas/transaction/meta/unitSwap';
import { isNetworkUnit } from 'selectors/config';
import { SagaIterator } from 'redux-saga';
import BN from 'bn.js';
import { setSchedulingToggle } from 'actions/transaction';
const itShouldBeDone = (gen: SagaIterator) => {
it('should be done', () => {
@ -207,6 +208,17 @@ describe('handleSetUnitMeta*', () => {
sharedLogicB(gens.gen, input, raw, value, currentUnit, isValid);
it('should put setSchedulingToogle', () => {
expect(gens.gen.next(to).value).toEqual(
put(
setSchedulingToggle({
raw: 'false',
value: false
})
)
);
});
it('should put swapEtherToToken', () => {
const data = encodeTransfer(to.value, value);
const payload: any = constructExpectedPayload(