starknet 4.19.2 → 4.19.3
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 +7 -0
- package/dist/index.d.ts +171 -135
- package/dist/index.global.js +60 -2
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +60 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +60 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3008,6 +3008,9 @@ var RpcProvider = class {
|
|
|
3008
3008
|
async getEvents(eventFilter) {
|
|
3009
3009
|
return this.fetchEndpoint("starknet_getEvents", { filter: eventFilter });
|
|
3010
3010
|
}
|
|
3011
|
+
async getSimulateTransaction(_invocation, _invocationDetails, _blockIdentifier) {
|
|
3012
|
+
throw new Error("RPC does not implement simulateTransaction function");
|
|
3013
|
+
}
|
|
3011
3014
|
};
|
|
3012
3015
|
|
|
3013
3016
|
// src/provider/sequencer.ts
|
|
@@ -3101,6 +3104,31 @@ var SequencerAPIResponseParser = class extends ResponseParser {
|
|
|
3101
3104
|
};
|
|
3102
3105
|
});
|
|
3103
3106
|
}
|
|
3107
|
+
parseFeeSimulateTransactionResponse(res) {
|
|
3108
|
+
if ("overall_fee" in res.fee_estimation) {
|
|
3109
|
+
let gasInfo = {};
|
|
3110
|
+
try {
|
|
3111
|
+
gasInfo = {
|
|
3112
|
+
gas_consumed: toBN(res.fee_estimation.gas_usage),
|
|
3113
|
+
gas_price: toBN(res.fee_estimation.gas_price)
|
|
3114
|
+
};
|
|
3115
|
+
} catch {
|
|
3116
|
+
}
|
|
3117
|
+
return {
|
|
3118
|
+
trace: res.trace,
|
|
3119
|
+
fee_estimation: {
|
|
3120
|
+
...gasInfo,
|
|
3121
|
+
overall_fee: toBN(res.fee_estimation.overall_fee)
|
|
3122
|
+
}
|
|
3123
|
+
};
|
|
3124
|
+
}
|
|
3125
|
+
return {
|
|
3126
|
+
trace: res.trace,
|
|
3127
|
+
fee_estimation: {
|
|
3128
|
+
overall_fee: toBN(res.fee_estimation.amount)
|
|
3129
|
+
}
|
|
3130
|
+
};
|
|
3131
|
+
}
|
|
3104
3132
|
parseCallContractResponse(res) {
|
|
3105
3133
|
return {
|
|
3106
3134
|
result: res.result
|
|
@@ -3502,7 +3530,7 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
3502
3530
|
};
|
|
3503
3531
|
return this.fetchEndpoint("estimate_message_fee", { blockIdentifier }, validCallL1Handler);
|
|
3504
3532
|
}
|
|
3505
|
-
async
|
|
3533
|
+
async getSimulateTransaction(invocation, invocationDetails, blockIdentifier = this.blockIdentifier) {
|
|
3506
3534
|
return this.fetchEndpoint(
|
|
3507
3535
|
"simulate_transaction",
|
|
3508
3536
|
{ blockIdentifier },
|
|
@@ -3514,7 +3542,7 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
3514
3542
|
version: toHex(toBN((invocationDetails == null ? void 0 : invocationDetails.version) || 1)),
|
|
3515
3543
|
nonce: toHex(toBN(invocationDetails.nonce))
|
|
3516
3544
|
}
|
|
3517
|
-
);
|
|
3545
|
+
).then(this.responseParser.parseFeeSimulateTransactionResponse);
|
|
3518
3546
|
}
|
|
3519
3547
|
};
|
|
3520
3548
|
|
|
@@ -3600,6 +3628,9 @@ var Provider = class {
|
|
|
3600
3628
|
async waitForTransaction(txHash, retryInterval, successStates) {
|
|
3601
3629
|
return this.provider.waitForTransaction(txHash, retryInterval, successStates);
|
|
3602
3630
|
}
|
|
3631
|
+
async getSimulateTransaction(invocation, invocationDetails, blockIdentifier) {
|
|
3632
|
+
return this.provider.getSimulateTransaction(invocation, invocationDetails, blockIdentifier);
|
|
3633
|
+
}
|
|
3603
3634
|
};
|
|
3604
3635
|
|
|
3605
3636
|
// src/provider/interface.ts
|
|
@@ -5004,6 +5035,33 @@ var Account = class extends Provider {
|
|
|
5004
5035
|
});
|
|
5005
5036
|
return calls;
|
|
5006
5037
|
}
|
|
5038
|
+
async simulateTransaction(calls, { nonce: providedNonce, blockIdentifier } = {}) {
|
|
5039
|
+
const transactions = Array.isArray(calls) ? calls : [calls];
|
|
5040
|
+
const nonce = toBN(providedNonce ?? await this.getNonce());
|
|
5041
|
+
const version = toBN(feeTransactionVersion);
|
|
5042
|
+
const chainId = await this.getChainId();
|
|
5043
|
+
const signerDetails = {
|
|
5044
|
+
walletAddress: this.address,
|
|
5045
|
+
nonce,
|
|
5046
|
+
maxFee: ZERO,
|
|
5047
|
+
version,
|
|
5048
|
+
chainId
|
|
5049
|
+
};
|
|
5050
|
+
const invocation = await this.buildInvocation(transactions, signerDetails);
|
|
5051
|
+
const response = await super.getSimulateTransaction(
|
|
5052
|
+
invocation,
|
|
5053
|
+
{ version, nonce },
|
|
5054
|
+
blockIdentifier
|
|
5055
|
+
);
|
|
5056
|
+
const suggestedMaxFee = estimatedFeeToMaxFee(response.fee_estimation.overall_fee);
|
|
5057
|
+
return {
|
|
5058
|
+
...response,
|
|
5059
|
+
fee_estimation: {
|
|
5060
|
+
...response.fee_estimation,
|
|
5061
|
+
suggestedMaxFee
|
|
5062
|
+
}
|
|
5063
|
+
};
|
|
5064
|
+
}
|
|
5007
5065
|
};
|
|
5008
5066
|
|
|
5009
5067
|
// src/account/interface.ts
|