diff --git a/api-schema.graphql b/api-schema.graphql index 12cbd81..d4daccc 100644 --- a/api-schema.graphql +++ b/api-schema.graphql @@ -82,11 +82,14 @@ type AppConfig { } type Claim { + account: String! amount: String! + community: Community communityId: String! createdAt: DateTime id: String! - minter: String! + identity: Identity + minter: TokenGatorMinter name: String! provider: IdentityProvider! providerId: String! @@ -96,9 +99,9 @@ type Claim { } input ClaimAdminCreateInput { + account: String! amount: String communityId: String! - minter: String! provider: IdentityProvider! providerId: String! } @@ -127,17 +130,17 @@ enum ClaimStatus { } input ClaimUserCreateInput { + account: String! amount: String communityId: String! - minter: String! provider: IdentityProvider! providerId: String! } input ClaimUserFindManyInput { + account: String communityId: String! limit: Int = 10 - minter: String page: Int = 1 provider: IdentityProvider providerId: String @@ -204,7 +207,7 @@ scalar DateTime type Identity { challenges: [IdentityChallenge!] - createdAt: DateTime! + createdAt: DateTime expired: Boolean id: String! name: String @@ -212,7 +215,7 @@ type Identity { profile: JSON provider: IdentityProvider! providerId: String! - updatedAt: DateTime! + updatedAt: DateTime url: String verified: Boolean } @@ -430,6 +433,8 @@ type Query { userFindOnePreset(presetId: String!): Preset userFindOneUser(username: String!): User userFindOneWallet(publicKey: String!): Wallet + userGetClaim(claimId: String!): Claim! + userGetClaims: [Claim!]! userGetMinter(account: String!): TokenGatorMinter! userGetMinterAssets(account: String!): JSON! userGetMinters: TokenGatorMinter! diff --git a/libs/api/claim/data-access/src/lib/api-claim-data-user.service.ts b/libs/api/claim/data-access/src/lib/api-claim-data-user.service.ts index 13ffff9..f39c051 100644 --- a/libs/api/claim/data-access/src/lib/api-claim-data-user.service.ts +++ b/libs/api/claim/data-access/src/lib/api-claim-data-user.service.ts @@ -34,4 +34,12 @@ export class ApiClaimDataUserService { async updateClaim(claimId: string, input: ClaimUserUpdateInput) { return this.data.update(claimId, input) } + + async userGetClaims(userId: string) { + return this.data.getClaims(userId) + } + + async userGetClaim(userId: string, claimId: string) { + return this.data.getClaim(userId, claimId) + } } diff --git a/libs/api/claim/data-access/src/lib/api-claim-data.service.ts b/libs/api/claim/data-access/src/lib/api-claim-data.service.ts index aeb2c51..19f2873 100644 --- a/libs/api/claim/data-access/src/lib/api-claim-data.service.ts +++ b/libs/api/claim/data-access/src/lib/api-claim-data.service.ts @@ -1,11 +1,23 @@ -import { Injectable } from '@nestjs/common' -import { ClaimStatus, Prisma } from '@prisma/client' +import { Injectable, Logger } from '@nestjs/common' +import { ClaimStatus, Identity, IdentityProvider, Prisma } from '@prisma/client' import { ApiCoreService, PagingInputFields } from '@tokengator-mint/api-core-data-access' +import { ApiPresetService, TokenGatorMinter } from '@tokengator-mint/api-preset-data-access' +import { LRUCache } from 'lru-cache' import { ClaimPaging } from './entity/claim.entity' @Injectable() export class ApiClaimDataService { - constructor(private readonly core: ApiCoreService) {} + private readonly logger = new Logger(ApiClaimDataService.name) + private readonly minterCache = new LRUCache({ + max: 1000, + ttl: 1000 * 60 * 5, // 5 minutes + fetchMethod: async (account) => { + this.logger.verbose(`minterCache: Cache miss for ${account}`) + return this.preset.minter.getMinter(account) + }, + }) + + constructor(private readonly core: ApiCoreService, private readonly preset: ApiPresetService) {} async create(input: Omit & { amount?: string }) { return this.core.data.claim.create({ @@ -41,4 +53,51 @@ export class ApiClaimDataService { async update(claimId: string, input: Prisma.ClaimUpdateInput) { return this.core.data.claim.update({ where: { id: claimId }, data: input }) } + + async getClaims(userId: string) { + const ids: Map = await this.core.getUserIdentityMap({ userId }) + const OR: Prisma.ClaimWhereInput[] = [] + + for (const provider of ids.keys()) { + const identities = ids.get(provider) + for (const { profile, providerId } of identities || []) { + OR.push({ provider, providerId }) + // This allows for adding claims to a user by their username instead of providerId + const username = (profile as { username?: string })?.username + if (username) { + OR.push({ provider, providerId: username }) + } + } + } + + return this.core.data.claim.findMany({ where: { OR }, include: { community: true } }).then(async (claims) => { + const uniqueMinters = Array.from(new Set(claims.map((claim) => claim.account))) + const minters = await Promise.all([...uniqueMinters.map((minter) => this.minterCache.fetch(minter))]) + + return claims.map((claim) => { + const identity = ids + .get(claim.provider) + ?.find( + ({ profile, providerId }) => + providerId === claim.providerId || (profile as { username?: string })?.username === claim.providerId, + ) + const minter = minters.find((m) => m?.publicKey.toString() === claim.account) + + return { + ...claim, + minter, + identity, + } + }) + }) + } + + async getClaim(userId: string, claimId: string) { + const claims = await this.getClaims(userId) + const found = claims.find((claim) => claim.id === claimId) + if (!found) { + throw new Error('Claim not found') + } + return found + } } diff --git a/libs/api/claim/data-access/src/lib/api-claim.data-access.module.ts b/libs/api/claim/data-access/src/lib/api-claim.data-access.module.ts index e436460..e8aa006 100644 --- a/libs/api/claim/data-access/src/lib/api-claim.data-access.module.ts +++ b/libs/api/claim/data-access/src/lib/api-claim.data-access.module.ts @@ -1,12 +1,13 @@ import { Module } from '@nestjs/common' import { ApiCoreDataAccessModule } from '@tokengator-mint/api-core-data-access' -import { ApiClaimService } from './api-claim.service' -import { ApiClaimDataService } from './api-claim-data.service' +import { ApiPresetDataAccessModule } from '@tokengator-mint/api-preset-data-access' import { ApiClaimDataAdminService } from './api-claim-data-admin.service' import { ApiClaimDataUserService } from './api-claim-data-user.service' +import { ApiClaimDataService } from './api-claim-data.service' +import { ApiClaimService } from './api-claim.service' @Module({ - imports: [ApiCoreDataAccessModule], + imports: [ApiCoreDataAccessModule, ApiPresetDataAccessModule], providers: [ApiClaimService, ApiClaimDataService, ApiClaimDataAdminService, ApiClaimDataUserService], exports: [ApiClaimService], }) diff --git a/libs/api/claim/data-access/src/lib/dto/claim-admin-create.input.ts b/libs/api/claim/data-access/src/lib/dto/claim-admin-create.input.ts index 485bab4..9d49905 100644 --- a/libs/api/claim/data-access/src/lib/dto/claim-admin-create.input.ts +++ b/libs/api/claim/data-access/src/lib/dto/claim-admin-create.input.ts @@ -8,7 +8,7 @@ export class ClaimAdminCreateInput { @Field() communityId!: string @Field() - minter!: string + account!: string @Field(() => IdentityProvider) provider!: IdentityProvider @Field() diff --git a/libs/api/claim/data-access/src/lib/dto/claim-user-create.input.ts b/libs/api/claim/data-access/src/lib/dto/claim-user-create.input.ts index 1e7a1d2..30f141a 100644 --- a/libs/api/claim/data-access/src/lib/dto/claim-user-create.input.ts +++ b/libs/api/claim/data-access/src/lib/dto/claim-user-create.input.ts @@ -8,7 +8,7 @@ export class ClaimUserCreateInput { @Field({ nullable: true }) amount?: string @Field() - minter!: string + account!: string @Field(() => IdentityProvider) provider!: IdentityProvider @Field() diff --git a/libs/api/claim/data-access/src/lib/dto/claim-user-find-many.input.ts b/libs/api/claim/data-access/src/lib/dto/claim-user-find-many.input.ts index f1b7164..18e1b97 100644 --- a/libs/api/claim/data-access/src/lib/dto/claim-user-find-many.input.ts +++ b/libs/api/claim/data-access/src/lib/dto/claim-user-find-many.input.ts @@ -10,7 +10,7 @@ export class ClaimUserFindManyInput extends PagingInput() { @Field({ nullable: true }) search?: string @Field({ nullable: true }) - minter?: string + account?: string @Field(() => IdentityProvider, { nullable: true }) provider?: IdentityProvider @Field({ nullable: true }) diff --git a/libs/api/claim/data-access/src/lib/entity/claim.entity.ts b/libs/api/claim/data-access/src/lib/entity/claim.entity.ts index 8cee374..334c735 100644 --- a/libs/api/claim/data-access/src/lib/entity/claim.entity.ts +++ b/libs/api/claim/data-access/src/lib/entity/claim.entity.ts @@ -1,6 +1,8 @@ import { Field, ObjectType } from '@nestjs/graphql' +import { Community } from '@tokengator-mint/api-community-data-access' import { PagingResponse } from '@tokengator-mint/api-core-data-access' -import { IdentityProvider } from '@tokengator-mint/api-identity-data-access' +import { Identity, IdentityProvider } from '@tokengator-mint/api-identity-data-access' +import { TokenGatorMinter } from '@tokengator-mint/api-preset-data-access' import { ClaimStatus } from './claim-status.enum' @ObjectType() @@ -16,7 +18,7 @@ export class Claim { @Field() communityId!: string @Field() - minter!: string + account!: string @Field({ nullable: true }) signature?: string | null @Field(() => IdentityProvider) @@ -25,6 +27,12 @@ export class Claim { providerId!: string @Field(() => ClaimStatus) status!: ClaimStatus + @Field(() => Community, { nullable: true }) + community?: Community + @Field(() => TokenGatorMinter, { nullable: true }) + minter?: TokenGatorMinter + @Field(() => Identity, { nullable: true }) + identity?: Identity } @ObjectType() diff --git a/libs/api/claim/data-access/src/lib/helpers/get-claim-where-user.input.ts b/libs/api/claim/data-access/src/lib/helpers/get-claim-where-user.input.ts index cebcdce..2a2cf74 100644 --- a/libs/api/claim/data-access/src/lib/helpers/get-claim-where-user.input.ts +++ b/libs/api/claim/data-access/src/lib/helpers/get-claim-where-user.input.ts @@ -4,7 +4,7 @@ import { ClaimUserFindManyInput } from '../dto/claim-user-find-many.input' export function getClaimWhereUserInput(input: ClaimUserFindManyInput): Prisma.ClaimWhereInput { const where: Prisma.ClaimWhereInput = { communityId: input.communityId, - minter: input.minter ?? undefined, + account: input.account ?? undefined, provider: input.provider ?? undefined, providerId: input.providerId ?? undefined, status: input.status ?? undefined, diff --git a/libs/api/claim/feature/src/lib/api-claim-user.resolver.ts b/libs/api/claim/feature/src/lib/api-claim-user.resolver.ts index 9d2f652..a105310 100644 --- a/libs/api/claim/feature/src/lib/api-claim-user.resolver.ts +++ b/libs/api/claim/feature/src/lib/api-claim-user.resolver.ts @@ -1,13 +1,12 @@ -import { Resolver } from '@nestjs/graphql' -import { ApiClaimService } from '@tokengator-mint/api-claim-data-access' -import { ApiAuthGraphQLUserGuard } from '@tokengator-mint/api-auth-data-access' -import { Mutation, Query, Args } from '@nestjs/graphql' import { UseGuards } from '@nestjs/common' +import { Args, Mutation, Query, Resolver } from '@nestjs/graphql' +import { ApiAuthGraphQLUserGuard, CtxUserId } from '@tokengator-mint/api-auth-data-access' import { - ClaimUserCreateInput, - ClaimUserFindManyInput, + ApiClaimService, Claim, ClaimPaging, + ClaimUserCreateInput, + ClaimUserFindManyInput, ClaimUserUpdateInput, } from '@tokengator-mint/api-claim-data-access' @@ -26,6 +25,16 @@ export class ApiClaimUserResolver { return this.service.user.deleteClaim(claimId) } + @Query(() => Claim) + userGetClaim(@CtxUserId() userId: string, @Args('claimId') claimId: string) { + return this.service.user.userGetClaim(userId, claimId) + } + + @Query(() => [Claim]) + userGetClaims(@CtxUserId() userId: string) { + return this.service.user.userGetClaims(userId) + } + @Query(() => ClaimPaging) userFindManyClaim(@Args('input') input: ClaimUserFindManyInput) { return this.service.user.findManyClaim(input) diff --git a/libs/api/claim/feature/src/lib/api-claim.resolver.ts b/libs/api/claim/feature/src/lib/api-claim.resolver.ts index b3e4715..1461c6d 100644 --- a/libs/api/claim/feature/src/lib/api-claim.resolver.ts +++ b/libs/api/claim/feature/src/lib/api-claim.resolver.ts @@ -8,6 +8,11 @@ export class ApiClaimResolver { @ResolveField(() => String) name(@Parent() claim: Claim) { + const communityName = claim.community?.name + const minterName = claim.minter?.name + if (communityName && minterName) { + return `${communityName} - ${minterName}` + } return `${claim.provider}: ${ellipsify(claim.providerId)} ` } } diff --git a/libs/api/community/data-access/src/lib/api-community-provision.service.ts b/libs/api/community/data-access/src/lib/api-community-provision.service.ts index d79ea21..97ae430 100644 --- a/libs/api/community/data-access/src/lib/api-community-provision.service.ts +++ b/libs/api/community/data-access/src/lib/api-community-provision.service.ts @@ -61,7 +61,7 @@ export const provisionCommunities: ProvisionCommunityInput[] = [ { provider: IdentityProvider.Solana, providerId: '81sWMLg1EgYps3nMwyeSW1JfjKgFqkGYPP85vTnkFzRn' }, { provider: IdentityProvider.Solana, providerId: 'BEEMANPx2jdmfR7jpn1hRdMuM2Vj4E3azBLb6RUBrCDY' }, { provider: IdentityProvider.Twitter, providerId: 'beeman_nl' }, - ].map((i) => ({ ...i, minter: '9u6HpBdFd1yZzQ8JszBoSRtcgbvJF5uk5pv7zcvrL3Se' })), + ].map((i) => ({ ...i, account: '9u6HpBdFd1yZzQ8JszBoSRtcgbvJF5uk5pv7zcvrL3Se' })), }, }, { diff --git a/libs/api/core/data-access/src/lib/api-core.service.ts b/libs/api/core/data-access/src/lib/api-core.service.ts index 9c3da58..7e873b8 100644 --- a/libs/api/core/data-access/src/lib/api-core.service.ts +++ b/libs/api/core/data-access/src/lib/api-core.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@nestjs/common' import { EventEmitter2 } from '@nestjs/event-emitter' -import { CommunityMemberRole, IdentityProvider } from '@prisma/client' +import { CommunityMemberRole, Identity, IdentityProvider } from '@prisma/client' import { ApiCorePrismaClient, prismaClient } from './api-core-prisma-client' import { ApiCoreConfigService } from './config/api-core-config.service' import { slugifyId } from './helpers/slugify-id' @@ -33,6 +33,26 @@ export class ApiCoreService { return found } + async getUserIdentityMap({ userId }: { userId: string }): Promise> { + const identities = await this.data.identity.findMany({ + where: { ownerId: userId }, + select: { + id: true, + profile: true, + provider: true, + providerId: true, + name: true, + }, + }) + + return identities.reduce((acc, identity) => { + const { provider } = identity + const existing = acc.get(provider) || [] + acc.set(provider, existing.length ? [...existing, identity] : [identity]) + return acc + }, new Map()) + } + async findUserByIdentity({ provider, providerId }: { provider: IdentityProvider; providerId: string }) { return this.data.identity.findUnique({ where: { provider_providerId: { provider, providerId } }, diff --git a/libs/api/identity/data-access/src/lib/entity/identity.entity.ts b/libs/api/identity/data-access/src/lib/entity/identity.entity.ts index d881884..f0f04ed 100644 --- a/libs/api/identity/data-access/src/lib/entity/identity.entity.ts +++ b/libs/api/identity/data-access/src/lib/entity/identity.entity.ts @@ -8,10 +8,10 @@ import { IdentityProvider } from './identity-provider.enum' export class Identity { @Field() id!: string - @Field() - createdAt!: Date - @Field() - updatedAt!: Date + @Field({ nullable: true }) + createdAt?: Date + @Field({ nullable: true }) + updatedAt?: Date @Field(() => IdentityProvider) provider!: IdentityProvider diff --git a/libs/api/preset/data-access/src/lib/api-preset.service.ts b/libs/api/preset/data-access/src/lib/api-preset.service.ts index 9353287..23e5846 100644 --- a/libs/api/preset/data-access/src/lib/api-preset.service.ts +++ b/libs/api/preset/data-access/src/lib/api-preset.service.ts @@ -2,6 +2,7 @@ import { Injectable } from '@nestjs/common' import { ApiPresetDataAdminService } from './api-preset-data-admin.service' import { ApiPresetDataUserService } from './api-preset-data-user.service' import { ApiPresetDataService } from './api-preset-data.service' +import { ApiPresetMinterService } from './api-preset-minter.service' @Injectable() export class ApiPresetService { @@ -9,5 +10,6 @@ export class ApiPresetService { readonly data: ApiPresetDataService, readonly admin: ApiPresetDataAdminService, readonly user: ApiPresetDataUserService, + readonly minter: ApiPresetMinterService, ) {} } diff --git a/libs/sdk/src/generated/graphql-sdk.ts b/libs/sdk/src/generated/graphql-sdk.ts index 261b2a5..c705586 100644 --- a/libs/sdk/src/generated/graphql-sdk.ts +++ b/libs/sdk/src/generated/graphql-sdk.ts @@ -106,11 +106,14 @@ export type AppConfig = { export type Claim = { __typename?: 'Claim' + account: Scalars['String']['output'] amount: Scalars['String']['output'] + community?: Maybe communityId: Scalars['String']['output'] createdAt?: Maybe id: Scalars['String']['output'] - minter: Scalars['String']['output'] + identity?: Maybe + minter?: Maybe name: Scalars['String']['output'] provider: IdentityProvider providerId: Scalars['String']['output'] @@ -120,9 +123,9 @@ export type Claim = { } export type ClaimAdminCreateInput = { + account: Scalars['String']['input'] amount?: InputMaybe communityId: Scalars['String']['input'] - minter: Scalars['String']['input'] provider: IdentityProvider providerId: Scalars['String']['input'] } @@ -152,17 +155,17 @@ export enum ClaimStatus { } export type ClaimUserCreateInput = { + account: Scalars['String']['input'] amount?: InputMaybe communityId: Scalars['String']['input'] - minter: Scalars['String']['input'] provider: IdentityProvider providerId: Scalars['String']['input'] } export type ClaimUserFindManyInput = { + account?: InputMaybe communityId: Scalars['String']['input'] limit?: InputMaybe - minter?: InputMaybe page?: InputMaybe provider?: InputMaybe providerId?: InputMaybe @@ -230,7 +233,7 @@ export type Currency = { export type Identity = { __typename?: 'Identity' challenges?: Maybe> - createdAt: Scalars['DateTime']['output'] + createdAt?: Maybe expired?: Maybe id: Scalars['String']['output'] name?: Maybe @@ -238,7 +241,7 @@ export type Identity = { profile?: Maybe provider: IdentityProvider providerId: Scalars['String']['output'] - updatedAt: Scalars['DateTime']['output'] + updatedAt?: Maybe url?: Maybe verified?: Maybe } @@ -655,6 +658,8 @@ export type Query = { userFindOnePreset?: Maybe userFindOneUser?: Maybe userFindOneWallet?: Maybe + userGetClaim: Claim + userGetClaims: Array userGetMinter: TokenGatorMinter userGetMinterAssets: Scalars['JSON']['output'] userGetMinters: TokenGatorMinter @@ -802,6 +807,10 @@ export type QueryUserFindOneWalletArgs = { publicKey: Scalars['String']['input'] } +export type QueryUserGetClaimArgs = { + claimId: Scalars['String']['input'] +} + export type QueryUserGetMinterArgs = { account: Scalars['String']['input'] } @@ -1077,14 +1086,14 @@ export type MeQuery = { username?: string | null identities?: Array<{ __typename?: 'Identity' - createdAt: Date + createdAt?: Date | null expired?: boolean | null id: string name?: string | null profile?: any | null provider: IdentityProvider providerId: string - updatedAt: Date + updatedAt?: Date | null url?: string | null verified?: boolean | null }> | null @@ -1096,14 +1105,80 @@ export type ClaimDetailsFragment = { createdAt?: Date | null id: string communityId: string + account: string amount: string - minter: string signature?: string | null provider: IdentityProvider providerId: string status: ClaimStatus name: string updatedAt?: Date | null + identity?: { + __typename?: 'Identity' + createdAt?: Date | null + expired?: boolean | null + id: string + name?: string | null + profile?: any | null + provider: IdentityProvider + providerId: string + updatedAt?: Date | null + url?: string | null + verified?: boolean | null + } | null + community?: { + __typename?: 'Community' + createdAt?: Date | null + id: string + name: string + slug: string + description: string + imageUrl?: string | null + publicUrl?: string | null + updatedAt?: Date | null + } | null + minter?: { + __typename?: 'TokenGatorMinter' + publicKey: string + bump: number + communityId: string + name: string + description: string + imageUrl: string + feePayer: string + authorities: Array + paymentConfig: { + __typename?: 'TokenGatorMinterPaymentConfig' + mint: string + days: number + amount: number + expiresAt: string + price: string + } + minterConfig: { + __typename?: 'TokenGatorMinterConfig' + mint: string + applicationConfig: { + __typename?: 'TokenGatorMinterApplicationConfig' + identities: Array + paymentConfig: { + __typename?: 'TokenGatorMinterPaymentConfig' + mint: string + days: number + amount: number + expiresAt: string + price: string + } + } + metadataConfig: { + __typename?: 'TokenGatorMinterMetadataConfig' + metadata: Array> + name: string + symbol: string + uri: string + } + } + } | null } export type AdminFindManyClaimQueryVariables = Exact<{ @@ -1119,14 +1194,80 @@ export type AdminFindManyClaimQuery = { createdAt?: Date | null id: string communityId: string + account: string amount: string - minter: string signature?: string | null provider: IdentityProvider providerId: string status: ClaimStatus name: string updatedAt?: Date | null + identity?: { + __typename?: 'Identity' + createdAt?: Date | null + expired?: boolean | null + id: string + name?: string | null + profile?: any | null + provider: IdentityProvider + providerId: string + updatedAt?: Date | null + url?: string | null + verified?: boolean | null + } | null + community?: { + __typename?: 'Community' + createdAt?: Date | null + id: string + name: string + slug: string + description: string + imageUrl?: string | null + publicUrl?: string | null + updatedAt?: Date | null + } | null + minter?: { + __typename?: 'TokenGatorMinter' + publicKey: string + bump: number + communityId: string + name: string + description: string + imageUrl: string + feePayer: string + authorities: Array + paymentConfig: { + __typename?: 'TokenGatorMinterPaymentConfig' + mint: string + days: number + amount: number + expiresAt: string + price: string + } + minterConfig: { + __typename?: 'TokenGatorMinterConfig' + mint: string + applicationConfig: { + __typename?: 'TokenGatorMinterApplicationConfig' + identities: Array + paymentConfig: { + __typename?: 'TokenGatorMinterPaymentConfig' + mint: string + days: number + amount: number + expiresAt: string + price: string + } + } + metadataConfig: { + __typename?: 'TokenGatorMinterMetadataConfig' + metadata: Array> + name: string + symbol: string + uri: string + } + } + } | null }> meta: { __typename?: 'PagingMeta' @@ -1152,14 +1293,80 @@ export type AdminFindOneClaimQuery = { createdAt?: Date | null id: string communityId: string + account: string amount: string - minter: string signature?: string | null provider: IdentityProvider providerId: string status: ClaimStatus name: string updatedAt?: Date | null + identity?: { + __typename?: 'Identity' + createdAt?: Date | null + expired?: boolean | null + id: string + name?: string | null + profile?: any | null + provider: IdentityProvider + providerId: string + updatedAt?: Date | null + url?: string | null + verified?: boolean | null + } | null + community?: { + __typename?: 'Community' + createdAt?: Date | null + id: string + name: string + slug: string + description: string + imageUrl?: string | null + publicUrl?: string | null + updatedAt?: Date | null + } | null + minter?: { + __typename?: 'TokenGatorMinter' + publicKey: string + bump: number + communityId: string + name: string + description: string + imageUrl: string + feePayer: string + authorities: Array + paymentConfig: { + __typename?: 'TokenGatorMinterPaymentConfig' + mint: string + days: number + amount: number + expiresAt: string + price: string + } + minterConfig: { + __typename?: 'TokenGatorMinterConfig' + mint: string + applicationConfig: { + __typename?: 'TokenGatorMinterApplicationConfig' + identities: Array + paymentConfig: { + __typename?: 'TokenGatorMinterPaymentConfig' + mint: string + days: number + amount: number + expiresAt: string + price: string + } + } + metadataConfig: { + __typename?: 'TokenGatorMinterMetadataConfig' + metadata: Array> + name: string + symbol: string + uri: string + } + } + } | null } | null } @@ -1174,14 +1381,80 @@ export type AdminCreateClaimMutation = { createdAt?: Date | null id: string communityId: string + account: string amount: string - minter: string signature?: string | null provider: IdentityProvider providerId: string status: ClaimStatus name: string updatedAt?: Date | null + identity?: { + __typename?: 'Identity' + createdAt?: Date | null + expired?: boolean | null + id: string + name?: string | null + profile?: any | null + provider: IdentityProvider + providerId: string + updatedAt?: Date | null + url?: string | null + verified?: boolean | null + } | null + community?: { + __typename?: 'Community' + createdAt?: Date | null + id: string + name: string + slug: string + description: string + imageUrl?: string | null + publicUrl?: string | null + updatedAt?: Date | null + } | null + minter?: { + __typename?: 'TokenGatorMinter' + publicKey: string + bump: number + communityId: string + name: string + description: string + imageUrl: string + feePayer: string + authorities: Array + paymentConfig: { + __typename?: 'TokenGatorMinterPaymentConfig' + mint: string + days: number + amount: number + expiresAt: string + price: string + } + minterConfig: { + __typename?: 'TokenGatorMinterConfig' + mint: string + applicationConfig: { + __typename?: 'TokenGatorMinterApplicationConfig' + identities: Array + paymentConfig: { + __typename?: 'TokenGatorMinterPaymentConfig' + mint: string + days: number + amount: number + expiresAt: string + price: string + } + } + metadataConfig: { + __typename?: 'TokenGatorMinterMetadataConfig' + metadata: Array> + name: string + symbol: string + uri: string + } + } + } | null } | null } @@ -1197,14 +1470,80 @@ export type AdminUpdateClaimMutation = { createdAt?: Date | null id: string communityId: string + account: string amount: string - minter: string signature?: string | null provider: IdentityProvider providerId: string status: ClaimStatus name: string updatedAt?: Date | null + identity?: { + __typename?: 'Identity' + createdAt?: Date | null + expired?: boolean | null + id: string + name?: string | null + profile?: any | null + provider: IdentityProvider + providerId: string + updatedAt?: Date | null + url?: string | null + verified?: boolean | null + } | null + community?: { + __typename?: 'Community' + createdAt?: Date | null + id: string + name: string + slug: string + description: string + imageUrl?: string | null + publicUrl?: string | null + updatedAt?: Date | null + } | null + minter?: { + __typename?: 'TokenGatorMinter' + publicKey: string + bump: number + communityId: string + name: string + description: string + imageUrl: string + feePayer: string + authorities: Array + paymentConfig: { + __typename?: 'TokenGatorMinterPaymentConfig' + mint: string + days: number + amount: number + expiresAt: string + price: string + } + minterConfig: { + __typename?: 'TokenGatorMinterConfig' + mint: string + applicationConfig: { + __typename?: 'TokenGatorMinterApplicationConfig' + identities: Array + paymentConfig: { + __typename?: 'TokenGatorMinterPaymentConfig' + mint: string + days: number + amount: number + expiresAt: string + price: string + } + } + metadataConfig: { + __typename?: 'TokenGatorMinterMetadataConfig' + metadata: Array> + name: string + symbol: string + uri: string + } + } + } | null } | null } @@ -1227,14 +1566,80 @@ export type UserFindManyClaimQuery = { createdAt?: Date | null id: string communityId: string + account: string amount: string - minter: string signature?: string | null provider: IdentityProvider providerId: string status: ClaimStatus name: string updatedAt?: Date | null + identity?: { + __typename?: 'Identity' + createdAt?: Date | null + expired?: boolean | null + id: string + name?: string | null + profile?: any | null + provider: IdentityProvider + providerId: string + updatedAt?: Date | null + url?: string | null + verified?: boolean | null + } | null + community?: { + __typename?: 'Community' + createdAt?: Date | null + id: string + name: string + slug: string + description: string + imageUrl?: string | null + publicUrl?: string | null + updatedAt?: Date | null + } | null + minter?: { + __typename?: 'TokenGatorMinter' + publicKey: string + bump: number + communityId: string + name: string + description: string + imageUrl: string + feePayer: string + authorities: Array + paymentConfig: { + __typename?: 'TokenGatorMinterPaymentConfig' + mint: string + days: number + amount: number + expiresAt: string + price: string + } + minterConfig: { + __typename?: 'TokenGatorMinterConfig' + mint: string + applicationConfig: { + __typename?: 'TokenGatorMinterApplicationConfig' + identities: Array + paymentConfig: { + __typename?: 'TokenGatorMinterPaymentConfig' + mint: string + days: number + amount: number + expiresAt: string + price: string + } + } + metadataConfig: { + __typename?: 'TokenGatorMinterMetadataConfig' + metadata: Array> + name: string + symbol: string + uri: string + } + } + } | null }> meta: { __typename?: 'PagingMeta' @@ -1249,6 +1654,180 @@ export type UserFindManyClaimQuery = { } } +export type UserGetClaimQueryVariables = Exact<{ + claimId: Scalars['String']['input'] +}> + +export type UserGetClaimQuery = { + __typename?: 'Query' + item: { + __typename?: 'Claim' + createdAt?: Date | null + id: string + communityId: string + account: string + amount: string + signature?: string | null + provider: IdentityProvider + providerId: string + status: ClaimStatus + name: string + updatedAt?: Date | null + identity?: { + __typename?: 'Identity' + createdAt?: Date | null + expired?: boolean | null + id: string + name?: string | null + profile?: any | null + provider: IdentityProvider + providerId: string + updatedAt?: Date | null + url?: string | null + verified?: boolean | null + } | null + community?: { + __typename?: 'Community' + createdAt?: Date | null + id: string + name: string + slug: string + description: string + imageUrl?: string | null + publicUrl?: string | null + updatedAt?: Date | null + } | null + minter?: { + __typename?: 'TokenGatorMinter' + publicKey: string + bump: number + communityId: string + name: string + description: string + imageUrl: string + feePayer: string + authorities: Array + paymentConfig: { + __typename?: 'TokenGatorMinterPaymentConfig' + mint: string + days: number + amount: number + expiresAt: string + price: string + } + minterConfig: { + __typename?: 'TokenGatorMinterConfig' + mint: string + applicationConfig: { + __typename?: 'TokenGatorMinterApplicationConfig' + identities: Array + paymentConfig: { + __typename?: 'TokenGatorMinterPaymentConfig' + mint: string + days: number + amount: number + expiresAt: string + price: string + } + } + metadataConfig: { + __typename?: 'TokenGatorMinterMetadataConfig' + metadata: Array> + name: string + symbol: string + uri: string + } + } + } | null + } +} + +export type UserGetClaimsQueryVariables = Exact<{ [key: string]: never }> + +export type UserGetClaimsQuery = { + __typename?: 'Query' + items: Array<{ + __typename?: 'Claim' + createdAt?: Date | null + id: string + communityId: string + account: string + amount: string + signature?: string | null + provider: IdentityProvider + providerId: string + status: ClaimStatus + name: string + updatedAt?: Date | null + identity?: { + __typename?: 'Identity' + createdAt?: Date | null + expired?: boolean | null + id: string + name?: string | null + profile?: any | null + provider: IdentityProvider + providerId: string + updatedAt?: Date | null + url?: string | null + verified?: boolean | null + } | null + community?: { + __typename?: 'Community' + createdAt?: Date | null + id: string + name: string + slug: string + description: string + imageUrl?: string | null + publicUrl?: string | null + updatedAt?: Date | null + } | null + minter?: { + __typename?: 'TokenGatorMinter' + publicKey: string + bump: number + communityId: string + name: string + description: string + imageUrl: string + feePayer: string + authorities: Array + paymentConfig: { + __typename?: 'TokenGatorMinterPaymentConfig' + mint: string + days: number + amount: number + expiresAt: string + price: string + } + minterConfig: { + __typename?: 'TokenGatorMinterConfig' + mint: string + applicationConfig: { + __typename?: 'TokenGatorMinterApplicationConfig' + identities: Array + paymentConfig: { + __typename?: 'TokenGatorMinterPaymentConfig' + mint: string + days: number + amount: number + expiresAt: string + price: string + } + } + metadataConfig: { + __typename?: 'TokenGatorMinterMetadataConfig' + metadata: Array> + name: string + symbol: string + uri: string + } + } + } | null + }> +} + export type UserFindOneClaimQueryVariables = Exact<{ claimId: Scalars['String']['input'] }> @@ -1260,14 +1839,80 @@ export type UserFindOneClaimQuery = { createdAt?: Date | null id: string communityId: string + account: string amount: string - minter: string signature?: string | null provider: IdentityProvider providerId: string status: ClaimStatus name: string updatedAt?: Date | null + identity?: { + __typename?: 'Identity' + createdAt?: Date | null + expired?: boolean | null + id: string + name?: string | null + profile?: any | null + provider: IdentityProvider + providerId: string + updatedAt?: Date | null + url?: string | null + verified?: boolean | null + } | null + community?: { + __typename?: 'Community' + createdAt?: Date | null + id: string + name: string + slug: string + description: string + imageUrl?: string | null + publicUrl?: string | null + updatedAt?: Date | null + } | null + minter?: { + __typename?: 'TokenGatorMinter' + publicKey: string + bump: number + communityId: string + name: string + description: string + imageUrl: string + feePayer: string + authorities: Array + paymentConfig: { + __typename?: 'TokenGatorMinterPaymentConfig' + mint: string + days: number + amount: number + expiresAt: string + price: string + } + minterConfig: { + __typename?: 'TokenGatorMinterConfig' + mint: string + applicationConfig: { + __typename?: 'TokenGatorMinterApplicationConfig' + identities: Array + paymentConfig: { + __typename?: 'TokenGatorMinterPaymentConfig' + mint: string + days: number + amount: number + expiresAt: string + price: string + } + } + metadataConfig: { + __typename?: 'TokenGatorMinterMetadataConfig' + metadata: Array> + name: string + symbol: string + uri: string + } + } + } | null } | null } @@ -1282,14 +1927,80 @@ export type UserCreateClaimMutation = { createdAt?: Date | null id: string communityId: string + account: string amount: string - minter: string signature?: string | null provider: IdentityProvider providerId: string status: ClaimStatus name: string updatedAt?: Date | null + identity?: { + __typename?: 'Identity' + createdAt?: Date | null + expired?: boolean | null + id: string + name?: string | null + profile?: any | null + provider: IdentityProvider + providerId: string + updatedAt?: Date | null + url?: string | null + verified?: boolean | null + } | null + community?: { + __typename?: 'Community' + createdAt?: Date | null + id: string + name: string + slug: string + description: string + imageUrl?: string | null + publicUrl?: string | null + updatedAt?: Date | null + } | null + minter?: { + __typename?: 'TokenGatorMinter' + publicKey: string + bump: number + communityId: string + name: string + description: string + imageUrl: string + feePayer: string + authorities: Array + paymentConfig: { + __typename?: 'TokenGatorMinterPaymentConfig' + mint: string + days: number + amount: number + expiresAt: string + price: string + } + minterConfig: { + __typename?: 'TokenGatorMinterConfig' + mint: string + applicationConfig: { + __typename?: 'TokenGatorMinterApplicationConfig' + identities: Array + paymentConfig: { + __typename?: 'TokenGatorMinterPaymentConfig' + mint: string + days: number + amount: number + expiresAt: string + price: string + } + } + metadataConfig: { + __typename?: 'TokenGatorMinterMetadataConfig' + metadata: Array> + name: string + symbol: string + uri: string + } + } + } | null } | null } @@ -1305,14 +2016,80 @@ export type UserUpdateClaimMutation = { createdAt?: Date | null id: string communityId: string + account: string amount: string - minter: string signature?: string | null provider: IdentityProvider providerId: string status: ClaimStatus name: string updatedAt?: Date | null + identity?: { + __typename?: 'Identity' + createdAt?: Date | null + expired?: boolean | null + id: string + name?: string | null + profile?: any | null + provider: IdentityProvider + providerId: string + updatedAt?: Date | null + url?: string | null + verified?: boolean | null + } | null + community?: { + __typename?: 'Community' + createdAt?: Date | null + id: string + name: string + slug: string + description: string + imageUrl?: string | null + publicUrl?: string | null + updatedAt?: Date | null + } | null + minter?: { + __typename?: 'TokenGatorMinter' + publicKey: string + bump: number + communityId: string + name: string + description: string + imageUrl: string + feePayer: string + authorities: Array + paymentConfig: { + __typename?: 'TokenGatorMinterPaymentConfig' + mint: string + days: number + amount: number + expiresAt: string + price: string + } + minterConfig: { + __typename?: 'TokenGatorMinterConfig' + mint: string + applicationConfig: { + __typename?: 'TokenGatorMinterApplicationConfig' + identities: Array + paymentConfig: { + __typename?: 'TokenGatorMinterPaymentConfig' + mint: string + days: number + amount: number + expiresAt: string + price: string + } + } + metadataConfig: { + __typename?: 'TokenGatorMinterMetadataConfig' + metadata: Array> + name: string + symbol: string + uri: string + } + } + } | null } | null } @@ -1933,14 +2710,14 @@ export type CurrenciesQuery = { export type IdentityDetailsFragment = { __typename?: 'Identity' - createdAt: Date + createdAt?: Date | null expired?: boolean | null id: string name?: string | null profile?: any | null provider: IdentityProvider providerId: string - updatedAt: Date + updatedAt?: Date | null url?: string | null verified?: boolean | null } @@ -1967,14 +2744,14 @@ export type AdminFindManyIdentityQuery = { __typename?: 'Query' items?: Array<{ __typename?: 'Identity' - createdAt: Date + createdAt?: Date | null expired?: boolean | null id: string name?: string | null profile?: any | null provider: IdentityProvider providerId: string - updatedAt: Date + updatedAt?: Date | null url?: string | null verified?: boolean | null challenges?: Array<{ @@ -2014,14 +2791,14 @@ export type AdminCreateIdentityMutation = { __typename?: 'Mutation' created?: { __typename?: 'Identity' - createdAt: Date + createdAt?: Date | null expired?: boolean | null id: string name?: string | null profile?: any | null provider: IdentityProvider providerId: string - updatedAt: Date + updatedAt?: Date | null url?: string | null verified?: boolean | null } | null @@ -2041,14 +2818,14 @@ export type UserFindManyIdentityQuery = { __typename?: 'Query' items?: Array<{ __typename?: 'Identity' - createdAt: Date + createdAt?: Date | null expired?: boolean | null id: string name?: string | null profile?: any | null provider: IdentityProvider providerId: string - updatedAt: Date + updatedAt?: Date | null url?: string | null verified?: boolean | null }> | null @@ -2110,14 +2887,14 @@ export type UserLinkIdentityMutation = { __typename?: 'Mutation' linked?: { __typename?: 'Identity' - createdAt: Date + createdAt?: Date | null expired?: boolean | null id: string name?: string | null profile?: any | null provider: IdentityProvider providerId: string - updatedAt: Date + updatedAt?: Date | null url?: string | null verified?: boolean | null } | null @@ -2844,14 +3621,14 @@ export type AdminFindManyUserQuery = { username?: string | null identities?: Array<{ __typename?: 'Identity' - createdAt: Date + createdAt?: Date | null expired?: boolean | null id: string name?: string | null profile?: any | null provider: IdentityProvider providerId: string - updatedAt: Date + updatedAt?: Date | null url?: string | null verified?: boolean | null }> | null @@ -3201,20 +3978,117 @@ export type UserSetWalletFeepayerMutation = { } | null } +export const IdentityDetailsFragmentDoc = gql` + fragment IdentityDetails on Identity { + createdAt + expired + id + name + profile + provider + providerId + updatedAt + url + verified + } +` +export const CommunityDetailsFragmentDoc = gql` + fragment CommunityDetails on Community { + createdAt + id + name + slug + description + imageUrl + publicUrl + updatedAt + } +` +export const TokenGatorPaymentConfigDetailsFragmentDoc = gql` + fragment TokenGatorPaymentConfigDetails on TokenGatorMinterPaymentConfig { + mint + days + amount + expiresAt + price + } +` +export const TokenGatorApplicationConfigDetailsFragmentDoc = gql` + fragment TokenGatorApplicationConfigDetails on TokenGatorMinterApplicationConfig { + identities + paymentConfig { + ...TokenGatorPaymentConfigDetails + } + } + ${TokenGatorPaymentConfigDetailsFragmentDoc} +` +export const TokenGatorMetadataConfigDetailsFragmentDoc = gql` + fragment TokenGatorMetadataConfigDetails on TokenGatorMinterMetadataConfig { + metadata + name + symbol + uri + } +` +export const TokenGatorMinterConfigDetailsFragmentDoc = gql` + fragment TokenGatorMinterConfigDetails on TokenGatorMinterConfig { + mint + applicationConfig { + ...TokenGatorApplicationConfigDetails + } + metadataConfig { + ...TokenGatorMetadataConfigDetails + } + } + ${TokenGatorApplicationConfigDetailsFragmentDoc} + ${TokenGatorMetadataConfigDetailsFragmentDoc} +` +export const TokenGatorMinterDetailsFragmentDoc = gql` + fragment TokenGatorMinterDetails on TokenGatorMinter { + publicKey + bump + communityId + name + description + imageUrl + feePayer + authorities + paymentConfig { + ...TokenGatorPaymentConfigDetails + } + minterConfig { + ...TokenGatorMinterConfigDetails + } + } + ${TokenGatorPaymentConfigDetailsFragmentDoc} + ${TokenGatorMinterConfigDetailsFragmentDoc} +` export const ClaimDetailsFragmentDoc = gql` fragment ClaimDetails on Claim { createdAt id communityId + account amount - minter signature provider providerId status name updatedAt + identity { + ...IdentityDetails + } + community { + ...CommunityDetails + } + minter { + ...TokenGatorMinterDetails + } } + ${IdentityDetailsFragmentDoc} + ${CommunityDetailsFragmentDoc} + ${TokenGatorMinterDetailsFragmentDoc} ` export const UserDetailsFragmentDoc = gql` fragment UserDetails on User { @@ -3244,18 +4118,6 @@ export const CommunityMemberDetailsFragmentDoc = gql` } ${UserDetailsFragmentDoc} ` -export const CommunityDetailsFragmentDoc = gql` - fragment CommunityDetails on Community { - createdAt - id - name - slug - description - imageUrl - publicUrl - updatedAt - } -` export const AppConfigDetailsFragmentDoc = gql` fragment AppConfigDetails on AppConfig { authDiscordEnabled @@ -3278,20 +4140,6 @@ export const PagingMetaDetailsFragmentDoc = gql` totalCount } ` -export const IdentityDetailsFragmentDoc = gql` - fragment IdentityDetails on Identity { - createdAt - expired - id - name - profile - provider - providerId - updatedAt - url - verified - } -` export const IdentityChallengeDetailsFragmentDoc = gql` fragment IdentityChallengeDetails on IdentityChallenge { id @@ -3344,65 +4192,6 @@ export const PriceDetailsFragmentDoc = gql` } ${CurrencyDetailsFragmentDoc} ` -export const TokenGatorPaymentConfigDetailsFragmentDoc = gql` - fragment TokenGatorPaymentConfigDetails on TokenGatorMinterPaymentConfig { - mint - days - amount - expiresAt - price - } -` -export const TokenGatorApplicationConfigDetailsFragmentDoc = gql` - fragment TokenGatorApplicationConfigDetails on TokenGatorMinterApplicationConfig { - identities - paymentConfig { - ...TokenGatorPaymentConfigDetails - } - } - ${TokenGatorPaymentConfigDetailsFragmentDoc} -` -export const TokenGatorMetadataConfigDetailsFragmentDoc = gql` - fragment TokenGatorMetadataConfigDetails on TokenGatorMinterMetadataConfig { - metadata - name - symbol - uri - } -` -export const TokenGatorMinterConfigDetailsFragmentDoc = gql` - fragment TokenGatorMinterConfigDetails on TokenGatorMinterConfig { - mint - applicationConfig { - ...TokenGatorApplicationConfigDetails - } - metadataConfig { - ...TokenGatorMetadataConfigDetails - } - } - ${TokenGatorApplicationConfigDetailsFragmentDoc} - ${TokenGatorMetadataConfigDetailsFragmentDoc} -` -export const TokenGatorMinterDetailsFragmentDoc = gql` - fragment TokenGatorMinterDetails on TokenGatorMinter { - publicKey - bump - communityId - name - description - imageUrl - feePayer - authorities - paymentConfig { - ...TokenGatorPaymentConfigDetails - } - minterConfig { - ...TokenGatorMinterConfigDetails - } - } - ${TokenGatorPaymentConfigDetailsFragmentDoc} - ${TokenGatorMinterConfigDetailsFragmentDoc} -` export const WalletDetailsFragmentDoc = gql` fragment WalletDetails on Wallet { createdAt @@ -3504,6 +4293,22 @@ export const UserFindManyClaimDocument = gql` ${ClaimDetailsFragmentDoc} ${PagingMetaDetailsFragmentDoc} ` +export const UserGetClaimDocument = gql` + query userGetClaim($claimId: String!) { + item: userGetClaim(claimId: $claimId) { + ...ClaimDetails + } + } + ${ClaimDetailsFragmentDoc} +` +export const UserGetClaimsDocument = gql` + query userGetClaims { + items: userGetClaims { + ...ClaimDetails + } + } + ${ClaimDetailsFragmentDoc} +` export const UserFindOneClaimDocument = gql` query userFindOneClaim($claimId: String!) { item: userFindOneClaim(claimId: $claimId) { @@ -4186,6 +4991,8 @@ const AdminCreateClaimDocumentString = print(AdminCreateClaimDocument) const AdminUpdateClaimDocumentString = print(AdminUpdateClaimDocument) const AdminDeleteClaimDocumentString = print(AdminDeleteClaimDocument) const UserFindManyClaimDocumentString = print(UserFindManyClaimDocument) +const UserGetClaimDocumentString = print(UserGetClaimDocument) +const UserGetClaimsDocumentString = print(UserGetClaimsDocument) const UserFindOneClaimDocumentString = print(UserFindOneClaimDocument) const UserCreateClaimDocumentString = print(UserCreateClaimDocument) const UserUpdateClaimDocumentString = print(UserUpdateClaimDocument) @@ -4457,6 +5264,48 @@ export function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper = variables, ) }, + userGetClaim( + variables: UserGetClaimQueryVariables, + requestHeaders?: GraphQLClientRequestHeaders, + ): Promise<{ + data: UserGetClaimQuery + errors?: GraphQLError[] + extensions?: any + headers: Headers + status: number + }> { + return withWrapper( + (wrappedRequestHeaders) => + client.rawRequest(UserGetClaimDocumentString, variables, { + ...requestHeaders, + ...wrappedRequestHeaders, + }), + 'userGetClaim', + 'query', + variables, + ) + }, + userGetClaims( + variables?: UserGetClaimsQueryVariables, + requestHeaders?: GraphQLClientRequestHeaders, + ): Promise<{ + data: UserGetClaimsQuery + errors?: GraphQLError[] + extensions?: any + headers: Headers + status: number + }> { + return withWrapper( + (wrappedRequestHeaders) => + client.rawRequest(UserGetClaimsDocumentString, variables, { + ...requestHeaders, + ...wrappedRequestHeaders, + }), + 'userGetClaims', + 'query', + variables, + ) + }, userFindOneClaim( variables: UserFindOneClaimQueryVariables, requestHeaders?: GraphQLClientRequestHeaders, @@ -6236,9 +7085,9 @@ export function AnonFindManyCommunityInputSchema(): z.ZodObject> { return z.object({ + account: z.string(), amount: z.string().nullish(), communityId: z.string(), - minter: z.string(), provider: IdentityProviderSchema, providerId: z.string(), }) @@ -6263,9 +7112,9 @@ export function ClaimAdminUpdateInputSchema(): z.ZodObject> { return z.object({ + account: z.string(), amount: z.string().nullish(), communityId: z.string(), - minter: z.string(), provider: IdentityProviderSchema, providerId: z.string(), }) @@ -6273,9 +7122,9 @@ export function ClaimUserCreateInputSchema(): z.ZodObject> { return z.object({ + account: z.string().nullish(), communityId: z.string(), limit: z.number().nullish(), - minter: z.string().nullish(), page: z.number().nullish(), provider: IdentityProviderSchema.nullish(), providerId: z.string().nullish(), diff --git a/libs/sdk/src/graphql/feature-claim.graphql b/libs/sdk/src/graphql/feature-claim.graphql index 3816bd4..fcc860c 100644 --- a/libs/sdk/src/graphql/feature-claim.graphql +++ b/libs/sdk/src/graphql/feature-claim.graphql @@ -2,14 +2,23 @@ fragment ClaimDetails on Claim { createdAt id communityId + account amount - minter signature provider providerId status name updatedAt + identity { + ...IdentityDetails + } + community { + ...CommunityDetails + } + minter { + ...TokenGatorMinterDetails + } } query adminFindManyClaim($input: ClaimAdminFindManyInput!) { @@ -56,6 +65,18 @@ query userFindManyClaim($input: ClaimUserFindManyInput!) { } } +query userGetClaim($claimId: String!) { + item: userGetClaim(claimId: $claimId) { + ...ClaimDetails + } +} + +query userGetClaims { + items: userGetClaims { + ...ClaimDetails + } +} + query userFindOneClaim($claimId: String!) { item: userFindOneClaim(claimId: $claimId) { ...ClaimDetails diff --git a/libs/web/claim/data-access/src/lib/use-user-find-many-claim.ts b/libs/web/claim/data-access/src/lib/use-user-find-many-claim.ts index 3ea7e86..66275b2 100644 --- a/libs/web/claim/data-access/src/lib/use-user-find-many-claim.ts +++ b/libs/web/claim/data-access/src/lib/use-user-find-many-claim.ts @@ -4,13 +4,15 @@ import { ClaimUserCreateInput, ClaimUserFindManyInput } from '@tokengator-mint/s import { useSdk } from '@tokengator-mint/web-core-data-access' import { useState } from 'react' -export function useUserFindManyClaim(props: Partial & { communityId: string; minter: string }) { +export function useUserFindManyClaim( + props: Partial & { communityId: string; account: string }, +) { const sdk = useSdk() const [limit, setLimit] = useState(props?.limit ?? 10) const [page, setPage] = useState(props?.page ?? 1) const [search, setSearch] = useState(props?.search ?? '') - const input: ClaimUserFindManyInput = { page, limit, search, communityId: props.communityId } + const input: ClaimUserFindManyInput = { page, limit, search, communityId: props.communityId, account: props.account } const query = useQuery({ queryKey: ['user', 'find-many-claim', input], queryFn: () => sdk.userFindManyClaim({ input }).then((res) => res.data), @@ -31,7 +33,7 @@ export function useUserFindManyClaim(props: Partial & { setSearch, createClaim: (input: ClaimUserCreateInput) => sdk - .userCreateClaim({ input: { ...input, minter: props.minter, communityId: props.communityId } }) + .userCreateClaim({ input: { ...input, account: props.account, communityId: props.communityId } }) .then((res) => res.data) .then((res) => { if (res.created) { diff --git a/libs/web/claim/data-access/src/lib/use-user-find-one-claim.ts b/libs/web/claim/data-access/src/lib/use-user-find-one-claim.ts index 0cb9cee..876368a 100644 --- a/libs/web/claim/data-access/src/lib/use-user-find-one-claim.ts +++ b/libs/web/claim/data-access/src/lib/use-user-find-one-claim.ts @@ -1,7 +1,7 @@ -import { ClaimUserUpdateInput } from '@tokengator-mint/sdk' -import { useSdk } from '@tokengator-mint/web-core-data-access' import { toastError, toastSuccess } from '@pubkey-ui/core' import { useQuery } from '@tanstack/react-query' +import { Claim, ClaimUserUpdateInput } from '@tokengator-mint/sdk' +import { useSdk } from '@tokengator-mint/web-core-data-access' export function useUserFindOneClaim({ claimId }: { claimId: string }) { const sdk = useSdk() @@ -34,3 +34,34 @@ export function useUserFindOneClaim({ claimId }: { claimId: string }) { }), } } + +export function useUserGetClaims() { + const sdk = useSdk() + const query = useQuery({ + queryKey: ['user', 'getClaims'], + queryFn: () => sdk.userGetClaims().then((res) => res.data), + retry: 0, + }) + const items: Claim[] = query.data?.items ?? [] + + return { + items, + query, + } +} + +export function useUserGetClaim({ claimId }: { claimId: string }) { + const sdk = useSdk() + const query = useQuery({ + queryKey: ['user', 'getClaim', claimId], + queryFn: () => sdk.userGetClaim({ claimId }).then((res) => res.data), + retry: 0, + }) + + const item: Claim | undefined = query.data?.item ?? undefined + + return { + item, + query, + } +} diff --git a/libs/web/claim/feature/src/index.ts b/libs/web/claim/feature/src/index.ts index 3ea59ac..b83a397 100644 --- a/libs/web/claim/feature/src/index.ts +++ b/libs/web/claim/feature/src/index.ts @@ -1,4 +1,5 @@ import { lazy } from 'react' -export const AdminClaimFeature = lazy(() => import('./lib/admin-claim.routes')) +export const AdminClaimFeature = lazy(() => import('./lib/admin-claim.routes')) export const UserClaimFeature = lazy(() => import('./lib/user-claim.routes')) +export const UserClaimPageFeature = lazy(() => import('./lib/user-claim-page.routes')) diff --git a/libs/web/claim/feature/src/lib/user-claim-create.feature.tsx b/libs/web/claim/feature/src/lib/user-claim-create.feature.tsx index 67465ec..a110df7 100644 --- a/libs/web/claim/feature/src/lib/user-claim-create.feature.tsx +++ b/libs/web/claim/feature/src/lib/user-claim-create.feature.tsx @@ -5,9 +5,9 @@ import { useUserFindManyClaim } from '@tokengator-mint/web-claim-data-access' import { UserClaimUiCreateForm } from '@tokengator-mint/web-claim-ui' import { useNavigate } from 'react-router-dom' -export default function UserClaimCreateFeature({ communityId, minter }: { communityId: string; minter: string }) { +export default function UserClaimCreateFeature({ communityId, account }: { communityId: string; account: string }) { const navigate = useNavigate() - const { createClaim } = useUserFindManyClaim({ communityId, minter }) + const { createClaim } = useUserFindManyClaim({ communityId, account }) async function submit(input: ClaimUserCreateInput) { return createClaim(input) diff --git a/libs/web/claim/feature/src/lib/user-claim-list.feature.tsx b/libs/web/claim/feature/src/lib/user-claim-list.feature.tsx index 747cc98..e49820a 100644 --- a/libs/web/claim/feature/src/lib/user-claim-list.feature.tsx +++ b/libs/web/claim/feature/src/lib/user-claim-list.feature.tsx @@ -5,11 +5,11 @@ import { UserClaimUiTable } from '@tokengator-mint/web-claim-ui' import { UiSearchField } from '@tokengator-mint/web-core-ui' import { Link } from 'react-router-dom' -export default function UserClaimListFeature({ communityId, minter }: { communityId: string; minter: string }) { +export default function UserClaimListFeature({ communityId, account }: { communityId: string; account: string }) { const { deleteClaim, items, pagination, query, setSearch } = useUserFindManyClaim({ limit: 100, communityId, - minter, + account, }) return ( diff --git a/libs/web/claim/feature/src/lib/user-claim-page-detail.feature.tsx b/libs/web/claim/feature/src/lib/user-claim-page-detail.feature.tsx new file mode 100644 index 0000000..2cf1517 --- /dev/null +++ b/libs/web/claim/feature/src/lib/user-claim-page-detail.feature.tsx @@ -0,0 +1,32 @@ +import { Group } from '@mantine/core' +import { UiBack, UiCard, UiDebugModal, UiError, UiGroup, UiLoader, UiStack } from '@pubkey-ui/core' +import { useUserGetClaim } from '@tokengator-mint/web-claim-data-access' +import { ClaimUiInfo, ClaimUiItem } from '@tokengator-mint/web-claim-ui' +import { useParams } from 'react-router-dom' + +export default function UserClaimDetailFeature() { + const { claimId } = useParams<{ claimId: string }>() as { claimId: string } + const { item, query } = useUserGetClaim({ claimId }) + + if (query.isLoading) { + return + } + if (!item) { + return + } + + return ( + + + + + + + + + + + + + ) +} diff --git a/libs/web/claim/feature/src/lib/user-claim-page-list.feature.tsx b/libs/web/claim/feature/src/lib/user-claim-page-list.feature.tsx new file mode 100644 index 0000000..933088d --- /dev/null +++ b/libs/web/claim/feature/src/lib/user-claim-page-list.feature.tsx @@ -0,0 +1,46 @@ +import { Group, Stack, Text } from '@mantine/core' +import { UiDebug, UiDebugModal, UiInfo, UiLoader, UiStack } from '@pubkey-ui/core' +import { ellipsify } from '@tokengator-mint/sdk' +import { useUserGetClaims } from '@tokengator-mint/web-claim-data-access' +import { IdentityUiAvatar, IdentityUiIcon } from '@tokengator-mint/web-identity-ui' + +export default function UserClaimListFeature() { + const { items, query } = useUserGetClaims() + + return ( + + {query.isLoading ? ( + + ) : items?.length ? ( + + {items.map((item) => ( + + + {item.identity ? : null} + + + + {item.identity?.name} + + {ellipsify(item.identity?.providerId)} + + + + + + } + /> + + ))} + {' '} + + ) : ( + + )} + + ) +} diff --git a/libs/web/claim/feature/src/lib/user-claim-page.routes.tsx b/libs/web/claim/feature/src/lib/user-claim-page.routes.tsx new file mode 100644 index 0000000..d00b0c2 --- /dev/null +++ b/libs/web/claim/feature/src/lib/user-claim-page.routes.tsx @@ -0,0 +1,12 @@ +import { lazy } from 'react' +import { useRoutes } from 'react-router-dom' + +const Detail = lazy(() => import('./user-claim-page-detail.feature')) +const List = lazy(() => import('./user-claim-page-list.feature')) + +export default function UserClaimPageRoutes() { + return useRoutes([ + { path: '', element: }, + { path: ':claimId/*', element: }, + ]) +} diff --git a/libs/web/claim/feature/src/lib/user-claim.routes.tsx b/libs/web/claim/feature/src/lib/user-claim.routes.tsx index a64ceae..6678cb3 100644 --- a/libs/web/claim/feature/src/lib/user-claim.routes.tsx +++ b/libs/web/claim/feature/src/lib/user-claim.routes.tsx @@ -5,10 +5,10 @@ const Create = lazy(() => import('./user-claim-create.feature')) const Detail = lazy(() => import('./user-claim-detail.feature')) const List = lazy(() => import('./user-claim-list.feature')) -export default function UserClaimRoutes({ communityId, minter }: { communityId: string; minter: string }) { +export default function UserClaimRoutes({ communityId, account }: { communityId: string; account: string }) { return useRoutes([ - { path: '', element: }, - { path: 'create', element: }, + { path: '', element: }, + { path: 'create', element: }, { path: ':claimId/*', element: }, ]) } diff --git a/libs/web/claim/ui/src/lib/admin-claim-ui-create-form.tsx b/libs/web/claim/ui/src/lib/admin-claim-ui-create-form.tsx index ec7e8ab..dd606d0 100644 --- a/libs/web/claim/ui/src/lib/admin-claim-ui-create-form.tsx +++ b/libs/web/claim/ui/src/lib/admin-claim-ui-create-form.tsx @@ -8,7 +8,7 @@ export function AdminClaimUiCreateForm({ submit }: { submit: (res: ClaimAdminCre initialValues: { communityId: '', amount: '', - minter: '', + account: '', provider: IdentityProvider.Solana, providerId: '', }, @@ -17,7 +17,7 @@ export function AdminClaimUiCreateForm({ submit }: { submit: (res: ClaimAdminCre return (
submit(values))}> - +