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/CHANGELOG.md +6 -0
- package/dist/index.d.ts +270 -210
- package/dist/index.global.js +100 -2
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +100 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +100 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -6443,6 +6443,12 @@ var RpcChannel = class {
|
|
|
6443
6443
|
});
|
|
6444
6444
|
return this.waitMode ? this.waitForTransaction((await promise).transaction_hash) : promise;
|
|
6445
6445
|
}
|
|
6446
|
+
async invokeSignedTx(transaction) {
|
|
6447
|
+
const promise = this.fetchEndpoint("starknet_addInvokeTransaction", {
|
|
6448
|
+
invoke_transaction: transaction
|
|
6449
|
+
});
|
|
6450
|
+
return this.waitMode ? this.waitForTransaction((await promise).transaction_hash) : promise;
|
|
6451
|
+
}
|
|
6446
6452
|
async declare(declareTransaction, details) {
|
|
6447
6453
|
const transaction = await this.buildTransaction(
|
|
6448
6454
|
{
|
|
@@ -7052,6 +7058,12 @@ var RpcChannel2 = class {
|
|
|
7052
7058
|
});
|
|
7053
7059
|
return this.waitMode ? this.waitForTransaction((await promise).transaction_hash) : promise;
|
|
7054
7060
|
}
|
|
7061
|
+
async invokeSignedTx(transaction) {
|
|
7062
|
+
const promise = this.fetchEndpoint("starknet_addInvokeTransaction", {
|
|
7063
|
+
invoke_transaction: transaction
|
|
7064
|
+
});
|
|
7065
|
+
return this.waitMode ? this.waitForTransaction((await promise).transaction_hash) : promise;
|
|
7066
|
+
}
|
|
7055
7067
|
async declare(declareTransaction, details) {
|
|
7056
7068
|
const transaction = await this.buildTransaction(
|
|
7057
7069
|
{
|
|
@@ -9742,6 +9754,34 @@ var RpcProvider = class {
|
|
|
9742
9754
|
async invokeFunction(functionInvocation, details) {
|
|
9743
9755
|
return this.channel.invoke(functionInvocation, details);
|
|
9744
9756
|
}
|
|
9757
|
+
/**
|
|
9758
|
+
* Submit a pre-signed INVOKE_TXN_V3 transaction to the network.
|
|
9759
|
+
*
|
|
9760
|
+
* Broadcasts a transaction previously built and signed by `Account.getSignedTransaction()`.
|
|
9761
|
+
* Fees are already included in the signed transaction and will not be re-estimated.
|
|
9762
|
+
*
|
|
9763
|
+
* @param transaction - A fully signed `RPC.INVOKE_TXN_V3` object, as returned by `Account.getSignedTransaction()`
|
|
9764
|
+
*
|
|
9765
|
+
* @returns The transaction hash if `waitMode` is disabled (default), or the transaction receipt if `waitMode` is enabled.
|
|
9766
|
+
*
|
|
9767
|
+
* @remarks
|
|
9768
|
+
* - The transaction must be signed before calling this method ; use `Account.getSignedTransaction()` to produce it.
|
|
9769
|
+
* - Resubmitting the same signed transaction (same nonce) will be rejected by the network.
|
|
9770
|
+
* - If `waitMode` is enabled on the provider, this method waits for the transaction to be included in a block before returning.
|
|
9771
|
+
*
|
|
9772
|
+
* @example
|
|
9773
|
+
* ```typescript
|
|
9774
|
+
* const signedTx = await account.getSignedTransaction([
|
|
9775
|
+
* { contractAddress: erc20Address, entrypoint: 'transfer', calldata: [recipient, amount, 0] }
|
|
9776
|
+
* ]);
|
|
9777
|
+
* // inspect or store signedTx, then submit when ready:
|
|
9778
|
+
* const { transaction_hash } = await provider.invokeSignedTx(signedTx);
|
|
9779
|
+
* await provider.waitForTransaction(transaction_hash);
|
|
9780
|
+
* ```
|
|
9781
|
+
*/
|
|
9782
|
+
async invokeSignedTx(transaction) {
|
|
9783
|
+
return this.channel.invokeSignedTx(transaction);
|
|
9784
|
+
}
|
|
9745
9785
|
async declareContract(transaction, details) {
|
|
9746
9786
|
return this.channel.declare(transaction, details);
|
|
9747
9787
|
}
|
|
@@ -11624,7 +11664,12 @@ var Account = class {
|
|
|
11624
11664
|
returnInitialReads
|
|
11625
11665
|
});
|
|
11626
11666
|
}
|
|
11627
|
-
|
|
11667
|
+
/**
|
|
11668
|
+
* Shared preparation logic for execute() and buildExecute().
|
|
11669
|
+
* Runs hooks, estimates fees, and builds accountInvocations.
|
|
11670
|
+
* @private
|
|
11671
|
+
*/
|
|
11672
|
+
async prepareInvoke(transactions, transactionsDetail = {}) {
|
|
11628
11673
|
const hookResult = this.accountPluginManager.runAccountHook("beforeExecute", {
|
|
11629
11674
|
calls: transactions,
|
|
11630
11675
|
details: transactionsDetail
|
|
@@ -11649,7 +11694,15 @@ var Account = class {
|
|
|
11649
11694
|
skipValidate: false
|
|
11650
11695
|
}
|
|
11651
11696
|
);
|
|
11652
|
-
|
|
11697
|
+
return {
|
|
11698
|
+
invocation: accountInvocations[0],
|
|
11699
|
+
hookedTransactions,
|
|
11700
|
+
hookedDetails,
|
|
11701
|
+
detailsWithTip
|
|
11702
|
+
};
|
|
11703
|
+
}
|
|
11704
|
+
async execute(transactions, transactionsDetail = {}) {
|
|
11705
|
+
const { invocation, hookedTransactions, hookedDetails, detailsWithTip } = await this.prepareInvoke(transactions, transactionsDetail);
|
|
11653
11706
|
const result = await this.provider.invokeFunction(
|
|
11654
11707
|
{
|
|
11655
11708
|
contractAddress: invocation.contractAddress,
|
|
@@ -11671,6 +11724,51 @@ var Account = class {
|
|
|
11671
11724
|
});
|
|
11672
11725
|
return result;
|
|
11673
11726
|
}
|
|
11727
|
+
/**
|
|
11728
|
+
* Build a signed INVOKE_TXN_V3 transaction without submitting it to the network.
|
|
11729
|
+
*
|
|
11730
|
+
* Produces a fully signed transaction object that can be inspected, stored,
|
|
11731
|
+
* or submitted later via `provider.channel.sendTransaction()`.
|
|
11732
|
+
* Main usage is to send a virtual transaction to a proof server.
|
|
11733
|
+
* Fees are estimated automatically if not provided.
|
|
11734
|
+
*
|
|
11735
|
+
* @param transactions - Single call or array of calls to include in the transaction
|
|
11736
|
+
* @param transactionsDetail - Transaction execution options
|
|
11737
|
+
* @returns A fully signed `RPC.INVOKE_TXN_V3` object, ready to broadcast
|
|
11738
|
+
*
|
|
11739
|
+
* @remarks
|
|
11740
|
+
* - Unlike `execute()`, this method does **not** submit the transaction ; the account nonce is unchanged after the call.
|
|
11741
|
+
* - The `afterExecute` plugin hook is intentionally **not** triggered.
|
|
11742
|
+
* - The returned object can be broadcast with `provider.channel.sendTransaction()`.
|
|
11743
|
+
*
|
|
11744
|
+
* @example
|
|
11745
|
+
* ```typescript
|
|
11746
|
+
* const signedTx = await account.getSignedTransaction(
|
|
11747
|
+
* { contractAddress: erc20Address, entrypoint: 'transfer', calldata: [recipient, amount, 0] }
|
|
11748
|
+
* );
|
|
11749
|
+
* ```
|
|
11750
|
+
*/
|
|
11751
|
+
async getSignedTransaction(transactions, transactionsDetail = {}) {
|
|
11752
|
+
const { invocation, hookedDetails, detailsWithTip } = await this.prepareInvoke(
|
|
11753
|
+
transactions,
|
|
11754
|
+
transactionsDetail
|
|
11755
|
+
);
|
|
11756
|
+
return this.provider.channel.buildTransaction(
|
|
11757
|
+
{
|
|
11758
|
+
type: api_exports.ETransactionType.INVOKE,
|
|
11759
|
+
contractAddress: invocation.contractAddress,
|
|
11760
|
+
calldata: invocation.calldata,
|
|
11761
|
+
signature: invocation.signature,
|
|
11762
|
+
...hookedDetails.proofFacts && { proofFacts: hookedDetails.proofFacts },
|
|
11763
|
+
...hookedDetails.proof && { proof: hookedDetails.proof },
|
|
11764
|
+
...v3Details(detailsWithTip),
|
|
11765
|
+
resourceBounds: invocation.resourceBounds,
|
|
11766
|
+
nonce: invocation.nonce,
|
|
11767
|
+
version: invocation.version
|
|
11768
|
+
},
|
|
11769
|
+
"transaction"
|
|
11770
|
+
);
|
|
11771
|
+
}
|
|
11674
11772
|
/**
|
|
11675
11773
|
* First check if contract is already declared, if not declare it
|
|
11676
11774
|
* If contract already declared returned transaction_hash is ''.
|