fix: show collection creator and info when ODA fails#846
fix: show collection creator and info when ODA fails#846
Conversation
- Collection page: catch ODA fetch so page still loads with drops; use chainSpec for route validate - useToken: fallback to genart then on-chain Nfts.Collection for collection creator when ODA fails - GalleryDetails: always show collection info block and creator (fallback to – when unknown) - CollectionHeader: fetch collection owner from chain when ODA/drops fail; narrow chain prop to AssetHubChain Made-with: Cursor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
🚅 Deployed to the app-pr-846 environment in chaotic-art-preview
|
📝 WalkthroughWalkthroughThe PR adds fallback mechanisms to resolve collection owners and creators by querying blockchain data when direct props are unavailable. Template rendering improvements use optional chaining for safer null handling, and collection fetching now includes error recovery with graceful degradation. Changes
Sequence Diagram(s)sequenceDiagram
participant CH as CollectionHeader
participant LC as Lifecycle
participant SDK as App SDK
participant BC as Blockchain<br/>(AssetHubChain)
CH->>LC: onMounted triggered
activate LC
alt ownerFromProps exists
LC->>CH: use ownerFromProps
else ownerFromProps missing
LC->>SDK: query Collection.getValue(collectionId)
activate SDK
SDK->>BC: fetch collection metadata
activate BC
BC-->>SDK: owner data
deactivate BC
SDK-->>LC: owner resolved
deactivate SDK
LC->>CH: store in ownerFromChain
end
deactivate LC
CH->>CH: ownerAddress = ownerFromProps || ownerFromChain
sequenceDiagram
participant UT as useToken<br/>Composable
participant API as /api/genart/list
participant SDK as App SDK
participant BC as Blockchain
UT->>UT: collectionCreator missing?
alt creator missing
UT->>API: fetch genart list
activate API
API-->>UT: data or error
deactivate API
alt creator found in API response
UT->>UT: use first creator
else creator still missing
UT->>SDK: Nfts.Collection.getValue
activate SDK
SDK->>BC: query on-chain
activate BC
BC-->>SDK: owner field
deactivate BC
SDK-->>UT: owner data
deactivate SDK
UT->>UT: use owner as creator
end
else creator exists
UT->>UT: use existing creator
end
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly Related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Deploying app with
|
| Latest commit: |
2e6e098
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://7a16b266.app-bzd.pages.dev |
| Branch Preview URL: | https://fix-collection-creator-when.app-bzd.pages.dev |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
app/composables/useToken.ts (1)
81-96: Consider extracting owner resolution into a shared utility.This fallback logic (genart → on-chain) is duplicated in
CollectionHeader.vue(lines 45-64). Both implementations:
- Check genart API for creator
- Fall back to
api.query.Nfts.Collection.getValue()for on-chain owner♻️ Suggested extraction
Create a shared utility in
~/composables/useCollectionOwner.ts:export async function resolveCollectionOwner( chain: AssetHubChain, collectionId: string | number, $sdk: ReturnType<typeof useNuxtApp>['$sdk'], ): Promise<string | null> { // Try genart first const [genartOk, _, genartRes] = await t($fetch<{ data: Array<{ creator?: string }> }>('/api/genart/list', { query: { collection: collectionId.toString() }, })) if (genartOk && genartRes?.data?.[0]?.creator) { return genartRes.data[0].creator } // Fall back to on-chain const { api } = $sdk(chain) const collection = await api.query.Nfts.Collection.getValue(Number(collectionId)).catch(() => null) return collection?.owner?.toString() ?? null }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/composables/useToken.ts` around lines 81 - 96, Extract the duplicated genart → on-chain owner resolution into a shared composable (e.g., create resolveCollectionOwner in useCollectionOwner.ts) and replace the logic in useToken.ts (the block that queries /api/genart/list and api.query.Nfts.Collection.getValue) with a call to that utility; the utility should accept (chain, collectionId, $sdk), try the genart fetch first and return genartRes.data[0].creator if present, otherwise call $sdk(chain).api.query.Nfts.Collection.getValue(...) and return collection.owner?.toString() or null, and update CollectionHeader.vue to use the same function to remove duplication.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@app/pages/`[chain]/collection/[collection_id].vue:
- Around line 173-177: The page meta validate function currently allows any
chain in chainSpec but the page code casts route.params.chain to AssetHubChain
and renders CollectionHeader which requires the Nfts pallet; change the
validation used in definePageMeta.validate to call and return
isAssetHubChain(route.params.chain) (the same predicate used in the studio page)
so only AssetHubChain values are accepted, ensuring the cast to AssetHubChain
and the CollectionHeader usage are safe; update any imports to include
isAssetHubChain where validate is defined.
---
Nitpick comments:
In `@app/composables/useToken.ts`:
- Around line 81-96: Extract the duplicated genart → on-chain owner resolution
into a shared composable (e.g., create resolveCollectionOwner in
useCollectionOwner.ts) and replace the logic in useToken.ts (the block that
queries /api/genart/list and api.query.Nfts.Collection.getValue) with a call to
that utility; the utility should accept (chain, collectionId, $sdk), try the
genart fetch first and return genartRes.data[0].creator if present, otherwise
call $sdk(chain).api.query.Nfts.Collection.getValue(...) and return
collection.owner?.toString() or null, and update CollectionHeader.vue to use the
same function to remove duplication.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: fbe964af-a4dd-4aab-8bc8-e8cd9b7fc5f1
📒 Files selected for processing (4)
app/components/collection/CollectionHeader.vueapp/components/gallery/GalleryDetails.vueapp/composables/useToken.tsapp/pages/[chain]/collection/[collection_id].vue
|
@hassnian This PR only fixes the frontend part, because the collection (831) metadata was invalid
|

Fixes #844
Summary
When the ODA collection API errors (e.g. issue #844), the collection and gallery detail pages should still show collection creator and collection information by falling back to other sources.
Changes
Collection page (
[chain]/collection/[collection_id])collectionisnullwhen ODA fails.chainSpecfor routevalidateinstead of@kodadot1/staticCHAINS.Gallery detail (useToken + GalleryDetails)
/api/genart/listby collection) for creator; if still missing, query on-chainNfts.Collectionfor owner socollectionCreatoris set.Collection page header (CollectionHeader)
creatorandcollection.ownerare both missing, fetch collection owner from chain (api.query.Nfts.Collection) inonMountedso creator + Subscan button still appear.chainprop type toAssetHubChainsoapi.query.Nftsis type-safe (relay chains have no Nfts pallet).