Skip to content

Commit

Permalink
fix websocket issue (#1024)
Browse files Browse the repository at this point in the history
* fix: fix core type error

* fix: add isomorphic-ws

* feat: add isomorphic-ws ws dependency

---------

Co-authored-by: Valazan <[email protected]>
  • Loading branch information
fabiorigam and Valazan authored Jul 8, 2024
1 parent 8b61a81 commit dfc8993
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/examples/subscriptions/block-subscriptions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { subscriptions } from '@vechain/sdk-network';
import WebSocket from 'ws';
import WebSocket from 'isomorphic-ws';

// The URL of the node to request the subscription from.
const testnetUrl = 'https://testnet.vechain.org';
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/subscriptions/event-subscriptions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { subscriptions } from '@vechain/sdk-network';
import WebSocket from 'ws';
import WebSocket from 'isomorphic-ws';

// The URL of the node to request the subscription from.
const testnetUrl = 'https://testnet.vechain.org';
Expand Down
4 changes: 2 additions & 2 deletions docs/subscriptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Subscribe to specific contract events through the `subscriptions.getEventSubscri

```typescript { name=event-subscriptions, category=example }
import { subscriptions } from '@vechain/sdk-network';
import WebSocket from 'ws';
import WebSocket from 'isomorphic-ws';

// The URL of the node to request the subscription from.
const testnetUrl = 'https://testnet.vechain.org';
Expand Down Expand Up @@ -88,7 +88,7 @@ Subscribe to new blocks as they are added to the blockchain through the `subscri

```typescript { name=block-subscriptions, category=example }
import { subscriptions } from '@vechain/sdk-network';
import WebSocket from 'ws';
import WebSocket from 'isomorphic-ws';

// The URL of the node to request the subscription from.
const testnetUrl = 'https://testnet.vechain.org';
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/hash/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { type BytesLike } from '../abi/types.d';

/**
* Input to hash function.
*/
Expand Down
6 changes: 4 additions & 2 deletions packages/network/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
"@vechain/sdk-errors": "1.0.0-beta.18",
"@vechain/sdk-logging": "1.0.0-beta.18",
"abitype": "^1.0.5",
"axios": "^1.7.2"
"axios": "^1.7.2",
"isomorphic-ws": "^5.0.0",
"ws": "^8.18.0"
}
}
}
2 changes: 1 addition & 1 deletion packages/network/tests/utils/subscriptions/fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { generateRandomValidAddress } from '../../../../core/tests/fixture';
import { vechain_sdk_core_ethers } from '@vechain/sdk-core';
import { TESTING_CONTRACT_ADDRESS } from '../../fixture';
// eslint-disable-next-line import/no-named-default
import { default as NodeWebSocket } from 'ws';
import { default as NodeWebSocket } from 'isomorphic-ws';

/**
* random address for `from` parameter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
THOR_SOLO_ACCOUNTS_BASE_WALLET
} from '../../fixture';
// eslint-disable-next-line import/no-named-default
import { default as NodeWebSocket } from 'ws';
import { default as NodeWebSocket } from 'isomorphic-ws';
import {
addressUtils,
clauseBuilder,
Expand Down
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4933,6 +4933,11 @@ isexe@^2.0.0:
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==

isomorphic-ws@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/isomorphic-ws/-/isomorphic-ws-5.0.0.tgz#e5529148912ecb9b451b46ed44d53dae1ce04bbf"
integrity sha512-muId7Zzn9ywDsyXgTIafTry2sV3nySZeUDe6YedVd1Hvuuep5AsIlqK+XefWpYTyJG5e503F2xIuT2lcU6rCSw==

istanbul-lib-coverage@^3.0.0, istanbul-lib-coverage@^3.2.0:
version "3.2.2"
resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz#2d166c4b0644d43a39f04bf6c2edd1e585f31756"
Expand Down Expand Up @@ -7897,6 +7902,11 @@ ws@^7.4.6:
resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.10.tgz#58b5c20dc281633f6c19113f39b349bd8bd558d9"
integrity sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==

ws@^8.18.0:
version "8.18.0"
resolved "https://registry.yarnpkg.com/ws/-/ws-8.18.0.tgz#0d7505a6eafe2b0e712d232b42279f53bc289bbc"
integrity sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==

xml-name-validator@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-4.0.0.tgz#79a006e2e63149a8600f15430f0a4725d1524835"
Expand Down

1 comment on commit dfc8993

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Coverage

Summary

Lines Statements Branches Functions
Coverage: 100%
100% (3464/3464) 100% (814/814) 100% (718/718)
Title Tests Skipped Failures Errors Time
core 503 0 💤 0 ❌ 0 🔥 1m 9s ⏱️
network 669 0 💤 0 ❌ 0 🔥 3m 56s ⏱️
errors 48 0 💤 0 ❌ 0 🔥 11.427s ⏱️

Please sign in to comment.