-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support new APIs from StarkNet
v0.8.0
(#90)
- Loading branch information
1 parent
33b903b
commit b4e48ec
Showing
11 changed files
with
205 additions
and
7 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use serde::Deserialize; | ||
|
||
#[derive(Debug, Deserialize)] | ||
pub struct FeeEstimate { | ||
pub amount: u64, | ||
pub unit: FeeUnit, | ||
} | ||
|
||
#[derive(Debug, Deserialize)] | ||
pub enum FeeUnit { | ||
#[serde(rename = "wei")] | ||
Wei, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
use super::{super::serde::unsigned_field_element::UfeHex, EntryPointType, ExecutionResources}; | ||
|
||
use ethereum_types::Address; | ||
use serde::Deserialize; | ||
use serde_with::serde_as; | ||
use starknet_crypto::FieldElement; | ||
|
||
/// Represents the trace of a StarkNet transaction execution, including internal calls. | ||
#[derive(Debug, Deserialize)] | ||
pub struct TransactionTrace { | ||
/// An object describing the invocation of a specific function. | ||
pub function_invocation: FunctionInvocation, | ||
pub signature: Vec<FieldElement>, | ||
} | ||
|
||
/// A lean version of CallInfo class, containing merely the information relevant for the user. | ||
#[serde_as] | ||
#[derive(Debug, Deserialize)] | ||
pub struct FunctionInvocation { | ||
#[serde_as(as = "UfeHex")] | ||
pub caller_address: FieldElement, | ||
#[serde_as(as = "UfeHex")] | ||
pub contract_address: FieldElement, | ||
#[serde_as(as = "Option<UfeHex>")] | ||
pub code_address: Option<FieldElement>, | ||
#[serde_as(as = "Option<UfeHex>")] | ||
pub selector: Option<FieldElement>, | ||
pub entry_point_type: Option<EntryPointType>, | ||
#[serde_as(as = "Vec<UfeHex>")] | ||
pub calldata: Vec<FieldElement>, | ||
#[serde_as(as = "Vec<UfeHex>")] | ||
pub result: Vec<FieldElement>, | ||
pub execution_resources: ExecutionResources, | ||
pub internal_calls: Vec<FunctionInvocation>, | ||
pub events: Vec<OrderedEventResponse>, | ||
pub messages: Vec<OrderedL2ToL1MessageResponse>, | ||
} | ||
|
||
#[serde_as] | ||
#[derive(Debug, Deserialize)] | ||
pub struct OrderedEventResponse { | ||
pub order: u64, | ||
#[serde_as(as = "Vec<UfeHex>")] | ||
pub keys: Vec<FieldElement>, | ||
#[serde_as(as = "Vec<UfeHex>")] | ||
pub data: Vec<FieldElement>, | ||
} | ||
|
||
#[serde_as] | ||
#[derive(Debug, Deserialize)] | ||
pub struct OrderedL2ToL1MessageResponse { | ||
pub order: u64, | ||
pub to_address: Address, | ||
#[serde_as(as = "Vec<UfeHex>")] | ||
pub payload: Vec<FieldElement>, | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] | ||
fn test_trace_deser_with_messages() { | ||
serde_json::from_str::<TransactionTrace>(include_str!( | ||
"../../test-data/raw_gateway_responses/get_transaction_trace/1_with_messages.txt" | ||
)) | ||
.unwrap(); | ||
} | ||
|
||
#[test] | ||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] | ||
fn test_trace_deser_with_events() { | ||
serde_json::from_str::<TransactionTrace>(include_str!( | ||
"../../test-data/raw_gateway_responses/get_transaction_trace/2_with_events.txt" | ||
)) | ||
.unwrap(); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
starknet-core/test-data/raw_gateway_responses/estimate_fee/1_success.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"amount": 1630000000000, "unit": "wei"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
starknet-core/test-data/raw_gateway_responses/get_transaction_trace/1_with_messages.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"function_invocation": {"caller_address": "0x0", "contract_address": "0x40498ecb5a86ae60195db96c9b52166751ede5c20c6fa6523303d459429e438", "code_address": "0x40498ecb5a86ae60195db96c9b52166751ede5c20c6fa6523303d459429e438", "selector": "0x12ead94ae9d3f9d2bdb6b847cf255f1f398193a1f88884a0ae8e18f24a037b6", "entry_point_type": "EXTERNAL", "calldata": ["0xcbf9b25c0f4cb0b741ac4b2eab6be2cc2b3f1d76"], "result": [], "execution_resources": {"n_steps": 31, "builtin_instance_counter": {"pedersen_builtin": 0, "range_check_builtin": 0, "output_builtin": 0, "ecdsa_builtin": 0, "bitwise_builtin": 0, "ec_op_builtin": 0}, "n_memory_holes": 0}, "internal_calls": [], "events": [], "messages": [{"order": 0, "to_address": "0xcBf9B25c0f4cb0b741AC4B2eAB6BE2CC2B3F1d76", "payload": ["0xc", "0x22"]}]}, "signature": []} |
1 change: 1 addition & 0 deletions
1
starknet-core/test-data/raw_gateway_responses/get_transaction_trace/2_with_events.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"function_invocation": {"caller_address": "0x0", "contract_address": "0x449c8f694001f99cea9302f2b1f6056879c48247fd1b27814c426ba3670740e", "code_address": "0x449c8f694001f99cea9302f2b1f6056879c48247fd1b27814c426ba3670740e", "selector": "0x240060cdb34fcc260f41eac7474ee1d7c80b7e3607daff9ac67c7ea2ebb1c44", "entry_point_type": "EXTERNAL", "calldata": ["0x47cfd9582fc4c7543d55d6853e8edee02ff72e233b4b2d4d42568ed4a68f9c0", "0x2f9bf85b08843c458690450fd7b221d0f793fa42db7245bbd08c0c12f85b60f", "0x1", "0x7394cbe418daa16e42b87ba67372d4ab4a5df0b05c6e554d158458ce245bc10", "0x77"], "result": ["0x0"], "execution_resources": {"n_steps": 861, "builtin_instance_counter": {"pedersen_builtin": 12, "range_check_builtin": 13, "ecdsa_builtin": 1, "output_builtin": 0, "bitwise_builtin": 0, "ec_op_builtin": 0}, "n_memory_holes": 30}, "internal_calls": [{"caller_address": "0x449c8f694001f99cea9302f2b1f6056879c48247fd1b27814c426ba3670740e", "contract_address": "0x47cfd9582fc4c7543d55d6853e8edee02ff72e233b4b2d4d42568ed4a68f9c0", "code_address": "0x47cfd9582fc4c7543d55d6853e8edee02ff72e233b4b2d4d42568ed4a68f9c0", "selector": "0x2f9bf85b08843c458690450fd7b221d0f793fa42db7245bbd08c0c12f85b60f", "entry_point_type": "EXTERNAL", "calldata": ["0x7394cbe418daa16e42b87ba67372d4ab4a5df0b05c6e554d158458ce245bc10"], "result": [], "execution_resources": {"n_steps": 427, "builtin_instance_counter": {"pedersen_builtin": 4, "range_check_builtin": 11, "ecdsa_builtin": 0, "output_builtin": 0, "bitwise_builtin": 0, "ec_op_builtin": 0}, "n_memory_holes": 30}, "internal_calls": [], "events": [{"order": 0, "keys": ["0x2d1d3dcc4fe9f25587df82853d883029e1453436eb63810ba4f444e76d7aa4a"], "data": ["0x7394cbe418daa16e42b87ba67372d4ab4a5df0b05c6e554d158458ce245bc10", "0x61e7b372"]}], "messages": []}], "events": [], "messages": []}, "signature": ["220134563884515005302105515860459019567739214287456771965489940677218361665", "3370972961224919564221792417554667287706831396645945832805232310863238883193"]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../starknet-core/test-data/raw_gateway_responses/ |