starknet 10.2.0 → 10.3.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/dist/index.js CHANGED
@@ -6624,6 +6624,12 @@ var RpcChannel = class {
6624
6624
  });
6625
6625
  return this.waitMode ? this.waitForTransaction((await promise).transaction_hash) : promise;
6626
6626
  }
6627
+ async invokeSignedTx(transaction) {
6628
+ const promise = this.fetchEndpoint("starknet_addInvokeTransaction", {
6629
+ invoke_transaction: transaction
6630
+ });
6631
+ return this.waitMode ? this.waitForTransaction((await promise).transaction_hash) : promise;
6632
+ }
6627
6633
  async declare(declareTransaction, details) {
6628
6634
  const transaction = await this.buildTransaction(
6629
6635
  {
@@ -7233,6 +7239,12 @@ var RpcChannel2 = class {
7233
7239
  });
7234
7240
  return this.waitMode ? this.waitForTransaction((await promise).transaction_hash) : promise;
7235
7241
  }
7242
+ async invokeSignedTx(transaction) {
7243
+ const promise = this.fetchEndpoint("starknet_addInvokeTransaction", {
7244
+ invoke_transaction: transaction
7245
+ });
7246
+ return this.waitMode ? this.waitForTransaction((await promise).transaction_hash) : promise;
7247
+ }
7236
7248
  async declare(declareTransaction, details) {
7237
7249
  const transaction = await this.buildTransaction(
7238
7250
  {
@@ -9923,6 +9935,34 @@ var RpcProvider = class {
9923
9935
  async invokeFunction(functionInvocation, details) {
9924
9936
  return this.channel.invoke(functionInvocation, details);
9925
9937
  }
9938
+ /**
9939
+ * Submit a pre-signed INVOKE_TXN_V3 transaction to the network.
9940
+ *
9941
+ * Broadcasts a transaction previously built and signed by `Account.getSignedTransaction()`.
9942
+ * Fees are already included in the signed transaction and will not be re-estimated.
9943
+ *
9944
+ * @param transaction - A fully signed `RPC.INVOKE_TXN_V3` object, as returned by `Account.getSignedTransaction()`
9945
+ *
9946
+ * @returns The transaction hash if `waitMode` is disabled (default), or the transaction receipt if `waitMode` is enabled.
9947
+ *
9948
+ * @remarks
9949
+ * - The transaction must be signed before calling this method ; use `Account.getSignedTransaction()` to produce it.
9950
+ * - Resubmitting the same signed transaction (same nonce) will be rejected by the network.
9951
+ * - If `waitMode` is enabled on the provider, this method waits for the transaction to be included in a block before returning.
9952
+ *
9953
+ * @example
9954
+ * ```typescript
9955
+ * const signedTx = await account.getSignedTransaction([
9956
+ * { contractAddress: erc20Address, entrypoint: 'transfer', calldata: [recipient, amount, 0] }
9957
+ * ]);
9958
+ * // inspect or store signedTx, then submit when ready:
9959
+ * const { transaction_hash } = await provider.invokeSignedTx(signedTx);
9960
+ * await provider.waitForTransaction(transaction_hash);
9961
+ * ```
9962
+ */
9963
+ async invokeSignedTx(transaction) {
9964
+ return this.channel.invokeSignedTx(transaction);
9965
+ }
9926
9966
  async declareContract(transaction, details) {
9927
9967
  return this.channel.declare(transaction, details);
9928
9968
  }
@@ -11805,7 +11845,12 @@ var Account = class {
11805
11845
  returnInitialReads
11806
11846
  });
11807
11847
  }
11808
- async execute(transactions, transactionsDetail = {}) {
11848
+ /**
11849
+ * Shared preparation logic for execute() and buildExecute().
11850
+ * Runs hooks, estimates fees, and builds accountInvocations.
11851
+ * @private
11852
+ */
11853
+ async prepareInvoke(transactions, transactionsDetail = {}) {
11809
11854
  const hookResult = this.accountPluginManager.runAccountHook("beforeExecute", {
11810
11855
  calls: transactions,
11811
11856
  details: transactionsDetail
@@ -11830,7 +11875,15 @@ var Account = class {
11830
11875
  skipValidate: false
11831
11876
  }
11832
11877
  );
11833
- const invocation = accountInvocations[0];
11878
+ return {
11879
+ invocation: accountInvocations[0],
11880
+ hookedTransactions,
11881
+ hookedDetails,
11882
+ detailsWithTip
11883
+ };
11884
+ }
11885
+ async execute(transactions, transactionsDetail = {}) {
11886
+ const { invocation, hookedTransactions, hookedDetails, detailsWithTip } = await this.prepareInvoke(transactions, transactionsDetail);
11834
11887
  const result = await this.provider.invokeFunction(
11835
11888
  {
11836
11889
  contractAddress: invocation.contractAddress,
@@ -11852,6 +11905,51 @@ var Account = class {
11852
11905
  });
11853
11906
  return result;
11854
11907
  }
11908
+ /**
11909
+ * Build a signed INVOKE_TXN_V3 transaction without submitting it to the network.
11910
+ *
11911
+ * Produces a fully signed transaction object that can be inspected, stored,
11912
+ * or submitted later via `provider.channel.sendTransaction()`.
11913
+ * Main usage is to send a virtual transaction to a proof server.
11914
+ * Fees are estimated automatically if not provided.
11915
+ *
11916
+ * @param transactions - Single call or array of calls to include in the transaction
11917
+ * @param transactionsDetail - Transaction execution options
11918
+ * @returns A fully signed `RPC.INVOKE_TXN_V3` object, ready to broadcast
11919
+ *
11920
+ * @remarks
11921
+ * - Unlike `execute()`, this method does **not** submit the transaction ; the account nonce is unchanged after the call.
11922
+ * - The `afterExecute` plugin hook is intentionally **not** triggered.
11923
+ * - The returned object can be broadcast with `provider.channel.sendTransaction()`.
11924
+ *
11925
+ * @example
11926
+ * ```typescript
11927
+ * const signedTx = await account.getSignedTransaction(
11928
+ * { contractAddress: erc20Address, entrypoint: 'transfer', calldata: [recipient, amount, 0] }
11929
+ * );
11930
+ * ```
11931
+ */
11932
+ async getSignedTransaction(transactions, transactionsDetail = {}) {
11933
+ const { invocation, hookedDetails, detailsWithTip } = await this.prepareInvoke(
11934
+ transactions,
11935
+ transactionsDetail
11936
+ );
11937
+ return this.provider.channel.buildTransaction(
11938
+ {
11939
+ type: api_exports.ETransactionType.INVOKE,
11940
+ contractAddress: invocation.contractAddress,
11941
+ calldata: invocation.calldata,
11942
+ signature: invocation.signature,
11943
+ ...hookedDetails.proofFacts && { proofFacts: hookedDetails.proofFacts },
11944
+ ...hookedDetails.proof && { proof: hookedDetails.proof },
11945
+ ...v3Details(detailsWithTip),
11946
+ resourceBounds: invocation.resourceBounds,
11947
+ nonce: invocation.nonce,
11948
+ version: invocation.version
11949
+ },
11950
+ "transaction"
11951
+ );
11952
+ }
11855
11953
  /**
11856
11954
  * First check if contract is already declared, if not declare it
11857
11955
  * If contract already declared returned transaction_hash is ''.