Skip to content

Commit

Permalink
Merge branch 'main' into issue-11148
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarsen136 authored Jan 21, 2025
2 parents 3b0a555 + 5d9cf5c commit 0001d9b
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 8 deletions.
2 changes: 1 addition & 1 deletion components/TheFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ const menuKodadot: Menu[] = [
{
name: $i18n.t('press kit'),
url: 'https://github.com/kodadot/kodadot-presskit/tree/main/pre-v4',
url: 'https://github.com/kodadot/kodadot-presskit/tree/main/v4',
external: true,
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
class="flex justify-end gallery-item-trade"
>
<NeoButton
data-testid="gallery-item-trade-make-offer"
:label="$t('transaction.offer')"
variant="k-blue"
size="large"
Expand Down
5 changes: 4 additions & 1 deletion components/swap/GridList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
grid-size="medium"
:grid-section="gridSection"
link-target="_blank"
:hide-hover-action="!selectable"
:hide-hover-action="!selectable || stepItems.length === MAX_AMOUNT_OF_SWAP_ITEMS"
>
<template
v-if="surcharge"
Expand All @@ -31,6 +31,8 @@ import { type SwapSurcharge } from '@/composables/transaction/types'
const gridSection = GridSection.PROFILE_GALLERY
const MAX_AMOUNT_OF_SWAP_ITEMS = 1
const props = defineProps<{
query: Record<string, any>
selectable?: boolean
Expand All @@ -40,6 +42,7 @@ const props = defineProps<{
const route = useRoute()
const { replaceUrl } = useReplaceUrl()
const { stepItems } = storeToRefs(useAtomicSwapStore())
const collections = ref(route.query.collections?.toString().split(',').filter(Boolean) || [])
Expand Down
5 changes: 3 additions & 2 deletions composables/drop/massmint/useDropMassMint.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Prefix } from '@kodadot1/static'
import type { ToMintNft } from '@/components/collection/drop/types'
import { generateId, setDyndataUrl } from '@/services/dyndata'
import { generateIdAssethub, setDyndataUrl } from '@/services/dyndata'

export type MassMintNFT = Omit<ToMintNft, 'priceUSD'> & {
image: string
Expand All @@ -18,7 +19,7 @@ export default () => {
const tokenIds = ref<number[]>([])
const populateTokenIds = async () => {
for (const _ of Array.from({ length: amountToMint.value })) {
const tokenId = Number.parseInt(await generateId())
const tokenId = Number.parseInt(await generateIdAssethub(parseInt(drop.value.collection), usePrefix().urlPrefix.value as Prefix))
if (!tokenIds.value.includes(tokenId)) {
tokenIds.value.push(tokenId)
}
Expand Down
2 changes: 1 addition & 1 deletion composables/transaction/mintToken/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export const lastIndexUsed = async (collection: MintedCollection, api) => {
return Math.max(lastIndexUsed, lastOnChainIndex, 0)
}

const getLastIndexUsedOnChain = async (api, collectionId) => {
export const getLastIndexUsedOnChain = async (api, collectionId) => {
const collectionItems = await api.query.nfts.item.entries(collectionId)
const itemIds = collectionItems.map(([key]) => key.args[1].toNumber())
return Math.max(...itemIds)
Expand Down
2 changes: 1 addition & 1 deletion libs/ui/src/components/MediaItem/type/VideoMedia.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
playsinline
loop
:autoplay="autoPlay"
:muted="preview"
muted
:poster="src"
:src="animationSrc || src"
controlslist="nodownload"
Expand Down
2 changes: 1 addition & 1 deletion locales/all_lang.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"href": "https://github.com/kodadot/nft-gallery/issues"
},
"presskit": {
"href": "https://github.com/kodadot/kodadot-presskit/tree/main/v3"
"href": "https://github.com/kodadot/kodadot-presskit/tree/main/v4"
},
"twitter": { "href": "https://twitter.com/kodadot" }
},
Expand Down
28 changes: 28 additions & 0 deletions services/dyndata.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import type { Prefix } from '@kodadot1/static'
import { getLastIndexUsedOnChain } from '@/composables/transaction/mintToken/utils'

const BASE_URL = isProduction
? 'https://dyndata.koda.art'
: 'https://dyndata-beta.koda.art'
Expand All @@ -6,6 +9,31 @@ const api = $fetch.create({
baseURL: BASE_URL,
})

// store latest IDs for each collection
const latestIdsMap = new Map<string, number>()

export const generateIdAssethub = async (collectionId: number, prefix?: Prefix) => {
// 237 is the latest drops collection id to handle backwards compatibility
if (collectionId <= 273 && prefix) {
const mapKey = `${prefix}-${collectionId}`

// Always check the chain for the latest ID
const { apiInstance } = useApi()
const lastIdFromChain = await getLastIndexUsedOnChain(await apiInstance.value, collectionId)
const currentStoredId = latestIdsMap.get(mapKey) || 0

// Use the larger of the two values to ensure we don't create duplicates
const currentId = Math.max(lastIdFromChain, currentStoredId)
const nextId = currentId + 1

// Store the new ID
latestIdsMap.set(mapKey, nextId)
return nextId.toString()
}

return (await api('/generate-id')) as string
}

export const generateId = async () => {
return (await api('/generate-id')) as string
}
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/footer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const footerLinks = [
},
{
linkName: 'Press Kit',
linkAddress: 'https://github.com/kodadot/kodadot-presskit/tree/main/pre-v4',
linkAddress: 'https://github.com/kodadot/kodadot-presskit/tree/main/v4',
},
{
linkName: 'MerchShop',
Expand Down
10 changes: 10 additions & 0 deletions tests/e2e/offer.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { expect, test } from './fixtures'

test('show offer modal', async ({ page, Commands }) => {
await Commands.e2elogin()
await page.goto('/ahp/gallery/256-4235681345')
await page.getByTestId('gallery-item-trade-make-offer').click()

// at least show the offer modal
await expect(page.locator('.modal-card-title')).toHaveText('Create Offer')
})

0 comments on commit 0001d9b

Please sign in to comment.