WA-238 Adding confirmation and transaction model entities (Immutable Records)

This commit is contained in:
apanizo 2018-05-21 16:09:01 +02:00
parent a16b5ed0f2
commit 7efcf44961
3 changed files with 44 additions and 2 deletions

View File

@ -0,0 +1,16 @@
// @flow
import { Record } from 'immutable'
import type { RecordFactory, RecordOf } from 'immutable'
import { makeOwner, type Owner } from '~/routes/safe/store/model/owner'
export type ConfirmationProps = {
owner: Owner,
status: boolean, // false: not confirmed, true: confirmed
}
export const makeConfirmation: RecordFactory<ConfirmationProps> = Record({
owner: makeOwner(),
status: false,
})
export type Confirmation = RecordOf<ConfirmationProps>

View File

@ -0,0 +1,26 @@
// @flow
import { List, Record } from 'immutable'
import type { RecordFactory, RecordOf } from 'immutable'
import { type Confirmation } from '~/routes/safe/store/model/confirmation'
export type TransactionProps = {
name: string,
nonce: number,
value: number,
threshold: number,
confirmations: List<Confirmation>,
destination: string,
tx: string,
}
export const makeTransaction: RecordFactory<TransactionProps> = Record({
name: '',
nonce: 0,
value: 0,
confirmations: List([]),
destination: '',
tx: '',
threshold: 0,
})
export type Transaction = RecordOf<TransactionProps>

View File

@ -5,7 +5,7 @@ import addSafe, { ADD_SAFE } from '~/routes/safe/store/actions/addSafe'
import updateDailyLimit, { UPDATE_DAILY_LIMIT } from '~/routes/safe/store/actions/updateDailyLimit'
import { makeOwner } from '~/routes/safe/store/model/owner'
import { type Safe, makeSafe } from '~/routes/safe/store/model/safe'
import { loadSafes, saveSafes } from '~/utils/localStorage'
import { load, saveSafes, SAFES_KEY } from '~/utils/localStorage'
import { makeDailyLimit } from '~/routes/safe/store/model/dailyLimit'
export const SAFE_REDUCER_ID = 'safes'
@ -26,7 +26,7 @@ const buildSafesFrom = (loadedSafes: Object): State => {
}
export const calculateInitialState = (): State => {
const storedSafes = loadSafes()
const storedSafes = load(SAFES_KEY)
return storedSafes ? buildSafesFrom(storedSafes) : Map()
}