Skip to content

Commit

Permalink
own endpoint for events
Browse files Browse the repository at this point in the history
  • Loading branch information
borispoehland committed Sep 18, 2024
1 parent e6d8260 commit 3cb8730
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/types/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export interface IMintInfoExtended extends IMintInfo {
}
}

export interface CollectionCreatorInfo {
interface BaseCreatorInfo {
name: string
contractAddress: string
address: string
Expand All @@ -66,13 +66,18 @@ export interface CollectionCreatorInfo {
description?: string
socials?: any
id: string
}

export interface CollectionCreatorInfo extends BaseCreatorInfo {
listing: IMintInfoExtended[]
}

export interface CreatorInfo extends CollectionCreatorInfo {
export interface EventCreatorInfo extends BaseCreatorInfo {
events: IEventDoc[]
}

export interface CreatorInfo extends CollectionCreatorInfo, EventCreatorInfo {}

export interface CollectionStatisticsProfile {
tradeData: TradeData
mintData: MintStatistics
Expand Down Expand Up @@ -801,7 +806,7 @@ export type GetCollectionMintInfo = {
owner: string
isVisible: boolean
}
creatorInfo: CreatorInfo
creatorInfo: BaseCreatorInfo
}

export type MintStage = {
Expand Down
21 changes: 21 additions & 0 deletions src/users/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { CollectionModule, XOXNOClient } from '..'
import type {
CollectionCreatorInfo,
CreatorInfo,
EventCreatorInfo,
GetNFTsArgs,
IMintInfo,
IMintInfoExtended,
Expand Down Expand Up @@ -242,6 +243,26 @@ export class UserModule {
return response
}

/** Gets user's creator info
* @param {String} address - User's address
* @returns {EventCreatorInfo} User's creator info
* @throws {Error} Throws an error if the address is invalid
* */
public getCreatorEvents = async (
address: string,
extra?: RequestInit
): Promise<EventCreatorInfo> => {
if (!isAddressValid(address)) throw new Error('Invalid address')

const response = await this.api.fetchWithTimeout<EventCreatorInfo>(
`/user/${address}/creator/events`,
{
...extra,
}
)
return response
}

/** Gets user's staking info
* @param {String} address - User's address
* @returns {UserStakingSummary[]} User's staking info
Expand Down

0 comments on commit 3cb8730

Please sign in to comment.