Skip to content

Commit

Permalink
refactor: encode JsonString as object in scale
Browse files Browse the repository at this point in the history
Signed-off-by: Shanin Roman <[email protected]>
  • Loading branch information
Erigara committed Sep 20, 2024
1 parent e680397 commit f64ca4e
Show file tree
Hide file tree
Showing 13 changed files with 323 additions and 61 deletions.
7 changes: 2 additions & 5 deletions crates/iroha/tests/integration/permissions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use iroha_executor_data_model::permission::{
use iroha_genesis::GenesisBlock;
use iroha_test_network::{PeerBuilder, *};
use iroha_test_samples::{gen_account_in, ALICE_ID, BOB_ID};
use serde_json::json;

#[test]
fn genesis_transactions_are_validated_by_executor() {
Expand Down Expand Up @@ -318,11 +319,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 = JsonString::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}" }}"##
));
let value_json = JsonString::new(json!({ "asset": format!("xor#wonderland#{mouse_id}") }));

let mouse_asset = AssetId::new(asset_definition_id, mouse_id.clone());
let allow_alice_to_set_key_value_in_mouse_asset = Grant::account_permission(
Expand Down
Binary file modified crates/iroha_codec/samples/account.bin
Binary file not shown.
2 changes: 1 addition & 1 deletion crates/iroha_codec/samples/domain.bin
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(wonderland�/ipfs/Qme7ss3ARVgxv6rXqVPiikMJ8u2NLgmgszg13pYrDKEoiuPIs_Jabberwocky_alivetrue
(wonderland�/ipfs/Qme7ss3ARVgxv6rXqVPiikMJ8u2NLgmgszg13pYrDKEoiuPIs_Jabberwocky_alive
2 changes: 1 addition & 1 deletion crates/iroha_executor_data_model_derive/src/parameter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub fn impl_derive_parameter(input: &syn::DeriveInput) -> TokenStream {
return Err(Self::Error::UnknownIdent(alloc::string::ToString::to_string(value_id.name().as_ref())));
}

serde_json::from_str::<Self>(value.payload().as_ref()).map_err(Self::Error::Deserialize)
value.payload().clone().try_into_any().map_err(Self::Error::Deserialize)
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/iroha_executor_data_model_derive/src/permission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub fn impl_derive_permission(input: &syn::DeriveInput) -> TokenStream {
return Err(Self::Error::UnknownIdent(value.name().to_owned()));
}

serde_json::from_str::<Self>(value.payload().as_ref()).map_err(Self::Error::Deserialize)
value.payload().clone().try_into_any().map_err(Self::Error::Deserialize)
}
}

Expand Down
Loading

0 comments on commit f64ca4e

Please sign in to comment.