@merkl/api 0.10.165 → 0.10.166

Sign up to get free protection for your applications and to get access to all the features.
@@ -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;
@@ -223,7 +223,7 @@ export class RewardRepository {
223
223
  }, { campaignId, amount: 0n });
224
224
  return reducedData;
225
225
  }
226
- static async getUnclaimed(x) {
226
+ static async getAmountAndClaimedForCampaigns(root, x) {
227
227
  return await apiDbClient.rewardBreakdown.findMany({
228
228
  select: {
229
229
  claimed: true,
@@ -234,6 +234,9 @@ export class RewardRepository {
234
234
  campaignId: {
235
235
  in: x.campaignIds.map(campaignId => CampaignService.hashId({ distributionChain: x.chainId, campaignId })),
236
236
  },
237
+ Reward: {
238
+ root,
239
+ },
237
240
  },
238
241
  });
239
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";