@merkl/api 0.15.48 → 0.15.49

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.
@@ -148,7 +148,8 @@ const updatePendings = async (data) => {
148
148
  }
149
149
  }
150
150
  const totalRewardIncrease = Object.values(rewardIdToPendingIncrease).reduce((prev, current) => prev + BigInt(current.pendingIncrease), 0n);
151
- log.info(`rewards to create: ${rewardToCreate.length}, to update: ${rewardToUpdate.length}, total reward increase: ${totalRewardIncrease.toString()}`);
151
+ log.info(`total increase: ${totalRewardIncrease.toString()}, rewards to create: ${rewardToCreate.length}, to update: ${rewardToUpdate.length}`);
152
+ log.info(`total increase: ${totalBreakdownIncrease.toString()}, breakdowns to create: ${breakdownToCreate.length}, to update: ${breakdownToUpdate.length}`);
152
153
  if (rewardToCreate.length > 0) {
153
154
  const users = rewardToCreate.map(x => x.recipient);
154
155
  await apiDbClient.user.createMany({ data: users.map(x => ({ address: x, tags: [] })), skipDuplicates: true });
@@ -168,20 +169,21 @@ const updatePendings = async (data) => {
168
169
  }),
169
170
  });
170
171
  }
171
- if (rewardToUpdate.length > 0) {
172
- await apiDbClient.$transaction(rewardToUpdate.map(x => {
173
- const rewardId = Bun.hash(`${data.root}${x.recipient}${rewardTokenId}`).toString();
174
- return apiDbClient.reward.update({
175
- where: {
176
- id: rewardId,
177
- },
178
- data: {
179
- pending: x.pending.toString(),
180
- },
181
- });
182
- }));
172
+ if (breakdownToCreate.length > 0) {
173
+ await apiDbClient.rewardBreakdown.createMany({
174
+ data: breakdownToCreate.map(x => {
175
+ const rewardId = Bun.hash(`${root}${x.recipient}${rewardTokenId}`).toString();
176
+ return {
177
+ reason: x.reason,
178
+ amount: "0",
179
+ pending: x.pending,
180
+ claimed: "0",
181
+ rewardId,
182
+ campaignId,
183
+ };
184
+ }),
185
+ });
183
186
  }
184
- log.info(`breakdowns to create: ${breakdownToCreate.length}, to update: ${breakdownToUpdate.length}, total breakdown increase: ${totalBreakdownIncrease.toString()}`);
185
187
  if (breakdownToUpdate.length > 0) {
186
188
  await apiDbClient.$transaction(breakdownToUpdate.map(x => {
187
189
  return apiDbClient.rewardBreakdown.update({
@@ -198,20 +200,18 @@ const updatePendings = async (data) => {
198
200
  });
199
201
  }));
200
202
  }
201
- if (breakdownToCreate.length > 0) {
202
- await apiDbClient.rewardBreakdown.createMany({
203
- data: breakdownToCreate.map(x => {
204
- const rewardId = Bun.hash(`${root}${x.recipient}${rewardTokenId}`).toString();
205
- return {
206
- reason: x.reason,
207
- amount: "0",
208
- pending: x.pending,
209
- claimed: "0",
210
- rewardId,
211
- campaignId,
212
- };
213
- }),
214
- });
203
+ if (rewardToUpdate.length > 0) {
204
+ await apiDbClient.$transaction(rewardToUpdate.map(x => {
205
+ const rewardId = Bun.hash(`${data.root}${x.recipient}${rewardTokenId}`).toString();
206
+ return apiDbClient.reward.update({
207
+ where: {
208
+ id: rewardId,
209
+ },
210
+ data: {
211
+ pending: x.pending.toString(),
212
+ },
213
+ });
214
+ }));
215
215
  }
216
216
  return { created: breakdownToCreate.length, updated: breakdownToUpdate.length };
217
217
  };