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.mjs
CHANGED
|
@@ -2950,6 +2950,9 @@ var RpcProvider = class {
|
|
|
2950
2950
|
async getEvents(eventFilter) {
|
|
2951
2951
|
return this.fetchEndpoint("starknet_getEvents", { filter: eventFilter });
|
|
2952
2952
|
}
|
|
2953
|
+
async getSimulateTransaction(_invocation, _invocationDetails, _blockIdentifier) {
|
|
2954
|
+
throw new Error("RPC does not implement simulateTransaction function");
|
|
2955
|
+
}
|
|
2953
2956
|
};
|
|
2954
2957
|
|
|
2955
2958
|
// src/provider/sequencer.ts
|
|
@@ -3043,6 +3046,31 @@ var SequencerAPIResponseParser = class extends ResponseParser {
|
|
|
3043
3046
|
};
|
|
3044
3047
|
});
|
|
3045
3048
|
}
|
|
3049
|
+
parseFeeSimulateTransactionResponse(res) {
|
|
3050
|
+
if ("overall_fee" in res.fee_estimation) {
|
|
3051
|
+
let gasInfo = {};
|
|
3052
|
+
try {
|
|
3053
|
+
gasInfo = {
|
|
3054
|
+
gas_consumed: toBN(res.fee_estimation.gas_usage),
|
|
3055
|
+
gas_price: toBN(res.fee_estimation.gas_price)
|
|
3056
|
+
};
|
|
3057
|
+
} catch {
|
|
3058
|
+
}
|
|
3059
|
+
return {
|
|
3060
|
+
trace: res.trace,
|
|
3061
|
+
fee_estimation: {
|
|
3062
|
+
...gasInfo,
|
|
3063
|
+
overall_fee: toBN(res.fee_estimation.overall_fee)
|
|
3064
|
+
}
|
|
3065
|
+
};
|
|
3066
|
+
}
|
|
3067
|
+
return {
|
|
3068
|
+
trace: res.trace,
|
|
3069
|
+
fee_estimation: {
|
|
3070
|
+
overall_fee: toBN(res.fee_estimation.amount)
|
|
3071
|
+
}
|
|
3072
|
+
};
|
|
3073
|
+
}
|
|
3046
3074
|
parseCallContractResponse(res) {
|
|
3047
3075
|
return {
|
|
3048
3076
|
result: res.result
|
|
@@ -3444,7 +3472,7 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
3444
3472
|
};
|
|
3445
3473
|
return this.fetchEndpoint("estimate_message_fee", { blockIdentifier }, validCallL1Handler);
|
|
3446
3474
|
}
|
|
3447
|
-
async
|
|
3475
|
+
async getSimulateTransaction(invocation, invocationDetails, blockIdentifier = this.blockIdentifier) {
|
|
3448
3476
|
return this.fetchEndpoint(
|
|
3449
3477
|
"simulate_transaction",
|
|
3450
3478
|
{ blockIdentifier },
|
|
@@ -3456,7 +3484,7 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
3456
3484
|
version: toHex(toBN((invocationDetails == null ? void 0 : invocationDetails.version) || 1)),
|
|
3457
3485
|
nonce: toHex(toBN(invocationDetails.nonce))
|
|
3458
3486
|
}
|
|
3459
|
-
);
|
|
3487
|
+
).then(this.responseParser.parseFeeSimulateTransactionResponse);
|
|
3460
3488
|
}
|
|
3461
3489
|
};
|
|
3462
3490
|
|
|
@@ -3542,6 +3570,9 @@ var Provider = class {
|
|
|
3542
3570
|
async waitForTransaction(txHash, retryInterval, successStates) {
|
|
3543
3571
|
return this.provider.waitForTransaction(txHash, retryInterval, successStates);
|
|
3544
3572
|
}
|
|
3573
|
+
async getSimulateTransaction(invocation, invocationDetails, blockIdentifier) {
|
|
3574
|
+
return this.provider.getSimulateTransaction(invocation, invocationDetails, blockIdentifier);
|
|
3575
|
+
}
|
|
3545
3576
|
};
|
|
3546
3577
|
|
|
3547
3578
|
// src/provider/interface.ts
|
|
@@ -4946,6 +4977,33 @@ var Account = class extends Provider {
|
|
|
4946
4977
|
});
|
|
4947
4978
|
return calls;
|
|
4948
4979
|
}
|
|
4980
|
+
async simulateTransaction(calls, { nonce: providedNonce, blockIdentifier } = {}) {
|
|
4981
|
+
const transactions = Array.isArray(calls) ? calls : [calls];
|
|
4982
|
+
const nonce = toBN(providedNonce ?? await this.getNonce());
|
|
4983
|
+
const version = toBN(feeTransactionVersion);
|
|
4984
|
+
const chainId = await this.getChainId();
|
|
4985
|
+
const signerDetails = {
|
|
4986
|
+
walletAddress: this.address,
|
|
4987
|
+
nonce,
|
|
4988
|
+
maxFee: ZERO,
|
|
4989
|
+
version,
|
|
4990
|
+
chainId
|
|
4991
|
+
};
|
|
4992
|
+
const invocation = await this.buildInvocation(transactions, signerDetails);
|
|
4993
|
+
const response = await super.getSimulateTransaction(
|
|
4994
|
+
invocation,
|
|
4995
|
+
{ version, nonce },
|
|
4996
|
+
blockIdentifier
|
|
4997
|
+
);
|
|
4998
|
+
const suggestedMaxFee = estimatedFeeToMaxFee(response.fee_estimation.overall_fee);
|
|
4999
|
+
return {
|
|
5000
|
+
...response,
|
|
5001
|
+
fee_estimation: {
|
|
5002
|
+
...response.fee_estimation,
|
|
5003
|
+
suggestedMaxFee
|
|
5004
|
+
}
|
|
5005
|
+
};
|
|
5006
|
+
}
|
|
4949
5007
|
};
|
|
4950
5008
|
|
|
4951
5009
|
// src/account/interface.ts
|