Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions apps/api/src/routes/dotphin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down Expand Up @@ -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
Expand All @@ -400,7 +408,7 @@ app.openapi(
);
}

const dotphinAsset = await getAsset(dotphinDID, c);
const dotphinAsset = await getAsset(dotphinDID);

const proofElement = getProofElement(proofAsset);

Expand Down
8 changes: 3 additions & 5 deletions apps/api/src/routes/dotphin/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -126,10 +125,9 @@ export async function getProofsWithStats(address: string) {
};
}

export async function getAsset(
did: string,
c: Context<AppContext>
): Promise<DeepAsset> {
export async function getAsset(did: string): Promise<DeepAsset> {
const c = getContext<AppContext>();

const assetResponse = await assetsApp.request(
`/${did}`,
{},
Expand Down
2 changes: 2 additions & 0 deletions apps/api/src/routes/dotphin/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down