Types
This commit is contained in:
parent
5c00d51c3c
commit
caa94c879b
|
@ -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<SafeOwner>,
|
||||
addSafe: Dispatch<any>,
|
||||
): Promise<void> => {
|
||||
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)
|
||||
|
|
|
@ -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<SafeOwner> => {
|
||||
const owners = names.map((name, index) => makeOwner({ name, address: addresses[index] }))
|
||||
|
||||
return List(owners)
|
||||
|
|
|
@ -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<SafeOwner>(buildOwnersFrom(remoteOwners, localSafe))
|
||||
const needsUpdate = safeNeedsUpdate(currentVersion, latestMasterContractVersion)
|
||||
const featuresEnabled = enabledFeatures(currentVersion)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue