Skip to content

Commit 6a7b71c

Browse files
committed
PR review, align to current wasm-bindgen
1 parent 9c6493c commit 6a7b71c

File tree

9 files changed

+24
-27
lines changed

9 files changed

+24
-27
lines changed

Cargo.lock

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

grpc/tests/tonic.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![cfg(not(target_arch = "wasm32"))]
2-
//! gRPC tests
32

43
use celestia_grpc::types::auth::Account;
54
use celestia_grpc::types::tx::sign_tx;

grpc/tests/utils/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![cfg(not(target_arch = "wasm32"))]
2-
//! Utilities for grpc tests
32

43
use std::{env, fs};
54

node-wasm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ tokio = { version = "1.38.0", features = ["sync"] }
4646
tracing = "0.1.40"
4747
tracing-subscriber = { version = "0.3.18", features = ["time"] }
4848
tracing-web = "0.1.3"
49-
wasm-bindgen = "0.2.95"
49+
wasm-bindgen = "0.2.93"
5050
wasm-bindgen-futures = "0.4.43"
5151
web-sys = { version = "0.3.70", features = [
5252
"BroadcastChannel",

node/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ pin-project = "1.1.5"
8989
rexie = "0.6.2"
9090
send_wrapper = { version = "0.6.0", features = ["futures"] }
9191
serde-wasm-bindgen = "0.6.5"
92-
wasm-bindgen = "0.2.97"
92+
wasm-bindgen = "0.2.93"
9393
wasm-bindgen-futures = "0.4.43"
9494
libp2p-websocket-websys = "0.3.3"
9595

rpc/tests/blob.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::time::Duration;
66
use celestia_rpc::blob::BlobsAtHeight;
77
use celestia_rpc::prelude::*;
88
use celestia_types::consts::appconsts::AppVersion;
9-
use celestia_types::Blob;
9+
use celestia_types::{Blob, Commitment};
1010
use jsonrpsee::core::client::Subscription;
1111

1212
pub mod utils;
@@ -194,7 +194,7 @@ async fn blob_get_get_proof_wrong_commitment() {
194194
let namespace = random_ns();
195195
let data = random_bytes(5);
196196
let blob = Blob::new(namespace, data, AppVersion::V2).unwrap();
197-
let commitment = random_bytes_array().into();
197+
let commitment = Commitment::new(random_bytes_array());
198198

199199
let submitted_height = blob_submit(&client, &[blob.clone()]).await.unwrap();
200200

types/src/blob.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ mod tests {
401401
#[test]
402402
fn validate_blob_commitment_mismatch() {
403403
let mut blob = sample_blob();
404-
blob.commitment = [7; 32].into();
404+
blob.commitment = Commitment::new([7; 32]);
405405

406406
blob.validate(AppVersion::V2).unwrap_err();
407407
}

types/src/blob/commitment.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ use crate::nmt::{Namespace, NamespacedHashExt, NamespacedSha2Hasher, Nmt, RawNam
1616
use crate::{Error, Result};
1717
use crate::{InfoByte, Share};
1818

19+
// TODO: once https://github.com/rustwasm/wasm-bindgen/pull/4351 is merged,
20+
// this can be replaced with a single common type definition
1921
/// A merkle hash used to identify the [`Blob`]s data.
2022
///
2123
/// In Celestia network, the transaction which pays for the blob's inclusion
@@ -56,11 +58,15 @@ use crate::{InfoByte, Share};
5658
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
5759
pub struct Commitment {
5860
/// hash of the commitment
59-
#[cfg_attr(all(feature = "wasm-bindgen", target_arch = "wasm32"), wasm_bindgen(skip))]
6061
hash: merkle::Hash,
6162
}
6263

6364
impl Commitment {
65+
/// Create a new commitment with hash
66+
pub fn new(hash: merkle::Hash) -> Self {
67+
Commitment { hash }
68+
}
69+
6470
/// Generate the share commitment from the given blob data.
6571
pub fn from_blob(
6672
namespace: Namespace,
@@ -133,12 +139,6 @@ impl From<Commitment> for merkle::Hash {
133139
}
134140
}
135141

136-
impl From<merkle::Hash> for Commitment {
137-
fn from(hash: merkle::Hash) -> Self {
138-
Commitment { hash }
139-
}
140-
}
141-
142142
impl Serialize for Commitment {
143143
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
144144
where

types/src/blob/msg_pay_for_blobs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl From<MsgPayForBlobs> for RawMsgPayForBlobs {
8181
let share_commitments = msg
8282
.share_commitments
8383
.into_iter()
84-
.map(|c| Hash::from(c).to_vec())
84+
.map(|c| c.hash().to_vec())
8585
.collect();
8686

8787
RawMsgPayForBlobs {
@@ -108,7 +108,7 @@ impl TryFrom<RawMsgPayForBlobs> for MsgPayForBlobs {
108108
.into_iter()
109109
.map(|c| {
110110
let hash = Hash::try_from(c).map_err(|_| Error::InvalidComittmentLength)?;
111-
Ok(hash.into())
111+
Ok(Commitment::new(hash))
112112
})
113113
.collect::<Result<_, Error>>()?;
114114

0 commit comments

Comments
 (0)