Skip to content

Commit 045edc5

Browse files
authored
Merge pull request #71 from AluVM/bytestr-debug
Bytestr debug
2 parents 50a4bb0 + 45657ba commit 045edc5

8 files changed

Lines changed: 38 additions & 22 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
strategy:
4545
fail-fast: false
4646
matrix:
47-
os: [ ubuntu-20.04, ubuntu-22.04, macos-11.0, macos-12.0, windows-2019, windows-2022 ]
47+
os: [ ubuntu-20.04, ubuntu-22.04, macos-11, macos-12, windows-2019, windows-2022 ]
4848
steps:
4949
- uses: actions/checkout@v2
5050
- name: Install macos dependencies

Cargo.lock

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

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "aluvm"
33
description = "Functional registry-based RISC virtual machine"
4-
version = "0.10.0-rc.1"
4+
version = "0.10.0"
55
authors = ["Dr Maxim Orlovsky <orlovsky@ubideco.org>"]
66
repository = "https://github.com/aluvm/rust-aluvm"
77
homepage = "https://aluvm.org"
@@ -25,13 +25,13 @@ name = "asm"
2525
required-features = ["all"]
2626

2727
[dependencies]
28-
amplify = { version = "4.0.0-beta.20", default-features = false, features = ["apfloat", "derive", "hex"] }
28+
amplify = { version = "4.0.0-beta.22", default-features = false, features = ["apfloat", "derive", "hex"] }
2929
paste = "1"
3030
strict_encoding = { version = "2.0.0", default-features = false, features = ["float", "derive"] }
31-
strict_types = { version = "1.0.0-rc.1", optional = true }
31+
strict_types = { version = "1.0.0", optional = true }
3232
bitcoin_hashes = { version = "0.12.0", default-features = false } # this is most well-maintained generic hash implementation library
3333
blake3 = { version = "1.3.3", default-features = false }
34-
baid58 = "0.2.0"
34+
baid58 = "0.3.0"
3535
secp256k1 = { version = "0.27.0", optional = true, features = ["global-context"] }
3636
curve25519-dalek = { version = "3.2", optional = true }
3737
half = "2.1.0"

src/bin/aluvm-stl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
4141
let args: Vec<String> = env::args().collect();
4242

4343
let sty_id =
44-
TypeLibId::from_str("gordon_george_magic_7UDb1RpkpgFcP3LhPVqSiAXAFfxoBLxtRSvWYwhy8F7W")?;
44+
TypeLibId::from_str("danube_cotton_kansas_3xcfudRJUuwQ187puYDdNcxGeTpG8AoHyTrfJ9ryo9k6")?;
4545

4646
let imports = bset! {
4747
Dependency::with(sty_id, libname!(STRICT_TYPES_LIB)),

src/data/byte_str.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ use alloc::boxed::Box;
2525
use alloc::vec::Vec;
2626
use core::borrow::{Borrow, BorrowMut};
2727
use core::convert::TryFrom;
28-
use core::fmt::{self, Display, Formatter};
28+
use core::fmt::{self, Debug, Display, Formatter};
2929
use core::ops::Range;
3030

3131
use amplify::confinement::{SmallBlob, TinyBlob};
3232
use amplify::num::error::OverflowError;
3333

3434
/// Large binary bytestring object.
35-
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
35+
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
3636
pub struct ByteStr {
3737
/// Adjusted slice length.
3838
len: u16,
@@ -155,12 +155,27 @@ impl ByteStr {
155155
pub fn to_vec(&self) -> Vec<u8> { self.as_ref().to_vec() }
156156
}
157157

158+
#[cfg(not(feature = "std"))]
159+
impl Debug for ByteStr {
160+
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { write!(f, "{:#04X?}", self.as_ref()) }
161+
}
162+
163+
#[cfg(feature = "std")]
164+
impl Debug for ByteStr {
165+
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
166+
use amplify::hex::ToHex;
167+
168+
f.debug_tuple("ByteStr").field(&self.as_ref().to_hex()).finish()
169+
}
170+
}
171+
158172
#[cfg(feature = "std")]
159173
impl Display for ByteStr {
160174
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
161175
use std::fmt::Write;
162176

163177
use amplify::hex::ToHex;
178+
164179
let vec = Vec::from(&self.bytes[..self.len as usize]);
165180
if f.alternate() {
166181
for (line, slice) in self.as_ref().chunks(16).enumerate() {
@@ -207,9 +222,7 @@ impl Display for ByteStr {
207222

208223
#[cfg(not(feature = "std"))]
209224
impl Display for ByteStr {
210-
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
211-
write!(f, "{:#04X?}", &self.bytes[0usize..self.len as usize])
212-
}
225+
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { write!(f, "{:#04X?}", self.as_ref()) }
213226
}
214227

215228
/*

src/library/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub const LIB_ID_TAG: [u8; 32] = *b"urn:ubideco:aluvm:lib:v01#230304";
4545
/// Unique identifier for a library.
4646
#[derive(Wrapper, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Default, Debug, Display, From)]
4747
#[wrapper(Deref, BorrowSlice, Hex, Index, RangeOps)]
48-
#[display(Self::to_baid58)]
48+
#[display(Self::to_baid58_string)]
4949
#[derive(StrictType, StrictEncode, StrictDecode)]
5050
#[strict_type(lib = LIB_NAME_ALUVM)]
5151
#[cfg_attr(
@@ -70,6 +70,10 @@ impl FromStr for LibId {
7070
fn from_str(s: &str) -> Result<Self, Self::Err> { Self::from_baid58_str(s) }
7171
}
7272

73+
impl LibId {
74+
fn to_baid58_string(&self) -> String { format!("{:+}", self.to_baid58()) }
75+
}
76+
7377
impl LibId {
7478
/// Computes LibId from the provided data
7579
pub fn with(

stl/AluVM.asc.stl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
----- BEGIN STRICT TYPE LIB -----
2-
Id: 5GpK1xbT5AT8buj9rEh2Tp7iFJf7rr36qmbbaU39aMWD
3-
Checksum: sardine-ground-beatles
2+
Id: sardine_ground_beatles_5GpK1xbT5AT8buj9rEh2Tp7iFJf7rr36qmbbaU39aMWD
43

54
BUFsdVZNAAIABUxpYklkBQEABwAAASAAB0xpYlNpdGUGAgNsaWIBBUxpYklkBNZYwiy7A7HjJQR9
65
MqOnirGxPe4MWiiqVIXEJR6dVcgDcG9zAAAC

stl/AluVM.sty

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{-
2-
Id: 5GpK1xbT5AT8buj9rEh2Tp7iFJf7rr36qmbbaU39aMWD
2+
Id: sardine_ground_beatles_5GpK1xbT5AT8buj9rEh2Tp7iFJf7rr36qmbbaU39aMWD
33
Name: AluVM
44
Description: Consensus layer for RGB smart contracts
55
Author: Dr Maxim Orlovsky <orlovsky@ubideco.org>

0 commit comments

Comments
 (0)