File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -82,6 +82,18 @@ impl WrapDescriptor {
8282 Ok ( self . explicit_script ( ) ?. to_asm_string ( ) )
8383 }
8484
85+ #[ wasm_bindgen( js_name = maxWeightToSatisfy) ]
86+ pub fn max_weight_to_satisfy ( & self ) -> Result < u32 , JsError > {
87+ let weight = ( match & self . 0 {
88+ WrapDescriptorEnum :: Derivable ( desc, _) => {
89+ desc. max_weight_to_satisfy ( )
90+ }
91+ WrapDescriptorEnum :: Definite ( desc) => desc. max_weight_to_satisfy ( ) ,
92+ WrapDescriptorEnum :: String ( desc) => desc. max_weight_to_satisfy ( ) ,
93+ } ) ?;
94+ weight. to_wu ( ) . try_into ( ) . map_err ( |_| JsError :: new ( "Weight exceeds u32" ) )
95+ }
96+
8597 #[ wasm_bindgen( js_name = fromString, skip_typescript) ]
8698 pub fn from_string ( descriptor : & str , pk_type : & str ) -> Result < WrapDescriptor , JsError > {
8799 match pk_type {
Original file line number Diff line number Diff line change @@ -58,6 +58,8 @@ describe("Descriptor fixtures", function () {
5858 fixture . script ,
5959 ) ;
6060 }
61+
62+ assert . ok ( Number . isInteger ( descriptor . maxWeightToSatisfy ( ) ) ) ;
6163 } ) ;
6264 } ) ;
6365} ) ;
You can’t perform that action at this time.
0 commit comments