Skip to content

Commit 392f624

Browse files
committed
fix
1 parent 1267ff2 commit 392f624

File tree

5 files changed

+25
-14
lines changed

5 files changed

+25
-14
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ resolver = "2"
77

88
[workspace.package]
99
version = "0.1.0"
10-
edition = "2021"
10+
edition = "2024"
1111
license = "MIT"
1212
repository = "https://github.com/paritytech/cargo-pvm-contract"
1313

crates/cargo-pvm-contract-builder/src/lib.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,13 @@ fn get_bin_targets(cargo_toml: &Path) -> Result<Vec<String>> {
138138
}
139139
}
140140

141-
if bins.is_empty() {
142-
if let Some(name) = doc
141+
if bins.is_empty()
142+
&& let Some(name) = doc
143143
.get("package")
144144
.and_then(|p| p.get("name"))
145145
.and_then(|n| n.as_str())
146-
{
147-
bins.push(name.to_string());
148-
}
146+
{
147+
bins.push(name.to_string());
149148
}
150149

151150
Ok(bins)

crates/cargo-pvm-contract/src/main.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use anyhow::{Context, Result};
22
use clap::{Parser, Subcommand, ValueEnum};
3-
use include_dir::{include_dir, Dir};
3+
use include_dir::{Dir, include_dir};
44
use inquire::{Select, Text};
55
use log::debug;
66
use std::{fs, path::PathBuf};
@@ -115,10 +115,10 @@ fn init_command(args: PvmContractArgs) -> Result<()> {
115115
.filter(|value| !value.trim().is_empty())
116116
.map(PathBuf::from);
117117

118-
if let Some(path) = builder_path.as_deref() {
119-
if !path.exists() {
120-
anyhow::bail!("Builder path does not exist: {}", path.display());
121-
}
118+
if let Some(path) = builder_path.as_deref()
119+
&& !path.exists()
120+
{
121+
anyhow::bail!("Builder path does not exist: {}", path.display());
122122
}
123123

124124
if args.non_interactive {
@@ -338,7 +338,11 @@ fn init_from_example(
338338
.duration_since(std::time::UNIX_EPOCH)
339339
.context("Failed to read system time")?
340340
.as_nanos();
341-
let temp_sol_path = temp_dir.join(format!("{timestamp}-{}", example.sol_filename()));
341+
let example_temp_dir = temp_dir.join(format!("cargo-pvm-contract-{timestamp}"));
342+
fs::create_dir_all(&example_temp_dir).with_context(|| {
343+
format!("Failed to create temporary directory for example: {example_temp_dir:?}",)
344+
})?;
345+
let temp_sol_path = example_temp_dir.join(example.sol_filename());
342346
fs::write(&temp_sol_path, example_file.contents())
343347
.with_context(|| format!("Failed to write temporary .sol file: {:?}", temp_sol_path))?;
344348

@@ -353,7 +357,7 @@ fn init_from_example(
353357
);
354358

355359
// Clean up temp file
356-
let _ = fs::remove_file(&temp_sol_path);
360+
let _ = fs::remove_dir_all(&example_temp_dir);
357361

358362
result
359363
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
3+
pragma solidity ^0.8.0;
4+
5+
interface Fibonacci {
6+
function fibonacci(uint32) external pure returns (uint32);
7+
}
8+

crates/cargo-pvm-contract/templates/scaffold/cargo_toml.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "{{ contract_name }}"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55
build = "build.rs"
66

77
[[bin]]

0 commit comments

Comments
 (0)