Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose public parameters and Position fns in no-std #108

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion kate/recovery/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ authors = ["Denis Ermolin <[email protected]>"]
edition = "2018"
license = "Apache-2.0"

[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.2.15", features = ["js"] }
sp-io = { workspace = true, features = [ "disable_panic_handler" ] }

[dependencies]
# Internals
avail-core = { path = "../../core", default-features = false }
dusk-plonk = { workspace = true, optional = true }
dusk-plonk = { workspace = true }

# Parity
codec = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
Expand Down
6 changes: 5 additions & 1 deletion kate/recovery/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ use sp_std::{collections::btree_map::BTreeMap, vec::Vec};

use crate::matrix::{Dimensions, Position, RowIndex};

#[cfg(target_arch = "wasm32")]
extern crate alloc;
#[cfg(target_arch = "wasm32")]
use alloc::string::String;

/// Position and data of a cell in extended matrix
#[derive(Default, Debug, Clone, Constructor)]
pub struct DataCell {
Expand All @@ -23,7 +28,6 @@ pub struct Cell {
}

impl Cell {
#[cfg(feature = "std")]
pub fn reference(&self, block: u32) -> String {
self.position.reference(block)
}
Expand Down
1 change: 0 additions & 1 deletion kate/recovery/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ pub mod sparse_slice_read;
#[cfg(feature = "std")]
pub mod testnet;

#[cfg(feature = "std")]
pub mod couscous;
7 changes: 5 additions & 2 deletions kate/recovery/src/matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ use sp_std::vec;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};

#[cfg(target_arch = "wasm32")]
extern crate alloc;
#[cfg(target_arch = "wasm32")]
use alloc::{format, string::String};

/// Position of a cell in the the matrix.
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Default, Debug, Clone, Copy, Hash, Eq, PartialEq, Constructor)]
Expand Down Expand Up @@ -51,7 +56,6 @@ impl Display for Position {

impl Position {
/// Reference in format `block_number:column_number:row_number`
#[cfg(feature = "std")]
pub fn reference(&self, block_number: u32) -> String {
format!("{}:{}", block_number, self)
}
Expand All @@ -76,7 +80,6 @@ pub struct RowIndex(pub u32);

impl RowIndex {
/// Reference in format `block_number:row_number`
#[cfg(feature = "std")]
pub fn reference(&self, block_number: u32) -> String {
format!("{}:{}", block_number, self.0)
}
Expand Down
Loading