Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
alenmestrov committed Dec 18, 2024
1 parent ca79b25 commit 5bb8a9b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions crates/context/config/src/client/env/proxy/types/starknet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,22 +282,24 @@ impl From<Vec<ProposalAction>> for StarknetProposalActionWithArgs {
..
} => {
// Parse the JSON string into a Value first
let args_value: serde_json::Value =
let args_value: serde_json::Value =
serde_json::from_str(&args).expect("Invalid JSON arguments");
// Convert JSON values to Starknet-compatible felt arguments
let felt_args = match args_value {
serde_json::Value::Object(map) => {
// For objects, serialize each value to a felt
map.into_iter()
.map(|(_, value)| Felt::from_bytes_be_slice(value.to_string().as_bytes()))
.map(|(_, value)| {
Felt::from_bytes_be_slice(value.to_string().as_bytes())
})
.collect()
},
}
serde_json::Value::Array(arr) => {
// For arrays, convert each element
arr.into_iter()
.map(|value| Felt::from_bytes_be_slice(value.to_string().as_bytes()))
.collect()
},
}
// Single value
value => vec![Felt::from_bytes_be_slice(value.to_string().as_bytes())],
};
Expand Down

0 comments on commit 5bb8a9b

Please sign in to comment.