Skip to content

Commit

Permalink
Merge branch 'main' into issue-8890-1
Browse files Browse the repository at this point in the history
  • Loading branch information
hassnian authored Nov 28, 2024
2 parents e9386cf + 1d9b58c commit 2a155d9
Show file tree
Hide file tree
Showing 55 changed files with 973 additions and 555 deletions.
19 changes: 7 additions & 12 deletions components/collection/activity/Activity.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
:class="{ 'my-7': !isBreadCrumbsShowing }"
>
<Events
:events="sortedEventsWithOffersDesc"
:events="filteredEvents"
:loading="loading"
/>
</div>
Expand Down Expand Up @@ -72,7 +72,7 @@ const isBreadCrumbsShowing = computed(
const collectionId = computed(() => route.params.id.toString())
const { events, flippers, owners, offers, loading } = useCollectionActivity({
const { events, flippers, owners, loading } = useCollectionActivity({
collectionId,
})
Expand All @@ -83,17 +83,12 @@ const InteractionIncluded = [
Interaction.SEND,
]
const filteredEvents = computed(() =>
events.value.filter(event =>
InteractionIncluded.includes(event.interaction as Interaction),
),
)
const withOffers = computed(() => [...filteredEvents.value, ...offers.value])
// newest events first (bigger timestamp first)
const sortedEventsWithOffersDesc = computed(() =>
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
withOffers.value.sort((a, b) => b.timestamp - a.timestamp),
const filteredEvents = computed(() =>
events.value
.filter(event =>
InteractionIncluded.includes(event.interaction as Interaction),
).sort((a, b) => b.timestamp - a.timestamp),
)
useResizeObserver(wrapper, (entry) => {
Expand Down
7 changes: 2 additions & 5 deletions components/collection/activity/events/EventRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@
<script setup lang="ts">
import EventRowDesktop from './eventRow/EventRowDesktop.vue'
import EventRowTablet from './eventRow/EventRowTablet.vue'
import type {
InteractionWithNFT,
Offer,
} from '@/composables/collectionActivity/types'
import type { InteractionWithNFT } from '@/composables/collectionActivity/types'
defineProps<{
event: InteractionWithNFT | Offer
event: InteractionWithNFT
variant: 'Touch' | 'Desktop'
}>()
</script>
12 changes: 3 additions & 9 deletions components/collection/activity/events/Events.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,13 @@ import { isAnyActivityFilterActive, isAnyEventTypeFilterActive } from '../utils'
import EventRow from './EventRow.vue'
import { blank, getFromAddress, getToAddress } from './eventRow/common'
import { mintInteraction } from '@/composables/collectionActivity/helpers'
import type {
InteractionWithNFT,
Offer } from '@/composables/collectionActivity/types'
import {
OfferInteraction,
} from '@/composables/collectionActivity/types'
import type { InteractionWithNFT } from '@/composables/collectionActivity/types'
import ResponsiveTable from '@/components/shared/ResponsiveTable.vue'
import { toSubstrateAddress } from '@/services/profile'
const props = withDefaults(
defineProps<{
events: (InteractionWithNFT | Offer)[]
events: InteractionWithNFT[]
loading: boolean
}>(),
{
Expand Down Expand Up @@ -92,7 +87,6 @@ const filteredEvents = computed(() => {
[mintInteraction()]: is(query?.mint as string),
[Interaction.LIST]: is(query?.listing as string),
[Interaction.SEND]: is(query?.transfer as string),
[OfferInteraction]: is(query?.offer as string),
}
const identityIds = profiles.value?.map(profile => profile?.address) || []
Expand Down Expand Up @@ -127,7 +121,7 @@ const eventsAddresses = computed(() => {
const { data: profiles } = useProfiles('profiles', eventsAddresses, { staleTime: 1000 * 60 * 5 })
const displayedEvents = ref<(InteractionWithNFT | Offer)[]>([])
const displayedEvents = ref<InteractionWithNFT[]>([])
const displayMoreEvents = () => {
offset.value += 10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,15 @@ import {
interactionNameMap,
} from './common'
import EventTag from './EventTag.vue'
import type {
InteractionWithNFT,
Offer,
} from '@/composables/collectionActivity/types'
import type { InteractionWithNFT } from '@/composables/collectionActivity/types'
import CommonTokenMoney from '@/components/shared/CommonTokenMoney.vue'
import IdentityIndex from '@/components/identity/IdentityIndex.vue'
const NuxtImg = resolveComponent('NuxtImg')
const { urlPrefix } = usePrefix()
const props = defineProps<{
event: InteractionWithNFT | Offer
event: InteractionWithNFT
}>()
const avatar = ref<string>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,14 @@ import {
getToAddress,
interactionNameMap,
} from './common'
import type {
InteractionWithNFT,
Offer,
} from '@/composables/collectionActivity/types'
import type { InteractionWithNFT } from '@/composables/collectionActivity/types'
import IdentityIndex from '@/components/identity/IdentityIndex.vue'
const NuxtImg = resolveComponent('NuxtImg')
const { urlPrefix } = usePrefix()
const props = defineProps<{
event: InteractionWithNFT | Offer
event: InteractionWithNFT
}>()
const avatar = ref<string>()
Expand Down
25 changes: 12 additions & 13 deletions components/collection/activity/events/eventRow/common.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { Interaction } from '@kodadot1/minimark/v1'
import type {
InteractionWithNFT,
Offer } from '@/composables/collectionActivity/types'
import {
OfferInteraction,
type InteractionWithNFT,
TradeInteraction,
} from '@/composables/collectionActivity/types'
import { parseNftAvatar } from '@/utils/nft'
import { mintInteraction } from '@/composables/collectionActivity/helpers'
Expand All @@ -25,6 +23,8 @@ export const interactionNameMap = ({
MINT: 'Mint',
SEND: 'Transfer',
Offer: 'Offer',
[TradeInteraction.OFFER]: 'Offer',
[TradeInteraction.SWAP]: 'Swap',
}

if (distinguishBuyAndSell) {
Expand All @@ -44,43 +44,42 @@ export const getInteractionColor = (
[mintInteraction()]: 'bg-k-yellow',
[Interaction.LIST]: 'bg-k-blue-accent',
[Interaction.BUY]: distinguishBuyAndSell ? buyColor : sellColor,
[OfferInteraction]: 'bg-k-green-accent',
[Interaction.SEND]: 'bg-background-color',
[TradeInteraction.OFFER]: 'bg-k-green-accent',
[TradeInteraction.SWAP]: 'bg-k-green-accent',
SELL: sellColor,
}[interaction]
}

export const getAmount = (
event: InteractionWithNFT | Offer,
event: InteractionWithNFT,
): string | number => {
switch (event.interaction) {
case mintInteraction():
return blank
case Interaction.LIST:
case Interaction.BUY:
return (event as InteractionWithNFT).meta
case OfferInteraction:
return (event as Offer).price
default:
return blank
}
}

export const getFromAddress = (event: InteractionWithNFT | Offer): string => {
export const getFromAddress = (event: InteractionWithNFT): string => {
const interaction = event.interaction
if (interaction === mintInteraction()) {
return blank
}
if (interaction === Interaction.BUY || interaction === Interaction.SEND) {
return (event as InteractionWithNFT).currentOwner
}
if (interaction === OfferInteraction || interaction === Interaction.LIST) {
return (event as Offer).caller
if (interaction === Interaction.LIST) {
return event.caller
}
return blank
}

export const getToAddress = (event: InteractionWithNFT | Offer): string => {
export const getToAddress = (event: InteractionWithNFT): string => {
const interaction = event.interaction
if (interaction === mintInteraction() || interaction === Interaction.BUY) {
return event.caller
Expand All @@ -91,5 +90,5 @@ export const getToAddress = (event: InteractionWithNFT | Offer): string => {
return blank
}
export const getNFTAvatar = (
event: InteractionWithNFT | Offer,
event: InteractionWithNFT,
): Promise<string> => parseNftAvatar(event.nft)
2 changes: 1 addition & 1 deletion components/common/CartItemDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<script setup lang="ts">
import { parseNftAvatar } from '@/utils/nft'
import type { ListCartItem } from '@/stores/listingCart'
import type { MakingOfferItem } from '@/components/offer/types'
import type { MakingOfferItem } from '@/components/trade/types'
import BasicImage from '@/components/shared/view/BasicImage.vue'
import { sanitizeIpfsUrl } from '@/utils/ipfs'
Expand Down
2 changes: 1 addition & 1 deletion components/common/shoppingCart/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useFiatStore } from '@/stores/fiat'
import { sum } from '@/utils/math'
import type { NFT, TokenId } from '@/types'
import { chainPropListOf } from '@/utils/config/chain.config'
import type { MakingOfferItem } from '@/components/offer/types'
import type { MakingOfferItem } from '@/components/trade/types'

export const prefixToToken = {
ahk: 'KSM',
Expand Down
3 changes: 1 addition & 2 deletions components/create/Confirm/MintConfirmModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ import { CreateComponent } from '@/composables/useCreate'
import { useFiatStore } from '@/stores/fiat'
import { usePreferencesStore } from '@/stores/preferences'
import { availablePrefixes } from '@/utils/chain'
import { getTransitionFee } from '@/utils/transactionExecutor'
import { calculateBalanceUsdValue } from '@/utils/format/balance'
import { BASE_FEE } from '@/utils/support'
import type { AutoTeleportAction } from '@/composables/autoTeleport/types'
Expand Down Expand Up @@ -183,7 +182,7 @@ const confirm = (params) => {
watchEffect(async () => {
networkFee.value = 0
const fee = await getTransitionFee(accountId.value, [''], decimals.value)
const fee = await estimateTransactionFee(accountId.value, decimals.value)
networkFee.value = props.nftInformation.listForSale
? Number(fee) * 2
: Number(fee)
Expand Down
2 changes: 1 addition & 1 deletion components/create/CreateCollection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ const submitButtonLabel = computed(() => {
? $i18n.t('mint.nft.connect')
: canDeposit.value
? $i18n.t('mint.collection.create')
: $i18n.t('confirmPurchase.notEnoughFuns')
: $i18n.t('confirmPurchase.notEnoughFunds')
})
const currentChain = computed(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class="w-[calc(10rem+55px)]"
@click="onMakeOfferClick"
/>
<MakeOffer />
<TradeMakeOfferModal />
</div>
</GalleryItemPriceSection>
</template>
Expand All @@ -24,7 +24,6 @@ import type { NFT } from '@/types'
import { nftToOfferItem } from '@/components/common/shoppingCart/utils'
import { usePreferencesStore } from '@/stores/preferences'
import { useMakingOfferStore } from '@/stores/makeOffer'
import MakeOffer from '@/components/offer/MakeOffer.vue'
import GalleryItemPriceSection from '@/components/gallery/GalleryItemAction/GalleryItemActionSection.vue'
import type { NFTOffer } from '@/composables/useNft'
import { doAfterCheckCurrentChainVM } from '@/components/common/ConnectWallet/openReconnectWalletModal'
Expand Down
6 changes: 4 additions & 2 deletions components/gallery/GalleryItemTabsPanel/GalleryItemOffers.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<template>
<div class="h-full flex flex-col">
<GalleryItemOffersTable
<GalleryItemTradesTable
:nft-id="nftId"
:type="TradeType.OFFER"
/>
</div>
</template>

<script setup lang="ts">
import GalleryItemOffersTable from './GalleryItemOffersTable.vue'
import GalleryItemTradesTable from './GalleryItemTradesTable.vue'
import { TradeType } from '@/composables/useTrades'
defineProps<{
nftId: string
Expand Down
17 changes: 17 additions & 0 deletions components/gallery/GalleryItemTabsPanel/GalleryItemSwaps.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<div class="h-full flex flex-col">
<GalleryItemTradesTable
:nft-id="nftId"
:type="TradeType.SWAP"
/>
</div>
</template>

<script setup lang="ts">
import GalleryItemTradesTable from './GalleryItemTradesTable.vue'
import { TradeType } from '@/composables/useTrades'
defineProps<{
nftId: string
}>()
</script>
16 changes: 15 additions & 1 deletion components/gallery/GalleryItemTabsPanel/GalleryItemTabsPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,22 @@
/>
</NeoTabItem>
<!-- chart -->
<!-- swaps -->
<NeoTabItem
v-if="offerVisible(urlPrefix)"
value="3"
:label="$t('swaps')"
data-testid="offers-activity"
>
<GalleryItemSwaps
v-if="nft?.id"
:nft-id="nft.id"
/>
</NeoTabItem>
<!-- chart -->
<NeoTabItem
value="4"
:label="$t('tabs.chart')"
class="p-5"
>
Expand All @@ -46,6 +59,7 @@
import { NeoTabItem, NeoTabs } from '@kodadot1/brick'
import GalleryItemActivity from './GalleryItemActivity.vue'
import GalleryItemOffers from './GalleryItemOffers.vue'
import GalleryItemSwaps from './GalleryItemSwaps.vue'
import GalleryItemChart from './GalleryItemChart.vue'
import { offerVisible } from '@/utils/config/permission.config'
Expand Down
Loading

0 comments on commit 2a155d9

Please sign in to comment.