From 336413c8e588c15cb3b9596546afb4d933e4750f Mon Sep 17 00:00:00 2001 From: Agustin Pane Date: Tue, 16 Jun 2020 09:29:12 -0300 Subject: [PATCH 01/22] Fix undefined for maxValue validator in case there is no token selected --- .../components/Balances/SendModal/screens/SendFunds/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/routes/safe/components/Balances/SendModal/screens/SendFunds/index.tsx b/src/routes/safe/components/Balances/SendModal/screens/SendFunds/index.tsx index eafeea53..1e40a01c 100644 --- a/src/routes/safe/components/Balances/SendModal/screens/SendFunds/index.tsx +++ b/src/routes/safe/components/Balances/SendModal/screens/SendFunds/index.tsx @@ -220,11 +220,12 @@ const SendFunds = ({ initialValues, onClose, onNext, recipientAddress, selectedT placeholder="Amount*" text="Amount*" type="text" + disabled={!selectedTokenRecord} validate={composeValidators( required, mustBeFloat, greaterThan(0), - maxValue(selectedTokenRecord && selectedTokenRecord.balance), + maxValue(selectedTokenRecord?.balance), )} /> From bcb468e3ec09782e75028a97eab3eb748798008d Mon Sep 17 00:00:00 2001 From: Agustin Pane Date: Fri, 19 Jun 2020 11:07:23 -0300 Subject: [PATCH 02/22] Fix race condition --- src/routes/load/container/Load.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/routes/load/container/Load.tsx b/src/routes/load/container/Load.tsx index 0fb69162..ece56987 100644 --- a/src/routes/load/container/Load.tsx +++ b/src/routes/load/container/Load.tsx @@ -16,17 +16,22 @@ import { SAFELIST_ADDRESS } from 'src/routes/routes' import { buildSafe } from 'src/routes/safe/store/actions/fetchSafe' import { history } from 'src/store' import { loadFromStorage } from 'src/utils/storage' +import { Dispatch } from 'redux' -export const loadSafe = async (safeName, safeAddress, owners, addSafe) => { +export const loadSafe = async ( + safeName: string, + safeAddress: string, + owners: any, + addSafe: Dispatch, +): Promise => { const safeProps = await buildSafe(safeAddress, safeName) safeProps.owners = owners - await addSafe(safeProps) - const storedSafes = (await loadFromStorage(SAFES_KEY)) || {} storedSafes[safeAddress] = safeProps - saveSafes(storedSafes) + await saveSafes(storedSafes) + await addSafe(safeProps) } class Load extends React.Component { From 3283bf1dc617af2e5a993db6975c848962c8da40 Mon Sep 17 00:00:00 2001 From: Agustin Pane Date: Fri, 19 Jun 2020 11:18:33 -0300 Subject: [PATCH 03/22] Add types --- src/utils/storage/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/storage/index.ts b/src/utils/storage/index.ts index 127db6f7..f1ff7dd1 100644 --- a/src/utils/storage/index.ts +++ b/src/utils/storage/index.ts @@ -10,7 +10,7 @@ export const storage = new ImmortalStorage(stores) const PREFIX = `v2_${getNetwork()}` -export const loadFromStorage = async (key) => { +export const loadFromStorage = async (key: string): Promise => { try { const stringifiedValue = await storage.get(`${PREFIX}__${key}`) if (stringifiedValue === null || stringifiedValue === undefined) { @@ -24,7 +24,7 @@ export const loadFromStorage = async (key) => { } } -export const saveToStorage = async (key, value) => { +export const saveToStorage = async (key: string, value: any): Promise => { try { const stringifiedValue = JSON.stringify(value) await storage.set(`${PREFIX}__${key}`, stringifiedValue) @@ -33,7 +33,7 @@ export const saveToStorage = async (key, value) => { } } -export const removeFromStorage = async (key) => { +export const removeFromStorage = async (key: string): Promise => { try { await storage.remove(`${PREFIX}__${key}`) } catch (err) { From 5c00d51c3ccf4f7c3a517010c964f2462b9fe713 Mon Sep 17 00:00:00 2001 From: Agustin Pane Date: Fri, 19 Jun 2020 12:21:24 -0300 Subject: [PATCH 04/22] Remove types on loadFromStorage --- .../Balances/SendModal/screens/SendFunds/index.tsx | 3 +-- src/utils/storage/index.ts | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/routes/safe/components/Balances/SendModal/screens/SendFunds/index.tsx b/src/routes/safe/components/Balances/SendModal/screens/SendFunds/index.tsx index 1e40a01c..eafeea53 100644 --- a/src/routes/safe/components/Balances/SendModal/screens/SendFunds/index.tsx +++ b/src/routes/safe/components/Balances/SendModal/screens/SendFunds/index.tsx @@ -220,12 +220,11 @@ const SendFunds = ({ initialValues, onClose, onNext, recipientAddress, selectedT placeholder="Amount*" text="Amount*" type="text" - disabled={!selectedTokenRecord} validate={composeValidators( required, mustBeFloat, greaterThan(0), - maxValue(selectedTokenRecord?.balance), + maxValue(selectedTokenRecord && selectedTokenRecord.balance), )} /> diff --git a/src/utils/storage/index.ts b/src/utils/storage/index.ts index f1ff7dd1..127db6f7 100644 --- a/src/utils/storage/index.ts +++ b/src/utils/storage/index.ts @@ -10,7 +10,7 @@ export const storage = new ImmortalStorage(stores) const PREFIX = `v2_${getNetwork()}` -export const loadFromStorage = async (key: string): Promise => { +export const loadFromStorage = async (key) => { try { const stringifiedValue = await storage.get(`${PREFIX}__${key}`) if (stringifiedValue === null || stringifiedValue === undefined) { @@ -24,7 +24,7 @@ export const loadFromStorage = async (key: string): Promise => { } } -export const saveToStorage = async (key: string, value: any): Promise => { +export const saveToStorage = async (key, value) => { try { const stringifiedValue = JSON.stringify(value) await storage.set(`${PREFIX}__${key}`, stringifiedValue) @@ -33,7 +33,7 @@ export const saveToStorage = async (key: string, value: any): Promise => { } } -export const removeFromStorage = async (key: string): Promise => { +export const removeFromStorage = async (key) => { try { await storage.remove(`${PREFIX}__${key}`) } catch (err) { From caa94c879b72c3e8f553a7f7409bec25d1ededa5 Mon Sep 17 00:00:00 2001 From: Agustin Pane Date: Fri, 19 Jun 2020 13:02:54 -0300 Subject: [PATCH 05/22] Types --- src/routes/load/container/Load.tsx | 7 +++++-- src/routes/open/utils/safeDataExtractor.ts | 3 ++- src/routes/safe/store/actions/fetchSafe.ts | 3 ++- src/routes/safe/store/models/safe.ts | 5 +++++ src/utils/storage/index.ts | 2 +- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/routes/load/container/Load.tsx b/src/routes/load/container/Load.tsx index ece56987..2ccf4757 100644 --- a/src/routes/load/container/Load.tsx +++ b/src/routes/load/container/Load.tsx @@ -17,17 +17,20 @@ import { buildSafe } from 'src/routes/safe/store/actions/fetchSafe' import { history } from 'src/store' import { loadFromStorage } from 'src/utils/storage' import { Dispatch } from 'redux' +import { SafeOwner, SafeRecordProps } from '../../safe/store/models/safe' +import { List } from 'immutable' export const loadSafe = async ( safeName: string, safeAddress: string, - owners: any, + owners: List, addSafe: Dispatch, ): Promise => { const safeProps = await buildSafe(safeAddress, safeName) safeProps.owners = owners - const storedSafes = (await loadFromStorage(SAFES_KEY)) || {} + const storedSafes: SafeRecordProps = (await loadFromStorage(SAFES_KEY)) || {} + storedSafes[safeAddress] = safeProps await saveSafes(storedSafes) diff --git a/src/routes/open/utils/safeDataExtractor.ts b/src/routes/open/utils/safeDataExtractor.ts index 32b1193b..855c674f 100644 --- a/src/routes/open/utils/safeDataExtractor.ts +++ b/src/routes/open/utils/safeDataExtractor.ts @@ -1,6 +1,7 @@ import { List } from 'immutable' import { makeOwner } from 'src/routes/safe/store/models/owner' +import { SafeOwner } from '../../safe/store/models/safe' export const getAccountsFrom = (values) => { const accounts = Object.keys(values) @@ -18,7 +19,7 @@ export const getNamesFrom = (values) => { return accounts.map((account) => values[account]).slice(0, values.owners) } -export const getOwnersFrom = (names, addresses) => { +export const getOwnersFrom = (names, addresses): List => { const owners = names.map((name, index) => makeOwner({ name, address: addresses[index] })) return List(owners) diff --git a/src/routes/safe/store/actions/fetchSafe.ts b/src/routes/safe/store/actions/fetchSafe.ts index 1fed7731..ed8dca20 100644 --- a/src/routes/safe/store/actions/fetchSafe.ts +++ b/src/routes/safe/store/actions/fetchSafe.ts @@ -13,6 +13,7 @@ import updateSafe from 'src/routes/safe/store/actions/updateSafe' import { makeOwner } from 'src/routes/safe/store/models/owner' import { checksumAddress } from 'src/utils/checksumAddress' +import { SafeOwner } from '../models/safe' const buildOwnersFrom = ( safeOwners, @@ -51,7 +52,7 @@ export const buildSafe = async (safeAdd, safeName, latestMasterContractVersion?: const threshold = Number(thresholdStr) const nonce = Number(nonceStr) - const owners = List(buildOwnersFrom(remoteOwners, localSafe)) + const owners = List(buildOwnersFrom(remoteOwners, localSafe)) const needsUpdate = safeNeedsUpdate(currentVersion, latestMasterContractVersion) const featuresEnabled = enabledFeatures(currentVersion) diff --git a/src/routes/safe/store/models/safe.ts b/src/routes/safe/store/models/safe.ts index 40eb1621..541bb0ff 100644 --- a/src/routes/safe/store/models/safe.ts +++ b/src/routes/safe/store/models/safe.ts @@ -1,5 +1,10 @@ import { List, Map, Record, RecordOf, Set } from 'immutable' +export type SafeOwner = { + name: string + address: string +} + export type SafeRecordProps = { name: string address: string diff --git a/src/utils/storage/index.ts b/src/utils/storage/index.ts index 127db6f7..2588c263 100644 --- a/src/utils/storage/index.ts +++ b/src/utils/storage/index.ts @@ -10,7 +10,7 @@ export const storage = new ImmortalStorage(stores) const PREFIX = `v2_${getNetwork()}` -export const loadFromStorage = async (key) => { +export const loadFromStorage = async (key: string) => { try { const stringifiedValue = await storage.get(`${PREFIX}__${key}`) if (stringifiedValue === null || stringifiedValue === undefined) { From cc6aa134513baafb60f55baa62481e9355bfb8e1 Mon Sep 17 00:00:00 2001 From: Agustin Pane Date: Fri, 19 Jun 2020 20:00:24 -0300 Subject: [PATCH 06/22] Fix types --- src/routes/load/container/Load.tsx | 8 +++++++- src/routes/safe/store/models/safe.ts | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/routes/load/container/Load.tsx b/src/routes/load/container/Load.tsx index 2ccf4757..226856f4 100644 --- a/src/routes/load/container/Load.tsx +++ b/src/routes/load/container/Load.tsx @@ -20,6 +20,12 @@ import { Dispatch } from 'redux' import { SafeOwner, SafeRecordProps } from '../../safe/store/models/safe' import { List } from 'immutable' +type RecordPropType = Partial + +type StoredSafesType = { + [address: string]: RecordPropType +} + export const loadSafe = async ( safeName: string, safeAddress: string, @@ -29,7 +35,7 @@ export const loadSafe = async ( const safeProps = await buildSafe(safeAddress, safeName) safeProps.owners = owners - const storedSafes: SafeRecordProps = (await loadFromStorage(SAFES_KEY)) || {} + const storedSafes: StoredSafesType = (await loadFromStorage(SAFES_KEY)) || {} storedSafes[safeAddress] = safeProps diff --git a/src/routes/safe/store/models/safe.ts b/src/routes/safe/store/models/safe.ts index 541bb0ff..50b7b10f 100644 --- a/src/routes/safe/store/models/safe.ts +++ b/src/routes/safe/store/models/safe.ts @@ -9,7 +9,7 @@ export type SafeRecordProps = { name: string address: string threshold: number - ethBalance: number + ethBalance: string owners: List<{ name: string; address: string }> activeTokens: Set activeAssets: Set @@ -28,7 +28,7 @@ const makeSafe = Record({ name: '', address: '', threshold: 0, - ethBalance: 0, + ethBalance: '0', owners: List([]), activeTokens: Set(), activeAssets: Set(), From 231a9a7d35fc374568f90a7d54b8babbf3d1a2e1 Mon Sep 17 00:00:00 2001 From: Agustin Pane Date: Mon, 22 Jun 2020 12:05:08 -0300 Subject: [PATCH 07/22] Remove types --- src/routes/load/container/Load.tsx | 10 ++-------- src/utils/storage/index.ts | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/routes/load/container/Load.tsx b/src/routes/load/container/Load.tsx index 226856f4..ff96a306 100644 --- a/src/routes/load/container/Load.tsx +++ b/src/routes/load/container/Load.tsx @@ -17,15 +17,9 @@ import { buildSafe } from 'src/routes/safe/store/actions/fetchSafe' import { history } from 'src/store' import { loadFromStorage } from 'src/utils/storage' import { Dispatch } from 'redux' -import { SafeOwner, SafeRecordProps } from '../../safe/store/models/safe' +import { SafeOwner } from '../../safe/store/models/safe' import { List } from 'immutable' -type RecordPropType = Partial - -type StoredSafesType = { - [address: string]: RecordPropType -} - export const loadSafe = async ( safeName: string, safeAddress: string, @@ -35,7 +29,7 @@ export const loadSafe = async ( const safeProps = await buildSafe(safeAddress, safeName) safeProps.owners = owners - const storedSafes: StoredSafesType = (await loadFromStorage(SAFES_KEY)) || {} + const storedSafes = (await loadFromStorage(SAFES_KEY)) || {} storedSafes[safeAddress] = safeProps diff --git a/src/utils/storage/index.ts b/src/utils/storage/index.ts index 2588c263..89d6f796 100644 --- a/src/utils/storage/index.ts +++ b/src/utils/storage/index.ts @@ -10,7 +10,7 @@ export const storage = new ImmortalStorage(stores) const PREFIX = `v2_${getNetwork()}` -export const loadFromStorage = async (key: string) => { +export const loadFromStorage = async unknown>(key: string): Promise => { try { const stringifiedValue = await storage.get(`${PREFIX}__${key}`) if (stringifiedValue === null || stringifiedValue === undefined) { From 18f03b8bc1a7d5b80af231e24b5b4478c2cf3a46 Mon Sep 17 00:00:00 2001 From: Mikhail Mikheev Date: Tue, 23 Jun 2020 13:53:10 +0400 Subject: [PATCH 08/22] typing loadFromStorage wip --- src/logic/wallets/store/middlewares/providerWatcher.ts | 6 +++--- src/utils/storage/index.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/logic/wallets/store/middlewares/providerWatcher.ts b/src/logic/wallets/store/middlewares/providerWatcher.ts index 16c43aa5..0dedb32d 100644 --- a/src/logic/wallets/store/middlewares/providerWatcher.ts +++ b/src/logic/wallets/store/middlewares/providerWatcher.ts @@ -10,10 +10,10 @@ const watchedActions = [ADD_PROVIDER, REMOVE_PROVIDER] const LAST_USED_PROVIDER_KEY = 'LAST_USED_PROVIDER' -export const loadLastUsedProvider = async () => { - const lastUsedProvider = await loadFromStorage(LAST_USED_PROVIDER_KEY) +export const loadLastUsedProvider = async (): Promise => { + const lastUsedProvider = await loadFromStorage(LAST_USED_PROVIDER_KEY) - return lastUsedProvider || '' + return lastUsedProvider } let watcherInterval = null diff --git a/src/utils/storage/index.ts b/src/utils/storage/index.ts index 89d6f796..5110fd37 100644 --- a/src/utils/storage/index.ts +++ b/src/utils/storage/index.ts @@ -10,7 +10,7 @@ export const storage = new ImmortalStorage(stores) const PREFIX = `v2_${getNetwork()}` -export const loadFromStorage = async unknown>(key: string): Promise => { +export const loadFromStorage = async (key: string): Promise => { try { const stringifiedValue = await storage.get(`${PREFIX}__${key}`) if (stringifiedValue === null || stringifiedValue === undefined) { From e7c012d5d13278bb0b9562951fc5e55d6a865331 Mon Sep 17 00:00:00 2001 From: Mikhail Mikheev Date: Tue, 23 Jun 2020 17:33:57 +0400 Subject: [PATCH 09/22] Fix addressbook type errors --- src/logic/addressBook/model/addressBook.ts | 8 +++++++- .../store/actions/loadAddressBookFromStorage.ts | 11 ++++++----- src/logic/addressBook/utils/index.ts | 7 ++++--- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/logic/addressBook/model/addressBook.ts b/src/logic/addressBook/model/addressBook.ts index fb4fd19f..f051fe18 100644 --- a/src/logic/addressBook/model/addressBook.ts +++ b/src/logic/addressBook/model/addressBook.ts @@ -1,6 +1,12 @@ import { Record } from 'immutable' -export const makeAddressBookEntry = Record({ +export interface AddressBookEntryProps { + address: string + name: string + isOwner: boolean +} + +export const makeAddressBookEntry = Record({ address: '', name: '', isOwner: false, diff --git a/src/logic/addressBook/store/actions/loadAddressBookFromStorage.ts b/src/logic/addressBook/store/actions/loadAddressBookFromStorage.ts index 20cfe570..88009c78 100644 --- a/src/logic/addressBook/store/actions/loadAddressBookFromStorage.ts +++ b/src/logic/addressBook/store/actions/loadAddressBookFromStorage.ts @@ -1,4 +1,4 @@ -import { List, Map } from 'immutable' +import { List } from 'immutable' import { loadAddressBook } from 'src/logic/addressBook/store/actions/loadAddressBook' import { buildAddressBook } from 'src/logic/addressBook/store/reducer/addressBook' @@ -8,11 +8,12 @@ import { safesListSelector } from 'src/routes/safe/store/selectors' const loadAddressBookFromStorage = () => async (dispatch, getState) => { try { const state = getState() - let addressBook = await getAddressBookFromStorage() - if (!addressBook) { - addressBook = Map([]) + let storedAdBk = await getAddressBookFromStorage() + if (!storedAdBk) { + storedAdBk = [] } - addressBook = buildAddressBook(addressBook) + + let addressBook = buildAddressBook(storedAdBk) // Fetch all the current safes, in case that we don't have a safe on the adbk, we add it const safes = safesListSelector(state) const adbkEntries = addressBook.keySeq().toArray() diff --git a/src/logic/addressBook/utils/index.ts b/src/logic/addressBook/utils/index.ts index b0131480..7fb48374 100644 --- a/src/logic/addressBook/utils/index.ts +++ b/src/logic/addressBook/utils/index.ts @@ -1,11 +1,12 @@ import { loadFromStorage, saveToStorage } from 'src/utils/storage' +import { AddressBookEntryProps } from './../model/addressBook' const ADDRESS_BOOK_STORAGE_KEY = 'ADDRESS_BOOK_STORAGE_KEY' -export const getAddressBookFromStorage = async () => { - const data = await loadFromStorage(ADDRESS_BOOK_STORAGE_KEY) +export const getAddressBookFromStorage = async (): Promise | undefined> => { + const data = await loadFromStorage>(ADDRESS_BOOK_STORAGE_KEY) - return data || [] + return data } export const saveAddressBook = async (addressBook) => { From 8f0cccdb5917dcab5f77c8c0cccebd2c1faddd5e Mon Sep 17 00:00:00 2001 From: Mikhail Mikheev Date: Tue, 23 Jun 2020 19:03:02 +0400 Subject: [PATCH 10/22] Fix token storage type errors, remove unused functions --- .../tokens/store/actions/loadActiveTokens.ts | 2 +- src/logic/tokens/store/actions/removeToken.ts | 19 ---------- src/logic/tokens/store/reducer/tokens.ts | 7 ---- src/logic/tokens/utils/tokensStorage.ts | 37 +++---------------- 4 files changed, 7 insertions(+), 58 deletions(-) delete mode 100644 src/logic/tokens/store/actions/removeToken.ts diff --git a/src/logic/tokens/store/actions/loadActiveTokens.ts b/src/logic/tokens/store/actions/loadActiveTokens.ts index c384bd4e..7b4ae61b 100644 --- a/src/logic/tokens/store/actions/loadActiveTokens.ts +++ b/src/logic/tokens/store/actions/loadActiveTokens.ts @@ -7,7 +7,7 @@ import { getActiveTokens } from 'src/logic/tokens/utils/tokensStorage' const loadActiveTokens = () => async (dispatch) => { try { - const tokens = await getActiveTokens() + const tokens = (await getActiveTokens()) || {} // The filter of strings was made because of the issue #751. Please see: https://github.com/gnosis/safe-react/pull/755#issuecomment-612969340 const tokenRecordsList = List( Object.values(tokens) diff --git a/src/logic/tokens/store/actions/removeToken.ts b/src/logic/tokens/store/actions/removeToken.ts deleted file mode 100644 index d6aab7bc..00000000 --- a/src/logic/tokens/store/actions/removeToken.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { createAction } from 'redux-actions' - -import { removeFromActiveTokens, removeTokenFromStorage } from 'src/logic/tokens/utils/tokensStorage' - -export const REMOVE_TOKEN = 'REMOVE_TOKEN' - -export const removeToken = createAction(REMOVE_TOKEN, (safeAddress, token) => ({ - safeAddress, - token, -})) - -const deleteToken = (safeAddress, token) => async (dispatch) => { - dispatch(removeToken(safeAddress, token)) - - await removeFromActiveTokens(safeAddress, token) - await removeTokenFromStorage(safeAddress, token) -} - -export default deleteToken diff --git a/src/logic/tokens/store/reducer/tokens.ts b/src/logic/tokens/store/reducer/tokens.ts index 418da6b0..50dc1def 100644 --- a/src/logic/tokens/store/reducer/tokens.ts +++ b/src/logic/tokens/store/reducer/tokens.ts @@ -2,7 +2,6 @@ import { Map } from 'immutable' import { handleActions } from 'redux-actions' import { ADD_TOKEN } from 'src/logic/tokens/store/actions/addToken' -import { REMOVE_TOKEN } from 'src/logic/tokens/store/actions/removeToken' import { ADD_TOKENS } from 'src/logic/tokens/store/actions/saveTokens' import { makeToken } from 'src/logic/tokens/store/model/token' @@ -27,12 +26,6 @@ export default handleActions( return state.set(tokenAddress, makeToken(token)) }, - [REMOVE_TOKEN]: (state, action) => { - const { token } = action.payload - const { address: tokenAddress } = token - - return state.remove(tokenAddress) - }, }, Map(), ) diff --git a/src/logic/tokens/utils/tokensStorage.ts b/src/logic/tokens/utils/tokensStorage.ts index c34d7c04..1b9f7970 100644 --- a/src/logic/tokens/utils/tokensStorage.ts +++ b/src/logic/tokens/utils/tokensStorage.ts @@ -1,6 +1,7 @@ -import { List } from 'immutable' +import { Map } from 'immutable' import { loadFromStorage, saveToStorage } from 'src/utils/storage' +import { TokenProps, Token } from './../store/model/token' export const ACTIVE_TOKENS_KEY = 'ACTIVE_TOKENS' export const CUSTOM_TOKENS_KEY = 'CUSTOM_TOKENS' @@ -9,7 +10,7 @@ export const CUSTOM_TOKENS_KEY = 'CUSTOM_TOKENS' // to avoid iterating a large amount of data of tokens from the backend // Custom tokens should be saved too unless they're deleted (marking them as inactive doesn't count) -export const saveActiveTokens = async (tokens) => { +export const saveActiveTokens = async (tokens: Map): Promise => { try { await saveToStorage(ACTIVE_TOKENS_KEY, tokens.toJS()) } catch (err) { @@ -17,34 +18,8 @@ export const saveActiveTokens = async (tokens) => { } } -export const getActiveTokens = async () => { - const data = await loadFromStorage(ACTIVE_TOKENS_KEY) +export const getActiveTokens = async (): Promise | undefined> => { + const data = await loadFromStorage>(ACTIVE_TOKENS_KEY) - return data || {} -} - -export const getCustomTokens = async () => { - const data = await loadFromStorage(CUSTOM_TOKENS_KEY) - - return data ? List(data) : List() -} - -export const removeTokenFromStorage = async (safeAddress, token) => { - const data = await getCustomTokens() - - try { - const index = data.indexOf(token) - await saveToStorage(CUSTOM_TOKENS_KEY, data.remove(index)) - } catch (err) { - console.error('Error removing token in localstorage', err) - } -} - -export const removeFromActiveTokens = async (safeAddress, token) => { - const activeTokens = await getActiveTokens() - const index = activeTokens.findIndex((activeToken) => activeToken.name === token.name) - - if (index !== -1) { - await saveActiveTokens(safeAddress) - } + return data } From 96ffd522662af1059265434d3f01687d80942ac3 Mon Sep 17 00:00:00 2001 From: Mikhail Mikheev Date: Tue, 23 Jun 2020 19:05:42 +0400 Subject: [PATCH 11/22] fix pendingSafeTx type issues --- src/routes/open/container/Open.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/open/container/Open.tsx b/src/routes/open/container/Open.tsx index 7c8f2f28..a6aa4737 100644 --- a/src/routes/open/container/Open.tsx +++ b/src/routes/open/container/Open.tsx @@ -103,7 +103,7 @@ const Open = ({ addSafe, network, provider, userAccount }) => { // check if there is a safe being created useEffect(() => { const load = async () => { - const pendingCreation = await loadFromStorage(SAFE_PENDING_CREATION_STORAGE_KEY) + const pendingCreation = await loadFromStorage<{ txHash: string }>(SAFE_PENDING_CREATION_STORAGE_KEY) if (pendingCreation && pendingCreation.txHash) { setSafeCreationPendingInfo(pendingCreation) setShowProgress(true) @@ -167,7 +167,7 @@ const Open = ({ addSafe, network, provider, userAccount }) => { } const onRetry = async () => { - const values = await loadFromStorage(SAFE_PENDING_CREATION_STORAGE_KEY) + const values = await loadFromStorage<{ txHash: string }>(SAFE_PENDING_CREATION_STORAGE_KEY) delete values.txHash await saveToStorage(SAFE_PENDING_CREATION_STORAGE_KEY, values) setSafeCreationPendingInfo(values) From f8d6ad4ca28b34e5a0800381edacc4095617e112 Mon Sep 17 00:00:00 2001 From: Mikhail Mikheev Date: Tue, 23 Jun 2020 19:06:23 +0400 Subject: [PATCH 12/22] more fixes for pendingCreationTx --- src/routes/open/container/Open.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/open/container/Open.tsx b/src/routes/open/container/Open.tsx index a6aa4737..f489fbe3 100644 --- a/src/routes/open/container/Open.tsx +++ b/src/routes/open/container/Open.tsx @@ -133,7 +133,7 @@ const Open = ({ addSafe, network, provider, userAccount }) => { } const onSafeCreated = async (safeAddress) => { - const pendingCreation = await loadFromStorage(SAFE_PENDING_CREATION_STORAGE_KEY) + const pendingCreation = await loadFromStorage<{ txHash: string }>(SAFE_PENDING_CREATION_STORAGE_KEY) const name = getSafeNameFrom(pendingCreation) const ownersNames = getNamesFrom(pendingCreation) From 21ae4800c9621ef5f23b1f2e95396d18c4cf9cae Mon Sep 17 00:00:00 2001 From: Mikhail Mikheev Date: Tue, 23 Jun 2020 19:09:24 +0400 Subject: [PATCH 13/22] fix getDefaultSafe return type --- src/logic/safe/utils/safeStorage.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/logic/safe/utils/safeStorage.ts b/src/logic/safe/utils/safeStorage.ts index 34446b8b..8d74ba44 100644 --- a/src/logic/safe/utils/safeStorage.ts +++ b/src/logic/safe/utils/safeStorage.ts @@ -27,10 +27,10 @@ export const getLocalSafe = async (safeAddress) => { return storedSafes[safeAddress] } -export const getDefaultSafe = async () => { - const defaultSafe = await loadFromStorage(DEFAULT_SAFE_KEY) +export const getDefaultSafe = async (): Promise => { + const defaultSafe = await loadFromStorage(DEFAULT_SAFE_KEY) - return defaultSafe || '' + return defaultSafe } export const saveDefaultSafe = async (safeAddress) => { From c925449db2a393cbdc5c0a67cf901e1efbc8ac52 Mon Sep 17 00:00:00 2001 From: Mikhail Mikheev Date: Tue, 23 Jun 2020 19:38:09 +0400 Subject: [PATCH 14/22] fix apps types, fix lastTimeUserLoggedInForSafes type --- src/routes/safe/components/Apps/index.tsx | 6 +++--- src/routes/safe/components/Apps/types.d.ts | 5 +++++ src/routes/safe/store/middleware/notificationsMiddleware.ts | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/routes/safe/components/Apps/index.tsx b/src/routes/safe/components/Apps/index.tsx index b4039f88..949e37f2 100644 --- a/src/routes/safe/components/Apps/index.tsx +++ b/src/routes/safe/components/Apps/index.tsx @@ -21,7 +21,7 @@ import { } from 'src/routes/safe/store/selectors' import { loadFromStorage, saveToStorage } from 'src/utils/storage' import { isSameHref } from 'src/utils/url' -import { SafeApp } from './types' +import { SafeApp, StoredSafeApp } from './types' const APPS_STORAGE_KEY = 'APPS_STORAGE_KEY' const APPS_LEGAL_DISCLAIMER_STORAGE_KEY = 'APPS_LEGAL_DISCLAIMER_STORAGE_KEY' @@ -195,7 +195,7 @@ function Apps({ closeModal, closeSnackbar, enqueueSnackbar, openModal }) { setAppList(copyAppList) // update storage list - const persistedAppList = (await loadFromStorage(APPS_STORAGE_KEY)) || [] + const persistedAppList = (await loadFromStorage(APPS_STORAGE_KEY)) || [] let storageApp = persistedAppList.find((a) => a.url === app.url) if (!storageApp) { @@ -303,7 +303,7 @@ function Apps({ closeModal, closeSnackbar, enqueueSnackbar, openModal }) { // recover apps from storage: // * third-party apps added by the user // * disabled status for both static and third-party apps - const persistedAppList = (await loadFromStorage(APPS_STORAGE_KEY)) || [] + const persistedAppList = (await loadFromStorage(APPS_STORAGE_KEY)) || [] const list = [...persistedAppList] staticAppsList.forEach((staticApp) => { diff --git a/src/routes/safe/components/Apps/types.d.ts b/src/routes/safe/components/Apps/types.d.ts index 635ba78f..8a8ead9b 100644 --- a/src/routes/safe/components/Apps/types.d.ts +++ b/src/routes/safe/components/Apps/types.d.ts @@ -6,3 +6,8 @@ export type SafeApp = { disabled?: boolean error: boolean } + +export type StoredSafeApp = { + url: string + disabled?: boolean +} diff --git a/src/routes/safe/store/middleware/notificationsMiddleware.ts b/src/routes/safe/store/middleware/notificationsMiddleware.ts index a28d76c7..48b752ae 100644 --- a/src/routes/safe/store/middleware/notificationsMiddleware.ts +++ b/src/routes/safe/store/middleware/notificationsMiddleware.ts @@ -38,7 +38,7 @@ const sendAwaitingTransactionNotification = async ( return } - let lastTimeUserLoggedInForSafes = (await loadFromStorage(LAST_TIME_USED_LOGGED_IN_ID)) || [] + let lastTimeUserLoggedInForSafes = (await loadFromStorage>(LAST_TIME_USED_LOGGED_IN_ID)) || {} const lastTimeUserLoggedIn = lastTimeUserLoggedInForSafes && lastTimeUserLoggedInForSafes[safeAddress] ? lastTimeUserLoggedInForSafes[safeAddress] From 01358de6436502a74e0bd57998cd35b2516be424 Mon Sep 17 00:00:00 2001 From: Mikhail Mikheev Date: Tue, 23 Jun 2020 19:57:30 +0400 Subject: [PATCH 15/22] fix default safe return --- src/logic/safe/utils/safeStorage.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/logic/safe/utils/safeStorage.ts b/src/logic/safe/utils/safeStorage.ts index 8d74ba44..868bf207 100644 --- a/src/logic/safe/utils/safeStorage.ts +++ b/src/logic/safe/utils/safeStorage.ts @@ -27,10 +27,10 @@ export const getLocalSafe = async (safeAddress) => { return storedSafes[safeAddress] } -export const getDefaultSafe = async (): Promise => { +export const getDefaultSafe = async (): Promise => { const defaultSafe = await loadFromStorage(DEFAULT_SAFE_KEY) - return defaultSafe + return defaultSafe || '' } export const saveDefaultSafe = async (safeAddress) => { From 46c227881a4c23bedb9c1918a4f5e593f31da195 Mon Sep 17 00:00:00 2001 From: Mikhail Mikheev Date: Fri, 26 Jun 2020 13:22:34 +0400 Subject: [PATCH 16/22] hardcode ens contract address to isERC721Transaction function, fallback to 18/unknown in methods fetching token decimals --- src/logic/tokens/utils/tokenHelpers.ts | 43 +++++++++++++------ .../transactions/utils/transactionHelpers.ts | 16 +++++-- 2 files changed, 42 insertions(+), 17 deletions(-) diff --git a/src/logic/tokens/utils/tokenHelpers.ts b/src/logic/tokens/utils/tokenHelpers.ts index eab9ec7e..202d000b 100644 --- a/src/logic/tokens/utils/tokenHelpers.ts +++ b/src/logic/tokens/utils/tokenHelpers.ts @@ -26,7 +26,7 @@ export const getEthAsToken = (balance: string): Token => { }) } -export const isAddressAToken = async (tokenAddress): Promise => { +export const isAddressAToken = async (tokenAddress: string): Promise => { // SECOND APPROACH: // They both seem to work the same // const tokenContract = await getStandardTokenContract() @@ -45,36 +45,51 @@ export const isTokenTransfer = (tx: any): boolean => { } export const isSendERC721Transaction = (tx: any, txCode: string, knownTokens: any) => { + // "0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85" - ens token contract, includes safeTransferFrom + // but no proper ERC721 standard implemented return ( - (txCode && txCode.includes(SAFE_TRANSFER_FROM_WITHOUT_DATA_HASH)) || + (txCode && + txCode.includes(SAFE_TRANSFER_FROM_WITHOUT_DATA_HASH) && + tx.to !== '0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85') || (isTokenTransfer(tx) && !knownTokens.get(tx.to)) ) } export const getERC721Symbol = memoize( async (contractAddress: string): Promise => { - const ERC721token = await getERC721TokenContract() - const tokenInstance = await ERC721token.at(contractAddress) - return tokenInstance.symbol() + let tokenSymbol = 'UNKNOWN' + try { + const ERC721token = await getERC721TokenContract() + const tokenInstance = await ERC721token.at(contractAddress) + tokenSymbol = tokenInstance.symbol() + } catch (err) { + console.error(`Failed to retrieve token symbol for ERC721 token ${contractAddress}`) + } + return tokenSymbol }, ) export const getERC20DecimalsAndSymbol = async ( tokenAddress: string, ): Promise<{ decimals: number; symbol: string }> => { - const tokenInfos = await getTokenInfos(tokenAddress) + const tokenInfo = { decimals: 18, symbol: 'UNKNOWN' } + try { + const storedTokenInfo = await getTokenInfos(tokenAddress) - if (tokenInfos === null) { - const [tokenDecimals, tokenSymbol] = await generateBatchRequests({ - abi: ALTERNATIVE_TOKEN_ABI, - address: tokenAddress, - methods: ['decimals', 'symbol'], - }) + if (storedTokenInfo === null) { + const [tokenDecimals, tokenSymbol] = await generateBatchRequests({ + abi: ALTERNATIVE_TOKEN_ABI, + address: tokenAddress, + methods: ['decimals', 'symbol'], + }) - return { decimals: Number(tokenDecimals), symbol: tokenSymbol } + return { decimals: Number(tokenDecimals), symbol: tokenSymbol } + } + } catch (err) { + console.error(`Failed to retrieve token info for ERC20 token ${tokenAddress}`) } - return { decimals: Number(tokenInfos.decimals), symbol: tokenInfos.symbol } + return tokenInfo } export const isSendERC20Transaction = async ( diff --git a/src/routes/safe/store/actions/transactions/utils/transactionHelpers.ts b/src/routes/safe/store/actions/transactions/utils/transactionHelpers.ts index b5b7db88..99817565 100644 --- a/src/routes/safe/store/actions/transactions/utils/transactionHelpers.ts +++ b/src/routes/safe/store/actions/transactions/utils/transactionHelpers.ts @@ -253,7 +253,17 @@ export const buildTx = async ({ const refundParams = await getRefundParams(tx, getERC20DecimalsAndSymbol) const decodedParams = getDecodedParams(tx) const confirmations = getConfirmations(tx) - const { decimals = 18, symbol = 'ETH' } = isSendERC20Tx ? await getERC20DecimalsAndSymbol(tx.to) : {} + + let tokenDecimals = 18 + let tokenSymbol = 'ETH' + if (isSendERC20Tx) { + const { decimals, symbol } = await getERC20DecimalsAndSymbol(tx.to) + tokenDecimals = decimals + tokenSymbol = symbol + } else if (isSendERC721Tx) { + const { symbol } = await getERC721Symbol(tx.to) + tokenSymbol = symbol + } const txToStore = makeTransaction({ baseGas: tx.baseGas, @@ -263,7 +273,7 @@ export const buildTx = async ({ creationTx: tx.creationTx, customTx: isCustomTx, data: tx.data ? tx.data : EMPTY_DATA, - decimals, + decimals: tokenDecimals, decodedParams, executionDate: tx.executionDate, executionTxHash: tx.transactionHash, @@ -286,7 +296,7 @@ export const buildTx = async ({ safeTxGas: tx.safeTxGas, safeTxHash: tx.safeTxHash, submissionDate: tx.submissionDate, - symbol: isSendERC721Tx ? await getERC721Symbol(tx.to) : symbol, + symbol: tokenSymbol, upgradeTx: isUpgradeTx, value: tx.value.toString(), }) From 728bcc3f8e29d51780e4b9c911f1b7b762f41956 Mon Sep 17 00:00:00 2001 From: Mikhail Mikheev Date: Fri, 26 Jun 2020 13:34:12 +0400 Subject: [PATCH 17/22] fix catching errors during retrieving token symbols/decimals --- src/config/development-mainnet.ts | 12 ++++----- src/logic/tokens/utils/tokenHelpers.ts | 25 ++++++++----------- .../transactions/utils/transactionHelpers.ts | 17 +++++++------ 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/config/development-mainnet.ts b/src/config/development-mainnet.ts index a26a7075..d24d20e1 100644 --- a/src/config/development-mainnet.ts +++ b/src/config/development-mainnet.ts @@ -1,11 +1,11 @@ // -import devConfig from './development' +import prodConfig from './production' import { TX_SERVICE_HOST, RELAY_API_URL } from 'src/config/names' -const devMainnetConfig = { - ...devConfig, - [TX_SERVICE_HOST]: 'https://safe-transaction.mainnet.staging.gnosisdev.com/api/v1/', - [RELAY_API_URL]: 'https://safe-relay.mainnet.staging.gnosisdev.com/api/v1/', +const prodMainnetConfig = { + ...prodConfig, + [TX_SERVICE_HOST]: 'https://safe-transaction.mainnet.gnosis.io/api/v1/', + [RELAY_API_URL]: 'https://safe-relay.gnosis.io/api/v1/', } -export default devMainnetConfig +export default prodMainnetConfig diff --git a/src/logic/tokens/utils/tokenHelpers.ts b/src/logic/tokens/utils/tokenHelpers.ts index 202d000b..4fab2c79 100644 --- a/src/logic/tokens/utils/tokenHelpers.ts +++ b/src/logic/tokens/utils/tokenHelpers.ts @@ -1,4 +1,3 @@ -import memoize from 'lodash.memoize' import logo from 'src/assets/icons/icon_etherTokens.svg' import generateBatchRequests from 'src/logic/contracts/generateBatchRequests' import { @@ -55,19 +54,17 @@ export const isSendERC721Transaction = (tx: any, txCode: string, knownTokens: an ) } -export const getERC721Symbol = memoize( - async (contractAddress: string): Promise => { - let tokenSymbol = 'UNKNOWN' - try { - const ERC721token = await getERC721TokenContract() - const tokenInstance = await ERC721token.at(contractAddress) - tokenSymbol = tokenInstance.symbol() - } catch (err) { - console.error(`Failed to retrieve token symbol for ERC721 token ${contractAddress}`) - } - return tokenSymbol - }, -) +export const getERC721Symbol = async (contractAddress: string): Promise => { + let tokenSymbol = 'UNKNOWN' + try { + const ERC721token = await getERC721TokenContract() + const tokenInstance = await ERC721token.at(contractAddress) + tokenSymbol = tokenInstance.symbol() + } catch (err) { + console.error(`Failed to retrieve token symbol for ERC721 token ${contractAddress}`) + } + return tokenSymbol +} export const getERC20DecimalsAndSymbol = async ( tokenAddress: string, diff --git a/src/routes/safe/store/actions/transactions/utils/transactionHelpers.ts b/src/routes/safe/store/actions/transactions/utils/transactionHelpers.ts index 99817565..ba8de692 100644 --- a/src/routes/safe/store/actions/transactions/utils/transactionHelpers.ts +++ b/src/routes/safe/store/actions/transactions/utils/transactionHelpers.ts @@ -256,13 +256,16 @@ export const buildTx = async ({ let tokenDecimals = 18 let tokenSymbol = 'ETH' - if (isSendERC20Tx) { - const { decimals, symbol } = await getERC20DecimalsAndSymbol(tx.to) - tokenDecimals = decimals - tokenSymbol = symbol - } else if (isSendERC721Tx) { - const { symbol } = await getERC721Symbol(tx.to) - tokenSymbol = symbol + try { + if (isSendERC20Tx) { + const { decimals, symbol } = await getERC20DecimalsAndSymbol(tx.to) + tokenDecimals = decimals + tokenSymbol = symbol + } else if (isSendERC721Tx) { + tokenSymbol = await getERC721Symbol(tx.to) + } + } catch (err) { + console.log(`Failed to retrieve token data from ${tx.to}`) } const txToStore = makeTransaction({ From 00843b5c6603751801f05c762b893e691930d4ed Mon Sep 17 00:00:00 2001 From: Mikhail Mikheev Date: Fri, 26 Jun 2020 13:36:43 +0400 Subject: [PATCH 18/22] Fix dev mainnet config --- src/config/development-mainnet.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/config/development-mainnet.ts b/src/config/development-mainnet.ts index d24d20e1..a26a7075 100644 --- a/src/config/development-mainnet.ts +++ b/src/config/development-mainnet.ts @@ -1,11 +1,11 @@ // -import prodConfig from './production' +import devConfig from './development' import { TX_SERVICE_HOST, RELAY_API_URL } from 'src/config/names' -const prodMainnetConfig = { - ...prodConfig, - [TX_SERVICE_HOST]: 'https://safe-transaction.mainnet.gnosis.io/api/v1/', - [RELAY_API_URL]: 'https://safe-relay.gnosis.io/api/v1/', +const devMainnetConfig = { + ...devConfig, + [TX_SERVICE_HOST]: 'https://safe-transaction.mainnet.staging.gnosisdev.com/api/v1/', + [RELAY_API_URL]: 'https://safe-relay.mainnet.staging.gnosisdev.com/api/v1/', } -export default prodMainnetConfig +export default devMainnetConfig From f2f9cb7d81f55c8d78ffcaaec2b192acfb8e3634 Mon Sep 17 00:00:00 2001 From: Mikhail Mikheev Date: Fri, 26 Jun 2020 18:38:59 +0400 Subject: [PATCH 19/22] default safe logic fixes --- src/routes/index.tsx | 3 ++- src/routes/safe/store/reducer/safe.ts | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/routes/index.tsx b/src/routes/index.tsx index e8b8e6a9..b9776171 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -7,6 +7,7 @@ import { LOAD_ADDRESS, OPEN_ADDRESS, SAFELIST_ADDRESS, SAFE_PARAM_ADDRESS, WELCO import Loader from 'src/components/Loader' import { defaultSafeSelector } from 'src/routes/safe/store/selectors' import { useAnalytics } from 'src/utils/googleAnalytics' +import { DEFAULT_SAFE_INITIAL_STATE } from 'src/routes/safe/store/reducer/safe' const Welcome = React.lazy(() => import('./welcome/container')) @@ -44,7 +45,7 @@ const Routes = ({ location }) => { return } - if (typeof defaultSafe === 'undefined') { + if (defaultSafe === DEFAULT_SAFE_INITIAL_STATE) { return } diff --git a/src/routes/safe/store/reducer/safe.ts b/src/routes/safe/store/reducer/safe.ts index 73e9c55e..8b3e23ec 100644 --- a/src/routes/safe/store/reducer/safe.ts +++ b/src/routes/safe/store/reducer/safe.ts @@ -16,6 +16,7 @@ import makeSafe from 'src/routes/safe/store/models/safe' import { checksumAddress } from 'src/utils/checksumAddress' export const SAFE_REDUCER_ID = 'safes' +export const DEFAULT_SAFE_INITIAL_STATE = 'NOT_ASKED' export const buildSafe = (storedSafe) => { const names = storedSafe.owners.map((owner) => owner.name) @@ -125,10 +126,8 @@ export default handleActions( [SET_LATEST_MASTER_CONTRACT_VERSION]: (state, action) => state.set('latestMasterContractVersion', action.payload), }, Map({ - // $FlowFixMe - defaultSafe: undefined, + defaultSafe: DEFAULT_SAFE_INITIAL_STATE, safes: Map(), - // $FlowFixMe latestMasterContractVersion: '', }), ) From ed72219f038ba8924818f860ecf0b6542b61ea5b Mon Sep 17 00:00:00 2001 From: Mikhail Mikheev Date: Mon, 29 Jun 2020 15:29:27 +0400 Subject: [PATCH 20/22] type definition fixes --- src/logic/tokens/utils/tokensStorage.ts | 2 +- src/utils/storage/index.ts | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/logic/tokens/utils/tokensStorage.ts b/src/logic/tokens/utils/tokensStorage.ts index 1b9f7970..27364f24 100644 --- a/src/logic/tokens/utils/tokensStorage.ts +++ b/src/logic/tokens/utils/tokensStorage.ts @@ -12,7 +12,7 @@ export const CUSTOM_TOKENS_KEY = 'CUSTOM_TOKENS' export const saveActiveTokens = async (tokens: Map): Promise => { try { - await saveToStorage(ACTIVE_TOKENS_KEY, tokens.toJS()) + await saveToStorage(ACTIVE_TOKENS_KEY, tokens.toJS() as Record) } catch (err) { console.error('Error storing tokens in localstorage', err) } diff --git a/src/utils/storage/index.ts b/src/utils/storage/index.ts index 5110fd37..bf0e8fce 100644 --- a/src/utils/storage/index.ts +++ b/src/utils/storage/index.ts @@ -10,7 +10,7 @@ export const storage = new ImmortalStorage(stores) const PREFIX = `v2_${getNetwork()}` -export const loadFromStorage = async (key: string): Promise => { +export const loadFromStorage = async (key: string): Promise => { try { const stringifiedValue = await storage.get(`${PREFIX}__${key}`) if (stringifiedValue === null || stringifiedValue === undefined) { @@ -24,7 +24,10 @@ export const loadFromStorage = async (key: string): Promise { +export const saveToStorage = async ( + key: string, + value: Record | boolean | string | number | Array, +): Promise => { try { const stringifiedValue = JSON.stringify(value) await storage.set(`${PREFIX}__${key}`, stringifiedValue) @@ -33,7 +36,7 @@ export const saveToStorage = async (key, value) => { } } -export const removeFromStorage = async (key) => { +export const removeFromStorage = async (key: string): Promise => { try { await storage.remove(`${PREFIX}__${key}`) } catch (err) { From 6def3cbc930e8afabdabd61f4257eba82fddac17 Mon Sep 17 00:00:00 2001 From: nicolas Date: Mon, 29 Jun 2020 13:39:48 -0300 Subject: [PATCH 21/22] add Aave app (#1075) --- src/routes/safe/components/Apps/utils.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/routes/safe/components/Apps/utils.ts b/src/routes/safe/components/Apps/utils.ts index b39862da..d6611f87 100644 --- a/src/routes/safe/components/Apps/utils.ts +++ b/src/routes/safe/components/Apps/utils.ts @@ -18,12 +18,9 @@ export const staticAppsList: Array<{ url: string; disabled: boolean }> = [ // request { url: `${process.env.REACT_APP_IPFS_GATEWAY}/QmQapdJP6zERqpDKKPECNeMDDgwmGUqbKk1PjHpYj8gfDJ`, disabled: false }, // Aave - // { url: `${process.env.REACT_APP_IPFS_GATEWAY}/QmUfgEqdJ5kVjWTQofnDmvxdhDLBAaejiHkhQhfw6aYvBg`, disabled: false }, + { url: `${process.env.REACT_APP_IPFS_GATEWAY}/QmfHFQHCSyaSL8Aq4eWZeB3buy4neiUCPchob2pYdV9gJT`, disabled: false }, { url: `${gnosisAppsUrl}/compound`, disabled: false }, { url: `${gnosisAppsUrl}/tx-builder`, disabled: false }, - { url: `${gnosisAppsUrl}/pool-together`, disabled: false }, - { url: `${gnosisAppsUrl}/open-zeppelin`, disabled: false }, - { url: `${gnosisAppsUrl}/synthetix`, disabled: false }, ] export const getAppInfoFromOrigin = (origin) => { From 6008eb1eb00418051738df1147dc6029eb34d08f Mon Sep 17 00:00:00 2001 From: nicolas Date: Mon, 29 Jun 2020 14:08:58 -0300 Subject: [PATCH 22/22] bump package.json version (#1077) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1e969774..b027b1ec 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "safe-react", - "version": "2.3.1", + "version": "2.4.0", "description": "Allowing crypto users manage funds in a safer way", "website": "https://github.com/gnosis/safe-react#readme", "bugs": {