@merkl/api 0.10.411 → 0.10.412

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.
@@ -6,7 +6,7 @@ import { apiDbClient } from "../../utils/prisma";
6
6
  import { S3Client } from "bun";
7
7
  import moment from "moment";
8
8
  // ─── Global Variables ────────────────────────────────────────
9
- const [chainIdString, root, campaignId] = process.env.FILENAME.split("_");
9
+ const [chainIdString, root, campaignId] = process.env.FILENAME.replace(".gz", "").split("_");
10
10
  const chainId = Number.parseInt(chainIdString);
11
11
  const gcsClient = new S3Client({
12
12
  accessKeyId: process.env.GCS_ACCESS_ID,
@@ -131,21 +131,21 @@ const updatePendings = async (data) => {
131
131
  }));
132
132
  let users = toCreate.map(x => x.recipient);
133
133
  await apiDbClient.user.createMany({ data: users.map(x => ({ address: x, tags: [] })), skipDuplicates: true });
134
- await apiDbClient.$transaction(toCreate.map(x => {
135
- const rewardId = Bun.hash(`${root}${x.recipient}${rewardTokenId}`).toString();
136
- return apiDbClient.reward.create({
137
- data: {
134
+ await apiDbClient.reward.createMany({
135
+ data: toCreate.map(x => {
136
+ const rewardId = Bun.hash(`${root}${x.recipient}${rewardTokenId}`).toString();
137
+ return {
138
138
  id: rewardId,
139
- MerklRoot: { connect: { root } },
140
- User: { connect: { address: x.recipient } },
141
- RewardToken: { connect: { id: rewardTokenId } },
139
+ root,
140
+ recipient: x.recipient,
141
+ rewardTokenId,
142
142
  proofs: [],
143
143
  amount: "0",
144
144
  pending: x.pending,
145
145
  claimed: "0",
146
- },
147
- });
148
- }));
146
+ };
147
+ }),
148
+ });
149
149
  await apiDbClient.$transaction(breakdownToUpdate.map(x => {
150
150
  return apiDbClient.rewardBreakdown.update({
151
151
  where: {
@@ -162,23 +162,19 @@ const updatePendings = async (data) => {
162
162
  }));
163
163
  users = toCreate.map(x => x.recipient);
164
164
  await apiDbClient.user.createMany({ data: users.map(x => ({ address: x, tags: [] })), skipDuplicates: true });
165
- await apiDbClient.$transaction(breakdownToCreate.map(x => {
166
- const rewardId = Bun.hash(`${root}${x.recipient}${rewardTokenId}`).toString();
167
- return apiDbClient.rewardBreakdown.create({
168
- data: {
165
+ await apiDbClient.rewardBreakdown.createMany({
166
+ data: breakdownToCreate.map(x => {
167
+ const rewardId = Bun.hash(`${root}${x.recipient}${rewardTokenId}`).toString();
168
+ return {
169
169
  reason: x.reason,
170
170
  amount: "0",
171
171
  pending: x.pending,
172
172
  claimed: "0",
173
- Reward: {
174
- connect: {
175
- id: rewardId,
176
- },
177
- },
178
- Campaign: { connect: { id: campaignId } },
179
- },
180
- });
181
- }));
173
+ rewardId,
174
+ campaignId,
175
+ };
176
+ }),
177
+ });
182
178
  return { created: breakdownToCreate.length, updated: breakdownToUpdate.length };
183
179
  };
184
180
  // ─────────────────────────────────────────────────────────────────────────────