starknet 10.6.7 → 10.7.0

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/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # [10.7.0](https://github.com/starknet-io/starknet.js/compare/v10.6.8...v10.7.0) (2026-08-13)
2
+
3
+ ### Features
4
+
5
+ - **deps:** bump types-js 0.10.4-beta.2 and get-starknet 6.0.4 ([cf26a77](https://github.com/starknet-io/starknet.js/commit/cf26a77dc706c841a207bc76fb2ff7a5a7955be9))
6
+
7
+ ## [10.6.8](https://github.com/starknet-io/starknet.js/compare/v10.6.7...v10.6.8) (2026-08-07)
8
+
9
+ ### Bug Fixes
10
+
11
+ - **ws:** close the subscription lifecycle races ([c242c76](https://github.com/starknet-io/starknet.js/commit/c242c76ab73f508ecd454d1d7eb2fde8728c4f9d))
12
+
1
13
  ## [10.6.7](https://github.com/starknet-io/starknet.js/compare/v10.6.6...v10.6.7) (2026-08-06)
2
14
 
3
15
  ### Bug Fixes
package/dist/index.d.ts CHANGED
@@ -10,7 +10,7 @@ import { Abi as Abi$1, TypedContract } from 'abi-wan-kanabi';
10
10
  import { WalletWithStarknetFeatures, StandardEventsChangeProperties } from '@starknet-io/get-starknet-wallet-standard/features';
11
11
  import { WalletWithStarknetFeatures as WalletWithStarknetFeatures$1 } from '@starknet-io/get-starknet-wallet-standard-v6/features';
12
12
  import * as _starknet_io_starknet_types_0104 from '@starknet-io/starknet-types-0104';
13
- import { STRK20_DEPOSIT_ACTION, STRK20_WITHDRAW_ACTION, STRK20_TRANSFER_ACTION, STRK20_INVOKE_ACTION, STRK20_SUBACCOUNT_INVOKE_ACTION as STRK20_SUBACCOUNT_INVOKE_ACTION$1, STRK20_CALL_AND_PROOF as STRK20_CALL_AND_PROOF$1, STRK20_PROOF, Address, STRK20_BALANCE_ENTRY, STRK20_DAPP_NAME, FELT as FELT$1, Permission as Permission$2, WatchAssetParameters as WatchAssetParameters$2, AddStarknetChainParameters as AddStarknetChainParameters$2, ChainId as ChainId$2, AccountDeploymentData as AccountDeploymentData$2, AddInvokeTransactionParameters as AddInvokeTransactionParameters$2, AddInvokeTransactionResult as AddInvokeTransactionResult$2, AddDeclareTransactionParameters as AddDeclareTransactionParameters$2, AddDeclareTransactionResult as AddDeclareTransactionResult$2, TypedData as TypedData$2, Signature as Signature$3, SpecVersion as SpecVersion$2, API_VERSION as API_VERSION$3, STRK20_ACTION as STRK20_ACTION$1 } from '@starknet-io/starknet-types-0104';
13
+ import { STRK20_DEPOSIT_ACTION, STRK20_WITHDRAW_ACTION, STRK20_TRANSFER_ACTION, STRK20_INVOKE_ACTION, STRK20_SHADOW_ACCOUNT_INVOKE_ACTION as STRK20_SHADOW_ACCOUNT_INVOKE_ACTION$1, STRK20_CALL_AND_PROOF as STRK20_CALL_AND_PROOF$1, STRK20_PROOF, Address, STRK20_BALANCE_ENTRY, STRK20_DAPP_NAME, FELT as FELT$1, Permission as Permission$2, WatchAssetParameters as WatchAssetParameters$2, AddStarknetChainParameters as AddStarknetChainParameters$2, ChainId as ChainId$2, AccountDeploymentData as AccountDeploymentData$2, AddInvokeTransactionParameters as AddInvokeTransactionParameters$2, AddInvokeTransactionResult as AddInvokeTransactionResult$2, AddDeclareTransactionParameters as AddDeclareTransactionParameters$2, AddDeclareTransactionResult as AddDeclareTransactionResult$2, TypedData as TypedData$2, Signature as Signature$3, SpecVersion as SpecVersion$2, API_VERSION as API_VERSION$3, STRK20_ACTION as STRK20_ACTION$1 } from '@starknet-io/starknet-types-0104';
14
14
  export { STRK20_BALANCE_ENTRY, STRK20_CALLDATA_ITEM, STRK20_CALLDATA_PLACEHOLDER, STRK20_COLLECT_POLICY, STRK20_DAPP_NAME, STRK20_DEPOSIT_ACTION, STRK20_INVOKE_ACTION, STRK20_PROOF, STRK20_TRANSFER_ACTION, STRK20_WITHDRAW_ACTION } from '@starknet-io/starknet-types-0104';
15
15
  import * as poseidon from '@noble/curves/abstract/poseidon';
16
16
  import * as json$1 from 'lossless-json';
@@ -4962,6 +4962,7 @@ declare class Subscription<T = any> {
4962
4962
  private maxBufferSize;
4963
4963
  private handler;
4964
4964
  private _isClosed;
4965
+ private pendingUnsubscribe;
4965
4966
  /**
4966
4967
  * @internal
4967
4968
  * @param options - Subscription configuration options
@@ -4972,6 +4973,15 @@ declare class Subscription<T = any> {
4972
4973
  * @returns {boolean} `true` if unsubscribed, `false` otherwise.
4973
4974
  */
4974
4975
  get isClosed(): boolean;
4976
+ /**
4977
+ * Closes the subscription locally, without contacting the node.
4978
+ *
4979
+ * Used when the channel knows the subscription is gone and cannot be recovered — a
4980
+ * re-subscribe refused after a reconnection, for instance. Without it the object would keep
4981
+ * reporting itself as open while no event could ever reach its handler again.
4982
+ * @internal
4983
+ */
4984
+ _markClosed(): void;
4975
4985
  /**
4976
4986
  * Internal method to handle incoming events from the WebSocket channel.
4977
4987
  * If a handler is attached, it's invoked immediately. Otherwise, the event is buffered.
@@ -5153,6 +5163,15 @@ declare class WebSocketChannel {
5153
5163
  private requestQueue;
5154
5164
  /** Abort handles for the requests currently on the wire, one per pending `sendReceive`. */
5155
5165
  private inFlight;
5166
+ /**
5167
+ * Callers blocked in `waitForUnsubscription`, keyed by subscription id.
5168
+ *
5169
+ * Held here rather than as `unsubscribe` event listeners because that event only ever
5170
+ * announces success: a waiter attached to it cannot learn that the node refused the
5171
+ * unsubscribe or that the connection went away, and would wait forever with no timeout of
5172
+ * its own to fall back on.
5173
+ */
5174
+ private unsubscribeWaiters;
5156
5175
  private events;
5157
5176
  private openListener;
5158
5177
  private closeListener;
@@ -5228,6 +5247,15 @@ declare class WebSocketChannel {
5228
5247
  * @returns {Promise<boolean>} A Promise that resolves with `true` if the unsubscription was successful.
5229
5248
  */
5230
5249
  unsubscribe(subscriptionId: SUBSCRIPTION_ID): Promise<boolean>;
5250
+ /** Settles every caller waiting on one subscription id: resolved, or rejected with `error`. */
5251
+ private _settleUnsubscribeWaiters;
5252
+ /**
5253
+ * Rejects every caller still waiting on any subscription.
5254
+ *
5255
+ * Once the connection is gone, no unsubscribe can be observed on it: a reconnection restores
5256
+ * each subscription under a fresh id, so the id being waited on will never be announced.
5257
+ */
5258
+ private _rejectUnsubscribeWaiters;
5231
5259
  /**
5232
5260
  * Returns a Promise that resolves when a specific subscription is successfully unsubscribed.
5233
5261
  * @param {SUBSCRIPTION_ID} targetId - The ID of the subscription to wait for.
@@ -6201,17 +6229,17 @@ declare class WalletAccountV5 extends Account {
6201
6229
  * The raw spec types remain available through the `RPC` namespace.
6202
6230
  */
6203
6231
  /**
6204
- * Invokes one or more contract calls through the user's STRK20 sub-account for a DAPP,
6205
- * routed via the sub-account anonymizer. The sub-account is selected by (`dapp_name`,
6206
- * `nonce`); each nonce maps to a distinct, deterministic sub-account.
6232
+ * Invokes one or more contract calls through the user's STRK20 shadow account for a DAPP,
6233
+ * routed via the shadow account anonymizer. The shadow account is selected by (`dapp_name`,
6234
+ * `nonce`); each nonce maps to a distinct, deterministic shadow account.
6207
6235
  *
6208
6236
  * The proceeds of the calls are settled into the open notes created by `transfer` actions
6209
6237
  * with `amount: "OPEN"` in the same transaction, so the number of open notes filled by
6210
6238
  * this action must match the number of open notes created in the transaction.
6211
6239
  * @example
6212
6240
  * ```typescript
6213
- * const action: STRK20_SUBACCOUNT_INVOKE_ACTION = {
6214
- * type: 'subaccount_invoke',
6241
+ * const action: STRK20_SHADOW_ACCOUNT_INVOKE_ACTION = {
6242
+ * type: 'shadow_account_invoke',
6215
6243
  * dapp_name: 'myDapp',
6216
6244
  * nonce: '0x0',
6217
6245
  * calls: [myContract.populate('stake', { amount: 1000n })],
@@ -6219,8 +6247,8 @@ declare class WalletAccountV5 extends Account {
6219
6247
  * };
6220
6248
  * ```
6221
6249
  */
6222
- type STRK20_SUBACCOUNT_INVOKE_ACTION = Omit<STRK20_SUBACCOUNT_INVOKE_ACTION$1, 'calls'> & {
6223
- /** The contract calls to execute through the sub-account, in order (min 1). */
6250
+ type STRK20_SHADOW_ACCOUNT_INVOKE_ACTION = Omit<STRK20_SHADOW_ACCOUNT_INVOKE_ACTION$1, 'calls'> & {
6251
+ /** The contract calls to execute through the shadow account, in order (min 1). */
6224
6252
  calls: Call[];
6225
6253
  };
6226
6254
  /**
@@ -6229,10 +6257,10 @@ type STRK20_SUBACCOUNT_INVOKE_ACTION = Omit<STRK20_SUBACCOUNT_INVOKE_ACTION$1, '
6229
6257
  * @example
6230
6258
  * ```typescript
6231
6259
  * const actions: STRK20_ACTION[] = [
6232
- * { type: 'withdraw', token: strkAddress, amount: '0x2386f26fc10000', recipient: subAccountAddr },
6260
+ * { type: 'withdraw', token: strkAddress, amount: '0x2386f26fc10000', recipient: shadowAccountAddr },
6233
6261
  * { type: 'transfer', token: strkAddress, amount: 'OPEN', recipient: myAddress },
6234
6262
  * {
6235
- * type: 'subaccount_invoke',
6263
+ * type: 'shadow_account_invoke',
6236
6264
  * dapp_name: 'myDapp',
6237
6265
  * nonce: '0x0',
6238
6266
  * calls: [myContract.populate('stake', { amount: 1000n })],
@@ -6241,7 +6269,7 @@ type STRK20_SUBACCOUNT_INVOKE_ACTION = Omit<STRK20_SUBACCOUNT_INVOKE_ACTION$1, '
6241
6269
  * ];
6242
6270
  * ```
6243
6271
  */
6244
- type STRK20_ACTION = STRK20_DEPOSIT_ACTION | STRK20_WITHDRAW_ACTION | STRK20_TRANSFER_ACTION | STRK20_INVOKE_ACTION | STRK20_SUBACCOUNT_INVOKE_ACTION;
6272
+ type STRK20_ACTION = STRK20_DEPOSIT_ACTION | STRK20_WITHDRAW_ACTION | STRK20_TRANSFER_ACTION | STRK20_INVOKE_ACTION | STRK20_SHADOW_ACCOUNT_INVOKE_ACTION;
6245
6273
  /**
6246
6274
  * A Starknet call built by the wallet, together with the SNIP-36 zero-knowledge proof
6247
6275
  * needed to submit it. In simulate mode the proof fields are present but empty, in which
@@ -6333,24 +6361,24 @@ declare class WalletAccountV6 extends WalletAccountV5 {
6333
6361
  transaction_hash: string;
6334
6362
  }>;
6335
6363
  /**
6336
- * Compute the commitment of a DAPP STRK20 sub-account. The commitment is computed
6364
+ * Compute the commitment of a DAPP STRK20 shadow account. The commitment is computed
6337
6365
  * locally by the wallet from the user private state ; no transaction is sent.
6338
6366
  *
6339
- * When `nonce` is given, the full commitment of this single sub-account is returned.
6367
+ * When `nonce` is given, the full commitment of this single shadow account is returned.
6340
6368
  * When `nonce` is omitted, the partial (nonce independent) commitment is returned
6341
- * instead : it is shared by every sub-account the user derives for this DAPP, so it can
6342
- * be published once to let a DAPP recognize all the sub-accounts of a user without
6343
- * learning any individual nonce.
6344
- * @param {STRK20_DAPP_NAME} dappName - The DAPP that scopes the sub-account(s).
6345
- * @param {FELT} [nonce] - The sub-account nonce ; each nonce selects a distinct sub-account for this user + DAPP. Omit it to get the partial commitment.
6346
- * @returns {Promise<FELT>} The sub-account commitment.
6369
+ * instead : it is shared by every shadow account the user derives for this DAPP, so it
6370
+ * can be published once to let a DAPP recognize all the shadow accounts of a user
6371
+ * without learning any individual nonce.
6372
+ * @param {STRK20_DAPP_NAME} dappName - The DAPP that scopes the shadow account(s).
6373
+ * @param {FELT} [nonce] - The shadow account nonce ; each nonce selects a distinct shadow account for this user + DAPP. Omit it to get the partial commitment.
6374
+ * @returns {Promise<FELT>} The shadow account commitment.
6347
6375
  * @example
6348
6376
  * ```typescript
6349
- * const commitment = await myWalletAccount.strk20SubaccountCommitment('myDapp', '0x0');
6377
+ * const commitment = await myWalletAccount.strk20ShadowAccountCommitment('myDapp', '0x0');
6350
6378
  * // commitment = '0x5f2e...'
6351
6379
  * ```
6352
6380
  */
6353
- strk20SubaccountCommitment(dappName: STRK20_DAPP_NAME, nonce?: FELT$1): Promise<FELT$1>;
6381
+ strk20ShadowAccountCommitment(dappName: STRK20_DAPP_NAME, nonce?: FELT$1): Promise<FELT$1>;
6354
6382
  static connect(provider: ProviderOptions | ProviderInterface, walletProvider: WalletWithStarknetFeatures$1, cairoVersion?: CairoVersion, paymaster?: PaymasterOptions | PaymasterInterface, silentMode?: boolean): Promise<WalletAccountV6>;
6355
6383
  static connectSilent(provider: ProviderOptions | ProviderInterface, walletProvider: WalletWithStarknetFeatures$1, cairoVersion?: CairoVersion, paymaster?: PaymasterOptions | PaymasterInterface): Promise<WalletAccountV6>;
6356
6384
  }
@@ -10672,25 +10700,25 @@ declare function strk20InvokeTransaction(walletWSF: WalletWithStarknetFeatures$1
10672
10700
  transaction_hash: string;
10673
10701
  }>;
10674
10702
  /**
10675
- * Compute the commitment of a DAPP STRK20 sub-account. The commitment is computed locally
10676
- * by the wallet from the user private state ; no transaction is sent.
10703
+ * Compute the commitment of a DAPP STRK20 shadow account. The commitment is computed
10704
+ * locally by the wallet from the user private state ; no transaction is sent.
10677
10705
  *
10678
- * When `nonce` is given, the full commitment of this single sub-account is returned. When
10679
- * `nonce` is omitted, the partial (nonce independent) commitment is returned instead : it
10680
- * is shared by every sub-account the user derives for this DAPP, so it can be published
10681
- * once to let a DAPP recognize all the sub-accounts of a user without learning any
10682
- * individual nonce.
10706
+ * When `nonce` is given, the full commitment of this single shadow account is returned.
10707
+ * When `nonce` is omitted, the partial (nonce independent) commitment is returned instead :
10708
+ * it is shared by every shadow account the user derives for this DAPP, so it can be
10709
+ * published once to let a DAPP recognize all the shadow accounts of a user without learning
10710
+ * any individual nonce.
10683
10711
  * @param {WalletWithStarknetFeaturesV6} walletWSF - The get-starknet V6 wallet object to use.
10684
- * @param {STRK20_DAPP_NAME} dapp_name - The DAPP that scopes the sub-account(s).
10685
- * @param {FELT} [nonce] - The sub-account nonce ; each nonce selects a distinct sub-account for this user + DAPP. Omit it to get the partial commitment.
10686
- * @returns {Promise<FELT>} The sub-account commitment.
10712
+ * @param {STRK20_DAPP_NAME} dapp_name - The DAPP that scopes the shadow account(s).
10713
+ * @param {FELT} [nonce] - The shadow account nonce ; each nonce selects a distinct shadow account for this user + DAPP. Omit it to get the partial commitment.
10714
+ * @returns {Promise<FELT>} The shadow account commitment.
10687
10715
  * @example
10688
10716
  * ```typescript
10689
- * const commitment = await strk20SubaccountCommitment(walletWSF, 'myDapp', '0x0');
10717
+ * const commitment = await strk20ShadowAccountCommitment(walletWSF, 'myDapp', '0x0');
10690
10718
  * // commitment = '0x5f2e...'
10691
10719
  * ```
10692
10720
  */
10693
- declare function strk20SubaccountCommitment(walletWSF: WalletWithStarknetFeatures$1, dapp_name: STRK20_DAPP_NAME, nonce?: FELT$1): Promise<FELT$1>;
10721
+ declare function strk20ShadowAccountCommitment(walletWSF: WalletWithStarknetFeatures$1, dapp_name: STRK20_DAPP_NAME, nonce?: FELT$1): Promise<FELT$1>;
10694
10722
 
10695
10723
  declare const connectV6_addDeclareTransaction: typeof addDeclareTransaction;
10696
10724
  declare const connectV6_addInvokeTransaction: typeof addInvokeTransaction;
@@ -10704,14 +10732,14 @@ declare const connectV6_standardConnect: typeof standardConnect;
10704
10732
  declare const connectV6_strk20Balances: typeof strk20Balances;
10705
10733
  declare const connectV6_strk20InvokeTransaction: typeof strk20InvokeTransaction;
10706
10734
  declare const connectV6_strk20PrepareInvoke: typeof strk20PrepareInvoke;
10707
- declare const connectV6_strk20SubaccountCommitment: typeof strk20SubaccountCommitment;
10735
+ declare const connectV6_strk20ShadowAccountCommitment: typeof strk20ShadowAccountCommitment;
10708
10736
  declare const connectV6_subscribeWalletEvent: typeof subscribeWalletEvent;
10709
10737
  declare const connectV6_supportedSpecs: typeof supportedSpecs;
10710
10738
  declare const connectV6_supportedWalletApi: typeof supportedWalletApi;
10711
10739
  declare const connectV6_switchStarknetChain: typeof switchStarknetChain;
10712
10740
  declare const connectV6_watchAsset: typeof watchAsset;
10713
10741
  declare namespace connectV6 {
10714
- export { connectV6_addDeclareTransaction as addDeclareTransaction, connectV6_addInvokeTransaction as addInvokeTransaction, connectV6_addStarknetChain as addStarknetChain, connectV6_deploymentData as deploymentData, connectV6_getPermissions as getPermissions, connectV6_requestAccounts as requestAccounts, connectV6_requestChainId as requestChainId, connectV6_signMessage as signMessage, connectV6_standardConnect as standardConnect, connectV6_strk20Balances as strk20Balances, connectV6_strk20InvokeTransaction as strk20InvokeTransaction, connectV6_strk20PrepareInvoke as strk20PrepareInvoke, connectV6_strk20SubaccountCommitment as strk20SubaccountCommitment, connectV6_subscribeWalletEvent as subscribeWalletEvent, connectV6_supportedSpecs as supportedSpecs, connectV6_supportedWalletApi as supportedWalletApi, connectV6_switchStarknetChain as switchStarknetChain, connectV6_watchAsset as watchAsset };
10742
+ export { connectV6_addDeclareTransaction as addDeclareTransaction, connectV6_addInvokeTransaction as addInvokeTransaction, connectV6_addStarknetChain as addStarknetChain, connectV6_deploymentData as deploymentData, connectV6_getPermissions as getPermissions, connectV6_requestAccounts as requestAccounts, connectV6_requestChainId as requestChainId, connectV6_signMessage as signMessage, connectV6_standardConnect as standardConnect, connectV6_strk20Balances as strk20Balances, connectV6_strk20InvokeTransaction as strk20InvokeTransaction, connectV6_strk20PrepareInvoke as strk20PrepareInvoke, connectV6_strk20ShadowAccountCommitment as strk20ShadowAccountCommitment, connectV6_subscribeWalletEvent as subscribeWalletEvent, connectV6_supportedSpecs as supportedSpecs, connectV6_supportedWalletApi as supportedWalletApi, connectV6_switchStarknetChain as switchStarknetChain, connectV6_watchAsset as watchAsset };
10715
10743
  }
10716
10744
 
10717
10745
  type DefaultConfig = typeof DEFAULT_GLOBAL_CONFIG;
@@ -10815,4 +10843,4 @@ declare class Logger {
10815
10843
  */
10816
10844
  declare const logger: Logger;
10817
10845
 
10818
- export { type Abi, type AbiEntry, type AbiEntryType, type AbiEnum, type AbiEnums, type AbiEvent, type AbiEvents, type AbiInterfaces, AbiParser1, AbiParser2, AbiParserInterface, type AbiStruct, type AbiStructs, Account, type AccountHooks, AccountInterface, type AccountInvocationItem, type AccountInvocations, type AccountInvocationsFactoryDetails, type AccountOptions, type AllowArray, type ApiEstimateFeeResponse, type Args, type ArgsOrCalldata, type ArgsOrCalldataWithOptions, type ArraySignatureType, type AsyncContractFunction, type BLOCK_HASH, type BLOCK_NUMBER, BatchClient, type BatchClientOptions, type BigNumberish, type Block$1 as Block, type BlockIdentifier, type BlockNumber, BlockStatus, BlockTag, type BlockTransactionTrace, type BlockTransactionsTracesWithInitialReads, type BlockWithTxHashes, BrotherIdImpl, type BrotherIdProviderMethods, type BrotherProfile, type Builtins, type ByteArray, type ByteCode, type CairoAssembly, CairoByteArray, CairoBytes31, type CairoContract, CairoCustomEnum, type CairoEnum, type CairoEnumRaw, type CairoEvent, type CairoEventDefinition, type CairoEventVariant, CairoFelt, CairoFelt252, CairoFixedArray, CairoInt128, CairoInt16, CairoInt32, CairoInt64, CairoInt8, CairoOption, CairoOptionVariant, CairoResult, CairoResultVariant, CairoUint128, CairoUint16, CairoUint256, CairoUint32, CairoUint512, CairoUint64, CairoUint8, CairoUint96, type CairoVersion, type Call, type CallContractResponse, CallData, type CallDetails, type CallOptions, type CallResult, type Calldata, type CommonContractOptions, type CompiledContract, type CompiledSierra, type CompiledSierraCasm, type CompilerVersion, type CompleteDeclareContractPayload, type CompressedProgram, Contract, type ContractClass, type ContractClassIdentifier, type ContractClassPayload, type ContractClassResponse, type ContractEntryPointFields, type ContractFunction, ContractInterface, type ContractOptions, type ContractVersion, type DeclareAndDeployContractPayload, type DeclareContractPayload, type DeclareContractResponse, type DeclareContractTransaction, type DeclareDeployUDCResponse, type DeclareSignerDetails, type DeclareTransactionReceiptResponse, type DeclaredTransaction, type DeployAccountContractPayload, type DeployAccountContractTransaction, type DeployAccountSignerDetails, type DeployAccountTransactionReceiptResponse, type DeployAndInvokeTransaction, type DeployContractResponse, type DeployContractUDCResponse, type DeployTransaction, type DeployTransactionReceiptResponse, type DeployedAccountTransaction, Deployer, type DeployerCall, DeployerInterface, type Details, EDAMode, EDataAvailabilityMode, ESubscriptionTag, ETH_ADDRESS, ETraceFlag, ETransactionExecutionStatus, ETransactionStatus, ETransactionVersion, ETransactionVersion2, ETransactionVersion3, ETxnResponseFlag, type EVENTS_CHUNK, type EmittedEvent, EntryPointType, type EntryPointsByType, type ErrorReceiptResponseHelper, type EstimateFeeBulk, type EstimateFeeResponseBulkOverhead, type EstimateFeeResponseOverhead, EthSigner, type Event$1 as Event, type EventEntry, type EventFilter, type ExecutableDeployAndInvokeTransaction, type ExecutableDeployTransaction, type ExecutableInvokeTransaction, type ExecutableUserInvoke, type ExecutableUserTransaction, type ExecuteOptions, type ExecutionParameters, type FEE_ESTIMATE, type FELT, type FactoryParams, type FastExecuteAccountMethods, type FastExecuteProviderMethods, type FastExecuteResponse, type FastWaitForTransactionOptions, type FeeEstimate, type FeeMode, type FormatResponse, type FunctionAbi, type GasPrices, type GetBlockResponse, type GetTransactionReceiptResponse, type GetTransactionResponse, type GetTxReceiptResponseWithoutHelper, type HexCalldata, type Hint, type INITIAL_READS, Int, type InterfaceAbi, type Invocation, type Invocations, type InvocationsDetails, type InvocationsDetailsWithNonce, type InvocationsSignerDetails, type InvokeFunctionResponse, type InvokeTransaction, type InvokeTransactionReceiptResponse, type InvokedTransaction, type L1HandlerTransactionReceiptResponse, type L1_HANDLER_TXN, type LedgerPathCalculation, LedgerSigner111 as LedgerSigner, LedgerSigner111, LedgerSigner221, LedgerSigner231, type LegacyCompiledContract, type LegacyContractClass, type LegacyEvent, LibraryError, Literal, type LoadedContract, type LogLevel, LogLevelIndex, type Methods, type MultiDeployContractResponse, type MultiType, NON_ZERO_PREFIX, type Nonce, type OptionalPayload, type OutsideCall, type OutsideExecution, type OutsideExecutionOptions, OutsideExecutionTypesV1, OutsideExecutionTypesV2, OutsideExecutionVersion, type OutsideTransaction, type PRE_CONFIRMED_STATE_UPDATE, type PRICE_UNIT, type ParsedEvent, type ParsedEvents, type ParsedStruct, type ParsingStrategy, type PaymasterDetails, type PaymasterFeeEstimate, PaymasterInterface, type PaymasterOptions, PaymasterRpc, type PaymasterRpcOptions, type PaymasterTimeBounds, type PluginConfig, PluginManager, type PreConfirmedBlock, type PreConfirmedStateUpdate, type PreparedDeployAndInvokeTransaction, type PreparedDeployTransaction, type PreparedInvokeTransaction, type PreparedTransaction, type Program, RpcProvider as Provider, type ProviderHooks, ProviderInterface, type ProviderOptions, type ProviderOrAccount, type PythonicHints, type RESOURCE_PRICE, index$4 as RPC, rpc_0_10_2 as RPC0102, rpc_0_10_3 as RPC0103, rpc_0_9_0 as RPC09, RPCResponseParser, type RPC_ERROR, type RPC_ERROR_SET, type RawArgs, type RawArgsArray, type RawArgsObject, type RawCalldata, type Receipt, ReceiptTx, type ReconnectOptions, type RequiredKeysOf, type ResourceBounds, type ResourceBoundsBN, type ResourceBoundsOverhead, ResponseParser, type RevertedTransactionReceiptResponse, type RevertedTransactionReceiptResponseHelper, RpcChannel, RpcError, RpcProvider, type RpcProviderOptions, type SIMULATION_FLAG, type STATE_UPDATE, type STRK20_ACTION, type STRK20_CALL_AND_PROOF, type STRK20_SUBACCOUNT_INVOKE_ACTION, type SierraContractClass, type SierraContractEntryPointFields, type SierraEntryPointsByType, type SierraProgramDebugInfo, type Signature, Signer, SignerInterface, type Simplify, type SimulateTransaction, type SimulateTransactionDetails, type SimulateTransactionOverhead, type SimulateTransactionOverheadResponse, type SimulateTransactionResponse, type SimulationFlags, type StarkProfile, type StarknetIdAccountMethods, StarknetIdImpl, type StarknetIdProviderMethods, type StarknetPlugin, type StateUpdate, type StateUpdateResponse, type StorageResponse, type SubscribeEventsParams, type SubscribeNewHeadsParams, type SubscribeNewTransactionReceiptsParams, type SubscribeNewTransactionsParams, type SubscribeTransactionStatusParams, Subscription, type SubscriptionBlockIdentifier, type SubscriptionNewHeadsEvent, type SubscriptionNewTransactionEvent, type SubscriptionNewTransactionReceiptsEvent, type SubscriptionOptions, type SubscriptionStarknetEventsEvent, type SubscriptionTransactionStatusEvent, type SuccessfulTransactionReceiptResponse, type SuccessfulTransactionReceiptResponseHelper, type TXN_EXECUTION_STATUS, type TXN_HASH, type TXN_STATUS, TimeoutError, type TipAnalysisOptions, type TipEstimate, type TipType, type TokenData, TransactionExecutionStatus, TransactionFinalityStatus, type TransactionReceipt, type TransactionReceiptCallbacks, type TransactionReceiptCallbacksDefault, type TransactionReceiptCallbacksDefined, type TransactionReceiptStatus, type TransactionReceiptValue, type TransactionStatus, type TransactionStatusReceiptSets, type TransactionTrace, TransactionType, type TransactionWithHash, type Tupled, type TypedContractV2, UINT_128_MAX, UINT_128_MIN, UINT_256_HIGH_MAX, UINT_256_HIGH_MIN, UINT_256_LOW_MAX, UINT_256_LOW_MIN, UINT_256_MAX, UINT_256_MIN, UINT_512_MAX, UINT_512_MIN, Uint, type Uint256, type Uint512, type UniversalDeployerContractPayload, type UniversalDetails, type UserInvoke, type UserTransaction, type V3DeclareSignerDetails, type V3DeployAccountSignerDetails, type V3InvocationsSignerDetails, type V3TransactionDetails, ValidateType, WalletAccount, WalletAccountV5, WalletAccountV6, WebSocketChannel, type WebSocketModule, WebSocketNotConnectedError, type WebSocketOptions, type WeierstrassSignatureType, type WithOptions, addAddressPadding, brotherId, byteArray, cairo, compareVersions, config, constants, contractClassResponseToLegacyCompiledContract, contractLoader, createAbiParser, createTransactionReceipt, defaultDeployer, defaultPlugins, ec, encode, eth, index as events, extractContractHashes, fastExecute, fastParsingStrategy, getAbiVersion, type getBlockTransactionsTracesOptions, getChecksumAddress, type getContractVersionOptions, type getEstimateFeeBulkOptions, getGasPrices, getLedgerPathBuffer111 as getLedgerPathBuffer, getLedgerPathBuffer111, getLedgerPathBuffer221, type getSimulateTransactionOptions, getTipStatsFromBlocks, index$3 as hash, hdParsingStrategy, isAccount, isFileSystemAvailable, isNoConstructorValid, isPreConfirmedBlock, isPreConfirmedStateUpdate, isPreConfirmedTransaction, isRPC08Plus_ResourceBounds, isRPC08Plus_ResourceBoundsBN, isSierra, isSupportedSpecVersion, isV3Tx, isVersion, json, legacyDeployer, logger, merkle, num, outsideExecution, parseCalldataField, paymaster, provider, selector, shortString, src5, index$1 as stark, starknetId, starknetId$1 as starknetIdPlugin, toAnyPatchVersion, toApiVersion, index$2 as transaction, typedData, uint256$1 as uint256, units, v2 as v2hash, v3 as v3hash, validateAndParseAddress, validateChecksumAddress, verifyMessageInStarknet, type waitForTransactionOptions, connect as wallet, connectV5 as walletV5, connectV6 as walletV6 };
10846
+ export { type Abi, type AbiEntry, type AbiEntryType, type AbiEnum, type AbiEnums, type AbiEvent, type AbiEvents, type AbiInterfaces, AbiParser1, AbiParser2, AbiParserInterface, type AbiStruct, type AbiStructs, Account, type AccountHooks, AccountInterface, type AccountInvocationItem, type AccountInvocations, type AccountInvocationsFactoryDetails, type AccountOptions, type AllowArray, type ApiEstimateFeeResponse, type Args, type ArgsOrCalldata, type ArgsOrCalldataWithOptions, type ArraySignatureType, type AsyncContractFunction, type BLOCK_HASH, type BLOCK_NUMBER, BatchClient, type BatchClientOptions, type BigNumberish, type Block$1 as Block, type BlockIdentifier, type BlockNumber, BlockStatus, BlockTag, type BlockTransactionTrace, type BlockTransactionsTracesWithInitialReads, type BlockWithTxHashes, BrotherIdImpl, type BrotherIdProviderMethods, type BrotherProfile, type Builtins, type ByteArray, type ByteCode, type CairoAssembly, CairoByteArray, CairoBytes31, type CairoContract, CairoCustomEnum, type CairoEnum, type CairoEnumRaw, type CairoEvent, type CairoEventDefinition, type CairoEventVariant, CairoFelt, CairoFelt252, CairoFixedArray, CairoInt128, CairoInt16, CairoInt32, CairoInt64, CairoInt8, CairoOption, CairoOptionVariant, CairoResult, CairoResultVariant, CairoUint128, CairoUint16, CairoUint256, CairoUint32, CairoUint512, CairoUint64, CairoUint8, CairoUint96, type CairoVersion, type Call, type CallContractResponse, CallData, type CallDetails, type CallOptions, type CallResult, type Calldata, type CommonContractOptions, type CompiledContract, type CompiledSierra, type CompiledSierraCasm, type CompilerVersion, type CompleteDeclareContractPayload, type CompressedProgram, Contract, type ContractClass, type ContractClassIdentifier, type ContractClassPayload, type ContractClassResponse, type ContractEntryPointFields, type ContractFunction, ContractInterface, type ContractOptions, type ContractVersion, type DeclareAndDeployContractPayload, type DeclareContractPayload, type DeclareContractResponse, type DeclareContractTransaction, type DeclareDeployUDCResponse, type DeclareSignerDetails, type DeclareTransactionReceiptResponse, type DeclaredTransaction, type DeployAccountContractPayload, type DeployAccountContractTransaction, type DeployAccountSignerDetails, type DeployAccountTransactionReceiptResponse, type DeployAndInvokeTransaction, type DeployContractResponse, type DeployContractUDCResponse, type DeployTransaction, type DeployTransactionReceiptResponse, type DeployedAccountTransaction, Deployer, type DeployerCall, DeployerInterface, type Details, EDAMode, EDataAvailabilityMode, ESubscriptionTag, ETH_ADDRESS, ETraceFlag, ETransactionExecutionStatus, ETransactionStatus, ETransactionVersion, ETransactionVersion2, ETransactionVersion3, ETxnResponseFlag, type EVENTS_CHUNK, type EmittedEvent, EntryPointType, type EntryPointsByType, type ErrorReceiptResponseHelper, type EstimateFeeBulk, type EstimateFeeResponseBulkOverhead, type EstimateFeeResponseOverhead, EthSigner, type Event$1 as Event, type EventEntry, type EventFilter, type ExecutableDeployAndInvokeTransaction, type ExecutableDeployTransaction, type ExecutableInvokeTransaction, type ExecutableUserInvoke, type ExecutableUserTransaction, type ExecuteOptions, type ExecutionParameters, type FEE_ESTIMATE, type FELT, type FactoryParams, type FastExecuteAccountMethods, type FastExecuteProviderMethods, type FastExecuteResponse, type FastWaitForTransactionOptions, type FeeEstimate, type FeeMode, type FormatResponse, type FunctionAbi, type GasPrices, type GetBlockResponse, type GetTransactionReceiptResponse, type GetTransactionResponse, type GetTxReceiptResponseWithoutHelper, type HexCalldata, type Hint, type INITIAL_READS, Int, type InterfaceAbi, type Invocation, type Invocations, type InvocationsDetails, type InvocationsDetailsWithNonce, type InvocationsSignerDetails, type InvokeFunctionResponse, type InvokeTransaction, type InvokeTransactionReceiptResponse, type InvokedTransaction, type L1HandlerTransactionReceiptResponse, type L1_HANDLER_TXN, type LedgerPathCalculation, LedgerSigner111 as LedgerSigner, LedgerSigner111, LedgerSigner221, LedgerSigner231, type LegacyCompiledContract, type LegacyContractClass, type LegacyEvent, LibraryError, Literal, type LoadedContract, type LogLevel, LogLevelIndex, type Methods, type MultiDeployContractResponse, type MultiType, NON_ZERO_PREFIX, type Nonce, type OptionalPayload, type OutsideCall, type OutsideExecution, type OutsideExecutionOptions, OutsideExecutionTypesV1, OutsideExecutionTypesV2, OutsideExecutionVersion, type OutsideTransaction, type PRE_CONFIRMED_STATE_UPDATE, type PRICE_UNIT, type ParsedEvent, type ParsedEvents, type ParsedStruct, type ParsingStrategy, type PaymasterDetails, type PaymasterFeeEstimate, PaymasterInterface, type PaymasterOptions, PaymasterRpc, type PaymasterRpcOptions, type PaymasterTimeBounds, type PluginConfig, PluginManager, type PreConfirmedBlock, type PreConfirmedStateUpdate, type PreparedDeployAndInvokeTransaction, type PreparedDeployTransaction, type PreparedInvokeTransaction, type PreparedTransaction, type Program, RpcProvider as Provider, type ProviderHooks, ProviderInterface, type ProviderOptions, type ProviderOrAccount, type PythonicHints, type RESOURCE_PRICE, index$4 as RPC, rpc_0_10_2 as RPC0102, rpc_0_10_3 as RPC0103, rpc_0_9_0 as RPC09, RPCResponseParser, type RPC_ERROR, type RPC_ERROR_SET, type RawArgs, type RawArgsArray, type RawArgsObject, type RawCalldata, type Receipt, ReceiptTx, type ReconnectOptions, type RequiredKeysOf, type ResourceBounds, type ResourceBoundsBN, type ResourceBoundsOverhead, ResponseParser, type RevertedTransactionReceiptResponse, type RevertedTransactionReceiptResponseHelper, RpcChannel, RpcError, RpcProvider, type RpcProviderOptions, type SIMULATION_FLAG, type STATE_UPDATE, type STRK20_ACTION, type STRK20_CALL_AND_PROOF, type STRK20_SHADOW_ACCOUNT_INVOKE_ACTION, type SierraContractClass, type SierraContractEntryPointFields, type SierraEntryPointsByType, type SierraProgramDebugInfo, type Signature, Signer, SignerInterface, type Simplify, type SimulateTransaction, type SimulateTransactionDetails, type SimulateTransactionOverhead, type SimulateTransactionOverheadResponse, type SimulateTransactionResponse, type SimulationFlags, type StarkProfile, type StarknetIdAccountMethods, StarknetIdImpl, type StarknetIdProviderMethods, type StarknetPlugin, type StateUpdate, type StateUpdateResponse, type StorageResponse, type SubscribeEventsParams, type SubscribeNewHeadsParams, type SubscribeNewTransactionReceiptsParams, type SubscribeNewTransactionsParams, type SubscribeTransactionStatusParams, Subscription, type SubscriptionBlockIdentifier, type SubscriptionNewHeadsEvent, type SubscriptionNewTransactionEvent, type SubscriptionNewTransactionReceiptsEvent, type SubscriptionOptions, type SubscriptionStarknetEventsEvent, type SubscriptionTransactionStatusEvent, type SuccessfulTransactionReceiptResponse, type SuccessfulTransactionReceiptResponseHelper, type TXN_EXECUTION_STATUS, type TXN_HASH, type TXN_STATUS, TimeoutError, type TipAnalysisOptions, type TipEstimate, type TipType, type TokenData, TransactionExecutionStatus, TransactionFinalityStatus, type TransactionReceipt, type TransactionReceiptCallbacks, type TransactionReceiptCallbacksDefault, type TransactionReceiptCallbacksDefined, type TransactionReceiptStatus, type TransactionReceiptValue, type TransactionStatus, type TransactionStatusReceiptSets, type TransactionTrace, TransactionType, type TransactionWithHash, type Tupled, type TypedContractV2, UINT_128_MAX, UINT_128_MIN, UINT_256_HIGH_MAX, UINT_256_HIGH_MIN, UINT_256_LOW_MAX, UINT_256_LOW_MIN, UINT_256_MAX, UINT_256_MIN, UINT_512_MAX, UINT_512_MIN, Uint, type Uint256, type Uint512, type UniversalDeployerContractPayload, type UniversalDetails, type UserInvoke, type UserTransaction, type V3DeclareSignerDetails, type V3DeployAccountSignerDetails, type V3InvocationsSignerDetails, type V3TransactionDetails, ValidateType, WalletAccount, WalletAccountV5, WalletAccountV6, WebSocketChannel, type WebSocketModule, WebSocketNotConnectedError, type WebSocketOptions, type WeierstrassSignatureType, type WithOptions, addAddressPadding, brotherId, byteArray, cairo, compareVersions, config, constants, contractClassResponseToLegacyCompiledContract, contractLoader, createAbiParser, createTransactionReceipt, defaultDeployer, defaultPlugins, ec, encode, eth, index as events, extractContractHashes, fastExecute, fastParsingStrategy, getAbiVersion, type getBlockTransactionsTracesOptions, getChecksumAddress, type getContractVersionOptions, type getEstimateFeeBulkOptions, getGasPrices, getLedgerPathBuffer111 as getLedgerPathBuffer, getLedgerPathBuffer111, getLedgerPathBuffer221, type getSimulateTransactionOptions, getTipStatsFromBlocks, index$3 as hash, hdParsingStrategy, isAccount, isFileSystemAvailable, isNoConstructorValid, isPreConfirmedBlock, isPreConfirmedStateUpdate, isPreConfirmedTransaction, isRPC08Plus_ResourceBounds, isRPC08Plus_ResourceBoundsBN, isSierra, isSupportedSpecVersion, isV3Tx, isVersion, json, legacyDeployer, logger, merkle, num, outsideExecution, parseCalldataField, paymaster, provider, selector, shortString, src5, index$1 as stark, starknetId, starknetId$1 as starknetIdPlugin, toAnyPatchVersion, toApiVersion, index$2 as transaction, typedData, uint256$1 as uint256, units, v2 as v2hash, v3 as v3hash, validateAndParseAddress, validateChecksumAddress, verifyMessageInStarknet, type waitForTransactionOptions, connect as wallet, connectV5 as walletV5, connectV6 as walletV6 };
@@ -12516,6 +12516,8 @@ ${indent}}` : "}";
12516
12516
  maxBufferSize;
12517
12517
  handler = null;
12518
12518
  _isClosed = false;
12519
+ // The unsubscribe request currently on the wire, shared by concurrent callers.
12520
+ pendingUnsubscribe = null;
12519
12521
  /**
12520
12522
  * @internal
12521
12523
  * @param options - Subscription configuration options
@@ -12534,6 +12536,20 @@ ${indent}}` : "}";
12534
12536
  get isClosed() {
12535
12537
  return this._isClosed;
12536
12538
  }
12539
+ /**
12540
+ * Closes the subscription locally, without contacting the node.
12541
+ *
12542
+ * Used when the channel knows the subscription is gone and cannot be recovered — a
12543
+ * re-subscribe refused after a reconnection, for instance. Without it the object would keep
12544
+ * reporting itself as open while no event could ever reach its handler again.
12545
+ * @internal
12546
+ */
12547
+ _markClosed() {
12548
+ if (this._isClosed) return;
12549
+ this._isClosed = true;
12550
+ this.events.emit("unsubscribe", void 0);
12551
+ this.events.clear();
12552
+ }
12537
12553
  /**
12538
12554
  * Internal method to handle incoming events from the WebSocket channel.
12539
12555
  * If a handler is attached, it's invoked immediately. Otherwise, the event is buffered.
@@ -12580,14 +12596,24 @@ ${indent}}` : "}";
12580
12596
  if (this._isClosed) {
12581
12597
  return true;
12582
12598
  }
12583
- const success = await this.channel.unsubscribe(this.id);
12584
- if (success) {
12585
- this._isClosed = true;
12586
- this.channel.removeSubscription(this.id);
12587
- this.events.emit("unsubscribe", void 0);
12588
- this.events.clear();
12599
+ if (this.pendingUnsubscribe) {
12600
+ return this.pendingUnsubscribe;
12589
12601
  }
12590
- return success;
12602
+ this.pendingUnsubscribe = (async () => {
12603
+ try {
12604
+ const success = await this.channel.unsubscribe(this.id);
12605
+ if (success) {
12606
+ this._isClosed = true;
12607
+ this.channel.removeSubscription(this.id);
12608
+ this.events.emit("unsubscribe", void 0);
12609
+ this.events.clear();
12610
+ }
12611
+ return success;
12612
+ } finally {
12613
+ this.pendingUnsubscribe = null;
12614
+ }
12615
+ })();
12616
+ return this.pendingUnsubscribe;
12591
12617
  }
12592
12618
  };
12593
12619
 
@@ -12620,6 +12646,15 @@ ${indent}}` : "}";
12620
12646
  requestQueue = [];
12621
12647
  /** Abort handles for the requests currently on the wire, one per pending `sendReceive`. */
12622
12648
  inFlight = /* @__PURE__ */ new Set();
12649
+ /**
12650
+ * Callers blocked in `waitForUnsubscription`, keyed by subscription id.
12651
+ *
12652
+ * Held here rather than as `unsubscribe` event listeners because that event only ever
12653
+ * announces success: a waiter attached to it cannot learn that the node refused the
12654
+ * unsubscribe or that the connection went away, and would wait forever with no timeout of
12655
+ * its own to fall back on.
12656
+ */
12657
+ unsubscribeWaiters = /* @__PURE__ */ new Map();
12623
12658
  events = new EventEmitter();
12624
12659
  openListener = (ev) => {
12625
12660
  this.scheduleReconnectAttemptsReset();
@@ -12816,6 +12851,7 @@ ${indent}}` : "}";
12816
12851
  this.isReconnecting = false;
12817
12852
  this._rejectRequestQueue("the connection was closed by the user");
12818
12853
  this._rejectInFlight("the connection was closed by the user");
12854
+ this._rejectUnsubscribeWaiters("the connection was closed by the user");
12819
12855
  this.websocket.close(code, reason);
12820
12856
  }
12821
12857
  /**
@@ -12840,14 +12876,48 @@ ${indent}}` : "}";
12840
12876
  * @returns {Promise<boolean>} A Promise that resolves with `true` if the unsubscription was successful.
12841
12877
  */
12842
12878
  async unsubscribe(subscriptionId) {
12843
- const status = await this.sendReceive("starknet_unsubscribe", {
12844
- subscription_id: subscriptionId
12845
- });
12879
+ let status;
12880
+ try {
12881
+ status = await this.sendReceive("starknet_unsubscribe", {
12882
+ subscription_id: subscriptionId
12883
+ });
12884
+ } catch (error) {
12885
+ this._settleUnsubscribeWaiters(subscriptionId, error);
12886
+ throw error;
12887
+ }
12846
12888
  if (status) {
12847
12889
  this.events.emit("unsubscribe", subscriptionId);
12890
+ this._settleUnsubscribeWaiters(subscriptionId);
12891
+ } else {
12892
+ this._settleUnsubscribeWaiters(
12893
+ subscriptionId,
12894
+ new Error(`Node refused to unsubscribe subscription ${subscriptionId}`)
12895
+ );
12848
12896
  }
12849
12897
  return status;
12850
12898
  }
12899
+ /** Settles every caller waiting on one subscription id: resolved, or rejected with `error`. */
12900
+ _settleUnsubscribeWaiters(subscriptionId, error) {
12901
+ const waiters = this.unsubscribeWaiters.get(subscriptionId);
12902
+ if (!waiters) return;
12903
+ this.unsubscribeWaiters.delete(subscriptionId);
12904
+ waiters.forEach((waiter) => error ? waiter.reject(error) : waiter.resolve());
12905
+ }
12906
+ /**
12907
+ * Rejects every caller still waiting on any subscription.
12908
+ *
12909
+ * Once the connection is gone, no unsubscribe can be observed on it: a reconnection restores
12910
+ * each subscription under a fresh id, so the id being waited on will never be announced.
12911
+ */
12912
+ _rejectUnsubscribeWaiters(reason) {
12913
+ if (this.unsubscribeWaiters.size === 0) return;
12914
+ Array.from(this.unsubscribeWaiters.keys()).forEach(
12915
+ (id) => this._settleUnsubscribeWaiters(
12916
+ id,
12917
+ new WebSocketNotConnectedError(`Subscription ${id} was never unsubscribed: ${reason}`)
12918
+ )
12919
+ );
12920
+ }
12851
12921
  /**
12852
12922
  * Returns a Promise that resolves when a specific subscription is successfully unsubscribed.
12853
12923
  * @param {SUBSCRIPTION_ID} targetId - The ID of the subscription to wait for.
@@ -12859,14 +12929,10 @@ ${indent}}` : "}";
12859
12929
  * ```
12860
12930
  */
12861
12931
  waitForUnsubscription(targetId) {
12862
- return new Promise((resolve) => {
12863
- const listener = (unsubId) => {
12864
- if (unsubId === targetId) {
12865
- this.events.off("unsubscribe", listener);
12866
- resolve();
12867
- }
12868
- };
12869
- this.events.on("unsubscribe", listener);
12932
+ return new Promise((resolve, reject) => {
12933
+ const waiters = this.unsubscribeWaiters.get(targetId) ?? /* @__PURE__ */ new Set();
12934
+ waiters.add({ resolve, reject });
12935
+ this.unsubscribeWaiters.set(targetId, waiters);
12870
12936
  });
12871
12937
  }
12872
12938
  /**
@@ -12933,6 +12999,7 @@ ${indent}}` : "}";
12933
12999
  logger.info(`Subscription ${sub.method} restored with new ID: ${newSubId}`);
12934
13000
  } catch (error) {
12935
13001
  logger.error(`Failed to restore subscription ${sub.method}:`, error);
13002
+ sub._markClosed();
12936
13003
  }
12937
13004
  });
12938
13005
  await Promise.all(restorePromises);
@@ -13002,6 +13069,7 @@ ${indent}}` : "}";
13002
13069
  this.websocket.removeEventListener("message", this.messageListener);
13003
13070
  this.websocket.removeEventListener("error", this.errorListener);
13004
13071
  this._rejectInFlight("the connection was closed");
13072
+ this._rejectUnsubscribeWaiters("the connection was closed");
13005
13073
  this.events.emit("close", ev);
13006
13074
  if (!this.userInitiatedClose) {
13007
13075
  this._startReconnect();
@@ -13023,9 +13091,16 @@ ${indent}}` : "}";
13023
13091
  if (subscription) {
13024
13092
  subscription._handleEvent(result);
13025
13093
  } else {
13026
- logger.warn(
13027
- `WebSocketChannel: Received event for untracked subscription ID: ${subscription_id}.`
13028
- );
13094
+ queueMicrotask(() => {
13095
+ const registered = this.activeSubscriptions.get(subscription_id);
13096
+ if (registered) {
13097
+ registered._handleEvent(result);
13098
+ } else {
13099
+ logger.warn(
13100
+ `WebSocketChannel: Received event for untracked subscription ID: ${subscription_id}.`
13101
+ );
13102
+ }
13103
+ });
13029
13104
  }
13030
13105
  }
13031
13106
  logger.debug("onMessageProxy:", event.data);
@@ -18072,7 +18147,7 @@ ${indent}}` : "}";
18072
18147
  }
18073
18148
  function toWalletApiActions(actions) {
18074
18149
  return actions.map(
18075
- (action) => action.type === "subaccount_invoke" ? { ...action, calls: action.calls.map(toWalletApiCall) } : action
18150
+ (action) => action.type === "shadow_account_invoke" ? { ...action, calls: action.calls.map(toWalletApiCall) } : action
18076
18151
  );
18077
18152
  }
18078
18153
 
@@ -18091,7 +18166,7 @@ ${indent}}` : "}";
18091
18166
  strk20Balances: () => strk20Balances,
18092
18167
  strk20InvokeTransaction: () => strk20InvokeTransaction,
18093
18168
  strk20PrepareInvoke: () => strk20PrepareInvoke,
18094
- strk20SubaccountCommitment: () => strk20SubaccountCommitment,
18169
+ strk20ShadowAccountCommitment: () => strk20ShadowAccountCommitment,
18095
18170
  subscribeWalletEvent: () => subscribeWalletEvent2,
18096
18171
  supportedSpecs: () => supportedSpecs3,
18097
18172
  supportedWalletApi: () => supportedWalletApi3,
@@ -18179,9 +18254,9 @@ ${indent}}` : "}";
18179
18254
  params: { actions }
18180
18255
  });
18181
18256
  }
18182
- function strk20SubaccountCommitment(walletWSF, dapp_name, nonce) {
18257
+ function strk20ShadowAccountCommitment(walletWSF, dapp_name, nonce) {
18183
18258
  return walletWSF.features["starknet:walletApi"].request({
18184
- type: "wallet_strk20SubaccountCommitment",
18259
+ type: "wallet_strk20ShadowAccountCommitment",
18185
18260
  params: { dapp_name, nonce }
18186
18261
  });
18187
18262
  }
@@ -18273,25 +18348,25 @@ ${indent}}` : "}";
18273
18348
  return strk20InvokeTransaction(this.v6Provider, toWalletApiActions(actions));
18274
18349
  }
18275
18350
  /**
18276
- * Compute the commitment of a DAPP STRK20 sub-account. The commitment is computed
18351
+ * Compute the commitment of a DAPP STRK20 shadow account. The commitment is computed
18277
18352
  * locally by the wallet from the user private state ; no transaction is sent.
18278
18353
  *
18279
- * When `nonce` is given, the full commitment of this single sub-account is returned.
18354
+ * When `nonce` is given, the full commitment of this single shadow account is returned.
18280
18355
  * When `nonce` is omitted, the partial (nonce independent) commitment is returned
18281
- * instead : it is shared by every sub-account the user derives for this DAPP, so it can
18282
- * be published once to let a DAPP recognize all the sub-accounts of a user without
18283
- * learning any individual nonce.
18284
- * @param {STRK20_DAPP_NAME} dappName - The DAPP that scopes the sub-account(s).
18285
- * @param {FELT} [nonce] - The sub-account nonce ; each nonce selects a distinct sub-account for this user + DAPP. Omit it to get the partial commitment.
18286
- * @returns {Promise<FELT>} The sub-account commitment.
18356
+ * instead : it is shared by every shadow account the user derives for this DAPP, so it
18357
+ * can be published once to let a DAPP recognize all the shadow accounts of a user
18358
+ * without learning any individual nonce.
18359
+ * @param {STRK20_DAPP_NAME} dappName - The DAPP that scopes the shadow account(s).
18360
+ * @param {FELT} [nonce] - The shadow account nonce ; each nonce selects a distinct shadow account for this user + DAPP. Omit it to get the partial commitment.
18361
+ * @returns {Promise<FELT>} The shadow account commitment.
18287
18362
  * @example
18288
18363
  * ```typescript
18289
- * const commitment = await myWalletAccount.strk20SubaccountCommitment('myDapp', '0x0');
18364
+ * const commitment = await myWalletAccount.strk20ShadowAccountCommitment('myDapp', '0x0');
18290
18365
  * // commitment = '0x5f2e...'
18291
18366
  * ```
18292
18367
  */
18293
- strk20SubaccountCommitment(dappName, nonce) {
18294
- return strk20SubaccountCommitment(this.v6Provider, dappName, nonce);
18368
+ strk20ShadowAccountCommitment(dappName, nonce) {
18369
+ return strk20ShadowAccountCommitment(this.v6Provider, dappName, nonce);
18295
18370
  }
18296
18371
  static async connect(provider, walletProvider, cairoVersion, paymaster, silentMode = false) {
18297
18372
  const { accounts } = await standardConnect2(walletProvider, silentMode);