diff --git a/apps/api/src/routes/dotphin/index.ts b/apps/api/src/routes/dotphin/index.ts index da9025e6b..89cc1d441 100644 --- a/apps/api/src/routes/dotphin/index.ts +++ b/apps/api/src/routes/dotphin/index.ts @@ -83,11 +83,19 @@ app.openapi( DOTPHIN_COLLECTION_ID ); + let dotphinAsset; + + if (dotphinDID) { + dotphinAsset = await getAsset(dotphinDID); + } + return c.json( { address, ...proofsWithStats, dotphinDID, + dotphin: dotphinAsset, + dotphinMaxLevel: MAX_DOTPHIN_LEVEL, }, 200 ); @@ -378,7 +386,7 @@ app.openapi( } //Proof validation - const proofAsset = await getAsset(proofDID, c); + const proofAsset = await getAsset(proofDID); await validateProof(proofAsset, address, c); //Check if user has DOTphin already @@ -400,7 +408,7 @@ app.openapi( ); } - const dotphinAsset = await getAsset(dotphinDID, c); + const dotphinAsset = await getAsset(dotphinDID); const proofElement = getProofElement(proofAsset); diff --git a/apps/api/src/routes/dotphin/lib/index.ts b/apps/api/src/routes/dotphin/lib/index.ts index c315ca196..943bdad3f 100644 --- a/apps/api/src/routes/dotphin/lib/index.ts +++ b/apps/api/src/routes/dotphin/lib/index.ts @@ -2,7 +2,6 @@ import { createAssetDID } from '@sni/address-utils'; import { DeepAsset, ExternalApiError, UniqueNetwork } from '@sni/types'; import { getContext } from 'hono/context-storage'; import { AccountTokensResponseSchema } from '@sni/clients/wallets-client/targets/unique/schemas'; -import { Context } from 'hono'; import walletsApp from '../../wallets'; import assetsApp from '../../assets'; import { @@ -126,10 +125,9 @@ export async function getProofsWithStats(address: string) { }; } -export async function getAsset( - did: string, - c: Context -): Promise { +export async function getAsset(did: string): Promise { + const c = getContext(); + const assetResponse = await assetsApp.request( `/${did}`, {}, diff --git a/apps/api/src/routes/dotphin/schemas.ts b/apps/api/src/routes/dotphin/schemas.ts index e80d4b5e5..489bfb8ad 100644 --- a/apps/api/src/routes/dotphin/schemas.ts +++ b/apps/api/src/routes/dotphin/schemas.ts @@ -85,9 +85,11 @@ export const ProfileResponseSchema = z.object({ }), }), }), + dotphin: DeepAssetSchema.optional(), //TODO: Add example dotphinDID: z.string().nullable().openapi({ example: 'did:asset:eip155:8880.unique2:700:1', //TODO: Update example with real DID }), + dotphinMaxLevel: z.number().openapi({ example: 3 }), }); export const ClaimBodySchema = z.object({