From 9a70d776b46655cd5320fc81d294ba819bc26f32 Mon Sep 17 00:00:00 2001 From: Daniel Kmak Date: Thu, 22 Mar 2018 14:57:18 +0300 Subject: [PATCH] [FEATURE] Redirection to the DApp for details. --- common/Root.tsx | 4 +- .../TransactionSucceeded.tsx | 14 +- common/components/GenerateTransaction.tsx | 19 +-- .../GenerateTransactionFactory.tsx | 2 +- .../ScheduleTransactionFactory/Container.tsx | 20 --- .../ScheduleTransactionFactory.tsx | 88 ------------ .../ScheduleTransactionFactory/index.ts | 1 - .../SendButtonFactory/SendButtonFactory.tsx | 2 +- .../GenerateScheduleTransactionButton.tsx | 15 ++ .../components/ScheduleTransactionFactory.tsx | 23 +++ .../SendScheduleTransactionButton.tsx | 32 +++++ .../SendScheduleTransactionButtonFactory.tsx | 29 ++++ .../index.tsx | 15 +- .../components/Fields/Fields.tsx | 133 +++++++++++------- .../components/Fields/SchedulingFields.tsx | 104 +++++++------- common/libs/scheduling.ts | 5 + .../sagas/transaction/broadcast/helpers.tsx | 12 +- common/selectors/transaction/transaction.ts | 24 +--- package.json | 3 + .../transaction/broadcast/helpers.spec.tsx | 17 ++- 20 files changed, 298 insertions(+), 264 deletions(-) delete mode 100644 common/components/ScheduleTransactionFactory/Container.tsx delete mode 100644 common/components/ScheduleTransactionFactory/ScheduleTransactionFactory.tsx delete mode 100644 common/components/ScheduleTransactionFactory/index.ts create mode 100644 common/containers/Tabs/ScheduleTransaction/components/GenerateScheduleTransactionButton.tsx create mode 100644 common/containers/Tabs/ScheduleTransaction/components/ScheduleTransactionFactory.tsx create mode 100644 common/containers/Tabs/ScheduleTransaction/components/SendScheduleTransactionButton.tsx create mode 100644 common/containers/Tabs/ScheduleTransaction/components/SendScheduleTransactionButtonFactory.tsx rename common/containers/Tabs/{Schedule => ScheduleTransaction}/index.tsx (77%) diff --git a/common/Root.tsx b/common/Root.tsx index 58b4195b..39ee6c70 100644 --- a/common/Root.tsx +++ b/common/Root.tsx @@ -4,7 +4,7 @@ import { withRouter, Switch, Redirect, HashRouter, Route, BrowserRouter } from ' // Components import Contracts from 'containers/Tabs/Contracts'; import ENS from 'containers/Tabs/ENS'; -import Schedule from 'containers/Tabs/Schedule'; +import ScheduleTransaction from 'containers/Tabs/ScheduleTransaction'; import GenerateWallet from 'containers/Tabs/GenerateWallet'; import SendTransaction from 'containers/Tabs/SendTransaction'; import Swap from 'containers/Tabs/Swap'; @@ -82,7 +82,7 @@ class RootClass extends Component { - + diff --git a/common/components/ExtendedNotifications/TransactionSucceeded.tsx b/common/components/ExtendedNotifications/TransactionSucceeded.tsx index 49206528..06a96d74 100644 --- a/common/components/ExtendedNotifications/TransactionSucceeded.tsx +++ b/common/components/ExtendedNotifications/TransactionSucceeded.tsx @@ -3,13 +3,15 @@ import { Link } from 'react-router-dom'; import translate from 'translations'; import { NewTabLink } from 'components/ui'; import { BlockExplorerConfig } from 'types/network'; +import { getTXDetailsCheckURL } from 'libs/scheduling'; export interface TransactionSucceededProps { txHash: string; blockExplorer?: BlockExplorerConfig; + scheduling?: boolean; } -const TransactionSucceeded = ({ txHash, blockExplorer }: TransactionSucceededProps) => { +const TransactionSucceeded = ({ txHash, blockExplorer, scheduling }: TransactionSucceededProps) => { let verifyBtn: React.ReactElement | undefined; if (blockExplorer) { verifyBtn = ( @@ -19,11 +21,21 @@ const TransactionSucceeded = ({ txHash, blockExplorer }: TransactionSucceededPro ); } + let scheduleDetailsBtn: React.ReactElement | undefined; + if (scheduling) { + scheduleDetailsBtn = ( + + {translate('SCHEDULE_check')} + + ); + } + return (

{translate('SUCCESS_3')} {txHash}

+ {scheduleDetailsBtn} {verifyBtn} {translate('NAV_CHECKTXSTATUS')} diff --git a/common/components/GenerateTransaction.tsx b/common/components/GenerateTransaction.tsx index ae236e06..a7252030 100644 --- a/common/components/GenerateTransaction.tsx +++ b/common/components/GenerateTransaction.tsx @@ -1,25 +1,8 @@ import { GenerateTransactionFactory } from './GenerateTransactionFactory'; import React from 'react'; import translate from 'translations'; -import { ScheduleTransactionFactory } from './ScheduleTransactionFactory'; - -interface Props { - scheduling?: boolean; -} - -export const GenerateTransaction: React.SFC = props => { - if (props.scheduling) { - return ( - ( - - )} - /> - ); - } +export const GenerateTransaction: React.SFC<{}> = () => { return ( ( diff --git a/common/components/GenerateTransactionFactory/GenerateTransactionFactory.tsx b/common/components/GenerateTransactionFactory/GenerateTransactionFactory.tsx index 4ec8d4e8..1e78c0f4 100644 --- a/common/components/GenerateTransactionFactory/GenerateTransactionFactory.tsx +++ b/common/components/GenerateTransactionFactory/GenerateTransactionFactory.tsx @@ -42,7 +42,7 @@ interface OwnProps { type Props = OwnProps & StateProps; -class GenerateTransactionFactoryClass extends Component { +export class GenerateTransactionFactoryClass extends Component { public render() { const { walletType, diff --git a/common/components/ScheduleTransactionFactory/Container.tsx b/common/components/ScheduleTransactionFactory/Container.tsx deleted file mode 100644 index d7814ead..00000000 --- a/common/components/ScheduleTransactionFactory/Container.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { signTransactionRequested, TSignTransactionRequested } from 'actions/transaction'; -import React, { Component } from 'react'; -import { connect } from 'react-redux'; - -interface DispatchProps { - signTransactionRequested: TSignTransactionRequested; -} - -interface OwnProps { - isWeb3: boolean; - withSigner(signer: TSignTransactionRequested): React.ReactElement | null; -} - -class Container extends Component { - public render() { - return this.props.withSigner(this.props.signTransactionRequested); - } -} - -export const WithSigner = connect(null, { signTransactionRequested })(Container); diff --git a/common/components/ScheduleTransactionFactory/ScheduleTransactionFactory.tsx b/common/components/ScheduleTransactionFactory/ScheduleTransactionFactory.tsx deleted file mode 100644 index d9ae8841..00000000 --- a/common/components/ScheduleTransactionFactory/ScheduleTransactionFactory.tsx +++ /dev/null @@ -1,88 +0,0 @@ -import { WithSigner } from './Container'; -import EthTx from 'ethereumjs-tx'; -import React, { Component } from 'react'; -import { connect } from 'react-redux'; -import { AppState } from 'reducers'; -import { - getSchedulingTransaction, - isNetworkRequestPending, - isValidGasPrice, - isValidGasLimit, - getGasPrice, - getCurrentTo, - getCurrentValue -} from 'selectors/transaction'; -import { getWalletType } from 'selectors/wallet'; -import { getWindowStart } from '../../selectors/transaction/fields'; - -export interface CallbackProps { - disabled: boolean; - isWeb3Wallet: boolean; - onClick(): void; -} - -interface StateProps { - transaction: EthTx; - networkRequestPending: boolean; - isFullTransaction: boolean; - isWeb3Wallet: boolean; - validGasPrice: boolean; - validGasLimit: boolean; - isWindowStartValid: boolean; - windowStart: any; - gasPrice: any; - currentTo: any; - currentValue: any; -} - -interface OwnProps { - withProps(props: CallbackProps): React.ReactElement | null; -} - -type Props = OwnProps & StateProps; - -class ScheduleTransactionFactoryClass extends Component { - public render() { - const { - isFullTransaction, - isWeb3Wallet, - networkRequestPending, - validGasPrice, - validGasLimit, - isWindowStartValid, - transaction - } = this.props; - - const isButtonDisabled = - !isWindowStartValid || - !isFullTransaction || - networkRequestPending || - !validGasPrice || - !validGasLimit; - - return ( - - this.props.withProps({ - disabled: isButtonDisabled, - isWeb3Wallet, - onClick: () => signer(transaction) - }) - } - /> - ); - } -} - -export const ScheduleTransactionFactory = connect((state: AppState) => ({ - ...getSchedulingTransaction(state), - networkRequestPending: isNetworkRequestPending(state), - isWeb3Wallet: getWalletType(state).isWeb3Wallet, - validGasPrice: isValidGasPrice(state), - validGasLimit: isValidGasLimit(state), - windowStart: getWindowStart(state), - gasPrice: getGasPrice(state), - currentTo: getCurrentTo(state), - currentValue: getCurrentValue(state) -}))(ScheduleTransactionFactoryClass); diff --git a/common/components/ScheduleTransactionFactory/index.ts b/common/components/ScheduleTransactionFactory/index.ts deleted file mode 100644 index 925cde69..00000000 --- a/common/components/ScheduleTransactionFactory/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './ScheduleTransactionFactory'; diff --git a/common/components/SendButtonFactory/SendButtonFactory.tsx b/common/components/SendButtonFactory/SendButtonFactory.tsx index a4bf908e..5bed56d6 100644 --- a/common/components/SendButtonFactory/SendButtonFactory.tsx +++ b/common/components/SendButtonFactory/SendButtonFactory.tsx @@ -41,7 +41,7 @@ interface OwnProps { type Props = StateProps & OwnProps; -class SendButtonFactoryClass extends Component { +export class SendButtonFactoryClass extends Component { public render() { const { signing, diff --git a/common/containers/Tabs/ScheduleTransaction/components/GenerateScheduleTransactionButton.tsx b/common/containers/Tabs/ScheduleTransaction/components/GenerateScheduleTransactionButton.tsx new file mode 100644 index 00000000..2c0e9329 --- /dev/null +++ b/common/containers/Tabs/ScheduleTransaction/components/GenerateScheduleTransactionButton.tsx @@ -0,0 +1,15 @@ +import React from 'react'; +import translate from 'translations'; +import { ScheduleTransactionFactory } from './ScheduleTransactionFactory'; + +export const GenerateScheduleTransactionButton: React.SFC<{}> = () => { + return ( + ( + + )} + /> + ); +}; diff --git a/common/containers/Tabs/ScheduleTransaction/components/ScheduleTransactionFactory.tsx b/common/containers/Tabs/ScheduleTransaction/components/ScheduleTransactionFactory.tsx new file mode 100644 index 00000000..f28807a3 --- /dev/null +++ b/common/containers/Tabs/ScheduleTransaction/components/ScheduleTransactionFactory.tsx @@ -0,0 +1,23 @@ +import { connect } from 'react-redux'; +import { AppState } from 'reducers'; +import { + getSchedulingTransaction, + isNetworkRequestPending, + isValidGasPrice, + isValidGasLimit, + getSerializedTransaction, + getSignedTx +} from 'selectors/transaction'; +import { getWalletType } from 'selectors/wallet'; +import { GenerateTransactionFactoryClass } from 'components/GenerateTransactionFactory'; + +export const ScheduleTransactionFactory = connect((state: AppState) => ({ + ...getSchedulingTransaction(state), + walletType: getWalletType(state), + serializedTransaction: getSerializedTransaction(state), + networkRequestPending: isNetworkRequestPending(state), + isWeb3Wallet: getWalletType(state).isWeb3Wallet, + validGasPrice: isValidGasPrice(state), + validGasLimit: isValidGasLimit(state), + signedTx: !!getSignedTx(state) +}))(GenerateTransactionFactoryClass); diff --git a/common/containers/Tabs/ScheduleTransaction/components/SendScheduleTransactionButton.tsx b/common/containers/Tabs/ScheduleTransaction/components/SendScheduleTransactionButton.tsx new file mode 100644 index 00000000..5009e382 --- /dev/null +++ b/common/containers/Tabs/ScheduleTransaction/components/SendScheduleTransactionButton.tsx @@ -0,0 +1,32 @@ +import React from 'react'; +import translate from 'translations'; +import { ConfirmationModal } from 'components/ConfirmationModal'; +import { SigningStatus } from 'components'; +import { SendScheduleTransactionButtonFactory } from 'containers/Tabs/ScheduleTransaction/components/SendScheduleTransactionButtonFactory'; + +export const SendScheduleTransactionButton: React.SFC<{ + className?: string; + signing?: boolean; + customModal?: typeof ConfirmationModal; +}> = ({ signing, customModal, className }) => ( + + ( + + + + )} + /> + + +); diff --git a/common/containers/Tabs/ScheduleTransaction/components/SendScheduleTransactionButtonFactory.tsx b/common/containers/Tabs/ScheduleTransaction/components/SendScheduleTransactionButtonFactory.tsx new file mode 100644 index 00000000..7b6bf57a --- /dev/null +++ b/common/containers/Tabs/ScheduleTransaction/components/SendScheduleTransactionButtonFactory.tsx @@ -0,0 +1,29 @@ +import { getWalletType } from 'selectors/wallet'; +import { connect } from 'react-redux'; +import { AppState } from 'reducers'; +import { + getSerializedTransaction, + isNetworkRequestPending, + isValidGasPrice, + isValidGasLimit, + getSignedTx, + getWeb3Tx, + getSchedulingTransaction +} from 'selectors/transaction'; +import { SendButtonFactoryClass } from 'components/SendButtonFactory'; + +const mapStateToProps = (state: AppState) => { + return { + walletType: getWalletType(state), + serializedTransaction: getSerializedTransaction(state), + ...getSchedulingTransaction(state), + networkRequestPending: isNetworkRequestPending(state), + validGasPrice: isValidGasPrice(state), + validGasLimit: isValidGasLimit(state), + signedTx: !!getSignedTx(state) || !!getWeb3Tx(state) + }; +}; + +export const SendScheduleTransactionButtonFactory = connect(mapStateToProps)( + SendButtonFactoryClass +); diff --git a/common/containers/Tabs/Schedule/index.tsx b/common/containers/Tabs/ScheduleTransaction/index.tsx similarity index 77% rename from common/containers/Tabs/Schedule/index.tsx rename to common/containers/Tabs/ScheduleTransaction/index.tsx index 78ac9fa9..a29c5819 100644 --- a/common/containers/Tabs/Schedule/index.tsx +++ b/common/containers/Tabs/ScheduleTransaction/index.tsx @@ -7,8 +7,8 @@ import { getWalletInst } from 'selectors/wallet'; import { AppState } from 'reducers'; import { RouteComponentProps, Redirect } from 'react-router'; import { UnavailableWallets, SchedulingFields } from 'containers/Tabs/SendTransaction/components'; -import { isNetworkUnit } from 'selectors/config/wallet'; import { SideBar } from '../SendTransaction/components/SideBar'; +import { getNetworkConfig } from 'selectors/config'; const ScheduleMain = () => ( @@ -18,16 +18,19 @@ const ScheduleMain = () => ( ); interface StateProps { + schedulingDisabled: boolean; wallet: AppState['wallet']['inst']; - requestDisabled: boolean; } type Props = StateProps & RouteComponentProps<{}>; class Schedule extends React.Component { public render() { - const { wallet, match } = this.props; - const currentPath = match.url; + const { schedulingDisabled, wallet } = this.props; + + if (schedulingDisabled && wallet) { + return ; + } return ( @@ -36,7 +39,7 @@ class Schedule extends React.Component { {wallet && (
- {wallet.isReadOnly ? : }; + {wallet.isReadOnly ? : };
@@ -49,5 +52,5 @@ class Schedule extends React.Component { export default connect((state: AppState) => ({ wallet: getWalletInst(state), - requestDisabled: !isNetworkUnit(state, 'ETH') + schedulingDisabled: getNetworkConfig(state).name !== 'Kovan' }))(Schedule); diff --git a/common/containers/Tabs/SendTransaction/components/Fields/Fields.tsx b/common/containers/Tabs/SendTransaction/components/Fields/Fields.tsx index 2886b13f..43235cc1 100644 --- a/common/containers/Tabs/SendTransaction/components/Fields/Fields.tsx +++ b/common/containers/Tabs/SendTransaction/components/Fields/Fields.tsx @@ -8,16 +8,23 @@ import { CurrentCustomMessage, GenerateTransaction, SendButton, - SigningStatus, - WindowStartField + WindowStartField, + ScheduleTimestampField, + ScheduleTimezoneDropDown, + TimeBountyField, + ScheduleType, + WindowSizeField, + ScheduleGasPriceField } from 'components'; import { OnlyUnlocked, WhenQueryExists } from 'components/renderCbs'; import translate from 'translations'; import { AppState } from 'reducers'; import { NonStandardTransaction } from './components'; -import { getCurrentWindowStart, ICurrentWindowStart } from 'selectors/transaction'; -import { getNetworkConfig } from 'selectors/config'; +import { getOffline } from 'selectors/config'; +import { SendScheduleTransactionButton } from 'containers/Tabs/ScheduleTransaction/components/SendScheduleTransactionButton'; +import { GenerateScheduleTransactionButton } from 'containers/Tabs/ScheduleTransaction/components/GenerateScheduleTransactionButton'; +import { getCurrentScheduleType, ICurrentScheduleType } from 'selectors/transaction'; const QueryWarning: React.SFC<{}> = () => ( = () => ( ); interface StateProps { - schedulingDisabled: boolean; + scheduling: boolean; shouldDisplay: boolean; offline: boolean; - windowStart: ICurrentWindowStart; + schedulingType: ICurrentScheduleType; } class FieldsClass extends Component { public render() { - const { schedulingDisabled, shouldDisplay, windowStart } = this.props; - - const scheduling = Boolean(windowStart.value); - - const content = ( -
- -
-
- - -
-
- - {!schedulingDisabled && ( -
-
- -
-
- )} - -
-
- -
-
- - - - -
-
- -
-
- -
- -
-
- ); + const { shouldDisplay, scheduling, schedulingType } = this.props; return ( {
+ {scheduling && ( +
+
Scheduled Transaction Settings
+
+ +
+
+ +
+ + {schedulingType.value === 'time' && ( +
+
+ +
+
+ +
+
+ )} + + {schedulingType.value === 'block' && ( +
+
+ +
+
+ )} + +
+ +
+
+ +
+
+ +
+
+ +
+
+
+ )} +
- +
- {offline ? : } + {this.getTxButton()} )} @@ -112,11 +123,29 @@ class FieldsClass extends Component { /> ); } + + private getTxButton() { + const { offline, scheduling } = this.props; + + if (scheduling) { + if (offline) { + return ; + } + + return ; + } + + if (offline) { + return ; + } + + return ; + } } export const Fields = connect((state: AppState) => ({ + scheduling: true, shouldDisplay: !isAnyOfflineWithWeb3(state), offline: getOffline(state), - windowStart: getCurrentWindowStart(state), - schedulingDisabled: getNetworkConfig(state).name !== 'Kovan' + schedulingType: getCurrentScheduleType(state) }))(FieldsClass); diff --git a/common/containers/Tabs/SendTransaction/components/Fields/SchedulingFields.tsx b/common/containers/Tabs/SendTransaction/components/Fields/SchedulingFields.tsx index 4e847920..745875d8 100644 --- a/common/containers/Tabs/SendTransaction/components/Fields/SchedulingFields.tsx +++ b/common/containers/Tabs/SendTransaction/components/Fields/SchedulingFields.tsx @@ -5,11 +5,7 @@ import { AddressField, AmountField, TXMetaDataPanel, - SendEverything, CurrentCustomMessage, - GenerateTransaction, - SendButton, - SigningStatus, WindowStartField } from 'components'; import { OnlyUnlocked, WhenQueryExists } from 'components/renderCbs'; @@ -18,6 +14,9 @@ import translate from 'translations'; import { AppState } from 'reducers'; import { NonStandardTransaction } from './components'; import { NewTabLink } from 'components/ui'; +import { getOffline } from 'selectors/config'; +import { SendScheduleTransactionButton } from 'containers/Tabs/ScheduleTransaction/components/SendScheduleTransactionButton'; +import { GenerateScheduleTransactionButton } from 'containers/Tabs/ScheduleTransaction/components/GenerateScheduleTransactionButton'; const EACLink = () => ( @@ -35,64 +34,62 @@ const QueryWarning: React.SFC<{}> = () => ( interface StateProps { shouldDisplay: boolean; + offline: boolean; } class SchedulingFieldsClass extends Component { public render() { - const { shouldDisplay } = this.props; - - const content = ( -
-
-
-

ChronoLogic Scheduler

- Powered by the , ChronoLogic Scheduler is a decentralized scheduling protocol - based on the Ethereum blockchain. -
-
-
- - -
-
- - -
-
- -
-
- -
-
- -
-
- -
-
- - - - -
-
- -
-
- -
- -
-
- ); + const { shouldDisplay, offline } = this.props; return ( - {shouldDisplay ? content : null} + {shouldDisplay && ( +
+
+
+

ChronoLogic Scheduler

+ Powered by the , ChronoLogic Scheduler is a decentralized scheduling + protocol based on the Ethereum blockchain. +
+
+
+ + +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + + + +
+
+ {offline ? ( + + ) : ( + + )} +
+
+
+ )} } /> @@ -101,5 +98,6 @@ class SchedulingFieldsClass extends Component { } export const SchedulingFields = connect((state: AppState) => ({ - shouldDisplay: !isAnyOfflineWithWeb3(state) + shouldDisplay: !isAnyOfflineWithWeb3(state), + offline: getOffline(state) }))(SchedulingFieldsClass); diff --git a/common/libs/scheduling.ts b/common/libs/scheduling.ts index ac58d294..6f43cd04 100644 --- a/common/libs/scheduling.ts +++ b/common/libs/scheduling.ts @@ -2,6 +2,7 @@ import BN from 'bn.js'; import abi from 'ethereumjs-abi'; export const EAC_SCHEDULING_CONFIG = { + DAPP_ADDRESS: 'https://app.chronologic.network', FEE: new BN('2242000000000000'), // $2 FEE_MULTIPLIER: new BN('2'), FUTURE_EXECUTION_COST: new BN('180000'), @@ -65,3 +66,7 @@ export const getScheduleData = ( requiredDeposit ]); }; + +export const getTXDetailsCheckURL = (txHash: string) => { + return `${EAC_SCHEDULING_CONFIG.DAPP_ADDRESS}/awaiting/scheduler/${txHash}`; +}; diff --git a/common/sagas/transaction/broadcast/helpers.tsx b/common/sagas/transaction/broadcast/helpers.tsx index c97a9f82..10f913c7 100644 --- a/common/sagas/transaction/broadcast/helpers.tsx +++ b/common/sagas/transaction/broadcast/helpers.tsx @@ -1,5 +1,11 @@ import { SagaIterator } from 'redux-saga'; -import { getWeb3Tx, getSignedTx, getTransactionStatus } from 'selectors/transaction'; +import { + getWeb3Tx, + getSignedTx, + getTransactionStatus, + getWindowStart, + ICurrentWindowStart +} from 'selectors/transaction'; import { select, call, put } from 'redux-saga/effects'; import { broadcastTransactionFailed, @@ -50,14 +56,18 @@ export const broadcastTransactionWrapper = (func: (serializedTx: string) => Saga const broadcastedHash: string = yield call(func, stringTx); // convert to string because node / web3 doesnt support buffers yield put(broadcastTransactionSucceeded({ indexingHash, broadcastedHash })); + const windowStart: ICurrentWindowStart = yield select(getWindowStart); const network: NetworkConfig = yield select(getNetworkConfig); + const scheduling = Boolean(windowStart && windowStart.value); + yield put( showNotification( 'success', , Infinity ) diff --git a/common/selectors/transaction/transaction.ts b/common/selectors/transaction/transaction.ts index 84aaa6cb..6c88272c 100644 --- a/common/selectors/transaction/transaction.ts +++ b/common/selectors/transaction/transaction.ts @@ -31,12 +31,6 @@ export interface IGetTransaction { isFullTransaction: boolean; //if the user has filled all the fields } -export interface IGetSchedulingTransaction { - transaction: EthTx; - isFullTransaction: boolean; - isWindowStartValid: boolean; -} - const getTransaction = (state: AppState): IGetTransaction => { const currentTo = getCurrentTo(state); const currentValue = getCurrentValue(state); @@ -59,7 +53,7 @@ const getTransaction = (state: AppState): IGetTransaction => { return { transaction, isFullTransaction }; }; -const getSchedulingTransaction = (state: AppState): IGetSchedulingTransaction => { +const getSchedulingTransaction = (state: AppState): IGetTransaction => { const currentTo = getCurrentTo(state); const currentValue = getCurrentValue(state); const transactionFields = getFields(state); @@ -72,16 +66,11 @@ const getSchedulingTransaction = (state: AppState): IGetSchedulingTransaction => const nonce = getNonce(state); const gasPrice = getGasPrice(state); const timeBounty = getTimeBounty(state); + const windowStartValid = isWindowStartValid(transactionFields, getLatestBlock(state)); - const isFullTransaction = isFullTx( - state, - transactionFields, - currentTo, - currentValue, - dataExists, - validGasCost, - unit - ); + const isFullTransaction = + isFullTx(state, transactionFields, currentTo, currentValue, dataExists, validGasCost, unit) && + windowStartValid; const transactionData = getScheduleData( currentTo.raw, @@ -119,8 +108,7 @@ const getSchedulingTransaction = (state: AppState): IGetSchedulingTransaction => return { transaction, - isFullTransaction, - isWindowStartValid: isWindowStartValid(transactionFields, getLatestBlock(state)) + isFullTransaction }; }; diff --git a/package.json b/package.json index 007e3d88..6aa8e916 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,9 @@ "ledgerco": "1.2.1", "lodash": "4.17.5", "moment": "2.22.0", + "moment-timezone": "0.5.14", "normalizr": "3.2.4", + "pikaday-time": "1.6.1", "qrcode": "1.2.0", "qrcode.react": "0.8.0", "query-string": "6.0.0", @@ -60,6 +62,7 @@ "@types/history": "4.6.2", "@types/jest": "22.2.2", "@types/lodash": "4.14.106", + "@types/moment-timezone": "0.5.4", "@types/qrcode": "0.8.0", "@types/qrcode.react": "0.6.3", "@types/query-string": "5.1.0", diff --git a/spec/sagas/transaction/broadcast/helpers.spec.tsx b/spec/sagas/transaction/broadcast/helpers.spec.tsx index 5dc1044f..24d9be9d 100644 --- a/spec/sagas/transaction/broadcast/helpers.spec.tsx +++ b/spec/sagas/transaction/broadcast/helpers.spec.tsx @@ -1,4 +1,9 @@ -import { getWeb3Tx, getSignedTx, getTransactionStatus } from 'selectors/transaction'; +import { + getWeb3Tx, + getSignedTx, + getTransactionStatus, + getWindowStart +} from 'selectors/transaction'; import { select, call, put } from 'redux-saga/effects'; import { broadcastTransactionFailed, @@ -118,6 +123,10 @@ describe('broadcastTransactionWrapper*', () => { ); }); + it('select getWindowStart', () => { + expect(gens.gen.next().value).toEqual(select(getWindowStart)); + }); + it('select getNetworkConfig', () => { expect(gens.gen.next().value).toEqual(select(getNetworkConfig)); }); @@ -127,7 +136,11 @@ describe('broadcastTransactionWrapper*', () => { put( showNotification( 'success', - , + , Infinity ) )