@merkl/api 0.20.149 → 0.20.150
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/eden/index.d.ts +15 -15
- package/dist/src/index.d.ts +5 -5
- package/dist/src/modules/v4/opportunity/opportunity.controller.d.ts +5 -5
- package/dist/src/modules/v4/opportunity/opportunity.controller.js +21 -0
- package/dist/src/modules/v4/opportunity/opportunity.model.d.ts +1 -11
- package/dist/src/modules/v4/opportunity/opportunity.model.js +1 -1
- package/dist/src/modules/v4/router.d.ts +5 -5
- package/dist/src/utils/throw.d.ts +1 -0
- package/dist/src/utils/throw.js +11 -0
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/src/eden/index.d.ts
CHANGED
@@ -648,7 +648,7 @@ declare const eden: {
|
|
648
648
|
tags?: string | undefined;
|
649
649
|
identifier?: string | undefined;
|
650
650
|
page?: number | undefined;
|
651
|
-
action?:
|
651
|
+
action?: string | undefined;
|
652
652
|
campaignId?: string | undefined;
|
653
653
|
creatorAddress?: string | undefined;
|
654
654
|
chainId?: string | undefined;
|
@@ -856,7 +856,7 @@ declare const eden: {
|
|
856
856
|
tags?: string | undefined;
|
857
857
|
identifier?: string | undefined;
|
858
858
|
page?: number | undefined;
|
859
|
-
action?:
|
859
|
+
action?: string | undefined;
|
860
860
|
campaignId?: string | undefined;
|
861
861
|
creatorAddress?: string | undefined;
|
862
862
|
chainId?: string | undefined;
|
@@ -1074,7 +1074,7 @@ declare const eden: {
|
|
1074
1074
|
tags?: string | undefined;
|
1075
1075
|
identifier?: string | undefined;
|
1076
1076
|
page?: number | undefined;
|
1077
|
-
action?:
|
1077
|
+
action?: string | undefined;
|
1078
1078
|
campaignId?: string | undefined;
|
1079
1079
|
creatorAddress?: string | undefined;
|
1080
1080
|
chainId?: string | undefined;
|
@@ -1109,7 +1109,7 @@ declare const eden: {
|
|
1109
1109
|
tags?: string | undefined;
|
1110
1110
|
identifier?: string | undefined;
|
1111
1111
|
page?: number | undefined;
|
1112
|
-
action?:
|
1112
|
+
action?: string | undefined;
|
1113
1113
|
campaignId?: string | undefined;
|
1114
1114
|
creatorAddress?: string | undefined;
|
1115
1115
|
chainId?: string | undefined;
|
@@ -1144,7 +1144,7 @@ declare const eden: {
|
|
1144
1144
|
tags?: string | undefined;
|
1145
1145
|
identifier?: string | undefined;
|
1146
1146
|
page?: number | undefined;
|
1147
|
-
action?:
|
1147
|
+
action?: string | undefined;
|
1148
1148
|
campaignId?: string | undefined;
|
1149
1149
|
creatorAddress?: string | undefined;
|
1150
1150
|
chainId?: string | undefined;
|
@@ -5698,7 +5698,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
5698
5698
|
tags?: string | undefined;
|
5699
5699
|
identifier?: string | undefined;
|
5700
5700
|
page?: number | undefined;
|
5701
|
-
action?:
|
5701
|
+
action?: string | undefined;
|
5702
5702
|
campaignId?: string | undefined;
|
5703
5703
|
creatorAddress?: string | undefined;
|
5704
5704
|
chainId?: string | undefined;
|
@@ -5911,7 +5911,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
5911
5911
|
tags?: string | undefined;
|
5912
5912
|
identifier?: string | undefined;
|
5913
5913
|
page?: number | undefined;
|
5914
|
-
action?:
|
5914
|
+
action?: string | undefined;
|
5915
5915
|
campaignId?: string | undefined;
|
5916
5916
|
creatorAddress?: string | undefined;
|
5917
5917
|
chainId?: string | undefined;
|
@@ -6433,7 +6433,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
6433
6433
|
tags?: string | undefined;
|
6434
6434
|
identifier?: string | undefined;
|
6435
6435
|
page?: number | undefined;
|
6436
|
-
action?:
|
6436
|
+
action?: string | undefined;
|
6437
6437
|
campaignId?: string | undefined;
|
6438
6438
|
creatorAddress?: string | undefined;
|
6439
6439
|
chainId?: string | undefined;
|
@@ -6476,7 +6476,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
6476
6476
|
tags?: string | undefined;
|
6477
6477
|
identifier?: string | undefined;
|
6478
6478
|
page?: number | undefined;
|
6479
|
-
action?:
|
6479
|
+
action?: string | undefined;
|
6480
6480
|
campaignId?: string | undefined;
|
6481
6481
|
creatorAddress?: string | undefined;
|
6482
6482
|
chainId?: string | undefined;
|
@@ -6520,7 +6520,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
6520
6520
|
tags?: string | undefined;
|
6521
6521
|
identifier?: string | undefined;
|
6522
6522
|
page?: number | undefined;
|
6523
|
-
action?:
|
6523
|
+
action?: string | undefined;
|
6524
6524
|
campaignId?: string | undefined;
|
6525
6525
|
creatorAddress?: string | undefined;
|
6526
6526
|
chainId?: string | undefined;
|
@@ -12344,7 +12344,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
12344
12344
|
tags?: string | undefined;
|
12345
12345
|
identifier?: string | undefined;
|
12346
12346
|
page?: number | undefined;
|
12347
|
-
action?:
|
12347
|
+
action?: string | undefined;
|
12348
12348
|
campaignId?: string | undefined;
|
12349
12349
|
creatorAddress?: string | undefined;
|
12350
12350
|
chainId?: string | undefined;
|
@@ -12552,7 +12552,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
12552
12552
|
tags?: string | undefined;
|
12553
12553
|
identifier?: string | undefined;
|
12554
12554
|
page?: number | undefined;
|
12555
|
-
action?:
|
12555
|
+
action?: string | undefined;
|
12556
12556
|
campaignId?: string | undefined;
|
12557
12557
|
creatorAddress?: string | undefined;
|
12558
12558
|
chainId?: string | undefined;
|
@@ -12770,7 +12770,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
12770
12770
|
tags?: string | undefined;
|
12771
12771
|
identifier?: string | undefined;
|
12772
12772
|
page?: number | undefined;
|
12773
|
-
action?:
|
12773
|
+
action?: string | undefined;
|
12774
12774
|
campaignId?: string | undefined;
|
12775
12775
|
creatorAddress?: string | undefined;
|
12776
12776
|
chainId?: string | undefined;
|
@@ -12805,7 +12805,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
12805
12805
|
tags?: string | undefined;
|
12806
12806
|
identifier?: string | undefined;
|
12807
12807
|
page?: number | undefined;
|
12808
|
-
action?:
|
12808
|
+
action?: string | undefined;
|
12809
12809
|
campaignId?: string | undefined;
|
12810
12810
|
creatorAddress?: string | undefined;
|
12811
12811
|
chainId?: string | undefined;
|
@@ -12840,7 +12840,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
12840
12840
|
tags?: string | undefined;
|
12841
12841
|
identifier?: string | undefined;
|
12842
12842
|
page?: number | undefined;
|
12843
|
-
action?:
|
12843
|
+
action?: string | undefined;
|
12844
12844
|
campaignId?: string | undefined;
|
12845
12845
|
creatorAddress?: string | undefined;
|
12846
12846
|
chainId?: string | undefined;
|
package/dist/src/index.d.ts
CHANGED
@@ -465,7 +465,7 @@ declare const app: Elysia<"", false, {
|
|
465
465
|
tags?: string | undefined;
|
466
466
|
identifier?: string | undefined;
|
467
467
|
page?: number | undefined;
|
468
|
-
action?:
|
468
|
+
action?: string | undefined;
|
469
469
|
campaignId?: string | undefined;
|
470
470
|
creatorAddress?: string | undefined;
|
471
471
|
chainId?: string | undefined;
|
@@ -678,7 +678,7 @@ declare const app: Elysia<"", false, {
|
|
678
678
|
tags?: string | undefined;
|
679
679
|
identifier?: string | undefined;
|
680
680
|
page?: number | undefined;
|
681
|
-
action?:
|
681
|
+
action?: string | undefined;
|
682
682
|
campaignId?: string | undefined;
|
683
683
|
creatorAddress?: string | undefined;
|
684
684
|
chainId?: string | undefined;
|
@@ -1200,7 +1200,7 @@ declare const app: Elysia<"", false, {
|
|
1200
1200
|
tags?: string | undefined;
|
1201
1201
|
identifier?: string | undefined;
|
1202
1202
|
page?: number | undefined;
|
1203
|
-
action?:
|
1203
|
+
action?: string | undefined;
|
1204
1204
|
campaignId?: string | undefined;
|
1205
1205
|
creatorAddress?: string | undefined;
|
1206
1206
|
chainId?: string | undefined;
|
@@ -1243,7 +1243,7 @@ declare const app: Elysia<"", false, {
|
|
1243
1243
|
tags?: string | undefined;
|
1244
1244
|
identifier?: string | undefined;
|
1245
1245
|
page?: number | undefined;
|
1246
|
-
action?:
|
1246
|
+
action?: string | undefined;
|
1247
1247
|
campaignId?: string | undefined;
|
1248
1248
|
creatorAddress?: string | undefined;
|
1249
1249
|
chainId?: string | undefined;
|
@@ -1287,7 +1287,7 @@ declare const app: Elysia<"", false, {
|
|
1287
1287
|
tags?: string | undefined;
|
1288
1288
|
identifier?: string | undefined;
|
1289
1289
|
page?: number | undefined;
|
1290
|
-
action?:
|
1290
|
+
action?: string | undefined;
|
1291
1291
|
campaignId?: string | undefined;
|
1292
1292
|
creatorAddress?: string | undefined;
|
1293
1293
|
chainId?: string | undefined;
|
@@ -320,7 +320,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
320
320
|
tags?: string | undefined;
|
321
321
|
identifier?: string | undefined;
|
322
322
|
page?: number | undefined;
|
323
|
-
action?:
|
323
|
+
action?: string | undefined;
|
324
324
|
campaignId?: string | undefined;
|
325
325
|
creatorAddress?: string | undefined;
|
326
326
|
chainId?: string | undefined;
|
@@ -533,7 +533,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
533
533
|
tags?: string | undefined;
|
534
534
|
identifier?: string | undefined;
|
535
535
|
page?: number | undefined;
|
536
|
-
action?:
|
536
|
+
action?: string | undefined;
|
537
537
|
campaignId?: string | undefined;
|
538
538
|
creatorAddress?: string | undefined;
|
539
539
|
chainId?: string | undefined;
|
@@ -1055,7 +1055,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
1055
1055
|
tags?: string | undefined;
|
1056
1056
|
identifier?: string | undefined;
|
1057
1057
|
page?: number | undefined;
|
1058
|
-
action?:
|
1058
|
+
action?: string | undefined;
|
1059
1059
|
campaignId?: string | undefined;
|
1060
1060
|
creatorAddress?: string | undefined;
|
1061
1061
|
chainId?: string | undefined;
|
@@ -1098,7 +1098,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
1098
1098
|
tags?: string | undefined;
|
1099
1099
|
identifier?: string | undefined;
|
1100
1100
|
page?: number | undefined;
|
1101
|
-
action?:
|
1101
|
+
action?: string | undefined;
|
1102
1102
|
campaignId?: string | undefined;
|
1103
1103
|
creatorAddress?: string | undefined;
|
1104
1104
|
chainId?: string | undefined;
|
@@ -1142,7 +1142,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
1142
1142
|
tags?: string | undefined;
|
1143
1143
|
identifier?: string | undefined;
|
1144
1144
|
page?: number | undefined;
|
1145
|
-
action?:
|
1145
|
+
action?: string | undefined;
|
1146
1146
|
campaignId?: string | undefined;
|
1147
1147
|
creatorAddress?: string | undefined;
|
1148
1148
|
chainId?: string | undefined;
|
@@ -3,6 +3,7 @@ import { BackOfficeGuard } from "@/guards/BackOffice.guard";
|
|
3
3
|
import { AuthorizationHeadersDto, TokenAuthGuard } from "@/guards/TokenAuth.guard";
|
4
4
|
import { GetCampaignQueryDto } from "@/modules/v4/campaign/campaign.model";
|
5
5
|
import { log } from "@/utils/logger";
|
6
|
+
import { throwOnUnsupportedActionList } from "@/utils/throw";
|
6
7
|
import { ChainId } from "@sdk";
|
7
8
|
import Elysia, { t } from "elysia";
|
8
9
|
import { CreateOpportunityDto, GetOpportunitiesQueryDto, GetOpportunityQueryDto, OpportunityAggregateFieldDto, OpportunityDeleteOverrideDto, OpportunityOverrideDto, OpportunityResourceDto, OpportunityUniqueDto, OpportunityUniqueUpdateDto, OpportunityWithCampaignsResourceDto, } from "./opportunity.model";
|
@@ -68,11 +69,19 @@ export const OpportunityController = new Elysia({
|
|
68
69
|
description: `**Retrieve Multiple Opportunities**
|
69
70
|
<p>This endpoint enables you to search for opportunities by providing specific criteria through query parameters.</p>`,
|
70
71
|
},
|
72
|
+
beforeHandle: ({ query }) => {
|
73
|
+
if (!!query.action)
|
74
|
+
throwOnUnsupportedActionList(query.action);
|
75
|
+
},
|
71
76
|
response: t.Array(t.Union([OpportunityResourceDto, t.Null()])),
|
72
77
|
})
|
73
78
|
// ─── Get Opportunities Count ─────────────────────────────────────────
|
74
79
|
.get("/count", async ({ query }) => await OpportunityService.countMany(query), {
|
75
80
|
query: GetOpportunitiesQueryDto,
|
81
|
+
beforeHandle: ({ query }) => {
|
82
|
+
if (!!query.action)
|
83
|
+
throwOnUnsupportedActionList(query.action);
|
84
|
+
},
|
76
85
|
detail: { description: "Get the count of opportunities corresponding to the query." },
|
77
86
|
response: { 200: t.Number() },
|
78
87
|
})
|
@@ -163,14 +172,26 @@ export const OpportunityController = new Elysia({
|
|
163
172
|
.get("/aggregate/:field", async ({ query, params }) => await OpportunityService.aggregate(query, params.field), {
|
164
173
|
params: OpportunityAggregateFieldDto,
|
165
174
|
query: GetOpportunitiesQueryDto,
|
175
|
+
beforeHandle: ({ query }) => {
|
176
|
+
if (!!query.action)
|
177
|
+
throwOnUnsupportedActionList(query.action);
|
178
|
+
},
|
166
179
|
})
|
167
180
|
// ─── Get Aggregate Fields ────────────────────────────────────────────
|
168
181
|
.get("/aggregate/max/:field", async ({ query, params }) => await OpportunityService.aggregateMax(query, params.field), {
|
169
182
|
params: OpportunityAggregateFieldDto,
|
170
183
|
query: GetOpportunitiesQueryDto,
|
184
|
+
beforeHandle: ({ query }) => {
|
185
|
+
if (!!query.action)
|
186
|
+
throwOnUnsupportedActionList(query.action);
|
187
|
+
},
|
171
188
|
})
|
172
189
|
// ─── Get Aggregate Fields ────────────────────────────────────────────
|
173
190
|
.get("/aggregate/min/:field", async ({ query, params }) => await OpportunityService.aggregateMin(query, params.field), {
|
174
191
|
params: OpportunityAggregateFieldDto,
|
175
192
|
query: GetOpportunitiesQueryDto,
|
193
|
+
beforeHandle: ({ query }) => {
|
194
|
+
if (!!query.action)
|
195
|
+
throwOnUnsupportedActionList(query.action);
|
196
|
+
},
|
176
197
|
});
|
@@ -309,17 +309,7 @@ export declare const GetOpportunitiesQueryDto: import("@sinclair/typebox").TObje
|
|
309
309
|
search: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
310
310
|
campaignId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
311
311
|
chainId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRegExp>;
|
312
|
-
action: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").
|
313
|
-
POOL: "POOL";
|
314
|
-
HOLD: "HOLD";
|
315
|
-
DROP: "DROP";
|
316
|
-
LEND: "LEND";
|
317
|
-
BORROW: "BORROW";
|
318
|
-
LONG: "LONG";
|
319
|
-
SHORT: "SHORT";
|
320
|
-
SWAP: "SWAP";
|
321
|
-
INVALID: "INVALID";
|
322
|
-
}>>;
|
312
|
+
action: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
323
313
|
type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
324
314
|
creatorAddress: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
325
315
|
tags: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
@@ -59,7 +59,7 @@ export const GetOpportunitiesQueryDto = t.Object({
|
|
59
59
|
chainId: t.Optional(t.RegExp(/^\d+(,\d+)*$/, {
|
60
60
|
description: "A comma separated list of chain ids. Example: ?chainId=1,42161<br>You can get the list of all supported chains by calling [GET /v4/chains](#tag/chains/GET/v4/chains/)",
|
61
61
|
})),
|
62
|
-
action: t.Optional(t.
|
62
|
+
action: t.Optional(t.String({
|
63
63
|
description: `A comma seprated list actions. Legal values are: ${Object.values(OpportunityAction).join(", ")}`,
|
64
64
|
})),
|
65
65
|
type: t.Optional(t.String({ description: "A comma separated list of Opportunity type" })),
|
@@ -335,7 +335,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
335
335
|
tags?: string | undefined;
|
336
336
|
identifier?: string | undefined;
|
337
337
|
page?: number | undefined;
|
338
|
-
action?:
|
338
|
+
action?: string | undefined;
|
339
339
|
campaignId?: string | undefined;
|
340
340
|
creatorAddress?: string | undefined;
|
341
341
|
chainId?: string | undefined;
|
@@ -548,7 +548,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
548
548
|
tags?: string | undefined;
|
549
549
|
identifier?: string | undefined;
|
550
550
|
page?: number | undefined;
|
551
|
-
action?:
|
551
|
+
action?: string | undefined;
|
552
552
|
campaignId?: string | undefined;
|
553
553
|
creatorAddress?: string | undefined;
|
554
554
|
chainId?: string | undefined;
|
@@ -1070,7 +1070,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
1070
1070
|
tags?: string | undefined;
|
1071
1071
|
identifier?: string | undefined;
|
1072
1072
|
page?: number | undefined;
|
1073
|
-
action?:
|
1073
|
+
action?: string | undefined;
|
1074
1074
|
campaignId?: string | undefined;
|
1075
1075
|
creatorAddress?: string | undefined;
|
1076
1076
|
chainId?: string | undefined;
|
@@ -1113,7 +1113,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
1113
1113
|
tags?: string | undefined;
|
1114
1114
|
identifier?: string | undefined;
|
1115
1115
|
page?: number | undefined;
|
1116
|
-
action?:
|
1116
|
+
action?: string | undefined;
|
1117
1117
|
campaignId?: string | undefined;
|
1118
1118
|
creatorAddress?: string | undefined;
|
1119
1119
|
chainId?: string | undefined;
|
@@ -1157,7 +1157,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
1157
1157
|
tags?: string | undefined;
|
1158
1158
|
identifier?: string | undefined;
|
1159
1159
|
page?: number | undefined;
|
1160
|
-
action?:
|
1160
|
+
action?: string | undefined;
|
1161
1161
|
campaignId?: string | undefined;
|
1162
1162
|
creatorAddress?: string | undefined;
|
1163
1163
|
chainId?: string | undefined;
|
@@ -19,3 +19,4 @@ export declare const throwOnInvalidAddress: (address: string | undefined) => str
|
|
19
19
|
* Use this function to throw an error if the chainId is not supported by Merkl
|
20
20
|
*/
|
21
21
|
export declare const throwOnUnsupportedChainId: (chainId: ChainId) => void;
|
22
|
+
export declare const throwOnUnsupportedActionList: (actionList: string) => void;
|
package/dist/src/utils/throw.js
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import { OpportunityAction } from "@db/api";
|
1
2
|
import { isSupportedChain } from "@sdk";
|
2
3
|
import { utils } from "ethers";
|
3
4
|
import { InvalidParameter, UnsupportedNetwork } from "./error";
|
@@ -42,3 +43,13 @@ export const throwOnUnsupportedChainId = (chainId) => {
|
|
42
43
|
if (chainId && !isSupportedChain(chainId, "merkl"))
|
43
44
|
throw new UnsupportedNetwork(chainId);
|
44
45
|
};
|
46
|
+
export const throwOnUnsupportedActionList = (actionList) => {
|
47
|
+
if (!!actionList) {
|
48
|
+
const actions = actionList.split(",");
|
49
|
+
for (const action of actions) {
|
50
|
+
if (!Object.values(OpportunityAction).includes(action)) {
|
51
|
+
throw new Error(`Invalid action: ${action}`);
|
52
|
+
}
|
53
|
+
}
|
54
|
+
}
|
55
|
+
};
|