From 3cb8730ea51e839875fb157bde25a2e87500084b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boris=20P=C3=B6hland?= Date: Wed, 18 Sep 2024 16:47:52 +0200 Subject: [PATCH] own endpoint for events --- src/types/collection.ts | 11 ++++++++--- src/users/index.ts | 21 +++++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/types/collection.ts b/src/types/collection.ts index 0a9a4df..3936958 100644 --- a/src/types/collection.ts +++ b/src/types/collection.ts @@ -57,7 +57,7 @@ export interface IMintInfoExtended extends IMintInfo { } } -export interface CollectionCreatorInfo { +interface BaseCreatorInfo { name: string contractAddress: string address: string @@ -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 @@ -801,7 +806,7 @@ export type GetCollectionMintInfo = { owner: string isVisible: boolean } - creatorInfo: CreatorInfo + creatorInfo: BaseCreatorInfo } export type MintStage = { diff --git a/src/users/index.ts b/src/users/index.ts index 98f48c1..511f8df 100644 --- a/src/users/index.ts +++ b/src/users/index.ts @@ -2,6 +2,7 @@ import { CollectionModule, XOXNOClient } from '..' import type { CollectionCreatorInfo, CreatorInfo, + EventCreatorInfo, GetNFTsArgs, IMintInfo, IMintInfoExtended, @@ -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 => { + if (!isAddressValid(address)) throw new Error('Invalid address') + + const response = await this.api.fetchWithTimeout( + `/user/${address}/creator/events`, + { + ...extra, + } + ) + return response + } + /** Gets user's staking info * @param {String} address - User's address * @returns {UserStakingSummary[]} User's staking info