Skip to content

Commit f670bf6

Browse files
committed
no_std ergo-lib, make ergo-merkle-tree and ergo-nipopow optional
1 parent ed0fc12 commit f670bf6

File tree

33 files changed

+241
-179
lines changed

33 files changed

+241
-179
lines changed

bindings/ergo-lib-c-core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ futures-util = "0.3"
2222
url = { workspace = true }
2323
bounded-integer = { workspace = true }
2424
serde_with = { workspace = true }
25-
bounded-vec = { workspace = true, features=["serde"] }
25+
bounded-vec = { workspace = true, features = ["serde"] }
2626

2727
[features]
2828
default = ["mnemonic_gen", "ergo-lib/compiler"]

bindings/ergo-lib-c-core/src/transaction.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub unsafe fn hints_bag_get(
7979
}
8080

8181
/// TransactionHintsBag
82-
pub struct TransactionHintsBag(pub(crate) ergo_lib::wallet::multi_sig::TransactionHintsBag);
82+
pub struct TransactionHintsBag(pub(crate) ergo_lib::wallet::TransactionHintsBag);
8383
pub type TransactionHintsBagPtr = *mut TransactionHintsBag;
8484
pub type ConstTransactionHintsBagPtr = *const TransactionHintsBag;
8585

@@ -90,7 +90,7 @@ pub unsafe fn transaction_hints_bag_empty(
9090
let transaction_hints_bag_out =
9191
mut_ptr_as_mut(transaction_hints_bag_out, "transaction_hints_bag_out")?;
9292
*transaction_hints_bag_out = Box::into_raw(Box::new(TransactionHintsBag(
93-
ergo_lib::wallet::multi_sig::TransactionHintsBag::empty(),
93+
ergo_lib::wallet::TransactionHintsBag::empty(),
9494
)));
9595
Ok(())
9696
}

bindings/ergo-lib-wasm/src/transaction.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ impl From<ergo_lib::ergotree_interpreter::sigma_protocol::prover::hint::HintsBag
7676

7777
/// TransactionHintsBag
7878
#[wasm_bindgen]
79-
pub struct TransactionHintsBag(pub(crate) ergo_lib::wallet::multi_sig::TransactionHintsBag);
79+
pub struct TransactionHintsBag(pub(crate) ergo_lib::wallet::TransactionHintsBag);
8080

8181
#[wasm_bindgen]
8282
impl TransactionHintsBag {
8383
/// Empty TransactionHintsBag
8484
pub fn empty() -> TransactionHintsBag {
85-
TransactionHintsBag(ergo_lib::wallet::multi_sig::TransactionHintsBag::empty())
85+
TransactionHintsBag(ergo_lib::wallet::TransactionHintsBag::empty())
8686
}
8787

8888
/// Adding hints for input
@@ -106,8 +106,8 @@ impl TransactionHintsBag {
106106
}
107107
}
108108

109-
impl From<ergo_lib::wallet::multi_sig::TransactionHintsBag> for TransactionHintsBag {
110-
fn from(t: ergo_lib::wallet::multi_sig::TransactionHintsBag) -> Self {
109+
impl From<ergo_lib::wallet::TransactionHintsBag> for TransactionHintsBag {
110+
fn from(t: ergo_lib::wallet::TransactionHintsBag) -> Self {
111111
TransactionHintsBag(t)
112112
}
113113
}

ergo-lib/Cargo.toml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ sigma-util = { workspace = true }
1717
ergo-chain-types = { workspace = true }
1818
ergotree-ir = { workspace = true }
1919
ergotree-interpreter = { workspace = true }
20-
ergo-nipopow = { workspace = true }
20+
ergo-nipopow = { workspace = true, optional = true }
2121
ergoscript-compiler = { workspace = true, optional = true }
22-
ergo-merkle-tree = { workspace = true }
22+
ergo-merkle-tree = { workspace = true, optional = true }
2323
ergo-rest = { workspace = true, optional = true }
2424
indexmap = { workspace = true }
2525
base16 = { workspace = true }
@@ -28,39 +28,45 @@ serde_json = { workspace = true, optional = true }
2828
thiserror = { workspace = true }
2929
derive_more = { workspace = true }
3030
bounded-vec = { workspace = true }
31-
num-bigint = { workspace = true, features = ["serde"] }
3231
proptest-derive = { workspace = true, optional = true }
3332
k256 = { workspace = true }
3433
sha2 = { workspace = true }
3534
hmac = { version = "0.12" }
3635
pbkdf2 = "0.11"
37-
rand = { workspace = true }
36+
rand = { workspace = true, optional = true }
3837
bitvec = { workspace = true, optional = true }
39-
unicode-normalization = "0.1.19"
38+
unicode-normalization = { version = "0.1.19", default-features = false }
4039
lazy_static = { workspace = true }
4140
proptest = { workspace = true, optional = true }
4241
serde_with = { workspace = true, optional = true }
4342
itertools = { workspace = true }
43+
hashbrown = { workspace = true }
4444

4545

4646
[features]
47-
default = ["json"]
47+
default = ["std", "json", "nipopow", "merkle"]
48+
std = ["rand", "ergotree-ir/std", "ergotree-interpreter/std"]
4849
json = [
4950
"serde",
5051
"serde_json",
5152
"serde_with",
5253
"bounded-vec/serde",
5354
"ergotree-ir/json",
55+
"ergotree-interpreter/json",
56+
"ergo-merkle-tree?/json",
5457
]
5558
compiler = ["ergoscript-compiler"]
5659
arbitrary = [
60+
"std",
5761
"proptest",
5862
"proptest-derive",
5963
"ergotree-ir/arbitrary",
6064
"ergo-chain-types/arbitrary",
6165
"ergotree-interpreter/arbitrary",
6266
]
63-
mnemonic_gen = ["bitvec"]
67+
merkle = ["ergo-merkle-tree"]
68+
nipopow = ["ergo-nipopow"]
69+
mnemonic_gen = ["bitvec", "rand"]
6470
rest = ["ergo-rest"]
6571

6672
[dev-dependencies]

ergo-lib/src/chain/contract.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,13 @@ impl Contract {
3737
}
3838
}
3939

40-
#[cfg(test)]
40+
#[cfg(all(test, feature = "compiler"))]
4141
#[allow(clippy::unwrap_used)]
4242
mod tests {
4343
use super::*;
4444

45-
#[cfg(feature = "compiler")]
4645
#[test]
4746
fn compile() {
48-
let contract =
49-
Contract::compile("HEIGHT", ergoscript_compiler::script_env::ScriptEnv::new()).unwrap();
50-
dbg!(&contract);
47+
Contract::compile("HEIGHT", ergoscript_compiler::script_env::ScriptEnv::new()).unwrap();
5148
}
5249
}

ergo-lib/src/chain/ergo_box/box_builder.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
//! ErgoBoxCandidate builder
22
3-
use std::collections::HashMap;
4-
use std::convert::{TryFrom, TryInto};
3+
use alloc::string::String;
4+
use alloc::string::ToString;
5+
use alloc::vec::Vec;
6+
use core::convert::{TryFrom, TryInto};
7+
use hashbrown::HashMap;
58

69
use ergotree_ir::chain::address::AddressEncoderError;
710
use ergotree_ir::chain::ergo_box::box_value::BoxValue;

ergo-lib/src/chain/json.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! JSON serialization
22
3+
use alloc::string::String;
4+
use alloc::vec::Vec;
35
use serde::{Deserialize, Serialize};
46

57
use ergotree_interpreter::sigma_protocol::prover::ProofBytes;

ergo-lib/src/chain/json/hint.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
use std::collections::HashMap;
1+
use alloc::vec::Vec;
2+
use hashbrown::HashMap;
23

34
use ergotree_interpreter::sigma_protocol::prover::hint::{Hint, HintsBag};
45
use serde::{Deserialize, Serialize};
56

6-
use crate::wallet::multi_sig::TransactionHintsBag;
7+
use crate::wallet::TransactionHintsBag;
78

89
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
910
pub struct TransactionHintsBagJson {
@@ -51,7 +52,7 @@ impl From<TransactionHintsBagJson> for TransactionHintsBag {
5152

5253
#[cfg(test)]
5354
mod tests {
54-
use crate::wallet::multi_sig::TransactionHintsBag;
55+
use crate::wallet::TransactionHintsBag;
5556
use proptest::prelude::*;
5657

5758
proptest! {

ergo-lib/src/chain/json/parameters.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::chain::parameters::{Parameter, Parameters};
2+
use hashbrown::HashMap;
23
use serde::{Deserialize, Serialize};
3-
use std::collections::HashMap;
44

55
#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Clone)]
66
pub struct ParametersJson {

ergo-lib/src/chain/json/transaction.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
use std::convert::TryFrom;
1+
use alloc::string::String;
2+
use alloc::vec::Vec;
3+
use core::convert::TryFrom;
24
use thiserror::Error;
35

46
use crate::chain::transaction::unsigned::UnsignedTransaction;

0 commit comments

Comments
 (0)