Skip to content

Commit

Permalink
Update all projects dependencies (#1775)
Browse files Browse the repository at this point in the history
* Update all projects dependencies

## Project

- Remove `@babel/core`
- Remove `@babel/preset-env`
- Remove `@babel/preset-typescript`
- `eslint`
	- Fix [`@typescript-eslint/no-this-alias`](https://typescript-eslint.io/rules/no-this-alias/) lint rule
	- Fix [`unicorn/prefer-node-protocol`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-node-protocol.md) lint rule (add `node:` prefix for built-in modules)
	- Move `.eslintignore` inside config with `ignorePatterns`
	- Update config annotations
	- Use `ESLINT_USE_FLAT_CONFIG=false` in `pnpm` scripts

## `cli`

- Add `node:` prefix for built-in modules (e.g. `node:fs`)
- Remove `dockerode`
- Remove `tern`
- Upgrade `moduleResolution` to `bundler`, `module` to `ESNext` and `target` to `ESNext` making it an ESM module
- `binary-install-raw`
	- Replace with `binary-install`
- `chokidar`
	- Import type `FSWatcher` as namespace no longer available
	- Remove `await` for `onTrigger` as it's no longer async
- `http-ipfs-client`
	- Migrate from `http-ipfs-client` to `kubo-rpc-client` with dynamic import as it's ESM only[^1]
	- Make `createCompiler` async due to dynamic import
- `immutable`
	- `Map([ [ 'k', 'v' ] ])` or `Map({ k: 'v' })` instead of `Map.of`[^2]
	- Replace `immutable.Collection<ProtocolName, string[]>` with `immutable.Collection<ProtocolName, immutable.List<string>>`
- `js-yaml`
	- Replace `safe*` variants with `load`/`loadall`/`dump`[^3]
- `oclif/core`
	- Use `gluegun.prompt` instead of `ux.prompt`[^4]
	- Fix `prompt` variable assignments from object destructuring (thanks @YaroShkvorets)
	- Migrate to ESM[^5]
- `sync-request` 
	- Replace with async `fetch` call[^6]
	- Make `generateTypes` async and update NEAR test snapshot
- `vitest`
	- Remove `concurrent` for tests using the file system
- `web3-eth-abi`
	- Import `decodeLogs` method directly as there is no more default export
- `yaml`
	- Remove `strOptions`[^7]

## `ts`

- Remove `common/eager_offset.ts`
- `assemblyscript/asc`
	- Use `assemblyscript/asc` as import
	- `asc.main` no longer as callback for error, uses stderr and is async[^8]
	- Remove `asc.ready`[^9]
	- Remove `ascMain` in `package.json`[^10]
	- Replace `Promise.allSettled` with for loop in tests for resolving WASM generation promises in sequence (prevent WASM file corruption since they use same file `outputWasmPath`).
	- Silence warning 235 on compilation about exports[^11]

## `website`

- Fix `eslint` config

## Examples

- `ethereum-basic-event-handlers`
	- Fix `chai` max version to `4.x.x` as `chai 5.x.x` is ESM and `hardhat` doesn't support ESM Typescript projects yet[^12]
	- Rename `ethers.BaseContract.address` to `ethers.BaseContract.target`
	- Remove `@nomiclabs/hardhat-ethers`
	- Remove `@nomiclabs/hardhat-etherscan`
	- Remove `@typechain/ethers-v5`
	- Remove `@typechain/hardhat`
	- Remove `ethers`
	- Remove `hardhat-gas-reporter`
	- Remove `solidity-coverage`
	- Remove `typechain`

[^1]: ipfs/helia#157
[^2]: https://github.com/immutable-js/immutable-js/blob/b3a1c9f13880048d744366ae561c39a34b26190a/CHANGELOG.md#breaking-changes
[^3]: https://github.com/nodeca/js-yaml/blob/0d3ca7a27b03a6c974790a30a89e456007d62976/migrate_v3_to_v4.md#safeload-safeloadall-safedump--load-loadall-dump
[^4]: oclif/core#999
[^5]: https://oclif.io/docs/esm/
[^6]: https://www.npmjs.com/package/sync-request
[^7]: eemeli/yaml#235
[^8]: https://github.com/AssemblyScript/assemblyscript/releases/tag/v0.20.0
[^9]: https://github.com/AssemblyScript/assemblyscript/releases/tag/v0.20.0
[^10]: https://github.com/AssemblyScript/assemblyscript/releases/tag/v0.20.0
[^11]: AssemblyScript/assemblyscript#2277
[^12]: https://hardhat.org/hardhat-runner/docs/advanced/using-esm#esm-and-typescript-projects

---------

Co-authored-by: YaroShkvorets <[email protected]>
  • Loading branch information
0237h and YaroShkvorets authored Dec 9, 2024
1 parent 7d18704 commit 7faa309
Show file tree
Hide file tree
Showing 160 changed files with 9,937 additions and 19,287 deletions.
6 changes: 6 additions & 0 deletions .changeset/green-islands-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@graphprotocol/graph-cli': minor
'@graphprotocol/graph-ts': minor
---

Update all dependencies
11 changes: 0 additions & 11 deletions .eslintignore

This file was deleted.

52 changes: 0 additions & 52 deletions .eslintrc.cjs

This file was deleted.

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ tmp

*.wasm

.idea
.idea
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ packages/cli/tests/cli/init
packages/cli/tests/cli/validation
packages/cli/tests/cli/add
pnpm-lock.yaml
cf-pages/**
website/src/graphql-env.d.ts
1 change: 0 additions & 1 deletion .prettierrc.cjs

This file was deleted.

1 change: 1 addition & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"@theguild/prettier-config"
61 changes: 61 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { FlatCompat } from '@eslint/eslintrc';
import js from '@eslint/js';

// needed to extend the guild config
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [
{
ignores: [
'**/dist',
'packages/cli/tests/cli/validation',
'packages/ts/test/',
'**/examples',
'**/vitest.config.ts',
],
},
...compat.extends('@theguild'),
{
rules: {
'import/extensions': 'off',
'unicorn/no-array-push-push': 'off',
'import/no-default-export': 'off',
'@typescript-eslint/no-explicit-any': 'off',
eqeqeq: 'off',
'@typescript-eslint/no-unused-vars': 'off',
},
},
{
files: ['packages/ts/**'],

rules: {
'@typescript-eslint/no-namespace': 'off',
'sonarjs/no-inverted-boolean-check': 'off',
},
},
{
files: ['packages/cli/**'],

rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['@whatwg-node/fetch'],
message: 'Please use `fetch` from `./packages/cli/src/fetch.ts`.',
},
],
},
],
},
},
];
60 changes: 28 additions & 32 deletions examples/aggregations/check-data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,54 +20,50 @@ sgd=$1
# Note that these substitutions are done for all possible combinations of
# INTV/DUR and TBL
expand() {
query=${1//SGD/$sgd}
if [[ "$query" =~ "INTV" ]]
then
for pair in hour:3600 day:86400
do
intv=${pair%:*}
duration=${pair#*:}
q=${query//INTV/$intv}
q=${q//DUR/$duration}
if [[ "$q" =~ "TBL" ]]
then
for tbl in stats group_1 group_2 group_3 groups
do
echo "${q//TBL/$tbl};"
done
else
echo "$q;"
fi
query=${1//SGD/$sgd}
if [[ "$query" =~ "INTV" ]]; then
for pair in hour:3600 day:86400; do
intv=${pair%:*}
duration=${pair#*:}
q=${query//INTV/$intv}
q=${q//DUR/$duration}
if [[ "$q" =~ "TBL" ]]; then
for tbl in stats group_1 group_2 group_3 groups; do
echo "${q//TBL/$tbl};"
done
else
echo "$query;"
fi
else
echo "$q;"
fi
done
else
echo "$query;"
fi
}

# Max and last must be the same
read -d '' -r max_last <<'EOF'
read -d '' -r max_last << 'EOF'
select count(*) = 0 as TBL_INTV_max_eq_last
from SGD.TBL_INTV
where max != last
EOF

# Min and first must be the same
read -d '' -r min_first <<'EOF'
read -d '' -r min_first << 'EOF'
select count(*) = 0 as TBL_INTV_min_eq_first
from SGD.TBL_INTV
where min != first
EOF

# The sum over block numbers must be correct
read -d '' -r sum_check <<'EOF'
read -d '' -r sum_check << 'EOF'
select count(*) = 0 as stats_INTV_sum_correct
from SGD.stats_INTV
where sum != (last - first + 1)::numeric*(last + first)::numeric/2
and first > 1
EOF

# The timestamps of all buckets are rounded to the beginning of the period
read -d '' -r bucket_timestamp <<'EOF'
read -d '' -r bucket_timestamp << 'EOF'
select count(*) = 0 as TBL_INTV_bucket_timestamp
from SGD.TBL_INTV
where to_timestamp(timestamp)
Expand All @@ -76,7 +72,7 @@ EOF

# The timestamp of the min and max block for all buckets must be between
# the bucket's timestamp plus the bucket's duration
read -d '' -r block_timestamp <<'EOF'
read -d '' -r block_timestamp << 'EOF'
select count(*) = 0 as TBL_INTV_timestamp
from SGD.TBL_INTV s,
SGD.block_time b
Expand All @@ -87,7 +83,7 @@ EOF
# For group_3_hour, since we split the aggregations into 1000 buckets,
# there can only be one or two blocks in each bucket; if there are two,
# they must differ by 1000 blocks
read -d '' -r group3_count_min_max <<'EOF'
read -d '' -r group3_count_min_max << 'EOF'
select count(*) = 0 as count_min_max
from SGD.group_3_hour
where (count = 1 and min != max)
Expand All @@ -96,15 +92,15 @@ select count(*) = 0 as count_min_max
EOF

# Same as previous for 'groups' instead of 'group_3'
read -d '' -r groups_count_min_max <<'EOF'
read -d '' -r groups_count_min_max << 'EOF'
select count(*) = 0 as count_min_max
from SGD.groups_hour
where (count = 1 and min != max)
or (count = 2 and min + 1000 != max)
or count > 2
EOF

read -d '' -r groups_total_min_max <<'EOF'
read -d '' -r groups_total_min_max << 'EOF'
select count(*) = 0 as total_min_max
from SGD.groups_hour
where total_min != group_3
Expand All @@ -118,14 +114,14 @@ EOF
# is g + (g+1000) + (g+2000) + .. + (g + (tc-1)*1000)
# We don't know what the total count should be since each group can contain
# 1 or 2 blocks, but we can at least relate total_count and total_sum
read -d '' -r groups_total_count_sum <<'EOF'
read -d '' -r groups_total_count_sum << 'EOF'
select count(*) = 0 as total_count_sum
from SGD.groups_hour
where total_sum != total_count * (group_3 + 1000 * (total_count::numeric - 1) / 2)
EOF

# Recalculate total count and sum with a window query
read -d '' -r groups_window_totals <<'EOF'
read -d '' -r groups_window_totals << 'EOF'
select count(*) = 0 as window_totals from
(select group_3, total_count, total_sum,
sum(count) over (partition by group_3 order by timestamp) as new_total_count,
Expand All @@ -144,4 +140,4 @@ expand "$block_timestamp"
expand "$group3_count_min_max"
expand "$groups_total_min_max"
expand "$groups_total_count_sum"
expand "$groups_window_totals"
expand "$groups_window_totals"
6 changes: 3 additions & 3 deletions examples/aggregations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"test": "graph test"
},
"dependencies": {
"@graphprotocol/graph-cli": "0.71.2",
"@graphprotocol/graph-ts": "^0.32.0"
"@graphprotocol/graph-cli": "0.90.1",
"@graphprotocol/graph-ts": "^0.35.1"
},
"devDependencies": {
"matchstick-as": "0.5.0"
"matchstick-as": "0.6.0"
}
}
2 changes: 1 addition & 1 deletion examples/arweave-blocks-transactions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"remove-local": "graph remove arweave-example --node http://localhost:8020"
},
"devDependencies": {
"@graphprotocol/graph-cli": "0.71.2",
"@graphprotocol/graph-cli": "0.90.1",
"@graphprotocol/graph-ts": "0.35.1"
}
}
2 changes: 1 addition & 1 deletion examples/cosmos-block-filtering/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"babel-register": "^6.26.0"
},
"devDependencies": {
"@graphprotocol/graph-cli": "0.71.2",
"@graphprotocol/graph-cli": "0.90.1",
"@graphprotocol/graph-ts": "0.35.1",
"mustache": "^4.2.0"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/cosmos-osmosis-token-swaps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"babel-register": "^6.26.0"
},
"devDependencies": {
"@graphprotocol/graph-cli": "0.71.2",
"@graphprotocol/graph-cli": "0.90.1",
"@graphprotocol/graph-ts": "0.35.1"
}
}
4 changes: 2 additions & 2 deletions examples/cosmos-validator-delegations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
"remove-local": "graph remove cosmos-validator-delegations --node http://127.0.0.1:8020"
},
"dependencies": {
"as-proto": "^0.2.3",
"as-proto": "^1.3.0",
"babel-polyfill": "^6.26.0",
"babel-register": "^6.26.0"
},
"devDependencies": {
"@graphprotocol/graph-cli": "0.71.2",
"@graphprotocol/graph-cli": "0.90.1",
"@graphprotocol/graph-ts": "0.35.1",
"mustache": "^4.2.0"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/cosmos-validator-rewards/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"babel-register": "^6.26.0"
},
"devDependencies": {
"@graphprotocol/graph-cli": "0.71.2",
"@graphprotocol/graph-cli": "0.90.1",
"@graphprotocol/graph-ts": "0.35.1",
"mustache": "^4.2.0"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/ethereum-basic-event-handlers/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ typechain-types
# Hardhat files
cache
artifacts/build-info
artifacts/contracts/**/*.dbg.json
artifacts/contracts/**/*.dbg.json
4 changes: 2 additions & 2 deletions examples/ethereum-basic-event-handlers/build/subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dataSources:
name: Gravity
network: test
source:
address: '0x5FbDB2315678afecb367f032d93F642f64180aa3'
address: "0x8f86403A4DE0BB5791fa46B8e795C547942fE4Cf"
abi: Gravity
mapping:
kind: ethereum/events
Expand All @@ -18,7 +18,7 @@ dataSources:
- Gravatar
abis:
- name: Gravity
file: Gravity/artifacts/contracts/Gravity.sol/GravatarRegistry.json
file: Gravity/GravatarRegistry.json
eventHandlers:
- event: NewGravatar(uint256,address,string,string)
handler: handleNewGravatar
Expand Down
Loading

0 comments on commit 7faa309

Please sign in to comment.