mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-02-26 09:45:18 +00:00
* [FEATURE] Initial EAC integration. * Title and explanation * [FEATURE] Move the Schedule Payment to the main tab. * [FEATURE] TimeBounty slider. * [FEATURE] Move to main menu. * [FEATURE] Redirection to the DApp for details. * [FEATURE] Timestamp scheduling * Scheduling: Basic date and time widget * Linting fixes * Moved the datetime field to new tab * Fixed push errors * Added missing specs * Undid unintentional UI change * Fixed some failing tests * Ignore datetime parameter when checking if a transaction is full * Added a date selector widget and renamed ScheduleTimestamp to ScheduleDate * Marked componentDidMount * Initialized Pikaday * Revert "Initialized Pikaday" This reverts commit 4e5bf5b2b882f236f5977400abf9b7092cbd1592. * Revert "Marked componentDidMount" This reverts commit 85d52192ac58f4b6ca9219e702f7390cd27e582f. * Revert "Added a date selector widget and renamed ScheduleTimestamp to ScheduleDate" This reverts commit aaad0ac9b565a78d1bfc631754160919fd38a59b. * Converted the date picker into a datetime picker * Added decent styling to the datetimepicker * Added validation to the datetime picker * Fixed prepush errors for scheduling timestamp * Adjusted validation logic scheduling timestamp * [FEATURE] Move scheduling to main tab. * [FEATURE] Timezone selector * [FEATURE] Scheduling: Timezone selector * Removed zombie files * [FEATURE] Reimplement Time Bounty. * [FEATURE] Time/block selector * [FEATURE] Add Window Size field. * [FEATURE] Time/block switch functionality * Implemented time/block switcher fuctionality * [FEATURE] Add Schedule Gas Price field. * [FEATURE] Scheduling toggle * [FEATURE] Add basic styling and network check. * [FEATURE] Add Schedule Gas Limit field * [FEATURE] "Scheduled" button styling * Reordered, renamed and centered scheduling elements * Added the toggle button styling * Class -> ClassName * [FEATURE] Add Deposit field * [FEATURE] Move scheduling code into one directory * [FIX] Scheduling responsiveness * [FIX] Datetime picker not working on md screens * [FEATURE] Timestamp Scheduling basic functionality * [FIX] Fix data serialization. * [FEATURE] Timezone inclusion * [FEATURE] Add ChronoLogic logo. * [FEATURE] Add link to image. * [FIX] Update CSS of logo. * [FEATURE] Default Window Size * [FEATURE] Modified Help component to enable acting as a tooltip * [FEATURE] Call contract to validate scheduling params * [FIX] Change moment import to fix tests * [FEATURE] Gas estimation for scheduling * [FEATURE] Additional validation * [FEATURE] UI changes and descriptions * [FEATURE] Add tooltip to window and fix fee display. * [FIX] Fix ethereumjs-abi dependency. * [FEATURE] Hide scheduling when sending tokens. * [FIX] Improved styling datetime picker * [FEATURE] Add Redux state for scheduling * [FEATURE] Create Toggle component, Share code between components * [FEATURE] Use Tooltip component for help. * [FEATURE] Better datetime picker * [FEATURE] Remove fee * Trigger mycryptobuild * [FIX] Timestamp scheduling - Validation match * [FIX] EAC integration touchups * [FIX] Code review fixes * [FIX] Window Size type * [FIX] Type fixes. * [FIX] Make tooltips only show on icons + resposiveness fixes * [FIX] Break tooltips into more lines * [FIX] Remove unnecessary code. * [FIX] Remove unnecessary code. * [FIX] Remove unnecessary types declaration. * [FIX] Fee class names
99 lines
3.7 KiB
TypeScript
99 lines
3.7 KiB
TypeScript
import { SagaIterator } from 'redux-saga';
|
|
import { getWeb3Tx, getSignedTx, getTransactionStatus } from 'selectors/transaction';
|
|
import { select, call, put } from 'redux-saga/effects';
|
|
import {
|
|
broadcastTransactionFailed,
|
|
broadcastTransactionSucceeded,
|
|
broadcastTransactionQueued,
|
|
TypeKeys as TK,
|
|
reset
|
|
} from 'actions/transaction';
|
|
import { bufferToHex } from 'ethereumjs-util';
|
|
import {
|
|
BroadcastRequestedAction,
|
|
StateSerializedTx,
|
|
ISerializedTxAndIndexingHash
|
|
} from 'sagas/transaction/broadcast/typings';
|
|
import { ITransactionStatus } from 'reducers/transaction/broadcast';
|
|
import { showNotification } from 'actions/notifications';
|
|
import React from 'react';
|
|
import { getNetworkConfig } from 'selectors/config';
|
|
import TransactionSucceeded from 'components/ExtendedNotifications/TransactionSucceeded';
|
|
import { computeIndexingHash } from 'libs/transaction';
|
|
import { NetworkConfig } from 'types/network';
|
|
import { isSchedulingEnabled } from 'selectors/schedule/fields';
|
|
|
|
export const broadcastTransactionWrapper = (func: (serializedTx: string) => SagaIterator) =>
|
|
function* handleBroadcastTransaction(action: BroadcastRequestedAction) {
|
|
const { indexingHash, serializedTransaction }: ISerializedTxAndIndexingHash = yield call(
|
|
getSerializedTxAndIndexingHash,
|
|
action
|
|
);
|
|
|
|
try {
|
|
const shouldBroadcast: boolean = yield call(shouldBroadcastTransaction, indexingHash);
|
|
if (!shouldBroadcast) {
|
|
yield put(
|
|
showNotification(
|
|
'warning',
|
|
'TxHash identical: This transaction has already been broadcasted or is broadcasting'
|
|
)
|
|
);
|
|
yield put(reset());
|
|
return;
|
|
}
|
|
const queueAction = broadcastTransactionQueued({
|
|
indexingHash,
|
|
serializedTransaction
|
|
});
|
|
yield put(queueAction);
|
|
const stringTx: string = yield call(bufferToHex, serializedTransaction);
|
|
const broadcastedHash: string = yield call(func, stringTx); // convert to string because node / web3 doesnt support buffers
|
|
yield put(broadcastTransactionSucceeded({ indexingHash, broadcastedHash }));
|
|
|
|
const network: NetworkConfig = yield select(getNetworkConfig);
|
|
|
|
const scheduling: boolean = yield select(isSchedulingEnabled);
|
|
yield put(
|
|
showNotification(
|
|
'success',
|
|
<TransactionSucceeded
|
|
txHash={broadcastedHash}
|
|
blockExplorer={network.isCustom ? undefined : network.blockExplorer}
|
|
scheduling={scheduling}
|
|
/>,
|
|
Infinity
|
|
)
|
|
);
|
|
} catch (error) {
|
|
yield put(broadcastTransactionFailed({ indexingHash }));
|
|
yield put(showNotification('danger', (error as Error).message));
|
|
}
|
|
};
|
|
|
|
export function* shouldBroadcastTransaction(indexingHash: string): SagaIterator {
|
|
const existingTx: ITransactionStatus | null = yield select(getTransactionStatus, indexingHash);
|
|
// if the transaction already exists
|
|
if (existingTx) {
|
|
// and is still broadcasting or already broadcasting, dont re-broadcast
|
|
if (existingTx.isBroadcasting || existingTx.broadcastSuccessful) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
export function* getSerializedTxAndIndexingHash({ type }: BroadcastRequestedAction): SagaIterator {
|
|
const isWeb3Req = type === TK.BROADCAST_WEB3_TRANSACTION_REQUESTED;
|
|
const txSelector = isWeb3Req ? getWeb3Tx : getSignedTx;
|
|
const serializedTransaction: StateSerializedTx = yield select(txSelector);
|
|
|
|
if (!serializedTransaction) {
|
|
throw Error('Can not broadcast: tx does not exist');
|
|
}
|
|
|
|
// grab the hash without the signature, we're going to index by this
|
|
const indexingHash = yield call(computeIndexingHash, serializedTransaction);
|
|
|
|
return { serializedTransaction, indexingHash };
|
|
}
|