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 {
25
25
pub async fn new ( rpc_url : String ) -> anyhow:: Result < Self > {
26
26
let raw = RpcClient :: from_url ( & rpc_url) . await ?;
27
27
let subxt = sugondat_subxt:: Client :: from_rpc_client ( raw. clone ( ) ) . await ?;
28
+ check_if_compatible ( & subxt) ?;
28
29
Ok ( Self { raw, subxt } )
29
30
}
30
31
@@ -112,6 +113,20 @@ impl Client {
112
113
}
113
114
}
114
115
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
+
115
130
/// Iterates over the extrinsics in a block and extracts the submit_blob extrinsics.
116
131
fn extract_blobs (
117
132
extrinsics : Vec <
You can’t perform that action at this time.
0 commit comments