Skip to content

Commit

Permalink
Fix unsafe api injecting wrong type (#291)
Browse files Browse the repository at this point in the history
* Fix unsafe api injecting wrong type

* Update changelogs

* Update node-core
  • Loading branch information
stwiname authored May 26, 2024
1 parent 29cdccc commit 1caa844
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 29 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ jobs:
run: |
if [ -n "${{ github.event.head_commit.message }}" ]
then
echo "commit-message=\"${{ github.event.head_commit.message }}\"" >> "$GITHUB_OUTPUT"
echo "commit-message=${{ github.event.head_commit.message }}" >> "$GITHUB_OUTPUT"
else
echo "commit-message=\"$(git log -1 --pretty=%B | head -n 1)\"" >> "$GITHUB_OUTPUT"
commit_message=$(git log -1 --pretty=%B | head -n 1)
echo "commit-message=$commit_message" >> "$GITHUB_OUTPUT"
fi
Build-Publish:
Expand Down
2 changes: 2 additions & 0 deletions packages/node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Fixed
- Wrong value being injected for unsafeApi into sandbox (#291)

## [4.3.1] - 2024-05-02
### Fixed
Expand Down
2 changes: 1 addition & 1 deletion packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@nestjs/schedule": "^3.0.1",
"@subql/common": "^3.5.1",
"@subql/common-ethereum": "workspace:*",
"@subql/node-core": "^10.1.1",
"@subql/node-core": "^10.3.2",
"@subql/testing": "^2.1.1",
"@subql/types-ethereum": "workspace:*",
"cacheable-lookup": "6",
Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/indexer/dictionary/v2/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('rawBlockToEthBlock', () => {
]);
});

it('successfully convers a block', () => {
it('successfully converts a block', () => {
const block = rawBlockToEthBlock(raw, api);

expect(block.getHeader()).toEqual({
Expand Down
13 changes: 12 additions & 1 deletion packages/node/src/indexer/indexer.manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
LightEthereumLog,
} from '@subql/types-ethereum';
import { EthereumProjectDs } from '../configure/SubqueryProject';
import { EthereumApi } from '../ethereum';
import { EthereumApi, EthereumApiService } from '../ethereum';
import {
filterBlocksProcessor,
filterLogsProcessor,
Expand Down Expand Up @@ -97,6 +97,17 @@ export class IndexerManager extends BaseIndexerManager<
return this.apiService.safeApi(block.number);
}

protected getDsProcessor(
ds: SubqlEthereumDataSource,
safeApi: SafeEthProvider,
): IndexerSandbox {
return this.sandboxService.getDsProcessor(
ds,
safeApi,
this.apiService.unsafeApi.api,
);
}

protected async indexBlockData(
block: BlockContent,
dataSources: EthereumProjectDs[],
Expand Down
2 changes: 2 additions & 0 deletions packages/types/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- Type for unsafeApi to from Provider to JsonRpcProvider (#291)

## [3.6.0] - 2024-04-30
### Changed
Expand Down
1 change: 1 addition & 0 deletions packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
],
"dependencies": {
"@ethersproject/abstract-provider": "^5.6.1",
"@ethersproject/providers": "^5.7.2",
"@subql/types-core": "^0.7.0"
}
}
3 changes: 2 additions & 1 deletion packages/types/src/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
// SPDX-License-Identifier: GPL-3.0

import {Provider} from '@ethersproject/abstract-provider';
import {JsonRpcProvider} from '@ethersproject/providers';
import '@subql/types-core/dist/global';

declare global {
const api: Provider;
const unsafeApi: Provider | undefined;
const unsafeApi: JsonRpcProvider | undefined;
}
65 changes: 42 additions & 23 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1744,7 +1744,7 @@ __metadata:
languageName: node
linkType: hard

"@ethersproject/providers@npm:5.7.2":
"@ethersproject/providers@npm:5.7.2, @ethersproject/providers@npm:^5.7.2":
version: 5.7.2
resolution: "@ethersproject/providers@npm:5.7.2"
dependencies:
Expand Down Expand Up @@ -2771,7 +2771,7 @@ __metadata:
languageName: node
linkType: hard

"@polkadot/util-crypto@npm:^12.5.1":
"@polkadot/util-crypto@npm:^12.6.2":
version: 12.6.2
resolution: "@polkadot/util-crypto@npm:12.6.2"
dependencies:
Expand All @@ -2791,7 +2791,7 @@ __metadata:
languageName: node
linkType: hard

"@polkadot/util@npm:12.6.2, @polkadot/util@npm:^12.5.1":
"@polkadot/util@npm:12.6.2, @polkadot/util@npm:^12.6.2":
version: 12.6.2
resolution: "@polkadot/util@npm:12.6.2"
dependencies:
Expand Down Expand Up @@ -3075,7 +3075,25 @@ __metadata:
languageName: unknown
linkType: soft

"@subql/common@npm:3.5.1, @subql/common@npm:^3.5.1":
"@subql/common@npm:3.6.0":
version: 3.6.0
resolution: "@subql/common@npm:3.6.0"
dependencies:
"@subql/types-core": 0.7.0
axios: ^0.28.0
class-transformer: ^0.5.1
class-validator: ^0.14.0
fs-extra: ^10.1.0
ipfs-http-client: 56
js-yaml: ^4.1.0
reflect-metadata: ^0.1.13
semver: ^7.5.2
update-notifier: 5.1.0
checksum: 65c35581969ba31965c1176b57c0881e29e20beb764623cd4fcb5bdf2fb68d632ea8c76149f773514081c4aa23f31be64fbea117dd1c1bbec12196ef1e86199e
languageName: node
linkType: hard

"@subql/common@npm:^3.5.1":
version: 3.5.1
resolution: "@subql/common@npm:3.5.1"
dependencies:
Expand All @@ -3093,18 +3111,18 @@ __metadata:
languageName: node
linkType: hard

"@subql/node-core@npm:^10.1.1":
version: 10.1.1
resolution: "@subql/node-core@npm:10.1.1"
"@subql/node-core@npm:^10.3.2":
version: 10.3.2
resolution: "@subql/node-core@npm:10.3.2"
dependencies:
"@apollo/client": ^3.8.8
"@nestjs/common": ^9.4.0
"@nestjs/event-emitter": ^2.0.0
"@nestjs/schedule": ^3.0.1
"@subql/common": 3.5.1
"@subql/common": 3.6.0
"@subql/testing": 2.1.1
"@subql/types": 3.5.0
"@subql/utils": 2.9.2
"@subql/types": 3.6.0
"@subql/utils": 2.10.0
"@willsoto/nestjs-prometheus": ^5.4.0
async-lock: ^1.4.0
async-mutex: ^0.4.0
Expand All @@ -3122,7 +3140,7 @@ __metadata:
toposort-class: ^1.0.1
vm2: ^3.9.19
yargs: ^16.2.0
checksum: dea91df0b7e18094689f4a8862b76a1de8957fb6e188250ea5337a93b268c477d32bbaf431daf4594b2752bcd5665b317fd4699834db69bfa681e32ce5be225f
checksum: bc73b8e11103c4b25edbcd5385f45043722f883db6a1c7aef1eeebc97dc9dd2b1a7a8c7d60e61b45817aadce1362359cf30bf15001231f407f9ae80aad6a2b12
languageName: node
linkType: hard

Expand All @@ -3139,7 +3157,7 @@ __metadata:
"@nestjs/testing": ^9.4.0
"@subql/common": ^3.5.1
"@subql/common-ethereum": "workspace:*"
"@subql/node-core": ^10.1.1
"@subql/node-core": ^10.3.2
"@subql/testing": ^2.1.1
"@subql/types-ethereum": "workspace:*"
"@types/express": ^4.17.13
Expand Down Expand Up @@ -3188,27 +3206,28 @@ __metadata:
resolution: "@subql/types-ethereum@workspace:packages/types"
dependencies:
"@ethersproject/abstract-provider": ^5.6.1
"@ethersproject/providers": ^5.7.2
"@subql/types-core": ^0.7.0
languageName: unknown
linkType: soft

"@subql/types@npm:3.5.0":
version: 3.5.0
resolution: "@subql/types@npm:3.5.0"
"@subql/types@npm:3.6.0":
version: 3.6.0
resolution: "@subql/types@npm:3.6.0"
dependencies:
"@subql/types-core": 0.7.0
peerDependencies:
"@polkadot/api": ^10
checksum: acecfafa56d3488f9ea25a8dd8d3038b1012f090d9f8c8046c74cbf17b983cf19a3d5711a88cb228bc48ce5d5348c9f0dd881a3eb504f319dcbb9b0c6303c526
"@polkadot/api": ^11
checksum: 38dad7ea774e251b6a62c522732abca79bd540c62c3496f89cca5a0e5d482871ed035883d8873dd19b907d197df7b248027fcb2bcb3fc39f254f1f17f1e73e80
languageName: node
linkType: hard

"@subql/utils@npm:2.9.2":
version: 2.9.2
resolution: "@subql/utils@npm:2.9.2"
"@subql/utils@npm:2.10.0":
version: 2.10.0
resolution: "@subql/utils@npm:2.10.0"
dependencies:
"@polkadot/util": ^12.5.1
"@polkadot/util-crypto": ^12.5.1
"@polkadot/util": ^12.6.2
"@polkadot/util-crypto": ^12.6.2
"@subql/x-sequelize": 6.32.0-0.0.4
ansi-styles: ^6.1.0
chalk: ^4.1.2
Expand All @@ -3221,7 +3240,7 @@ __metadata:
rotating-file-stream: ^3.0.2
semver: ^7.5.2
tar: ^6.2.1
checksum: fd2f32136d0324e3b19e826e4760e90db36e66b580ee244e77fa96124389d3253923c74ab98a07799803ba2421c285b68bc42b295e8a3b48376db34405adb872
checksum: 33ae10bd89c29baa6b70e46764adbde5016ac4ab3ba2143d327e63e6055874ddb12824d0368df563a6fb60a9af6e5dc58e0037b17cefecb346b1916835cca12a
languageName: node
linkType: hard

Expand Down

0 comments on commit 1caa844

Please sign in to comment.