@merkl/api 0.10.164 → 0.10.166

Sign up to get free protection for your applications and to get access to all the features.
@@ -175,6 +175,7 @@ export type UserRewardV3Model = typeof UserRewardV3Dto.static;
175
175
  export type RewardV3Model = typeof RewardV3Dto.static;
176
176
  export type BreakdownForCampaignsRaw = {
177
177
  amount: string;
178
+ claimed: string;
178
179
  recipient: string;
179
180
  campaignId: string;
180
181
  reason: string;
@@ -149,7 +149,7 @@ export declare abstract class RewardRepository {
149
149
  campaignId: string;
150
150
  amount: bigint;
151
151
  }>;
152
- static getUnclaimed(x: CampaignIdWithoutPageModel): Promise<{
152
+ static getAmountAndClaimedForCampaigns(root: string, x: CampaignIdWithoutPageModel): Promise<{
153
153
  campaignId: string;
154
154
  amount: string;
155
155
  claimed: string;
@@ -186,6 +186,7 @@ export class RewardRepository {
186
186
  SELECT
187
187
  rb."amount",
188
188
  rb."reason",
189
+ rb."claimed",
189
190
  r."recipient",
190
191
  t."address" as "rewardTokenAddress"
191
192
  FROM
@@ -222,7 +223,7 @@ export class RewardRepository {
222
223
  }, { campaignId, amount: 0n });
223
224
  return reducedData;
224
225
  }
225
- static async getUnclaimed(x) {
226
+ static async getAmountAndClaimedForCampaigns(root, x) {
226
227
  return await apiDbClient.rewardBreakdown.findMany({
227
228
  select: {
228
229
  claimed: true,
@@ -233,6 +234,9 @@ export class RewardRepository {
233
234
  campaignId: {
234
235
  in: x.campaignIds.map(campaignId => CampaignService.hashId({ distributionChain: x.chainId, campaignId })),
235
236
  },
237
+ Reward: {
238
+ root,
239
+ },
236
240
  },
237
241
  });
238
242
  }
@@ -264,7 +264,8 @@ export class RewardService {
264
264
  acc[CampaignService.hashId({ distributionChain: x.chainId, campaignId })] = campaignId;
265
265
  return acc;
266
266
  }, {});
267
- const data = await RewardRepository.getUnclaimed(x);
267
+ const currentRoot = await MerklRootService.fetch(x.chainId);
268
+ const data = await RewardRepository.getAmountAndClaimedForCampaigns(currentRoot.live, x);
268
269
  return data.reduce((acc, { amount, campaignId, claimed }) => {
269
270
  if (!acc[campaignToCampaignIds[campaignId]])
270
271
  acc[campaignToCampaignIds[campaignId]] = "0";