@@ -36,7 +36,11 @@ use std::fs;
3636use std:: io:: { self , BufReader , Cursor , Read } ;
3737use std:: path:: { Path , PathBuf } ;
3838
39- use ckb_system_scripts:: BUNDLED_CELL ;
39+ use ckb_system_scripts_v0_5_4:: BUNDLED_CELL ;
40+ /// get multisig_legacy from v_0_5_4
41+ use ckb_system_scripts_v0_5_4:: BUNDLED_CELL as BUNDLED_CELL_v0_5_4 ;
42+ /// get multisg_v1 from v0_6_0
43+ use ckb_system_scripts_v0_6_0:: BUNDLED_CELL as BUNDLED_CELL_v0_6_0 ;
4044
4145mod bundled {
4246 #![ allow( missing_docs, clippy:: unreadable_literal) ]
@@ -156,6 +160,20 @@ impl Resource {
156160 matches ! ( self , Resource :: Bundled { .. } )
157161 }
158162
163+ fn remap_bundled < ' a > ( & self , bundled : & ' a str ) -> ( & Files , & ' a str ) {
164+ match bundled {
165+ "specs/cells/secp256k1_blake160_multisig_all_legacy" => (
166+ & BUNDLED_CELL_v0_5_4 ,
167+ "specs/cells/secp256k1_blake160_multisig_all" ,
168+ ) ,
169+ "specs/cells/secp256k1_blake160_multisig_all_v1" => (
170+ & BUNDLED_CELL_v0_6_0 ,
171+ "specs/cells/secp256k1_blake160_multisig_all" ,
172+ ) ,
173+ _ => ( & BUNDLED_CELL , bundled) ,
174+ }
175+ }
176+
159177 /// Returns `true` if the resource exists.
160178 ///
161179 /// The bundled resource exists only when the identifier is included in the bundle.
@@ -164,7 +182,8 @@ impl Resource {
164182 pub fn exists ( & self ) -> bool {
165183 match self {
166184 Resource :: Bundled { bundled } => {
167- SourceFiles :: new ( & BUNDLED_CELL , & BUNDLED ) . is_available ( bundled)
185+ let ( system_cells, bundled) = self . remap_bundled ( bundled) ;
186+ SourceFiles :: new ( & system_cells, & BUNDLED ) . is_available ( bundled)
168187 }
169188 Resource :: FileSystem { file } => file. exists ( ) ,
170189 Resource :: Raw { .. } => true ,
@@ -195,7 +214,10 @@ impl Resource {
195214 /// Gets resource content.
196215 pub fn get ( & self ) -> Result < Cow < ' static , [ u8 ] > > {
197216 match self {
198- Resource :: Bundled { bundled } => SourceFiles :: new ( & BUNDLED_CELL , & BUNDLED ) . get ( bundled) ,
217+ Resource :: Bundled { bundled } => {
218+ let ( system_cells, bundled) = self . remap_bundled ( bundled) ;
219+ SourceFiles :: new ( & system_cells, & BUNDLED ) . get ( bundled)
220+ }
199221 Resource :: FileSystem { file } => Ok ( Cow :: Owned ( fs:: read ( file) ?) ) ,
200222 Resource :: Raw { raw } => Ok ( Cow :: Owned ( raw. to_owned ( ) . into_bytes ( ) ) ) ,
201223 }
@@ -205,7 +227,8 @@ impl Resource {
205227 pub fn read ( & self ) -> Result < Box < dyn Read > > {
206228 match self {
207229 Resource :: Bundled { bundled } => {
208- SourceFiles :: new ( & BUNDLED_CELL , & BUNDLED ) . read ( bundled)
230+ let ( system_cells, bundled) = self . remap_bundled ( bundled) ;
231+ SourceFiles :: new ( & system_cells, & BUNDLED ) . read ( bundled)
209232 }
210233 Resource :: FileSystem { file } => Ok ( Box :: new ( BufReader :: new ( fs:: File :: open ( file) ?) ) ) ,
211234 Resource :: Raw { raw } => Ok ( Box :: new ( Cursor :: new ( raw. to_owned ( ) . into_bytes ( ) ) ) ) ,
0 commit comments