Skip to content

Commit 2d5444b

Browse files
starknet_api: fix compiler->SNAPI contract class ABI string conversion for tests
1 parent e875064 commit 2d5444b

File tree

4 files changed

+39
-2
lines changed

4 files changed

+39
-2
lines changed

Cargo.lock

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ schemars = "0.8.12"
295295
semver = "1.0.23"
296296
serde = "1.0.197"
297297
serde_json = "1.0.116"
298+
serde-json-fmt = "0.1.0"
298299
serde_repr = "0.1.19"
299300
serde_with = "3.12.0"
300301
serde_yaml = "0.9.16"

crates/starknet_api/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ license-file.workspace = true
77
description = "Starknet Rust types related to computation and execution."
88

99
[features]
10-
testing = []
10+
testing = ["serde-json-fmt"]
1111

1212
[dependencies]
1313
apollo_infra_utils.workspace = true
@@ -31,6 +31,7 @@ rand.workspace = true
3131
semver.workspace = true
3232
serde = { workspace = true, features = ["derive", "rc"] }
3333
serde_json.workspace = true
34+
serde-json-fmt = { workspace = true, optional = true }
3435
sha3.workspace = true
3536
size-of.workspace = true
3637
starknet-crypto.workspace = true
@@ -43,6 +44,7 @@ time.workspace = true
4344
[dev-dependencies]
4445
assert_matches.workspace = true
4546
rstest.workspace = true
47+
serde-json-fmt.workspace = true
4648

4749
[lints]
4850
workspace = true

crates/starknet_api/src/state.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,18 @@ impl From<cairo_lang_starknet_classes::contract_class::ContractClass> for Sierra
311311
.collect(),
312312
contract_class_version: cairo_lang_contract_class.contract_class_version,
313313
entry_points_by_type: cairo_lang_contract_class.entry_points_by_type.into(),
314-
abi: cairo_lang_contract_class.abi.map(|abi| abi.json()).unwrap_or_default(),
314+
abi: cairo_lang_contract_class
315+
.abi
316+
.map(|abi| {
317+
serde_json_fmt::JsonFormat::new()
318+
.comma(", ")
319+
.unwrap()
320+
.colon(": ")
321+
.unwrap()
322+
.format_to_string(&abi)
323+
.unwrap()
324+
})
325+
.unwrap_or_default(),
315326
}
316327
}
317328
}

0 commit comments

Comments
 (0)