Skip to content

Commit

Permalink
Sync @subql dependencies (#64)
Browse files Browse the repository at this point in the history
* Update @subql deps

* Update node-core

---------

Co-authored-by: stwiname <[email protected]>
  • Loading branch information
stwiname and stwiname authored May 2, 2024
1 parent b64b416 commit f61266d
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 21 deletions.
3 changes: 3 additions & 0 deletions packages/node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed
- Unused deps and deprecated type (#63)

### Fixed
- Block timestamp filter not working (#64)

## [3.10.1] - 2024-04-11
### Fixed
- Fixed failed previous release
Expand Down
3 changes: 1 addition & 2 deletions packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@
"@nestjs/schedule": "^3.0.1",
"@subql/common": "^3.5.1",
"@subql/common-stellar": "workspace:*",
"@subql/node-core": "^10.0.0",
"@subql/node-core": "^10.1.0",
"@subql/testing": "^2.0.0",
"@subql/types": "^2.2.1-1",
"@subql/types-stellar": "workspace:*",
"cron-converter": "^1.0.2",
"lodash": "^4.17.21",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
Expand Down
4 changes: 4 additions & 0 deletions packages/node/src/configure/SubqueryProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
isRuntimeDs,
} from '@subql/common-stellar';
import {
CronFilter,
insertBlockFiltersCronSchedules,
ISubqueryProject,
loadProjectTemplates,
Expand All @@ -23,6 +24,7 @@ import {
SubqlDatasource,
CustomDatasourceTemplate,
RuntimeDatasourceTemplate,
StellarBlockFilter,
} from '@subql/types-stellar';
import { buildSchemaFromString } from '@subql/utils';
import { GraphQLSchema } from 'graphql';
Expand All @@ -33,6 +35,8 @@ export type StellarProjectDsTemplate =
| RuntimeDatasourceTemplate
| CustomDatasourceTemplate;

export type SubqlProjectBlockFilter = StellarBlockFilter & CronFilter;

const NOT_SUPPORT = (name: string) => {
throw new Error(`Manifest specVersion ${name} is not supported`);
};
Expand Down
12 changes: 11 additions & 1 deletion packages/node/src/stellar/block.stellar.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
// SPDX-License-Identifier: GPL-3.0

import { filterBlockTimestamp } from '@subql/node-core';
import {
StellarBlock,
StellarBlockFilter,
Expand All @@ -14,7 +15,8 @@ import {
StellarTransaction,
StellarTransactionFilter,
} from '@subql/types-stellar';
import { Address, scValToNative, xdr } from 'stellar-sdk';
import { scValToNative } from 'stellar-sdk';
import { SubqlProjectBlockFilter } from '../configure/SubqueryProject';
import { stringNormalizedEq } from '../utils/string';

export class StellarBlockWrapped implements StellarBlockWrapper {
Expand Down Expand Up @@ -54,6 +56,14 @@ export class StellarBlockWrapped implements StellarBlockWrapper {
if (filter?.modulo && block.sequence % filter.modulo !== 0) {
return false;
}
if (
!filterBlockTimestamp(
new Date(block.closed_at).getTime(),
filter as SubqlProjectBlockFilter,
)
) {
return false;
}
return true;
}

Expand Down
9 changes: 1 addition & 8 deletions packages/types/src/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
// SPDX-License-Identifier: GPL-3.0

import {
StellarBlock,
StellarBlockWrapper,
StellarEffect,
SorobanEvent,
StellarOperation,
StellarTransaction,
} from './stellar';
import {StellarBlock, StellarEffect, SorobanEvent, StellarOperation, StellarTransaction} from './stellar';

export interface BlockWrapper<
B extends StellarBlock = StellarBlock,
Expand Down
78 changes: 78 additions & 0 deletions scripts/update_versions.sh
Original file line number Diff line number Diff line change
@@ -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"
37 changes: 27 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2762,9 +2762,9 @@ __metadata:
languageName: node
linkType: hard

"@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
Expand All @@ -2773,10 +2773,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
Expand All @@ -2789,7 +2790,7 @@ __metadata:
toposort-class: ^1.0.1
vm2: ^3.9.19
yargs: ^16.2.0
checksum: c52c304ea23c10a171ef411b877032c88733eb6a2262b4a167de9484f7e1fed567bdc36ad1bcb7f9a610d1774a348bd203dc82dd1f7c52f693ff7756c4097d4f
checksum: b7df8c672e93bc6339d47c4a8c806dd8fca7c1a24e0ce0ac065925928151bc476b8cf9f6149e85c472085f81800d601a79ea6fd8e1e0ca09636b09fdc3371dd0
languageName: node
linkType: hard

Expand All @@ -2806,7 +2807,7 @@ __metadata:
"@nestjs/testing": ^9.4.0
"@subql/common": ^3.5.1
"@subql/common-stellar": "workspace:*"
"@subql/node-core": ^10.0.0
"@subql/node-core": ^10.1.0
"@subql/testing": ^2.0.0
"@subql/types": ^2.2.1-1
"@subql/types-stellar": "workspace:*"
Expand Down Expand Up @@ -2896,9 +2897,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
Expand All @@ -2914,7 +2915,7 @@ __metadata:
rotating-file-stream: ^3.0.2
semver: ^7.5.2
tar: ^6.2.1
checksum: 555c215f44ac6f6828ade30c3643e260bf99ef3c14381d14a9e9ba3c9fa5cfd0a4e938b3a2fbd907379ad2b832bb79a5071f96966b32d751824affb9cea266c8
checksum: fd2f32136d0324e3b19e826e4760e90db36e66b580ee244e77fa96124389d3253923c74ab98a07799803ba2421c285b68bc42b295e8a3b48376db34405adb872
languageName: node
linkType: hard

Expand Down Expand Up @@ -4932,6 +4933,15 @@ __metadata:
languageName: node
linkType: hard

"cron-converter@npm:^2.0.1":
version: 2.0.1
resolution: "cron-converter@npm:2.0.1"
dependencies:
luxon: ^3.1.0
checksum: 74ef69ec7e9020183cfa8f117fe687c654ba32f863ae8cf86a834b5baafd1321ee0d9caa62cc8e6e4cfe02b255f237ed0a0f91f0da78d01eb49317d06bf76f3d
languageName: node
linkType: hard

"cron@npm:2.4.1":
version: 2.4.1
resolution: "cron@npm:2.4.1"
Expand Down Expand Up @@ -8416,6 +8426,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.4.3
resolution: "luxon@npm:3.4.3"
Expand Down

0 comments on commit f61266d

Please sign in to comment.