kodadot/nft-gallery

View on GitHub
composables/useBlockTime.ts

Summary

Maintainability
A
0 mins
Test Coverage
import type { PartialConfig } from '@/utils/config/types'

export default function () {
  const { urlPrefix } = usePrefix()

  const paraChainBlockTime = 12 // seconds
  const relayChainBlockTime = 6 // seconds

  const chainBlockTimes: PartialConfig<number> = {
    ksm: relayChainBlockTime,
    dot: relayChainBlockTime,
  }

  const blockTime = computed(
    () => chainBlockTimes[urlPrefix.value] ?? paraChainBlockTime,
  )

  const estimatedTimes = computed(() => ({
    [TransactionStatus.Broadcast]: 3 * blockTime.value,
    [TransactionStatus.Block]: 2 * blockTime.value,
  }))

  return {
    blockTime,
    estimatedTimes,
  }
}