@visualizevalue/mint-app-base 0.1.66 → 0.1.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,6 +9,7 @@
9
9
  currentBlock,
10
10
  blocksRemaining,
11
11
  secondsRemaining,
12
+ countDownStr,
12
13
  until,
13
14
  transactionFlowConfig: {
14
15
  title: {
@@ -54,9 +55,11 @@ const priceFeed = usePriceFeedStore()
54
55
 
55
56
  const { data: currentBlock } = useBlockNumber({ chainId: config.public.chainId })
56
57
  const blocksRemaining = computed(() => props.token.mintedBlock + 7200n - (currentBlock.value || 0n))
57
- const mintOpen = computed(() => currentBlock.value && blocksRemaining.value > 0n)
58
- const secondsRemaining = computed(() => props.token.closeAt - BigInt(nowInSeconds()))
58
+ const now = useNow()
59
59
  const until = computed(() => props.token.closeAt)
60
+ const secondsRemaining = computed(() => until.value - BigInt(now.value))
61
+ const mintOpen = computed(() => secondsRemaining.value > 0)
62
+ const { str: countDownStr } = useCountDown(secondsRemaining)
60
63
 
61
64
  const mintCount = computed(() => props.mintCount)
62
65
  const { price, displayPrice } = useMintPrice(mintCount)
@@ -24,7 +24,7 @@
24
24
  minted,
25
25
  mintOpen,
26
26
  currentBlock,
27
- blocksRemaining,
27
+ countDownStr,
28
28
  transactionFlowConfig
29
29
  }"
30
30
  >
@@ -54,13 +54,12 @@
54
54
  </div>
55
55
 
56
56
  <div class="mint-status">
57
- <p v-if="mintOpen">{{ $t('token.blocks_remaining', { blocksRemaining }) }}</p>
57
+ <p v-if="mintOpen">{{ $t('token.closes_in', { time: countDownStr }) }}</p>
58
58
  <p v-else-if="currentBlock">
59
- {{ $t('token.closed_at_block')}}
60
- {{ token.mintedBlock + BLOCKS_PER_DAY }}
59
+ {{ $t('token.closed_ago', { time: countDownStr })}}
61
60
  </p>
62
61
  <p v-if="ownedBalance">
63
- {{ $t('token.you_own', { ownedBalance }) }}
62
+ {{ $t('token.you_own', { ownedBalance }) }}
64
63
  {{ $t('tokens', Number(ownedBalance)) }}
65
64
  </p>
66
65
  </div>
@@ -9,6 +9,8 @@
9
9
  minted,
10
10
  mintOpen,
11
11
  blocksRemaining,
12
+ secondsRemaining,
13
+ countDownStr,
12
14
  transactionFlowConfig
13
15
  }"
14
16
  >
@@ -20,6 +22,8 @@
20
22
  :mintRequest="mintRequest"
21
23
  :minted="minted"
22
24
  :mintOpen="mintOpen"
25
+ :secondsRemaining="secondsRemaining"
26
+ :countDownStr="countDownStr"
23
27
  :blocksRemaining="blocksRemaining"
24
28
  :transactionFlowConfig="transactionFlowConfig"
25
29
  >
@@ -29,10 +33,7 @@
29
33
  <span>{{ token.name }} <span class="token-id">#{{ token.tokenId }}</span></span>
30
34
  <span v-if="token.description" class="description">{{ shortString(token.description, 60, 30) }}</span>
31
35
  </h1>
32
- <p v-if="mintOpen" class="closes-in">
33
- {{ $t('token.closes_in') }} {{ blocksRemaining }} {{ $t('blocks', Number(blocksRemaining)) }}
34
- </p>
35
- <p v-else class="closed-at">{{ $t('token.closed_at_block') }} {{ token.mintedBlock + BLOCKS_PER_DAY }}</p>
36
+ <p v-if="mintOpen" class="closes-in">{{ $t('token.closes_in', { time: countDownStr }) }}</p>
36
37
  </header>
37
38
  <Embed v-if="token.animationUrl" :src="token.animationUrl" />
38
39
  <Image v-else-if="token.image" :src="token.image" :alt="token.name" />
@@ -65,6 +66,8 @@
65
66
  </template>
66
67
 
67
68
  <script setup lang="ts">
69
+ import CountDownUntil from '../CountDownUntil.vue';
70
+
68
71
  const { token } = defineProps<{
69
72
  token: Token
70
73
  }>()
package/locales/en.json CHANGED
@@ -71,9 +71,8 @@
71
71
  },
72
72
  "token": {
73
73
  "by": "By",
74
- "closes_in": "Closes in",
75
- "blocks_remaining": "{blocksRemaining} blocks remaining",
76
- "closed_at_block": "Closed at block",
74
+ "closes_in": "Closes in {time}",
75
+ "closed_ago": "Closed {time} ago",
77
76
  "you_own": "You own {ownedBalance} {tokens}",
78
77
  "mint_timeline": "Mint Timeline",
79
78
  "artist_mint": "Artist Mint",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visualizevalue/mint-app-base",
3
- "version": "0.1.66",
3
+ "version": "0.1.67",
4
4
  "type": "module",
5
5
  "main": "./nuxt.config.ts",
6
6
  "dependencies": {
package/utils/time.ts CHANGED
@@ -19,3 +19,24 @@ export const useNow = () => {
19
19
 
20
20
  return now
21
21
  }
22
+
23
+ export const useCountDown = (s: Ref<Number|BigInt>) => {
24
+ const duration = computed(() => Math.abs(parseInt(`${s.value}`)))
25
+
26
+ const seconds = computed(() => duration.value % 60)
27
+ const minutes = computed(() => Math.floor(duration.value / 60) % 60)
28
+ const hours = computed(() => Math.floor(duration.value / 60 / 60))
29
+
30
+ const str = computed(() => [
31
+ hours.value ? `${hours.value}h` : null,
32
+ minutes.value ? `${minutes.value}m` : null,
33
+ seconds.value ? `${seconds.value}s` : null,
34
+ ].filter(s => !!s).join(' '))
35
+
36
+ return {
37
+ seconds,
38
+ minutes,
39
+ hours,
40
+ str,
41
+ }
42
+ }