Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(beta): 48% of October 2024 Cherry 🍒 #11109

Merged
merged 35 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
d6b23e4
function to trim trailing zeroes
uDaiko Oct 1, 2024
8dcc99d
edge case check for no price value
uDaiko Oct 1, 2024
60ffab6
refactor to minimize lines
uDaiko Oct 2, 2024
88dd3c1
util function to trim trailing zeroes
uDaiko Oct 3, 2024
fc71868
refactor card components to use new util function
uDaiko Oct 3, 2024
30c4f9e
[skip ci] updated code diagram
kkukelka Oct 4, 2024
5ac0103
removed new util function
uDaiko Oct 7, 2024
07aec2e
replaced util function again (reset shenanigans)
uDaiko Oct 7, 2024
3dc9b54
Merge branch 'kodadot:main' into trim_trailing_zeroes
uDaiko Oct 7, 2024
3acbe34
changed composable function to filter falsys
uDaiko Oct 8, 2024
47f65b1
refactored to use round composable directly
uDaiko Oct 8, 2024
9a9f948
Merge branch 'trim_trailing_zeroes' of https://github.com/uDaiko/nft-…
uDaiko Oct 8, 2024
f086fed
Merge pull request #11079 from kodadot/action
vikiival Oct 9, 2024
8a7b9b2
moved formatting code into separate function
uDaiko Oct 10, 2024
d03e197
modified format function for usd amount
uDaiko Oct 10, 2024
e4eb2e2
:label: correct type for attribute
vikiival Oct 12, 2024
70114ec
:bug: attributes should be handled normally
vikiival Oct 12, 2024
b8da1be
:zap: attributes
vikiival Oct 12, 2024
53f38bc
Merge pull request #11098 from kodadot/fix/attributes
vikiival Oct 12, 2024
173ad7b
fix: Open in new tab does not work
Jarsen136 Oct 14, 2024
405b0f7
ref(useAmount.ts): revert to simpler code
hassnian Oct 15, 2024
9214de3
Merge branch 'main' into trim_trailing_zeroes
hassnian Oct 15, 2024
73bc736
fix(useMetaTransaction.ts): long message on cancelled transaction
hassnian Oct 15, 2024
140c4b9
🔧 ImageMedia object-contain
roiLeo Oct 15, 2024
f1f424f
Merge pull request #11104 from Jarsen136/issue-11103
vikiival Oct 15, 2024
e3cdec4
fix(create): collections not reacting to prefix change
hassnian Oct 16, 2024
3febecf
ref(ChooseCollectionDropdown.vue): disable dropdown while loading
hassnian Oct 16, 2024
22b0d32
ref(ChooseCollectionDropdown.vue): reorder code
hassnian Oct 16, 2024
a1d2177
fix(useMassMint.ts): data not loading immediatly
hassnian Oct 16, 2024
649f232
add(ChooseCollectionDropdown.vue): change label when loading
hassnian Oct 16, 2024
07a4eef
Merge pull request #11111 from hassnian/issue-11110
vikiival Oct 16, 2024
bfd2aa3
Merge pull request #11105 from hassnian/issue-11074
vikiival Oct 16, 2024
9309bd4
Merge pull request #11107 from roiLeo/fix/ImageMedia/object-contain
vikiival Oct 16, 2024
33f14b0
Merge branch 'main' into trim_trailing_zeroes
vikiival Oct 16, 2024
e6751b1
Merge pull request #11068 from uDaiko/trim_trailing_zeroes
vikiival Oct 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/diagram.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 10 additions & 8 deletions components/common/ChooseCollectionDropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
},
]"
:no-shadow="noShadow"
:disabled="!isLogIn"
:disabled="disabled"
>
<template #trigger="{ active }">
<NeoButton
v-if="!selectedCollection"
class="dropdown-width"
:no-shadow="noShadow"
:label="$t('massmint.selectCollection')"
:icon="active ? 'chevron-up' : 'chevron-down'"
:label="isLoading ? $t('loading') : $t('massmint.selectCollection')"
:icon="isLoading ? undefined : (active ? 'chevron-up' : 'chevron-down')"
/>
<NeoButton
v-else
Expand Down Expand Up @@ -93,6 +93,7 @@ import {
import type { MintedCollection } from '@/composables/transaction/types'
import { useCollectionForMint } from '@/composables/massmint/useMassMint'

const emit = defineEmits(['selectedCollection'])
const props = defineProps({
fullWidth: { type: Boolean, default: false },
noShadow: { type: Boolean, default: false },
Expand All @@ -101,13 +102,10 @@ const props = defineProps({

const { isLogIn, accountId } = useAuth()

const { collectionsEntites } = useCollectionForMint()
const { collectionsEntites, isLoading } = useCollectionForMint()
const selectedCollection = ref<MintedCollection>()
const emit = defineEmits(['selectedCollection'])

watch(accountId, () => {
selectedCollection.value = undefined
})
const disabled = computed(() => !isLogIn.value || isLoading.value)

const selectCollection = (collection) => {
selectedCollection.value = collection
Expand All @@ -131,6 +129,10 @@ const handleCollectionsChange = (
}
}

watch(accountId, () => {
selectedCollection.value = undefined
})

watch(collectionsEntites, handleCollectionsChange, { immediate: true })
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ import ListingCartPriceInput from '../shared/ListingCartPriceInput.vue'
import CartItemDetails from '@/components/common/CartItemDetails.vue'
import type { ListCartItem } from '@/stores/listingCart'
import { useListingCartStore } from '@/stores/listingCart'
import formatBalance from '@/utils/format/balance'

const { decimals, chainSymbol } = useChain()

Expand All @@ -56,9 +55,7 @@ const props = defineProps<{
nft: ListCartItem
}>()

const floor = computed(() =>
formatBalance(props.nft.collection.floor, decimals.value, chainSymbol.value),
)
const { formatted: floor } = useAmount(computed(() => props.nft.collection.floor || 0), decimals, chainSymbol, { withBlank: true })

const listingCartItem = computed({
get: () => listingCartStore.getItem(props.nft.id)?.listPrice,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import ListingCartFloorPrice from '../shared/ListingCartFloorPrice.vue'
import ListingCartPriceInput from '../shared/ListingCartPriceInput.vue'
import CartItemDetails from '@/components/common/CartItemDetails.vue'
import { useListingCartStore } from '@/stores/listingCart'
import formatBalance from '@/utils/format/balance'

const emit = defineEmits([
'setFixedPrice',
Expand All @@ -65,15 +64,8 @@ const { chainSymbol, decimals } = useChain()

const item = computed(() => listingCartStore.itemsInChain[0])

const itemPrice = computed(() => formatWithBlank(Number(item.value.price)))

const collectionPrice = computed(() =>
formatWithBlank(Number(item.value.collection.floor)),
)

const formatWithBlank = (value: number) => {
return value ? formatBalance(value, decimals.value, chainSymbol.value) : '--'
}
const { formatted: itemPrice } = useAmount(computed(() => (item.value.price || 0)), decimals, chainSymbol, { withBlank: true })
const { formatted: collectionPrice } = useAmount(computed(() => item.value.collection.floor || 0), decimals, chainSymbol, { withBlank: true })

watch(
() => props.fixedPrice,
Expand Down
1 change: 0 additions & 1 deletion components/create/CreateNft.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@

<!-- select collections -->
<NeoField
:key="`collection-${currentChain}`"
ref="chooseCollectionRef"
:label="`${$t('mint.nft.collection.label')} *`"
@click="startSelectedCollection = true"
Expand Down
9 changes: 7 additions & 2 deletions components/gallery/GalleryItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<div class="flex flex-col lg:flex-row">
<div class="w-full lg:w-2/5 lg:pr-7 group">
<div
id="nft-img-container"
:id="CONTAINER_ID"
ref="imgref"
:class="{
'relative': !isFullscreen,
Expand Down Expand Up @@ -41,7 +41,10 @@
:audio-player-cover="image"
/>
</div>
<GalleryItemToolBar @toggle="toggleFullscreen" />
<GalleryItemToolBar
:container-id="CONTAINER_ID"
@toggle="toggleFullscreen"
/>
</div>

<div class="w-full lg:w-3/5 lg:pl-5 py-7">
Expand Down Expand Up @@ -188,6 +191,8 @@ import { sanitizeIpfsUrl, toOriginalContentUrl } from '@/utils/ipfs'
import { convertMarkdownToText } from '@/utils/markdown'
import { generateNftImage } from '@/utils/seoImageGenerator'

const CONTAINER_ID = 'nft-img-container'

const NuxtImg = resolveComponent('NuxtImg')

const { urlPrefix } = usePrefix()
Expand Down
6 changes: 5 additions & 1 deletion components/gallery/GalleryItemToolBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ type ReloadElement =

defineEmits(['toggle'])

const props = defineProps<{
containerId: string
}>()

const { getNft: nft, getNftImage: nftImage, getNftMimeType: nftMimeType, getNftAnimation: nftAnimation, getNftAnimationMimeType: nftAnimationMimeType } = storeToRefs(useNftStore())

const isLoading = ref(false)
Expand Down Expand Up @@ -126,7 +130,7 @@ const handleReloadClick = () => {
}

const openInNewTab = (selector: string, attribute: string = 'src') => {
const element = document.querySelector(selector)
const element = document.querySelector(`#${props.containerId} ${selector}`)
if (element) {
const src = element.getAttribute(attribute)
if (src) {
Expand Down
4 changes: 4 additions & 0 deletions components/massmint/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { OpenSeaAttribute } from '@kodadot1/hyperdata'

export enum Status {
Ok = 'Ok',
Incomplete = 'Incomplete',
Expand All @@ -14,13 +16,15 @@ export type NFT = {
description?: string
price?: number
status?: Status
attributes?: OpenSeaAttribute[]
}

export type NFTToMint = {
name: string
file: File
description?: string
price?: number
attributes?: OpenSeaAttribute[]
}

export type NFTS = { [id: string]: NFT }
13 changes: 3 additions & 10 deletions components/offer/MakingOfferSingleItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
import OfferPriceInput from '@/components/offer/OfferPriceInput.vue'
import OfferExpirationSelector from '@/components/offer/OfferExpirationSelector.vue'
import { useMakingOfferStore } from '@/stores/makeOffer'
import formatBalance from '@/utils/format/balance'
import CartItemDetails from '@/components/common/CartItemDetails.vue'

const emit = defineEmits([
Expand All @@ -73,11 +72,8 @@ const { chainSymbol, decimals } = useChain()

const item = computed(() => offerStore.items[0])

const itemPrice = computed(() => formatWithBlank(Number(item.value.price)))
const { formatted: itemPrice } = useAmount(computed(() => item.value.price), decimals, chainSymbol, { withBlank: true })

const formatWithBlank = (value: number) => {
return value ? formatBalance(value, decimals.value, chainSymbol.value) : '--'
}
const offerPriceStoreItem = computed({
get: () => offerStore.getItem(item.value?.id)?.offerPrice,
set: price => offerStore.updateItem({ id: item.value.id, offerPrice: price }),
Expand All @@ -87,11 +83,8 @@ const offerExpirationStoreItem = computed({
set: v => offerStore.updateItem({ id: item.value.id, offerExpiration: v }),
})

const highestOfferPrice = computed(() => formatWithBlank(Number(item.value.highestOffer) || 0) || '--')

const collectionFloorPrice = computed(() =>
formatWithBlank(Number(item.value.collection.floorPrice?.[0]?.price || '0')) || '--',
)
const { formatted: highestOfferPrice } = useAmount(computed(() => item.value.highestOffer || 0), decimals, chainSymbol, { withBlank: true })
const { formatted: collectionFloorPrice } = useAmount(computed(() => item.value.collection.floorPrice?.[0]?.price || 0), decimals, chainSymbol, { withBlank: true })

watch(
() => props.offerPrice,
Expand Down
2 changes: 1 addition & 1 deletion composables/massmint/massMintHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const createTokensToMint = (
nft.price === undefined ? 0 : nft.price * Math.pow(10, decimals.value),
nsfw: false,
postfix: true,
tags: [],
tags: Array.isArray(nft.attributes) ? nft.attributes : [],
}))
}
export const subscribeToCollectionLengthUpdates = (collectionId: string) => {
Expand Down
2 changes: 2 additions & 0 deletions composables/massmint/parsers/common.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { OpenSeaAttribute } from '@kodadot1/hyperdata'
import { validFormats } from '@/composables/massmint/useZipValidator'

export type Entry = {
Expand All @@ -7,6 +8,7 @@ export type Entry = {
price?: number
valid: boolean
currency?: string
attributes?: OpenSeaAttribute[]
}

export const validFileExtension = (stringWithFileName: string): boolean => {
Expand Down
1 change: 1 addition & 0 deletions composables/massmint/parsers/parseJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export function parseJson(jsonData: string): Record<string, Entry> {
name: item.name || undefined,
description: item.description || undefined,
price: item.price !== undefined ? parseFloat(item.price) : undefined,
attributes: item.attributes || [],
}

if (!entry.file) {
Expand Down
90 changes: 37 additions & 53 deletions composables/massmint/useMassMint.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Interaction } from '@kodadot1/minimark/v1'
import { useQuery } from '@tanstack/vue-query'
import {
createTokensToMint,
subscribeToCollectionLengthUpdates,
} from './massMintHelpers'
import { unwrapSafe } from '@/utils/uniquery'
import resolveQueryPath from '@/utils/queryPathResolver'
import type { NFTToMint } from '@/components/massmint/types'
import { Status } from '@/components/massmint/types'
import type { MintedCollection } from '@/composables/transaction/types'
Expand Down Expand Up @@ -35,64 +35,48 @@ export const statusClass = (status?: Status) => {

export const useCollectionForMint = () => {
const collectionsEntites = ref<MintedCollection[]>()
const collections = ref()
const { $consola } = useNuxtApp()
const { accountId, isLogIn } = useAuth()
const { client, urlPrefix } = usePrefix()

const doFetch = async () => {
if (!isLogIn.value) {
return
}

const query = await resolveQueryPath(urlPrefix.value, 'collectionForMint')
const { data } = await useAsyncQuery({
query: query.default,
variables: {
account: accountId.value,
},
clientId: client.value,
})

const { collectionEntities } = data.value

collections.value = collectionEntities
.map(collection => ({
...collection,
lastIndexUsed: Math.max(
...collection.nfts.map(nft => Number(nft.index)),
),

alreadyMinted: collection.nfts?.length,
totalCount: collection.nfts?.filter(nft => !nft.burned).length,
}))
.filter(
collection =>
(collection.max || Infinity) - collection.alreadyMinted > 0,
)
}

const doFetchWithErrorHandling = () =>
doFetch().catch((error) => {
$consola.error(
`Error fetching collections for account ${accountId.value}:`,
error,
)
})
const { accountId } = useAuth()
const { urlPrefix } = usePrefix()

watch(accountId, doFetchWithErrorHandling, { immediate: true })
const { data, isPending } = useQuery({
queryKey: ['collections-for-mint', accountId, urlPrefix],
queryFn: async () =>
accountId.value
? (await useAsyncGraphql({
query: 'collectionForMint',
variables: {
account: accountId.value,
},
})).data.value
: null,
})

watch(collections, () => {
if (!collections) {
$consola.log(`collections for account ${accountId.value} not found`)
return
watch(data, () => {
const collectionEntities = data.value?.collectionEntities

if (collectionEntities?.length) {
const collections = collectionEntities
.map(collection => ({
...collection,
lastIndexUsed: Math.max(
...collection.nfts.map(nft => Number(nft.index)),
),

alreadyMinted: collection.nfts?.length,
totalCount: collection.nfts?.filter(nft => !nft.burned).length,
}))
.filter(
collection =>
(collection.max || Infinity) - collection.alreadyMinted > 0,
)

collectionsEntites.value = unwrapSafe(collections)
}

collectionsEntites.value = unwrapSafe(collections.value)
})
}, { immediate: true })

return {
collectionsEntites,
isLoading: isPending,
}
}

Expand Down
13 changes: 4 additions & 9 deletions composables/transaction/evm/useMetaTransaction.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Address, TransactionExecutionError } from 'viem'
import { type Address } from 'viem'
import { simulateContract, waitForTransactionReceipt, writeContract } from '@wagmi/core'
import { useChainId, useConfig, useSwitchChain } from '@wagmi/vue'
import type { Abi } from '../types'
Expand Down Expand Up @@ -105,14 +105,9 @@ export default function useEvmMetaTransaction() {
const errorCb
= (onError?: () => void) =>
({ error }) => {
if (error instanceof TransactionExecutionError) {
const isCancelled = error.message.includes('User rejected the request.')
isError.value = !isCancelled

if (isCancelled) {
warningMessage($i18n.t('general.tx.cancelled'), { reportable: false })
status.value = TransactionStatus.Cancelled
}
if (error.message?.includes('User rejected the request.')) {
warningMessage($i18n.t('general.tx.cancelled'), { reportable: false })
status.value = TransactionStatus.Cancelled
}
else {
isError.value = true
Expand Down
4 changes: 2 additions & 2 deletions composables/useAmount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ export default function (
tokenAmount: ComputedRef<number | string | undefined>,
tokenDecimals: ComputedRef<number>,
chainSymbol: ComputedRef<string>,
roundBy?: ComputedRef<Prefix | number>,
{ roundBy, withBlank = false }: { roundBy?: ComputedRef<Prefix | number>, withBlank?: boolean } = {},
) {
const { getCurrentTokenValue } = useFiatStore()

const amountFormatted = computed(() => {
const amount = tokenAmount.value
? formatAmountWithRound(tokenAmount.value, tokenDecimals.value, roundBy?.value)
: 0
return `${amount} ${chainSymbol.value}`
return (!Number(amount) && withBlank) ? '--' : `${amount} ${chainSymbol.value}`
})

const amountUsd = computed(() => {
Expand Down
Loading
Loading