Skip to content

Commit 8674eb1

Browse files
committed
fix build after rebase;
1 parent 6d12b89 commit 8674eb1

File tree

12 files changed

+45
-29
lines changed

12 files changed

+45
-29
lines changed

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

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
use std::convert::TryInto;
44

55
use derive_more::FromStr;
6-
use ergo_lib::chain::ergo_box::BoxId;
7-
use ergo_lib::chain::ergo_box::BoxValue;
8-
use ergo_lib::chain::ergo_box::ErgoBox;
9-
use ergo_lib::chain::ergo_box::ErgoBoxCandidate;
10-
use ergo_lib::chain::ergo_box::NonMandatoryRegisters;
11-
use ergo_lib::chain::token::Token;
12-
use ergo_lib::chain::token::TokenId;
136
use ergo_lib::chain::transaction::unsigned::UnsignedTransaction;
147
use ergo_lib::chain::transaction::DataInput;
158
use ergo_lib::chain::transaction::Input;
169
use ergo_lib::chain::transaction::Transaction;
1710
use ergo_lib::chain::transaction::TxId;
1811
use ergo_lib::chain::transaction::UnsignedInput;
12+
use ergo_lib::ergotree_ir::chain::ergo_box::box_value::BoxValue;
13+
use ergo_lib::ergotree_ir::chain::ergo_box::BoxId;
14+
use ergo_lib::ergotree_ir::chain::ergo_box::ErgoBox;
15+
use ergo_lib::ergotree_ir::chain::ergo_box::ErgoBoxCandidate;
16+
use ergo_lib::ergotree_ir::chain::ergo_box::NonMandatoryRegisters;
17+
use ergo_lib::ergotree_ir::chain::token::Token;
18+
use ergo_lib::ergotree_ir::chain::token::TokenId;
1919
use ergo_lib::ergotree_ir::ergo_tree::ErgoTree;
2020
use serde::Serialize;
2121

@@ -85,7 +85,10 @@ pub(crate) struct ErgoBoxJsonEip12 {
8585
#[serde(rename = "value")]
8686
pub value: BoxValueJsonEip12,
8787
/// guarding script, which should be evaluated to true in order to open this box
88-
#[serde(rename = "ergoTree", with = "ergo_lib::chain::json::ergo_tree")]
88+
#[serde(
89+
rename = "ergoTree",
90+
with = "ergo_lib::ergotree_ir::chain::json::ergo_tree"
91+
)]
8992
pub ergo_tree: ErgoTree,
9093
/// secondary tokens the box contains
9194
#[serde(rename = "assets")]
@@ -130,7 +133,10 @@ pub(crate) struct ErgoBoxCandidateJsonEip12 {
130133
#[serde(rename = "value")]
131134
pub value: BoxValueJsonEip12,
132135
/// guarding script, which should be evaluated to true in order to open this box
133-
#[serde(rename = "ergoTree", with = "ergo_lib::chain::json::ergo_tree")]
136+
#[serde(
137+
rename = "ergoTree",
138+
with = "ergo_lib::ergotree_ir::chain::json::ergo_tree"
139+
)]
134140
pub ergo_tree: ErgoTree,
135141
#[serde(rename = "assets")]
136142
pub tokens: Vec<TokenJsonEip12>,
@@ -184,7 +190,7 @@ impl From<Token> for TokenJsonEip12 {
184190
fn from(t: Token) -> Self {
185191
TokenJsonEip12 {
186192
token_id: t.token_id,
187-
amount: TokenAmountJsonEip12(t.amount.as_u64()),
193+
amount: TokenAmountJsonEip12(*t.amount.as_u64()),
188194
}
189195
}
190196
}
@@ -196,6 +202,7 @@ pub struct TokenAmountJsonEip12(
196202
// Encodes as string always
197203
#[serde_as(as = "serde_with::DisplayFromStr")] u64,
198204
);
205+
199206
#[cfg(test)]
200207
mod tests {
201208
use super::*;

ergo-lib/CHANGELOG.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
3838
- `Constant::to/from_ergo_box`to Wasm API [#397](https://github.com/ergoplatform/sigma-rust/pull/397);
3939

4040
### Changed(BREAKING!):
41-
- `ErgoTree::to_bytes()` renamed to `ErgoTree::sigma_serialize_bytes()` in Wasm [#387](https://github.com/ergoplatform/sigma-rust/pull/387);
42-
- `ErgoBox` and other types that it uses moved to `ergotree_ir` crate and re-exported in `ergo_lib::ergotree_ir` [#397](https://github.com/ergoplatform/sigma-rust/pull/397);
43-
44-
### Changed(BREAKING)
4541
- **WASM `to_json()` returns string (instead of `JsValue`) to avoid silent accuracy loss on JS object -> text conversion on JS side [#346](https://github.com/ergoplatform/sigma-rust/pull/346);**
4642
- `SigmaSerializable:sigma_serialize_bytes` made failible (returns `Result`) [#328](https://github.com/ergoplatform/sigma-rust/pull/328);
4743
- `ErgoBox::new`, `from_box_candidate` made failible (returns `Result`) [#328](https://github.com/ergoplatform/sigma-rust/pull/328);
4844
- `ErgoTree::new`, `template_bytes`, `to_base16_bytes` made failible (returns `Result`) [#328](https://github.com/ergoplatform/sigma-rust/pull/328);
4945
- `Transaction::new` made failible (returns `Result`) [#328](https://github.com/ergoplatform/sigma-rust/pull/328);
5046
- WASM `ErgoBox::new`, `byte_to_sign` made failible (returns `Result`) [#328](https://github.com/ergoplatform/sigma-rust/pull/328);
5147
- WASM `ErgoTree::to_bytes`, `to_base16_bytes` made failible (returns `Result`) [#328](https://github.com/ergoplatform/sigma-rust/pull/328);
48+
- `ErgoTree::to_bytes()` renamed to `ErgoTree::sigma_serialize_bytes()` in Wasm [#387](https://github.com/ergoplatform/sigma-rust/pull/387);
49+
- `ErgoBox` and other types that it uses moved to `ergotree_ir` crate and re-exported in `ergo_lib::ergotree_ir` [#397](https://github.com/ergoplatform/sigma-rust/pull/397);
5250

5351
### Changed
5452
- Switched to `ThreadRng` CSPRNG for source of randomness in sigma protocol [#315](https://github.com/ergoplatform/sigma-rust/pull/315);

ergo-lib/src/chain/json.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub(crate) mod transaction;
66
use ergotree_interpreter::sigma_protocol::prover::ProofBytes;
77
use serde::{Deserialize, Serialize};
88

9+
/// Serde remote type
910
#[cfg_attr(
1011
feature = "json",
1112
derive(Serialize, Deserialize),

ergotree-interpreter/src/eval/coll_slice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ mod tests {
8787
)
8888
.unwrap()
8989
.into();
90-
assert_eq!(eval_out_wo_ctx::<Vec<i64>>(&expr), vec![]);
90+
assert_eq!(eval_out_wo_ctx::<Vec<i64>>(&expr), Vec::<i64>::new());
9191
}
9292

9393
#[test]

ergotree-interpreter/src/eval/scoll.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ mod tests {
561561
.unwrap()
562562
.into();
563563
let res = eval_out_wo_ctx::<Vec<i32>>(&expr);
564-
assert_eq!(res, vec![]);
564+
assert_eq!(res, Vec::<i32>::new());
565565
}
566566

567567
#[test]

ergotree-interpreter/src/sigma_protocol/private_input.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use ergotree_ir::sigma_protocol::dlog_group;
66
use ergotree_ir::sigma_protocol::sigma_boolean::ProveDhTuple;
77
use ergotree_ir::sigma_protocol::sigma_boolean::ProveDlog;
88

9-
use elliptic_curve::group::ff::PrimeField;
109
use ergotree_ir::sigma_protocol::sigma_boolean::SigmaBoolean;
1110
use k256::Scalar;
1211

ergotree-ir/Cargo.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,17 @@ default-features = false
4949
features = ["std"]
5050
optional = true
5151

52+
[dependencies.serde_with]
53+
version = "1.9.1"
54+
features = [ "json" ]
55+
optional = true
56+
5257
[features]
5358
default = []
5459
arbitrary = ["proptest", "proptest-derive"]
55-
json = ["serde", "serde_json"]
60+
json = ["serde", "serde_json", "serde_with"]
5661

5762
[dev-dependencies]
5863
sigma-test-util = { version = "0.2.0", path = "../sigma-test-util" }
5964
rand = "0.8.3"
65+
pretty_assertions = "0.7.2"

ergotree-ir/src/chain/ergo_box/box_value.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
//! Box value newtype
22
33
use crate::chain::token::TokenAmountError;
4-
use derive_more::FromStr;
5-
use ergotree_ir::mir::constant::Constant;
6-
use ergotree_ir::serialization::sigma_byte_writer::SigmaByteWrite;
7-
use ergotree_ir::serialization::SigmaSerializeResult;
8-
use ergotree_ir::serialization::{
4+
use crate::mir::constant::Constant;
5+
use crate::serialization::sigma_byte_writer::SigmaByteWrite;
6+
use crate::serialization::SigmaSerializeResult;
7+
use crate::serialization::{
98
sigma_byte_reader::SigmaByteRead, SigmaParsingError, SigmaSerializable,
109
};
10+
use derive_more::FromStr;
1111
use std::convert::TryFrom;
1212
use thiserror::Error;
1313

@@ -211,7 +211,7 @@ pub fn checked_sum<I: Iterator<Item = BoxValue>>(mut iter: I) -> Result<BoxValue
211211

212212
/// Arbitrary
213213
#[cfg(feature = "arbitrary")]
214-
pub(crate) mod arbitrary {
214+
pub mod arbitrary {
215215
use derive_more::{From, Into};
216216
use proptest::{arbitrary::Arbitrary, prelude::*};
217217
use std::ops::Range;

ergotree-ir/src/chain/json.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use serde::Serializer;
44

55
pub(crate) mod ergo_box;
6-
pub(crate) mod ergo_tree;
6+
pub mod ergo_tree;
77

88
/// Serialize bytes ([u8]) as base16 encoded string
99
pub fn serialize_bytes<S, T>(bytes: T, serializer: S) -> Result<S::Ok, S::Error>

ergo-lib/src/chain/json/ergo_box/box_value.rs renamed to ergotree-ir/src/chain/json/ergo_box/box_value.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
#[allow(clippy::unwrap_used)]
12
#[cfg(test)]
23
mod tests {
3-
use crate::chain::ergo_box::BoxValue;
4+
use crate::chain::ergo_box::box_value::BoxValue;
45
use std::convert::TryInto;
56

67
#[test]

0 commit comments

Comments
 (0)