@@ -8,19 +8,20 @@ use avail_rust::{
88 AvailHeader , H256 ,
99} ;
1010use 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 } ;
1514use derive_more:: From ;
15+ #[ cfg( not( target_arch = "wasm32" ) ) ]
1616use hyper:: { http, StatusCode } ;
1717use 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" ) ) ]
2222use tokio:: sync:: { mpsc:: UnboundedSender , RwLock } ;
2323use uuid:: Uuid ;
24+ #[ cfg( not( target_arch = "wasm32" ) ) ]
2425use warp:: {
2526 ws:: { self , Message } ,
2627 Reply ,
@@ -41,6 +42,7 @@ use crate::{
4142#[ derive( Debug ) ]
4243pub struct InternalServerError { }
4344
45+ #[ cfg( not( target_arch = "wasm32" ) ) ]
4446impl warp:: reject:: Reject for InternalServerError { }
4547
4648#[ derive( Serialize , Deserialize , Clone , Debug ) ]
@@ -49,6 +51,7 @@ pub struct Version {
4951 pub network_version : String ,
5052}
5153
54+ #[ cfg( not( target_arch = "wasm32" ) ) ]
5255impl Reply for Version {
5356 fn into_response ( self ) -> warp:: reply:: Response {
5457 warp:: reply:: json ( & self ) . into_response ( )
@@ -124,6 +127,7 @@ pub struct SubmitResponse {
124127 pub index : u32 ,
125128}
126129
130+ #[ cfg( not( target_arch = "wasm32" ) ) ]
127131impl Reply for SubmitResponse {
128132 fn into_response ( self ) -> warp:: reply:: Response {
129133 warp:: reply:: json ( & self ) . into_response ( )
@@ -174,6 +178,7 @@ impl From<&SharedConfig> for Vec<Mode> {
174178 }
175179}
176180
181+ #[ cfg( not( target_arch = "wasm32" ) ) ]
177182impl Reply for Status {
178183 fn into_response ( self ) -> warp:: reply:: Response {
179184 warp:: reply:: json ( & self ) . into_response ( )
@@ -318,6 +323,7 @@ impl Block {
318323 }
319324}
320325
326+ #[ cfg( not( target_arch = "wasm32" ) ) ]
321327impl Reply for Block {
322328 fn into_response ( self ) -> warp:: reply:: Response {
323329 warp:: reply:: json ( & self ) . into_response ( )
@@ -348,6 +354,7 @@ pub struct Header {
348354 received_at : u64 ,
349355}
350356
357+ #[ cfg( not( target_arch = "wasm32" ) ) ]
351358impl Reply for Header {
352359 fn into_response ( self ) -> warp:: reply:: Response {
353360 warp:: reply:: json ( & self ) . into_response ( )
@@ -547,6 +554,7 @@ pub struct DataResponse {
547554 pub data_transactions : Vec < DataTransaction > ,
548555}
549556
557+ #[ cfg( not( target_arch = "wasm32" ) ) ]
550558impl Reply for DataResponse {
551559 fn into_response ( self ) -> warp:: reply:: Response {
552560 warp:: reply:: json ( & self ) . into_response ( )
@@ -618,6 +626,7 @@ pub enum PublishMessage {
618626 DataVerified ( DataMessage ) ,
619627}
620628
629+ #[ cfg( not( target_arch = "wasm32" ) ) ]
621630impl PublishMessage {
622631 fn apply_filter ( & mut self , fields : & HashSet < DataField > ) {
623632 match self {
@@ -630,6 +639,7 @@ impl PublishMessage {
630639 }
631640}
632641
642+ #[ cfg( not( target_arch = "wasm32" ) ) ]
633643impl TryFrom < PublishMessage > for Message {
634644 type Error = Report ;
635645 fn try_from ( value : PublishMessage ) -> Result < Self , Self :: Error > {
@@ -639,13 +649,16 @@ impl TryFrom<PublishMessage> for Message {
639649 }
640650}
641651
652+ #[ cfg( not( target_arch = "wasm32" ) ) ]
642653pub type Sender = UnboundedSender < Result < ws:: Message , warp:: Error > > ;
643654
655+ #[ cfg( not( target_arch = "wasm32" ) ) ]
644656pub struct WsClient {
645657 pub subscription : Subscription ,
646658 pub sender : Option < Sender > ,
647659}
648660
661+ #[ cfg( not( target_arch = "wasm32" ) ) ]
649662impl WsClient {
650663 pub fn new ( subscription : Subscription ) -> Self {
651664 WsClient {
@@ -665,9 +678,11 @@ impl WsClient {
665678 }
666679}
667680
681+ #[ cfg( not( target_arch = "wasm32" ) ) ]
668682#[ derive( Clone ) ]
669683pub struct WsClients ( pub Arc < RwLock < HashMap < String , WsClient > > > ) ;
670684
685+ #[ cfg( not( target_arch = "wasm32" ) ) ]
671686impl WsClients {
672687 pub async fn set_sender ( & self , subscription_id : & str , sender : Sender ) -> Result < ( ) > {
673688 let mut clients = self . 0 . write ( ) . await ;
@@ -707,6 +722,7 @@ impl WsClients {
707722 }
708723}
709724
725+ #[ cfg( not( target_arch = "wasm32" ) ) ]
710726impl Default for WsClients {
711727 fn default ( ) -> Self {
712728 Self ( Arc :: new ( RwLock :: new ( HashMap :: new ( ) ) ) )
@@ -718,6 +734,7 @@ pub struct SubscriptionId {
718734 pub subscription_id : String ,
719735}
720736
737+ #[ cfg( not( target_arch = "wasm32" ) ) ]
721738impl Reply for SubscriptionId {
722739 fn into_response ( self ) -> warp:: reply:: Response {
723740 warp:: reply:: json ( & self ) . into_response ( )
@@ -754,6 +771,7 @@ impl<T> Response<T> {
754771 }
755772}
756773
774+ #[ cfg( not( target_arch = "wasm32" ) ) ]
757775impl TryFrom < ws:: Message > for Request {
758776 type Error = Report ;
759777
@@ -816,6 +834,7 @@ impl Error {
816834 Self :: new ( Some ( request_id) , None , ErrorCode :: BadRequest , message)
817835 }
818836
837+ #[ cfg( not( target_arch = "wasm32" ) ) ]
819838 fn status ( & self ) -> StatusCode {
820839 match self . error_code {
821840 ErrorCode :: NotFound => StatusCode :: NOT_FOUND ,
@@ -825,6 +844,7 @@ impl Error {
825844 }
826845}
827846
847+ #[ cfg( not( target_arch = "wasm32" ) ) ]
828848impl Reply for Error {
829849 fn into_response ( self ) -> warp:: reply:: Response {
830850 http:: Response :: builder ( )
0 commit comments