@merkl/api 0.10.247 → 0.10.248
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/src/eden/index.d.ts +6 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/modules/v4/reward/reward.repository.d.ts +1 -1
- package/dist/src/modules/v4/reward/reward.repository.js +7 -2
- package/dist/src/modules/v4/reward/reward.service.d.ts +2 -2
- package/dist/src/modules/v4/reward/reward.service.js +4 -4
- package/dist/src/modules/v4/router.d.ts +2 -0
- package/dist/src/modules/v4/user/user.controller.d.ts +2 -0
- package/dist/src/modules/v4/user/user.controller.js +2 -2
- package/dist/src/modules/v4/user/user.model.d.ts +2 -0
- package/dist/src/modules/v4/user/user.model.js +2 -0
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/src/eden/index.d.ts
CHANGED
@@ -1436,6 +1436,7 @@ declare const eden: {
|
|
1436
1436
|
get: (options: {
|
1437
1437
|
headers?: Record<string, unknown> | undefined;
|
1438
1438
|
query: {
|
1439
|
+
test?: boolean | undefined;
|
1439
1440
|
chainIds?: number[] | undefined;
|
1440
1441
|
reloadChainId?: number | undefined;
|
1441
1442
|
};
|
@@ -1541,6 +1542,7 @@ declare const eden: {
|
|
1541
1542
|
get: (options: {
|
1542
1543
|
headers?: Record<string, unknown> | undefined;
|
1543
1544
|
query: {
|
1545
|
+
test?: boolean | undefined;
|
1544
1546
|
reloadChainId?: number | undefined;
|
1545
1547
|
chainId: number[];
|
1546
1548
|
};
|
@@ -4564,6 +4566,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
4564
4566
|
address: string;
|
4565
4567
|
};
|
4566
4568
|
query: {
|
4569
|
+
test?: boolean | undefined;
|
4567
4570
|
chainIds?: number[] | undefined;
|
4568
4571
|
reloadChainId?: number | undefined;
|
4569
4572
|
};
|
@@ -4680,6 +4683,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
4680
4683
|
address: string;
|
4681
4684
|
};
|
4682
4685
|
query: {
|
4686
|
+
test?: boolean | undefined;
|
4683
4687
|
reloadChainId?: number | undefined;
|
4684
4688
|
chainId: number[];
|
4685
4689
|
};
|
@@ -7624,6 +7628,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
7624
7628
|
get: (options: {
|
7625
7629
|
headers?: Record<string, unknown> | undefined;
|
7626
7630
|
query: {
|
7631
|
+
test?: boolean | undefined;
|
7627
7632
|
chainIds?: number[] | undefined;
|
7628
7633
|
reloadChainId?: number | undefined;
|
7629
7634
|
};
|
@@ -7729,6 +7734,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
7729
7734
|
get: (options: {
|
7730
7735
|
headers?: Record<string, unknown> | undefined;
|
7731
7736
|
query: {
|
7737
|
+
test?: boolean | undefined;
|
7732
7738
|
reloadChainId?: number | undefined;
|
7733
7739
|
chainId: number[];
|
7734
7740
|
};
|
package/dist/src/index.d.ts
CHANGED
@@ -1824,6 +1824,7 @@ declare const app: Elysia<"", false, {
|
|
1824
1824
|
address: string;
|
1825
1825
|
};
|
1826
1826
|
query: {
|
1827
|
+
test?: boolean | undefined;
|
1827
1828
|
chainIds?: number[] | undefined;
|
1828
1829
|
reloadChainId?: number | undefined;
|
1829
1830
|
};
|
@@ -1940,6 +1941,7 @@ declare const app: Elysia<"", false, {
|
|
1940
1941
|
address: string;
|
1941
1942
|
};
|
1942
1943
|
query: {
|
1944
|
+
test?: boolean | undefined;
|
1943
1945
|
reloadChainId?: number | undefined;
|
1944
1946
|
chainId: number[];
|
1945
1947
|
};
|
@@ -4,7 +4,7 @@ import type { BreakdownForCampaignsRaw, CampaignIdModel, CampaignIdWithoutPageMo
|
|
4
4
|
export declare abstract class RewardRepository {
|
5
5
|
static createManyReward(rewards: CreateManyRewardModel): Promise<Prisma.BatchPayload>;
|
6
6
|
static createManyBreakdown(data: CreateManyBreakdownModel): Promise<Prisma.BatchPayload>;
|
7
|
-
static getByRecipient(recipient: string, roots: string[], withToken: boolean, chainFilter?: ChainId[]): Promise<({
|
7
|
+
static getByRecipient(recipient: string, roots: string[], withToken: boolean, withTestTokens: boolean, chainFilter?: ChainId[]): Promise<({
|
8
8
|
RewardToken: {
|
9
9
|
symbol: string;
|
10
10
|
name: string | null;
|
@@ -52,14 +52,19 @@ export class RewardRepository {
|
|
52
52
|
data: breakdownsToCreate,
|
53
53
|
});
|
54
54
|
}
|
55
|
-
static async getByRecipient(recipient, roots, withToken, chainFilter) {
|
55
|
+
static async getByRecipient(recipient, roots, withToken, withTestTokens, chainFilter) {
|
56
56
|
return await apiDbClient.reward.findMany({
|
57
57
|
where: {
|
58
58
|
root: {
|
59
59
|
in: roots,
|
60
60
|
},
|
61
61
|
recipient,
|
62
|
-
|
62
|
+
RewardToken: !!chainFilter?.length || !withTestTokens
|
63
|
+
? {
|
64
|
+
chainId: !!chainFilter?.length ? { in: chainFilter } : undefined,
|
65
|
+
isTest: withTestTokens ? undefined : false,
|
66
|
+
}
|
67
|
+
: undefined,
|
63
68
|
},
|
64
69
|
include: {
|
65
70
|
Breakdown: {
|
@@ -158,7 +158,7 @@ export declare abstract class RewardService {
|
|
158
158
|
proofs: string[];
|
159
159
|
}[];
|
160
160
|
static createManyBreakdown(data: CreateManyBreakdownModel): Promise<import("../../../../database/api/.generated").Prisma.BatchPayload | undefined>;
|
161
|
-
static getByRecipient(recipient: string, roots: string[], withToken?: boolean, chainFilter?: ChainId[]): Promise<({
|
161
|
+
static getByRecipient(recipient: string, roots: string[], withToken?: boolean, withTestTokens?: boolean, chainFilter?: ChainId[]): Promise<({
|
162
162
|
RewardToken: {
|
163
163
|
symbol: string;
|
164
164
|
name: string | null;
|
@@ -543,7 +543,7 @@ export declare abstract class RewardService {
|
|
543
543
|
root: string;
|
544
544
|
proofs: string[];
|
545
545
|
})[]>;
|
546
|
-
static getUserRewardsByChain(user: string, withToken: boolean, chainFilter?: ChainId[], connectedChainId?: MerklChainId | null): Promise<{
|
546
|
+
static getUserRewardsByChain(user: string, withToken: boolean, chainFilter?: ChainId[], connectedChainId?: MerklChainId | null, withTestTokens?: boolean): Promise<{
|
547
547
|
chain: Chain;
|
548
548
|
rewards: Awaited<ReturnType<(typeof RewardService)["format"]>>;
|
549
549
|
}[]>;
|
@@ -83,8 +83,8 @@ export class RewardService {
|
|
83
83
|
log.error(`createManyBreakdown - error creating many breakdowns for campaigns ${foundCampaigns.join(", ")}`, e);
|
84
84
|
}
|
85
85
|
}
|
86
|
-
static async getByRecipient(recipient, roots, withToken = false, chainFilter) {
|
87
|
-
return RewardRepository.getByRecipient(recipient, roots, withToken, chainFilter);
|
86
|
+
static async getByRecipient(recipient, roots, withToken = false, withTestTokens = false, chainFilter) {
|
87
|
+
return RewardRepository.getByRecipient(recipient, roots, withToken, withTestTokens, chainFilter);
|
88
88
|
}
|
89
89
|
/**
|
90
90
|
* Groups a breakdown array by their corresponding opportunities
|
@@ -172,7 +172,7 @@ export class RewardService {
|
|
172
172
|
}
|
173
173
|
return rewards;
|
174
174
|
}
|
175
|
-
static async getUserRewardsByChain(user, withToken, chainFilter = [], connectedChainId = null) {
|
175
|
+
static async getUserRewardsByChain(user, withToken, chainFilter = [], connectedChainId = null, withTestTokens = false) {
|
176
176
|
const chains = await ChainService.findMany();
|
177
177
|
let chainIds = !chainFilter || !chainFilter.length
|
178
178
|
? chains.map(({ id }) => id)
|
@@ -190,7 +190,7 @@ export class RewardService {
|
|
190
190
|
.filter(({ status }) => status === "fulfilled")
|
191
191
|
.map(x => x.value);
|
192
192
|
/** Load rewards from api DB */
|
193
|
-
const rewards = (await RewardService.getByRecipient(user, merkleRoots.map(({ live }) => live), withToken)).filter(reward => chainIds.includes(reward.RewardToken.chainId));
|
193
|
+
const rewards = (await RewardService.getByRecipient(user, merkleRoots.map(({ live }) => live), withToken, withTestTokens)).filter(reward => chainIds.includes(reward.RewardToken.chainId));
|
194
194
|
const promises = [];
|
195
195
|
for (const [index, chainId] of chainIds.entries()) {
|
196
196
|
const chain = chains.find(chain => chain.id === chainId);
|
@@ -1702,6 +1702,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
1702
1702
|
address: string;
|
1703
1703
|
};
|
1704
1704
|
query: {
|
1705
|
+
test?: boolean | undefined;
|
1705
1706
|
chainIds?: number[] | undefined;
|
1706
1707
|
reloadChainId?: number | undefined;
|
1707
1708
|
};
|
@@ -1818,6 +1819,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
1818
1819
|
address: string;
|
1819
1820
|
};
|
1820
1821
|
query: {
|
1822
|
+
test?: boolean | undefined;
|
1821
1823
|
reloadChainId?: number | undefined;
|
1822
1824
|
chainId: number[];
|
1823
1825
|
};
|
@@ -83,6 +83,7 @@ export declare const UserController: Elysia<"/users", false, {
|
|
83
83
|
address: string;
|
84
84
|
};
|
85
85
|
query: {
|
86
|
+
test?: boolean | undefined;
|
86
87
|
chainIds?: number[] | undefined;
|
87
88
|
reloadChainId?: number | undefined;
|
88
89
|
};
|
@@ -199,6 +200,7 @@ export declare const UserController: Elysia<"/users", false, {
|
|
199
200
|
address: string;
|
200
201
|
};
|
201
202
|
query: {
|
203
|
+
test?: boolean | undefined;
|
202
204
|
reloadChainId?: number | undefined;
|
203
205
|
chainId: number[];
|
204
206
|
};
|
@@ -18,7 +18,7 @@ export const UserController = new Elysia({ prefix: "/users", detail: { tags: ["U
|
|
18
18
|
})
|
19
19
|
// ─── Get User's Rewards With Breakdown And Details for our FE ────────
|
20
20
|
.get("/:address/rewards/breakdowns", async ({ params, query }) => {
|
21
|
-
const rewardsByChain = await RewardService.getUserRewardsByChain(params.address, true, query?.chainIds, query.reloadChainId ?? null);
|
21
|
+
const rewardsByChain = await RewardService.getUserRewardsByChain(params.address, true, query?.chainIds, query.reloadChainId ?? null, !!query.test ? query.test : false);
|
22
22
|
return RewardService.splitRewardsBreakdownByOpportunity(rewardsByChain);
|
23
23
|
}, {
|
24
24
|
params: UserUniqueDto,
|
@@ -35,7 +35,7 @@ export const UserController = new Elysia({ prefix: "/users", detail: { tags: ["U
|
|
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, !!query.reloadChainId ? query.reloadChainId : null);
|
38
|
+
const rewardsByChain = await RewardService.getUserRewardsByChain(params.address, false, typeof query.chainId === "number" ? [query.chainId] : query.chainId, !!query.reloadChainId ? query.reloadChainId : null, !!query.test ? query.test : false);
|
39
39
|
return RewardService.removeOpportunityFromRewardBreakdown(rewardsByChain);
|
40
40
|
}, {
|
41
41
|
params: UserUniqueDto,
|
@@ -8,6 +8,7 @@ export type User = Resource<"User">;
|
|
8
8
|
export declare const UserRewardRouteDto: import("@sinclair/typebox").TObject<{
|
9
9
|
chainId: import("@sinclair/typebox").TTransform<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TNumber>]>, number[]>;
|
10
10
|
reloadChainId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
11
|
+
test: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
11
12
|
}>;
|
12
13
|
export declare const UserRewardsResourceDto: import("@sinclair/typebox").TObject<{
|
13
14
|
chain: import("@sinclair/typebox").TObject<{
|
@@ -45,6 +46,7 @@ export declare const UserUniqueDto: import("@sinclair/typebox").TObject<{
|
|
45
46
|
export declare const OptionalChainIdDto: import("@sinclair/typebox").TObject<{
|
46
47
|
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[]>>;
|
47
48
|
reloadChainId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
49
|
+
test: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
48
50
|
}>;
|
49
51
|
export declare const UserDto: import("@sinclair/typebox").TObject<{
|
50
52
|
address: import("@sinclair/typebox").TString;
|
@@ -9,6 +9,7 @@ export const UserRewardRouteDto = t.Object({
|
|
9
9
|
reloadChainId: t.Optional(t.Numeric({
|
10
10
|
description: "An optional chainId to bypass the cache and check if there was very recently a claim on this chain",
|
11
11
|
})),
|
12
|
+
test: t.Optional(t.Boolean({ description: "Include test token rewards" })),
|
12
13
|
}, {
|
13
14
|
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
15
|
});
|
@@ -47,6 +48,7 @@ export const OptionalChainIdDto = t.Object({
|
|
47
48
|
.Decode(value => (typeof value === "string" ? value.split(",").map(v => Number.parseInt(v)) : value))
|
48
49
|
.Encode(value => [...value])),
|
49
50
|
reloadChainId: t.Optional(t.Numeric()),
|
51
|
+
test: t.Optional(t.Boolean({ description: "Include test token rewards" })),
|
50
52
|
});
|
51
53
|
export const UserDto = t.Object({
|
52
54
|
address: t.String(),
|