Skip to content

Commit

Permalink
Added DOTphin asset for profile output (#1907)
Browse files Browse the repository at this point in the history
  • Loading branch information
smakhtin authored Oct 22, 2024
1 parent 45d3671 commit a564c07
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
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

0 comments on commit a564c07

Please sign in to comment.