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
1 change: 1 addition & 0 deletions api-schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,7 @@ type NetworkAsset {
group: String
id: String!
imageUrl: String
logs: [Log!]
metadata: JSON
mint: String!
name: String!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ export class ApiNetworkAssetDataService {

async findOneByAccount(cluster: NetworkCluster, account: string) {
return this.core.data.networkAsset.findUnique({
include: {
logs: {
include: { identity: { include: { owner: true } } },
orderBy: { createdAt: 'desc' },
},
},
where: { account_cluster: { cluster, account } },
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ export class ApiNetworkAssetSyncService {
await this.core.logInfo(`[${cluster}] syncIdentity: Removed ${removedIds.count} assets for ${owner}`, {
identityProvider: IdentityProvider.Solana,
identityProviderId: owner,
data: { assetIds },
})
}

Expand Down Expand Up @@ -308,17 +309,18 @@ export class ApiNetworkAssetSyncService {
if (isNetworkAssetEqual({ found, asset })) {
return true
}
const data = findNetworkAssetDiff({ found, asset })
const updated = await this.core.data.networkAsset.update({
where: { account_cluster: { account: asset.account, cluster } },
data: {
...asset,
logs: {
create: {
level: LogLevel.Info,
message: 'Asset updated',
message: `Asset updated. Type ${asset.type}, diff keys: ${Object.keys(data)}`,
identityProviderId: linkIdentity ? asset.owner : undefined,
identityProvider: linkIdentity ? IdentityProvider.Solana : undefined,
data: findNetworkAssetDiff({ found, asset }),
data,
},
},
},
Expand All @@ -331,7 +333,7 @@ export class ApiNetworkAssetSyncService {
logs: {
create: {
level: LogLevel.Info,
message: `Asset created: ${asset.name} (${asset.symbol})`,
message: `Asset created: ${asset.name} (${asset.symbol}). Owner ${asset.owner ?? 'unknown'}`,
identityProviderId: linkIdentity ? asset.owner : undefined,
identityProvider: linkIdentity ? IdentityProvider.Solana : undefined,
data: findNetworkAssetDiff({ found: {}, asset }),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Field, Int, ObjectType } from '@nestjs/graphql'
import { Prisma } from '@prisma/client'
import { Log, Prisma } from '@prisma/client'
import { NetworkResolver, PagingResponse } from '@pubkey-link/api-core-data-access'
import { NetworkCluster } from '@pubkey-link/api-network-data-access'
import { NetworkTokenType } from '@pubkey-link/api-network-token-data-access'
Expand Down Expand Up @@ -35,6 +35,7 @@ export class NetworkAsset {
burnt?: boolean
@Field()
mint!: string
logs?: Log[]
@Field()
owner!: string
@Field({ nullable: true })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Parent, ResolveField, Resolver } from '@nestjs/graphql'
import { ApiNetworkAssetService, NetworkAsset } from '@pubkey-link/api-network-asset-data-access'
import { getNetworkExplorerUrl } from '@pubkey-link/api-network-util'
import { Log } from '@pubkey-link/api-log-data-access'

@Resolver(() => NetworkAsset)
export class ApiNetworkAssetResolver {
Expand All @@ -10,4 +11,9 @@ export class ApiNetworkAssetResolver {
explorerUrl(@Parent() networkAsset: NetworkAsset) {
return getNetworkExplorerUrl(networkAsset.cluster).replace('{path}', `address/${networkAsset.account}`)
}

@ResolveField(() => [Log], { nullable: true })
logs(@Parent() networkAsset: NetworkAsset) {
return networkAsset.logs ?? []
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ export class ApiNetworkResolverRealmsVoterService {

async resolve({ owner, tokens }: { owner: string; tokens: NetworkToken[] }): Promise<NetworkAssetInput[]> {
const cluster = NetworkCluster.SolanaMainnet
const tag = `resolveNetworkAssetsSolanaRealmsVoter(${owner}, ${cluster}, ${tokens.map((t) => t.account).join(',')})`
this.logger.verbose(`${tag}: Start resolving assets`)
const groups = tokens.map((token) => token.account)

const voters = await getRealmsVoters({ realms: tokens.map((t) => t.account), owner })
const tag = `resolveNetworkAssetsSolanaRealmsVoter(${owner}, ${cluster})`
this.logger.verbose(`${tag}: Start resolving assets for groups: ${groups.join(',')}`)

const voters = await getRealmsVoters({ realms: groups, owner })
if (!voters.length) {
return []
}
Expand Down
1 change: 1 addition & 0 deletions libs/api/network/util/src/lib/resolver-realms/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ function convertVoterToNetworkAsset(voter: RealmVoter): Prisma.NetworkAssetCreat
network: { connect: { cluster: NetworkCluster.SolanaMainnet } },
owner: voter.voter,
resolver: NetworkResolver.SolanaRealms,
symbol: 'VOTER',
type: NetworkTokenType.RealmsVoter,
}
}
193 changes: 193 additions & 0 deletions libs/sdk/src/generated/graphql-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,7 @@ export type NetworkAsset = {
group?: Maybe<Scalars['String']['output']>
id: Scalars['String']['output']
imageUrl?: Maybe<Scalars['String']['output']>
logs?: Maybe<Array<Log>>
metadata?: Maybe<Scalars['JSON']['output']>
mint: Scalars['String']['output']
name: Scalars['String']['output']
Expand Down Expand Up @@ -6299,6 +6300,194 @@ export type UserFindOneNetworkAssetQuery = {
explorerUrl: string
metadata?: any | null
attributes?: any | null
logs?: Array<{
__typename?: 'Log'
createdAt?: Date | null
id: string
message: string
level: LogLevel
relatedId?: string | null
relatedType?: LogRelatedType | null
communityId?: string | null
identityProvider?: IdentityProvider | null
identityProviderId?: string | null
networkAssetId?: string | null
botId?: string | null
userId?: string | null
roleId?: string | null
updatedAt?: Date | null
data?: any | null
bot?: {
__typename?: 'Bot'
avatarUrl?: string | null
communityId: string
createdAt?: Date | null
developersUrl: string
id: string
inviteUrl: string
name: string
redirectUrl: string
redirectUrlSet?: boolean | null
started: boolean
status: BotStatus
updatedAt?: Date | null
verificationUrl: string
verificationUrlSet?: boolean | null
} | null
identity?: {
__typename?: 'Identity'
avatarUrl?: string | null
createdAt?: Date | null
syncStarted?: Date | null
syncEnded?: Date | null
expired?: boolean | null
id: string
name: string
ownerId?: string | null
profile?: any | null
provider: IdentityProvider
providerId: string
updatedAt?: Date | null
url?: string | null
verified?: boolean | null
} | null
networkAsset?: {
__typename?: 'NetworkAsset'
id: string
createdAt?: Date | null
updatedAt?: Date | null
cluster: NetworkCluster
resolver: NetworkResolver
type: NetworkTokenType
account: string
balance?: string | null
name: string
symbol?: string | null
program?: string | null
decimals: number
mint: string
burnt?: boolean | null
owner: string
group?: string | null
imageUrl?: string | null
explorerUrl: string
metadata?: any | null
attributes?: any | null
} | null
role?: {
__typename?: 'Role'
createdAt?: Date | null
id: string
communityId: string
name: string
updatedAt?: Date | null
viewUrl?: string | null
conditions?: Array<{
__typename?: 'RoleCondition'
createdAt?: Date | null
id: string
type: NetworkTokenType
amount?: string | null
amountMax?: string | null
filters?: any | null
config?: any | null
tokenId?: string | null
roleId?: string | null
updatedAt?: Date | null
valid?: boolean | null
token?: {
__typename?: 'NetworkToken'
id: string
createdAt?: Date | null
updatedAt?: Date | null
cache?: boolean | null
cluster: NetworkCluster
type: NetworkTokenType
account: string
program: string
name: string
mintList?: Array<string> | null
symbol?: string | null
description?: string | null
imageUrl?: string | null
metadataUrl?: string | null
raw?: any | null
} | null
asset?: { __typename?: 'SolanaNetworkAsset'; owner: string; amount: string; accounts: Array<string> } | null
}> | null
permissions?: Array<{
__typename?: 'RolePermission'
createdAt?: Date | null
id: string
updatedAt?: Date | null
botId?: string | null
roleId?: string | null
botRole?: {
__typename?: 'BotRole'
botId?: string | null
createdAt?: Date | null
id: string
serverId?: string | null
updatedAt?: Date | null
serverRoleId?: string | null
serverRole?: {
__typename?: 'DiscordRole'
id: string
name: string
managed: boolean
color: number
position: number
} | null
server?: {
__typename?: 'DiscordServer'
id: string
name: string
icon?: string | null
permissions?: Array<string> | null
} | null
} | null
}> | null
member?: {
__typename?: 'CommunityMember'
communityId: string
createdAt?: Date | null
id: string
admin: boolean
updatedAt?: Date | null
userId: string
user?: {
__typename?: 'User'
avatarUrl?: string | null
createdAt?: Date | null
developer?: boolean | null
private?: boolean | null
lastLogin?: Date | null
id: string
name?: string | null
profileUrl: string
role?: UserRole | null
status?: UserStatus | null
updatedAt?: Date | null
username?: string | null
} | null
} | null
} | null
user?: {
__typename?: 'User'
avatarUrl?: string | null
createdAt?: Date | null
developer?: boolean | null
private?: boolean | null
lastLogin?: Date | null
id: string
name?: string | null
profileUrl: string
role?: UserRole | null
status?: UserStatus | null
updatedAt?: Date | null
username?: string | null
} | null
}> | null
} | null
}

Expand Down Expand Up @@ -10348,9 +10537,13 @@ export const UserFindOneNetworkAssetDocument = gql`
query userFindOneNetworkAsset($account: String!, $cluster: NetworkCluster!) {
item: userFindOneNetworkAsset(account: $account, cluster: $cluster) {
...NetworkAssetDetails
logs {
...LogDetails
}
}
}
${NetworkAssetDetailsFragmentDoc}
${LogDetailsFragmentDoc}
`
export const AdminFindManyNetworkAssetDocument = gql`
query adminFindManyNetworkAsset($input: AdminFindManyNetworkAssetInput!) {
Expand Down
3 changes: 3 additions & 0 deletions libs/sdk/src/graphql/feature-network-asset.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ query userFindManyNetworkAsset($input: UserFindManyNetworkAssetInput!) {
query userFindOneNetworkAsset($account: String!, $cluster: NetworkCluster!) {
item: userFindOneNetworkAsset(account: $account, cluster: $cluster) {
...NetworkAssetDetails
logs {
...LogDetails
}
}
}

Expand Down
1 change: 1 addition & 0 deletions libs/web/log/ui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './lib/admin-log-ui-table'
export * from './lib/log-ui-item'
export * from './lib/user-log-list-feature'
export * from './lib/user-log-ui-table'
export * from './lib/user-log-ui-table-simple'
Loading
Loading