Skip to content

Commit

Permalink
Add account details
Browse files Browse the repository at this point in the history
  • Loading branch information
danielailie committed Sep 11, 2023
1 parent b4a4bde commit c1c5cb8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,7 @@ input HistoryPagination {
}

type HoldersCount {
accountDetails: Account!
address: String!
count: Int!
}
Expand Down
6 changes: 6 additions & 0 deletions src/modules/analytics/analytics.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ import { CollectionDetailsRedisHandler } from './loaders/collection-details.redi
import { ListingAuctionAnalyticsHandler } from './events-parsers/listing-event-analytics.parser';
import { UpdateListingEventParser } from './events-parsers/updateListing-event.parser';
import { UpdatePriceEventParser } from './events-parsers/updatePrice-event.parser';
import { HoldersResolver } from './holders.resolver';
import { AccountsProvider } from '../account-stats/loaders/accounts.loader';
import { AccountsRedisHandler } from '../account-stats/loaders/accounts.redis-handler';

@Module({
providers: [
Expand All @@ -48,6 +51,9 @@ import { UpdatePriceEventParser } from './events-parsers/updatePrice-event.parse
CollectionDetailsRedisHandler,
UpdatePriceEventParser,
UpdateListingEventParser,
AccountsProvider,
AccountsRedisHandler,
HoldersResolver,
],
imports: [
ConfigModule.forRoot({
Expand Down
21 changes: 21 additions & 0 deletions src/modules/analytics/holders.resolver.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Resolver, ResolveField, Parent } from '@nestjs/graphql';
import { BaseResolver } from '../common/base.resolver';
import { HoldersCount } from './models/general-stats.model';
import { Account } from '../account-stats/models';
import { AccountsProvider } from '../account-stats/loaders/accounts.loader';

@Resolver(() => HoldersCount)
export class HoldersResolver extends BaseResolver(HoldersCount) {
constructor(private readonly accountsProvider: AccountsProvider) {
super();
}

@ResolveField(() => Account)
async accountDetails(@Parent() holders: HoldersCount) {
const { address } = holders;

if (!address) return null;
const account = await this.accountsProvider.load(address);
return Account.fromEntity(account?.value, address);
}
}

0 comments on commit c1c5cb8

Please sign in to comment.