Skip to content

Commit 5f0c781

Browse files
committed
chore: update configuration for token price feature
1 parent f534e5f commit 5f0c781

File tree

6 files changed

+279
-243
lines changed

6 files changed

+279
-243
lines changed

package.json

Lines changed: 244 additions & 243 deletions
Large diffs are not rendered by default.

src/entities/entities.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { SwapTransaction } from './swapTransaction';
4040
import { QaccPointsHistory } from './qaccPointsHistory';
4141
import { UserRankMaterializedView } from './userRanksMaterialized';
4242
import { VestingData } from './vestingData';
43+
import { TokenPriceHistory } from './tokenPriceHistory';
4344

4445
export const getEntities = (): DataSourceOptions['entities'] => {
4546
return [
@@ -93,5 +94,6 @@ export const getEntities = (): DataSourceOptions['entities'] => {
9394
SwapTransaction,
9495
UserRankMaterializedView,
9596
VestingData,
97+
TokenPriceHistory,
9698
];
9799
};

src/resolvers/resolvers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { OnboardingFormResolver } from './onboardingFormResolver';
1717
import { RoundsResolver } from './roundsResolver';
1818
import { QAccResolver } from './qAccResolver';
1919
import { QaccPointsHistoryResolver } from './qaccPointsHistoryResolver';
20+
import { TokenPriceResolver } from './tokenPriceResolver';
2021

2122
// eslint-disable-next-line @typescript-eslint/ban-types
2223
export const getResolvers = (): Function[] => {
@@ -44,5 +45,6 @@ export const getResolvers = (): Function[] => {
4445

4546
QAccResolver,
4647
QaccPointsHistoryResolver,
48+
TokenPriceResolver,
4749
];
4850
};

src/server/bootstrap.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ import { ChainType } from '../types/network';
6767
import { runSyncDataWithInverter } from '../services/cronJobs/syncDataWithInverter';
6868
import { runSyncWithAnkrTransfers } from '../services/cronJobs/syncWithAnkrTransfers';
6969
import { runCheckPendingSwapsCronJob } from '../services/cronJobs/syncSwapTransactions';
70+
import { startTokenPriceCron } from '../services/cronJobs/tokenPriceCron';
7071

7172
Resource.validate = validate;
7273

@@ -164,6 +165,8 @@ export async function bootstrap() {
164165

165166
// runUpdateUserRanksCronJob();
166167

168+
startTokenPriceCron();
169+
167170
if (process.env.ENABLE_IMPORT_LOST_DONATIONS === 'true') {
168171
runSyncLostDonations();
169172
}

src/server/createSchema.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { NonEmptyArray } from 'type-graphql';
55
import { userCheck } from '../auth/userCheck';
66
import { getResolvers } from '../resolvers/resolvers';
77
import config from '../config';
8+
import { DateTimeScalar } from '../scalars/dateTime';
89

910
const createSchema = async (): Promise<GraphQLSchema> => {
1011
// James: removing for safety. We shouldn't need to do this again except on a local dev machine
@@ -25,6 +26,7 @@ const createSchema = async (): Promise<GraphQLSchema> => {
2526
forbidUnknownValues: false,
2627
enableDebugMessages: environment !== 'production',
2728
},
29+
scalarsMap: [{ type: Date, scalar: DateTimeScalar }],
2830
});
2931
return schema;
3032
};

test/graphqlQueries.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2288,3 +2288,29 @@ query donationsByQfRoundId($qfRoundId: Int!) {
22882288
}
22892289
}
22902290
`;
2291+
2292+
export const getTokenPriceHistoryQuery = `
2293+
query GetTokenPriceHistory($tokenAddress: String!, $startTime: DateTime, $endTime: DateTime) {
2294+
getTokenPriceHistory(tokenAddress: $tokenAddress, startTime: $startTime, endTime: $endTime) {
2295+
token
2296+
tokenAddress
2297+
price
2298+
priceUSD
2299+
marketCap
2300+
timestamp
2301+
}
2302+
}
2303+
`;
2304+
2305+
export const getTokenMarketCapChanges24hQuery = `
2306+
query GetTokenMarketCapChanges24h($tokenAddress: String!) {
2307+
getTokenMarketCapChanges24h(tokenAddress: $tokenAddress) {
2308+
token
2309+
tokenAddress
2310+
price
2311+
priceUSD
2312+
marketCap
2313+
timestamp
2314+
}
2315+
}
2316+
`;

0 commit comments

Comments
 (0)