update safe and token models
This commit is contained in:
parent
f5983447ee
commit
93cf045c00
|
@ -8,9 +8,6 @@ export type TokenProps = {
|
||||||
symbol: string,
|
symbol: string,
|
||||||
decimals: number,
|
decimals: number,
|
||||||
logoUri: string,
|
logoUri: string,
|
||||||
funds: string,
|
|
||||||
status: boolean,
|
|
||||||
removable: boolean,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const makeToken: RecordFactory<TokenProps> = Record({
|
export const makeToken: RecordFactory<TokenProps> = Record({
|
||||||
|
@ -19,9 +16,6 @@ export const makeToken: RecordFactory<TokenProps> = Record({
|
||||||
symbol: '',
|
symbol: '',
|
||||||
decimals: 0,
|
decimals: 0,
|
||||||
logoUri: '',
|
logoUri: '',
|
||||||
funds: '0',
|
|
||||||
status: true,
|
|
||||||
removable: false,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
export type Token = RecordOf<TokenProps>
|
export type Token = RecordOf<TokenProps>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// @flow
|
// @flow
|
||||||
import { List } from 'immutable'
|
import { List } from 'immutable'
|
||||||
import { createAction } from 'redux-actions'
|
import { createAction } from 'redux-actions'
|
||||||
import { type Safe, makeSafe } from '~/routes/safe/store/model/safe'
|
import SafeRecord, { type Safe } from '~/routes/safe/store/model/safe'
|
||||||
import { saveSafes, setOwners } from '~/logic/safe/utils'
|
import { saveSafes, setOwners } from '~/logic/safe/utils'
|
||||||
import { makeOwner, type Owner } from '~/routes/safe/store/model/owner'
|
import { makeOwner, type Owner } from '~/routes/safe/store/model/owner'
|
||||||
import type { Dispatch as ReduxDispatch, GetState } from 'redux'
|
import type { Dispatch as ReduxDispatch, GetState } from 'redux'
|
||||||
|
@ -37,7 +37,7 @@ const saveSafe = (
|
||||||
const owners: List<Owner> = buildOwnersFrom(ownersName, ownersAddress)
|
const owners: List<Owner> = buildOwnersFrom(ownersName, ownersAddress)
|
||||||
const state: GlobalState = getState()
|
const state: GlobalState = getState()
|
||||||
|
|
||||||
const safe: Safe = makeSafe({
|
const safe: Safe = SafeRecord({
|
||||||
name,
|
name,
|
||||||
address,
|
address,
|
||||||
threshold,
|
threshold,
|
||||||
|
|
|
@ -3,7 +3,7 @@ import type { Dispatch as ReduxDispatch } from 'redux'
|
||||||
import { List, Map } from 'immutable'
|
import { List, Map } from 'immutable'
|
||||||
import { type GlobalState } from '~/store/index'
|
import { type GlobalState } from '~/store/index'
|
||||||
import { makeOwner } from '~/routes/safe/store/model/owner'
|
import { makeOwner } from '~/routes/safe/store/model/owner'
|
||||||
import { type SafeProps, makeSafe } from '~/routes/safe/store/model/safe'
|
import SafeRecord, { type SafeProps } from '~/routes/safe/store/model/safe'
|
||||||
import updateSafe from '~/routes/safe/store/actions/updateSafe'
|
import updateSafe from '~/routes/safe/store/actions/updateSafe'
|
||||||
import { getOwners, getSafeName } from '~/logic/safe/utils'
|
import { getOwners, getSafeName } from '~/logic/safe/utils'
|
||||||
import { getGnosisSafeContract } from '~/logic/contracts/safeContracts'
|
import { getGnosisSafeContract } from '~/logic/contracts/safeContracts'
|
||||||
|
@ -29,7 +29,7 @@ export const buildSafe = async (safeAddress: string, safeName: string) => {
|
||||||
owners,
|
owners,
|
||||||
}
|
}
|
||||||
|
|
||||||
return makeSafe(safe)
|
return SafeRecord(safe)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default (safeAddress: string) => async (dispatch: ReduxDispatch<GlobalState>) => {
|
export default (safeAddress: string) => async (dispatch: ReduxDispatch<GlobalState>) => {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// @flow
|
// @flow
|
||||||
import { List, Record } from 'immutable'
|
import { List, Record, Map } from 'immutable'
|
||||||
import type { RecordFactory, RecordOf } from 'immutable'
|
import type { RecordFactory, RecordOf } from 'immutable'
|
||||||
import type { Owner } from '~/routes/safe/store/model/owner'
|
import type { Owner } from '~/routes/safe/store/model/owner'
|
||||||
|
|
||||||
|
@ -8,15 +8,17 @@ export type SafeProps = {
|
||||||
address: string,
|
address: string,
|
||||||
threshold: number,
|
threshold: number,
|
||||||
owners: List<Owner>,
|
owners: List<Owner>,
|
||||||
|
activeTokensBalances: Map<String, String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const makeSafe: RecordFactory<SafeProps> = Record({
|
const SafeRecord: RecordFactory<SafeProps> = Record({
|
||||||
name: '',
|
name: '',
|
||||||
address: '',
|
address: '',
|
||||||
threshold: 0,
|
threshold: 0,
|
||||||
owners: List([]),
|
owners: List([]),
|
||||||
|
activeTokensBalances: Map([]),
|
||||||
})
|
})
|
||||||
|
|
||||||
export type Safe = RecordOf<SafeProps>
|
export type Safe = RecordOf<SafeProps>
|
||||||
|
|
||||||
// Useage const someRecord: Safe = makeSafe({ name: ... })
|
export default SafeRecord
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
import { Map } from 'immutable'
|
import { Map } from 'immutable'
|
||||||
import { handleActions, type ActionType } from 'redux-actions'
|
import { handleActions, type ActionType } from 'redux-actions'
|
||||||
import { ADD_SAFE, buildOwnersFrom } from '~/routes/safe/store/actions/addSafe'
|
import { ADD_SAFE, buildOwnersFrom } from '~/routes/safe/store/actions/addSafe'
|
||||||
import { type Safe, type SafeProps, makeSafe } from '~/routes/safe/store/model/safe'
|
import SafeRecord, { type Safe, type SafeProps } from '~/routes/safe/store/model/safe'
|
||||||
import { type OwnerProps } from '~/routes/safe/store/model/owner'
|
import { type OwnerProps } from '~/routes/safe/store/model/owner'
|
||||||
import { loadFromStorage } from '~/utils/storage'
|
import { loadFromStorage } from '~/utils/storage'
|
||||||
import { SAFES_KEY } from '~/logic/safe/utils'
|
import { SAFES_KEY } from '~/logic/safe/utils'
|
||||||
|
@ -21,10 +21,12 @@ export const buildSafe = (storedSafe: SafeProps) => {
|
||||||
address: storedSafe.address,
|
address: storedSafe.address,
|
||||||
name: storedSafe.name,
|
name: storedSafe.name,
|
||||||
threshold: storedSafe.threshold,
|
threshold: storedSafe.threshold,
|
||||||
|
activeTokens: storedSafe.activeTokens,
|
||||||
|
balances: storedSafe.balances,
|
||||||
owners,
|
owners,
|
||||||
}
|
}
|
||||||
|
|
||||||
return makeSafe(safe)
|
return SafeRecord(safe)
|
||||||
}
|
}
|
||||||
|
|
||||||
const buildSafesFrom = (loadedSafes: Object): Map<string, Safe> => {
|
const buildSafesFrom = (loadedSafes: Object): Map<string, Safe> => {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
// @flow
|
// @flow
|
||||||
import { makeSafe, type Safe } from '~/routes/safe/store/model/safe'
|
import SafeRecord, { type Safe } from '~/routes/safe/store/model/safe'
|
||||||
import { buildOwnersFrom } from '~/routes/safe/store/actions/addSafe'
|
import { buildOwnersFrom } from '~/routes/safe/store/actions/addSafe'
|
||||||
|
|
||||||
class SafeBuilder {
|
class SafeBuilder {
|
||||||
safe: Safe
|
safe: Safe
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.safe = makeSafe()
|
this.safe = SafeRecord()
|
||||||
}
|
}
|
||||||
|
|
||||||
withAddress(address: string) {
|
withAddress(address: string) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// @flow
|
// @flow
|
||||||
import { makeSafe, type Safe } from '~/routes/safe/store/model/safe'
|
import SafeRecord, { type Safe } from '~/routes/safe/store/model/safe'
|
||||||
import addSafe, { buildOwnersFrom } from '~/routes/safe/store/actions/addSafe'
|
import addSafe, { buildOwnersFrom } from '~/routes/safe/store/actions/addSafe'
|
||||||
import {
|
import {
|
||||||
FIELD_NAME,
|
FIELD_NAME,
|
||||||
|
@ -18,7 +18,7 @@ class SafeBuilder {
|
||||||
safe: Safe
|
safe: Safe
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.safe = makeSafe()
|
this.safe = SafeRecord()
|
||||||
}
|
}
|
||||||
|
|
||||||
withAddress(address: string) {
|
withAddress(address: string) {
|
||||||
|
|
Loading…
Reference in New Issue