Skip to content

Commit 101a3bb

Browse files
committed
chore: build clarity for wasm32-unknown-unknown
1 parent bc58a1e commit 101a3bb

File tree

10 files changed

+41
-41
lines changed

10 files changed

+41
-41
lines changed

Cargo.lock

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

clarity/Cargo.toml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ name = "clarity"
1818
path = "./src/libclarity.rs"
1919

2020
[dependencies]
21-
rand = { workspace = true }
22-
rand_chacha = { workspace = true }
2321
serde = "1"
2422
serde_derive = "1"
2523
serde_stacker = "0.1"
@@ -28,22 +26,23 @@ lazy_static = "1.4.0"
2826
integer-sqrt = "0.1.3"
2927
slog = { version = "2.5.2", features = [ "max_level_trace" ] }
3028
stacks_common = { package = "stacks-common", path = "../stacks-common", default-features = false }
31-
rstest = "0.17.0"
32-
rstest_reuse = "0.5.0"
29+
rstest = { version = "0.17.0", optional = true }
30+
rstest_reuse = { version = "0.5.0", optional = true }
3331
hashbrown = { workspace = true }
3432
rusqlite = { workspace = true, optional = true }
3533

34+
[target.'cfg(target_arch = "wasm32")'.dependencies]
35+
getrandom = { version = "0.2", features = ["js"] }
36+
3637
[dependencies.serde_json]
3738
version = "1.0"
3839
features = ["arbitrary_precision", "unbounded_depth"]
3940

40-
[dependencies.time]
41-
version = "0.2.23"
42-
features = ["std"]
43-
4441
[dev-dependencies]
4542
assert-json-diff = "1.0.0"
4643
mutants = "0.0.3"
44+
rstest = { version = "0.17.0" }
45+
rstest_reuse = { version = "0.5.0" }
4746
# a nightly rustc regression (35dbef235 2021-03-02) prevents criterion from compiling
4847
# but it isn't necessary for tests: only benchmarks. therefore, commenting out for now.
4948
# criterion = "0.3"
@@ -53,7 +52,7 @@ default = ["rusqlite"]
5352
developer-mode = ["stacks_common/developer-mode"]
5453
slog_json = ["stacks_common/slog_json"]
5554
rusqlite = ["stacks_common/rusqlite", "dep:rusqlite"]
56-
testing = []
55+
testing = ["rstest", "rstest_reuse"]
5756
devtools = []
5857
rollback_value_check = []
5958
disable-costs = []

clarity/src/vm/analysis/type_checker/v2_05/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ pub fn no_type() -> TypeSignature {
335335
}
336336

337337
impl<'a, 'b> TypeChecker<'a, 'b> {
338-
fn new(
338+
pub fn new(
339339
db: &'a mut AnalysisDatabase<'b>,
340340
cost_track: LimitedCostTracker,
341341
build_type_map: bool,

clarity/src/vm/costs/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,12 @@ pub enum CostErrors {
417417
ExecutionTimeExpired,
418418
}
419419

420+
impl fmt::Display for CostErrors {
421+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
422+
write!(f, "{:?}", self)
423+
}
424+
}
425+
420426
impl CostErrors {
421427
fn rejectable(&self) -> bool {
422428
matches!(self, CostErrors::InterpreterFailure | CostErrors::Expect(_))

clarity/src/vm/docs/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2632,7 +2632,7 @@ pub fn make_api_reference(function: &NativeFunctions) -> FunctionAPI {
26322632
}
26332633
}
26342634

2635-
fn make_keyword_reference(variable: &NativeVariables) -> Option<KeywordAPI> {
2635+
pub fn make_keyword_reference(variable: &NativeVariables) -> Option<KeywordAPI> {
26362636
let keyword = match variable {
26372637
NativeVariables::TxSender => TX_SENDER_KEYWORD.clone(),
26382638
NativeVariables::ContractCaller => CONTRACT_CALLER_KEYWORD.clone(),

clarity/src/vm/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ pub mod clarity;
5656
use std::collections::BTreeMap;
5757

5858
use costs::CostErrors;
59-
use serde_json;
6059
use stacks_common::types::StacksEpochId;
6160

6261
use self::analysis::ContractAnalysis;
@@ -77,6 +76,7 @@ pub use crate::vm::database::clarity_db::StacksEpoch;
7776
use crate::vm::errors::{
7877
CheckErrors, Error, InterpreterError, InterpreterResult as Result, RuntimeErrorType,
7978
};
79+
use crate::vm::events::StacksTransactionEvent;
8080
use crate::vm::functions::define::DefineResult;
8181
pub use crate::vm::functions::stx_transfer_consolidated;
8282
pub use crate::vm::representations::{
@@ -118,12 +118,12 @@ pub enum EvaluationResult {
118118
#[derive(Debug, Clone)]
119119
pub struct ExecutionResult {
120120
pub result: EvaluationResult,
121-
pub events: Vec<serde_json::Value>,
121+
pub events: Vec<StacksTransactionEvent>,
122122
pub cost: Option<CostSynthesis>,
123123
pub diagnostics: Vec<Diagnostic>,
124124
}
125125

126-
#[derive(Clone, Debug)]
126+
#[derive(Clone, Debug, Serialize)]
127127
pub struct CostSynthesis {
128128
pub total: ExecutionCost,
129129
pub limit: ExecutionCost,

pox-locking/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ name = "pox_locking"
1919
path = "src/lib.rs"
2020

2121
[dependencies]
22-
clarity = { package = "clarity", path = "../clarity" }
23-
stacks_common = { package = "stacks-common", path = "../stacks-common" }
22+
clarity = { package = "clarity", path = "../clarity", default-features = false}
23+
stacks_common = { package = "stacks-common", path = "../stacks-common", default-features = false}
2424
slog = { version = "2.5.2", features = [ "max_level_trace" ] }
2525

2626
[dev-dependencies]

stacks-common/Cargo.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ workspace = true
6868
version = "4.1.3"
6969
features = ["serde"]
7070

71-
[dependencies.time]
72-
version = "0.2.23"
73-
features = ["std"]
74-
7571
[target.'cfg(not(target_family = "wasm"))'.dependencies]
7672
secp256k1 = { version = "0.24.3", features = ["serde", "recovery"] }
7773

@@ -83,7 +79,7 @@ rand_core = { workspace = true }
8379
proptest = "1.6.0"
8480

8581
[features]
86-
default = ["developer-mode"]
82+
default = ["rusqlite", "developer-mode"]
8783
developer-mode = []
8884
slog_json = ["slog-json"]
8985
rusqlite = ["dep:rusqlite"]

stacks-common/src/deps_common/bitcoin/util/mod.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ pub mod hash;
2020

2121
use std::{error, fmt};
2222

23-
use secp256k1;
24-
2523
use crate::deps_common::bitcoin::network;
2624
use crate::deps_common::bitcoin::network::serialize;
25+
use crate::util::secp256k1::Error as Secp256k1Error;
2726

2827
/// A trait which allows numbers to act as fixed-size bit arrays
2928
pub trait BitArray {
@@ -51,7 +50,7 @@ pub trait BitArray {
5150
#[derive(Debug)]
5251
pub enum Error {
5352
/// secp-related error
54-
Secp256k1(secp256k1::Error),
53+
Secp256k1(Secp256k1Error),
5554
/// Serialization error
5655
Serialize(serialize::Error),
5756
/// Network error
@@ -86,8 +85,8 @@ impl error::Error for Error {
8685
}
8786

8887
#[doc(hidden)]
89-
impl From<secp256k1::Error> for Error {
90-
fn from(e: secp256k1::Error) -> Error {
88+
impl From<Secp256k1Error> for Error {
89+
fn from(e: Secp256k1Error) -> Error {
9190
Error::Secp256k1(e)
9291
}
9392
}

stacks-common/src/deps_common/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
pub mod bech32;
1818
pub mod bitcoin;
19+
#[cfg(not(target_arch = "wasm32"))]
1920
pub mod ctrlc;
2021
pub mod httparse;
2122

0 commit comments

Comments
 (0)