Skip to content

Commit

Permalink
refactor simulateTransactions and estimateFee
Browse files Browse the repository at this point in the history
  • Loading branch information
ArielElp committed Nov 24, 2023
1 parent 237fe16 commit cc98e2f
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 17 deletions.
62 changes: 49 additions & 13 deletions api/starknet_api_openrpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@
{
"name": "starknet_estimateFee",
"summary": "estimate the fee for of StarkNet transactions",
"description": "estimates the resources required by transactions when applyed on a given state",
"description": "Estimates the resources required by a given sequence of transactions when applied on a given state. If one of the transaction reverts, a TRANSACTION_EXECUTION_ERROR is returned.",
"params": [
{
"name": "request",
Expand All @@ -597,6 +597,17 @@
},
"required": true
},
{
"name": "simulation_flags",
"description": "describes what parts of the transaction should be executed",
"required": false,
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/SIMULATION_FLAG_FOR_ESTIMATE_FEE"
}
}
},
{
"name": "block_id",
"description": "The hash of the requested block, or number (height) of the requested block, or a block tag, for the block referencing the state or call the transaction on.",
Expand All @@ -621,10 +632,7 @@
},
"errors": [
{
"$ref": "#/components/errors/CONTRACT_NOT_FOUND"
},
{
"$ref": "#/components/errors/CONTRACT_ERROR"
"$ref": "#/components/errors/TRANSACTION_EXECUTION_ERROR"
},
{
"$ref": "#/components/errors/BLOCK_NOT_FOUND"
Expand Down Expand Up @@ -662,9 +670,6 @@
}
},
"errors": [
{
"$ref": "#/components/errors/CONTRACT_NOT_FOUND"
},
{
"$ref": "#/components/errors/CONTRACT_ERROR"
},
Expand Down Expand Up @@ -3626,6 +3631,13 @@
"type"
]
},
"SIMULATION_FLAG_FOR_ESTIMATE_FEE": {
"type": "string",
"enum": [
"SKIP_VALIDATE"
],
"description": "Flags that indicate how to simulate a given transaction. By default, the sequencer behavior is replicated locally"
},
"FEE_ESTIMATE": {
"title": "Fee estimation",
"type": "object",
Expand Down Expand Up @@ -3667,7 +3679,7 @@
"type": "string",
"enum": [
"WEI",
"STRK"
"FRI"
]
}
},
Expand Down Expand Up @@ -3726,9 +3738,9 @@
"RESOURCE_PRICE": {
"type": "object",
"properties": {
"price_in_strk": {
"title": "price in strk",
"description": "the price of one unit of the given resource, denominated in strk",
"price_in_fri": {
"title": "price in fri",
"description": "the price of one unit of the given resource, denominated in fri (10^-18 strk)",
"$ref": "#/components/schemas/FELT"
},
"price_in_wei": {
Expand All @@ -3739,7 +3751,7 @@
},
"required": [
"price_in_wei",
"price_in_strk"
"price_in_fri"
]
},
"EXECUTION_RESOURCES": {
Expand Down Expand Up @@ -3889,6 +3901,30 @@
},
"required": "revert_error"
}
},
"TRANSACTION_EXECUTION_ERROR": {
"code": 40,
"message": "Transaction execution error",
"data": {
"type": "object",
"description": "More data about the execution failure",
"properties": {
"transaction_index": {
"title": "Transaction index",
"description": "The index of the first transaction failing in a sequence of given transactions",
"type": "integer"
},
"revert_error": {
"title": "revert error",
"description": "a string encoding the execution trace up to the point of failure",
"type": "string"
}
},
"required": [
"transaction_index",
"revert_error"
]
}
}
}
}
Expand Down
5 changes: 1 addition & 4 deletions api/starknet_trace_api_openrpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
{
"name": "starknet_simulateTransactions",
"summary": "simulate a given sequence of transactions on the requested state, and generate the execution traces. If one of the transactions is reverted, raises CONTRACT_ERROR.",
"summary": "Simulate a given sequence of transactions on the requested state, and generate the execution traces. Note that some of the transactions may revert, in which case no error is thrown, but revert details can be seen on the returned trace object.",
"params": [
{
"name": "block_id",
Expand Down Expand Up @@ -99,9 +99,6 @@
{
"$ref": "#/components/errors/CONTRACT_NOT_FOUND"
},
{
"$ref": "#/components/errors/CONTRACT_ERROR"
},
{
"$ref": "#/components/errors/BLOCK_NOT_FOUND"
}
Expand Down

0 comments on commit cc98e2f

Please sign in to comment.