diff --git a/packages/node/CHANGELOG.md b/packages/node/CHANGELOG.md index 3356c682..e123e2c6 100644 --- a/packages/node/CHANGELOG.md +++ b/packages/node/CHANGELOG.md @@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Removed - Unused deps and deprecated type (#116) +### Fixed +- Timestamp filter not working (#117) + ## [3.10.0] - 2024-04-10 ### Changed - Updated with node-core.Now dictionary support multiple dictionary endpoints, indexer will fetch and switch dictionaries base on available blocks diff --git a/packages/node/package.json b/packages/node/package.json index b626c7e2..4743b38d 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -26,11 +26,10 @@ "@nestjs/schedule": "^3.0.1", "@subql/common": "^3.5.1", "@subql/common-algorand": "workspace:*", - "@subql/node-core": "^10.0.0", + "@subql/node-core": "^10.1.0", "@subql/types-algorand": "workspace:*", "algosdk": "^2.2.0", "axios": "^1.3.4", - "cron-converter": "^1.0.2", "lodash": "^4.17.21", "reflect-metadata": "^0.1.13", "rimraf": "^3.0.2", diff --git a/packages/node/src/algorand/utils.algorand.ts b/packages/node/src/algorand/utils.algorand.ts index 0ccf1834..1237f1d5 100644 --- a/packages/node/src/algorand/utils.algorand.ts +++ b/packages/node/src/algorand/utils.algorand.ts @@ -1,7 +1,7 @@ // Copyright 2020-2024 SubQuery Pte Ltd authors & contributors // SPDX-License-Identifier: GPL-3.0 -import { Header, IBlock } from '@subql/node-core'; +import { filterBlockTimestamp, Header, IBlock } from '@subql/node-core'; import { AlgorandBlock, AlgorandBlockFilter, @@ -10,6 +10,7 @@ import { } from '@subql/types-algorand'; import { Indexer, TransactionType } from 'algosdk'; import { camelCase, get } from 'lodash'; +import { SubqlProjectBlockFilter } from '../configure/SubqueryProject'; import { BlockContent } from '../indexer/types'; export function algorandBlockToHeader(block: BlockContent): Header { @@ -86,6 +87,11 @@ export function filterBlock( ): boolean { if (!filter) return true; if (!filterBlockModulo(block, filter)) return false; + if ( + !filterBlockTimestamp(block.timestamp, filter as SubqlProjectBlockFilter) + ) { + return false; + } // no filters for block. return true; } diff --git a/packages/node/src/configure/SubqueryProject.ts b/packages/node/src/configure/SubqueryProject.ts index 9fd1a91c..97574033 100644 --- a/packages/node/src/configure/SubqueryProject.ts +++ b/packages/node/src/configure/SubqueryProject.ts @@ -13,6 +13,7 @@ import { isCustomDs, } from '@subql/common-algorand'; import { + CronFilter, insertBlockFiltersCronSchedules, loadProjectTemplates, updateDataSourcesV1_0_0, @@ -29,7 +30,6 @@ import { RunnerSpecs, } from '@subql/types-core'; import { buildSchemaFromString } from '@subql/utils'; -import Cron from 'cron-converter'; import { GraphQLSchema } from 'graphql'; const { version: packageVersion } = require('../../package.json'); @@ -38,12 +38,7 @@ export type AlgorandProjectDsTemplate = | RuntimeDatasourceTemplate | CustomDatasourceTemplate; -export type SubqlProjectBlockFilter = BlockFilter & { - cronSchedule?: { - schedule: Cron.Seeker; - next: number; - }; -}; +export type SubqlProjectBlockFilter = BlockFilter & CronFilter; const NOT_SUPPORT = (name: string) => { throw new Error(`Manifest specVersion ${name}() is not supported`); diff --git a/scripts/update_versions.sh b/scripts/update_versions.sh new file mode 100755 index 00000000..f8fba526 --- /dev/null +++ b/scripts/update_versions.sh @@ -0,0 +1,78 @@ +#!/bin/sh +set -e + +LIGHT_BLUE='\033[1;34m' +YELLOW='\033[1;33m' +NC='\033[0m' + +# Function to echo unreleased changes from CHANGELOG.md +echo_unreleased_changes() { + local changelog_file="$1" + + # Check if the provided argument is a valid file + if [ ! -f "$changelog_file" ]; then + echo "Changelog doesn't exist" + return 1 + fi + + # Use sed to extract the line number of the start and end of the unreleased changes + local start_line=$(sed -n '/## \[Unreleased\]/=' "$changelog_file") + local end_line=$(sed -n '/## \[/=' "$changelog_file" | sed -n 2p) + + # Use awk to extract the unreleased changes + local changes=$(awk "NR > $start_line && NR < $end_line" "$changelog_file") + + # Check if there are any changes + if [ -z "$changes" ]; then + echo "No unreleased changes found. Please include some changes and try again" + exit 1 + else + echo "Unreleased Changes:\n${LIGHT_BLUE}$changes${NC}\n" + fi +} + +prepare_package_release() { + local dir="$1" + + # Check if the provided argument is a valid file + if [ ! -d "$dir" ]; then + echo "Expected $dir to be a directory" + exit 1 + fi + + # Movde into the directory in the path + cd "$dir" + + # Get the version from package.json + VERSION=$(jq -r '.version' package.json) + NAME=$(jq -r '.name' package.json) + + # Check if the version is a prerelease (ends with a hyphen and one or more digits) + if [[ $VERSION =~ -[0-9]+$ ]]; then + # Prompt the user for the version bump + echo "Please select the version bump for ${YELLOW}$NAME${NC}" + echo_unreleased_changes "./CHANGELOG.md" + read -p "Version bump (major, minor or patch): " BUMP + + # Update the package.json version + yarn version $BUMP + + # Run the changelog:release command + yarn changelog:release + fi + + # Back to previous dir + cd - +} + +## Warning this will not automatically update packages that just have dependency changes +## E.g. when @subql/common is updated, @subql/common-substrate should also be updated +## It also doesn't do things in order of dependencies +for dir in packages/*; do + # Check the path is a directory and is tracked by git + if [ -d "$dir" ] && [[ $(git ls-files "$dir") ]]; then + prepare_package_release "$dir" + fi +done + +# prepare_package_release "$1" diff --git a/yarn.lock b/yarn.lock index 72c342dc..e968ddc1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2832,7 +2832,7 @@ __metadata: "@nestjs/testing": ^9.4.0 "@subql/common": ^3.5.1 "@subql/common-algorand": "workspace:*" - "@subql/node-core": ^10.0.0 + "@subql/node-core": ^10.1.0 "@subql/types-algorand": "workspace:*" "@types/express": ^4.17.13 "@types/jest": ^27.4.0 @@ -2842,7 +2842,6 @@ __metadata: "@types/yargs": ^16.0.4 algosdk: ^2.2.0 axios: ^1.3.4 - cron-converter: ^1.0.2 dotenv: ^15.0.1 lodash: ^4.17.21 nodemon: ^2.0.15 @@ -2856,9 +2855,9 @@ __metadata: languageName: unknown linkType: soft -"@subql/node-core@npm:^10.0.0": - version: 10.0.0 - resolution: "@subql/node-core@npm:10.0.0" +"@subql/node-core@npm:^10.1.0": + version: 10.1.0 + resolution: "@subql/node-core@npm:10.1.0" dependencies: "@apollo/client": ^3.8.8 "@nestjs/common": ^9.4.0 @@ -2867,10 +2866,11 @@ __metadata: "@subql/common": 3.5.1 "@subql/testing": 2.1.1 "@subql/types": 3.5.0 - "@subql/utils": 2.9.1 + "@subql/utils": 2.9.2 "@willsoto/nestjs-prometheus": ^5.4.0 async-lock: ^1.4.0 async-mutex: ^0.4.0 + cron-converter: ^2.0.1 cross-fetch: ^3.1.6 csv-stringify: ^6.4.5 dayjs: ^1.10.7 @@ -2883,7 +2883,7 @@ __metadata: toposort-class: ^1.0.1 vm2: ^3.9.19 yargs: ^16.2.0 - checksum: c52c304ea23c10a171ef411b877032c88733eb6a2262b4a167de9484f7e1fed567bdc36ad1bcb7f9a610d1774a348bd203dc82dd1f7c52f693ff7756c4097d4f + checksum: b7df8c672e93bc6339d47c4a8c806dd8fca7c1a24e0ce0ac065925928151bc476b8cf9f6149e85c472085f81800d601a79ea6fd8e1e0ca09636b09fdc3371dd0 languageName: node linkType: hard @@ -2928,9 +2928,9 @@ __metadata: languageName: node linkType: hard -"@subql/utils@npm:2.9.1": - version: 2.9.1 - resolution: "@subql/utils@npm:2.9.1" +"@subql/utils@npm:2.9.2": + version: 2.9.2 + resolution: "@subql/utils@npm:2.9.2" dependencies: "@polkadot/util": ^12.5.1 "@polkadot/util-crypto": ^12.5.1 @@ -2946,7 +2946,7 @@ __metadata: rotating-file-stream: ^3.0.2 semver: ^7.5.2 tar: ^6.2.1 - checksum: 555c215f44ac6f6828ade30c3643e260bf99ef3c14381d14a9e9ba3c9fa5cfd0a4e938b3a2fbd907379ad2b832bb79a5071f96966b32d751824affb9cea266c8 + checksum: fd2f32136d0324e3b19e826e4760e90db36e66b580ee244e77fa96124389d3253923c74ab98a07799803ba2421c285b68bc42b295e8a3b48376db34405adb872 languageName: node linkType: hard @@ -5046,13 +5046,12 @@ __metadata: languageName: node linkType: hard -"cron-converter@npm:^1.0.2": - version: 1.0.2 - resolution: "cron-converter@npm:1.0.2" +"cron-converter@npm:^2.0.1": + version: 2.0.1 + resolution: "cron-converter@npm:2.0.1" dependencies: - moment-timezone: ~0.5 - sprintf-js: ~1 - checksum: 7bbd01f29a6fc5a8a8c8dabda3a6468b7040acd374beadbf103d6c86f9e85c961a0937cfa2a997e4bfcdcd6bd07cde658a3009b899130e69e6c9ceb5f0a82ac3 + luxon: ^3.1.0 + checksum: 74ef69ec7e9020183cfa8f117fe687c654ba32f863ae8cf86a834b5baafd1321ee0d9caa62cc8e6e4cfe02b255f237ed0a0f91f0da78d01eb49317d06bf76f3d languageName: node linkType: hard @@ -8595,6 +8594,13 @@ __metadata: languageName: node linkType: hard +"luxon@npm:^3.1.0": + version: 3.4.4 + resolution: "luxon@npm:3.4.4" + checksum: 36c1f99c4796ee4bfddf7dc94fa87815add43ebc44c8934c924946260a58512f0fd2743a629302885df7f35ccbd2d13f178c15df046d0e3b6eb71db178f1c60c + languageName: node + linkType: hard + "luxon@npm:^3.2.1": version: 3.3.0 resolution: "luxon@npm:3.3.0" @@ -8935,7 +8941,7 @@ __metadata: languageName: node linkType: hard -"moment-timezone@npm:^0.5.35, moment-timezone@npm:~0.5": +"moment-timezone@npm:^0.5.35": version: 0.5.43 resolution: "moment-timezone@npm:0.5.43" dependencies: @@ -10754,13 +10760,6 @@ __metadata: languageName: node linkType: hard -"sprintf-js@npm:~1": - version: 1.1.2 - resolution: "sprintf-js@npm:1.1.2" - checksum: d4bb46464632b335e5faed381bd331157e0af64915a98ede833452663bc672823db49d7531c32d58798e85236581fb7342fd0270531ffc8f914e186187bf1c90 - languageName: node - linkType: hard - "sprintf-js@npm:~1.0.2": version: 1.0.3 resolution: "sprintf-js@npm:1.0.3"