From 237a8c6fa8fb48465946a6cf1a248a1a59283166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marin=20Ver=C5=A1i=C4=87?= Date: Fri, 18 Oct 2024 10:32:11 +0200 Subject: [PATCH] refactor: rename JsonValue to Json (#5154) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marin Veršić --- crates/iroha/tests/integration/permissions.rs | 8 +-- .../integration/queries/smart_contract.rs | 2 +- crates/iroha/tests/integration/roles.rs | 14 ++--- .../tests/integration/transfer_domain.rs | 10 ++-- .../integration/triggers/time_trigger.rs | 4 +- crates/iroha_cli/src/main.rs | 14 ++--- crates/iroha_codec/src/main.rs | 2 +- crates/iroha_core/src/query/store.rs | 4 +- .../src/smartcontracts/isi/account.rs | 4 +- .../src/smartcontracts/isi/asset.rs | 4 +- .../src/smartcontracts/isi/domain.rs | 6 +- .../src/smartcontracts/isi/query.rs | 38 ++++++------- .../src/smartcontracts/isi/triggers/mod.rs | 4 +- .../src/smartcontracts/isi/world.rs | 4 +- .../src/events/data/events.rs | 6 +- .../src/events/execute_trigger.rs | 4 +- crates/iroha_data_model/src/executor.rs | 6 +- crates/iroha_data_model/src/isi.rs | 24 ++++---- crates/iroha_data_model/src/metadata.rs | 12 ++-- crates/iroha_data_model/src/parameter.rs | 8 +-- crates/iroha_data_model/src/permission.rs | 8 +-- crates/iroha_data_model/src/query/mod.rs | 14 ++--- crates/iroha_kagami/src/genesis/generate.rs | 2 +- crates/iroha_primitives/src/json.rs | 56 +++++++++---------- crates/iroha_schema_gen/src/lib.rs | 6 +- crates/iroha_torii/src/routing.rs | 12 ++-- docs/source/references/schema.json | 42 +++++++------- .../src/complex_isi.rs | 6 +- .../src/mint_rose_args.rs | 10 ++-- .../src/multisig.rs | 16 +++--- .../src/simple_isi.rs | 6 +- wasm_samples/multisig/src/lib.rs | 6 +- wasm_samples/multisig_register/src/lib.rs | 2 +- .../query_assets_and_save_cursor/src/lib.rs | 2 +- 34 files changed, 180 insertions(+), 186 deletions(-) diff --git a/crates/iroha/tests/integration/permissions.rs b/crates/iroha/tests/integration/permissions.rs index 49149c393e..0302a52059 100644 --- a/crates/iroha/tests/integration/permissions.rs +++ b/crates/iroha/tests/integration/permissions.rs @@ -261,7 +261,7 @@ fn permissions_differ_not_only_by_names() { .submit_blocking(SetKeyValue::asset( mouse_hat_id, "color".parse().expect("Valid"), - "red".parse::().expect("Valid"), + "red".parse::().expect("Valid"), )) .expect("Failed to modify Mouse's hats"); @@ -270,7 +270,7 @@ fn permissions_differ_not_only_by_names() { let set_shoes_color = SetKeyValue::asset( mouse_shoes_id.clone(), "color".parse().expect("Valid"), - "yellow".parse::().expect("Valid"), + "yellow".parse::().expect("Valid"), ); let _err = client .submit_blocking(set_shoes_color.clone()) @@ -318,7 +318,7 @@ fn stored_vs_granted_permission_payload() -> Result<()> { .expect("Failed to register mouse"); // Allow alice to mint mouse asset and mint initial value - let value_json = JsonValue::from_string_unchecked(format!( + let value_json = Json::from_string_unchecked(format!( // NOTE: Permissions is created explicitly as a json string to introduce additional whitespace // This way, if the executor compares permissions just as JSON strings, the test will fail r##"{{ "asset" : "xor#wonderland#{mouse_id}" }}"## @@ -341,7 +341,7 @@ fn stored_vs_granted_permission_payload() -> Result<()> { let set_key_value = SetKeyValue::asset( mouse_asset, "color".parse()?, - "red".parse::().expect("Valid"), + "red".parse::().expect("Valid"), ); iroha .submit_blocking(set_key_value) diff --git a/crates/iroha/tests/integration/queries/smart_contract.rs b/crates/iroha/tests/integration/queries/smart_contract.rs index 3c1a605c3e..ab2742bd8a 100644 --- a/crates/iroha/tests/integration/queries/smart_contract.rs +++ b/crates/iroha/tests/integration/queries/smart_contract.rs @@ -17,7 +17,7 @@ fn live_query_is_dropped_after_smart_contract_end() -> Result<()> { ); client.submit_transaction_blocking(&transaction)?; - let metadata_value: JsonValue = client.query_single(FindAccountMetadata::new( + let metadata_value: Json = client.query_single(FindAccountMetadata::new( client.account.clone(), "cursor".parse().unwrap(), ))?; diff --git a/crates/iroha/tests/integration/roles.rs b/crates/iroha/tests/integration/roles.rs index ec0bb59f4e..57938464e2 100644 --- a/crates/iroha/tests/integration/roles.rs +++ b/crates/iroha/tests/integration/roles.rs @@ -62,11 +62,8 @@ fn register_and_grant_role_for_metadata_access() -> Result<()> { test_client.submit_transaction_blocking(&grant_role_tx)?; // Alice modifies Mouse's metadata - let set_key_value = SetKeyValue::account( - mouse_id, - "key".parse::()?, - "value".parse::()?, - ); + let set_key_value = + SetKeyValue::account(mouse_id, "key".parse::()?, "value".parse::()?); test_client.submit_blocking(set_key_value)?; // Making request to find Alice's roles @@ -219,11 +216,8 @@ fn grant_revoke_role_permissions() -> Result<()> { .sign(mouse_keypair.private_key()); test_client.submit_transaction_blocking(&grant_role_tx)?; - let set_key_value = SetKeyValue::account( - mouse_id.clone(), - "key".parse()?, - "value".parse::()?, - ); + let set_key_value = + SetKeyValue::account(mouse_id.clone(), "key".parse()?, "value".parse::()?); let can_set_key_value_in_mouse = CanModifyAccountMetadata { account: mouse_id.clone(), }; diff --git a/crates/iroha/tests/integration/transfer_domain.rs b/crates/iroha/tests/integration/transfer_domain.rs index c4c3d0d345..6a8c5276fd 100644 --- a/crates/iroha/tests/integration/transfer_domain.rs +++ b/crates/iroha/tests/integration/transfer_domain.rs @@ -13,7 +13,7 @@ use iroha_executor_data_model::permission::{ trigger::CanUnregisterTrigger, }; use iroha_genesis::GenesisBlock; -use iroha_primitives::json::JsonValue; +use iroha_primitives::json::Json; use iroha_test_network::{Peer as TestPeer, *}; use iroha_test_samples::{gen_account_in, ALICE_ID, BOB_ID, SAMPLE_GENESIS_ACCOUNT_ID}; use tokio::runtime::Runtime; @@ -74,7 +74,7 @@ fn domain_owner_domain_permissions() -> Result<()> { // check that "alice@wonderland" as owner of domain can edit metadata in her domain let key: Name = "key".parse()?; - let value = JsonValue::new("value"); + let value = Json::new("value"); test_client.submit_blocking(SetKeyValue::domain(kingdom_id.clone(), key.clone(), value))?; test_client.submit_blocking(RemoveKeyValue::domain(kingdom_id.clone(), key))?; @@ -111,7 +111,7 @@ fn domain_owner_account_permissions() -> Result<()> { // check that "alice@wonderland" as owner of domain can edit metadata of account in her domain let key: Name = "key".parse()?; - let value = JsonValue::new("value"); + let value = Json::new("value"); test_client.submit_blocking(SetKeyValue::account( mad_hatter_id.clone(), key.clone(), @@ -177,7 +177,7 @@ fn domain_owner_asset_definition_permissions() -> Result<()> { // check that "alice@wonderland" as owner of domain can edit metadata of asset definition in her domain let key: Name = "key".parse()?; - let value = JsonValue::new("value"); + let value = Json::new("value"); test_client.submit_blocking(SetKeyValue::asset_definition( coin_id.clone(), key.clone(), @@ -249,7 +249,7 @@ fn domain_owner_asset_permissions() -> Result<()> { // check that "alice@wonderland" as owner of domain can edit metadata of store asset in her domain let key: Name = "key".parse()?; - let value = JsonValue::new("value"); + let value = Json::new("value"); let bob_store_id = AssetId::new(store_id, bob_id.clone()); test_client.submit_blocking(SetKeyValue::asset(bob_store_id.clone(), key.clone(), value))?; test_client.submit_blocking(RemoveKeyValue::asset(bob_store_id.clone(), key))?; diff --git a/crates/iroha/tests/integration/triggers/time_trigger.rs b/crates/iroha/tests/integration/triggers/time_trigger.rs index 99b01902d8..94d5a79d66 100644 --- a/crates/iroha/tests/integration/triggers/time_trigger.rs +++ b/crates/iroha/tests/integration/triggers/time_trigger.rs @@ -121,7 +121,7 @@ fn pre_commit_trigger_should_be_executed() -> Result<()> { let sample_isi = SetKeyValue::account( account_id.clone(), "key".parse::()?, - "value".parse::()?, + "value".parse::()?, ); test_client.submit(sample_isi)?; } @@ -251,7 +251,7 @@ fn submit_sample_isi_on_every_block_commit( let sample_isi = SetKeyValue::account( account_id.clone(), "key".parse::()?, - JsonValue::new("value"), + Json::new("value"), ); test_client.submit(sample_isi)?; } diff --git a/crates/iroha_cli/src/main.rs b/crates/iroha_cli/src/main.rs index e022718fd3..6afb8ee703 100644 --- a/crates/iroha_cli/src/main.rs +++ b/crates/iroha_cli/src/main.rs @@ -11,7 +11,7 @@ use erased_serde::Serialize; use error_stack::{fmt::ColorMode, IntoReportCompat, ResultExt}; use eyre::{eyre, Error, Result, WrapErr}; use iroha::{client::Client, config::Config, data_model::prelude::*}; -use iroha_primitives::{addr::SocketAddr, json::JsonValue}; +use iroha_primitives::{addr::SocketAddr, json::Json}; use thiserror::Error; /// Re-usable clap `--metadata ` (`-m`) argument. @@ -58,7 +58,7 @@ pub struct MetadataValueArg { /// Booleans: false/true /// Objects: e.g. {"Vec":[{"String":"a"},{"String":"b"}]} #[arg(short, long)] - value: JsonValue, + value: Json, } impl FromStr for MetadataValueArg { @@ -66,7 +66,7 @@ impl FromStr for MetadataValueArg { fn from_str(s: &str) -> Result { Ok(MetadataValueArg { - value: JsonValue::from_str(s)?, + value: Json::from_str(s)?, }) } } @@ -1212,12 +1212,12 @@ mod tests { } // Boolean values - case!("true", JsonValue::new(true)); - case!("false", JsonValue::new(false)); + case!("true", Json::new(true)); + case!("false", Json::new(false)); // Numeric values - case!("\"123\"", JsonValue::new(numeric!(123))); - case!("\"123.0\"", JsonValue::new(numeric!(123.0))); + case!("\"123\"", Json::new(numeric!(123))); + case!("\"123.0\"", Json::new(numeric!(123.0))); // JSON Value let json_str = r#"{"Vec":[{"String":"a"},{"String":"b"}]}"#; diff --git a/crates/iroha_codec/src/main.rs b/crates/iroha_codec/src/main.rs index 9f37a8a496..a6d902131d 100644 --- a/crates/iroha_codec/src/main.rs +++ b/crates/iroha_codec/src/main.rs @@ -313,7 +313,7 @@ mod tests { let mut metadata = Metadata::default(); metadata.insert( "hat".parse().expect("Valid"), - "white".parse::().expect("Valid"), + "white".parse::().expect("Valid"), ); let account = Account::new(ALICE_ID.clone()).with_metadata(metadata); diff --git a/crates/iroha_core/src/query/store.rs b/crates/iroha_core/src/query/store.rs index aa021857f7..3db0c98e47 100644 --- a/crates/iroha_core/src/query/store.rs +++ b/crates/iroha_core/src/query/store.rs @@ -329,7 +329,7 @@ mod tests { permission::Permission, query::parameters::{FetchSize, Pagination, QueryParams, Sorting}, }; - use iroha_primitives::json::JsonValue; + use iroha_primitives::json::Json; use iroha_test_samples::ALICE_ID; use nonzero_ext::nonzero; @@ -355,7 +355,7 @@ mod tests { // it's not important which type we use here, just to test the flow let query_output = - (0..100).map(|_| Permission::new(String::default(), JsonValue::from(false))); + (0..100).map(|_| Permission::new(String::default(), Json::from(false))); let query_output = crate::smartcontracts::query::apply_query_postprocessing( query_output, &query_params, diff --git a/crates/iroha_core/src/smartcontracts/isi/account.rs b/crates/iroha_core/src/smartcontracts/isi/account.rs index 056609cdf6..914b1311b1 100644 --- a/crates/iroha_core/src/smartcontracts/isi/account.rs +++ b/crates/iroha_core/src/smartcontracts/isi/account.rs @@ -453,7 +453,7 @@ pub mod query { }, }, }; - use iroha_primitives::json::JsonValue; + use iroha_primitives::json::Json; use super::*; use crate::{smartcontracts::ValidQuery, state::StateReadOnly}; @@ -508,7 +508,7 @@ pub mod query { impl ValidSingularQuery for FindAccountMetadata { #[metrics(+"find_account_key_value_by_id_and_key")] - fn execute(&self, state_ro: &impl StateReadOnly) -> Result { + fn execute(&self, state_ro: &impl StateReadOnly) -> Result { let id = &self.id; let key = &self.key; iroha_logger::trace!(%id, %key); diff --git a/crates/iroha_core/src/smartcontracts/isi/asset.rs b/crates/iroha_core/src/smartcontracts/isi/asset.rs index b864e851bc..9db957022c 100644 --- a/crates/iroha_core/src/smartcontracts/isi/asset.rs +++ b/crates/iroha_core/src/smartcontracts/isi/asset.rs @@ -433,7 +433,7 @@ pub mod query { }, }, }; - use iroha_primitives::json::JsonValue; + use iroha_primitives::json::Json; use super::*; use crate::{smartcontracts::ValidQuery, state::StateReadOnly}; @@ -495,7 +495,7 @@ pub mod query { impl ValidSingularQuery for FindAssetMetadata { #[metrics(+"find_asset_key_value_by_id_and_key")] - fn execute(&self, state_ro: &impl StateReadOnly) -> Result { + fn execute(&self, state_ro: &impl StateReadOnly) -> Result { let id = &self.id; let key = &self.key; let asset = state_ro.world().asset(id).map_err(|asset_err| { diff --git a/crates/iroha_core/src/smartcontracts/isi/domain.rs b/crates/iroha_core/src/smartcontracts/isi/domain.rs index 46ae246c3a..7131c4ec2f 100644 --- a/crates/iroha_core/src/smartcontracts/isi/domain.rs +++ b/crates/iroha_core/src/smartcontracts/isi/domain.rs @@ -388,7 +388,7 @@ pub mod query { predicate::{predicate_atoms::domain::DomainPredicateBox, CompoundPredicate}, }, }; - use iroha_primitives::json::JsonValue; + use iroha_primitives::json::Json; use super::*; use crate::{smartcontracts::ValidQuery, state::StateReadOnly}; @@ -410,7 +410,7 @@ pub mod query { impl ValidSingularQuery for FindDomainMetadata { #[metrics(+"find_domain_key_value_by_id_and_key")] - fn execute(&self, state_ro: &impl StateReadOnly) -> Result { + fn execute(&self, state_ro: &impl StateReadOnly) -> Result { let id = &self.id; let key = &self.key; iroha_logger::trace!(%id, %key); @@ -424,7 +424,7 @@ pub mod query { impl ValidSingularQuery for FindAssetDefinitionMetadata { #[metrics(+"find_asset_definition_key_value_by_id_and_key")] - fn execute(&self, state_ro: &impl StateReadOnly) -> Result { + fn execute(&self, state_ro: &impl StateReadOnly) -> Result { let id = &self.id; let key = &self.key; iroha_logger::trace!(%id, %key); diff --git a/crates/iroha_core/src/smartcontracts/isi/query.rs b/crates/iroha_core/src/smartcontracts/isi/query.rs index 60a6cc101e..4fbaa74c1a 100644 --- a/crates/iroha_core/src/smartcontracts/isi/query.rs +++ b/crates/iroha_core/src/smartcontracts/isi/query.rs @@ -26,29 +26,29 @@ pub trait SortableQueryOutput { /// Get the sorting key for the output, from metadata /// /// If the type doesn't have metadata or metadata key doesn't exist - return None - fn get_metadata_sorting_key(&self, key: &Name) -> Option; + fn get_metadata_sorting_key(&self, key: &Name) -> Option; } impl SortableQueryOutput for Account { - fn get_metadata_sorting_key(&self, key: &Name) -> Option { + fn get_metadata_sorting_key(&self, key: &Name) -> Option { self.metadata.get(key).cloned() } } impl SortableQueryOutput for Domain { - fn get_metadata_sorting_key(&self, key: &Name) -> Option { + fn get_metadata_sorting_key(&self, key: &Name) -> Option { self.metadata.get(key).cloned() } } impl SortableQueryOutput for AssetDefinition { - fn get_metadata_sorting_key(&self, key: &Name) -> Option { + fn get_metadata_sorting_key(&self, key: &Name) -> Option { self.metadata.get(key).cloned() } } impl SortableQueryOutput for Asset { - fn get_metadata_sorting_key(&self, key: &Name) -> Option { + fn get_metadata_sorting_key(&self, key: &Name) -> Option { match &self.value { AssetValue::Numeric(_) => None, AssetValue::Store(metadata) => metadata.get(key).cloned(), @@ -57,55 +57,55 @@ impl SortableQueryOutput for Asset { } impl SortableQueryOutput for Role { - fn get_metadata_sorting_key(&self, _key: &Name) -> Option { + fn get_metadata_sorting_key(&self, _key: &Name) -> Option { None } } impl SortableQueryOutput for RoleId { - fn get_metadata_sorting_key(&self, _key: &Name) -> Option { + fn get_metadata_sorting_key(&self, _key: &Name) -> Option { None } } impl SortableQueryOutput for TransactionQueryOutput { - fn get_metadata_sorting_key(&self, _key: &Name) -> Option { + fn get_metadata_sorting_key(&self, _key: &Name) -> Option { None } } impl SortableQueryOutput for Peer { - fn get_metadata_sorting_key(&self, _key: &Name) -> Option { + fn get_metadata_sorting_key(&self, _key: &Name) -> Option { None } } impl SortableQueryOutput for Permission { - fn get_metadata_sorting_key(&self, _key: &Name) -> Option { + fn get_metadata_sorting_key(&self, _key: &Name) -> Option { None } } impl SortableQueryOutput for Trigger { - fn get_metadata_sorting_key(&self, _key: &Name) -> Option { + fn get_metadata_sorting_key(&self, _key: &Name) -> Option { None } } impl SortableQueryOutput for TriggerId { - fn get_metadata_sorting_key(&self, _key: &Name) -> Option { + fn get_metadata_sorting_key(&self, _key: &Name) -> Option { None } } impl SortableQueryOutput for iroha_data_model::block::SignedBlock { - fn get_metadata_sorting_key(&self, _key: &Name) -> Option { + fn get_metadata_sorting_key(&self, _key: &Name) -> Option { None } } impl SortableQueryOutput for iroha_data_model::block::BlockHeader { - fn get_metadata_sorting_key(&self, _key: &Name) -> Option { + fn get_metadata_sorting_key(&self, _key: &Name) -> Option { None } } @@ -138,7 +138,7 @@ where // sort & paginate, erase the iterator with QueryBatchedErasedIterator let output = if let Some(key) = &sorting.sort_by_metadata_key { // if sorting was requested, we need to retrieve all the results first - let mut pairs: Vec<(Option, I::Item)> = iter + let mut pairs: Vec<(Option, I::Item)> = iter .map(|value| { let key = value.get_metadata_sorting_key(key); (key, value) @@ -340,7 +340,7 @@ impl ValidQueryRequest { mod tests { use iroha_crypto::{Hash, KeyPair}; use iroha_data_model::query::predicate::CompoundPredicate; - use iroha_primitives::json::JsonValue; + use iroha_primitives::json::Json; use iroha_test_samples::{gen_account_in, ALICE_ID, ALICE_KEYPAIR}; use nonzero_ext::nonzero; use tokio::test; @@ -475,7 +475,7 @@ mod tests { let asset_definition_id = "rose#wonderland".parse()?; let asset_id = AssetId::new(asset_definition_id, ALICE_ID.clone()); let bytes = FindAssetMetadata::new(asset_id, "Bytes".parse()?).execute(&state.view())?; - assert_eq!(JsonValue::from(vec![1_u32, 2_u32, 3_u32,]), bytes,); + assert_eq!(Json::from(vec![1_u32, 2_u32, 3_u32,]), bytes,); Ok(()) } @@ -487,7 +487,7 @@ mod tests { let bytes = FindAccountMetadata::new(ALICE_ID.clone(), "Bytes".parse()?).execute(&state.view())?; - assert_eq!(JsonValue::from(vec![1_u32, 2_u32, 3_u32,]), bytes,); + assert_eq!(Json::from(vec![1_u32, 2_u32, 3_u32,]), bytes,); Ok(()) } @@ -684,7 +684,7 @@ mod tests { let domain_id = "wonderland".parse()?; let key = "Bytes".parse()?; let bytes = FindDomainMetadata::new(domain_id, key).execute(&state.view())?; - assert_eq!(JsonValue::from(vec![1_u32, 2_u32, 3_u32,]), bytes,); + assert_eq!(Json::from(vec![1_u32, 2_u32, 3_u32,]), bytes,); Ok(()) } } diff --git a/crates/iroha_core/src/smartcontracts/isi/triggers/mod.rs b/crates/iroha_core/src/smartcontracts/isi/triggers/mod.rs index 14bdb339ac..cf18bf0e0c 100644 --- a/crates/iroha_core/src/smartcontracts/isi/triggers/mod.rs +++ b/crates/iroha_core/src/smartcontracts/isi/triggers/mod.rs @@ -329,7 +329,7 @@ pub mod query { }, trigger::{Trigger, TriggerId}, }; - use iroha_primitives::json::JsonValue; + use iroha_primitives::json::Json; use super::*; use crate::{ @@ -380,7 +380,7 @@ pub mod query { impl ValidSingularQuery for FindTriggerMetadata { #[metrics(+"find_trigger_key_value_by_id_and_key")] - fn execute(&self, state_ro: &impl StateReadOnly) -> Result { + fn execute(&self, state_ro: &impl StateReadOnly) -> Result { let id = &self.id; let key = &self.key; iroha_logger::trace!(%id, %key); diff --git a/crates/iroha_core/src/smartcontracts/isi/world.rs b/crates/iroha_core/src/smartcontracts/isi/world.rs index e3e4304208..8993e7e7de 100644 --- a/crates/iroha_core/src/smartcontracts/isi/world.rs +++ b/crates/iroha_core/src/smartcontracts/isi/world.rs @@ -25,7 +25,7 @@ pub mod isi { query::error::FindError, Level, }; - use iroha_primitives::{json::JsonValue, unique_vec::PushResult}; + use iroha_primitives::{json::Json, unique_vec::PushResult}; use super::*; @@ -356,7 +356,7 @@ pub mod isi { CustomParameter { id: next.id.clone(), - payload: JsonValue::default(), + payload: Json::default(), } }); diff --git a/crates/iroha_data_model/src/events/data/events.rs b/crates/iroha_data_model/src/events/data/events.rs index 823eae8893..7f94a75da3 100644 --- a/crates/iroha_data_model/src/events/data/events.rs +++ b/crates/iroha_data_model/src/events/data/events.rs @@ -3,7 +3,7 @@ use getset::Getters; use iroha_data_model_derive::{model, EventSet, HasOrigin}; -use iroha_primitives::{json::JsonValue, numeric::Numeric}; +use iroha_primitives::{json::Json, numeric::Numeric}; pub use self::model::*; use super::*; @@ -60,7 +60,7 @@ mod model { pub struct MetadataChanged { pub target: Id, pub key: Name, - pub value: JsonValue, + pub value: Json, } /// Event @@ -653,7 +653,7 @@ impl MetadataChanged { } /// Getter for `value` - pub fn value(&self) -> &JsonValue { + pub fn value(&self) -> &Json { &self.value } } diff --git a/crates/iroha_data_model/src/events/execute_trigger.rs b/crates/iroha_data_model/src/events/execute_trigger.rs index ef170fbc4b..22cffb2d1c 100644 --- a/crates/iroha_data_model/src/events/execute_trigger.rs +++ b/crates/iroha_data_model/src/events/execute_trigger.rs @@ -35,7 +35,7 @@ mod model { pub authority: AccountId, /// Args to pass for trigger execution #[getset(skip)] - pub args: JsonValue, + pub args: Json, } /// Filter for trigger execution [`Event`] @@ -64,7 +64,7 @@ mod model { impl ExecuteTriggerEvent { /// Args to pass for trigger execution - pub fn args(&self) -> &JsonValue { + pub fn args(&self) -> &Json { &self.args } } diff --git a/crates/iroha_data_model/src/executor.rs b/crates/iroha_data_model/src/executor.rs index 071f3531bd..8ce04e334d 100644 --- a/crates/iroha_data_model/src/executor.rs +++ b/crates/iroha_data_model/src/executor.rs @@ -6,7 +6,7 @@ use alloc::{collections::BTreeSet, format, string::String, vec::Vec}; use std::collections::BTreeSet; use iroha_data_model_derive::model; -use iroha_primitives::json::JsonValue; +use iroha_primitives::json::Json; use iroha_schema::{Ident, IntoSchema}; pub use self::model::*; @@ -89,7 +89,7 @@ mod model { /// Ids of permission tokens supported by the executor. pub permissions: BTreeSet, /// Schema of executor defined data types (instructions, parameters, permissions) - pub schema: JsonValue, + pub schema: Json, } // TODO: Client doesn't need structures defined inside this macro. When dynamic linking is @@ -105,7 +105,7 @@ impl ExecutorDataModel { } /// Getter - pub fn schema(&self) -> &JsonValue { + pub fn schema(&self) -> &Json { &self.schema } } diff --git a/crates/iroha_data_model/src/isi.rs b/crates/iroha_data_model/src/isi.rs index 1b9ea4b6a1..4bf8ec295a 100644 --- a/crates/iroha_data_model/src/isi.rs +++ b/crates/iroha_data_model/src/isi.rs @@ -189,7 +189,7 @@ impl BuiltInInstruction for InstructionBox { } mod transparent { - use iroha_primitives::json::JsonValue; + use iroha_primitives::json::Json; use super::*; use crate::{account::NewAccount, domain::NewDomain, metadata::Metadata}; @@ -270,13 +270,13 @@ mod transparent { /// Key. pub key: Name, /// Value. - pub value: JsonValue, + pub value: Json, } } impl SetKeyValue { /// Constructs a new [`SetKeyValue`] for a [`Domain`] with the given `key` and `value`. - pub fn domain(domain_id: DomainId, key: Name, value: impl Into) -> Self { + pub fn domain(domain_id: DomainId, key: Name, value: impl Into) -> Self { Self { object: domain_id, key, @@ -287,7 +287,7 @@ mod transparent { impl SetKeyValue { /// Constructs a new [`SetKeyValue`] for an [`Account`] with the given `key` and `value`. - pub fn account(account_id: AccountId, key: Name, value: impl Into) -> Self { + pub fn account(account_id: AccountId, key: Name, value: impl Into) -> Self { Self { object: account_id, key, @@ -301,7 +301,7 @@ mod transparent { pub fn asset_definition( asset_definition_id: AssetDefinitionId, key: Name, - value: impl Into, + value: impl Into, ) -> Self { Self { object: asset_definition_id, @@ -313,7 +313,7 @@ mod transparent { impl SetKeyValue { /// Constructs a new [`SetKeyValue`] for an [`Asset`] with the given `key` and `value`. - pub fn asset(asset_id: AssetId, key: Name, value: impl Into) -> Self { + pub fn asset(asset_id: AssetId, key: Name, value: impl Into) -> Self { Self { object: asset_id, key, @@ -324,7 +324,7 @@ mod transparent { impl SetKeyValue { /// Constructs a new [`SetKeyValue`] for a [`Trigger`] with the given `key` and `value`. - pub fn trigger(trigger_id: TriggerId, key: Name, value: impl Into) -> Self { + pub fn trigger(trigger_id: TriggerId, key: Name, value: impl Into) -> Self { Self { object: trigger_id, key, @@ -919,7 +919,7 @@ mod transparent { /// Id of a trigger to execute pub trigger: TriggerId, /// Arguments to trigger execution - pub args: JsonValue, + pub args: Json, } } @@ -928,14 +928,14 @@ mod transparent { pub fn new(trigger: TriggerId) -> Self { Self { trigger, - args: JsonValue::default(), + args: Json::default(), } } /// Add trigger execution args #[must_use] pub fn with_args(mut self, args: &T) -> Self { - self.args = JsonValue::new(args); + self.args = Json::new(args); self } } @@ -981,13 +981,13 @@ mod transparent { #[display(fmt = "CUSTOM({payload})")] pub struct CustomInstruction { /// Custom payload - pub payload: JsonValue, + pub payload: Json, } } impl CustomInstruction { /// Constructor - pub fn new(payload: impl Into) -> Self { + pub fn new(payload: impl Into) -> Self { Self { payload: payload.into(), } diff --git a/crates/iroha_data_model/src/metadata.rs b/crates/iroha_data_model/src/metadata.rs index 186173f118..cfc708170c 100644 --- a/crates/iroha_data_model/src/metadata.rs +++ b/crates/iroha_data_model/src/metadata.rs @@ -7,7 +7,7 @@ use core::borrow::Borrow; use std::collections::BTreeMap; use iroha_data_model_derive::model; -use iroha_primitives::json::JsonValue; +use iroha_primitives::json::Json; pub use self::model::*; use crate::prelude::Name; @@ -46,7 +46,7 @@ mod model { #[serde(transparent)] #[display(fmt = "Metadata")] #[allow(clippy::multiple_inherent_impl)] - pub struct Metadata(pub(super) BTreeMap); + pub struct Metadata(pub(super) BTreeMap); } impl Metadata { @@ -56,13 +56,13 @@ impl Metadata { } /// Iterate over key/value pairs stored in the internal map. - pub fn iter(&self) -> impl ExactSizeIterator { + pub fn iter(&self) -> impl ExactSizeIterator { self.0.iter() } /// Get the `Some(&Value)` associated to `key`. Return `None` if not found. #[inline] - pub fn get(&self, key: &K) -> Option<&JsonValue> + pub fn get(&self, key: &K) -> Option<&Json> where Name: Borrow, { @@ -71,7 +71,7 @@ impl Metadata { /// Insert [`Value`] under the given key. Returns `Some(value)` /// if the value was already present, `None` otherwise. - pub fn insert(&mut self, key: Name, value: impl Into) -> Option { + pub fn insert(&mut self, key: Name, value: impl Into) -> Option { self.0.insert(key, value.into()) } } @@ -82,7 +82,7 @@ impl Metadata { /// `Some(value)` at the key if the key was previously in the /// map, else `None`. #[inline] - pub fn remove(&mut self, key: &K) -> Option + pub fn remove(&mut self, key: &K) -> Option where Name: Borrow, { diff --git a/crates/iroha_data_model/src/parameter.rs b/crates/iroha_data_model/src/parameter.rs index 302fc3ea42..ff04c6a520 100644 --- a/crates/iroha_data_model/src/parameter.rs +++ b/crates/iroha_data_model/src/parameter.rs @@ -6,7 +6,7 @@ use core::{num::NonZeroU64, time::Duration}; use std::collections::btree_map; use iroha_data_model_derive::model; -use iroha_primitives::json::JsonValue; +use iroha_primitives::json::Json; pub use self::model::*; use crate::{name::Name, Identifiable}; @@ -232,7 +232,7 @@ mod model { /// /// It is JSON-encoded, and its structure must correspond to the structure of /// the type defined in [`crate::executor::ExecutorDataModel`]. - pub payload: JsonValue, + pub payload: Json, } /// Set of all current blockchain parameter values @@ -577,7 +577,7 @@ impl CustomParameterId { impl CustomParameter { /// Constructor - pub fn new(id: CustomParameterId, payload: impl Into) -> Self { + pub fn new(id: CustomParameterId, payload: impl Into) -> Self { Self { id, payload: payload.into(), @@ -586,7 +586,7 @@ impl CustomParameter { /// Getter // TODO: derive with getset once FFI impl is fixed - pub fn payload(&self) -> &JsonValue { + pub fn payload(&self) -> &Json { &self.payload } } diff --git a/crates/iroha_data_model/src/permission.rs b/crates/iroha_data_model/src/permission.rs index 3e811e9f69..692a85a513 100644 --- a/crates/iroha_data_model/src/permission.rs +++ b/crates/iroha_data_model/src/permission.rs @@ -5,7 +5,7 @@ use alloc::{collections::BTreeSet, format, string::String, vec::Vec}; use std::collections::BTreeSet; use iroha_data_model_derive::model; -use iroha_primitives::json::JsonValue; +use iroha_primitives::json::Json; use iroha_schema::{Ident, IntoSchema}; pub use self::model::*; @@ -45,13 +45,13 @@ mod model { /// /// It is JSON-encoded, and its structure must correspond to the structure of /// the type defined in [`crate::executor::ExecutorDataModel`]. - pub payload: JsonValue, + pub payload: Json, } } impl Permission { /// Constructor - pub fn new(name: Ident, payload: impl Into) -> Self { + pub fn new(name: Ident, payload: impl Into) -> Self { Self { name, payload: payload.into(), @@ -65,7 +65,7 @@ impl Permission { /// Getter // TODO: derive with getset once FFI impl is fixed - pub fn payload(&self) -> &JsonValue { + pub fn payload(&self) -> &Json { &self.payload } } diff --git a/crates/iroha_data_model/src/query/mod.rs b/crates/iroha_data_model/src/query/mod.rs index 1869386935..c2ed143790 100644 --- a/crates/iroha_data_model/src/query/mod.rs +++ b/crates/iroha_data_model/src/query/mod.rs @@ -9,7 +9,7 @@ use derive_more::Constructor; use iroha_crypto::{PublicKey, SignatureOf}; use iroha_data_model_derive::model; use iroha_macro::FromVariant; -use iroha_primitives::{json::JsonValue, numeric::Numeric}; +use iroha_primitives::{json::Json, numeric::Numeric}; use iroha_schema::IntoSchema; use iroha_version::prelude::*; use parameters::{ForwardCursor, QueryParams}; @@ -150,7 +150,7 @@ mod model { pub enum SingularQueryOutputBox { Numeric(Numeric), ExecutorDataModel(crate::executor::ExecutorDataModel), - Json(JsonValue), + Json(Json), Trigger(crate::trigger::Trigger), Parameters(Parameters), Transaction(TransactionQueryOutput), @@ -570,13 +570,13 @@ impl_iter_queries! { } impl_singular_queries! { - FindAccountMetadata => JsonValue, + FindAccountMetadata => Json, FindAssetQuantityById => Numeric, - FindAssetMetadata => JsonValue, - FindAssetDefinitionMetadata => JsonValue, - FindDomainMetadata => JsonValue, + FindAssetMetadata => Json, + FindAssetDefinitionMetadata => Json, + FindDomainMetadata => Json, FindParameters => crate::parameter::Parameters, - FindTriggerMetadata => JsonValue, + FindTriggerMetadata => Json, FindExecutorDataModel => crate::executor::ExecutorDataModel, } diff --git a/crates/iroha_kagami/src/genesis/generate.rs b/crates/iroha_kagami/src/genesis/generate.rs index 880a6eba1b..b0bc4601f8 100644 --- a/crates/iroha_kagami/src/genesis/generate.rs +++ b/crates/iroha_kagami/src/genesis/generate.rs @@ -90,7 +90,7 @@ pub fn generate_default( ) -> color_eyre::Result { let genesis_account_id = AccountId::new(GENESIS_DOMAIN_ID.clone(), genesis_public_key); let mut meta = Metadata::default(); - meta.insert("key".parse()?, JsonValue::new("value")); + meta.insert("key".parse()?, Json::new("value")); let mut builder = builder .domain_with_metadata("wonderland".parse()?, meta.clone()) diff --git a/crates/iroha_primitives/src/json.rs b/crates/iroha_primitives/src/json.rs index cfa6dadce5..0355ffecee 100644 --- a/crates/iroha_primitives/src/json.rs +++ b/crates/iroha_primitives/src/json.rs @@ -20,12 +20,12 @@ use parity_scale_codec::{Decode, Encode}; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use serde_json::Value; -/// A valid `JsonValue` that consists of valid String of Json type +/// A valid `Json` that consists of valid String of Json type #[derive(Debug, Display, Clone, PartialOrd, PartialEq, Ord, Eq, IntoSchema, Encode, Decode)] #[display(fmt = "{_0}")] -pub struct JsonValue(String); +pub struct Json(String); -impl JsonValue { +impl Json { /// Constructs [`Self`] /// # Errors /// @@ -57,7 +57,7 @@ impl JsonValue { } } -impl<'de> serde::de::Deserialize<'de> for JsonValue { +impl<'de> serde::de::Deserialize<'de> for Json { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, @@ -67,7 +67,7 @@ impl<'de> serde::de::Deserialize<'de> for JsonValue { } } -impl serde::ser::Serialize for JsonValue { +impl serde::ser::Serialize for Json { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer, @@ -77,77 +77,77 @@ impl serde::ser::Serialize for JsonValue { } } -impl From<&Value> for JsonValue { +impl From<&Value> for Json { fn from(value: &Value) -> Self { - JsonValue(value.to_string()) + Json(value.to_string()) } } -impl From for JsonValue { +impl From for Json { fn from(value: Value) -> Self { - JsonValue(value.to_string()) + Json(value.to_string()) } } -impl From for JsonValue { +impl From for Json { fn from(value: u32) -> Self { - JsonValue::new(value) + Json::new(value) } } -impl From for JsonValue { +impl From for Json { fn from(value: u64) -> Self { - JsonValue::new(value) + Json::new(value) } } -impl From for JsonValue { +impl From for Json { fn from(value: f64) -> Self { - JsonValue::new(value) + Json::new(value) } } -impl From for JsonValue { +impl From for Json { fn from(value: bool) -> Self { - JsonValue::new(value) + Json::new(value) } } -impl From<&str> for JsonValue { +impl From<&str> for Json { fn from(value: &str) -> Self { - value.parse::().expect("Impossible error") + value.parse::().expect("Impossible error") } } -impl + Serialize> From> for JsonValue { +impl + Serialize> From> for Json { fn from(value: Vec) -> Self { - JsonValue::new(value) + Json::new(value) } } /// Removes extra spaces from object if `&str` is an object -impl FromStr for JsonValue { +impl FromStr for Json { type Err = serde_json::Error; fn from_str(s: &str) -> Result { if let Ok(value) = serde_json::from_str::(s) { - Ok(JsonValue(value.to_string())) + Ok(Json(value.to_string())) } else { let json_formatted_string = serde_json::to_string(s)?; let value: Value = serde_json::from_str(&json_formatted_string)?; - Ok(JsonValue(value.to_string())) + Ok(Json(value.to_string())) } } } -impl Default for JsonValue { +impl Default for Json { fn default() -> Self { // NOTE: empty string isn't valid JSON Self("null".to_string()) } } -impl AsRef for JsonValue { +impl AsRef for Json { fn as_ref(&self) -> &str { &self.0 } @@ -165,10 +165,10 @@ mod candidate { } } - impl TryFrom> for JsonValue { + impl TryFrom> for Json { type Error = serde_json::Error; fn try_from(value: JsonCandidate) -> Result { - Ok(JsonValue(serde_json::to_string(&value.0)?)) + Ok(Json(serde_json::to_string(&value.0)?)) } } } diff --git a/crates/iroha_schema_gen/src/lib.rs b/crates/iroha_schema_gen/src/lib.rs index a373e870c7..1ac635ede4 100644 --- a/crates/iroha_schema_gen/src/lib.rs +++ b/crates/iroha_schema_gen/src/lib.rs @@ -158,7 +158,7 @@ types!( Box>, Box, BTreeMap, - BTreeMap, + BTreeMap, BTreeSet, BTreeSet, BurnBox, @@ -279,7 +279,7 @@ types!( QueryWithFilter, QueryWithFilter, QueryWithParams, - JsonValue, + Json, Level, Log, MathError, @@ -552,7 +552,7 @@ pub mod complete_data_model { addr::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrHost, SocketAddrV4, SocketAddrV6}, const_vec::ConstVec, conststr::ConstString, - json::JsonValue, + json::Json, }; pub use iroha_schema::Compact; } diff --git a/crates/iroha_torii/src/routing.rs b/crates/iroha_torii/src/routing.rs index 62b9b6f3d7..5fa43f72c0 100644 --- a/crates/iroha_torii/src/routing.rs +++ b/crates/iroha_torii/src/routing.rs @@ -78,14 +78,14 @@ pub async fn handle_health() -> &'static str { #[iroha_futures::telemetry_future] #[cfg(feature = "schema")] -pub async fn handle_schema() -> Json { - Json(iroha_schema_gen::build_schemas()) +pub async fn handle_schema() -> axum::Json { + axum::Json(iroha_schema_gen::build_schemas()) } #[iroha_futures::telemetry_future] -pub async fn handle_get_configuration(kiso: KisoHandle) -> Result> { +pub async fn handle_get_configuration(kiso: KisoHandle) -> Result> { let dto = kiso.get_dto().await?; - Ok(Json(dto)) + Ok(axum::Json(dto)) } #[iroha_futures::telemetry_future] @@ -301,13 +301,13 @@ pub fn handle_status( .try_fold(&value, serde_json::Value::get) .wrap_err_with(|| eyre!("Path not found: \"{}\"", tail)) .map_err(Error::StatusSegmentNotFound) - .map(|segment| Json(segment).into_response())?; + .map(|segment| axum::Json(segment).into_response())?; Ok(reply) } else if accept.is_some_and(|x| x.as_ref() == utils::PARITY_SCALE_MIME_TYPE.as_bytes()) { Ok(Scale(status).into_response()) } else { - Ok(Json(status).into_response()) + Ok(axum::Json(status).into_response()) } } diff --git a/docs/source/references/schema.json b/docs/source/references/schema.json index a1f460792d..ecd4b45257 100644 --- a/docs/source/references/schema.json +++ b/docs/source/references/schema.json @@ -1359,7 +1359,7 @@ "Struct": [ { "name": "payload", - "type": "JsonValue" + "type": "Json" } ] }, @@ -1371,7 +1371,7 @@ }, { "name": "payload", - "type": "JsonValue" + "type": "Json" } ] }, @@ -1699,7 +1699,7 @@ }, { "name": "args", - "type": "JsonValue" + "type": "Json" } ] }, @@ -1715,7 +1715,7 @@ }, { "name": "args", - "type": "JsonValue" + "type": "Json" } ] }, @@ -1768,7 +1768,7 @@ }, { "name": "schema", - "type": "JsonValue" + "type": "Json" } ] }, @@ -2336,7 +2336,7 @@ "IpfsPath": "String", "Ipv4Addr": "Array", "Ipv6Addr": "Array", - "JsonValue": "String", + "Json": "String", "Level": { "Enum": [ { @@ -2409,7 +2409,7 @@ "MerkleTree": { "Vec": "HashOf" }, - "Metadata": "SortedMap", + "Metadata": "SortedMap", "MetadataChanged": { "Struct": [ { @@ -2422,7 +2422,7 @@ }, { "name": "value", - "type": "JsonValue" + "type": "Json" } ] }, @@ -2438,7 +2438,7 @@ }, { "name": "value", - "type": "JsonValue" + "type": "Json" } ] }, @@ -2454,7 +2454,7 @@ }, { "name": "value", - "type": "JsonValue" + "type": "Json" } ] }, @@ -2470,7 +2470,7 @@ }, { "name": "value", - "type": "JsonValue" + "type": "Json" } ] }, @@ -2486,7 +2486,7 @@ }, { "name": "value", - "type": "JsonValue" + "type": "Json" } ] }, @@ -2882,7 +2882,7 @@ }, { "name": "payload", - "type": "JsonValue" + "type": "Json" } ] }, @@ -3825,7 +3825,7 @@ }, { "name": "value", - "type": "JsonValue" + "type": "Json" } ] }, @@ -3841,7 +3841,7 @@ }, { "name": "value", - "type": "JsonValue" + "type": "Json" } ] }, @@ -3857,7 +3857,7 @@ }, { "name": "value", - "type": "JsonValue" + "type": "Json" } ] }, @@ -3873,7 +3873,7 @@ }, { "name": "value", - "type": "JsonValue" + "type": "Json" } ] }, @@ -3889,7 +3889,7 @@ }, { "name": "value", - "type": "JsonValue" + "type": "Json" } ] }, @@ -4079,7 +4079,7 @@ { "tag": "Json", "discriminant": 2, - "type": "JsonValue" + "type": "Json" }, { "tag": "Trigger", @@ -4190,10 +4190,10 @@ "value": "CustomParameter" } }, - "SortedMap": { + "SortedMap": { "Map": { "key": "Name", - "value": "JsonValue" + "value": "Json" } }, "SortedVec": { diff --git a/wasm_samples/executor_custom_data_model/src/complex_isi.rs b/wasm_samples/executor_custom_data_model/src/complex_isi.rs index f632706823..262b875db3 100644 --- a/wasm_samples/executor_custom_data_model/src/complex_isi.rs +++ b/wasm_samples/executor_custom_data_model/src/complex_isi.rs @@ -12,7 +12,7 @@ mod isi { use iroha_data_model::{ isi::{CustomInstruction, Instruction, InstructionBox}, - prelude::JsonValue, + prelude::Json, }; use iroha_schema::IntoSchema; use serde::{Deserialize, Serialize}; @@ -69,10 +69,10 @@ mod isi { } } - impl TryFrom<&JsonValue> for CustomInstructionExpr { + impl TryFrom<&Json> for CustomInstructionExpr { type Error = serde_json::Error; - fn try_from(payload: &JsonValue) -> serde_json::Result { + fn try_from(payload: &Json) -> serde_json::Result { serde_json::from_str::(payload.as_ref()) } } diff --git a/wasm_samples/executor_custom_data_model/src/mint_rose_args.rs b/wasm_samples/executor_custom_data_model/src/mint_rose_args.rs index 9ecbd3d16d..d9a8da2724 100644 --- a/wasm_samples/executor_custom_data_model/src/mint_rose_args.rs +++ b/wasm_samples/executor_custom_data_model/src/mint_rose_args.rs @@ -1,6 +1,6 @@ //! Arguments to mint rose with args trigger -use iroha_data_model::prelude::JsonValue; +use iroha_data_model::prelude::Json; use serde::{Deserialize, Serialize}; /// Arguments to mint rose with args trigger @@ -10,16 +10,16 @@ pub struct MintRoseArgs { pub val: u32, } -impl From for JsonValue { +impl From for Json { fn from(details: MintRoseArgs) -> Self { - JsonValue::new(details) + Json::new(details) } } -impl TryFrom<&JsonValue> for MintRoseArgs { +impl TryFrom<&Json> for MintRoseArgs { type Error = serde_json::Error; - fn try_from(payload: &JsonValue) -> serde_json::Result { + fn try_from(payload: &Json) -> serde_json::Result { serde_json::from_str::(payload.as_ref()) } } diff --git a/wasm_samples/executor_custom_data_model/src/multisig.rs b/wasm_samples/executor_custom_data_model/src/multisig.rs index 8a40fc55e7..6cbe685e55 100644 --- a/wasm_samples/executor_custom_data_model/src/multisig.rs +++ b/wasm_samples/executor_custom_data_model/src/multisig.rs @@ -23,30 +23,30 @@ pub enum MultisigArgs { Vote(HashOf>), } -impl From for JsonValue { +impl From for Json { fn from(details: MultisigRegisterArgs) -> Self { - JsonValue::new(details) + Json::new(details) } } -impl TryFrom<&JsonValue> for MultisigRegisterArgs { +impl TryFrom<&Json> for MultisigRegisterArgs { type Error = serde_json::Error; - fn try_from(payload: &JsonValue) -> serde_json::Result { + fn try_from(payload: &Json) -> serde_json::Result { serde_json::from_str::(payload.as_ref()) } } -impl From for JsonValue { +impl From for Json { fn from(details: MultisigArgs) -> Self { - JsonValue::new(details) + Json::new(details) } } -impl TryFrom<&JsonValue> for MultisigArgs { +impl TryFrom<&Json> for MultisigArgs { type Error = serde_json::Error; - fn try_from(payload: &JsonValue) -> serde_json::Result { + fn try_from(payload: &Json) -> serde_json::Result { serde_json::from_str::(payload.as_ref()) } } diff --git a/wasm_samples/executor_custom_data_model/src/simple_isi.rs b/wasm_samples/executor_custom_data_model/src/simple_isi.rs index f5bafea4fe..9b11a35e29 100644 --- a/wasm_samples/executor_custom_data_model/src/simple_isi.rs +++ b/wasm_samples/executor_custom_data_model/src/simple_isi.rs @@ -6,7 +6,7 @@ use alloc::{format, string::String, vec::Vec}; use iroha_data_model::{ asset::AssetDefinitionId, isi::{CustomInstruction, Instruction, InstructionBox}, - prelude::{JsonValue, Numeric}, + prelude::{Json, Numeric}, }; use iroha_schema::IntoSchema; use serde::{Deserialize, Serialize}; @@ -53,10 +53,10 @@ impl From for InstructionBox { } } -impl TryFrom<&JsonValue> for CustomInstructionBox { +impl TryFrom<&Json> for CustomInstructionBox { type Error = serde_json::Error; - fn try_from(payload: &JsonValue) -> serde_json::Result { + fn try_from(payload: &Json) -> serde_json::Result { serde_json::from_str::(payload.as_ref()) } } diff --git a/wasm_samples/multisig/src/lib.rs b/wasm_samples/multisig/src/lib.rs index db772e2c9a..8722bac4b6 100644 --- a/wasm_samples/multisig/src/lib.rs +++ b/wasm_samples/multisig/src/lib.rs @@ -55,14 +55,14 @@ fn main(host: Iroha, context: Context) { host.submit(&SetKeyValue::trigger( trigger_id.clone(), instructions_metadata_key.clone(), - JsonValue::new(&instructions), + Json::new(&instructions), )) .dbg_unwrap(); host.submit(&SetKeyValue::trigger( trigger_id.clone(), votes_metadata_key.clone(), - JsonValue::new(&votes), + Json::new(&votes), )) .dbg_unwrap(); @@ -83,7 +83,7 @@ fn main(host: Iroha, context: Context) { host.submit(&SetKeyValue::trigger( trigger_id.clone(), votes_metadata_key.clone(), - JsonValue::new(&votes), + Json::new(&votes), )) .dbg_unwrap(); diff --git a/wasm_samples/multisig_register/src/lib.rs b/wasm_samples/multisig_register/src/lib.rs index 08b27e4205..821c22a33a 100644 --- a/wasm_samples/multisig_register/src/lib.rs +++ b/wasm_samples/multisig_register/src/lib.rs @@ -83,7 +83,7 @@ fn main(host: Iroha, context: Context) { host.submit(&SetKeyValue::trigger( trigger_id, "signatories".parse().unwrap(), - JsonValue::new(&args.signatories), + Json::new(&args.signatories), )) .dbg_unwrap(); diff --git a/wasm_samples/query_assets_and_save_cursor/src/lib.rs b/wasm_samples/query_assets_and_save_cursor/src/lib.rs index 81ab1a299c..81ed71a94f 100644 --- a/wasm_samples/query_assets_and_save_cursor/src/lib.rs +++ b/wasm_samples/query_assets_and_save_cursor/src/lib.rs @@ -51,7 +51,7 @@ fn main(host: Iroha, context: Context) { host.submit(&SetKeyValue::account( context.authority, "cursor".parse().unwrap(), - JsonValue::new(asset_cursor.cursor), + Json::new(asset_cursor.cursor), )) .dbg_expect("Failed to save cursor to the owner's metadata"); }