@merkl/api 0.20.68 → 0.20.70
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.
package/dist/database/index.js
CHANGED
@@ -4,7 +4,7 @@ import { drizzle } from "drizzle-orm/prisma/pg";
|
|
4
4
|
export const apiDbClient = new ApiPrismaClient({
|
5
5
|
datasources: {
|
6
6
|
db: {
|
7
|
-
url: `${process.env.DATABASE_API_URL}&connection_limit=${!!process.env.BACKOFFICE_SECRET ? "
|
7
|
+
url: `${process.env.DATABASE_API_URL}&connection_limit=${!!process.env.BACKOFFICE_SECRET ? "200" : "10"}&pool_timeout=60`,
|
8
8
|
},
|
9
9
|
},
|
10
10
|
}).$extends(drizzle());
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import { Campaign, type CampaignDynamicData
|
1
|
+
import { Campaign, type CampaignDynamicData } from "@sdk";
|
2
2
|
export type CampaignsCacheUpdaterReturnType = {
|
3
3
|
[type_mainParameter: string]: {
|
4
4
|
[campaignId: string]: CampaignDynamicData<Campaign>;
|
5
5
|
};
|
6
6
|
};
|
7
|
-
export declare const main: (
|
7
|
+
export declare const main: () => Promise<{
|
8
8
|
success: boolean;
|
9
9
|
}>;
|
@@ -7,15 +7,18 @@ import { dynamicDataBuilderFactory } from "@/engine/dynamicData/factory";
|
|
7
7
|
import { campaignsToOldFormat } from "@/libs/deprecated-merklv3";
|
8
8
|
import { merklChainData } from "@/libs/merklChainData";
|
9
9
|
import { staticCampaignWithCache } from "@/libs/staticCampaigns";
|
10
|
-
import { ChainService } from "@/modules/v4/chain/chain.service";
|
11
10
|
import { log } from "@/utils/logger";
|
12
11
|
import { ALL_CAMPAIGNS_FOR_CHAIN_AFTER } from "@/utils/queries/allCampaigns";
|
13
12
|
import { engineDbClient } from "@db";
|
14
|
-
import { Campaign, ChainId, NETWORK_LABELS
|
13
|
+
import { Campaign, ChainId, NETWORK_LABELS } from "@sdk";
|
15
14
|
import moment from "moment";
|
15
|
+
// ─── Required Env Variables ──────────────────────────────────────────────────
|
16
|
+
const chainId = Number(process.env.CHAIN_ID);
|
17
|
+
if (!chainId)
|
18
|
+
throw new Error("Environment variable CHAIN_ID is required.");
|
16
19
|
const queryCampaignTypes = process.env.CAMPAIGN_TYPES ? JSON.parse(process.env.CAMPAIGN_TYPES) : [];
|
17
20
|
const highCampaignsChains = [ChainId.ARBITRUM, ChainId.POLYGON, ChainId.BLAST, ChainId.BASE];
|
18
|
-
export const main = async (
|
21
|
+
export const main = async () => {
|
19
22
|
let success = true;
|
20
23
|
try {
|
21
24
|
await Redis.safeSet(`MerklChainData_${chainId}`, await merklChainData(chainId));
|
@@ -125,13 +128,11 @@ export const main = async (chainId) => {
|
|
125
128
|
}
|
126
129
|
return { success };
|
127
130
|
};
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
.then(success => (success ? process.exit(0) : process.exit(1)))
|
134
|
-
.catch((err) => {
|
131
|
+
try {
|
132
|
+
await main();
|
133
|
+
process.exit(0);
|
134
|
+
}
|
135
|
+
catch (err) {
|
135
136
|
console.error(err);
|
136
137
|
process.exit(1);
|
137
|
-
}
|
138
|
+
}
|
@@ -62,8 +62,14 @@ export class TokenService {
|
|
62
62
|
* @param additionalTokens balances along with the verified ones
|
63
63
|
*/
|
64
64
|
static async fetchVerifiedAndNativeBalances(chainId, userAddress, additionalTokenAddresses) {
|
65
|
-
const verifiedTokens = await TokenService.findMany
|
66
|
-
|
65
|
+
const verifiedTokens = await CacheService.wrap(TTLPresets.MIN_5, TokenService.findMany, {
|
66
|
+
chainId,
|
67
|
+
verified: true,
|
68
|
+
});
|
69
|
+
const nativeTokens = (await CacheService.wrap(TTLPresets.MIN_5, TokenService.findMany, {
|
70
|
+
chainId,
|
71
|
+
isNative: true,
|
72
|
+
})).filter(t => !!t);
|
67
73
|
const additionalTokens = !!additionalTokenAddresses?.length
|
68
74
|
? await TokenService.findManyOrCreate(additionalTokenAddresses?.map(address => ({ chainId, address })))
|
69
75
|
: [];
|