On using serde_json in my pallet dependency it throws this throws these error:- ``
#[weight=10_000]
pub fn insert_data_class(origin,app_id:Vec<u8>,db_id:Vec<u8>,cid:Vec<u8>,data:Vec<u8>,signature:H512)->DispatchResult{
let caller = ensure_signed(origin)?;
let app_data = alioth_register::Module::<T>::check_ownership(&caller,&app_id);
ensure!(app_data.0,Error::<T>::AppNotFound);
let data_str = String::from_utf8(data.clone()).unwrap();
let data_json = json!(data_str);
let uid:Vec<u8> = data_json["uid"].to_string().as_bytes().to_vec();
//let uuid_str = data_json["uuid"].to_string();
let uuid:Vec<u8> = data_json["uuid"].to_string().as_bytes().to_vec();
let data1 = data.clone();
let data1 = String::from_utf8(data1).unwrap();
let user_data = alioth_users::Module::<T>::check_user_extern(&uuid,&app_id);
ensure!(user_data.0,Error::<T>::UserNotFound);
let class_data = alioth_class::Module::<T>::check_class(&db_id,&cid);
ensure!(class_data.0,Error::<T>::ClassOrDatabaseNotFound);
//I needed a public key for this purpose we are going to write a function in alioth-users
let pub_key_ref:(bool,H256) = alioth_users::Module::<T>::get_public_key(&uuid,&app_id);
ensure!(pub_key_ref.0,Error::<T>::ObjectNotCreated);
//now we are going to verify the signature for the further transaction
ensure!(sp_io::crypto::sr25519_verify(&Signature::from_h512(signature),data1.as_bytes(),&Public::from_h256(pub_key_ref.1)),Error::<T>::SignatureNotVerified);
//its over now we are going ahead to check the uniqness of data and insert it later.
let data_from_self = Self::check_obj_store(&uid,&cid);
ensure!(!data_from_self.0,Error::<T>::DataIsNotUnique);
let struct_data = ObjectData{
duid:uid,
object:data,
};
if data_from_self.1==0{
let vec_data = vec![struct_data];
<ObjectStore>::insert(cid,vec_data);
Self::deposit_event(Event::ObjectCreated());
}
else{
let mut vec_data = <ObjectStore>::get(&cid);
vec_data.insert(vec_data.len(),struct_data);
<ObjectStore>::insert(cid,vec_data);
Self::deposit_event(Event::ObjectCreated());
}
Ok(())
}**this code uses serde_json::json macro**
error: failed to run custom build command for node-template-runtime v3.0.0 (/home/corteri/Desktop/blockchain/new_tmp/substrate-node-template/runtime)
Caused by:
process didn't exit successfully: /home/corteri/Desktop/blockchain/new_tmp/substrate-node-template/target/debug/build/node-template-runtime-e56bc02a2834241f/build-script-build (exit status: 1)
--- stdout
Information that should be included in a bug report.
Executing build command: "rustup" "run" "nightly" "cargo" "-Zfeatures=build_dep" "rustc" "--target=wasm32-unknown-unknown" "--manifest-path=/home/corteri/Desktop/blockchain/new_tmp/substrate-node-template/target/debug/wbuild/node-template-runtime/Cargo.toml" "--color=always" "--release"
Using rustc version: rustc 1.56.0-nightly (b7404c898 2021-09-03)
--- stderr
warning: flag -Z features has been stabilized in the 1.51 release, and is no longer necessary
The new feature resolver is now available by specifying resolver = "2" in Cargo.toml.
See https://doc.rust-lang.org/nightly/cargo/reference/features.html#feature-resolver-version-2 for more information.
Compiling getrandom v0.2.1
error: target is not supported, for more information see: https://docs.rs/getrandom/#unsupported-targets
--> /home/corteri/.cargo/registry/src/github.com-1ecc6299db9ec823/getrandom-0.2.1/src/lib.rs:214:9
|
214 | / compile_error!("target is not supported, for more information see:
215 | | https://docs.rs/getrandom/#unsupported-targets");
| |_________________________________________________________________________^
error[E0433]: failed to resolve: use of undeclared crate or module imp
--> /home/corteri/.cargo/registry/src/github.com-1ecc6299db9ec823/getrandom-0.2.1/src/lib.rs:236:5
|
236 | imp::getrandom_inner(dest)
| ^^^ use of undeclared crate or module imp
For more information about this error, try rustc --explain E0433.
error: could not compile getrandom due to 2 previous errors