@@ -39,22 +39,29 @@ pub struct OfflineQuery {
39
39
#[ wasm_bindgen]
40
40
impl OfflineQuery {
41
41
/// Creates a new offline query object. The state root is required to be passed in as a string
42
+ ///
43
+ /// @param {u32} block_height The block height.
44
+ /// @param {string} state_root The state root of the current network.
45
+ ///
46
+ /// @returns {OfflineQuery} The newly created offline query object.
42
47
#[ wasm_bindgen( constructor) ]
43
48
pub fn new ( block_height : u32 , state_root : & str ) -> Result < OfflineQuery , String > {
44
49
let state_root = <CurrentNetwork as Network >:: StateRoot :: from_str ( state_root) . map_err ( |e| e. to_string ( ) ) ?;
45
50
Ok ( Self { block_height, state_paths : IndexMap :: new ( ) , state_root } )
46
51
}
47
52
48
53
/// Add a new block height to the offline query object.
54
+ ///
55
+ /// @param {u32} block_height The block height to add.
49
56
#[ wasm_bindgen( js_name = "addBlockHeight" ) ]
50
57
pub fn add_block_height ( & mut self , block_height : u32 ) {
51
58
self . block_height = block_height;
52
59
}
53
60
54
61
/// Add a new state path to the offline query object.
55
62
///
56
- /// @param {string} commitment: The commitment corresponding to a record inpout
57
- /// @param {string} state_path: The state path corresponding to the commitment
63
+ /// @param {string} commitment: The commitment corresponding to a record input.
64
+ /// @param {string} state_path: The state path corresponding to the commitment.
58
65
#[ wasm_bindgen( js_name = "addStatePath" ) ]
59
66
pub fn add_state_path ( & mut self , commitment : & str , state_path : & str ) -> Result < ( ) , String > {
60
67
let commitment = Field :: from_str ( commitment) . map_err ( |e| e. to_string ( ) ) ?;
@@ -63,18 +70,18 @@ impl OfflineQuery {
63
70
Ok ( ( ) )
64
71
}
65
72
66
- /// Get a json string representation of the offline query object
73
+ /// Get a json string representation of the offline query object.
67
74
///
68
- /// @returns {string} JSON string representation of the offline query object
75
+ /// @returns {string} JSON string representation of the offline query object.
69
76
#[ wasm_bindgen( js_name = "toString" ) ]
70
77
#[ allow( clippy:: inherent_to_string) ]
71
78
pub fn to_string ( & self ) -> String {
72
79
serde_json:: to_string ( & self ) . unwrap ( )
73
80
}
74
81
75
- /// Create an offline query object from a json string representation
82
+ /// Create an offline query object from a json string representation.
76
83
///
77
- /// @param {string} s JSON string representation of the offline query object
84
+ /// @param {string} JSON string representation of the offline query object.
78
85
#[ wasm_bindgen( js_name = "fromString" ) ]
79
86
pub fn from_string ( s : & str ) -> Result < OfflineQuery , String > {
80
87
serde_json:: from_str ( s) . map_err ( |e| e. to_string ( ) )
0 commit comments