mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-06-14 14:51:01 +00:00
fix(tiki): fetch roleNFTs from blockchain instead of returning empty array
- getAllTikiNFTDetails now calls fetchUserTikiNFTs to query UserTikis storage - This enables proper authorization check for government roles like Serok
This commit is contained in:
+9
-4
@@ -549,14 +549,19 @@ export const getAllTikiNFTDetails = async (
|
|||||||
totalNFTs: number;
|
totalNFTs: number;
|
||||||
}> => {
|
}> => {
|
||||||
try {
|
try {
|
||||||
// Only fetch citizen NFT because it's the only one with stored item ID
|
// Fetch citizen NFT details (has stored item ID in CitizenNft storage)
|
||||||
// Role assignments in UserTikis don't have associated NFT item IDs
|
|
||||||
const citizenNFT = await getCitizenNFTDetails(api, address);
|
const citizenNFT = await getCitizenNFTDetails(api, address);
|
||||||
|
|
||||||
|
// Fetch all role tikis from UserTikis storage on blockchain
|
||||||
|
const allRoleNFTs = await fetchUserTikiNFTs(api, address);
|
||||||
|
|
||||||
|
// Filter out Welati since it's represented by citizenNFT
|
||||||
|
const roleNFTs = allRoleNFTs.filter(nft => nft.tikiRole !== 'Welati');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
citizenNFT,
|
citizenNFT,
|
||||||
roleNFTs: [], // Don't show role NFTs because UserTikis doesn't store item IDs
|
roleNFTs,
|
||||||
totalNFTs: citizenNFT ? 1 : 0
|
totalNFTs: (citizenNFT ? 1 : 0) + roleNFTs.length
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user