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.global.js
CHANGED
|
@@ -11580,6 +11580,12 @@ ${indent}}` : "}";
|
|
|
11580
11580
|
});
|
|
11581
11581
|
return this.waitMode ? this.waitForTransaction((await promise).transaction_hash) : promise;
|
|
11582
11582
|
}
|
|
11583
|
+
async invokeSignedTx(transaction) {
|
|
11584
|
+
const promise = this.fetchEndpoint("starknet_addInvokeTransaction", {
|
|
11585
|
+
invoke_transaction: transaction
|
|
11586
|
+
});
|
|
11587
|
+
return this.waitMode ? this.waitForTransaction((await promise).transaction_hash) : promise;
|
|
11588
|
+
}
|
|
11583
11589
|
async declare(declareTransaction, details) {
|
|
11584
11590
|
const transaction = await this.buildTransaction(
|
|
11585
11591
|
{
|
|
@@ -12273,6 +12279,12 @@ ${indent}}` : "}";
|
|
|
12273
12279
|
});
|
|
12274
12280
|
return this.waitMode ? this.waitForTransaction((await promise).transaction_hash) : promise;
|
|
12275
12281
|
}
|
|
12282
|
+
async invokeSignedTx(transaction) {
|
|
12283
|
+
const promise = this.fetchEndpoint("starknet_addInvokeTransaction", {
|
|
12284
|
+
invoke_transaction: transaction
|
|
12285
|
+
});
|
|
12286
|
+
return this.waitMode ? this.waitForTransaction((await promise).transaction_hash) : promise;
|
|
12287
|
+
}
|
|
12276
12288
|
async declare(declareTransaction, details) {
|
|
12277
12289
|
const transaction = await this.buildTransaction(
|
|
12278
12290
|
{
|
|
@@ -14963,6 +14975,34 @@ ${indent}}` : "}";
|
|
|
14963
14975
|
async invokeFunction(functionInvocation, details) {
|
|
14964
14976
|
return this.channel.invoke(functionInvocation, details);
|
|
14965
14977
|
}
|
|
14978
|
+
/**
|
|
14979
|
+
* Submit a pre-signed INVOKE_TXN_V3 transaction to the network.
|
|
14980
|
+
*
|
|
14981
|
+
* Broadcasts a transaction previously built and signed by `Account.getSignedTransaction()`.
|
|
14982
|
+
* Fees are already included in the signed transaction and will not be re-estimated.
|
|
14983
|
+
*
|
|
14984
|
+
* @param transaction - A fully signed `RPC.INVOKE_TXN_V3` object, as returned by `Account.getSignedTransaction()`
|
|
14985
|
+
*
|
|
14986
|
+
* @returns The transaction hash if `waitMode` is disabled (default), or the transaction receipt if `waitMode` is enabled.
|
|
14987
|
+
*
|
|
14988
|
+
* @remarks
|
|
14989
|
+
* - The transaction must be signed before calling this method ; use `Account.getSignedTransaction()` to produce it.
|
|
14990
|
+
* - Resubmitting the same signed transaction (same nonce) will be rejected by the network.
|
|
14991
|
+
* - If `waitMode` is enabled on the provider, this method waits for the transaction to be included in a block before returning.
|
|
14992
|
+
*
|
|
14993
|
+
* @example
|
|
14994
|
+
* ```typescript
|
|
14995
|
+
* const signedTx = await account.getSignedTransaction([
|
|
14996
|
+
* { contractAddress: erc20Address, entrypoint: 'transfer', calldata: [recipient, amount, 0] }
|
|
14997
|
+
* ]);
|
|
14998
|
+
* // inspect or store signedTx, then submit when ready:
|
|
14999
|
+
* const { transaction_hash } = await provider.invokeSignedTx(signedTx);
|
|
15000
|
+
* await provider.waitForTransaction(transaction_hash);
|
|
15001
|
+
* ```
|
|
15002
|
+
*/
|
|
15003
|
+
async invokeSignedTx(transaction) {
|
|
15004
|
+
return this.channel.invokeSignedTx(transaction);
|
|
15005
|
+
}
|
|
14966
15006
|
async declareContract(transaction, details) {
|
|
14967
15007
|
return this.channel.declare(transaction, details);
|
|
14968
15008
|
}
|
|
@@ -16841,7 +16881,12 @@ ${indent}}` : "}";
|
|
|
16841
16881
|
returnInitialReads
|
|
16842
16882
|
});
|
|
16843
16883
|
}
|
|
16844
|
-
|
|
16884
|
+
/**
|
|
16885
|
+
* Shared preparation logic for execute() and buildExecute().
|
|
16886
|
+
* Runs hooks, estimates fees, and builds accountInvocations.
|
|
16887
|
+
* @private
|
|
16888
|
+
*/
|
|
16889
|
+
async prepareInvoke(transactions, transactionsDetail = {}) {
|
|
16845
16890
|
const hookResult = this.accountPluginManager.runAccountHook("beforeExecute", {
|
|
16846
16891
|
calls: transactions,
|
|
16847
16892
|
details: transactionsDetail
|
|
@@ -16866,7 +16911,15 @@ ${indent}}` : "}";
|
|
|
16866
16911
|
skipValidate: false
|
|
16867
16912
|
}
|
|
16868
16913
|
);
|
|
16869
|
-
|
|
16914
|
+
return {
|
|
16915
|
+
invocation: accountInvocations[0],
|
|
16916
|
+
hookedTransactions,
|
|
16917
|
+
hookedDetails,
|
|
16918
|
+
detailsWithTip
|
|
16919
|
+
};
|
|
16920
|
+
}
|
|
16921
|
+
async execute(transactions, transactionsDetail = {}) {
|
|
16922
|
+
const { invocation, hookedTransactions, hookedDetails, detailsWithTip } = await this.prepareInvoke(transactions, transactionsDetail);
|
|
16870
16923
|
const result = await this.provider.invokeFunction(
|
|
16871
16924
|
{
|
|
16872
16925
|
contractAddress: invocation.contractAddress,
|
|
@@ -16888,6 +16941,51 @@ ${indent}}` : "}";
|
|
|
16888
16941
|
});
|
|
16889
16942
|
return result;
|
|
16890
16943
|
}
|
|
16944
|
+
/**
|
|
16945
|
+
* Build a signed INVOKE_TXN_V3 transaction without submitting it to the network.
|
|
16946
|
+
*
|
|
16947
|
+
* Produces a fully signed transaction object that can be inspected, stored,
|
|
16948
|
+
* or submitted later via `provider.channel.sendTransaction()`.
|
|
16949
|
+
* Main usage is to send a virtual transaction to a proof server.
|
|
16950
|
+
* Fees are estimated automatically if not provided.
|
|
16951
|
+
*
|
|
16952
|
+
* @param transactions - Single call or array of calls to include in the transaction
|
|
16953
|
+
* @param transactionsDetail - Transaction execution options
|
|
16954
|
+
* @returns A fully signed `RPC.INVOKE_TXN_V3` object, ready to broadcast
|
|
16955
|
+
*
|
|
16956
|
+
* @remarks
|
|
16957
|
+
* - Unlike `execute()`, this method does **not** submit the transaction ; the account nonce is unchanged after the call.
|
|
16958
|
+
* - The `afterExecute` plugin hook is intentionally **not** triggered.
|
|
16959
|
+
* - The returned object can be broadcast with `provider.channel.sendTransaction()`.
|
|
16960
|
+
*
|
|
16961
|
+
* @example
|
|
16962
|
+
* ```typescript
|
|
16963
|
+
* const signedTx = await account.getSignedTransaction(
|
|
16964
|
+
* { contractAddress: erc20Address, entrypoint: 'transfer', calldata: [recipient, amount, 0] }
|
|
16965
|
+
* );
|
|
16966
|
+
* ```
|
|
16967
|
+
*/
|
|
16968
|
+
async getSignedTransaction(transactions, transactionsDetail = {}) {
|
|
16969
|
+
const { invocation, hookedDetails, detailsWithTip } = await this.prepareInvoke(
|
|
16970
|
+
transactions,
|
|
16971
|
+
transactionsDetail
|
|
16972
|
+
);
|
|
16973
|
+
return this.provider.channel.buildTransaction(
|
|
16974
|
+
{
|
|
16975
|
+
type: ETransactionType2.INVOKE,
|
|
16976
|
+
contractAddress: invocation.contractAddress,
|
|
16977
|
+
calldata: invocation.calldata,
|
|
16978
|
+
signature: invocation.signature,
|
|
16979
|
+
...hookedDetails.proofFacts && { proofFacts: hookedDetails.proofFacts },
|
|
16980
|
+
...hookedDetails.proof && { proof: hookedDetails.proof },
|
|
16981
|
+
...v3Details(detailsWithTip),
|
|
16982
|
+
resourceBounds: invocation.resourceBounds,
|
|
16983
|
+
nonce: invocation.nonce,
|
|
16984
|
+
version: invocation.version
|
|
16985
|
+
},
|
|
16986
|
+
"transaction"
|
|
16987
|
+
);
|
|
16988
|
+
}
|
|
16891
16989
|
/**
|
|
16892
16990
|
* First check if contract is already declared, if not declare it
|
|
16893
16991
|
* If contract already declared returned transaction_hash is ''.
|