@merkl/api 0.10.298 → 0.10.300
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 +7 -13
- package/dist/src/index.d.ts +1 -3
- package/dist/src/modules/v4/boost/boost.controller.d.ts +1 -3
- package/dist/src/modules/v4/boost/boost.controller.js +0 -5
- package/dist/src/modules/v4/reward/reward.repository.d.ts +15 -5
- package/dist/src/modules/v4/reward/reward.repository.js +7 -15
- package/dist/src/modules/v4/reward/reward.service.js +24 -17
- package/dist/src/modules/v4/router.d.ts +1 -3
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/src/eden/index.d.ts
CHANGED
@@ -2269,13 +2269,11 @@ declare const eden: {
|
|
2269
2269
|
score: string;
|
2270
2270
|
}[] | {
|
2271
2271
|
addresses: string[];
|
2272
|
-
}, options
|
2273
|
-
headers
|
2274
|
-
authorization: string;
|
2275
|
-
};
|
2272
|
+
}, options?: {
|
2273
|
+
headers?: Record<string, unknown> | undefined;
|
2276
2274
|
query?: Record<string, unknown> | undefined;
|
2277
2275
|
fetch?: RequestInit | undefined;
|
2278
|
-
}) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
2276
|
+
} | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
2279
2277
|
200: {
|
2280
2278
|
address: string;
|
2281
2279
|
boost: string;
|
@@ -5702,9 +5700,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
5702
5700
|
}[];
|
5703
5701
|
params: {};
|
5704
5702
|
query: unknown;
|
5705
|
-
headers:
|
5706
|
-
authorization: string;
|
5707
|
-
};
|
5703
|
+
headers: unknown;
|
5708
5704
|
response: {
|
5709
5705
|
200: {
|
5710
5706
|
address: string;
|
@@ -8744,13 +8740,11 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
8744
8740
|
score: string;
|
8745
8741
|
}[] | {
|
8746
8742
|
addresses: string[];
|
8747
|
-
}, options
|
8748
|
-
headers
|
8749
|
-
authorization: string;
|
8750
|
-
};
|
8743
|
+
}, options?: {
|
8744
|
+
headers?: Record<string, unknown> | undefined;
|
8751
8745
|
query?: Record<string, unknown> | undefined;
|
8752
8746
|
fetch?: RequestInit | undefined;
|
8753
|
-
}) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
8747
|
+
} | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
8754
8748
|
200: {
|
8755
8749
|
address: string;
|
8756
8750
|
boost: string;
|
package/dist/src/index.d.ts
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
import { AuthorizationHeadersDto, BackOfficeGuard } from "../../../guards/BackOffice.guard";
|
2
1
|
import Elysia from "elysia";
|
3
2
|
import { getEulerBoostBody } from "./boost.model";
|
4
3
|
import { BoostService } from "./boost.service";
|
@@ -6,9 +5,5 @@ export const BoostController = new Elysia({ prefix: "/boosts", detail: { tags: [
|
|
6
5
|
// ─── Get Euler Boost ─────────────────────────────────────────────────
|
7
6
|
.post("/euler", async ({ body }) => await BoostService.getEulerBoost(), {
|
8
7
|
body: getEulerBoostBody,
|
9
|
-
headers: AuthorizationHeadersDto,
|
10
|
-
beforeHandle: async ({ headers }) => {
|
11
|
-
await BackOfficeGuard({ headers });
|
12
|
-
},
|
13
8
|
detail: { hide: true },
|
14
9
|
});
|
@@ -126,12 +126,22 @@ export declare abstract class RewardRepository {
|
|
126
126
|
};
|
127
127
|
})[]>;
|
128
128
|
static updateClaimed(recipient: string, rewardTokenId: string, campaignId: string, reason: string, amount: string): Promise<Prisma.BatchPayload>;
|
129
|
-
static findManyBreakdownUniques(
|
129
|
+
static findManyBreakdownUniques(uniques: {
|
130
|
+
rewardId: string;
|
131
|
+
campaignId: string;
|
130
132
|
reason: string;
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
133
|
+
}[]): Promise<({
|
134
|
+
reason: string;
|
135
|
+
pending: string;
|
136
|
+
id: number;
|
137
|
+
campaignId: string;
|
138
|
+
amount: string;
|
139
|
+
protocolId: string | null;
|
140
|
+
claimed: string;
|
141
|
+
auxiliaryData1: string | null;
|
142
|
+
auxiliaryData2: string | null;
|
143
|
+
rewardId: string;
|
144
|
+
} | null)[]>;
|
135
145
|
static upsertPendings(rewardTokenId: string, root: string, campaignId: string, toUpdate: PendingEntity[]): Promise<{
|
136
146
|
reason: string;
|
137
147
|
pending: string;
|
@@ -139,24 +139,16 @@ export class RewardRepository {
|
|
139
139
|
},
|
140
140
|
});
|
141
141
|
}
|
142
|
-
static async findManyBreakdownUniques(
|
143
|
-
return await apiDbClient.rewardBreakdown.
|
142
|
+
static async findManyBreakdownUniques(uniques) {
|
143
|
+
return await apiDbClient.$transaction(uniques.map(x => apiDbClient.rewardBreakdown.findUnique({
|
144
144
|
where: {
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
campaignId,
|
150
|
-
},
|
151
|
-
select: {
|
152
|
-
Reward: {
|
153
|
-
select: {
|
154
|
-
recipient: true,
|
155
|
-
},
|
145
|
+
rewardId_campaignId_reason: {
|
146
|
+
rewardId: x.rewardId,
|
147
|
+
campaignId: x.campaignId,
|
148
|
+
reason: x.reason,
|
156
149
|
},
|
157
|
-
reason: true,
|
158
150
|
},
|
159
|
-
});
|
151
|
+
})));
|
160
152
|
}
|
161
153
|
static async upsertPendings(rewardTokenId, root, campaignId, toUpdate) {
|
162
154
|
const users = toUpdate.map(x => x.recipient);
|
@@ -238,23 +238,30 @@ export class RewardService {
|
|
238
238
|
distributionChain: data.distributionChainId,
|
239
239
|
campaignId: data.campaignId,
|
240
240
|
});
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
241
|
+
let totalCreated = 0;
|
242
|
+
let totalUpdated = 0;
|
243
|
+
const uniques = await data.data.map(({ recipient, reason }) => {
|
244
|
+
const rewardId = RewardService.hashId(data.root, recipient, rewardTokenId);
|
245
|
+
return { rewardId, reason, campaignId };
|
246
|
+
});
|
247
|
+
for (let i = 0; i < uniques.length; i += 1000) {
|
248
|
+
const toUpdate = [];
|
249
|
+
const toCreate = [];
|
250
|
+
const exists = await RewardRepository.findManyBreakdownUniques(uniques.slice(i, Math.min(i + 1000, uniques.length)));
|
251
|
+
for (const [pointIndex, point] of data.data.entries()) {
|
252
|
+
if (!!exists[pointIndex]) {
|
253
|
+
toUpdate.push(point);
|
254
|
+
}
|
255
|
+
else {
|
256
|
+
toCreate.push(point);
|
257
|
+
}
|
258
|
+
}
|
259
|
+
await RewardRepository.updatePendings(rewardTokenId, data.root, campaignId, toUpdate);
|
260
|
+
await RewardRepository.createPendings(rewardTokenId, data.root, campaignId, toCreate);
|
261
|
+
totalCreated += toCreate.length;
|
262
|
+
totalUpdated += toUpdate.length;
|
263
|
+
}
|
264
|
+
return { created: totalCreated, updated: totalUpdated };
|
258
265
|
}
|
259
266
|
static async countAllchains() {
|
260
267
|
const rewardPerRewardTokenId = await RewardRepository.countRewardPerRewardTokenIdAndRoot();
|