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.js CHANGED
@@ -7815,11 +7815,12 @@ var WebSocketChannel = class {
7815
7815
  this.websocket.addEventListener("error", this.errorListener);
7816
7816
  }
7817
7817
  _processRequestQueue() {
7818
- logger.info(`WebSocket: Processing ${this.requestQueue.length} queued requests.`);
7819
- while (this.requestQueue.length > 0) {
7820
- const { method, params, resolve, reject } = this.requestQueue.shift();
7818
+ const pending = this.requestQueue;
7819
+ this.requestQueue = [];
7820
+ logger.info(`WebSocket: Processing ${pending.length} queued requests.`);
7821
+ pending.forEach(({ method, params, resolve, reject }) => {
7821
7822
  this.sendReceive(method, params).then(resolve).catch(reject);
7822
- }
7823
+ });
7823
7824
  }
7824
7825
  async _restoreSubscriptions() {
7825
7826
  const oldSubscriptions = Array.from(this.activeSubscriptions.values());
@@ -12948,6 +12949,27 @@ var WalletAccountV5 = class _WalletAccountV5 extends Account {
12948
12949
  // TODO: MISSING ESTIMATES
12949
12950
  };
12950
12951
 
12952
+ // src/wallet/adapterV6.ts
12953
+ function toWalletApiCall(call) {
12954
+ return {
12955
+ contract_address: call.contractAddress,
12956
+ entry_point: call.entrypoint,
12957
+ calldata: CallData.toHex(call.calldata)
12958
+ };
12959
+ }
12960
+ function fromWalletApiCall(call) {
12961
+ return {
12962
+ contractAddress: call.contract_address,
12963
+ entrypoint: call.entry_point,
12964
+ calldata: call.calldata ?? []
12965
+ };
12966
+ }
12967
+ function toWalletApiActions(actions) {
12968
+ return actions.map(
12969
+ (action) => action.type === "subaccount_invoke" ? { ...action, calls: action.calls.map(toWalletApiCall) } : action
12970
+ );
12971
+ }
12972
+
12951
12973
  // src/wallet/connectV6.ts
12952
12974
  var connectV6_exports = {};
12953
12975
  __export(connectV6_exports, {
@@ -12963,6 +12985,7 @@ __export(connectV6_exports, {
12963
12985
  strk20Balances: () => strk20Balances,
12964
12986
  strk20InvokeTransaction: () => strk20InvokeTransaction,
12965
12987
  strk20PrepareInvoke: () => strk20PrepareInvoke,
12988
+ strk20SubaccountCommitment: () => strk20SubaccountCommitment,
12966
12989
  subscribeWalletEvent: () => subscribeWalletEvent2,
12967
12990
  supportedSpecs: () => supportedSpecs3,
12968
12991
  supportedWalletApi: () => supportedWalletApi3,
@@ -13050,6 +13073,12 @@ function strk20InvokeTransaction(walletWSF, actions) {
13050
13073
  params: { actions }
13051
13074
  });
13052
13075
  }
13076
+ function strk20SubaccountCommitment(walletWSF, dapp_name, nonce) {
13077
+ return walletWSF.features["starknet:walletApi"].request({
13078
+ type: "wallet_strk20SubaccountCommitment",
13079
+ params: { dapp_name, nonce }
13080
+ });
13081
+ }
13053
13082
 
13054
13083
  // src/wallet/accountV6.ts
13055
13084
  var WalletAccountV6 = class _WalletAccountV6 extends WalletAccountV5 {
@@ -13063,22 +13092,100 @@ var WalletAccountV6 = class _WalletAccountV6 extends WalletAccountV5 {
13063
13092
  switchStarknetChain(chainId, silent_mode = false) {
13064
13093
  return switchStarknetChain3(this.v6Provider, chainId, silent_mode);
13065
13094
  }
13095
+ /**
13096
+ * Execute call(s) with an optional STRK20 privacy proof attached. Same signature as
13097
+ * `execute()`, with an extra parameter for the proof provided by `strk20PrepareInvoke()`.
13098
+ * @param {AllowArray<Call>} calls - The call(s) to invoke.
13099
+ * @param {STRK20_PROOF} [proof] - The SNIP-36 zero-knowledge proof to attach.
13100
+ * @returns {Promise<AddInvokeTransactionResult>} The hash of the submitted transaction.
13101
+ * @example
13102
+ * ```typescript
13103
+ * const { proof } = await myWalletAccount.strk20PrepareInvoke(actions);
13104
+ * const result = await myWalletAccount.executeWithProof(myContract.populate('claim'), proof);
13105
+ * // result = { transaction_hash: '0x6f7d...' }
13106
+ * ```
13107
+ */
13066
13108
  executeWithProof(calls, proof) {
13067
- const txCalls = [].concat(calls).map((it) => ({
13068
- contract_address: it.contractAddress,
13069
- entry_point: it.entrypoint,
13070
- calldata: it.calldata
13071
- }));
13109
+ const txCalls = [].concat(calls).map(toWalletApiCall);
13072
13110
  return addInvokeTransaction3(this.v6Provider, { calls: txCalls, proof });
13073
13111
  }
13112
+ /**
13113
+ * Get the private balances held by the user inside the STRK20 privacy pool.
13114
+ * @param {Address[]} tokens - The tokens to get the private balance of. An empty array returns every shielded token.
13115
+ * @returns {Promise<STRK20_BALANCE_ENTRY[]>} One entry per token.
13116
+ * @example
13117
+ * ```typescript
13118
+ * const balances = await myWalletAccount.strk20Balances([strkAddress]);
13119
+ * // balances = [{ token: '0x4718...', amount: '0x2386f26fc10000' }]
13120
+ * ```
13121
+ */
13074
13122
  strk20Balances(tokens) {
13075
13123
  return strk20Balances(this.v6Provider, tokens);
13076
13124
  }
13077
- strk20PrepareInvoke(actions, simulate) {
13078
- return strk20PrepareInvoke(this.v6Provider, actions, simulate);
13125
+ /**
13126
+ * Build the Starknet call and the SNIP-36 zero-knowledge proof of a STRK20 transaction,
13127
+ * without submitting it : the DAPP submits the returned call itself, and therefore pays
13128
+ * the fee (the wallet adds no fee action in this mode).
13129
+ *
13130
+ * With `simulate` set to true, the wallet skips the expensive proof generation and
13131
+ * returns an empty proof : the call is then NOT submittable on-chain, and is only useful
13132
+ * for fee estimation or UI previews.
13133
+ * @param {STRK20_ACTION[]} actions - The STRK20 actions to perform atomically (min 1).
13134
+ * @param {boolean} [simulate] - True to skip the proof generation.
13135
+ * @returns {Promise<STRK20_CALL_AND_PROOF>} The Starknet.js call to submit, and its proof.
13136
+ * @example
13137
+ * ```typescript
13138
+ * const { call, proof } = await myWalletAccount.strk20PrepareInvoke(actions);
13139
+ * const result = await mySponsorAccount.execute(call, {
13140
+ * proof: proof.data,
13141
+ * proofFacts: proof.proof_facts,
13142
+ * });
13143
+ * // result = { transaction_hash: '0x6f7d...' }
13144
+ * ```
13145
+ */
13146
+ async strk20PrepareInvoke(actions, simulate) {
13147
+ const { call, proof } = await strk20PrepareInvoke(
13148
+ this.v6Provider,
13149
+ toWalletApiActions(actions),
13150
+ simulate
13151
+ );
13152
+ return { call: fromWalletApiCall(call), proof };
13079
13153
  }
13154
+ /**
13155
+ * Submit STRK20 actions as a single atomic transaction. The wallet displays an approval
13156
+ * UI, generates the SNIP-36 proof, adds the fee action, and submits — so this call may
13157
+ * take significantly longer than a standard invoke.
13158
+ * @param {STRK20_ACTION[]} actions - The STRK20 actions to perform atomically (min 1).
13159
+ * @returns {Promise<{transaction_hash: string}>} The hash of the submitted transaction.
13160
+ * @example
13161
+ * ```typescript
13162
+ * const result = await myWalletAccount.strk20InvokeTransaction(actions);
13163
+ * // result = { transaction_hash: '0x6f7d...' }
13164
+ * ```
13165
+ */
13080
13166
  strk20InvokeTransaction(actions) {
13081
- return strk20InvokeTransaction(this.v6Provider, actions);
13167
+ return strk20InvokeTransaction(this.v6Provider, toWalletApiActions(actions));
13168
+ }
13169
+ /**
13170
+ * Compute the commitment of a DAPP STRK20 sub-account. The commitment is computed
13171
+ * locally by the wallet from the user private state ; no transaction is sent.
13172
+ *
13173
+ * When `nonce` is given, the full commitment of this single sub-account is returned.
13174
+ * When `nonce` is omitted, the partial (nonce independent) commitment is returned
13175
+ * instead : it is shared by every sub-account the user derives for this DAPP, so it can
13176
+ * be published once to let a DAPP recognize all the sub-accounts of a user without
13177
+ * learning any individual nonce.
13178
+ * @param {STRK20_DAPP_NAME} dappName - The DAPP that scopes the sub-account(s).
13179
+ * @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.
13180
+ * @returns {Promise<FELT>} The sub-account commitment.
13181
+ * @example
13182
+ * ```typescript
13183
+ * const commitment = await myWalletAccount.strk20SubaccountCommitment('myDapp', '0x0');
13184
+ * // commitment = '0x5f2e...'
13185
+ * ```
13186
+ */
13187
+ strk20SubaccountCommitment(dappName, nonce) {
13188
+ return strk20SubaccountCommitment(this.v6Provider, dappName, nonce);
13082
13189
  }
13083
13190
  static async connect(provider, walletProvider, cairoVersion, paymaster, silentMode = false) {
13084
13191
  const { accounts } = await standardConnect2(walletProvider, silentMode);