mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-02-10 18:16:45 +00:00
### Re-implements: * min/max validators on initial currency swap selection * polling of order status * timer that persists across refreshes via localStorage (computed based on `createdTime` and `validFor` amount) * swap persists across refreshes once order is created. * various type refactors ### New additions: * *SimpleButton* (can be PRd separately on request) * clear loading state after order create (via SimpleButton and font-awesome) * buffers for non-BTC swaps (bity does not actually accept 0.01 BTC worth of ETH as they claim they do in their JSON response, so a magic number of 10% is added to the minimum).
53 lines
1.0 KiB
JavaScript
53 lines
1.0 KiB
JavaScript
// @flow
|
|
|
|
/*** Shared types ***/
|
|
export type NOTIFICATION_LEVEL = 'danger' | 'warning' | 'success' | 'info';
|
|
export type INFINITY = 'infinity';
|
|
|
|
export type Notification = {
|
|
level: NOTIFICATION_LEVEL,
|
|
msg: string,
|
|
duration?: number | INFINITY
|
|
};
|
|
|
|
/*** Show Notification ***/
|
|
export type ShowNotificationAction = {
|
|
type: 'SHOW_NOTIFICATION',
|
|
payload: Notification
|
|
};
|
|
|
|
export function showNotification(
|
|
level: NOTIFICATION_LEVEL = 'info',
|
|
msg: string,
|
|
duration?: number
|
|
): ShowNotificationAction {
|
|
return {
|
|
type: 'SHOW_NOTIFICATION',
|
|
payload: {
|
|
level,
|
|
msg,
|
|
duration
|
|
}
|
|
};
|
|
}
|
|
|
|
/*** Close notification ***/
|
|
export type CloseNotificationAction = {
|
|
type: 'CLOSE_NOTIFICATION',
|
|
payload: Notification
|
|
};
|
|
|
|
export function closeNotification(
|
|
notification: Notification
|
|
): CloseNotificationAction {
|
|
return {
|
|
type: 'CLOSE_NOTIFICATION',
|
|
payload: notification
|
|
};
|
|
}
|
|
|
|
/*** Union Type ***/
|
|
export type NotificationsAction =
|
|
| ShowNotificationAction
|
|
| CloseNotificationAction;
|