Skip to content

Commit

Permalink
fix: work around a few new rpc issues
Browse files Browse the repository at this point in the history
  • Loading branch information
xJonathanLEI committed Sep 15, 2023
1 parent a5e23d0 commit d0c7297
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions examples/parse_jsonrpc_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ use starknet_providers::jsonrpc::{JsonRpcRequest, JsonRpcRequestData};

fn main() {
// Let's pretend this is the raw request body coming from HTTP
let raw_request = r###"{
let raw_request = r#"{
"id": 1,
"jsonrpc": "2.0",
"method": "starknet_getBlockTransactionCount",
"params": [{ "block_number": 200 }]
}"###;
}"#;

// Your server framework should handle this for you. Here we deserialize manually to see what's
// going on.
Expand Down
3 changes: 3 additions & 0 deletions starknet-accounts/tests/single_owner_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,9 @@ async fn can_declare_cairo0_contract_inner<P: Provider + Send + Sync>(provider:

let result = account
.declare_legacy(Arc::new(contract_artifact))
// There seems to be a fee estimation issue with `pathfinder`
// https://github.com/eqlabs/pathfinder/issues/1372
.fee_estimate_multiplier(2.0)
.send()
.await
.unwrap();
Expand Down
16 changes: 16 additions & 0 deletions starknet-core/src/types/contract/legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,18 +510,34 @@ impl LegacyProgram {
compiler_version: &'a Option<String>,
#[serde_as(as = "Vec<UfeHex>")]
data: &'a Vec<FieldElement>,
// Needed due to pathfinder bug:
// https://github.com/eqlabs/pathfinder/issues/1371
debug_info: EmptyDebugInfo,
hints: &'a BTreeMap<u64, Vec<LegacyHint>>,
identifiers: &'a BTreeMap<String, LegacyIdentifier>,
main_scope: &'a String,
prime: &'a String,
reference_manager: &'a LegacyReferenceManager,
}

#[derive(Serialize)]
pub struct EmptyDebugInfo {
file_contents: Unit,
instruction_locations: Unit,
}

#[derive(Serialize)]
pub struct Unit {}

let program_json = serde_json::to_string(&ProgramWithoutDebugInfo {
attributes: &self.attributes,
builtins: &self.builtins,
compiler_version: &self.compiler_version,
data: &self.data,
debug_info: EmptyDebugInfo {
file_contents: Unit {},
instruction_locations: Unit {},
},
hints: &self.hints,
identifiers: &self.identifiers,
main_scope: &self.main_scope,
Expand Down

0 comments on commit d0c7297

Please sign in to comment.