Skip to content

Commit ee3600e

Browse files
authored
Token Unlocks API SDK w/ examples (#13)
* Added token unlocks APIs to SDK w/ examples * Removed unnecessary impoprt * Removed unused types
1 parent 0be0a5d commit ee3600e

File tree

11 files changed

+1454
-6
lines changed

11 files changed

+1454
-6
lines changed

packages/api/src/client/base.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ import type {
4545
Investors,
4646
getAcquisitionDealsParameters,
4747
AcquisitionDeal,
48+
getTokenUnlockSupportedAssetsParameters,
49+
getTokenUnlockSupportedAssetsResponse,
50+
getTokenUnlockAllocationsParameters,
51+
getTokenUnlockAllocationsResponse,
52+
getTokenUnlockVestingScheduleParameters,
53+
getTokenUnlockVestingScheduleResponse,
54+
getTokenUnlocksParameters,
55+
getTokenUnlocksResponse,
56+
getTokenUnlockEventsParameters,
57+
getTokenUnlockEventsResponse,
4858
} from "@messari-kit/types";
4959
import { LogLevel, type Logger, makeConsoleLogger, createFilteredLogger, noOpLogger } from "../logging";
5060
import type { PaginatedResult, RequestOptions, ClientEventMap, ClientEventType, ClientEventHandler } from "./types";
@@ -279,6 +289,17 @@ export interface FundraisingAPIInterface {
279289
getAcquisitionDeals(params?: getAcquisitionDealsParameters): Promise<APIResponseWithMetadata<AcquisitionDeal[]>>;
280290
}
281291

292+
/**
293+
* Interface for the Token Unlocks API methods
294+
*/
295+
export interface TokenUnlocksInterface {
296+
getSupportedAssets(params?: getTokenUnlockSupportedAssetsParameters, options?: RequestOptions): Promise<getTokenUnlockSupportedAssetsResponse>;
297+
getAllocations(params?: getTokenUnlockAllocationsParameters, options?: RequestOptions): Promise<getTokenUnlockAllocationsResponse>;
298+
getVestingSchedule(params: getTokenUnlockVestingScheduleParameters, options?: RequestOptions): Promise<getTokenUnlockVestingScheduleResponse>;
299+
getUnlocks(params: getTokenUnlocksParameters, options?: RequestOptions): Promise<getTokenUnlocksResponse>;
300+
getEvents(params: getTokenUnlockEventsParameters, options?: RequestOptions): Promise<getTokenUnlockEventsResponse>;
301+
}
302+
282303
/**
283304
* Abstract base class for the Messari client
284305
* Defines the structure and common functionality that all client implementations must provide
@@ -314,6 +335,11 @@ export abstract class MessariClientBase {
314335
*/
315336
public abstract readonly research: ResearchInterface;
316337

338+
/**
339+
* Interface for Token Unlocks-related API methods
340+
*/
341+
public abstract readonly tokenUnlocks: TokenUnlocksInterface;
342+
317343
/**
318344
* Logger instance for the client
319345
*/

packages/api/src/client/client.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ import {
2424
getFundingRounds,
2525
getFundingRoundsInvestors,
2626
getAcquisitionDeals,
27+
getTokenUnlockAllocations,
28+
getTokenUnlockEvents,
29+
getTokenUnlockSupportedAssets,
30+
getTokenUnlocks,
31+
getTokenUnlockVestingSchedule,
2732
} from "@messari-kit/types";
2833
import type {
2934
createChatCompletionParameters,
@@ -72,6 +77,16 @@ import type {
7277
getFundingRoundsInvestorsResponse,
7378
getAcquisitionDealsParameters,
7479
getAcquisitionDealsResponse,
80+
getTokenUnlockAllocationsParameters,
81+
getTokenUnlockAllocationsResponse,
82+
getTokenUnlockEventsParameters,
83+
getTokenUnlockEventsResponse,
84+
getTokenUnlockSupportedAssetsParameters,
85+
getTokenUnlockSupportedAssetsResponse,
86+
getTokenUnlocksParameters,
87+
getTokenUnlocksResponse,
88+
getTokenUnlockVestingScheduleParameters,
89+
getTokenUnlockVestingScheduleResponse,
7590
} from "@messari-kit/types";
7691
import type { Agent } from "node:http";
7792
import { pick } from "../utils";
@@ -98,6 +113,7 @@ import type {
98113
NewsInterface,
99114
RecapsAPIInterface,
100115
ResearchInterface,
116+
TokenUnlocksInterface,
101117
} from "./base";
102118
import { MessariClientBase } from "./base";
103119

@@ -810,4 +826,51 @@ export class MessariClient extends MessariClientBase {
810826
});
811827
},
812828
};
829+
830+
public readonly tokenUnlocks: TokenUnlocksInterface = {
831+
getSupportedAssets: async (params: getTokenUnlockSupportedAssetsParameters = {}, options?: RequestOptions) => {
832+
return this.request<getTokenUnlockSupportedAssetsResponse>({
833+
method: getTokenUnlockSupportedAssets.method,
834+
path: getTokenUnlockSupportedAssets.path(),
835+
queryParams: pick(params, getTokenUnlockSupportedAssets.queryParams),
836+
options,
837+
});
838+
},
839+
840+
getAllocations: async (params: getTokenUnlockAllocationsParameters = {}, options?: RequestOptions) => {
841+
return this.request<getTokenUnlockAllocationsResponse>({
842+
method: getTokenUnlockAllocations.method,
843+
path: getTokenUnlockAllocations.path(),
844+
queryParams: pick(params, getTokenUnlockAllocations.queryParams),
845+
options,
846+
});
847+
},
848+
849+
getVestingSchedule: async (params: getTokenUnlockVestingScheduleParameters, options?: RequestOptions) => {
850+
return this.request<getTokenUnlockVestingScheduleResponse>({
851+
method: getTokenUnlockVestingSchedule.method,
852+
path: getTokenUnlockVestingSchedule.path(params),
853+
queryParams: pick(params, getTokenUnlockVestingSchedule.queryParams),
854+
options,
855+
});
856+
},
857+
858+
getUnlocks: async (params: getTokenUnlocksParameters, options?: RequestOptions) => {
859+
return this.request<getTokenUnlocksResponse>({
860+
method: getTokenUnlocks.method,
861+
path: getTokenUnlocks.path(params),
862+
queryParams: pick(params, getTokenUnlocks.queryParams),
863+
options,
864+
});
865+
},
866+
867+
getEvents: async (params: getTokenUnlockEventsParameters, options?: RequestOptions) => {
868+
return this.request<getTokenUnlockEventsResponse>({
869+
method: getTokenUnlockEvents.method,
870+
path: getTokenUnlockEvents.path(params),
871+
queryParams: pick(params, getTokenUnlockEvents.queryParams),
872+
options,
873+
});
874+
},
875+
};
813876
}

packages/examples/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
"clean": "rimraf dist",
99
"start": "tsx src/index.ts",
1010
"start:asset": "tsx src/asset.ts",
11-
"start:intel": "tsx src/intelEvents.ts",
12-
"start:news": "tsx src/newsFeed.ts",
1311
"start:chat": "tsx src/chatCompletion.ts",
12+
"start:diligence": "tsx src/diligence.ts",
13+
"start:fundraising": "tsx src/fundraising.ts",
14+
"start:intel": "tsx src/intelEvents.ts",
1415
"start:marketdata": "tsx src/marketData.ts",
16+
"start:news": "tsx src/newsFeed.ts",
1517
"start:recaps": "tsx src/recaps.ts",
16-
"start:diligence": "tsx src/diligence.ts",
1718
"start:research": "tsx src/research.ts",
18-
"start:fundraising": "tsx src/fundraising.ts"
19+
"start:token-unlocks": "tsx src/tokenUnlocks.ts"
1920
},
2021
"dependencies": {
2122
"@messari-kit/api": "workspace:*",

0 commit comments

Comments
 (0)