V1.6.2 - Bugfixes (#447)

* Add trailing `/` to urls (#433)

* Fix #349:  Cancel btn grey (#438)

* Fix #409: Can't execute transactions that has more confirmations than required (#437)

* Fix #381: notification shown after loading safe (#402)

* 1.6.2

Co-authored-by: Germán Martínez <germartinez@users.noreply.github.com>
Co-authored-by: Uxío <Uxio0@users.noreply.github.com>
Co-authored-by: Agustin Pane <agustin.pane@gmail.com>
Co-authored-by: Mikhail Mikheev <mmvsha73@gmail.com>
Co-authored-by: Fernando <fernando.greco@gmail.com>
This commit is contained in:
Germán Martínez 2020-01-16 20:00:45 +01:00 committed by GitHub
parent 7777ab3f30
commit 4d33f88d78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 148 additions and 43 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "safe-react", "name": "safe-react",
"version": "1.6.1", "version": "1.6.2",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "safe-react", "name": "safe-react",
"version": "1.6.1", "version": "1.6.2",
"description": "Allowing crypto users manage funds in a safer way", "description": "Allowing crypto users manage funds in a safer way",
"homepage": "https://github.com/gnosis/safe-react#readme", "homepage": "https://github.com/gnosis/safe-react#readme",
"bugs": { "bugs": {

View File

@ -7,8 +7,8 @@ import Root from '~/components/Root'
import loadActiveTokens from '~/logic/tokens/store/actions/loadActiveTokens' import loadActiveTokens from '~/logic/tokens/store/actions/loadActiveTokens'
import loadDefaultSafe from '~/routes/safe/store/actions/loadDefaultSafe' import loadDefaultSafe from '~/routes/safe/store/actions/loadDefaultSafe'
import loadSafesFromStorage from '~/routes/safe/store/actions/loadSafesFromStorage' import loadSafesFromStorage from '~/routes/safe/store/actions/loadSafesFromStorage'
import loadCurrentSessionFromStorage from '~/logic/currentSession/store/actions/loadCurrentSessionFromStorage'
import { store } from '~/store' import { store } from '~/store'
import verifyRecurringUser from '~/utils/verifyRecurringUser'
BigNumber.set({ EXPONENTIAL_AT: [-7, 255] }) BigNumber.set({ EXPONENTIAL_AT: [-7, 255] })
@ -20,9 +20,12 @@ if (process.env.NODE_ENV !== 'production') {
// $FlowFixMe // $FlowFixMe
store.dispatch(loadActiveTokens()) store.dispatch(loadActiveTokens())
// $FlowFixMe
store.dispatch(loadSafesFromStorage()) store.dispatch(loadSafesFromStorage())
// $FlowFixMe
store.dispatch(loadDefaultSafe()) store.dispatch(loadDefaultSafe())
verifyRecurringUser() // $FlowFixMe
store.dispatch(loadCurrentSessionFromStorage())
const root = document.getElementById('root') const root = document.getElementById('root')

View File

@ -7,7 +7,7 @@ const fetchTokenCurrenciesBalances = (safeAddress: string) => {
return null return null
} }
const apiUrl = getTxServiceHost() const apiUrl = getTxServiceHost()
const url = `${apiUrl}safes/${safeAddress}/balances/usd` const url = `${apiUrl}safes/${safeAddress}/balances/usd/`
return axios.get(url) return axios.get(url)
} }

View File

@ -0,0 +1,10 @@
// @flow
import { type Dispatch as ReduxDispatch } from 'redux'
import { type GlobalState } from '~/store'
import updateViewedSafes from '~/logic/currentSession/store/actions/updateViewedSafes'
const addViewedSafe = (safeAddress: string) => (dispatch: ReduxDispatch<GlobalState>) => {
dispatch(updateViewedSafes(safeAddress))
}
export default addViewedSafe

View File

@ -0,0 +1,8 @@
// @flow
import { createAction } from 'redux-actions'
export const LOAD_CURRENT_SESSION = 'LOAD_CURRENT_SESSION'
const loadCurrentSession = createAction<string, *>(LOAD_CURRENT_SESSION)
export default loadCurrentSession

View File

@ -0,0 +1,14 @@
// @flow
import { type Dispatch as ReduxDispatch } from 'redux'
import { type GlobalState } from '~/store'
import { getCurrentSessionFromStorage } from '~/logic/currentSession/utils'
import loadCurrentSession from '~/logic/currentSession/store/actions/loadCurrentSession'
import { makeCurrentSession } from '~/logic/currentSession/store/model/currentSession'
const loadCurrentSessionFromStorage = () => async (dispatch: ReduxDispatch<GlobalState>) => {
const currentSession = (await getCurrentSessionFromStorage())
dispatch(loadCurrentSession(makeCurrentSession(currentSession ? currentSession : {})))
}
export default loadCurrentSessionFromStorage

View File

@ -0,0 +1,8 @@
// @flow
import { createAction } from 'redux-actions'
export const UPDATE_VIEWED_SAFES = 'UPDATE_VIEWED_SAFES'
const updateViewedSafes = createAction<string, *>(UPDATE_VIEWED_SAFES)
export default updateViewedSafes

View File

@ -0,0 +1,14 @@
// @flow
import {
Record, type RecordFactory, type RecordOf,
} from 'immutable'
export type CurrentSessionProps = {
viewedSafes: Array<string>,
}
export const makeCurrentSession: RecordFactory<CurrentSessionProps> = Record({
viewedSafes: [],
})
export type CurrentSession = RecordOf<CurrentSessionProps>

View File

@ -0,0 +1,32 @@
// @flow
import { Map } from 'immutable'
import { handleActions, type ActionType } from 'redux-actions'
import { LOAD_CURRENT_SESSION } from '~/logic/currentSession/store/actions/loadCurrentSession'
import { UPDATE_VIEWED_SAFES } from '~/logic/currentSession/store/actions/updateViewedSafes'
import { saveCurrentSessionToStorage } from '~/logic/currentSession/utils'
export const CURRENT_SESSION_REDUCER_ID = 'currentSession'
export type State = Map<string, *>
export default handleActions<State, *>(
{
[LOAD_CURRENT_SESSION]: (
state: State,
action: ActionType<Function>,
): State => state.merge(Map(action.payload)),
[UPDATE_VIEWED_SAFES]: (state: State, action: ActionType<Function>): State => {
const safeAddress = action.payload
const newState = state.updateIn(
['viewedSafes'],
(prev) => (prev.includes(safeAddress) ? prev : [...prev, safeAddress]),
)
saveCurrentSessionToStorage(newState)
return newState
},
},
Map(),
)

View File

@ -0,0 +1,15 @@
// @flow
import type { CurrentSession, CurrentSessionProps } from '~/logic/currentSession/store/model/currentSession'
import { loadFromStorage, saveToStorage } from '~/utils/storage'
const CURRENT_SESSION_STORAGE_KEY = 'CURRENT_SESSION'
export const getCurrentSessionFromStorage = async (): Promise<CurrentSessionProps | *> => loadFromStorage(CURRENT_SESSION_STORAGE_KEY)
export const saveCurrentSessionToStorage = async (currentSession: CurrentSession): Promise<*> => {
try {
await saveToStorage(CURRENT_SESSION_STORAGE_KEY, currentSession.toJSON())
} catch (err) {
console.error('Error storing currentSession in localStorage', err)
}
}

View File

@ -47,7 +47,7 @@ class Load extends React.Component<Props> {
await loadSafe(safeName, safeAddress, owners, addSafe) await loadSafe(safeName, safeAddress, owners, addSafe)
const url = `${SAFELIST_ADDRESS}/${safeAddress}/balances` const url = `${SAFELIST_ADDRESS}/${safeAddress}/balances/`
history.push(url) history.push(url)
} catch (error) { } catch (error) {
console.error('Error while loading the Safe', error) console.error('Error while loading the Safe', error)

View File

@ -70,6 +70,7 @@ const ApproveTxModal = ({
const [gasCosts, setGasCosts] = useState<string>('< 0.001') const [gasCosts, setGasCosts] = useState<string>('< 0.001')
const { title, description } = getModalTitleAndDescription(thresholdReached) const { title, description } = getModalTitleAndDescription(thresholdReached)
const oneConfirmationLeft = !thresholdReached && tx.confirmations.size + 1 === threshold const oneConfirmationLeft = !thresholdReached && tx.confirmations.size + 1 === threshold
const isTheTxReadyToBeExecuted = oneConfirmationLeft ? true : thresholdReached
useEffect(() => { useEffect(() => {
let isCurrent = true let isCurrent = true
@ -109,7 +110,7 @@ const ApproveTxModal = ({
notifiedTransaction: TX_NOTIFICATION_TYPES.CONFIRMATION_TX, notifiedTransaction: TX_NOTIFICATION_TYPES.CONFIRMATION_TX,
enqueueSnackbar, enqueueSnackbar,
closeSnackbar, closeSnackbar,
approveAndExecute: canExecute && approveAndExecute && oneConfirmationLeft, approveAndExecute: canExecute && approveAndExecute && isTheTxReadyToBeExecuted,
}) })
onClose() onClose()
} }

View File

@ -9,6 +9,7 @@ import updateSafe from '~/routes/safe/store/actions/updateSafe'
import fetchTokens from '~/logic/tokens/store/actions/fetchTokens' import fetchTokens from '~/logic/tokens/store/actions/fetchTokens'
import fetchCurrencyValues from '~/logic/currencyValues/store/actions/fetchCurrencyValues' import fetchCurrencyValues from '~/logic/currencyValues/store/actions/fetchCurrencyValues'
import activateTokensByBalance from '~/logic/tokens/store/actions/activateTokensByBalance' import activateTokensByBalance from '~/logic/tokens/store/actions/activateTokensByBalance'
import addViewedSafe from '~/logic/currentSession/store/actions/addViewedSafe'
export type Actions = { export type Actions = {
fetchSafe: typeof fetchSafe, fetchSafe: typeof fetchSafe,
@ -21,7 +22,8 @@ export type Actions = {
fetchEtherBalance: typeof fetchEtherBalance, fetchEtherBalance: typeof fetchEtherBalance,
activateTokensByBalance: typeof activateTokensByBalance, activateTokensByBalance: typeof activateTokensByBalance,
checkAndUpdateSafeOwners: typeof checkAndUpdateSafe, checkAndUpdateSafeOwners: typeof checkAndUpdateSafe,
fetchCurrencyValues: typeof fetchCurrencyValues fetchCurrencyValues: typeof fetchCurrencyValues,
addViewedSafe: typeof addViewedSafe,
} }
export default { export default {
@ -36,4 +38,5 @@ export default {
fetchEtherBalance, fetchEtherBalance,
fetchCurrencyValues, fetchCurrencyValues,
checkAndUpdateSafeOwners: checkAndUpdateSafe, checkAndUpdateSafeOwners: checkAndUpdateSafe,
addViewedSafe,
} }

View File

@ -34,13 +34,22 @@ class SafeView extends React.Component<Props, State> {
componentDidMount() { componentDidMount() {
const { const {
fetchSafe, activeTokens, safeUrl, fetchTokenBalances, fetchTokens, fetchTransactions, fetchCurrencyValues, fetchSafe,
activeTokens,
safeUrl,
fetchTokenBalances,
fetchTokens,
fetchTransactions,
fetchCurrencyValues,
addViewedSafe,
} = this.props } = this.props
fetchSafe(safeUrl).then(() => { fetchSafe(safeUrl)
// The safe needs to be loaded before fetching the transactions .then(() => {
fetchTransactions(safeUrl) // The safe needs to be loaded before fetching the transactions
}) fetchTransactions(safeUrl)
addViewedSafe(safeUrl)
})
fetchTokenBalances(safeUrl, activeTokens) fetchTokenBalances(safeUrl, activeTokens)
// fetch tokens there to get symbols for tokens in TXs list // fetch tokens there to get symbols for tokens in TXs list
fetchTokens() fetchTokens()

View File

@ -12,9 +12,6 @@ import { enhanceSnackbarForAction, NOTIFICATIONS } from '~/logic/notifications'
import closeSnackbarAction from '~/logic/notifications/store/actions/closeSnackbar' import closeSnackbarAction from '~/logic/notifications/store/actions/closeSnackbar'
import { getIncomingTxAmount } from '~/routes/safe/components/Transactions/TxsTable/columns' import { getIncomingTxAmount } from '~/routes/safe/components/Transactions/TxsTable/columns'
import updateSafe from '~/routes/safe/store/actions/updateSafe' import updateSafe from '~/routes/safe/store/actions/updateSafe'
import { loadFromStorage } from '~/utils/storage'
import { SAFES_KEY } from '~/logic/safe/utils'
import { RECURRING_USER_KEY } from '~/utils/verifyRecurringUser'
import { safesMapSelector } from '~/routes/safe/store/selectors' import { safesMapSelector } from '~/routes/safe/store/selectors'
import { isUserOwner } from '~/logic/wallets/ethAddresses' import { isUserOwner } from '~/logic/wallets/ethAddresses'
@ -69,17 +66,16 @@ const notificationsMiddleware = (store: Store<GlobalState>) => (
break break
} }
case ADD_INCOMING_TRANSACTIONS: { case ADD_INCOMING_TRANSACTIONS: {
action.payload.forEach(async (incomingTransactions, safeAddress) => { action.payload.forEach((incomingTransactions, safeAddress) => {
const storedSafes = await loadFromStorage(SAFES_KEY) const { latestIncomingTxBlock } = state.safes.get('safes').get(safeAddress)
const latestIncomingTxBlock = storedSafes const viewedSafes = state.currentSession ? state.currentSession.get('viewedSafes') : []
? storedSafes[safeAddress].latestIncomingTxBlock const recurringUser = viewedSafes.includes(safeAddress)
: 0
const newIncomingTransactions = incomingTransactions.filter( const newIncomingTransactions = incomingTransactions.filter(
(tx) => tx.blockNumber > latestIncomingTxBlock, (tx) => tx.blockNumber > latestIncomingTxBlock,
) )
const { message, ...TX_INCOMING_MSG } = NOTIFICATIONS.TX_INCOMING_MSG const { message, ...TX_INCOMING_MSG } = NOTIFICATIONS.TX_INCOMING_MSG
const recurringUser = await loadFromStorage(RECURRING_USER_KEY)
if (recurringUser) { if (recurringUser) {
if (newIncomingTransactions.size > 3) { if (newIncomingTransactions.size > 3) {
@ -109,7 +105,7 @@ const notificationsMiddleware = (store: Store<GlobalState>) => (
updateSafe({ updateSafe({
address: safeAddress, address: safeAddress,
latestIncomingTxBlock: newIncomingTransactions.size latestIncomingTxBlock: newIncomingTransactions.size
? newIncomingTransactions.last().blockNumber ? newIncomingTransactions.first().blockNumber
: latestIncomingTxBlock, : latestIncomingTxBlock,
}), }),
) )

View File

@ -16,6 +16,7 @@ export type SafeProps = {
ethBalance?: string, ethBalance?: string,
nonce: number, nonce: number,
latestIncomingTxBlock: number, latestIncomingTxBlock: number,
recurringUser?: boolean,
} }
const SafeRecord: RecordFactory<SafeProps> = Record({ const SafeRecord: RecordFactory<SafeProps> = Record({
@ -29,6 +30,7 @@ const SafeRecord: RecordFactory<SafeProps> = Record({
balances: Map({}), balances: Map({}),
nonce: 0, nonce: 0,
latestIncomingTxBlock: 0, latestIncomingTxBlock: 0,
recurringUser: undefined,
}) })
export type Safe = RecordOf<SafeProps> export type Safe = RecordOf<SafeProps>

View File

@ -25,7 +25,10 @@ import notifications, {
import currencyValues, { CURRENCY_VALUES_KEY } from '~/logic/currencyValues/store/reducer/currencyValues' import currencyValues, { CURRENCY_VALUES_KEY } from '~/logic/currencyValues/store/reducer/currencyValues'
import cookies, { COOKIES_REDUCER_ID } from '~/logic/cookies/store/reducer/cookies' import cookies, { COOKIES_REDUCER_ID } from '~/logic/cookies/store/reducer/cookies'
import notificationsMiddleware from '~/routes/safe/store/middleware/notificationsMiddleware' import notificationsMiddleware from '~/routes/safe/store/middleware/notificationsMiddleware'
import currentSession, {
CURRENT_SESSION_REDUCER_ID,
type State as CurrentSessionState,
} from '~/logic/currentSession/store/reducer/currentSession'
export const history = createBrowserHistory() export const history = createBrowserHistory()
@ -42,6 +45,7 @@ export type GlobalState = {
transactions: TransactionsState, transactions: TransactionsState,
incomingTransactions: IncomingTransactionsState, incomingTransactions: IncomingTransactionsState,
notifications: NotificationsState, notifications: NotificationsState,
currentSession: CurrentSessionState,
} }
export type GetState = () => GlobalState export type GetState = () => GlobalState
@ -56,6 +60,7 @@ const reducers: Reducer<GlobalState> = combineReducers({
[NOTIFICATIONS_REDUCER_ID]: notifications, [NOTIFICATIONS_REDUCER_ID]: notifications,
[CURRENCY_VALUES_KEY]: currencyValues, [CURRENCY_VALUES_KEY]: currencyValues,
[COOKIES_REDUCER_ID]: cookies, [COOKIES_REDUCER_ID]: cookies,
[CURRENT_SESSION_REDUCER_ID]: currentSession,
}) })
export const store: Store<GlobalState> = createStore(reducers, finalCreateStore) export const store: Store<GlobalState> = createStore(reducers, finalCreateStore)

View File

@ -102,7 +102,7 @@ const renderApp = (store: Store) => ({
export const renderSafeView = (store: Store<GlobalState>, address: string) => { export const renderSafeView = (store: Store<GlobalState>, address: string) => {
const app = renderApp(store) const app = renderApp(store)
const url = `${SAFELIST_ADDRESS}/${address}/balances` const url = `${SAFELIST_ADDRESS}/${address}/balances/`
history.push(url) history.push(url)
return app return app

View File

@ -73,6 +73,9 @@ const theme = createMuiTheme({
}, },
containedSecondary: { containedSecondary: {
backgroundColor: error, backgroundColor: error,
'&:hover': {
backgroundColor: '#d4d5d3',
},
}, },
outlinedPrimary: { outlinedPrimary: {
border: `2px solid ${primary}`, border: `2px solid ${primary}`,

View File

@ -1,18 +0,0 @@
// @flow
import { loadFromStorage, saveToStorage } from '~/utils/storage'
export const RECURRING_USER_KEY = 'RECURRING_USER'
const verifyRecurringUser = async () => {
const recurringUser = await loadFromStorage(RECURRING_USER_KEY)
if (recurringUser === undefined) {
await saveToStorage(RECURRING_USER_KEY, false)
}
if (recurringUser === false) {
await saveToStorage(RECURRING_USER_KEY, true)
}
}
export default verifyRecurringUser