Skip to content

Commit

Permalink
chore: bump fast-unstake stored exposure version
Browse files Browse the repository at this point in the history
To avoid conflict from `ErasStakersPaged` upgrade
  • Loading branch information
tien committed Apr 23, 2024
1 parent 2cd0195 commit 8da3d8c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions apps/portal/src/domains/fastUnstake/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { writeableSubstrateAccountsState } from '@domains/accounts/recoils'
import { useSubstrateApiEndpoint, useSubstrateApiState } from '@domains/common'
import { encodeAddress } from '@polkadot/util-crypto'
import { bool, coercion, jsonParser, writableDict } from '@recoiljs/refine'
import { bool, coercion, jsonParser, literal, object, writableDict } from '@recoiljs/refine'
import { useQueryState } from '@talismn/react-polkadot-api'
import { useMemo } from 'react'
import { DefaultValue, atomFamily, useRecoilValue } from 'recoil'
Expand All @@ -11,7 +11,7 @@ import type { WorkerFunction } from './worker'

const getExposureKey = (genesisHash: string) => `fast-unstake-exposure/${genesisHash}`

const exposureChecker = writableDict(writableDict(bool()))
const exposureChecker = object({ version: literal(0), value: writableDict(writableDict(bool())) })
const exposureCoercion = coercion(exposureChecker)
const exposureJsonParser = jsonParser(exposureChecker)

Expand All @@ -27,10 +27,11 @@ const unexposedAddressesState = atomFamily<
return
}

const exposure = exposureJsonParser(localStorage.getItem(getExposureKey(genesisHash))) ?? {}
const storedExposure = exposureJsonParser(localStorage.getItem(getExposureKey(genesisHash)))
const exposure = storedExposure?.value ?? {}

const storeExposure = () => {
const coercedExposure = exposureCoercion(exposure)
const coercedExposure = exposureCoercion({ version: 0, value: exposure })

if (coercedExposure !== undefined && coercedExposure !== null) {
localStorage.setItem(getExposureKey(genesisHash), JSON.stringify(coercedExposure))
Expand Down

0 comments on commit 8da3d8c

Please sign in to comment.