@atomiqlabs/chain-starknet 8.0.13 → 8.1.10
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 +18 -18
- package/dist/index.js +42 -42
- package/dist/starknet/StarknetChainType.d.ts +19 -19
- package/dist/starknet/StarknetChainType.js +2 -2
- package/dist/starknet/StarknetInitializer.d.ts +66 -63
- package/dist/starknet/StarknetInitializer.js +101 -101
- package/dist/starknet/btcrelay/BtcRelayAbi.d.ts +250 -250
- package/dist/starknet/btcrelay/BtcRelayAbi.js +341 -341
- package/dist/starknet/btcrelay/StarknetBtcRelay.d.ts +196 -196
- package/dist/starknet/btcrelay/StarknetBtcRelay.js +419 -411
- package/dist/starknet/btcrelay/headers/StarknetBtcHeader.d.ts +70 -70
- package/dist/starknet/btcrelay/headers/StarknetBtcHeader.js +115 -115
- package/dist/starknet/btcrelay/headers/StarknetBtcStoredHeader.d.ts +91 -91
- package/dist/starknet/btcrelay/headers/StarknetBtcStoredHeader.js +155 -155
- package/dist/starknet/chain/StarknetAction.d.ts +19 -19
- package/dist/starknet/chain/StarknetAction.js +74 -74
- package/dist/starknet/chain/StarknetChainInterface.d.ts +142 -143
- package/dist/starknet/chain/StarknetChainInterface.js +198 -199
- package/dist/starknet/chain/StarknetModule.d.ts +8 -8
- package/dist/starknet/chain/StarknetModule.js +12 -12
- package/dist/starknet/chain/modules/ERC20Abi.d.ts +755 -755
- package/dist/starknet/chain/modules/ERC20Abi.js +1032 -1032
- package/dist/starknet/chain/modules/StarknetAccounts.d.ts +6 -6
- package/dist/starknet/chain/modules/StarknetAccounts.js +26 -26
- package/dist/starknet/chain/modules/StarknetAddresses.d.ts +10 -10
- package/dist/starknet/chain/modules/StarknetAddresses.js +27 -27
- package/dist/starknet/chain/modules/StarknetBlocks.d.ts +27 -27
- package/dist/starknet/chain/modules/StarknetBlocks.js +82 -82
- package/dist/starknet/chain/modules/StarknetEvents.d.ts +47 -47
- package/dist/starknet/chain/modules/StarknetEvents.js +90 -90
- package/dist/starknet/chain/modules/StarknetFees.d.ts +118 -104
- package/dist/starknet/chain/modules/StarknetFees.js +150 -146
- package/dist/starknet/chain/modules/StarknetSignatures.d.ts +29 -29
- package/dist/starknet/chain/modules/StarknetSignatures.js +72 -72
- package/dist/starknet/chain/modules/StarknetTokens.d.ts +66 -66
- package/dist/starknet/chain/modules/StarknetTokens.js +99 -99
- package/dist/starknet/chain/modules/StarknetTransactions.d.ts +122 -115
- package/dist/starknet/chain/modules/StarknetTransactions.js +633 -612
- package/dist/starknet/contract/StarknetContractBase.d.ts +14 -13
- package/dist/starknet/contract/StarknetContractBase.js +21 -20
- package/dist/starknet/contract/StarknetContractModule.d.ts +8 -8
- package/dist/starknet/contract/StarknetContractModule.js +11 -11
- package/dist/starknet/contract/modules/StarknetContractEvents.d.ts +56 -57
- package/dist/starknet/contract/modules/StarknetContractEvents.js +111 -111
- package/dist/starknet/events/StarknetChainEvents.d.ts +21 -21
- package/dist/starknet/events/StarknetChainEvents.js +61 -61
- package/dist/starknet/events/StarknetChainEventsBrowser.d.ts +178 -190
- package/dist/starknet/events/StarknetChainEventsBrowser.js +523 -582
- package/dist/starknet/provider/RpcProviderWithRetries.d.ts +49 -53
- package/dist/starknet/provider/RpcProviderWithRetries.js +94 -94
- package/dist/starknet/provider/WebSocketChannelWithRetries.d.ts +21 -21
- package/dist/starknet/provider/WebSocketChannelWithRetries.js +46 -46
- package/dist/starknet/spv_swap/SpvVaultContractAbi.d.ts +488 -488
- package/dist/starknet/spv_swap/SpvVaultContractAbi.js +656 -656
- package/dist/starknet/spv_swap/StarknetSpvVaultContract.d.ts +225 -219
- package/dist/starknet/spv_swap/StarknetSpvVaultContract.js +663 -621
- package/dist/starknet/spv_swap/StarknetSpvVaultData.d.ts +108 -108
- package/dist/starknet/spv_swap/StarknetSpvVaultData.js +190 -190
- package/dist/starknet/spv_swap/StarknetSpvWithdrawalData.d.ts +56 -56
- package/dist/starknet/spv_swap/StarknetSpvWithdrawalData.js +103 -103
- package/dist/starknet/swaps/EscrowManagerAbi.d.ts +431 -431
- package/dist/starknet/swaps/EscrowManagerAbi.js +583 -583
- package/dist/starknet/swaps/StarknetSwapContract.d.ts +309 -278
- package/dist/starknet/swaps/StarknetSwapContract.js +755 -579
- package/dist/starknet/swaps/StarknetSwapData.d.ts +234 -234
- package/dist/starknet/swaps/StarknetSwapData.js +474 -474
- package/dist/starknet/swaps/StarknetSwapModule.d.ts +10 -10
- package/dist/starknet/swaps/StarknetSwapModule.js +12 -12
- package/dist/starknet/swaps/handlers/IHandler.d.ts +13 -13
- package/dist/starknet/swaps/handlers/IHandler.js +2 -2
- package/dist/starknet/swaps/handlers/claim/ClaimHandlers.d.ts +13 -13
- package/dist/starknet/swaps/handlers/claim/ClaimHandlers.js +13 -13
- package/dist/starknet/swaps/handlers/claim/HashlockClaimHandler.d.ts +21 -21
- package/dist/starknet/swaps/handlers/claim/HashlockClaimHandler.js +44 -44
- package/dist/starknet/swaps/handlers/claim/btc/BitcoinNoncedOutputClaimHandler.d.ts +24 -24
- package/dist/starknet/swaps/handlers/claim/btc/BitcoinNoncedOutputClaimHandler.js +48 -48
- package/dist/starknet/swaps/handlers/claim/btc/BitcoinOutputClaimHandler.d.ts +25 -25
- package/dist/starknet/swaps/handlers/claim/btc/BitcoinOutputClaimHandler.js +40 -40
- package/dist/starknet/swaps/handlers/claim/btc/BitcoinTxIdClaimHandler.d.ts +20 -20
- package/dist/starknet/swaps/handlers/claim/btc/BitcoinTxIdClaimHandler.js +30 -30
- package/dist/starknet/swaps/handlers/claim/btc/IBitcoinClaimHandler.d.ts +42 -45
- package/dist/starknet/swaps/handlers/claim/btc/IBitcoinClaimHandler.js +50 -54
- package/dist/starknet/swaps/handlers/refund/TimelockRefundHandler.d.ts +17 -17
- package/dist/starknet/swaps/handlers/refund/TimelockRefundHandler.js +27 -27
- package/dist/starknet/swaps/modules/StarknetLpVault.d.ts +67 -67
- package/dist/starknet/swaps/modules/StarknetLpVault.js +122 -122
- package/dist/starknet/swaps/modules/StarknetSwapClaim.d.ts +52 -52
- package/dist/starknet/swaps/modules/StarknetSwapClaim.js +99 -99
- package/dist/starknet/swaps/modules/StarknetSwapInit.d.ts +94 -94
- package/dist/starknet/swaps/modules/StarknetSwapInit.js +239 -239
- package/dist/starknet/swaps/modules/StarknetSwapRefund.d.ts +60 -60
- package/dist/starknet/swaps/modules/StarknetSwapRefund.js +126 -126
- package/dist/starknet/wallet/StarknetBrowserSigner.d.ts +11 -11
- package/dist/starknet/wallet/StarknetBrowserSigner.js +17 -17
- package/dist/starknet/wallet/StarknetPersistentSigner.d.ts +76 -76
- package/dist/starknet/wallet/StarknetPersistentSigner.js +291 -291
- package/dist/starknet/wallet/StarknetSigner.d.ts +72 -72
- package/dist/starknet/wallet/StarknetSigner.js +114 -114
- package/dist/starknet/wallet/accounts/StarknetKeypairWallet.d.ts +18 -18
- package/dist/starknet/wallet/accounts/StarknetKeypairWallet.js +45 -45
- package/dist/utils/Utils.d.ts +77 -77
- package/dist/utils/Utils.js +304 -303
- package/package.json +2 -2
- package/src/starknet/StarknetInitializer.ts +6 -3
- package/src/starknet/btcrelay/StarknetBtcRelay.ts +19 -6
- package/src/starknet/btcrelay/headers/StarknetBtcHeader.ts +7 -7
- package/src/starknet/btcrelay/headers/StarknetBtcStoredHeader.ts +6 -6
- package/src/starknet/chain/StarknetAction.ts +1 -0
- package/src/starknet/chain/StarknetChainInterface.ts +0 -2
- package/src/starknet/chain/modules/StarknetFees.ts +15 -2
- package/src/starknet/chain/modules/StarknetTransactions.ts +24 -0
- package/src/starknet/contract/StarknetContractBase.ts +7 -4
- package/src/starknet/contract/StarknetContractModule.ts +1 -1
- package/src/starknet/contract/modules/StarknetContractEvents.ts +7 -7
- package/src/starknet/events/StarknetChainEventsBrowser.ts +2 -64
- package/src/starknet/provider/RpcProviderWithRetries.ts +1 -1
- package/src/starknet/spv_swap/StarknetSpvVaultContract.ts +84 -18
- package/src/starknet/swaps/StarknetSwapContract.ts +242 -6
- package/src/starknet/swaps/handlers/claim/btc/IBitcoinClaimHandler.ts +0 -4
|
@@ -1,53 +1,49 @@
|
|
|
1
|
-
import { RPC09, RPC010, RpcProvider, RpcProviderOptions } from "starknet";
|
|
2
|
-
/**
|
|
3
|
-
* @private
|
|
4
|
-
*/
|
|
5
|
-
export declare class Rpc09ChannelWithRetries extends RPC09.RpcChannel {
|
|
6
|
-
readonly retryPolicy
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
delay?: number;
|
|
51
|
-
exponential?: boolean;
|
|
52
|
-
});
|
|
53
|
-
}
|
|
1
|
+
import { RPC09, RPC010, RpcProvider, RpcProviderOptions } from "starknet";
|
|
2
|
+
/**
|
|
3
|
+
* @private
|
|
4
|
+
*/
|
|
5
|
+
export declare class Rpc09ChannelWithRetries extends RPC09.RpcChannel {
|
|
6
|
+
private readonly retryPolicy?;
|
|
7
|
+
constructor(options?: RpcProviderOptions, retryPolicy?: {
|
|
8
|
+
maxRetries?: number;
|
|
9
|
+
delay?: number;
|
|
10
|
+
exponential?: boolean;
|
|
11
|
+
});
|
|
12
|
+
protected fetchEndpoint(method: any, params?: any): Promise<any>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* @private
|
|
16
|
+
*/
|
|
17
|
+
export declare class Rpc010ChannelWithRetries extends RPC010.RpcChannel {
|
|
18
|
+
readonly retryPolicy?: {
|
|
19
|
+
maxRetries?: number;
|
|
20
|
+
delay?: number;
|
|
21
|
+
exponential?: boolean;
|
|
22
|
+
};
|
|
23
|
+
constructor(options?: RpcProviderOptions, retryPolicy?: {
|
|
24
|
+
maxRetries?: number;
|
|
25
|
+
delay?: number;
|
|
26
|
+
exponential?: boolean;
|
|
27
|
+
});
|
|
28
|
+
protected fetchEndpoint(method: any, params?: any): Promise<any>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* An RPC provider with built-in retry functionality, retries calls to the RPC service on failure
|
|
32
|
+
*
|
|
33
|
+
* @category Providers
|
|
34
|
+
*/
|
|
35
|
+
export declare class RpcProviderWithRetries extends RpcProvider {
|
|
36
|
+
/**
|
|
37
|
+
* Creates a new RPC provider which retries RPC calls on failure, controlled by the passed `retryPolicy`
|
|
38
|
+
* NOTE: Tries to do naive detection of the spec version based on the suffix of nodeUrl, better pass the `options.specVersion`
|
|
39
|
+
* in the options!
|
|
40
|
+
*
|
|
41
|
+
* @param options
|
|
42
|
+
* @param retryPolicy
|
|
43
|
+
*/
|
|
44
|
+
constructor(options?: RpcProviderOptions, retryPolicy?: {
|
|
45
|
+
maxRetries?: number;
|
|
46
|
+
delay?: number;
|
|
47
|
+
exponential?: boolean;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RpcProviderWithRetries = exports.Rpc010ChannelWithRetries = exports.Rpc09ChannelWithRetries = void 0;
|
|
4
|
-
const starknet_1 = require("starknet");
|
|
5
|
-
const Utils_1 = require("../../utils/Utils");
|
|
6
|
-
/**
|
|
7
|
-
* @private
|
|
8
|
-
*/
|
|
9
|
-
class Rpc09ChannelWithRetries extends starknet_1.RPC09.RpcChannel {
|
|
10
|
-
constructor(options, retryPolicy) {
|
|
11
|
-
super(options);
|
|
12
|
-
this.retryPolicy = retryPolicy;
|
|
13
|
-
}
|
|
14
|
-
fetchEndpoint(method, params) {
|
|
15
|
-
return (0, Utils_1.tryWithRetries)(() => super.fetchEndpoint(method, params), this.retryPolicy, e => {
|
|
16
|
-
if (!e.message.startsWith("RPC: "))
|
|
17
|
-
return false;
|
|
18
|
-
if (e.message.includes("Unsupported method"))
|
|
19
|
-
return true;
|
|
20
|
-
const arr = e.message.split("\n");
|
|
21
|
-
const errorCode = parseInt(arr[arr.length - 1]);
|
|
22
|
-
if (isNaN(errorCode))
|
|
23
|
-
return false;
|
|
24
|
-
if (errorCode < 0)
|
|
25
|
-
return false; //Not defined error, e.g. Rate limit (-32097)
|
|
26
|
-
return true;
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.Rpc09ChannelWithRetries = Rpc09ChannelWithRetries;
|
|
31
|
-
/**
|
|
32
|
-
* @private
|
|
33
|
-
*/
|
|
34
|
-
class Rpc010ChannelWithRetries extends starknet_1.RPC010.RpcChannel {
|
|
35
|
-
constructor(options, retryPolicy) {
|
|
36
|
-
super(options);
|
|
37
|
-
this.retryPolicy = retryPolicy;
|
|
38
|
-
}
|
|
39
|
-
fetchEndpoint(method, params) {
|
|
40
|
-
return (0, Utils_1.tryWithRetries)(() => super.fetchEndpoint(method, params), this.retryPolicy, e => {
|
|
41
|
-
if (!e.message.startsWith("RPC: "))
|
|
42
|
-
return false;
|
|
43
|
-
if (e.message.includes("Unsupported method"))
|
|
44
|
-
return true;
|
|
45
|
-
const arr = e.message.split("\n");
|
|
46
|
-
const errorCode = parseInt(arr[arr.length - 1]);
|
|
47
|
-
if (isNaN(errorCode))
|
|
48
|
-
return false;
|
|
49
|
-
if (errorCode < 0)
|
|
50
|
-
return false; //Not defined error, e.g. Rate limit (-32097)
|
|
51
|
-
return true;
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
exports.Rpc010ChannelWithRetries = Rpc010ChannelWithRetries;
|
|
56
|
-
/**
|
|
57
|
-
* An RPC provider with built-in retry functionality, retries calls to the RPC service on failure
|
|
58
|
-
*
|
|
59
|
-
* @category Providers
|
|
60
|
-
*/
|
|
61
|
-
class RpcProviderWithRetries extends starknet_1.RpcProvider {
|
|
62
|
-
/**
|
|
63
|
-
* Creates a new RPC provider which retries RPC calls on failure, controlled by the passed `retryPolicy`
|
|
64
|
-
* NOTE: Tries to do naive detection of the spec version based on the suffix of nodeUrl, better pass the `options.specVersion`
|
|
65
|
-
* in the options!
|
|
66
|
-
*
|
|
67
|
-
* @param options
|
|
68
|
-
* @param retryPolicy
|
|
69
|
-
*/
|
|
70
|
-
constructor(options, retryPolicy) {
|
|
71
|
-
options ?? (options = {});
|
|
72
|
-
if (options.specVersion == null) {
|
|
73
|
-
// Default to RPC 0.10.0 (starknetjs v9 default), fallback to 0.9.0 if URL indicates v0_9
|
|
74
|
-
if (options.nodeUrl?.endsWith("v0_9")) {
|
|
75
|
-
options.specVersion = "0.9.0";
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
// Default to 0.10.0 for v9
|
|
79
|
-
options.specVersion = "0.10.0";
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
super(options);
|
|
83
|
-
const channelId = this.channel.id;
|
|
84
|
-
if (channelId === "RPC090") {
|
|
85
|
-
this.channel = new Rpc09ChannelWithRetries({ ...options, waitMode: false }, retryPolicy);
|
|
86
|
-
}
|
|
87
|
-
else if (channelId === "RPC0100" || channelId === "RPC010" || channelId === "RPC0.10.0" || (channelId && !channelId.startsWith("RPC08"))) {
|
|
88
|
-
// Handle RPC 0.10 (default in starknetjs v9) - channel ID might be "RPC0100", "RPC010", or other format
|
|
89
|
-
// Also handle any non-RPC08/RPC09 channel as RPC 0.10
|
|
90
|
-
this.channel = new Rpc010ChannelWithRetries({ ...options, waitMode: false }, retryPolicy);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
exports.RpcProviderWithRetries = RpcProviderWithRetries;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RpcProviderWithRetries = exports.Rpc010ChannelWithRetries = exports.Rpc09ChannelWithRetries = void 0;
|
|
4
|
+
const starknet_1 = require("starknet");
|
|
5
|
+
const Utils_1 = require("../../utils/Utils");
|
|
6
|
+
/**
|
|
7
|
+
* @private
|
|
8
|
+
*/
|
|
9
|
+
class Rpc09ChannelWithRetries extends starknet_1.RPC09.RpcChannel {
|
|
10
|
+
constructor(options, retryPolicy) {
|
|
11
|
+
super(options);
|
|
12
|
+
this.retryPolicy = retryPolicy;
|
|
13
|
+
}
|
|
14
|
+
fetchEndpoint(method, params) {
|
|
15
|
+
return (0, Utils_1.tryWithRetries)(() => super.fetchEndpoint(method, params), this.retryPolicy, e => {
|
|
16
|
+
if (!e.message.startsWith("RPC: "))
|
|
17
|
+
return false;
|
|
18
|
+
if (e.message.includes("Unsupported method"))
|
|
19
|
+
return true;
|
|
20
|
+
const arr = e.message.split("\n");
|
|
21
|
+
const errorCode = parseInt(arr[arr.length - 1]);
|
|
22
|
+
if (isNaN(errorCode))
|
|
23
|
+
return false;
|
|
24
|
+
if (errorCode < 0)
|
|
25
|
+
return false; //Not defined error, e.g. Rate limit (-32097)
|
|
26
|
+
return true;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.Rpc09ChannelWithRetries = Rpc09ChannelWithRetries;
|
|
31
|
+
/**
|
|
32
|
+
* @private
|
|
33
|
+
*/
|
|
34
|
+
class Rpc010ChannelWithRetries extends starknet_1.RPC010.RpcChannel {
|
|
35
|
+
constructor(options, retryPolicy) {
|
|
36
|
+
super(options);
|
|
37
|
+
this.retryPolicy = retryPolicy;
|
|
38
|
+
}
|
|
39
|
+
fetchEndpoint(method, params) {
|
|
40
|
+
return (0, Utils_1.tryWithRetries)(() => super.fetchEndpoint(method, params), this.retryPolicy, e => {
|
|
41
|
+
if (!e.message.startsWith("RPC: "))
|
|
42
|
+
return false;
|
|
43
|
+
if (e.message.includes("Unsupported method"))
|
|
44
|
+
return true;
|
|
45
|
+
const arr = e.message.split("\n");
|
|
46
|
+
const errorCode = parseInt(arr[arr.length - 1]);
|
|
47
|
+
if (isNaN(errorCode))
|
|
48
|
+
return false;
|
|
49
|
+
if (errorCode < 0)
|
|
50
|
+
return false; //Not defined error, e.g. Rate limit (-32097)
|
|
51
|
+
return true;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.Rpc010ChannelWithRetries = Rpc010ChannelWithRetries;
|
|
56
|
+
/**
|
|
57
|
+
* An RPC provider with built-in retry functionality, retries calls to the RPC service on failure
|
|
58
|
+
*
|
|
59
|
+
* @category Providers
|
|
60
|
+
*/
|
|
61
|
+
class RpcProviderWithRetries extends starknet_1.RpcProvider {
|
|
62
|
+
/**
|
|
63
|
+
* Creates a new RPC provider which retries RPC calls on failure, controlled by the passed `retryPolicy`
|
|
64
|
+
* NOTE: Tries to do naive detection of the spec version based on the suffix of nodeUrl, better pass the `options.specVersion`
|
|
65
|
+
* in the options!
|
|
66
|
+
*
|
|
67
|
+
* @param options
|
|
68
|
+
* @param retryPolicy
|
|
69
|
+
*/
|
|
70
|
+
constructor(options, retryPolicy) {
|
|
71
|
+
options ?? (options = {});
|
|
72
|
+
if (options.specVersion == null) {
|
|
73
|
+
// Default to RPC 0.10.0 (starknetjs v9 default), fallback to 0.9.0 if URL indicates v0_9
|
|
74
|
+
if (options.nodeUrl?.endsWith("v0_9")) {
|
|
75
|
+
options.specVersion = "0.9.0";
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
// Default to 0.10.0 for v9
|
|
79
|
+
options.specVersion = "0.10.0";
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
super(options);
|
|
83
|
+
const channelId = this.channel.id;
|
|
84
|
+
if (channelId === "RPC090") {
|
|
85
|
+
this.channel = new Rpc09ChannelWithRetries({ ...options, waitMode: false }, retryPolicy);
|
|
86
|
+
}
|
|
87
|
+
else if (channelId === "RPC0100" || channelId === "RPC010" || channelId === "RPC0.10.0" || (channelId && !channelId.startsWith("RPC08"))) {
|
|
88
|
+
// Handle RPC 0.10 (default in starknetjs v9) - channel ID might be "RPC0100", "RPC010", or other format
|
|
89
|
+
// Also handle any non-RPC08/RPC09 channel as RPC 0.10
|
|
90
|
+
this.channel = new Rpc010ChannelWithRetries({ ...options, waitMode: false }, retryPolicy);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.RpcProviderWithRetries = RpcProviderWithRetries;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { WebSocketChannel, WebSocketOptions } from "starknet";
|
|
2
|
-
/**
|
|
3
|
-
* An impl of WebSocketChannel which override the default exponential backoff and makes it linear
|
|
4
|
-
* Also adds connection timeouts and retries if the initial connection fails. Retries indefinitely!
|
|
5
|
-
*
|
|
6
|
-
* @category Providers
|
|
7
|
-
*/
|
|
8
|
-
export declare class WebSocketChannelWithRetries extends WebSocketChannel {
|
|
9
|
-
private connectionTimeout;
|
|
10
|
-
private connectionTimeoutMs;
|
|
11
|
-
/**
|
|
12
|
-
* Creates a new websocket channel, you can pass an additional `options.connectionTimeoutMs` param, which
|
|
13
|
-
* defines a connection timeout, after the timeout the connection is re-attempted
|
|
14
|
-
*
|
|
15
|
-
* @param options
|
|
16
|
-
*/
|
|
17
|
-
constructor(options: WebSocketOptions & {
|
|
18
|
-
connectionTimeoutMs?: number;
|
|
19
|
-
});
|
|
20
|
-
reconnect(): void;
|
|
21
|
-
}
|
|
1
|
+
import { WebSocketChannel, WebSocketOptions } from "starknet";
|
|
2
|
+
/**
|
|
3
|
+
* An impl of WebSocketChannel which override the default exponential backoff and makes it linear
|
|
4
|
+
* Also adds connection timeouts and retries if the initial connection fails. Retries indefinitely!
|
|
5
|
+
*
|
|
6
|
+
* @category Providers
|
|
7
|
+
*/
|
|
8
|
+
export declare class WebSocketChannelWithRetries extends WebSocketChannel {
|
|
9
|
+
private connectionTimeout;
|
|
10
|
+
private connectionTimeoutMs;
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new websocket channel, you can pass an additional `options.connectionTimeoutMs` param, which
|
|
13
|
+
* defines a connection timeout, after the timeout the connection is re-attempted
|
|
14
|
+
*
|
|
15
|
+
* @param options
|
|
16
|
+
*/
|
|
17
|
+
constructor(options: WebSocketOptions & {
|
|
18
|
+
connectionTimeoutMs?: number;
|
|
19
|
+
});
|
|
20
|
+
reconnect(): void;
|
|
21
|
+
}
|
|
@@ -1,46 +1,46 @@
|
|
|
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
|
-
* Also adds connection timeouts and retries if the initial connection fails. Retries indefinitely!
|
|
8
|
-
*
|
|
9
|
-
* @category Providers
|
|
10
|
-
*/
|
|
11
|
-
class WebSocketChannelWithRetries extends starknet_1.WebSocketChannel {
|
|
12
|
-
/**
|
|
13
|
-
* Creates a new websocket channel, you can pass an additional `options.connectionTimeoutMs` param, which
|
|
14
|
-
* defines a connection timeout, after the timeout the connection is re-attempted
|
|
15
|
-
*
|
|
16
|
-
* @param options
|
|
17
|
-
*/
|
|
18
|
-
constructor(options) {
|
|
19
|
-
super(options);
|
|
20
|
-
this.connectionTimeoutMs = options.connectionTimeoutMs ?? 5 * 1000;
|
|
21
|
-
const websocket = this.websocket;
|
|
22
|
-
this.connectionTimeout = setTimeout(() => {
|
|
23
|
-
console.log(`WebSocketChannelWithRetries: ctor(): Connection not opened in ${this.connectionTimeoutMs}ms, closing...`);
|
|
24
|
-
websocket.close();
|
|
25
|
-
}, this.connectionTimeoutMs);
|
|
26
|
-
websocket.addEventListener("open", () => {
|
|
27
|
-
clearTimeout(this.connectionTimeout);
|
|
28
|
-
this._processRequestQueue();
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
reconnect() {
|
|
32
|
-
this.reconnectAttempts = 1;
|
|
33
|
-
super.reconnect();
|
|
34
|
-
if (this.connectionTimeout != null)
|
|
35
|
-
clearTimeout(this.connectionTimeout);
|
|
36
|
-
const websocket = this.websocket;
|
|
37
|
-
this.connectionTimeout = setTimeout(() => {
|
|
38
|
-
console.log(`WebSocketChannelWithRetries: reconnect(): Connection not opened in ${this.connectionTimeoutMs}ms, closing...`);
|
|
39
|
-
websocket.close();
|
|
40
|
-
}, this.connectionTimeoutMs);
|
|
41
|
-
websocket.addEventListener("open", () => {
|
|
42
|
-
clearTimeout(this.connectionTimeout);
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
exports.WebSocketChannelWithRetries = WebSocketChannelWithRetries;
|
|
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
|
+
* Also adds connection timeouts and retries if the initial connection fails. Retries indefinitely!
|
|
8
|
+
*
|
|
9
|
+
* @category Providers
|
|
10
|
+
*/
|
|
11
|
+
class WebSocketChannelWithRetries extends starknet_1.WebSocketChannel {
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new websocket channel, you can pass an additional `options.connectionTimeoutMs` param, which
|
|
14
|
+
* defines a connection timeout, after the timeout the connection is re-attempted
|
|
15
|
+
*
|
|
16
|
+
* @param options
|
|
17
|
+
*/
|
|
18
|
+
constructor(options) {
|
|
19
|
+
super(options);
|
|
20
|
+
this.connectionTimeoutMs = options.connectionTimeoutMs ?? 5 * 1000;
|
|
21
|
+
const websocket = this.websocket;
|
|
22
|
+
this.connectionTimeout = setTimeout(() => {
|
|
23
|
+
console.log(`WebSocketChannelWithRetries: ctor(): Connection not opened in ${this.connectionTimeoutMs}ms, closing...`);
|
|
24
|
+
websocket.close();
|
|
25
|
+
}, this.connectionTimeoutMs);
|
|
26
|
+
websocket.addEventListener("open", () => {
|
|
27
|
+
clearTimeout(this.connectionTimeout);
|
|
28
|
+
this._processRequestQueue();
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
reconnect() {
|
|
32
|
+
this.reconnectAttempts = 1;
|
|
33
|
+
super.reconnect();
|
|
34
|
+
if (this.connectionTimeout != null)
|
|
35
|
+
clearTimeout(this.connectionTimeout);
|
|
36
|
+
const websocket = this.websocket;
|
|
37
|
+
this.connectionTimeout = setTimeout(() => {
|
|
38
|
+
console.log(`WebSocketChannelWithRetries: reconnect(): Connection not opened in ${this.connectionTimeoutMs}ms, closing...`);
|
|
39
|
+
websocket.close();
|
|
40
|
+
}, this.connectionTimeoutMs);
|
|
41
|
+
websocket.addEventListener("open", () => {
|
|
42
|
+
clearTimeout(this.connectionTimeout);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.WebSocketChannelWithRetries = WebSocketChannelWithRetries;
|