starknet 10.5.3 → 10.6.1

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.mjs CHANGED
@@ -7632,11 +7632,12 @@ var WebSocketChannel = class {
7632
7632
  this.websocket.addEventListener("error", this.errorListener);
7633
7633
  }
7634
7634
  _processRequestQueue() {
7635
- logger.info(`WebSocket: Processing ${this.requestQueue.length} queued requests.`);
7636
- while (this.requestQueue.length > 0) {
7637
- const { method, params, resolve, reject } = this.requestQueue.shift();
7635
+ const pending = this.requestQueue;
7636
+ this.requestQueue = [];
7637
+ logger.info(`WebSocket: Processing ${pending.length} queued requests.`);
7638
+ pending.forEach(({ method, params, resolve, reject }) => {
7638
7639
  this.sendReceive(method, params).then(resolve).catch(reject);
7639
- }
7640
+ });
7640
7641
  }
7641
7642
  async _restoreSubscriptions() {
7642
7643
  const oldSubscriptions = Array.from(this.activeSubscriptions.values());
@@ -12765,6 +12766,27 @@ var WalletAccountV5 = class _WalletAccountV5 extends Account {
12765
12766
  // TODO: MISSING ESTIMATES
12766
12767
  };
12767
12768
 
12769
+ // src/wallet/adapterV6.ts
12770
+ function toWalletApiCall(call) {
12771
+ return {
12772
+ contract_address: call.contractAddress,
12773
+ entry_point: call.entrypoint,
12774
+ calldata: CallData.toHex(call.calldata)
12775
+ };
12776
+ }
12777
+ function fromWalletApiCall(call) {
12778
+ return {
12779
+ contractAddress: call.contract_address,
12780
+ entrypoint: call.entry_point,
12781
+ calldata: call.calldata ?? []
12782
+ };
12783
+ }
12784
+ function toWalletApiActions(actions) {
12785
+ return actions.map(
12786
+ (action) => action.type === "subaccount_invoke" ? { ...action, calls: action.calls.map(toWalletApiCall) } : action
12787
+ );
12788
+ }
12789
+
12768
12790
  // src/wallet/connectV6.ts
12769
12791
  var connectV6_exports = {};
12770
12792
  __export(connectV6_exports, {
@@ -12780,6 +12802,7 @@ __export(connectV6_exports, {
12780
12802
  strk20Balances: () => strk20Balances,
12781
12803
  strk20InvokeTransaction: () => strk20InvokeTransaction,
12782
12804
  strk20PrepareInvoke: () => strk20PrepareInvoke,
12805
+ strk20SubaccountCommitment: () => strk20SubaccountCommitment,
12783
12806
  subscribeWalletEvent: () => subscribeWalletEvent2,
12784
12807
  supportedSpecs: () => supportedSpecs3,
12785
12808
  supportedWalletApi: () => supportedWalletApi3,
@@ -12867,6 +12890,12 @@ function strk20InvokeTransaction(walletWSF, actions) {
12867
12890
  params: { actions }
12868
12891
  });
12869
12892
  }
12893
+ function strk20SubaccountCommitment(walletWSF, dapp_name, nonce) {
12894
+ return walletWSF.features["starknet:walletApi"].request({
12895
+ type: "wallet_strk20SubaccountCommitment",
12896
+ params: { dapp_name, nonce }
12897
+ });
12898
+ }
12870
12899
 
12871
12900
  // src/wallet/accountV6.ts
12872
12901
  var WalletAccountV6 = class _WalletAccountV6 extends WalletAccountV5 {
@@ -12880,22 +12909,100 @@ var WalletAccountV6 = class _WalletAccountV6 extends WalletAccountV5 {
12880
12909
  switchStarknetChain(chainId, silent_mode = false) {
12881
12910
  return switchStarknetChain3(this.v6Provider, chainId, silent_mode);
12882
12911
  }
12912
+ /**
12913
+ * Execute call(s) with an optional STRK20 privacy proof attached. Same signature as
12914
+ * `execute()`, with an extra parameter for the proof provided by `strk20PrepareInvoke()`.
12915
+ * @param {AllowArray<Call>} calls - The call(s) to invoke.
12916
+ * @param {STRK20_PROOF} [proof] - The SNIP-36 zero-knowledge proof to attach.
12917
+ * @returns {Promise<AddInvokeTransactionResult>} The hash of the submitted transaction.
12918
+ * @example
12919
+ * ```typescript
12920
+ * const { proof } = await myWalletAccount.strk20PrepareInvoke(actions);
12921
+ * const result = await myWalletAccount.executeWithProof(myContract.populate('claim'), proof);
12922
+ * // result = { transaction_hash: '0x6f7d...' }
12923
+ * ```
12924
+ */
12883
12925
  executeWithProof(calls, proof) {
12884
- const txCalls = [].concat(calls).map((it) => ({
12885
- contract_address: it.contractAddress,
12886
- entry_point: it.entrypoint,
12887
- calldata: it.calldata
12888
- }));
12926
+ const txCalls = [].concat(calls).map(toWalletApiCall);
12889
12927
  return addInvokeTransaction3(this.v6Provider, { calls: txCalls, proof });
12890
12928
  }
12929
+ /**
12930
+ * Get the private balances held by the user inside the STRK20 privacy pool.
12931
+ * @param {Address[]} tokens - The tokens to get the private balance of. An empty array returns every shielded token.
12932
+ * @returns {Promise<STRK20_BALANCE_ENTRY[]>} One entry per token.
12933
+ * @example
12934
+ * ```typescript
12935
+ * const balances = await myWalletAccount.strk20Balances([strkAddress]);
12936
+ * // balances = [{ token: '0x4718...', amount: '0x2386f26fc10000' }]
12937
+ * ```
12938
+ */
12891
12939
  strk20Balances(tokens) {
12892
12940
  return strk20Balances(this.v6Provider, tokens);
12893
12941
  }
12894
- strk20PrepareInvoke(actions, simulate) {
12895
- return strk20PrepareInvoke(this.v6Provider, actions, simulate);
12942
+ /**
12943
+ * Build the Starknet call and the SNIP-36 zero-knowledge proof of a STRK20 transaction,
12944
+ * without submitting it : the DAPP submits the returned call itself, and therefore pays
12945
+ * the fee (the wallet adds no fee action in this mode).
12946
+ *
12947
+ * With `simulate` set to true, the wallet skips the expensive proof generation and
12948
+ * returns an empty proof : the call is then NOT submittable on-chain, and is only useful
12949
+ * for fee estimation or UI previews.
12950
+ * @param {STRK20_ACTION[]} actions - The STRK20 actions to perform atomically (min 1).
12951
+ * @param {boolean} [simulate] - True to skip the proof generation.
12952
+ * @returns {Promise<STRK20_CALL_AND_PROOF>} The Starknet.js call to submit, and its proof.
12953
+ * @example
12954
+ * ```typescript
12955
+ * const { call, proof } = await myWalletAccount.strk20PrepareInvoke(actions);
12956
+ * const result = await mySponsorAccount.execute(call, {
12957
+ * proof: proof.data,
12958
+ * proofFacts: proof.proof_facts,
12959
+ * });
12960
+ * // result = { transaction_hash: '0x6f7d...' }
12961
+ * ```
12962
+ */
12963
+ async strk20PrepareInvoke(actions, simulate) {
12964
+ const { call, proof } = await strk20PrepareInvoke(
12965
+ this.v6Provider,
12966
+ toWalletApiActions(actions),
12967
+ simulate
12968
+ );
12969
+ return { call: fromWalletApiCall(call), proof };
12896
12970
  }
12971
+ /**
12972
+ * Submit STRK20 actions as a single atomic transaction. The wallet displays an approval
12973
+ * UI, generates the SNIP-36 proof, adds the fee action, and submits — so this call may
12974
+ * take significantly longer than a standard invoke.
12975
+ * @param {STRK20_ACTION[]} actions - The STRK20 actions to perform atomically (min 1).
12976
+ * @returns {Promise<{transaction_hash: string}>} The hash of the submitted transaction.
12977
+ * @example
12978
+ * ```typescript
12979
+ * const result = await myWalletAccount.strk20InvokeTransaction(actions);
12980
+ * // result = { transaction_hash: '0x6f7d...' }
12981
+ * ```
12982
+ */
12897
12983
  strk20InvokeTransaction(actions) {
12898
- return strk20InvokeTransaction(this.v6Provider, actions);
12984
+ return strk20InvokeTransaction(this.v6Provider, toWalletApiActions(actions));
12985
+ }
12986
+ /**
12987
+ * Compute the commitment of a DAPP STRK20 sub-account. The commitment is computed
12988
+ * locally by the wallet from the user private state ; no transaction is sent.
12989
+ *
12990
+ * When `nonce` is given, the full commitment of this single sub-account is returned.
12991
+ * When `nonce` is omitted, the partial (nonce independent) commitment is returned
12992
+ * instead : it is shared by every sub-account the user derives for this DAPP, so it can
12993
+ * be published once to let a DAPP recognize all the sub-accounts of a user without
12994
+ * learning any individual nonce.
12995
+ * @param {STRK20_DAPP_NAME} dappName - The DAPP that scopes the sub-account(s).
12996
+ * @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.
12997
+ * @returns {Promise<FELT>} The sub-account commitment.
12998
+ * @example
12999
+ * ```typescript
13000
+ * const commitment = await myWalletAccount.strk20SubaccountCommitment('myDapp', '0x0');
13001
+ * // commitment = '0x5f2e...'
13002
+ * ```
13003
+ */
13004
+ strk20SubaccountCommitment(dappName, nonce) {
13005
+ return strk20SubaccountCommitment(this.v6Provider, dappName, nonce);
12899
13006
  }
12900
13007
  static async connect(provider, walletProvider, cairoVersion, paymaster, silentMode = false) {
12901
13008
  const { accounts } = await standardConnect2(walletProvider, silentMode);