From 7efcf4496131a3cc4e639deb45cf6dcd96c7a723 Mon Sep 17 00:00:00 2001 From: apanizo Date: Mon, 21 May 2018 16:09:01 +0200 Subject: [PATCH] WA-238 Adding confirmation and transaction model entities (Immutable Records) --- src/routes/safe/store/model/confirmation.js | 16 +++++++++++++ src/routes/safe/store/model/transaction.js | 26 +++++++++++++++++++++ src/routes/safe/store/reducer/safe.js | 4 ++-- 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 src/routes/safe/store/model/confirmation.js create mode 100644 src/routes/safe/store/model/transaction.js diff --git a/src/routes/safe/store/model/confirmation.js b/src/routes/safe/store/model/confirmation.js new file mode 100644 index 00000000..71fa5602 --- /dev/null +++ b/src/routes/safe/store/model/confirmation.js @@ -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 = Record({ + owner: makeOwner(), + status: false, +}) + +export type Confirmation = RecordOf diff --git a/src/routes/safe/store/model/transaction.js b/src/routes/safe/store/model/transaction.js new file mode 100644 index 00000000..83a664d0 --- /dev/null +++ b/src/routes/safe/store/model/transaction.js @@ -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, + destination: string, + tx: string, +} + +export const makeTransaction: RecordFactory = Record({ + name: '', + nonce: 0, + value: 0, + confirmations: List([]), + destination: '', + tx: '', + threshold: 0, +}) + +export type Transaction = RecordOf diff --git a/src/routes/safe/store/reducer/safe.js b/src/routes/safe/store/reducer/safe.js index 550e9b87..ec6543ef 100644 --- a/src/routes/safe/store/reducer/safe.js +++ b/src/routes/safe/store/reducer/safe.js @@ -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() }