Skip to content

Commit

Permalink
Correct logic to follow runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
ikprk committed Jul 9, 2024
1 parent e9cd9b5 commit c00bf0a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/atlas/src/hooks/useIsTokenInLockedMode.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { useRef } from 'react'

// import { useRef } from 'react'
import { FullCreatorTokenFragment } from '@/api/queries/__generated__/fragments.generated'
import { useJoystreamStore } from '@/providers/joystream/joystream.store'

// import { useJoystreamStore } from '@/providers/joystream/joystream.store'

export const useIsTokenInLockedMode = (token?: FullCreatorTokenFragment) => {
const currentBlockRef = useRef(useJoystreamStore((store) => store.currentBlock))
// const currentBlockRef = useRef(useJoystreamStore((store) => store.currentBlock))
// 1. Check if there is any unfinalized revenue share
const activeRevenueShare = token?.revenueShares.find((rS) => !rS.finalized)

// 2. If ending block is not yet came for a user, consider that the token is locked
const hasActiveRevenueShare = (activeRevenueShare?.endsAt ?? 0) > currentBlockRef.current
// BUG: looks like runtime doesnt allow to make tx if the revenue share not finalized
// const hasActiveRevenueShare = (activeRevenueShare?.endsAt ?? 0) > currentBlockRef.current

return hasActiveRevenueShare
return !!activeRevenueShare
}

0 comments on commit c00bf0a

Please sign in to comment.