@atomiqlabs/chain-starknet 7.0.10 → 7.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -37,3 +37,4 @@ export * from "./starknet/spv_swap/StarknetSpvVaultContract";
37
37
  export * from "./starknet/spv_swap/StarknetSpvVaultData";
38
38
  export * from "./starknet/spv_swap/StarknetSpvWithdrawalData";
39
39
  export * from "./starknet/provider/RpcProviderWithRetries";
40
+ export * from "./starknet/provider/WebSocketChannelWithRetries";
package/dist/index.js CHANGED
@@ -56,3 +56,4 @@ __exportStar(require("./starknet/spv_swap/StarknetSpvVaultContract"), exports);
56
56
  __exportStar(require("./starknet/spv_swap/StarknetSpvVaultData"), exports);
57
57
  __exportStar(require("./starknet/spv_swap/StarknetSpvWithdrawalData"), exports);
58
58
  __exportStar(require("./starknet/provider/RpcProviderWithRetries"), exports);
59
+ __exportStar(require("./starknet/provider/WebSocketChannelWithRetries"), exports);
@@ -13,6 +13,7 @@ const StarknetSpvVaultContract_1 = require("./spv_swap/StarknetSpvVaultContract"
13
13
  const StarknetSpvVaultData_1 = require("./spv_swap/StarknetSpvVaultData");
14
14
  const StarknetSpvWithdrawalData_1 = require("./spv_swap/StarknetSpvWithdrawalData");
15
15
  const RpcProviderWithRetries_1 = require("./provider/RpcProviderWithRetries");
16
+ const WebSocketChannelWithRetries_1 = require("./provider/WebSocketChannelWithRetries");
16
17
  exports.StarknetAssets = {
17
18
  ETH: {
18
19
  address: "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
@@ -45,7 +46,7 @@ function initializeStarknet(options, bitcoinRpc, network) {
45
46
  let wsChannel;
46
47
  if (options.wsUrl != null)
47
48
  wsChannel = typeof (options.wsUrl) === "string" ?
48
- new starknet_1.WebSocketChannel({ nodeUrl: options.wsUrl }) :
49
+ new WebSocketChannelWithRetries_1.WebSocketChannelWithRetries({ nodeUrl: options.wsUrl, reconnectOptions: { delay: 2000, retries: Infinity } }) :
49
50
  options.wsUrl;
50
51
  const Fees = options.fees ?? new StarknetFees_1.StarknetFees(provider);
51
52
  const chainId = options.chainId ??
@@ -0,0 +1,7 @@
1
+ import { WebSocketChannel } from "starknet";
2
+ /**
3
+ * An impl of WebSocketChannel which override the default exponential backoff and makes it linear
4
+ */
5
+ export declare class WebSocketChannelWithRetries extends WebSocketChannel {
6
+ reconnect(): void;
7
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WebSocketChannelWithRetries = void 0;
4
+ const starknet_1 = require("starknet");
5
+ /**
6
+ * An impl of WebSocketChannel which override the default exponential backoff and makes it linear
7
+ */
8
+ class WebSocketChannelWithRetries extends starknet_1.WebSocketChannel {
9
+ reconnect() {
10
+ this.reconnectAttempts = 1;
11
+ super.reconnect();
12
+ }
13
+ }
14
+ exports.WebSocketChannelWithRetries = WebSocketChannelWithRetries;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomiqlabs/chain-starknet",
3
- "version": "7.0.10",
3
+ "version": "7.0.11",
4
4
  "description": "Starknet specific base implementation",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
package/src/index.ts CHANGED
@@ -49,3 +49,4 @@ export * from "./starknet/spv_swap/StarknetSpvVaultData";
49
49
  export * from "./starknet/spv_swap/StarknetSpvWithdrawalData";
50
50
 
51
51
  export * from "./starknet/provider/RpcProviderWithRetries";
52
+ export * from "./starknet/provider/WebSocketChannelWithRetries";
@@ -11,6 +11,7 @@ import {StarknetSpvVaultContract} from "./spv_swap/StarknetSpvVaultContract";
11
11
  import {StarknetSpvVaultData} from "./spv_swap/StarknetSpvVaultData";
12
12
  import {StarknetSpvWithdrawalData} from "./spv_swap/StarknetSpvWithdrawalData";
13
13
  import {RpcProviderWithRetries} from "./provider/RpcProviderWithRetries";
14
+ import {WebSocketChannelWithRetries} from "./provider/WebSocketChannelWithRetries";
14
15
 
15
16
  export type StarknetAssetsType = BaseTokenType<"ETH" | "STRK" | "WBTC" | "TBTC" | "_TESTNET_WBTC_VESU">;
16
17
  export const StarknetAssets: StarknetAssetsType = {
@@ -72,7 +73,7 @@ export function initializeStarknet(
72
73
  options.rpcUrl;
73
74
  let wsChannel: WebSocketChannel;
74
75
  if(options.wsUrl!=null) wsChannel = typeof(options.wsUrl)==="string" ?
75
- new WebSocketChannel({nodeUrl: options.wsUrl}) :
76
+ new WebSocketChannelWithRetries({nodeUrl: options.wsUrl, reconnectOptions: {delay: 2000, retries: Infinity}}) :
76
77
  options.wsUrl;
77
78
 
78
79
  const Fees = options.fees ?? new StarknetFees(provider);
@@ -0,0 +1,13 @@
1
+ import {WebSocketChannel} from "starknet";
2
+
3
+ /**
4
+ * An impl of WebSocketChannel which override the default exponential backoff and makes it linear
5
+ */
6
+ export class WebSocketChannelWithRetries extends WebSocketChannel {
7
+
8
+ reconnect() {
9
+ (this as any).reconnectAttempts = 1;
10
+ super.reconnect();
11
+ }
12
+
13
+ }