@@ -8,19 +8,20 @@ use avail_rust::{
8
8
AvailHeader , H256 ,
9
9
} ;
10
10
use codec:: Encode ;
11
- use color_eyre:: {
12
- eyre:: { eyre, WrapErr } ,
13
- Report , Result ,
14
- } ;
11
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
12
+ use color_eyre:: eyre:: eyre;
13
+ use color_eyre:: { eyre:: WrapErr , Report , Result } ;
15
14
use derive_more:: From ;
15
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
16
16
use hyper:: { http, StatusCode } ;
17
17
use serde:: { de, Deserialize , Deserializer , Serialize , Serializer } ;
18
- use std:: {
19
- collections :: { HashMap , HashSet } ,
20
- sync:: Arc ,
21
- } ;
18
+ use std:: collections :: HashSet ;
19
+ # [ cfg ( not ( target_arch = "wasm32" ) ) ]
20
+ use std :: { collections :: HashMap , sync:: Arc } ;
21
+ # [ cfg ( not ( target_arch = "wasm32" ) ) ]
22
22
use tokio:: sync:: { mpsc:: UnboundedSender , RwLock } ;
23
23
use uuid:: Uuid ;
24
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
24
25
use warp:: {
25
26
ws:: { self , Message } ,
26
27
Reply ,
@@ -41,6 +42,7 @@ use crate::{
41
42
#[ derive( Debug ) ]
42
43
pub struct InternalServerError { }
43
44
45
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
44
46
impl warp:: reject:: Reject for InternalServerError { }
45
47
46
48
#[ derive( Serialize , Deserialize , Clone , Debug ) ]
@@ -49,6 +51,7 @@ pub struct Version {
49
51
pub network_version : String ,
50
52
}
51
53
54
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
52
55
impl Reply for Version {
53
56
fn into_response ( self ) -> warp:: reply:: Response {
54
57
warp:: reply:: json ( & self ) . into_response ( )
@@ -124,6 +127,7 @@ pub struct SubmitResponse {
124
127
pub index : u32 ,
125
128
}
126
129
130
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
127
131
impl Reply for SubmitResponse {
128
132
fn into_response ( self ) -> warp:: reply:: Response {
129
133
warp:: reply:: json ( & self ) . into_response ( )
@@ -174,6 +178,7 @@ impl From<&SharedConfig> for Vec<Mode> {
174
178
}
175
179
}
176
180
181
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
177
182
impl Reply for Status {
178
183
fn into_response ( self ) -> warp:: reply:: Response {
179
184
warp:: reply:: json ( & self ) . into_response ( )
@@ -318,6 +323,7 @@ impl Block {
318
323
}
319
324
}
320
325
326
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
321
327
impl Reply for Block {
322
328
fn into_response ( self ) -> warp:: reply:: Response {
323
329
warp:: reply:: json ( & self ) . into_response ( )
@@ -348,6 +354,7 @@ pub struct Header {
348
354
received_at : u64 ,
349
355
}
350
356
357
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
351
358
impl Reply for Header {
352
359
fn into_response ( self ) -> warp:: reply:: Response {
353
360
warp:: reply:: json ( & self ) . into_response ( )
@@ -547,6 +554,7 @@ pub struct DataResponse {
547
554
pub data_transactions : Vec < DataTransaction > ,
548
555
}
549
556
557
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
550
558
impl Reply for DataResponse {
551
559
fn into_response ( self ) -> warp:: reply:: Response {
552
560
warp:: reply:: json ( & self ) . into_response ( )
@@ -618,6 +626,7 @@ pub enum PublishMessage {
618
626
DataVerified ( DataMessage ) ,
619
627
}
620
628
629
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
621
630
impl PublishMessage {
622
631
fn apply_filter ( & mut self , fields : & HashSet < DataField > ) {
623
632
match self {
@@ -630,6 +639,7 @@ impl PublishMessage {
630
639
}
631
640
}
632
641
642
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
633
643
impl TryFrom < PublishMessage > for Message {
634
644
type Error = Report ;
635
645
fn try_from ( value : PublishMessage ) -> Result < Self , Self :: Error > {
@@ -639,13 +649,16 @@ impl TryFrom<PublishMessage> for Message {
639
649
}
640
650
}
641
651
652
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
642
653
pub type Sender = UnboundedSender < Result < ws:: Message , warp:: Error > > ;
643
654
655
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
644
656
pub struct WsClient {
645
657
pub subscription : Subscription ,
646
658
pub sender : Option < Sender > ,
647
659
}
648
660
661
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
649
662
impl WsClient {
650
663
pub fn new ( subscription : Subscription ) -> Self {
651
664
WsClient {
@@ -665,9 +678,11 @@ impl WsClient {
665
678
}
666
679
}
667
680
681
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
668
682
#[ derive( Clone ) ]
669
683
pub struct WsClients ( pub Arc < RwLock < HashMap < String , WsClient > > > ) ;
670
684
685
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
671
686
impl WsClients {
672
687
pub async fn set_sender ( & self , subscription_id : & str , sender : Sender ) -> Result < ( ) > {
673
688
let mut clients = self . 0 . write ( ) . await ;
@@ -707,6 +722,7 @@ impl WsClients {
707
722
}
708
723
}
709
724
725
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
710
726
impl Default for WsClients {
711
727
fn default ( ) -> Self {
712
728
Self ( Arc :: new ( RwLock :: new ( HashMap :: new ( ) ) ) )
@@ -718,6 +734,7 @@ pub struct SubscriptionId {
718
734
pub subscription_id : String ,
719
735
}
720
736
737
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
721
738
impl Reply for SubscriptionId {
722
739
fn into_response ( self ) -> warp:: reply:: Response {
723
740
warp:: reply:: json ( & self ) . into_response ( )
@@ -754,6 +771,7 @@ impl<T> Response<T> {
754
771
}
755
772
}
756
773
774
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
757
775
impl TryFrom < ws:: Message > for Request {
758
776
type Error = Report ;
759
777
@@ -816,6 +834,7 @@ impl Error {
816
834
Self :: new ( Some ( request_id) , None , ErrorCode :: BadRequest , message)
817
835
}
818
836
837
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
819
838
fn status ( & self ) -> StatusCode {
820
839
match self . error_code {
821
840
ErrorCode :: NotFound => StatusCode :: NOT_FOUND ,
@@ -825,6 +844,7 @@ impl Error {
825
844
}
826
845
}
827
846
847
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
828
848
impl Reply for Error {
829
849
fn into_response ( self ) -> warp:: reply:: Response {
830
850
http:: Response :: builder ( )
0 commit comments