Update enqueueSnackbar types

This commit is contained in:
Germán Martínez 2019-09-17 16:02:46 +02:00
parent 72f40ff494
commit e183bb3415
14 changed files with 43 additions and 20 deletions

View File

@ -14,7 +14,12 @@ import Layout from './component/Layout'
import actions, { type Actions } from './actions'
import selector, { type SelectorProps } from './selector'
type Variant = 'success' | 'error' | 'warning' | 'info'
const SUCCESS = 'SUCCESS'
const ERROR = 'ERROR'
const WARNING = 'WARNING'
const INFO = 'INFO'
export type Variant = SUCCESS | ERROR | WARNING | INFO
type Props = Actions &
SelectorProps & {

View File

@ -3,6 +3,7 @@ import type { Dispatch as ReduxDispatch } from 'redux'
import { ETHEREUM_NETWORK_IDS, ETHEREUM_NETWORK } from '~/logic/wallets/getWeb3'
import type { ProviderProps } from '~/logic/wallets/store/model/provider'
import { makeProvider } from '~/logic/wallets/store/model/provider'
import { type Variant } from '~/components/Header'
import addProvider from './addProvider'
export const processProviderResponse = (dispatch: ReduxDispatch<*>, provider: ProviderProps) => {
@ -26,7 +27,10 @@ const UNLOCK_MSG = 'Unlock your wallet to connect'
const WRONG_NETWORK = 'You are connected to wrong network. Please use RINKEBY'
export const WALLET_ERROR_MSG = 'Error connecting to your wallet'
const handleProviderNotification = (enqueueSnackbar: Function, provider: ProviderProps) => {
const handleProviderNotification = (
enqueueSnackbar: (message: string, variant: Variant) => void,
provider: ProviderProps,
) => {
const { loaded, available, network } = provider
if (!loaded) {
@ -44,7 +48,9 @@ const handleProviderNotification = (enqueueSnackbar: Function, provider: Provide
enqueueSnackbar(msg, variant)
}
export default (provider: ProviderProps, enqueueSnackbar: Function) => (dispatch: ReduxDispatch<*>) => {
export default (provider: ProviderProps, enqueueSnackbar: (message: string, variant: Variant) => void) => (
dispatch: ReduxDispatch<*>,
) => {
handleProviderNotification(enqueueSnackbar, provider)
processProviderResponse(dispatch, provider)
}

View File

@ -1,9 +1,10 @@
// @flow
import type { Dispatch as ReduxDispatch } from 'redux'
import { makeProvider, type ProviderProps, type Provider } from '~/logic/wallets/store/model/provider'
import { type Variant } from '~/components/Header'
import addProvider from './addProvider'
export default (enqueueSnackbar: Function) => async (dispatch: ReduxDispatch<*>) => {
export default (enqueueSnackbar: (message: string, variant: Variant) => void) => async (dispatch: ReduxDispatch<*>) => {
const providerProps: ProviderProps = {
name: '',
available: false,

View File

@ -13,8 +13,9 @@ import Button from '~/components/layout/Button'
import Img from '~/components/layout/Img'
import Block from '~/components/layout/Block'
import Identicon from '~/components/Identicon'
import { copyToClipboard } from '~/utils/clipboard'
import Hairline from '~/components/layout/Hairline'
import { type Variant } from '~/components/Header'
import { copyToClipboard } from '~/utils/clipboard'
import SafeInfo from '~/routes/safe/components/Balances/SendModal/SafeInfo'
import { setImageToPlaceholder } from '~/routes/safe/components/Balances/utils'
import { getWeb3 } from '~/logic/wallets/getWeb3'
@ -33,7 +34,7 @@ type Props = {
ethBalance: string,
tx: Object,
createTransaction: Function,
enqueueSnackbar: Function,
enqueueSnackbar: (message: string, variant: Variant) => void,
}
const openIconStyle = {

View File

@ -15,6 +15,7 @@ import Block from '~/components/layout/Block'
import Identicon from '~/components/Identicon'
import { copyToClipboard } from '~/utils/clipboard'
import Hairline from '~/components/layout/Hairline'
import { type Variant } from '~/components/Header'
import SafeInfo from '~/routes/safe/components/Balances/SendModal/SafeInfo'
import { setImageToPlaceholder } from '~/routes/safe/components/Balances/utils'
import { getStandardTokenContract } from '~/logic/tokens/store/actions/fetchTokens'
@ -35,7 +36,7 @@ type Props = {
ethBalance: string,
tx: Object,
createTransaction: Function,
enqueueSnackbar: Function,
enqueueSnackbar: (message: string, variant: Variant) => void,
}
const openIconStyle = {

View File

@ -12,6 +12,7 @@ import GnoForm from '~/components/forms/GnoForm'
import Row from '~/components/layout/Row'
import Paragraph from '~/components/layout/Paragraph'
import Button from '~/components/layout/Button'
import { type Variant } from '~/components/Header'
import { styles } from './style'
export const SAFE_NAME_INPUT_TEST_ID = 'safe-name-input'
@ -22,7 +23,7 @@ type Props = {
safeAddress: string,
safeName: string,
updateSafe: Function,
enqueueSnackbar: Function,
enqueueSnackbar: (message: string, variant: Variant) => void,
}
const ChangeSafeName = (props: Props) => {

View File

@ -4,6 +4,7 @@ import { List } from 'immutable'
import { withStyles } from '@material-ui/core/styles'
import { withSnackbar } from 'notistack'
import Modal from '~/components/Modal'
import { type Variant } from '~/components/Header'
import { type Owner } from '~/routes/safe/store/models/owner'
import { getGnosisSafeInstanceAt } from '~/logic/contracts/safeContracts'
import OwnerForm from './screens/OwnerForm'
@ -29,7 +30,7 @@ type Props = {
network: string,
addSafeOwner: Function,
createTransaction: Function,
enqueueSnackbar: Function,
enqueueSnackbar: (message: string, variant: Variant) => void,
}
type ActiveScreen = 'selectOwner' | 'selectThreshold' | 'reviewAddOwner'
@ -37,7 +38,7 @@ export const sendAddOwner = async (
values: Object,
safeAddress: string,
ownersOld: List<Owner>,
enqueueSnackbar: Function,
enqueueSnackbar: (message: string, variant: Variant) => void,
createTransaction: Function,
addSafeOwner: Function,
) => {

View File

@ -4,6 +4,7 @@ import { List } from 'immutable'
import { withStyles } from '@material-ui/core/styles'
import { withSnackbar } from 'notistack'
import Modal from '~/components/Modal'
import { type Variant } from '~/components/Header'
import { type Owner } from '~/routes/safe/store/models/owner'
import { getGnosisSafeInstanceAt, SENTINEL_ADDRESS } from '~/logic/contracts/safeContracts'
import CheckOwner from './screens/CheckOwner'
@ -31,7 +32,7 @@ type Props = {
network: string,
createTransaction: Function,
removeSafeOwner: Function,
enqueueSnackbar: Function,
enqueueSnackbar: (message: string, variant: Variant) => void,
}
type ActiveScreen = 'checkOwner' | 'selectThreshold' | 'reviewRemoveOwner'
@ -42,7 +43,7 @@ export const sendRemoveOwner = async (
ownerAddressToRemove: string,
ownerNameToRemove: string,
ownersOld: List<Owner>,
enqueueSnackbar: Function,
enqueueSnackbar: (message: string, variant: Variant) => void,
createTransaction: Function,
removeSafeOwner: Function,
) => {

View File

@ -4,6 +4,7 @@ import { List } from 'immutable'
import { withStyles } from '@material-ui/core/styles'
import { withSnackbar } from 'notistack'
import Modal from '~/components/Modal'
import { type Variant } from '~/components/Header'
import { getGnosisSafeInstanceAt, SENTINEL_ADDRESS } from '~/logic/contracts/safeContracts'
import OwnerForm from './screens/OwnerForm'
import ReviewReplaceOwner from './screens/Review'
@ -29,7 +30,7 @@ type Props = {
threshold: string,
createTransaction: Function,
replaceSafeOwner: Function,
enqueueSnackbar: Function,
enqueueSnackbar: (message: string, variant: Variant) => void,
}
type ActiveScreen = 'checkOwner' | 'reviewReplaceOwner'
@ -37,7 +38,7 @@ export const sendReplaceOwner = async (
values: Object,
safeAddress: string,
ownerAddressToRemove: string,
enqueueSnackbar: Function,
enqueueSnackbar: (message: string, variant: Variant) => void,
createTransaction: Function,
replaceSafeOwner: Function,
) => {

View File

@ -10,10 +10,11 @@ import Block from '~/components/layout/Block'
import Row from '~/components/layout/Row'
import Modal from '~/components/Modal'
import Paragraph from '~/components/layout/Paragraph'
import { type Variant } from '~/components/Header'
import ChangeThreshold from './ChangeThreshold'
import type { Owner } from '~/routes/safe/store/models/owner'
import { styles } from './style'
import { getGnosisSafeInstanceAt } from '~/logic/contracts/safeContracts'
import { styles } from './style'
type Props = {
owners: List<Owner>,
@ -22,7 +23,7 @@ type Props = {
createTransaction: Function,
safeAddress: string,
granted: boolean,
enqueueSnackbar: Function,
enqueueSnackbar: (message: string, variant: Variant) => void,
}
const ThresholdSettings = ({

View File

@ -13,6 +13,7 @@ import Row from '~/components/layout/Row'
import Bold from '~/components/layout/Bold'
import Block from '~/components/layout/Block'
import Paragraph from '~/components/layout/Paragraph'
import { type Variant } from '~/components/Header'
import { type Transaction } from '~/routes/safe/store/models/transaction'
import { styles } from './style'
@ -29,7 +30,7 @@ type Props = {
threshold: number,
thresholdReached: boolean,
userAddress: string,
enqueueSnackbar: Function,
enqueueSnackbar: (message: string, variant: Variant) => void,
}
const getModalTitleAndDescription = (thresholdReached: boolean) => {

View File

@ -13,6 +13,7 @@ import Block from '~/components/layout/Block'
import Paragraph from '~/components/layout/Paragraph'
import { type Transaction } from '~/routes/safe/store/models/transaction'
import { EMPTY_DATA } from '~/logic/wallets/ethTransactions'
import { type Variant } from '~/components/Header'
import { styles } from './style'
type Props = {
@ -22,7 +23,7 @@ type Props = {
createTransaction: Function,
tx: Transaction,
safeAddress: string,
enqueueSnackbar: Function,
enqueueSnackbar: (message: string, variant: Variant) => void,
}
const CancelTxModal = ({

View File

@ -12,13 +12,14 @@ import {
type Notifications,
DEFAULT_NOTIFICATIONS,
} from '~/logic/safe/transactions'
import { type Variant } from '~/components/Header'
const createTransaction = (
safeAddress: string,
to: string,
valueInWei: string,
txData: string = EMPTY_DATA,
enqueueSnackbar: Function,
enqueueSnackbar: (message: string, variant: Variant) => void,
shouldExecute?: boolean,
notifications?: Notifications = DEFAULT_NOTIFICATIONS,
) => async (dispatch: ReduxDispatch<GlobalState>, getState: GetState<GlobalState>) => {

View File

@ -6,6 +6,7 @@ import fetchTransactions from '~/routes/safe/store/actions/fetchTransactions'
import { type GlobalState } from '~/store'
import { getGnosisSafeInstanceAt } from '~/logic/contracts/safeContracts'
import { approveTransaction, executeTransaction, CALL } from '~/logic/safe/transactions'
import { type Variant } from '~/components/Header'
// https://gnosis-safe.readthedocs.io/en/latest/contracts/signatures.html#pre-validated-signatures
// https://github.com/gnosis/safe-contracts/blob/master/test/gnosisSafeTeamEdition.js#L26
@ -31,7 +32,7 @@ const generateSignaturesFromTxConfirmations = (tx: Transaction, preApprovingOwne
const processTransaction = (
safeAddress: string,
tx: Transaction,
enqueueSnackbar: Function,
enqueueSnackbar: (message: string, variant: Variant) => void,
userAddress: string,
approveAndExecute?: boolean,
) => async (dispatch: ReduxDispatch<GlobalState>, getState: GetState<GlobalState>) => {