Store transaction subject function

This commit is contained in:
apanizo 2018-08-03 10:15:01 +02:00
parent d8b7d171c6
commit 45fda62e19
1 changed files with 19 additions and 0 deletions

View File

@ -0,0 +1,19 @@
// @flow
import { Map } from 'immutable'
import { load } from '~/utils/localStorage'
const getSubjectKeyFrom = (safeAddress: string) => `TXS-SUBJECTS-${safeAddress}`
export const storeSubject = (safeAddress: string, nonce: number, subject: string) => {
const key = getSubjectKeyFrom(safeAddress)
const subjects = load(key) || Map()
try {
const updatedSubjects = subjects.setIn([safeAddress, String(nonce)], subject)
const serializedState = JSON.stringify(updatedSubjects)
localStorage.setItem(key, serializedState)
} catch (err) {
// eslint-disable-next-line
console.log('Error storing transaction subject in localstorage')
}
}