Skip to content

Commit

Permalink
[release] @subql/[email protected]
Browse files Browse the repository at this point in the history
* feat: adapt error

* fix: fix old

* [release] @subql/[email protected]

* chore: revert main file path in package.json

---------

Co-authored-by: Jacob <[email protected]>
  • Loading branch information
cool-firer and icezohu authored Jul 15, 2024
1 parent 1cd8084 commit d84002f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
5 changes: 4 additions & 1 deletion packages/network-support/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.3.0] 2024-07-15

## [1.2.6] 2024-05-20

## [1.2.5] 2024-05-16
Expand Down Expand Up @@ -39,7 +41,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- It's a internal library.

[unreleased]: https://github.com/subquery/network-support/compare/v1.2.6...HEAD
[unreleased]: https://github.com/subquery/network-support/compare/v1.3.0...HEAD
[1.3.0]: https://github.com/subquery/network-support/releases/tag/v1.3.0
[1.2.6]: https://github.com/subquery/network-support/releases/tag/v1.2.6
[1.2.5]: https://github.com/subquery/network-support/releases/tag/v1.2.5
[1.2.4]: https://github.com/subquery/network-support/releases/tag/v1.2.4
Expand Down
2 changes: 1 addition & 1 deletion packages/network-support/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@subql/network-support",
"version": "1.3.0-7",
"version": "1.3.0",
"main": "dist/index.js",
"author": "SubQuery Pte Limited",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/network-support/src/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export function createFetch(
let scoreType = ScoreType.RPC;
const errorObj = safeJSONParse(errorMsg);

if (errorObj?.code && errorObj?.error) {
if (errorObj?.code && (errorObj?.error || errorObj?.message)) {
if (fatalErrorCodes.has(errorObj.code)) {
scoreType = ScoreType.FATAL;
} else if (rpcErrorCodes.has(errorObj.code)) {
Expand Down
21 changes: 13 additions & 8 deletions packages/network-support/src/orderManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,14 +295,19 @@ export class OrderManager {
return [body, state, ''];
}
default:
if (
(typeof payload === 'object' && (payload as any).code) ||
(typeof payload === 'string' && JSON.parse(payload).code)
) {
if (typeof payload === 'string') {
payload = JSON.parse(payload);
}
if ((payload as any).code === 1050 && (payload as any).error === 'PAYG conflict') {
if (typeof payload === 'string') {
payload = JSON.parse(payload);
}
if ((payload as any).error && typeof (payload as any).error === 'object') {
payload = (payload as any).error as { code: number; message: string };
}

if ((payload as any).code) {
if (
(payload as any).code === 1050 &&
((payload as any).error === 'PAYG conflict' ||
(payload as any).message === 'PAYG conflict')
) {
this.stateManager.forceReportInactiveState(channelId);
}
throw new Error(JSON.stringify(payload));
Expand Down

0 comments on commit d84002f

Please sign in to comment.