@merkl/api 0.20.99 → 0.20.100
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.
@@ -54,7 +54,7 @@ export const CampaignTestController = new Elysia({
|
|
54
54
|
// @dev Starts from the engine db to debug opportunity creation failing and preventing the api db to be filled
|
55
55
|
.post("/metadata", async ({ body }) => {
|
56
56
|
const engineCampaign = CampaignService.createFakeCampaignEngine(body);
|
57
|
-
return await OpportunityService.createFromCampaign(engineCampaign, false,
|
57
|
+
return await OpportunityService.createFromCampaign(engineCampaign, false, true);
|
58
58
|
}, {
|
59
59
|
body: CampaignConfigMinimal,
|
60
60
|
})
|
@@ -69,7 +69,7 @@ export const CampaignTestController = new Elysia({
|
|
69
69
|
]);
|
70
70
|
if (!engineCampaigns.length)
|
71
71
|
throw new NotFoundError("CampaignEnum not found in engine db");
|
72
|
-
return await OpportunityService.createFromCampaign(engineCampaigns[0], false,
|
72
|
+
return await OpportunityService.createFromCampaign(engineCampaigns[0], false, true);
|
73
73
|
}, {
|
74
74
|
query: CampaignUniqueDto,
|
75
75
|
}));
|
@@ -5,6 +5,7 @@ import { CampaignService } from "@/modules/v4/campaign";
|
|
5
5
|
import { CampaignRepository } from "@/modules/v4/campaign/campaign.repository";
|
6
6
|
import { TokenService } from "@/modules/v4/token/token.service";
|
7
7
|
import { UserService } from "@/modules/v4/user/user.service";
|
8
|
+
import { log } from "@/utils/logger";
|
8
9
|
import { Status } from "@db/api";
|
9
10
|
import { Campaign as CampaignEnum } from "@sdk";
|
10
11
|
import moment from "moment";
|
@@ -55,6 +56,8 @@ export class OpportunityService {
|
|
55
56
|
*/
|
56
57
|
static async createFromCampaign(campaign, upsert = false, dryRun = false) {
|
57
58
|
const campaignType = CampaignService.getTypeFromV3(campaign.type);
|
59
|
+
if (dryRun)
|
60
|
+
log.info(`opportunity creation dry run for ${campaign.campaignId} of type ${campaignType}`);
|
58
61
|
const metadata = await OpportunityService.#getMetadata(campaign);
|
59
62
|
const tags = [...((await UserService.findUnique(campaign.creator))?.tags ?? []), ...(campaign?.tags ?? [])];
|
60
63
|
const opportunityId = OpportunityService.hashId({
|
@@ -8,7 +8,7 @@ import { log } from "@/utils/logger";
|
|
8
8
|
import { throwOnInvalidRequiredAddress, throwOnUnsupportedChainId } from "@/utils/throw";
|
9
9
|
import { apiDbClient } from "@db";
|
10
10
|
import { Prisma } from "@db/api";
|
11
|
-
import { ChainInteractionService, DistributionCreatorService, NETWORK_LABELS, bigIntToNumber, } from "@sdk";
|
11
|
+
import { ChainInteractionService, DistributionCreatorService, NETWORK_LABELS, NULL_ADDRESS, bigIntToNumber, } from "@sdk";
|
12
12
|
import { getAddress, parseUnits } from "viem";
|
13
13
|
import { CacheService } from "../cache";
|
14
14
|
import { TTLPresets } from "../cache/cache.model";
|
@@ -77,7 +77,13 @@ export class TokenService {
|
|
77
77
|
return TokenService.fetchBalances(chainId, userAddress, allTokens);
|
78
78
|
}
|
79
79
|
static async fetchOnChain(token) {
|
80
|
-
const onchainData =
|
80
|
+
const onchainData = token.address === NULL_ADDRESS
|
81
|
+
? {
|
82
|
+
name: `${NETWORK_LABELS[token.chainId]} Native Token`,
|
83
|
+
symbol: `${NETWORK_LABELS[token.chainId]} Native Token`,
|
84
|
+
decimals: 18,
|
85
|
+
}
|
86
|
+
: await TokenRepository.getTokenInfo(token);
|
81
87
|
try {
|
82
88
|
// biome-ignore lint/suspicious/noControlCharactersInRegex: <explanation>
|
83
89
|
onchainData.name = Buffer.from(onchainData.name.replace(/\u0000/g, ""), "utf-8").toString("utf-8");
|
@@ -234,15 +240,18 @@ export class TokenService {
|
|
234
240
|
return await TokenRepository.findUniqueOrThrow(id);
|
235
241
|
}
|
236
242
|
catch (err) {
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
+
try {
|
244
|
+
if (err instanceof Prisma.PrismaClientKnownRequestError && err.code === "P2025") {
|
245
|
+
return TokenService.format(await TokenService.fillAndCreate({
|
246
|
+
...token,
|
247
|
+
verified: false,
|
248
|
+
icon: "",
|
249
|
+
}));
|
250
|
+
}
|
243
251
|
}
|
252
|
+
catch { }
|
253
|
+
throw new HttpError(`Failed to fetch or create token ${token.address} on chain ${token.chainId}.`);
|
244
254
|
}
|
245
|
-
throw new HttpError(`Failed to fetch or create token ${token.address} on chain ${token.chainId}.`);
|
246
255
|
}));
|
247
256
|
}
|
248
257
|
static async getValidRewardTokens(chainId) {
|