Skip to content

Commit e8b51f6

Browse files
authored
Contracts use polkavm workspace deps (#3715)
1 parent 4987d79 commit e8b51f6

File tree

5 files changed

+19
-57
lines changed

5 files changed

+19
-57
lines changed

Cargo.lock

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

substrate/frame/contracts/fixtures/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ parity-wasm = "0.45.0"
2020
tempfile = "3.8.1"
2121
toml = "0.8.2"
2222
twox-hash = "1.6.3"
23-
polkavm-linker = { version = "0.5.0", optional = true }
23+
polkavm-linker = { workspace = true, optional = true }
2424
anyhow = "1.0.0"
2525

2626
[features]

substrate/frame/contracts/fixtures/build.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,11 @@ fn collect_entries(contracts_dir: &Path, out_dir: &Path) -> Vec<Entry> {
121121
/// Create a `Cargo.toml` to compile the given contract entries.
122122
fn create_cargo_toml<'a>(
123123
fixtures_dir: &Path,
124+
root_cargo_toml: &Path,
124125
entries: impl Iterator<Item = &'a Entry>,
125126
output_dir: &Path,
126127
) -> Result<()> {
128+
let root_toml: toml::Value = toml::from_str(&fs::read_to_string(root_cargo_toml)?)?;
127129
let mut cargo_toml: toml::Value = toml::from_str(include_str!("./build/Cargo.toml"))?;
128130
let mut set_dep = |name, path| -> Result<()> {
129131
cargo_toml["dependencies"][name]["path"] = toml::Value::String(
@@ -133,6 +135,8 @@ fn create_cargo_toml<'a>(
133135
};
134136
set_dep("uapi", "../uapi")?;
135137
set_dep("common", "./contracts/common")?;
138+
cargo_toml["dependencies"]["polkavm-derive"]["version"] =
139+
root_toml["workspace"]["dependencies"]["polkavm-derive"].clone();
136140

137141
cargo_toml["bin"] = toml::Value::Array(
138142
entries
@@ -324,6 +328,7 @@ fn main() -> Result<()> {
324328
let contracts_dir = fixtures_dir.join("contracts");
325329
let out_dir: PathBuf = env::var("OUT_DIR")?.into();
326330
let workspace_root = find_workspace_root(&fixtures_dir).expect("workspace root exists; qed");
331+
let root_cargo_toml = workspace_root.join("Cargo.toml");
327332

328333
let entries = collect_entries(&contracts_dir, &out_dir);
329334
if entries.is_empty() {
@@ -333,7 +338,7 @@ fn main() -> Result<()> {
333338
let tmp_dir = tempfile::tempdir()?;
334339
let tmp_dir_path = tmp_dir.path();
335340

336-
create_cargo_toml(&fixtures_dir, entries.iter(), tmp_dir.path())?;
341+
create_cargo_toml(&fixtures_dir, &root_cargo_toml, entries.iter(), tmp_dir.path())?;
337342
invoke_cargo_fmt(
338343
&workspace_root.join(".rustfmt.toml"),
339344
entries.iter().map(|entry| &entry.path as _),

substrate/frame/contracts/fixtures/build/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ edition = "2021"
66
# Binary targets are injected dynamically by the build script.
77
[[bin]]
88

9-
# local path are injected dynamically by the build script.
9+
# All paths or versions are injected dynamically by the build script.
1010
[dependencies]
1111
uapi = { package = 'pallet-contracts-uapi', path = "", default-features = false }
1212
common = { package = 'pallet-contracts-fixtures-common', path = "" }
13-
polkavm-derive = '0.5.0'
13+
polkavm-derive = { version = "" }
1414

1515
[profile.release]
1616
opt-level = 3

substrate/frame/contracts/uapi/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ scale = { package = "parity-scale-codec", version = "3.6.1", default-features =
2121
], optional = true }
2222

2323
[target.'cfg(target_arch = "riscv32")'.dependencies]
24-
polkavm-derive = '0.5.0'
24+
polkavm-derive = { workspace = true }
2525

2626
[package.metadata.docs.rs]
2727
default-target = ["wasm32-unknown-unknown"]

0 commit comments

Comments
 (0)