Skip to content

Commit dd8eac7

Browse files
authored
Merge pull request #177 from celenium-io/dev
fix(Events): event amount
2 parents c0e19be + 5ff73e8 commit dd8eac7

5 files changed

Lines changed: 436 additions & 38 deletions

File tree

.prettierrc

Lines changed: 0 additions & 7 deletions
This file was deleted.

.prettierrc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"semi": false,
3+
"trailingComma": "all",
4+
"printWidth": 140,
5+
"tabWidth": 4,
6+
"useTabs": true
7+
}

components/shared/tables/Events.vue

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { fetchBlockEvents } from "@/services/api/block"
1616
/** Store */
1717
import { useModalsStore } from "@/store/modals.store"
1818
import { useCacheStore } from "@/store/cache.store"
19+
1920
const modalsStore = useModalsStore()
2021
const cacheStore = useCacheStore()
2122
@@ -119,6 +120,15 @@ watch(
119120
getEvents()
120121
},
121122
)
123+
124+
const formatEventAmount = (amount) => {
125+
console.log(amount)
126+
if (amount.endsWith("utia")) {
127+
return `${tia(amount.replace("utia", ""))} TIA`
128+
}
129+
130+
return amount.replace(/^(\d+)(.*)/, "$1 $2")
131+
}
122132
</script>
123133

124134
<template>
@@ -161,8 +171,8 @@ watch(
161171
<Text size="12" weight="500" color="secondary">spent</Text>
162172

163173
<Text size="12" weight="500" color="primary" mono no-wrap>
164-
{{ tia(event.data.amount.replace("utia", "")) }} TIA</Text
165-
>
174+
{{ event.data.amount ? formatEventAmount(event.data.amount) : 0 }}
175+
</Text>
166176
</Flex>
167177
<!-- Event: coin_received -->
168178
<Flex v-else-if="event.type === 'coin_received'" align="center" gap="4" color="secondary" :class="$style.text">
@@ -181,7 +191,7 @@ watch(
181191
<Text size="12" weight="500" color="secondary">received</Text>
182192

183193
<Text size="12" weight="500" color="primary" mono no-wrap>
184-
{{ tia(event.data.amount.replace("utia", "")) }} TIA
194+
{{ event.data.amount ? formatEventAmount(event.data.amount) : 0 }}
185195
</Text>
186196
</Flex>
187197
<!-- Event: delegate -->
@@ -223,8 +233,8 @@ watch(
223233
<Text size="12" weight="500" color="secondary">sent</Text>
224234

225235
<Text size="12" weight="500" color="primary" mono no-wrap>
226-
{{ tia(event.data.amount.replace("utia", "")) }} TIA</Text
227-
>
236+
{{ event.data.amount ? formatEventAmount(event.data.amount) : 0 }}
237+
</Text>
228238

229239
<Text size="12" weight="500" color="secondary">to</Text>
230240

@@ -297,8 +307,8 @@ watch(
297307
<Text size="12" weight="500" color="secondary">paid</Text>
298308

299309
<Text size="12" weight="500" color="primary" mono no-wrap>
300-
{{ tia(event.data.fee.replace("utia", "")) }} TIA</Text
301-
>
310+
{{ event.data.amount ? formatEventAmount(event.data.amount) : 0 }}
311+
</Text>
302312

303313
<Text size="12" weight="500" color="secondary">fee</Text>
304314
</template>
@@ -343,8 +353,8 @@ watch(
343353
<Text size="12" weight="500" color="secondary">Withdrawal</Text>
344354

345355
<Text size="12" weight="500" color="primary" mono no-wrap>
346-
{{ tia(event.data.amount.replace("utia", "")) }} TIA</Text
347-
>
356+
{{ event.data.amount ? formatEventAmount(event.data.amount) : 0 }}
357+
</Text>
348358

349359
<Text size="12" weight="500" color="secondary">from</Text>
350360

@@ -365,7 +375,7 @@ watch(
365375
<Text size="12" weight="500" color="secondary">Commission</Text>
366376

367377
<Text size="12" weight="500" color="primary" mono no-wrap>
368-
{{ tia(event.data.amount.replace("utia", "")) }} TIA
378+
{{ event.data.amount ? formatEventAmount(event.data.amount) : 0 }}
369379
</Text>
370380
</Flex>
371381
<!-- Event: proposer_reward -->
@@ -387,7 +397,7 @@ watch(
387397
<Text size="12" weight="500" color="secondary">received rewards</Text>
388398

389399
<Text size="12" weight="500" color="primary" mono no-wrap>
390-
{{ event.data.amount ? tia(event.data.amount.replace("utia", "")) : 0 }} TIA
400+
{{ event.data.amount ? formatEventAmount(event.data.amount) : 0 }}
391401
</Text>
392402
</Flex>
393403
<!-- Event: rewards -->
@@ -409,7 +419,7 @@ watch(
409419
<Text size="12" weight="500" color="secondary">received rewards</Text>
410420

411421
<Text size="12" weight="500" color="primary" mono no-wrap>
412-
{{ event.data.amount ? tia(event.data.amount.replace("utia", "")) : 0 }} TIA
422+
{{ event.data.amount ? formatEventAmount(event.data.amount) : 0 }}
413423
</Text>
414424
</Flex>
415425
<!-- Event: commission -->
@@ -429,7 +439,7 @@ watch(
429439
<Text size="12" weight="500" color="secondary">received commission of</Text>
430440

431441
<Text size="12" weight="500" color="primary" mono no-wrap>
432-
{{ event.data.amount ? tia(event.data.amount.replace("utia", "")) : 0 }} TIA
442+
{{ event.data.amount ? formatEventAmount(event.data.amount) : 0 }}
433443
</Text>
434444
</Flex>
435445
<!-- Event: coinbase -->
@@ -449,30 +459,30 @@ watch(
449459
<Text size="12" weight="500" color="secondary">received</Text>
450460

451461
<Text size="12" weight="500" color="primary" mono no-wrap>
452-
{{ event.data.amount ? tia(event.data.amount.replace("utia", "")) : 0 }} TIA
462+
{{ event.data.amount ? formatEventAmount(event.data.amount) : 0 }}
453463
</Text>
454464
</Flex>
455465
<!-- Event: mint -->
456466
<Flex v-else-if="event.type === 'mint'" align="center" gap="4" color="secondary" :class="$style.text">
457467
<Text size="12" weight="500" color="primary" mono no-wrap>
458-
{{ event.data.amount ? tia(event.data.amount.replace("utia", "")) : 0 }} TIA</Text
459-
>
468+
{{ event.data.amount ? formatEventAmount(event.data.amount) : 0 }}
469+
</Text>
460470

461471
<Text size="12" weight="500" color="secondary">was minted</Text>
462472
</Flex>
463473
<!-- Event: burn -->
464474
<Flex v-else-if="event.type === 'burn'" align="center" gap="4" color="secondary" :class="$style.text">
465475
<Text size="12" weight="500" color="primary" mono no-wrap>
466-
{{ event.data.amount ? tia(event.data.amount.replace("utia", "")) : 0 }} TIA</Text
467-
>
476+
{{ event.data.amount ? formatEventAmount(event.data.amount) : 0 }}
477+
</Text>
468478

469479
<Text size="12" weight="500" color="secondary">was burned</Text>
470480
</Flex>
471481
<!-- Event: unbond -->
472482
<Flex v-else-if="event.type === 'unbond'" align="center" gap="4" color="secondary" :class="$style.text">
473483
<Text size="12" weight="500" color="primary" mono no-wrap>
474-
{{ event.data.amount ? tia(event.data.amount.replace("utia", "")) : 0 }} TIA</Text
475-
>
484+
{{ event.data.amount ? formatEventAmount(event.data.amount) : 0 }}
485+
</Text>
476486

477487
<Text size="12" weight="500" color="secondary">will unbond from</Text>
478488

@@ -503,8 +513,8 @@ watch(
503513
<!-- Event: redelegate -->
504514
<Flex v-else-if="event.type === 'redelegate'" align="center" gap="4" color="secondary" :class="$style.text">
505515
<Text size="12" weight="500" color="primary" mono no-wrap>
506-
{{ event.data.amount ? tia(event.data.amount.replace("utia", "")) : 0 }} TIA</Text
507-
>
516+
{{ event.data.amount ? formatEventAmount(event.data.amount) : 0 }}
517+
</Text>
508518

509519
<Text size="12" weight="500" color="secondary">will redelegate from</Text>
510520

@@ -549,8 +559,8 @@ watch(
549559
<!-- Event: complete_unbonding -->
550560
<Flex v-else-if="event.type === 'complete_unbonding'" align="center" gap="4" color="secondary" :class="$style.text">
551561
<Text size="12" weight="500" color="primary" mono no-wrap>
552-
{{ event.data.amount ? tia(event.data.amount.replace("utia", "")) : 0 }} TIA</Text
553-
>
562+
{{ event.data.amount ? formatEventAmount(event.data.amount) : 0 }}
563+
</Text>
554564

555565
<Text size="12" weight="500" color="secondary">was unbonded from</Text>
556566

@@ -583,8 +593,8 @@ watch(
583593
<!-- Event: complete_redelegation -->
584594
<Flex v-else-if="event.type === 'complete_redelegation'" align="center" gap="4" color="secondary" :class="$style.text">
585595
<Text size="12" weight="500" color="primary" mono no-wrap>
586-
{{ event.data.amount ? tia(event.data.amount.replace("utia", "")) : 0 }} TIA</Text
587-
>
596+
{{ event.data.amount ? formatEventAmount(event.data.amount) : 0 }}
597+
</Text>
588598

589599
<Text size="12" weight="500" color="secondary">was redelegated from</Text>
590600

@@ -651,8 +661,8 @@ watch(
651661
<Text size="12" weight="500" color="secondary">Unbonding</Text>
652662

653663
<Text size="12" weight="500" color="primary" mono no-wrap>
654-
{{ event.data.amount ? tia(event.data.amount.replace("utia", "")) : 0 }} TIA</Text
655-
>
664+
{{ event.data.amount ? formatEventAmount(event.data.amount) : 0 }}
665+
</Text>
656666

657667
<Text size="12" weight="500" color="secondary">from</Text>
658668

@@ -806,7 +816,7 @@ watch(
806816
</Flex>
807817

808818
<Flex v-else direction="column" align="center" justify="center" gap="8" :class="$style.empty">
809-
<Text size="13" weight="600" color="secondary" align="center"> No events </Text>
819+
<Text size="13" weight="600" color="secondary" align="center"> No events</Text>
810820
<Text size="12" weight="500" height="160" color="tertiary" align="center" style="max-width: 220px">
811821
This block does not contain any events
812822
</Text>
@@ -822,7 +832,7 @@ watch(
822832
</Button>
823833

824834
<Button type="secondary" size="mini" disabled>
825-
<Text size="12" weight="600" color="primary"> {{ page }} of {{ pages }} </Text>
835+
<Text size="12" weight="600" color="primary"> {{ page }} of {{ pages }}</Text>
826836
</Button>
827837

828838
<Button @click="handleNext" type="secondary" size="mini" :disabled="page === pages">

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"nuxt": "3.16.2",
2525
"nuxt-og-image": "5.1.3",
2626
"oxlint": "^1.0.0",
27+
"prettier": "^3.8.1",
2728
"sass": "1.66.1",
2829
"sass-loader": "13.3.2",
2930
"unenv": "^1.9.0",

0 commit comments

Comments
 (0)