diff --git a/.gitignore b/.gitignore index 9029ece..dacbfda 100644 --- a/.gitignore +++ b/.gitignore @@ -106,3 +106,6 @@ dist # TernJS port file .tern-port + +# IDE +.idea \ No newline at end of file diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..3296105 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,7 @@ +{ + "useTabs": true, + "singleQuote": true, + "trailingComma": "all", + "arrowParens": "avoid", + "printWidth": 80 +} diff --git a/src/config.ts b/src/config.ts index 0ab6865..b34195d 100644 --- a/src/config.ts +++ b/src/config.ts @@ -3,10 +3,7 @@ import path from 'path'; import logger from './logger'; dotenv.config({ - path: path.resolve( - __dirname, - `../config/${process.env.NODE_ENV || ''}.env`, - ), + path: path.resolve(__dirname, `../config/${process.env.NODE_ENV || ''}.env`), }); if (!process.env.GIVPOWER_CONTRACT_ADDRESS) { @@ -23,6 +20,7 @@ const config: { nodeUrl: string; pollPeriodSecond: number; subgraphEndpoint: string; + subgraphDomain: string; givpowerContractAddress: string; privateKey: string; unlockPerTransaction: number; @@ -32,6 +30,7 @@ const config: { nodeUrl: process.env.NODE_URL || 'https://rpc.gnosischain.com/', pollPeriodSecond: Number(process.env.POLL_PERIOD_SECOND) || 60, subgraphEndpoint: process.env.SUBGRAPH_ENDPOINT, + subgraphDomain: process.env.SUBGRAPH_DOMAIN || 'https://giveth.io', givpowerContractAddress: process.env.GIVPOWER_CONTRACT_ADDRESS, privateKey: process.env.PRIVATE_KEY || '', unlockPerTransaction: Number(process.env.UNLOCK_PER_TRANSACTION) || 1, diff --git a/src/subgraph.ts b/src/subgraph.ts index 2646e00..9bc5cd6 100644 --- a/src/subgraph.ts +++ b/src/subgraph.ts @@ -64,10 +64,7 @@ const getSubgraphData = async () => { query getUnlockablePositions($lastBlockTimeStamp: Int!) { tokenLocks( first: 100 - where: { - unlocked: false - unlockableAt_lte: $lastBlockTimeStamp - } + where: { unlocked: false, unlockableAt_lte: $lastBlockTimeStamp } orderBy: untilRound orderDirection: asc ) { @@ -85,11 +82,20 @@ const getSubgraphData = async () => { `; try { - subgraphResponse = await request(config.subgraphEndpoint, query, { - lastBlockTimeStamp: currentBlock.timestamp, - }); + console.log('subgraphEndpoint', config.subgraphEndpoint); + subgraphResponse = await request( + config.subgraphEndpoint, + query, + { + lastBlockTimeStamp: currentBlock.timestamp, + }, + { origin: config.subgraphDomain }, + ); } catch (e) { - logger.error('Error getting locked positions from subgraph', e); + logger.error( + 'Error getting locked positions from subgraph', + JSON.stringify(e, null, 2), + ); return undefined; }