1
- #![ cfg( target_family = "wasm" ) ]
2
1
use async_trait:: async_trait;
3
2
use mithril_client:: {
4
3
feedback:: { FeedbackReceiver , MithrilEvent } ,
@@ -10,6 +9,7 @@ use wasm_bindgen::prelude::*;
10
9
11
10
type WasmResult = Result < JsValue , JsValue > ;
12
11
12
+ #[ wasm_bindgen]
13
13
struct JSBroadcastChannelFeedbackReceiver {
14
14
channel : String ,
15
15
}
@@ -50,12 +50,12 @@ impl From<MithrilEvent> for MithrilEventWasm {
50
50
}
51
51
}
52
52
53
- #[ cfg_attr ( target_family = "wasm" , wasm_bindgen( js_name = MithrilClient ) ) ]
53
+ #[ wasm_bindgen]
54
54
pub struct MithrilClient {
55
55
client : Client ,
56
56
}
57
57
58
- #[ wasm_bindgen( js_class = MithrilClient ) ]
58
+ #[ wasm_bindgen]
59
59
impl MithrilClient {
60
60
/// Constructor for wasm client
61
61
#[ wasm_bindgen( constructor) ]
@@ -70,7 +70,6 @@ impl MithrilClient {
70
70
}
71
71
72
72
/// Call the client to get a snapshot from a digest
73
- // #[wasm_bindgen(js_name = get_snapshot)]
74
73
pub async fn get_snapshot ( & self , digest : & str ) -> WasmResult {
75
74
let result = self
76
75
. client
@@ -83,7 +82,6 @@ impl MithrilClient {
83
82
}
84
83
85
84
/// Call the client to get the list of available snapshots
86
- // #[wasm_bindgen(js_name = list_snapshots)]
87
85
pub async fn list_snapshots ( & self ) -> WasmResult {
88
86
let result = self
89
87
. client
@@ -96,7 +94,6 @@ impl MithrilClient {
96
94
}
97
95
98
96
/// Call the client to get a mithril stake distribution from a hash
99
- // #[wasm_bindgen(js_name = get_mithril_stake_distribution)]
100
97
pub async fn get_mithril_stake_distribution ( & self , hash : & str ) -> WasmResult {
101
98
let result = self
102
99
. client
@@ -109,7 +106,6 @@ impl MithrilClient {
109
106
}
110
107
111
108
/// Call the client for the list of available mithril stake distributions
112
- // #[wasm_bindgen(js_name = list_mithril_stake_distributions)]
113
109
pub async fn list_mithril_stake_distributions ( & self ) -> WasmResult {
114
110
let result = self
115
111
. client
@@ -122,7 +118,6 @@ impl MithrilClient {
122
118
}
123
119
124
120
/// Call the client to compute a mithril stake distribution message
125
- // #[wasm_bindgen(js_name = compute_mithril_stake_distribution_message)]
126
121
pub async fn compute_mithril_stake_distribution_message (
127
122
& self ,
128
123
stake_distribution : JsValue ,
@@ -137,7 +132,6 @@ impl MithrilClient {
137
132
}
138
133
139
134
/// Call the client to verify a mithril stake distribution message
140
- // #[wasm_bindgen(js_name = verify_message_match_certificate)]
141
135
pub async fn verify_message_match_certificate (
142
136
& self ,
143
137
message : JsValue ,
@@ -151,7 +145,6 @@ impl MithrilClient {
151
145
}
152
146
153
147
/// Call the client to get a mithril certificate from a certificate hash
154
- // #[wasm_bindgen(js_name = get_mithril_certificate)]
155
148
pub async fn get_mithril_certificate ( & self , hash : & str ) -> WasmResult {
156
149
let result = self
157
150
. client
@@ -164,7 +157,6 @@ impl MithrilClient {
164
157
}
165
158
166
159
/// Call the client for the list of available mithril certificates
167
- // #[wasm_bindgen(js_name = list_mithril_certificates)]
168
160
pub async fn list_mithril_certificates ( & self ) -> WasmResult {
169
161
let result = self
170
162
. client
@@ -177,7 +169,6 @@ impl MithrilClient {
177
169
}
178
170
179
171
/// Call the client to verify the certificate chain from a certificate hash
180
- // #[wasm_bindgen(js_name = verify_certificate_chain)]
181
172
pub async fn verify_certificate_chain ( & self , hash : & str ) -> WasmResult {
182
173
let result = self
183
174
. client
@@ -203,7 +194,7 @@ mod tests {
203
194
"5b33322c3235332c3138362c3230312c3137372c31312c3131372c3133352c3138372c3136372c3138312c3138382c32322c35392c3230362c3130352c3233312c3135302c3231352c33302c37382c3231322c37362c31362c3235322c3138302c37322c3133342c3133372c3234372c3136312c36385d" ,
204
195
) . await ;
205
196
206
- let list = wasm_client
197
+ wasm_client
207
198
. list_mithril_stake_distributions ( )
208
199
. await
209
200
. expect ( "should not fail" ) ;
0 commit comments