Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve indexer request frequence #36

Merged
merged 8 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions packages/common/src/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,16 @@ export abstract class AbstractGraphqlService {
const requestBody = JSON.stringify(options, (key, value) =>
typeof value === "bigint" ? value.toString() : value,
);
const response = await axios.post(query.endpoint, requestBody, {
headers: {
"Content-Type": "application/json",
},
});
let response = null;
try {
response = await axios.post(query.endpoint, requestBody, {
headers: {
"Content-Type": "application/json",
},
});
} catch (e: any) {
throw new Error(`[${query.endpoint}]: \n${requestBody} \n${e}`);
}
const { errors, data } = response.data;
if (errors) {
throw new Error(
Expand Down
20 changes: 9 additions & 11 deletions packages/common/src/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,21 @@ import chalk = require("chalk");
export class Tools {
public static shortLog(options: { input: string; len?: number }): string {
const { input, len } = options;
let output = input;
const maxLength = len ?? input.length;

const envXapiLogFull: any = process.env.XAPI_LOG_FULL;
if (
envXapiLogFull !== 1 ||
envXapiLogFull !== "1" ||
envXapiLogFull !== "true"
envXapiLogFull === 1 ||
envXapiLogFull === "1" ||
envXapiLogFull === "true"
) {
output =
Tools.ellipsisText({
text: input,
len: input.length > maxLength ? maxLength : input.length,
suffix: "...",
}) + chalk.gray("(set XAPI_LOG_FULL=1 to show)");
return input;
}
return output;
return Tools.ellipsisText({
text: input,
len: input.length > maxLength ? maxLength : input.length,
suffix: "...",
}) + chalk.gray("(set XAPI_LOG_FULL=1 to show)");
}

public static ellipsisText(options: {
Expand Down
4 changes: 2 additions & 2 deletions packages/evm-indexer/subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ dataSources:
name: XAPI
network: sepolia
source:
address: "0x6D83b038d5bF428a8C3fF34bf1b380b3A2acA6fe"
address: "0x7DE29a6ee2d6B1BfC4DE88d278107Cf65261f698"
abi: XAPI
startBlock: 6961265
startBlock: 7020836
mapping:
kind: ethereum/events
apiVersion: 0.0.7
Expand Down
Loading
Loading