Skip to content

Commit

Permalink
feat: show contract call arguments in a more approchable way (#486)
Browse files Browse the repository at this point in the history
Co-authored-by: Michele F. <michele-franchi@users.noreply.github.com>
  • Loading branch information
lukeromanowicz and michele-franchi committed Sep 6, 2023
1 parent 54f9fc7 commit 5bc8bee
Show file tree
Hide file tree
Showing 37 changed files with 761 additions and 105 deletions.
6 changes: 5 additions & 1 deletion src/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
</Head>
</Html>

<NuxtErrorBoundary>
<NuxtErrorBoundary @error="logError">
<the-header/>
<NuxtLayout>
<NuxtPage/>
Expand Down Expand Up @@ -103,6 +103,10 @@ if (import.meta.env.MODE !== 'production') {
meta: [{ name: 'robots', content: 'noindex' }],
})
}
function logError(error) {
console.error(error)
}
</script>

<style>
Expand Down
3 changes: 3 additions & 0 deletions src/assets/icons/check.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/assets/icons/copy-simple.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/assets/icons/minus-circle.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/assets/icons/plus-circle.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 54 additions & 0 deletions src/components/ContractEventCell.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<template>
<div class="contract-event-cell">
<Suspense>
<component
:is="contractEventCellComponent"
:event="event"
:contract-details="contractDetails"/>
<template #fallback>
Loading...
</template>
</Suspense>
</div>
</template>

<script setup>
import { defineAsyncComponent } from 'vue'
const props = defineProps({
contractDetails: {
type: Object,
required: true,
},
event: {
type: Object,
required: true,
},
})
const contractEventCellComponent = computed(() =>
defineAsyncComponent(async() => {
try {
return await import(`@/components/ContractEventCell${props.event.eventName}.vue`)
} catch {
console.error(`Unknown event ${props.event.eventName} in contract ${props.contractDetails.id}`)
return defineComponent(() => () => h('span', 'N/A'))
}
},
),
)
</script>

<style scoped>
.contract-event-cell {
display: flex;
justify-content: flex-end;
align-items: center;
gap: var(--space-1);
flex-wrap: wrap;
@media(--desktop) {
justify-content: space-between;
}
}
</style>
44 changes: 44 additions & 0 deletions src/components/ContractEventCellAllowance.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<template>
<value-hash-ellipsed
:hash="eventData[0]"
:link-to="`/accounts/${eventData[0]}`"/>

<transaction-arrow-right-icon/>

<value-hash-ellipsed
:hash="eventData[1]"
:link-to="`/accounts/${eventData[1]}`"/>

<app-chip size="sm">
{{ tokenValue }}
</app-chip>
</template>

<script setup>
import { formatNumber, formatReduceDecimals } from '@/utils/format'
import AppChip from '@/components/AppChip'
import TransactionArrowRightIcon from '@/components/TransactionArrowRightIcon'
import ValueHashEllipsed from '@/components/ValueHashEllipsed'
const props = defineProps({
contractDetails: {
required: true,
type: Object,
},
event: {
required: true,
type: Object,
},
})
const eventData = computed(() => props.event.data)
const tokenValue = computed(() => {
if (!props.contractDetails.tokenDetails || props.contractDetails.contractType === 'AEX-141') {
return eventData.value[2]
}
return formatNumber(
formatReduceDecimals(eventData.value[2], props.contractDetails.tokenDetails.decimals),
) + ` ${props.contractDetails.tokenDetails.symbol}`
})
</script>
40 changes: 40 additions & 0 deletions src/components/ContractEventCellBurn.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<template>
<value-hash-ellipsed
:hash="contractDetails.id"
:link-to="`/contracts/${contractDetails.id}`"/>

<transaction-arrow-right-icon/>

<app-chip size="sm">
{{ tokenValue }}
</app-chip>
</template>

<script setup>
import { formatNumber, formatReduceDecimals } from '@/utils/format'
import AppChip from '@/components/AppChip'
import TransactionArrowRightIcon from '@/components/TransactionArrowRightIcon'
import ValueHashEllipsed from '@/components/ValueHashEllipsed'
const props = defineProps({
contractDetails: {
required: true,
type: Object,
},
event: {
required: true,
type: Object,
},
})
const eventData = computed(() => props.event.data)
const tokenValue = computed(() => {
if (!props.contractDetails.tokenDetails || props.contractDetails.contractType === 'AEX-141') {
return eventData.value[0]
}
return formatNumber(
formatReduceDecimals(eventData.value[0], props.contractDetails.tokenDetails.decimals),
) + ` ${props.contractDetails.tokenDetails.symbol}`
})
</script>
24 changes: 24 additions & 0 deletions src/components/ContractEventCellEditionLimit.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<template>
{{ eventData[0] }}

<transaction-arrow-right-icon/>

{{ eventData[1] }}
</template>

<script setup>
import TransactionArrowRightIcon from '@/components/TransactionArrowRightIcon'
const props = defineProps({
contractDetails: {
required: true,
type: Object,
},
event: {
required: true,
type: Object,
},
})
const eventData = computed(() => props.event.data)
</script>
24 changes: 24 additions & 0 deletions src/components/ContractEventCellEditionLimitDecrease.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<template>
{{ eventData[0] }}

<transaction-arrow-right-icon/>

{{ eventData[1] }}
</template>

<script setup>
import TransactionArrowRightIcon from '@/components/TransactionArrowRightIcon'
const props = defineProps({
contractDetails: {
required: true,
type: Object,
},
event: {
required: true,
type: Object,
},
})
const eventData = computed(() => props.event.data)
</script>
44 changes: 44 additions & 0 deletions src/components/ContractEventCellMint.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<template>
<value-hash-ellipsed
:hash="contractDetails.id"
:link-to="`/contracts/${contractDetails.id}`"/>

<transaction-arrow-right-icon/>

<value-hash-ellipsed
:hash="eventData[0]"
:link-to="`/accounts/${eventData[0]}`"/>

<app-chip size="sm">
{{ tokenValue }}
</app-chip>
</template>

<script setup>
import { formatNumber, formatReduceDecimals } from '@/utils/format'
import AppChip from '@/components/AppChip'
import TransactionArrowRightIcon from '@/components/TransactionArrowRightIcon'
import ValueHashEllipsed from '@/components/ValueHashEllipsed'
const props = defineProps({
contractDetails: {
required: true,
type: Object,
},
event: {
required: true,
type: Object,
},
})
const eventData = computed(() => props.event.data)
const tokenValue = computed(() => {
if (!props.contractDetails.tokenDetails || props.contractDetails.contractType === 'AEX-141') {
return eventData.value[1]
}
return formatNumber(
formatReduceDecimals(eventData.value[1], props.contractDetails.tokenDetails.decimals),
) + ` ${props.contractDetails.tokenDetails.symbol}`
})
</script>
31 changes: 31 additions & 0 deletions src/components/ContractEventCellSwap.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<template>
<value-hash-ellipsed
:hash="eventData[0]"
:link-to="`/accounts/${eventData[0]}`"/>

<transaction-arrow-right-icon/>

<app-chip size="sm">
{{ formatAePrice(formatAettosToAe(eventData[1])) }}
</app-chip>
</template>

<script setup>
import { formatAePrice, formatAettosToAe } from '@/utils/format'
import AppChip from '@/components/AppChip'
import TransactionArrowRightIcon from '@/components/TransactionArrowRightIcon'
import ValueHashEllipsed from '@/components/ValueHashEllipsed'
const props = defineProps({
contractDetails: {
required: true,
type: Object,
},
event: {
required: true,
type: Object,
},
})
const eventData = computed(() => props.event.data)
</script>
18 changes: 18 additions & 0 deletions src/components/ContractEventCellTemplateCreation.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<template>
{{ eventData[0] }}
</template>

<script setup>
const props = defineProps({
contractDetails: {
required: true,
type: Object,
},
event: {
required: true,
type: Object,
},
})
const eventData = computed(() => props.event.data)
</script>
18 changes: 18 additions & 0 deletions src/components/ContractEventCellTemplateDeletion.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<template>
{{ eventData[0] }}
</template>

<script setup>
const props = defineProps({
contractDetails: {
required: true,
type: Object,
},
event: {
required: true,
type: Object,
},
})
const eventData = computed(() => props.event.data)
</script>
18 changes: 18 additions & 0 deletions src/components/ContractEventCellTemplateLimit.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<template>
{{ eventData[0] }}
</template>

<script setup>
const props = defineProps({
contractDetails: {
required: true,
type: Object,
},
event: {
required: true,
type: Object,
},
})
const eventData = computed(() => props.event.data)
</script>
24 changes: 24 additions & 0 deletions src/components/ContractEventCellTemplateLimitDecrease.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<template>
{{ eventData[0] }}

<transaction-arrow-right-icon/>

{{ eventData[1] }}
</template>

<script setup>
import TransactionArrowRightIcon from '@/components/TransactionArrowRightIcon'
const props = defineProps({
contractDetails: {
required: true,
type: Object,
},
event: {
required: true,
type: Object,
},
})
const eventData = computed(() => props.event.data)
</script>

0 comments on commit 5bc8bee

Please sign in to comment.