diff --git a/apps/verification-portal/src/lib/features/DOTphin.ts b/apps/verification-portal/src/lib/features/DOTphin.ts index d9442c555..47d6342e9 100644 --- a/apps/verification-portal/src/lib/features/DOTphin.ts +++ b/apps/verification-portal/src/lib/features/DOTphin.ts @@ -41,6 +41,10 @@ export async function updateMultipassStateForAddress(address: string) { DID: data.dotphinDID, pending: false, }, + evolution: { + level: data.dotphin ? getLevelAttributeValue(data.dotphin) : 0, + maxLevel: data.dotphinMaxLevel, + }, }); if (data.dotphinDID) { @@ -121,7 +125,13 @@ async function fetchNFTDataByDID(did: string) { console.error('Error fetching NFT data:', error); } } - +// Get Level Attribute Value +function getLevelAttributeValue(asset: DeepAsset): number { + const levelAttribute = asset.attributes?.find( + (attr) => attr.trait_type === 'level' + ); + return levelAttribute ? Number(levelAttribute.value) : 0; +} // Find Proof by Trait Type function findProofByTraitType( proofs: DeepAsset[], @@ -192,6 +202,7 @@ export async function evolveDOTphinNFT( }, nft: { DID: dotphinDID, data: evolveData, pending: true }, evolution: { + ...currentState.evolution, level: currentState.evolution.level + 1, }, }); diff --git a/apps/verification-portal/src/lib/features/MultipassStates.ts b/apps/verification-portal/src/lib/features/MultipassStates.ts index 3a4166794..36817e9d0 100644 --- a/apps/verification-portal/src/lib/features/MultipassStates.ts +++ b/apps/verification-portal/src/lib/features/MultipassStates.ts @@ -7,7 +7,6 @@ const canEvolve = isFeatureEnabled('dotphinEvolution'); import { MAX_EVOLUTION_LEVEL, - EVOLUTION_LIMIT, initialStepConfig, STATUS, } from '$lib/shared/multipassConfig'; @@ -39,6 +38,7 @@ export type MultipassData = { }; evolution: { level: number; + maxLevel: number; }; }; @@ -58,6 +58,7 @@ const initialState: MultipassData = { }, evolution: { level: 0, + maxLevel: MAX_EVOLUTION_LEVEL, // set limit same as max }, }; @@ -112,7 +113,9 @@ export const evolveStepState = derived( return 'INITIAL'; } else if ($multipassData.evolution.level >= MAX_EVOLUTION_LEVEL) { return 'COMPLETE'; - } else if ($multipassData.evolution.level >= EVOLUTION_LIMIT) { + } else if ( + $multipassData.evolution.level >= $multipassData.evolution.maxLevel + ) { return 'LIMITED'; } else { return 'EVOLVING'; @@ -159,7 +162,8 @@ export const multipassStepConfig = derived( : proofsStatus === STATUS.COMPLETE && nftStatus === STATUS.COMPLETE ? $multipassData.evolution.level >= MAX_EVOLUTION_LEVEL ? STATUS.COMPLETE - : $multipassData.evolution.level >= EVOLUTION_LIMIT + : $multipassData.evolution.level >= + $multipassData.evolution.maxLevel ? STATUS.LOCKED : STATUS.ACTIVE : STATUS.LOCKED;