@merkl/api 0.10.217 → 0.10.218
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/src/eden/index.d.ts +3 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/modules/v4/chain/chain.model.d.ts +0 -4
- package/dist/src/modules/v4/chain/chain.model.js +0 -8
- package/dist/src/modules/v4/router.d.ts +1 -0
- package/dist/src/modules/v4/user/user.controller.d.ts +1 -0
- package/dist/src/modules/v4/user/user.controller.js +6 -4
- package/dist/src/modules/v4/user/user.model.d.ts +4 -0
- package/dist/src/modules/v4/user/user.model.js +11 -0
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/src/eden/index.d.ts
CHANGED
@@ -1507,6 +1507,7 @@ declare const eden: {
|
|
1507
1507
|
get: (options: {
|
1508
1508
|
headers?: Record<string, unknown> | undefined;
|
1509
1509
|
query: {
|
1510
|
+
reloadChainId?: number | undefined;
|
1510
1511
|
chainId: number[];
|
1511
1512
|
};
|
1512
1513
|
fetch?: RequestInit | undefined;
|
@@ -4637,6 +4638,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
4637
4638
|
address: string;
|
4638
4639
|
};
|
4639
4640
|
query: {
|
4641
|
+
reloadChainId?: number | undefined;
|
4640
4642
|
chainId: number[];
|
4641
4643
|
};
|
4642
4644
|
headers: unknown;
|
@@ -7689,6 +7691,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
7689
7691
|
get: (options: {
|
7690
7692
|
headers?: Record<string, unknown> | undefined;
|
7691
7693
|
query: {
|
7694
|
+
reloadChainId?: number | undefined;
|
7692
7695
|
chainId: number[];
|
7693
7696
|
};
|
7694
7697
|
fetch?: RequestInit | undefined;
|
package/dist/src/index.d.ts
CHANGED
@@ -19,9 +19,6 @@ export declare const ChainUniqueDto: import("@sinclair/typebox").TObject<{
|
|
19
19
|
export declare const ChainUniqueOptionalDto: import("@sinclair/typebox").TObject<{
|
20
20
|
chainId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
21
21
|
}>;
|
22
|
-
export declare const ChainArrayDto: import("@sinclair/typebox").TObject<{
|
23
|
-
chainId: import("@sinclair/typebox").TTransform<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TNumber>]>, number[]>;
|
24
|
-
}>;
|
25
22
|
export declare const ChainArrayOptionalDto: import("@sinclair/typebox").TObject<{
|
26
23
|
chainIds: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTransform<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TNumber>]>, number[]>>;
|
27
24
|
}>;
|
@@ -38,5 +35,4 @@ export declare const UpdateChainDto: import("@sinclair/typebox").TObject<{
|
|
38
35
|
}>;
|
39
36
|
export type ChainUniqueModel = typeof ChainUniqueDto.static;
|
40
37
|
export type ChainSearchDto = typeof GetChainQueryDto.static;
|
41
|
-
export type ChainsArrayModel = typeof ChainArrayDto.static;
|
42
38
|
export type UpdateChainModel = typeof UpdateChainDto.static;
|
@@ -15,14 +15,6 @@ export const ChainUniqueDto = t.Object({
|
|
15
15
|
export const ChainUniqueOptionalDto = t.Object({
|
16
16
|
chainId: t.Optional(t.Numeric()),
|
17
17
|
});
|
18
|
-
export const ChainArrayDto = t.Object({
|
19
|
-
chainId: t
|
20
|
-
.Transform(t.Union([t.String(), t.Array(t.Numeric())]))
|
21
|
-
.Decode(value => (typeof value === "string" ? value.split(",").map(v => Number.parseInt(v)) : value))
|
22
|
-
.Encode(value => [...value]),
|
23
|
-
}, {
|
24
|
-
description: "A required comma separated list of chain ids.<br>You can get the list of all supported chains by calling [GET /v4/chains](#tag/chains/GET/v4/chains/)",
|
25
|
-
});
|
26
18
|
export const ChainArrayOptionalDto = t.Object({
|
27
19
|
chainIds: t.Optional(t
|
28
20
|
.Transform(t.Union([t.String(), t.Array(t.Numeric())]))
|
@@ -1,9 +1,8 @@
|
|
1
1
|
import { AuthorizationHeadersDto, BackOfficeGuard } from "../../../guards/BackOffice.guard";
|
2
2
|
import { throwOnInvalidRequiredAddress, throwOnUnsupportedChainId } from "../../../utils/throw";
|
3
3
|
import { Elysia, t } from "elysia";
|
4
|
-
import { ChainArrayDto } from "../chain";
|
5
4
|
import { RewardService } from "../reward";
|
6
|
-
import { GetManyUserQuery, OptionalChainIdDto, UpdateUserTagsDto, UserDto, UserRewardsResourceDto, UserUniqueDto, } from "./user.model";
|
5
|
+
import { GetManyUserQuery, OptionalChainIdDto, UpdateUserTagsDto, UserDto, UserRewardRouteDto, UserRewardsResourceDto, UserUniqueDto, } from "./user.model";
|
7
6
|
import { UserService } from "./user.service";
|
8
7
|
// ─── Users Controller ────────────────────────────────────────────────────────
|
9
8
|
export const UserController = new Elysia({ prefix: "/users", detail: { tags: ["Users"] } })
|
@@ -32,14 +31,15 @@ export const UserController = new Elysia({ prefix: "/users", detail: { tags: ["U
|
|
32
31
|
throwOnUnsupportedChainId(chainId);
|
33
32
|
}
|
34
33
|
},
|
34
|
+
detail: { hide: true },
|
35
35
|
})
|
36
36
|
// ─── Get User's Rewards With Breakdown ──────────────────────────────
|
37
37
|
.get("/:address/rewards", async ({ params, query }) => {
|
38
|
-
const rewardsByChain = await RewardService.getUserRewardsByChain(params.address, false, typeof query.chainId === "number" ? [query.chainId] : query.chainId);
|
38
|
+
const rewardsByChain = await RewardService.getUserRewardsByChain(params.address, false, typeof query.chainId === "number" ? [query.chainId] : query.chainId, !!query.reloadChainId ? query.reloadChainId : null);
|
39
39
|
return RewardService.removeOpportunityFromRewardBreakdown(rewardsByChain);
|
40
40
|
}, {
|
41
41
|
params: UserUniqueDto,
|
42
|
-
query:
|
42
|
+
query: UserRewardRouteDto,
|
43
43
|
beforeHandle: ({ query, params }) => {
|
44
44
|
params.address = throwOnInvalidRequiredAddress(params.address);
|
45
45
|
if (typeof query.chainId === "number") {
|
@@ -50,6 +50,8 @@ export const UserController = new Elysia({ prefix: "/users", detail: { tags: ["U
|
|
50
50
|
throwOnUnsupportedChainId(chainId);
|
51
51
|
}
|
52
52
|
}
|
53
|
+
if (!!query.reloadChainId)
|
54
|
+
throwOnUnsupportedChainId(query.reloadChainId);
|
53
55
|
},
|
54
56
|
response: t.Array(UserRewardsResourceDto),
|
55
57
|
detail: { description: "Get the rewards associated to a user on a given chain." },
|
@@ -5,6 +5,10 @@ import type { Resource } from "../prisma";
|
|
5
5
|
* @see {@link Resource}
|
6
6
|
*/
|
7
7
|
export type User = Resource<"User">;
|
8
|
+
export declare const UserRewardRouteDto: import("@sinclair/typebox").TObject<{
|
9
|
+
chainId: import("@sinclair/typebox").TTransform<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TNumber>]>, number[]>;
|
10
|
+
reloadChainId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
11
|
+
}>;
|
8
12
|
export declare const UserRewardsResourceDto: import("@sinclair/typebox").TObject<{
|
9
13
|
chain: import("@sinclair/typebox").TObject<{
|
10
14
|
id: import("@sinclair/typebox").TNumber;
|
@@ -1,6 +1,17 @@
|
|
1
1
|
import { t } from "elysia";
|
2
2
|
import { ChainResourceDto } from "../chain";
|
3
3
|
// ─── Dtos ────────────────────────────────────────────────────────────────────
|
4
|
+
export const UserRewardRouteDto = t.Object({
|
5
|
+
chainId: t
|
6
|
+
.Transform(t.Union([t.String(), t.Array(t.Numeric())]))
|
7
|
+
.Decode(value => (typeof value === "string" ? value.split(",").map(v => Number.parseInt(v)) : value))
|
8
|
+
.Encode(value => [...value]),
|
9
|
+
reloadChainId: t.Optional(t.Numeric({
|
10
|
+
description: "An optional chainId to bypass the cache and check if there was very recently a claim on this chain",
|
11
|
+
})),
|
12
|
+
}, {
|
13
|
+
description: "A required comma separated list of chain ids.<br>You can get the list of all supported chains by calling [GET /v4/chains](#tag/chains/GET/v4/chains/)",
|
14
|
+
});
|
4
15
|
export const UserRewardsResourceDto = t.Object({
|
5
16
|
chain: ChainResourceDto,
|
6
17
|
rewards: t.Array(t.Object({
|