File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ impl Client {
2525 pub async fn new ( rpc_url : String ) -> anyhow:: Result < Self > {
2626 let raw = RpcClient :: from_url ( & rpc_url) . await ?;
2727 let subxt = sugondat_subxt:: Client :: from_rpc_client ( raw. clone ( ) ) . await ?;
28+ check_if_compatible ( & subxt) ?;
2829 Ok ( Self { raw, subxt } )
2930 }
3031
@@ -112,6 +113,20 @@ impl Client {
112113 }
113114}
114115
116+ /// Tries to find the `Blob` pallet in the runtime metadata. If it's not there, then we are not
117+ /// connected to a Sugondat node.
118+ fn check_if_compatible ( client : & sugondat_subxt:: Client ) -> anyhow:: Result < ( ) > {
119+ assert ! ( sugondat_subxt:: sugondat:: PALLETS . contains( & "Blob" ) ) ;
120+ if let Some ( pallet) = client. metadata ( ) . pallet_by_name ( "Blob" ) {
121+ if pallet. call_variant_by_name ( "submit_blob" ) . is_some ( ) {
122+ return Ok ( ( ) ) ;
123+ }
124+ }
125+ Err ( anyhow:: anyhow!(
126+ "connected to a Substrate node that is not Sugondat"
127+ ) )
128+ }
129+
115130/// Iterates over the extrinsics in a block and extracts the submit_blob extrinsics.
116131fn extract_blobs (
117132 extrinsics : Vec <
You can’t perform that action at this time.
0 commit comments