diff --git a/cli/src/lib.rs b/cli/src/lib.rs index 027a9189aef..e0ae2b8a6aa 100644 --- a/cli/src/lib.rs +++ b/cli/src/lib.rs @@ -319,14 +319,14 @@ impl Iroha { &config.block_sync, sumeragi.clone(), Arc::clone(&kura), - config.common.peer_id(), + config.common.peer.clone(), network.clone(), Arc::clone(&state), ) .start(); let gossiper = TransactionGossiper::from_config( - config.common.chain_id.clone(), + config.common.chain.clone(), config.transaction_gossiper, network.clone(), Arc::clone(&queue), @@ -356,7 +356,7 @@ impl Iroha { let kiso = KisoHandle::new(config.clone()); let torii = Torii::new( - config.common.chain_id.clone(), + config.common.chain.clone(), kiso.clone(), config.torii, Arc::clone(&queue), diff --git a/cli/src/samples.rs b/cli/src/samples.rs index 8c5a2ba1698..b73d2820e57 100644 --- a/cli/src/samples.rs +++ b/cli/src/samples.rs @@ -63,7 +63,7 @@ pub fn get_config_toml( let mut raw = toml::Table::new(); iroha_config::base::toml::Writer::new(&mut raw) - .write("chain_id", chain_id) + .write("chain", chain_id) .write("public_key", public_key) .write("private_key", ExposedPrivateKey(private_key)) .write(["sumeragi", "trusted_peers"], peers) diff --git a/client/src/client.rs b/client/src/client.rs index a86c3c37c50..84535567942 100644 --- a/client/src/client.rs +++ b/client/src/client.rs @@ -362,7 +362,7 @@ impl_query_output! { #[display(fmt = "{}@{torii_url}", "key_pair.public_key()")] pub struct Client { /// Unique id of the blockchain. Used for simple replay attack protection. - pub chain_id: ChainId, + pub chain: ChainId, /// Url for accessing Iroha node pub torii_url: Url, /// Accounts keypair @@ -372,7 +372,7 @@ pub struct Client { /// Transaction status timeout pub transaction_status_timeout: Duration, /// Current account - pub account_id: AccountId, + pub account: AccountId, /// Http headers which will be appended to each request pub headers: HashMap, /// If `true` add nonce, which makes different hashes for @@ -435,8 +435,8 @@ impl Client { #[inline] pub fn with_headers( Config { - chain_id, - account_id, + chain, + account, torii_api_url, key_pair, basic_auth, @@ -454,12 +454,12 @@ impl Client { } Self { - chain_id, + chain, torii_url: torii_api_url, key_pair, transaction_ttl: Some(transaction_ttl), transaction_status_timeout, - account_id, + account, headers, add_transaction_nonce: transaction_add_nonce, } @@ -474,7 +474,7 @@ impl Client { instructions: impl Into, metadata: UnlimitedMetadata, ) -> SignedTransaction { - let tx_builder = TransactionBuilder::new(self.chain_id.clone(), self.account_id.clone()); + let tx_builder = TransactionBuilder::new(self.chain.clone(), self.account.clone()); let mut tx_builder = match instructions.into() { Executable::Instructions(instructions) => tx_builder.with_instructions(instructions), @@ -836,7 +836,7 @@ impl Client { where >::Error: Into, { - let query_builder = ClientQueryBuilder::new(request, self.account_id.clone()) + let query_builder = ClientQueryBuilder::new(request, self.account.clone()) .with_filter(filter) .with_pagination(pagination) .with_sorting(sorting) @@ -1619,9 +1619,9 @@ mod tests { fn config_factory() -> Config { let (account_id, key_pair) = gen_account_in("wonderland"); Config { - chain_id: ChainId::from("00000000-0000-0000-0000-000000000000"), + chain: ChainId::from("00000000-0000-0000-0000-000000000000"), key_pair, - account_id, + account: account_id, torii_api_url: "http://127.0.0.1:8080".parse().unwrap(), basic_auth: None, transaction_add_nonce: false, @@ -1644,10 +1644,9 @@ mod tests { assert_ne!(tx1.hash(), tx2.hash()); let tx2 = { - let mut tx = - TransactionBuilder::new(client.chain_id.clone(), client.account_id.clone()) - .with_executable(tx1.instructions().clone()) - .with_metadata(tx1.metadata().clone()); + let mut tx = TransactionBuilder::new(client.chain.clone(), client.account.clone()) + .with_executable(tx1.instructions().clone()) + .with_metadata(tx1.metadata().clone()); tx.set_creation_time(tx1.creation_time()); if let Some(nonce) = tx1.nonce() { diff --git a/client/src/config.rs b/client/src/config.rs index 316434da4a2..53190d5b4d4 100644 --- a/client/src/config.rs +++ b/client/src/config.rs @@ -56,8 +56,8 @@ pub struct BasicAuth { #[derive(Clone, Debug, Serialize)] #[allow(missing_docs)] pub struct Config { - pub chain_id: ChainId, - pub account_id: AccountId, + pub chain: ChainId, + pub account: AccountId, pub key_pair: KeyPair, pub basic_auth: Option, pub torii_api_url: Url, @@ -108,7 +108,7 @@ mod tests { fn config_sample() -> toml::Table { toml::toml! { - chain_id = "00000000-0000-0000-0000-000000000000" + chain = "00000000-0000-0000-0000-000000000000" torii_url = "http://127.0.0.1:8080/" [basic_auth] @@ -116,7 +116,7 @@ mod tests { password = "ilovetea" [account] - domain_id = "wonderland" + domain = "wonderland" public_key = "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03" private_key = "802640CCF31D85E3B32A4BEA59987CE0C78E3B8E2DB93881468AB2435FE45D5C9DCD53CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03" diff --git a/client/src/config/user.rs b/client/src/config/user.rs index 7ea7b1f066c..c096b224748 100644 --- a/client/src/config/user.rs +++ b/client/src/config/user.rs @@ -16,7 +16,7 @@ use crate::config::BasicAuth; #[derive(Clone, Debug, ReadConfig)] #[allow(missing_docs)] pub struct Root { - pub chain_id: ChainId, + pub chain: ChainId, #[config(env = "TORII_URL")] pub torii_url: WithOrigin, pub basic_auth: Option, @@ -44,12 +44,12 @@ impl Root { /// If a set of validity errors occurs. pub fn parse(self) -> error_stack::Result { let Self { - chain_id, + chain: chain_id, torii_url, basic_auth, account: Account { - domain_id, + domain: domain_id, public_key, private_key, }, @@ -98,8 +98,8 @@ impl Root { emitter.into_result()?; Ok(super::Config { - chain_id, - account_id, + chain: chain_id, + account: account_id, key_pair: key_pair.unwrap(), torii_api_url: torii_url.into_value(), basic_auth, @@ -113,7 +113,7 @@ impl Root { #[derive(Debug, Clone, ReadConfig)] #[allow(missing_docs)] pub struct Account { - pub domain_id: DomainId, + pub domain: DomainId, pub public_key: WithOrigin, pub private_key: WithOrigin, } diff --git a/client/src/lib.rs b/client/src/lib.rs index 0de4272bd81..f3541257d2c 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -30,10 +30,10 @@ pub mod samples { .parse() .expect("should be valid"); Config { - chain_id, + chain: chain_id, key_pair, torii_api_url, - account_id, + account: account_id, basic_auth: None, transaction_ttl: DEFAULT_TRANSACTION_TIME_TO_LIVE, transaction_status_timeout: DEFAULT_TRANSACTION_STATUS_TIMEOUT, diff --git a/client/tests/integration/asset.rs b/client/tests/integration/asset.rs index c3af76a2d58..d9e9022f591 100644 --- a/client/tests/integration/asset.rs +++ b/client/tests/integration/asset.rs @@ -43,7 +43,7 @@ fn client_register_asset_should_add_asset_once_but_not_twice() -> Result<()> { let assets = result.collect::>>().expect("Valid"); assets.iter().any(|asset| { - asset.id().definition_id == asset_definition_id + *asset.id().definition() == asset_definition_id && *asset.value() == AssetValue::Numeric(Numeric::ZERO) }) })?; @@ -77,7 +77,7 @@ fn unregister_asset_should_remove_asset_from_account() -> Result<()> { assets .iter() - .any(|asset| asset.id().definition_id == asset_definition_id) + .any(|asset| *asset.id().definition() == asset_definition_id) })?; test_client.submit(unregister_asset)?; @@ -88,7 +88,7 @@ fn unregister_asset_should_remove_asset_from_account() -> Result<()> { assets .iter() - .all(|asset| asset.id().definition_id != asset_definition_id) + .all(|asset| *asset.id().definition() != asset_definition_id) })?; Ok(()) @@ -120,7 +120,7 @@ fn client_add_asset_quantity_to_existing_asset_should_increase_asset_amount() -> let assets = result.collect::>>().expect("Valid"); assets.iter().any(|asset| { - asset.id().definition_id == asset_definition_id + *asset.id().definition() == asset_definition_id && *asset.value() == AssetValue::Numeric(quantity) }) })?; @@ -151,7 +151,7 @@ fn client_add_big_asset_quantity_to_existing_asset_should_increase_asset_amount( let assets = result.collect::>>().expect("Valid"); assets.iter().any(|asset| { - asset.id().definition_id == asset_definition_id + *asset.id().definition() == asset_definition_id && *asset.value() == AssetValue::Numeric(quantity) }) })?; @@ -183,7 +183,7 @@ fn client_add_asset_with_decimal_should_increase_asset_amount() -> Result<()> { let assets = result.collect::>>().expect("Valid"); assets.iter().any(|asset| { - asset.id().definition_id == asset_definition_id + *asset.id().definition() == asset_definition_id && *asset.value() == AssetValue::Numeric(quantity) }) })?; @@ -202,7 +202,7 @@ fn client_add_asset_with_decimal_should_increase_asset_amount() -> Result<()> { let assets = result.collect::>>().expect("Valid"); assets.iter().any(|asset| { - asset.id().definition_id == asset_definition_id + *asset.id().definition() == asset_definition_id && *asset.value() == AssetValue::Numeric(sum) }) })?; @@ -298,13 +298,13 @@ fn find_rate_and_make_exchange_isi_should_succeed() { let instruction = Grant::permission( Permission::new( "CanTransferUserAsset".parse().unwrap(), - json!({ "asset_id": asset_id }), + json!({ "asset": asset_id }), ), alice_id.clone(), ); let transaction = TransactionBuilder::new( ChainId::from("00000000-0000-0000-0000-000000000000"), - asset_id.account_id().clone(), + asset_id.account().clone(), ) .with_instructions([instruction]) .sign(&owner_key_pair); diff --git a/client/tests/integration/asset_propagation.rs b/client/tests/integration/asset_propagation.rs index 1e8326dd237..bcf99a5ca9c 100644 --- a/client/tests/integration/asset_propagation.rs +++ b/client/tests/integration/asset_propagation.rs @@ -53,7 +53,7 @@ fn client_add_asset_quantity_to_existing_asset_should_increase_asset_amount_on_a let assets = result.collect::>>().expect("Valid"); assets.iter().any(|asset| { - asset.id().definition_id == asset_definition_id + *asset.id().definition() == asset_definition_id && *asset.value() == AssetValue::Numeric(quantity) }) }, diff --git a/client/tests/integration/domain_owner_permissions.rs b/client/tests/integration/domain_owner_permissions.rs index 54ebd1e7c9c..a6d1434b514 100644 --- a/client/tests/integration/domain_owner_permissions.rs +++ b/client/tests/integration/domain_owner_permissions.rs @@ -48,7 +48,7 @@ fn domain_owner_domain_permissions() -> Result<()> { // Granting a respective token also allows "bob@kingdom" to do so let token = Permission::new( "CanRegisterAssetDefinitionInDomain".parse().unwrap(), - json!({ "domain_id": kingdom_id }), + json!({ "domain": kingdom_id }), ); test_client.submit_blocking(Grant::permission(token.clone(), bob_id.clone()))?; let transaction = TransactionBuilder::new(chain_id, bob_id.clone()) @@ -66,7 +66,7 @@ fn domain_owner_domain_permissions() -> Result<()> { // check that "alice@wonderland" as owner of domain can grant and revoke domain related permission tokens let token = Permission::new( "CanUnregisterDomain".parse().unwrap(), - json!({ "domain_id": kingdom_id }), + json!({ "domain": kingdom_id }), ); test_client.submit_blocking(Grant::permission(token.clone(), bob_id.clone()))?; test_client.submit_blocking(Revoke::permission(token, bob_id))?; @@ -106,7 +106,7 @@ fn domain_owner_account_permissions() -> Result<()> { let bob_id = BOB_ID.clone(); let token = Permission::new( "CanUnregisterAccount".parse().unwrap(), - json!({ "account_id": mad_hatter_id }), + json!({ "account": mad_hatter_id }), ); test_client.submit_blocking(Grant::permission(token.clone(), bob_id.clone()))?; test_client.submit_blocking(Revoke::permission(token, bob_id))?; @@ -141,7 +141,7 @@ fn domain_owner_asset_definition_permissions() -> Result<()> { // Grant permission to register asset definitions to "bob@kingdom" let token = Permission::new( "CanRegisterAssetDefinitionInDomain".parse().unwrap(), - json!({ "domain_id": kingdom_id }), + json!({ "domain": kingdom_id }), ); test_client.submit_blocking(Grant::permission(token, bob_id.clone()))?; @@ -172,7 +172,7 @@ fn domain_owner_asset_definition_permissions() -> Result<()> { // check that "alice@wonderland" as owner of domain can grant and revoke asset definition related permission tokens in her domain let token = Permission::new( "CanUnregisterAssetDefinition".parse().unwrap(), - json!({ "asset_definition_id": coin_id }), + json!({ "asset_definition": coin_id }), ); test_client.submit_blocking(Grant::permission(token.clone(), bob_id.clone()))?; test_client.submit_blocking(Revoke::permission(token, bob_id))?; @@ -206,7 +206,7 @@ fn domain_owner_asset_permissions() -> Result<()> { // Grant permission to register asset definitions to "bob@kingdom" let token = Permission::new( "CanRegisterAssetDefinitionInDomain".parse().unwrap(), - json!({ "domain_id": kingdom_id }), + json!({ "domain": kingdom_id }), ); test_client.submit_blocking(Grant::permission(token, bob_id.clone()))?; @@ -242,7 +242,7 @@ fn domain_owner_asset_permissions() -> Result<()> { // check that "alice@wonderland" as owner of domain can grant and revoke asset related permission tokens in her domain let token = Permission::new( "CanUnregisterUserAsset".parse().unwrap(), - json!({ "asset_id": bob_store_id }), + json!({ "asset": bob_store_id }), ); test_client.submit_blocking(Grant::permission(token.clone(), bob_id.clone()))?; test_client.submit_blocking(Revoke::permission(token, bob_id))?; @@ -293,7 +293,7 @@ fn domain_owner_trigger_permissions() -> Result<()> { // check that "alice@wonderland" as owner of domain can grant and revoke trigger related permission tokens in her domain let token = Permission::new( "CanUnregisterUserTrigger".parse().unwrap(), - json!({ "account_id": bob_id }), + json!({ "account": bob_id }), ); test_client.submit_blocking(Grant::permission(token.clone(), bob_id.clone()))?; test_client.submit_blocking(Revoke::permission(token, bob_id))?; diff --git a/client/tests/integration/events/data.rs b/client/tests/integration/events/data.rs index aa4aaa16932..1e35a9819ed 100644 --- a/client/tests/integration/events/data.rs +++ b/client/tests/integration/events/data.rs @@ -201,11 +201,11 @@ fn produce_multiple_events() -> Result<()> { let role_id = RoleId::from_str("TEST_ROLE")?; let token_1 = Permission::new( "CanRemoveKeyValueInAccount".parse()?, - json!({ "account_id": alice_id }), + json!({ "account": alice_id }), ); let token_2 = Permission::new( "CanSetKeyValueInAccount".parse()?, - json!({ "account_id": alice_id }), + json!({ "account": alice_id }), ); let role = iroha::data_model::role::Role::new(role_id.clone()) .add_permission(token_1.clone()) @@ -239,38 +239,38 @@ fn produce_multiple_events() -> Result<()> { let expected_domain_events: Vec = [ DataEvent::Domain(DomainEvent::Account(AccountEvent::PermissionAdded( AccountPermissionChanged { - account_id: bob_id.clone(), - permission_id: token_1.id.clone(), + account: bob_id.clone(), + permission: token_1.id.clone(), }, ))), DataEvent::Domain(DomainEvent::Account(AccountEvent::PermissionAdded( AccountPermissionChanged { - account_id: bob_id.clone(), - permission_id: token_2.id.clone(), + account: bob_id.clone(), + permission: token_2.id.clone(), }, ))), DataEvent::Domain(DomainEvent::Account(AccountEvent::RoleGranted( AccountRoleChanged { - account_id: bob_id.clone(), - role_id: role_id.clone(), + account: bob_id.clone(), + role: role_id.clone(), }, ))), DataEvent::Domain(DomainEvent::Account(AccountEvent::PermissionRemoved( AccountPermissionChanged { - account_id: bob_id.clone(), - permission_id: token_1.id, + account: bob_id.clone(), + permission: token_1.id, }, ))), DataEvent::Domain(DomainEvent::Account(AccountEvent::PermissionRemoved( AccountPermissionChanged { - account_id: bob_id.clone(), - permission_id: token_2.id, + account: bob_id.clone(), + permission: token_2.id, }, ))), DataEvent::Domain(DomainEvent::Account(AccountEvent::RoleRevoked( AccountRoleChanged { - account_id: bob_id, - role_id: role_id.clone(), + account: bob_id, + role: role_id.clone(), }, ))), DataEvent::Role(RoleEvent::Deleted(role_id)), diff --git a/client/tests/integration/events/notification.rs b/client/tests/integration/events/notification.rs index 8c36edc64c3..90f04abdf30 100644 --- a/client/tests/integration/events/notification.rs +++ b/client/tests/integration/events/notification.rs @@ -21,10 +21,10 @@ fn trigger_completion_success_should_produce_event() -> Result<()> { Action::new( vec![InstructionBox::from(instruction)], Repeats::Indefinitely, - asset_id.account_id.clone(), + asset_id.account().clone(), ExecuteTriggerEventFilter::new() .for_trigger(trigger_id.clone()) - .under_authority(asset_id.account_id), + .under_authority(asset_id.account().clone()), ), )); test_client.submit_blocking(register_trigger)?; diff --git a/client/tests/integration/extra_functional/multiple_blocks_created.rs b/client/tests/integration/extra_functional/multiple_blocks_created.rs index afa8737c974..458af606d10 100644 --- a/client/tests/integration/extra_functional/multiple_blocks_created.rs +++ b/client/tests/integration/extra_functional/multiple_blocks_created.rs @@ -62,7 +62,7 @@ fn long_multiple_blocks_created() -> Result<()> { let assets = result.collect::>>().expect("Valid"); assets.iter().any(|asset| { - asset.id().definition_id == asset_definition_id + *asset.id().definition() == asset_definition_id && *asset.value() == AssetValue::Numeric(account_has_quantity) }) }, diff --git a/client/tests/integration/extra_functional/offline_peers.rs b/client/tests/integration/extra_functional/offline_peers.rs index f0d847ee048..163d8ce20ab 100644 --- a/client/tests/integration/extra_functional/offline_peers.rs +++ b/client/tests/integration/extra_functional/offline_peers.rs @@ -36,7 +36,7 @@ fn genesis_block_is_committed_with_some_offline_peers() -> Result<()> { .collect::>>()?; let asset = assets .iter() - .find(|asset| asset.id().definition_id == roses) + .find(|asset| *asset.id().definition() == roses) .unwrap(); assert_eq!(AssetValue::Numeric(alice_has_roses), *asset.value()); Ok(()) diff --git a/client/tests/integration/extra_functional/restart_peer.rs b/client/tests/integration/extra_functional/restart_peer.rs index 2b919073c68..40540b7f549 100644 --- a/client/tests/integration/extra_functional/restart_peer.rs +++ b/client/tests/integration/extra_functional/restart_peer.rs @@ -51,7 +51,7 @@ fn restarted_peer_should_have_the_same_asset_amount() -> Result<()> { .collect::>>()?; let asset = assets .into_iter() - .find(|asset| asset.id().definition_id == asset_definition_id) + .find(|asset| *asset.id().definition() == asset_definition_id) .expect("Asset not found"); assert_eq!(AssetValue::Numeric(quantity), *asset.value()); @@ -82,7 +82,7 @@ fn restarted_peer_should_have_the_same_asset_amount() -> Result<()> { let account_asset = assets .into_iter() - .find(|asset| asset.id().definition_id == asset_definition_id) + .find(|asset| *asset.id().definition() == asset_definition_id) .expect("Asset not found"); AssetValue::Numeric(quantity) == *account_asset.value() diff --git a/client/tests/integration/extra_functional/unregister_peer.rs b/client/tests/integration/extra_functional/unregister_peer.rs index 3ea3a3292f8..ade2324d525 100644 --- a/client/tests/integration/extra_functional/unregister_peer.rs +++ b/client/tests/integration/extra_functional/unregister_peer.rs @@ -81,7 +81,7 @@ fn check_assets( let assets = result.collect::>>().expect("Valid"); assets.iter().any(|asset| { - asset.id().definition_id == *asset_definition_id + asset.id().definition() == asset_definition_id && *asset.value() == AssetValue::Numeric(quantity) }) }, diff --git a/client/tests/integration/extra_functional/unstable_network.rs b/client/tests/integration/extra_functional/unstable_network.rs index e96bfb428fc..3792be04267 100644 --- a/client/tests/integration/extra_functional/unstable_network.rs +++ b/client/tests/integration/extra_functional/unstable_network.rs @@ -118,7 +118,7 @@ fn unstable_network( let assets = result.collect::>>().expect("Valid"); assets.iter().any(|asset| { - asset.id().definition_id == asset_definition_id + *asset.id().definition() == asset_definition_id && *asset.value() == AssetValue::Numeric(account_has_quantity) }) }, diff --git a/client/tests/integration/non_mintable.rs b/client/tests/integration/non_mintable.rs index b6561028e41..b3f80e3d3d6 100644 --- a/client/tests/integration/non_mintable.rs +++ b/client/tests/integration/non_mintable.rs @@ -36,7 +36,7 @@ fn non_mintable_asset_can_be_minted_once_but_not_twice() -> Result<()> { test_client.poll_request(client::asset::by_account_id(account_id.clone()), |result| { let assets = result.collect::>>().expect("Valid"); assets.iter().any(|asset| { - asset.id().definition_id == asset_definition_id + *asset.id().definition() == asset_definition_id && *asset.value() == AssetValue::Numeric(numeric!(200)) }) })?; @@ -49,7 +49,7 @@ fn non_mintable_asset_can_be_minted_once_but_not_twice() -> Result<()> { .poll_request(client::asset::by_account_id(account_id), |result| { let assets = result.collect::>>().expect("Valid"); assets.iter().any(|asset| { - asset.id().definition_id == asset_definition_id + *asset.id().definition() == asset_definition_id && *asset.value() == AssetValue::Numeric(numeric!(400)) }) }) @@ -79,7 +79,7 @@ fn non_mintable_asset_cannot_be_minted_if_registered_with_non_zero_value() -> Re test_client.poll_request(client::asset::by_account_id(account_id), |result| { let assets = result.collect::>>().expect("Valid"); assets.iter().any(|asset| { - asset.id().definition_id == asset_definition_id + *asset.id().definition() == asset_definition_id && *asset.value() == AssetValue::Numeric(numeric!(1)) }) })?; @@ -117,7 +117,7 @@ fn non_mintable_asset_can_be_minted_if_registered_with_zero_value() -> Result<() test_client.poll_request(client::asset::by_account_id(account_id), |result| { let assets = result.collect::>>().expect("Valid"); assets.iter().any(|asset| { - asset.id().definition_id == asset_definition_id + *asset.id().definition() == asset_definition_id && *asset.value() == AssetValue::Numeric(numeric!(1)) }) })?; diff --git a/client/tests/integration/permissions.rs b/client/tests/integration/permissions.rs index 1538d6483ab..d213d9345f6 100644 --- a/client/tests/integration/permissions.rs +++ b/client/tests/integration/permissions.rs @@ -233,7 +233,7 @@ fn permissions_differ_not_only_by_names() { let allow_alice_to_set_key_value_in_hats = Grant::permission( Permission::new( "CanSetKeyValueInUserAsset".parse().unwrap(), - json!({ "asset_id": mouse_hat_id }), + json!({ "asset": mouse_hat_id }), ), alice_id.clone(), ); @@ -269,7 +269,7 @@ fn permissions_differ_not_only_by_names() { let allow_alice_to_set_key_value_in_shoes = Grant::permission( Permission::new( "CanSetKeyValueInUserAsset".parse().unwrap(), - json!({ "asset_id": mouse_shoes_id }), + json!({ "asset": mouse_shoes_id }), ), alice_id, ); @@ -321,7 +321,7 @@ fn stored_vs_granted_token_payload() -> Result<()> { JsonString::from_string_unchecked(format!( // Introducing some whitespaces // This way, if the executor compares just JSON strings, this test would fail - r##"{{ "asset_id" : "xor#wonderland#{mouse_id}" }}"## + r##"{{ "asset" : "xor#wonderland#{mouse_id}" }}"## )), ), alice_id, @@ -355,7 +355,7 @@ fn permissions_are_unified() { let allow_alice_to_transfer_rose_1 = Grant::permission( Permission::new( "CanTransferUserAsset".parse().unwrap(), - json!({ "asset_id": format!("rose#wonderland#{alice_id}") }), + json!({ "asset": format!("rose#wonderland#{alice_id}") }), ), alice_id.clone(), ); @@ -364,7 +364,7 @@ fn permissions_are_unified() { Permission::new( "CanTransferUserAsset".parse().unwrap(), // different content, but same meaning - json!({ "asset_id": format!("rose##{alice_id}") }), + json!({ "asset": format!("rose##{alice_id}") }), ), alice_id, ); @@ -391,7 +391,7 @@ fn associated_permissions_removed_on_unregister() { let register_domain = Register::domain(kingdom); let bob_to_set_kv_in_domain_token = Permission::new( "CanSetKeyValueInDomain".parse().unwrap(), - json!({ "domain_id": kingdom_id }), + json!({ "domain": kingdom_id }), ); let allow_bob_to_set_kv_in_domain = Grant::permission(bob_to_set_kv_in_domain_token.clone(), bob_id.clone()); @@ -438,7 +438,7 @@ fn associated_permissions_removed_from_role_on_unregister() { let register_domain = Register::domain(kingdom); let set_kv_in_domain_token = Permission::new( "CanSetKeyValueInDomain".parse().unwrap(), - json!({ "domain_id": kingdom_id }), + json!({ "domain": kingdom_id }), ); let role = Role::new(role_id.clone()).add_permission(set_kv_in_domain_token.clone()); let register_role = Register::role(role); diff --git a/client/tests/integration/queries/role.rs b/client/tests/integration/queries/role.rs index a2cd250a060..07d0035a3dc 100644 --- a/client/tests/integration/queries/role.rs +++ b/client/tests/integration/queries/role.rs @@ -133,7 +133,7 @@ fn find_roles_by_account_id() -> Result<()> { .map(|role_id| { Register::role(Role::new(role_id).add_permission(Permission::new( "CanSetKeyValueInAccount".parse().unwrap(), - json!({ "account_id": alice_id }), + json!({ "account": alice_id }), ))) }) .collect::>(); diff --git a/client/tests/integration/queries/smart_contract.rs b/client/tests/integration/queries/smart_contract.rs index 33858c64c07..649f4550146 100644 --- a/client/tests/integration/queries/smart_contract.rs +++ b/client/tests/integration/queries/smart_contract.rs @@ -30,7 +30,7 @@ fn live_query_is_dropped_after_smart_contract_end() -> Result<()> { client.submit_transaction_blocking(&transaction)?; let metadata_value = client.request(FindAccountKeyValueByIdAndKey::new( - client.account_id.clone(), + client.account.clone(), Name::from_str("cursor").unwrap(), ))?; let cursor: String = metadata_value.try_into()?; diff --git a/client/tests/integration/roles.rs b/client/tests/integration/roles.rs index 2f3a968e7a1..5fae2f04222 100644 --- a/client/tests/integration/roles.rs +++ b/client/tests/integration/roles.rs @@ -64,11 +64,11 @@ fn register_and_grant_role_for_metadata_access() -> Result<()> { let role = Role::new(role_id.clone()) .add_permission(Permission::new( "CanSetKeyValueInAccount".parse()?, - json!({ "account_id": mouse_id }), + json!({ "account": mouse_id }), )) .add_permission(Permission::new( "CanRemoveKeyValueInAccount".parse()?, - json!({ "account_id": mouse_id }), + json!({ "account": mouse_id }), )); let register_role = Register::role(role); test_client.submit_blocking(register_role)?; @@ -113,7 +113,7 @@ fn unregistered_role_removed_from_account() -> Result<()> { // Register root role let register_role = Register::role(Role::new(role_id.clone()).add_permission(Permission::new( "CanSetKeyValueInAccount".parse()?, - json!({ "account_id": alice_id }), + json!({ "account": alice_id }), ))); test_client.submit_blocking(register_role)?; @@ -151,7 +151,7 @@ fn role_with_invalid_permissions_is_not_accepted() -> Result<()> { .expect("should be valid"); let role = Role::new(role_id).add_permission(Permission::new( "CanSetKeyValueInAccount".parse()?, - json!({ "account_id": rose_asset_id }), + json!({ "account": rose_asset_id }), )); let err = test_client @@ -178,13 +178,13 @@ fn role_permissions_are_deduplicated() { let allow_alice_to_transfer_rose_1 = Permission::new( "CanTransferUserAsset".parse().unwrap(), - json!({ "asset_id": "rose#wonderland#ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland" }), + json!({ "asset": "rose#wonderland#ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland" }), ); // Different content, but same meaning let allow_alice_to_transfer_rose_2 = Permission::new( "CanTransferUserAsset".parse().unwrap(), - json!({ "asset_id": "rose##ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland" }), + json!({ "asset": "rose##ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland" }), ); let role_id: RoleId = "role_id".parse().expect("Valid"); @@ -247,7 +247,7 @@ fn grant_revoke_role_permissions() -> Result<()> { ); let permission = Permission::new( "CanSetKeyValueInAccount".parse()?, - json!({ "account_id": mouse_id }), + json!({ "account": mouse_id }), ); let grant_role_permission = Grant::role_permission(permission.clone(), role_id.clone()); let revoke_role_permission = Revoke::role_permission(permission.clone(), role_id.clone()); diff --git a/client/tests/integration/smartcontracts/create_nft_for_every_user_trigger/src/lib.rs b/client/tests/integration/smartcontracts/create_nft_for_every_user_trigger/src/lib.rs index 4ae58d430b7..811e64fbbb8 100644 --- a/client/tests/integration/smartcontracts/create_nft_for_every_user_trigger/src/lib.rs +++ b/client/tests/integration/smartcontracts/create_nft_for_every_user_trigger/src/lib.rs @@ -31,7 +31,7 @@ fn main(_id: TriggerId, _owner: AccountId, _event: EventBox) { for account in accounts_cursor { let account = account.dbg_unwrap(); - if bad_domain_ids.contains(account.id().domain_id()) { + if bad_domain_ids.contains(account.id().domain()) { continue; } @@ -39,7 +39,7 @@ fn main(_id: TriggerId, _owner: AccountId, _event: EventBox) { let name = format!( "nft_for_{}_in_{}", account.id().signatory(), - account.id().domain_id() + account.id().domain() ) .parse() .dbg_unwrap(); @@ -69,7 +69,7 @@ fn generate_new_nft_id(account_id: &AccountId) -> AssetDefinitionId { let new_number = assets .into_iter() .map(|res| res.dbg_unwrap()) - .filter(|asset| asset.id().definition_id().to_string().starts_with("nft_")) + .filter(|asset| asset.id().definition().to_string().starts_with("nft_")) .count() .checked_add(1) .dbg_unwrap(); @@ -79,7 +79,7 @@ fn generate_new_nft_id(account_id: &AccountId) -> AssetDefinitionId { "nft_number_{}_for_{}#{}", new_number, account_id.signatory(), - account_id.domain_id() + account_id.domain() ) .parse() .dbg_unwrap() diff --git a/client/tests/integration/smartcontracts/executor_custom_data_model/src/simple.rs b/client/tests/integration/smartcontracts/executor_custom_data_model/src/simple.rs index 21b63095307..16d479a67ab 100644 --- a/client/tests/integration/smartcontracts/executor_custom_data_model/src/simple.rs +++ b/client/tests/integration/smartcontracts/executor_custom_data_model/src/simple.rs @@ -20,7 +20,7 @@ pub enum CustomInstructionBox { #[derive(Debug, Deserialize, Serialize, IntoSchema)] pub struct MintAssetForAllAccounts { - pub asset_definition_id: AssetDefinitionId, + pub asset_definition: AssetDefinitionId, pub quantity: Numeric, } diff --git a/client/tests/integration/smartcontracts/executor_custom_instructions_simple/src/lib.rs b/client/tests/integration/smartcontracts/executor_custom_instructions_simple/src/lib.rs index 37c7c1bdfc0..a10b0ea9fc6 100644 --- a/client/tests/integration/smartcontracts/executor_custom_instructions_simple/src/lib.rs +++ b/client/tests/integration/smartcontracts/executor_custom_instructions_simple/src/lib.rs @@ -45,10 +45,10 @@ fn execute_custom_instruction(isi: CustomInstructionBox) -> Result<(), Validatio } fn execute_mint_asset_for_all_accounts(isi: MintAssetForAllAccounts) -> Result<(), ValidationFail> { - let accounts = FindAccountsWithAsset::new(isi.asset_definition_id.clone()).execute()?; + let accounts = FindAccountsWithAsset::new(isi.asset_definition.clone()).execute()?; for account in accounts { let account = account.dbg_expect("Failed to get accounts with asset"); - let asset_id = AssetId::new(isi.asset_definition_id.clone(), account.id().clone()); + let asset_id = AssetId::new(isi.asset_definition.clone(), account.id().clone()); Mint::asset_numeric(isi.quantity, asset_id).execute()?; } Ok(()) diff --git a/client/tests/integration/smartcontracts/executor_with_custom_permission/src/lib.rs b/client/tests/integration/smartcontracts/executor_with_custom_permission/src/lib.rs index 72d553d5ed1..4a4ddb6df86 100644 --- a/client/tests/integration/smartcontracts/executor_with_custom_permission/src/lib.rs +++ b/client/tests/integration/smartcontracts/executor_with_custom_permission/src/lib.rs @@ -99,7 +99,7 @@ impl Executor { &token, ) { - found_accounts.push((account, can_unregister_domain_token.domain_id)); + found_accounts.push((account, can_unregister_domain_token.domain)); break; } } @@ -120,7 +120,7 @@ impl Executor { Revoke::permission( Permission::new( can_unregister_domain_definition_id.clone(), - json!({ "domain_id": domain_id }), + json!({ "domain": domain_id }), ), account.id().clone(), ) diff --git a/client/tests/integration/transfer_asset.rs b/client/tests/integration/transfer_asset.rs index e974e9f8e2b..ae217ae6b5b 100644 --- a/client/tests/integration/transfer_asset.rs +++ b/client/tests/integration/transfer_asset.rs @@ -66,8 +66,8 @@ fn simulate_transfer_store_asset() { |result| { let assets = result.collect::>>().unwrap(); assets.iter().any(|asset| { - asset.id().definition_id == asset_definition_id - && asset.id().account_id == mouse_id + *asset.id().definition() == asset_definition_id + && *asset.id().account() == mouse_id }) }, ) @@ -125,9 +125,9 @@ fn simulate_transfer( let assets = result.collect::>>().unwrap(); assets.iter().any(|asset| { - asset.id().definition_id == asset_definition_id + *asset.id().definition() == asset_definition_id && *asset.value() == amount_to_transfer.clone().into() - && asset.id().account_id == mouse_id + && *asset.id().account() == mouse_id }) }, ) diff --git a/client/tests/integration/triggers/by_call_trigger.rs b/client/tests/integration/triggers/by_call_trigger.rs index 358173f3018..79598ce4c7a 100644 --- a/client/tests/integration/triggers/by_call_trigger.rs +++ b/client/tests/integration/triggers/by_call_trigger.rs @@ -29,7 +29,7 @@ fn call_execute_trigger() -> Result<()> { let prev_value = get_asset_value(&mut test_client, asset_id.clone()); let instruction = Mint::asset_numeric(1u32, asset_id.clone()); - let register_trigger = build_register_trigger_isi(asset_id.clone(), vec![instruction.into()]); + let register_trigger = build_register_trigger_isi(asset_id.account(), vec![instruction.into()]); test_client.submit_blocking(register_trigger)?; let trigger_id = TriggerId::from_str(TRIGGER_NAME)?; @@ -52,7 +52,7 @@ fn execute_trigger_should_produce_event() -> Result<()> { let asset_id = AssetId::new(asset_definition_id, account_id.clone()); let instruction = Mint::asset_numeric(1u32, asset_id.clone()); - let register_trigger = build_register_trigger_isi(asset_id, vec![instruction.into()]); + let register_trigger = build_register_trigger_isi(asset_id.account(), vec![instruction.into()]); test_client.submit_blocking(register_trigger)?; let trigger_id = TriggerId::from_str(TRIGGER_NAME)?; @@ -94,7 +94,7 @@ fn infinite_recursion_should_produce_one_call_per_block() -> Result<()> { Mint::asset_numeric(1u32, asset_id.clone()).into(), call_trigger.clone().into(), ]; - let register_trigger = build_register_trigger_isi(asset_id.clone(), instructions); + let register_trigger = build_register_trigger_isi(asset_id.account(), instructions); test_client.submit_blocking(register_trigger)?; test_client.submit_blocking(call_trigger)?; @@ -274,21 +274,21 @@ fn only_account_with_permission_can_register_trigger() -> Result<()> { let (_rt, _peer, test_client) = ::new().with_port(10_035).start_with_runtime(); wait_for_genesis_committed(&vec![test_client.clone()], 0); - let domain_id = ALICE_ID.domain_id().clone(); + let domain_id = ALICE_ID.domain().clone(); let alice_account_id = ALICE_ID.clone(); let rabbit_keys = KeyPair::random(); let rabbit_account_id = AccountId::new(domain_id, rabbit_keys.public_key().clone()); let rabbit_account = Account::new(rabbit_account_id.clone()); let mut rabbit_client = test_client.clone(); - rabbit_client.account_id = rabbit_account_id.clone(); + rabbit_client.account = rabbit_account_id.clone(); rabbit_client.key_pair = rabbit_keys; // Permission token for the trigger registration // on behalf of alice let permission_on_registration = Permission::new( "CanRegisterUserTrigger".parse().unwrap(), - json!({ "account_id": ALICE_ID.clone(), }), + json!({ "account": ALICE_ID.clone(), }), ); // Trigger with 'alice' as authority @@ -628,7 +628,7 @@ fn get_asset_value(client: &mut Client, asset_id: AssetId) -> Numeric { } fn build_register_trigger_isi( - asset_id: AssetId, + account_id: &AccountId, trigger_instructions: Vec, ) -> Register { let trigger_id: TriggerId = TRIGGER_NAME.parse().expect("Valid"); @@ -638,10 +638,10 @@ fn build_register_trigger_isi( Action::new( trigger_instructions, Repeats::Indefinitely, - asset_id.account_id.clone(), + account_id.clone(), ExecuteTriggerEventFilter::new() .for_trigger(trigger_id) - .under_authority(asset_id.account_id), + .under_authority(account_id.clone()), ), )) } diff --git a/client/tests/integration/triggers/time_trigger.rs b/client/tests/integration/triggers/time_trigger.rs index 24945786a7f..b44acc1611a 100644 --- a/client/tests/integration/triggers/time_trigger.rs +++ b/client/tests/integration/triggers/time_trigger.rs @@ -269,14 +269,14 @@ fn mint_nft_for_every_user_every_1_sec() -> Result<()> { // Checking results for account_id in accounts { let start_pattern = "nft_number_"; - let end_pattern = format!("_for_{}#{}", account_id.signatory, account_id.domain_id); + let end_pattern = format!("_for_{}#{}", account_id.signatory(), account_id.domain()); let assets = test_client .request(client::asset::by_account_id(account_id.clone()))? .collect::>>()?; let count: u64 = assets .into_iter() .filter(|asset| { - let s = asset.id().definition_id.to_string(); + let s = asset.id().definition().to_string(); s.starts_with(start_pattern) && s.ends_with(&end_pattern) }) .count() diff --git a/client/tests/integration/tx_rollback.rs b/client/tests/integration/tx_rollback.rs index c9a713d79c0..8e29755b377 100644 --- a/client/tests/integration/tx_rollback.rs +++ b/client/tests/integration/tx_rollback.rs @@ -30,7 +30,7 @@ fn client_sends_transaction_with_invalid_instruction_should_not_see_any_changes( let query_result = client.request(request)?.collect::>>()?; assert!(query_result .iter() - .all(|asset| asset.id().definition_id != wrong_asset_definition_id)); + .all(|asset| *asset.id().definition() != wrong_asset_definition_id)); let definition_query_result = client .request(client::asset::all_definitions())? .collect::>>()?; diff --git a/client/tests/integration/upgrade.rs b/client/tests/integration/upgrade.rs index 23954f4ac08..4ecebbf685f 100644 --- a/client/tests/integration/upgrade.rs +++ b/client/tests/integration/upgrade.rs @@ -34,7 +34,7 @@ fn executor_upgrade_should_work() -> Result<()> { wait_for_genesis_committed(&vec![client.clone()], 0); // Register `admin` domain and account - let admin_domain = Domain::new(admin_id.domain_id().clone()); + let admin_domain = Domain::new(admin_id.domain().clone()); let register_admin_domain = Register::domain(admin_domain); client.submit_blocking(register_admin_domain)?; @@ -93,7 +93,7 @@ fn executor_upgrade_should_run_migration() -> Result<()> { .expect("Valid"); assert!(alice_tokens.contains(&Permission::new( can_unregister_domain_token_id.clone(), - json!({ "domain_id": DomainId::from_str("wonderland").unwrap() }), + json!({ "domain": DomainId::from_str("wonderland").unwrap() }), ))); upgrade_executor( @@ -136,7 +136,7 @@ fn executor_upgrade_should_revoke_removed_permissions() -> Result<()> { // Permission which will be removed by executor let can_unregister_domain_token = Permission::new( "CanUnregisterDomain".parse()?, - json!({ "domain_id": DomainId::from_str("wonderland")? }), + json!({ "domain": DomainId::from_str("wonderland")? }), ); // Register `TEST_ROLE` with permission @@ -224,7 +224,7 @@ fn executor_custom_instructions_simple() -> Result<()> { // Give 1 rose to all let isi = MintAssetForAllAccounts { - asset_definition_id, + asset_definition: asset_definition_id, quantity: Numeric::from(1u32), }; let isi = CustomInstructionBox::MintAssetForAllAccounts(isi); diff --git a/client_cli/pytests/common/json_isi_examples/unregister_asset.json b/client_cli/pytests/common/json_isi_examples/unregister_asset.json index 837355581fb..2a5f1c21d41 100644 --- a/client_cli/pytests/common/json_isi_examples/unregister_asset.json +++ b/client_cli/pytests/common/json_isi_examples/unregister_asset.json @@ -1,7 +1,7 @@ [{ "Unregister": { "Asset": { - "object_id": "rose#ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland" + "object": "rose#ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland" } } }] diff --git a/client_cli/pytests/src/client_cli/client_cli.py b/client_cli/pytests/src/client_cli/client_cli.py index c78373fa2cf..6ebcdadafba 100644 --- a/client_cli/pytests/src/client_cli/client_cli.py +++ b/client_cli/pytests/src/client_cli/client_cli.py @@ -285,12 +285,12 @@ def register_trigger(self, account): return self - def unregister_asset(self, asset_id): + def unregister_asset(self, asset): """ Creates a JSON file for the unregister asset and executes it using the Iroha CLI. - :param asset_id: The object ID to be used in the unregister_asset. - :type asset_id: str + :param asset: The object ID to be used in the unregister_asset. + :type asset: str """ json_template_path = ( @@ -301,7 +301,7 @@ def unregister_asset(self, asset_id): / "unregister_asset.json" ) asset_data = read_isi_from_json(str(json_template_path)) - asset_data[0]["Unregister"]["Asset"]["object_id"] = str(asset_id) + asset_data[0]["Unregister"]["Asset"]["object"] = str(asset) json_temp_file_path = Path(ROOT_DIR) / "isi_unregister_asset.json" write_isi_to_json(asset_data, str(json_temp_file_path)) diff --git a/client_cli/pytests/src/client_cli/configuration.py b/client_cli/pytests/src/client_cli/configuration.py index 897eec066f8..09ff381c0df 100644 --- a/client_cli/pytests/src/client_cli/configuration.py +++ b/client_cli/pytests/src/client_cli/configuration.py @@ -130,7 +130,7 @@ def account_domain(self): :return: The account domain. :rtype: str """ - return self._config["account"]["domain_id"] + return self._config["account"]["domain"] @property def account_signatory(self): diff --git a/client_cli/pytests/test/assets/test_unregister_asset.py b/client_cli/pytests/test/assets/test_unregister_asset.py index bd48a79e0c2..6eb86623744 100644 --- a/client_cli/pytests/test/assets/test_unregister_asset.py +++ b/client_cli/pytests/test/assets/test_unregister_asset.py @@ -26,7 +26,7 @@ def test_unregister_asset( f'WHEN client_cli unregisters the asset "{GIVEN_numeric_asset_for_account.definition.name}"' ): client_cli.unregister_asset( - asset_id=f"{GIVEN_numeric_asset_for_account.definition.name}#" + asset=f"{GIVEN_numeric_asset_for_account.definition.name}#" f"{GIVEN_numeric_asset_for_account.account}@" f"{GIVEN_numeric_asset_for_account.definition.domain}" ) diff --git a/config/base/tests/misc.rs b/config/base/tests/misc.rs index 8ea64ba8493..af1d1e6a48a 100644 --- a/config/base/tests/misc.rs +++ b/config/base/tests/misc.rs @@ -18,7 +18,7 @@ pub mod sample_config { #[derive(Debug)] pub struct Root { - pub chain_id: String, + pub chain: String, pub torii: Torii, pub kura: Kura, pub telemetry: Telemetry, @@ -31,8 +31,8 @@ pub mod sample_config { Self: Sized, { let chain_id = reader - .read_parameter::(["chain_id"]) - .env("CHAIN_ID") + .read_parameter::(["chain"]) + .env("CHAIN") .value_required() .finish(); @@ -45,7 +45,7 @@ pub mod sample_config { let logger = reader.read_nested("logger"); FinalWrap::value_fn(move || Self { - chain_id: chain_id.unwrap(), + chain: chain_id.unwrap(), torii: torii.unwrap(), kura: kura.unwrap(), telemetry: telemetry.unwrap(), @@ -252,7 +252,7 @@ fn error_reading_empty_config() { expect![[r#" Some required parameters are missing - ╰╴missing parameter: `chain_id`"#]] + ╰╴missing parameter: `chain`"#]] .assert_eq_report(&report); } @@ -269,7 +269,7 @@ fn error_extra_fields_in_multiple_files() { .with_toml_source(TomlSource::new( PathBuf::from("./base.toml"), toml! { - chain_id = "412" + chain = "412" [torii] bar = false @@ -298,7 +298,7 @@ fn multiple_parsing_errors_in_multiple_sources() { .with_toml_source(TomlSource::new( PathBuf::from("./base.toml"), toml! { - chain_id = "ok" + chain = "ok" torii.address = "is it socket addr?" }, )) @@ -335,7 +335,7 @@ fn minimal_config_ok() { .with_toml_source(TomlSource::new( PathBuf::from("./config.toml"), toml! { - chain_id = "whatever" + chain = "whatever" }, )) .read_and_complete::() @@ -343,7 +343,7 @@ fn minimal_config_ok() { expect![[r#" Root { - chain_id: "whatever", + chain: "whatever", torii: Torii { address: WithOrigin { value: 128.0.0.1:8080, @@ -378,7 +378,7 @@ fn full_config_ok() { .with_toml_source(TomlSource::new( PathBuf::from("./config.toml"), toml! { - chain_id = "whatever" + chain = "whatever" [torii] address = "127.0.0.2:1337" @@ -400,7 +400,7 @@ fn full_config_ok() { expect![[r#" Root { - chain_id: "whatever", + chain: "whatever", torii: Torii { address: WithOrigin { value: 127.0.0.2:1337, @@ -442,17 +442,17 @@ fn full_config_ok() { #[test] fn env_overwrites_toml() { let root = ConfigReader::new() - .with_env(MockEnv::from(vec![("CHAIN_ID", "in env")])) + .with_env(MockEnv::from(vec![("CHAIN", "in env")])) .with_toml_source(TomlSource::new( PathBuf::from("config.toml"), toml! { - chain_id = "in file" + chain = "in file" }, )) .read_and_complete::() .expect("config is valid"); - assert_eq!(root.chain_id, "in env"); + assert_eq!(root.chain, "in env"); } #[test] @@ -465,7 +465,7 @@ fn full_from_env() { fn multiple_env_parsing_errors() { let report = ConfigReader::new() .with_env(MockEnv::from([ - ("CHAIN_ID", "just to set"), + ("CHAIN", "just to set"), ("API_ADDRESS", "i am not socket addr"), ("LOG_LEVEL", "error or whatever"), ])) diff --git a/config/iroha_test_config.toml b/config/iroha_test_config.toml index a9c73000aea..00da96628dc 100644 --- a/config/iroha_test_config.toml +++ b/config/iroha_test_config.toml @@ -1,4 +1,4 @@ -chain_id = "00000000-0000-0000-0000-000000000000" +chain = "00000000-0000-0000-0000-000000000000" public_key = "ed01201C61FAF8FE94E253B93114240394F79A607B7FA55F9E5A41EBEC74B88055768B" private_key = "802640282ED9F3CF92811C3818DBC4AE594ED59DC1A2F78E4241E31924E101D6B1FB831C61FAF8FE94E253B93114240394F79A607B7FA55F9E5A41EBEC74B88055768B" diff --git a/config/src/parameters/actual.rs b/config/src/parameters/actual.rs index 893a77592ab..43fedf49286 100644 --- a/config/src/parameters/actual.rs +++ b/config/src/parameters/actual.rs @@ -69,16 +69,9 @@ impl Root { #[allow(missing_docs)] #[derive(Debug, Clone)] pub struct Common { - pub chain_id: ChainId, + pub chain: ChainId, pub key_pair: KeyPair, - pub peer_id: PeerId, -} - -impl Common { - /// Construct an id of this peer - pub fn peer_id(&self) -> PeerId { - self.peer_id.clone() - } + pub peer: PeerId, } /// Network options diff --git a/config/src/parameters/user.rs b/config/src/parameters/user.rs index 1d04ebb0fd3..8f9aa61549a 100644 --- a/config/src/parameters/user.rs +++ b/config/src/parameters/user.rs @@ -56,8 +56,8 @@ impl FromEnvStr for ChainIdInConfig { #[derive(Debug, ReadConfig)] pub struct Root { - #[config(env = "CHAIN_ID")] - chain_id: ChainIdInConfig, + #[config(env = "CHAIN")] + chain: ChainIdInConfig, #[config(env = "PUBLIC_KEY")] public_key: WithOrigin, #[config(env = "PRIVATE_KEY")] @@ -136,9 +136,9 @@ impl Root { let key_pair = key_pair.unwrap(); let peer = actual::Common { - chain_id: self.chain_id.0, + chain: self.chain.0, key_pair, - peer_id: peer_id.unwrap(), + peer: peer_id.unwrap(), }; Ok(actual::Root { diff --git a/config/tests/fixtures.rs b/config/tests/fixtures.rs index 2a455e59f5c..93f8d0e12d7 100644 --- a/config/tests/fixtures.rs +++ b/config/tests/fixtures.rs @@ -69,7 +69,7 @@ fn minimal_config_snapshot() { expect![[r#" Root { common: Common { - chain_id: ChainId( + chain: ChainId( "0", ), key_pair: KeyPair { @@ -80,7 +80,7 @@ fn minimal_config_snapshot() { ), private_key: "[REDACTED PrivateKey]", }, - peer_id: PeerId { + peer: PeerId { address: 127.0.0.1:1337, public_key: PublicKey( ed25519( @@ -256,7 +256,7 @@ fn self_is_presented_in_trusted_peers() { .value() .clone() .into_non_empty_vec() - .contains(&config.common.peer_id())); + .contains(&config.common.peer)); } #[test] @@ -264,7 +264,7 @@ fn missing_fields() { let error = load_config_from_fixtures("bad.missing_fields.toml") .expect_err("should fail without missing fields"); - assert_contains!(format!("{error:?}"), "missing parameter: `chain_id`"); + assert_contains!(format!("{error:?}"), "missing parameter: `chain`"); assert_contains!(format!("{error:?}"), "missing parameter: `public_key`"); assert_contains!(format!("{error:?}"), "missing parameter: `network.address`"); } diff --git a/config/tests/fixtures/base.toml b/config/tests/fixtures/base.toml index 201c8b56299..f69d6111a7a 100644 --- a/config/tests/fixtures/base.toml +++ b/config/tests/fixtures/base.toml @@ -1,4 +1,4 @@ -chain_id = "0" +chain = "0" public_key = "ed01208BA62848CF767D72E7F7F4B9D2D7BA07FEE33760F79ABE5597A51520E292A0CB" private_key = "8026408F4C15E5D664DA3F13778801D23D4E89B76E94C1B94B389544168B6CB894F84F8BA62848CF767D72E7F7F4B9D2D7BA07FEE33760F79ABE5597A51520E292A0CB" diff --git a/config/tests/fixtures/full.env b/config/tests/fixtures/full.env index 5f320d36af3..4c1c087d760 100644 --- a/config/tests/fixtures/full.env +++ b/config/tests/fixtures/full.env @@ -1,4 +1,4 @@ -CHAIN_ID=0-0 +CHAIN=0-0 PUBLIC_KEY=ed01208BA62848CF767D72E7F7F4B9D2D7BA07FEE33760F79ABE5597A51520E292A0CB PRIVATE_KEY=8026408F4C15E5D664DA3F13778801D23D4E89B76E94C1B94B389544168B6CB894F84F8BA62848CF767D72E7F7F4B9D2D7BA07FEE33760F79ABE5597A51520E292A0CB P2P_ADDRESS=127.0.0.1:5432 diff --git a/config/tests/fixtures/full.toml b/config/tests/fixtures/full.toml index 59f6a1c0ab5..b62a2fe4cfd 100644 --- a/config/tests/fixtures/full.toml +++ b/config/tests/fixtures/full.toml @@ -1,6 +1,6 @@ # This config has ALL fields specified (except `extends`) -chain_id = "0" +chain = "0" public_key = "ed01208BA62848CF767D72E7F7F4B9D2D7BA07FEE33760F79ABE5597A51520E292A0CB" private_key = "8026408F4C15E5D664DA3F13778801D23D4E89B76E94C1B94B389544168B6CB894F84F8BA62848CF767D72E7F7F4B9D2D7BA07FEE33760F79ABE5597A51520E292A0CB" diff --git a/config/tests/fixtures/minimal_file_and_env.toml b/config/tests/fixtures/minimal_file_and_env.toml index 91143ba49d9..a8ea3ca9510 100644 --- a/config/tests/fixtures/minimal_file_and_env.toml +++ b/config/tests/fixtures/minimal_file_and_env.toml @@ -1,6 +1,6 @@ extends = "base_trusted_peers.toml" -chain_id = "0" +chain = "0" public_key = "ed01208BA62848CF767D72E7F7F4B9D2D7BA07FEE33760F79ABE5597A51520E292A0CB" private_key = "8026408F4C15E5D664DA3F13778801D23D4E89B76E94C1B94B389544168B6CB894F84F8BA62848CF767D72E7F7F4B9D2D7BA07FEE33760F79ABE5597A51520E292A0CB" diff --git a/configs/client.template.toml b/configs/client.template.toml index 858a4c1df8e..6b01f574a82 100644 --- a/configs/client.template.toml +++ b/configs/client.template.toml @@ -1,4 +1,4 @@ -# chain_id = +# chain = ## Might be set via `TORII_URL` env var # torii_url = @@ -8,7 +8,7 @@ # password = [account] -# domain_id = +# domain = # public_key = # private_key = diff --git a/configs/peer.template.toml b/configs/peer.template.toml index a1eb2e9b0ef..61d5cb86b8d 100644 --- a/configs/peer.template.toml +++ b/configs/peer.template.toml @@ -6,7 +6,7 @@ ## Or, for a chain of extensions: # extends = ["base-1.toml", "base-2.toml"] -# chain_id = +# chain = # public_key = # private_key = diff --git a/configs/swarm/client.toml b/configs/swarm/client.toml index f8fd0815237..7a62f9e6c37 100644 --- a/configs/swarm/client.toml +++ b/configs/swarm/client.toml @@ -1,4 +1,4 @@ -chain_id = "00000000-0000-0000-0000-000000000000" +chain = "00000000-0000-0000-0000-000000000000" torii_url = "http://127.0.0.1:8080/" [basic_auth] @@ -6,6 +6,6 @@ web_login = "mad_hatter" password = "ilovetea" [account] -domain_id = "wonderland" +domain = "wonderland" public_key = "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03" private_key = "802640CCF31D85E3B32A4BEA59987CE0C78E3B8E2DB93881468AB2435FE45D5C9DCD53CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03" diff --git a/configs/swarm/executor.wasm b/configs/swarm/executor.wasm index eb20b37f59d..0ec7ad328a4 100644 Binary files a/configs/swarm/executor.wasm and b/configs/swarm/executor.wasm differ diff --git a/configs/swarm/genesis.json b/configs/swarm/genesis.json index 22711024837..327578b900a 100644 --- a/configs/swarm/genesis.json +++ b/configs/swarm/genesis.json @@ -80,7 +80,7 @@ "Mint": { "Asset": { "object": "13", - "destination_id": "rose##ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland" + "destination": "rose##ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland" } } }, @@ -88,25 +88,25 @@ "Mint": { "Asset": { "object": "44", - "destination_id": "cabbage#garden_of_live_flowers#ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland" + "destination": "cabbage#garden_of_live_flowers#ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland" } } }, { "Transfer": { "AssetDefinition": { - "source_id": "ed01204164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4@genesis", + "source": "ed01204164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4@genesis", "object": "rose#wonderland", - "destination_id": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland" + "destination": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland" } } }, { "Transfer": { "Domain": { - "source_id": "ed01204164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4@genesis", + "source": "ed01204164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4@genesis", "object": "wonderland", - "destination_id": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland" + "destination": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland" } } }, @@ -117,7 +117,7 @@ "id": "CanSetParameters", "payload": null }, - "destination_id": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland" + "destination": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland" } } }, diff --git a/core/benches/blocks/common.rs b/core/benches/blocks/common.rs index 851dd6592c2..a60b34a37f8 100644 --- a/core/benches/blocks/common.rs +++ b/core/benches/blocks/common.rs @@ -170,7 +170,7 @@ pub fn build_state(rt: &tokio::runtime::Handle, account_id: &AccountId) -> State let _guard = rt.enter(); LiveQueryStore::test().start() }; - let mut domain = Domain::new(account_id.domain_id.clone()).build(account_id); + let mut domain = Domain::new(account_id.domain().clone()).build(account_id); domain.accounts.insert( account_id.clone(), Account::new(account_id.clone()).build(account_id), diff --git a/core/src/lib.rs b/core/src/lib.rs index 5a3e1bb4be6..f1104d47163 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -123,25 +123,25 @@ pub mod role { )] pub struct RoleIdWithOwner { /// [`AccountId`] of the owner. - pub account_id: AccountId, + pub account: AccountId, /// [`RoleId`] of the given role. - pub role_id: RoleId, + pub id: RoleId, } /// Reference to [`RoleIdWithOwner`]. #[derive(Debug, Clone, Copy, Constructor, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct RoleIdWithOwnerRef<'role> { /// [`AccountId`] of the owner. - pub account_id: &'role AccountId, + pub account: &'role AccountId, /// [`RoleId`] of the given role. - pub role_id: &'role RoleId, + pub role: &'role RoleId, } impl AsRoleIdWithOwnerRef for RoleIdWithOwner { fn as_key(&self) -> RoleIdWithOwnerRef<'_> { RoleIdWithOwnerRef { - account_id: &self.account_id, - role_id: &self.role_id, + account: &self.account, + role: &self.id, } } } @@ -187,8 +187,8 @@ mod tests { for account_id in [&account_id_a, &account_id_b] { for role_id in [&role_id_a, &role_id_b] { role_ids_with_owner.push(RoleIdWithOwner { - role_id: role_id.clone(), - account_id: account_id.clone(), + id: role_id.clone(), + account: account_id.clone(), }) } } @@ -196,8 +196,8 @@ mod tests { for role_id_with_owner_1 in &role_ids_with_owner { for role_id_with_owner_2 in &role_ids_with_owner { match ( - role_id_with_owner_1.account_id.cmp(&role_id_with_owner_2.account_id), - role_id_with_owner_1.role_id.cmp(&role_id_with_owner_2.role_id), + role_id_with_owner_1.account.cmp(&role_id_with_owner_2.account), + role_id_with_owner_1.id.cmp(&role_id_with_owner_2.id), ) { // `AccountId` take precedence in comparison // if `AccountId`s are equal than comparison based on `RoleId`s diff --git a/core/src/smartcontracts/isi/account.rs b/core/src/smartcontracts/isi/account.rs index 236a3dc017e..09afde491a1 100644 --- a/core/src/smartcontracts/isi/account.rs +++ b/core/src/smartcontracts/isi/account.rs @@ -51,7 +51,7 @@ pub mod isi { Err(err) => match err { QueryExecutionFail::Find(FindError::Asset(_)) => { assert_can_register( - &asset_id.definition_id, + &asset_id.definition, state_transaction, &self.object.value, )?; @@ -62,14 +62,13 @@ pub mod isi { match asset.value { AssetValue::Numeric(increment) => { - state_transaction.world.increase_asset_total_amount( - &asset_id.definition_id, - increment, - )?; + state_transaction + .world + .increase_asset_total_amount(&asset_id.definition, increment)?; } AssetValue::Store(_) => { state_transaction.world.increase_asset_total_amount( - &asset_id.definition_id, + &asset_id.definition, Numeric::ONE, )?; } @@ -94,14 +93,14 @@ pub mod isi { _authority: &AccountId, state_transaction: &mut StateTransaction<'_, '_>, ) -> Result<(), Error> { - let asset_id = self.object_id; + let asset_id = self.object; let asset = state_transaction .world - .account_mut(&asset_id.account_id) + .account_mut(&asset_id.account) .and_then(|account| { account - .remove_asset(&asset_id.definition_id) + .remove_asset(&asset_id.definition) .ok_or_else(|| FindError::Asset(asset_id)) })?; @@ -109,12 +108,12 @@ pub mod isi { AssetValue::Numeric(increment) => { state_transaction .world - .decrease_asset_total_amount(&asset.id.definition_id, increment)?; + .decrease_asset_total_amount(&asset.id.definition, increment)?; } AssetValue::Store(_) => { state_transaction .world - .decrease_asset_total_amount(&asset.id.definition_id, Numeric::ONE)?; + .decrease_asset_total_amount(&asset.id.definition, Numeric::ONE)?; } } @@ -122,7 +121,7 @@ pub mod isi { .world .emit_events(Some(AccountEvent::Asset(AssetEvent::Removed( AssetChanged { - asset_id: asset.id, + asset: asset.id, amount: asset.value, }, )))); @@ -138,27 +137,27 @@ pub mod isi { state_transaction: &mut StateTransaction<'_, '_>, ) -> Result<(), Error> { let Transfer { - source_id, + source, object, - destination_id, + destination, } = self; - let _ = state_transaction.world.account(&source_id)?; - let _ = state_transaction.world.account(&destination_id)?; + let _ = state_transaction.world.account(&source)?; + let _ = state_transaction.world.account(&destination)?; let asset_definition = state_transaction.world.asset_definition_mut(&object)?; - if asset_definition.owned_by != source_id { - return Err(Error::Find(FindError::Account(source_id))); + if asset_definition.owned_by != source { + return Err(Error::Find(FindError::Account(source))); } - asset_definition.owned_by = destination_id.clone(); + asset_definition.owned_by = destination.clone(); state_transaction .world .emit_events(Some(AssetDefinitionEvent::OwnerChanged( AssetDefinitionOwnerChanged { - asset_definition_id: object, - new_owner: destination_id, + asset_definition: object, + new_owner: destination, }, ))); @@ -173,7 +172,7 @@ pub mod isi { _authority: &AccountId, state_transaction: &mut StateTransaction<'_, '_>, ) -> Result<(), Error> { - let account_id = self.object_id; + let account_id = self.object; let account_metadata_limits = state_transaction.config.account_metadata_limits; @@ -195,7 +194,7 @@ pub mod isi { state_transaction .world .emit_events(Some(AccountEvent::MetadataInserted(MetadataChanged { - target_id: account_id, + target: account_id, key: self.key, value: self.value, }))); @@ -211,7 +210,7 @@ pub mod isi { _authority: &AccountId, state_transaction: &mut StateTransaction<'_, '_>, ) -> Result<(), Error> { - let account_id = self.object_id; + let account_id = self.object; let value = state_transaction .world @@ -226,7 +225,7 @@ pub mod isi { state_transaction .world .emit_events(Some(AccountEvent::MetadataRemoved(MetadataChanged { - target_id: account_id, + target: account_id, key: self.key, value, }))); @@ -242,7 +241,7 @@ pub mod isi { _authority: &AccountId, state_transaction: &mut StateTransaction<'_, '_>, ) -> Result<(), Error> { - let account_id = self.destination_id; + let account_id = self.destination; let permission = self.object; let permission_id = permission.id.clone(); @@ -277,8 +276,8 @@ pub mod isi { .world .emit_events(Some(AccountEvent::PermissionAdded( AccountPermissionChanged { - account_id, - permission_id, + account: account_id, + permission: permission_id, }, ))); @@ -293,7 +292,7 @@ pub mod isi { _authority: &AccountId, state_transaction: &mut StateTransaction<'_, '_>, ) -> Result<(), Error> { - let account_id = self.destination_id; + let account_id = self.destination; let permission = self.object; // Check if account exists @@ -310,8 +309,8 @@ pub mod isi { .world .emit_events(Some(AccountEvent::PermissionRemoved( AccountPermissionChanged { - account_id, - permission_id: permission.id, + account: account_id, + permission: permission.id, }, ))); @@ -326,7 +325,7 @@ pub mod isi { _authority: &AccountId, state_transaction: &mut StateTransaction<'_, '_>, ) -> Result<(), Error> { - let account_id = self.destination_id; + let account_id = self.destination; let role_id = self.object; let permissions = state_transaction @@ -362,14 +361,14 @@ pub mod isi { permissions .zip(core::iter::repeat_with(move || account_id.clone())) .map(|(permission_id, account_id)| AccountPermissionChanged { - account_id, - permission_id, + account: account_id, + permission: permission_id, }) .map(AccountEvent::PermissionAdded) .chain(std::iter::once(AccountEvent::RoleGranted( AccountRoleChanged { - account_id: account_id_clone, - role_id, + account: account_id_clone, + role: role_id, }, ))) }); @@ -385,7 +384,7 @@ pub mod isi { _authority: &AccountId, state_transaction: &mut StateTransaction<'_, '_>, ) -> Result<(), Error> { - let account_id = self.destination_id; + let account_id = self.destination; let role_id = self.object; let permissions = state_transaction @@ -402,8 +401,8 @@ pub mod isi { .world .account_roles .remove(RoleIdWithOwner { - account_id: account_id.clone(), - role_id: role_id.clone(), + account: account_id.clone(), + id: role_id.clone(), }) .is_none() { @@ -415,14 +414,14 @@ pub mod isi { permissions .zip(core::iter::repeat_with(move || account_id.clone())) .map(|(permission_id, account_id)| AccountPermissionChanged { - account_id, - permission_id, + account: account_id, + permission: permission_id, }) .map(AccountEvent::PermissionRemoved) .chain(std::iter::once(AccountEvent::RoleRevoked( AccountRoleChanged { - account_id: account_id_clone, - role_id, + account: account_id_clone, + role: role_id, }, ))) }); @@ -610,7 +609,7 @@ pub mod query { Ok(Box::new( state_ro .world() - .map_domain(&asset_definition_id.domain_id.clone(), move |domain| { + .map_domain(&asset_definition_id.domain.clone(), move |domain| { domain.accounts.values().filter(move |account| { account.assets.contains_key(&asset_definition_id) }) diff --git a/core/src/smartcontracts/isi/asset.rs b/core/src/smartcontracts/isi/asset.rs index 20752dd167f..3c75c35cf35 100644 --- a/core/src/smartcontracts/isi/asset.rs +++ b/core/src/smartcontracts/isi/asset.rs @@ -44,10 +44,10 @@ pub mod isi { _authority: &AccountId, state_transaction: &mut StateTransaction<'_, '_>, ) -> Result<(), Error> { - let asset_id = self.object_id; + let asset_id = self.object; assert_asset_type( - &asset_id.definition_id, + &asset_id.definition, state_transaction, expected_asset_value_type_store, )?; @@ -59,7 +59,7 @@ pub mod isi { ) { state_transaction .world - .increase_asset_total_amount(&asset_id.definition_id, Numeric::ONE)?; + .increase_asset_total_amount(&asset_id.definition, Numeric::ONE)?; } let asset_metadata_limits = state_transaction.config.asset_metadata_limits; @@ -82,7 +82,7 @@ pub mod isi { state_transaction .world .emit_events(Some(AssetEvent::MetadataInserted(MetadataChanged { - target_id: asset_id, + target: asset_id, key: self.key, value: self.value, }))); @@ -98,10 +98,10 @@ pub mod isi { _authority: &AccountId, state_transaction: &mut StateTransaction<'_, '_>, ) -> Result<(), Error> { - let asset_id = self.object_id; + let asset_id = self.object; assert_asset_type( - &asset_id.definition_id, + &asset_id.definition, state_transaction, expected_asset_value_type_store, )?; @@ -121,7 +121,7 @@ pub mod isi { state_transaction .world .emit_events(Some(AssetEvent::MetadataRemoved(MetadataChanged { - target_id: asset_id, + target: asset_id, key: self.key, value, }))); @@ -137,25 +137,25 @@ pub mod isi { _authority: &AccountId, state_transaction: &mut StateTransaction<'_, '_>, ) -> Result<(), Error> { - let asset_id = self.source_id; + let asset_id = self.source; assert_asset_type( - &asset_id.definition_id, + &asset_id.definition, state_transaction, expected_asset_value_type_store, )?; let asset = state_transaction .world - .account_mut(&asset_id.account_id) + .account_mut(&asset_id.account) .and_then(|account| { account - .remove_asset(&asset_id.definition_id) + .remove_asset(&asset_id.definition) .ok_or_else(|| FindError::Asset(asset_id.clone())) })?; let destination_store = { let destination_id = - AssetId::new(asset_id.definition_id.clone(), self.destination_id.clone()); + AssetId::new(asset_id.definition.clone(), self.destination.clone()); let destination_store_asset = state_transaction .world .asset_or_insert(destination_id.clone(), asset.value)?; @@ -178,10 +178,10 @@ pub mod isi { _authority: &AccountId, state_transaction: &mut StateTransaction<'_, '_>, ) -> Result<(), Error> { - let asset_id = self.destination_id; + let asset_id = self.destination; let asset_definition = assert_asset_type( - &asset_id.definition_id, + &asset_id.definition, state_transaction, expected_asset_value_type_numeric, )?; @@ -206,13 +206,13 @@ pub mod isi { .push(self.object.to_f64()); state_transaction .world - .increase_asset_total_amount(&asset_id.definition_id, self.object)?; + .increase_asset_total_amount(&asset_id.definition, self.object)?; } state_transaction .world .emit_events(Some(AssetEvent::Added(AssetChanged { - asset_id, + asset: asset_id, amount: self.object.into(), }))); @@ -226,19 +226,19 @@ pub mod isi { _authority: &AccountId, state_transaction: &mut StateTransaction<'_, '_>, ) -> Result<(), Error> { - let asset_id = self.destination_id; + let asset_id = self.destination; let asset_definition = assert_asset_type( - &asset_id.definition_id, + &asset_id.definition, state_transaction, expected_asset_value_type_numeric, )?; assert_numeric_spec(&self.object, &asset_definition)?; - let account = state_transaction.world.account_mut(&asset_id.account_id)?; + let account = state_transaction.world.account_mut(&asset_id.account)?; let asset = account .assets - .get_mut(&asset_id.definition_id) + .get_mut(&asset_id.definition) .ok_or_else(|| FindError::Asset(asset_id.clone()))?; let AssetValue::Numeric(quantity) = &mut asset.value else { return Err(Error::Conversion("Expected numeric asset type".to_owned())); @@ -248,7 +248,7 @@ pub mod isi { .ok_or(MathError::NotEnoughQuantity)?; if asset.value.is_zero_value() { - assert!(account.remove_asset(&asset_id.definition_id).is_some()); + assert!(account.remove_asset(&asset_id.definition).is_some()); } #[allow(clippy::float_arithmetic)] @@ -259,13 +259,13 @@ pub mod isi { .push(self.object.to_f64()); state_transaction .world - .decrease_asset_total_amount(&asset_id.definition_id, self.object)?; + .decrease_asset_total_amount(&asset_id.definition, self.object)?; } state_transaction .world .emit_events(Some(AssetEvent::Removed(AssetChanged { - asset_id: asset_id.clone(), + asset: asset_id.clone(), amount: self.object.into(), }))); @@ -279,22 +279,22 @@ pub mod isi { _authority: &AccountId, state_transaction: &mut StateTransaction<'_, '_>, ) -> Result<(), Error> { - let source_id = self.source_id; + let source_id = self.source; let destination_id = - AssetId::new(source_id.definition_id.clone(), self.destination_id.clone()); + AssetId::new(source_id.definition.clone(), self.destination.clone()); let asset_definition = assert_asset_type( - &source_id.definition_id, + &source_id.definition, state_transaction, expected_asset_value_type_numeric, )?; assert_numeric_spec(&self.object, &asset_definition)?; { - let account = state_transaction.world.account_mut(&source_id.account_id)?; + let account = state_transaction.world.account_mut(&source_id.account)?; let asset = account .assets - .get_mut(&source_id.definition_id) + .get_mut(&source_id.definition) .ok_or_else(|| FindError::Asset(source_id.clone()))?; let AssetValue::Numeric(quantity) = &mut asset.value else { return Err(Error::Conversion("Expected numeric asset type".to_owned())); @@ -303,7 +303,7 @@ pub mod isi { .checked_sub(self.object) .ok_or(MathError::NotEnoughQuantity)?; if asset.value.is_zero_value() { - assert!(account.remove_asset(&source_id.definition_id).is_some()); + assert!(account.remove_asset(&source_id.definition).is_some()); } } @@ -329,11 +329,11 @@ pub mod isi { state_transaction.world.emit_events([ AssetEvent::Removed(AssetChanged { - asset_id: source_id, + asset: source_id, amount: self.object.into(), }), AssetEvent::Added(AssetChanged { - asset_id: destination_id, + asset: destination_id, amount: self.object.into(), }), ]); @@ -476,7 +476,7 @@ pub mod query { let id = &self.id; iroha_logger::trace!(%id); state_ro.world().asset(id).map_err(|asset_err| { - if let Err(definition_err) = state_ro.world().asset_definition(&id.definition_id) { + if let Err(definition_err) = state_ro.world().asset_definition(&id.definition) { definition_err.into() } else { asset_err @@ -517,7 +517,7 @@ pub mod query { account .assets .values() - .filter(move |asset| asset.id().definition_id.name == name) + .filter(move |asset| asset.id().definition.name == name) }) }) .cloned(), @@ -558,7 +558,7 @@ pub mod query { account .assets .values() - .filter(move |asset| asset.id().definition_id == id) + .filter(move |asset| asset.id().definition == id) }) }) .cloned(), @@ -609,8 +609,8 @@ pub mod query { let asset_definition_id = asset_definition_id.clone(); account.assets.values().filter(move |asset| { - asset.id().account_id.domain_id == domain_id - && asset.id().definition_id == asset_definition_id + asset.id().account.domain == domain_id + && asset.id().definition == asset_definition_id }) }) .cloned(), @@ -627,9 +627,7 @@ pub mod query { .world() .asset(id) .map_err(|asset_err| { - if let Err(definition_err) = - state_ro.world().asset_definition(&id.definition_id) - { + if let Err(definition_err) = state_ro.world().asset_definition(&id.definition) { Error::Find(definition_err) } else { asset_err @@ -662,7 +660,7 @@ pub mod query { let id = &self.id; let key = &self.key; let asset = state_ro.world().asset(id).map_err(|asset_err| { - if let Err(definition_err) = state_ro.world().asset_definition(&id.definition_id) { + if let Err(definition_err) = state_ro.world().asset_definition(&id.definition) { Error::Find(definition_err) } else { asset_err diff --git a/core/src/smartcontracts/isi/domain.rs b/core/src/smartcontracts/isi/domain.rs index 15e5a6df06a..34efd4848b8 100644 --- a/core/src/smartcontracts/isi/domain.rs +++ b/core/src/smartcontracts/isi/domain.rs @@ -50,13 +50,13 @@ pub mod isi { let account: Account = self.object.build(authority); let account_id = account.id().clone(); - if *account_id.domain_id() == *iroha_genesis::GENESIS_DOMAIN_ID { + if *account_id.domain() == *iroha_genesis::GENESIS_DOMAIN_ID { return Err(InstructionExecutionError::InvariantViolation( "Not allowed to register account in genesis domain".to_owned(), )); } - let domain = state_transaction.world.domain_mut(&account_id.domain_id)?; + let domain = state_transaction.world.domain_mut(&account_id.domain)?; if domain.accounts.contains_key(&account_id) { return Err(RepetitionError { instruction_type: InstructionType::Register, @@ -81,7 +81,7 @@ pub mod isi { _authority: &AccountId, state_transaction: &mut StateTransaction<'_, '_>, ) -> Result<(), Error> { - let account_id = self.object_id; + let account_id = self.object; state_transaction .world() @@ -103,7 +103,7 @@ pub mod isi { if state_transaction .world - .domain_mut(&account_id.domain_id)? + .domain_mut(&account_id.domain)? .remove_account(&account_id) .is_none() { @@ -135,7 +135,7 @@ pub mod isi { let asset_definition_id = asset_definition.id().clone(); let domain = state_transaction .world - .domain_mut(&asset_definition_id.domain_id)?; + .domain_mut(&asset_definition_id.domain)?; if domain.asset_definitions.contains_key(&asset_definition_id) { return Err(RepetitionError { instruction_type: InstructionType::Register, @@ -165,7 +165,7 @@ pub mod isi { _authority: &AccountId, state_transaction: &mut StateTransaction<'_, '_>, ) -> Result<(), Error> { - let asset_definition_id = self.object_id; + let asset_definition_id = self.object; let mut assets_to_remove = Vec::new(); for domain in state_transaction.world.domains_iter() { @@ -175,7 +175,7 @@ pub mod isi { .assets .values() .filter_map(|asset| { - if asset.id().definition_id == asset_definition_id { + if asset.id().definition == asset_definition_id { return Some(asset.id()); } @@ -190,8 +190,8 @@ pub mod isi { for asset_id in assets_to_remove { if state_transaction .world - .account_mut(&asset_id.account_id)? - .remove_asset(&asset_id.definition_id) + .account_mut(&asset_id.account)? + .remove_asset(&asset_id.definition) .is_none() { error!(%asset_id, "asset not found. This is a bug"); @@ -202,7 +202,7 @@ pub mod isi { let domain = state_transaction .world - .domain_mut(&asset_definition_id.domain_id)?; + .domain_mut(&asset_definition_id.domain)?; if domain .remove_asset_definition(&asset_definition_id) .is_none() @@ -229,7 +229,7 @@ pub mod isi { _authority: &AccountId, state_transaction: &mut StateTransaction<'_, '_>, ) -> Result<(), Error> { - let asset_definition_id = self.object_id; + let asset_definition_id = self.object; let metadata_limits = state_transaction.config.asset_definition_metadata_limits; state_transaction @@ -247,7 +247,7 @@ pub mod isi { .world .emit_events(Some(AssetDefinitionEvent::MetadataInserted( MetadataChanged { - target_id: asset_definition_id, + target: asset_definition_id, key: self.key, value: self.value, }, @@ -264,7 +264,7 @@ pub mod isi { _authority: &AccountId, state_transaction: &mut StateTransaction<'_, '_>, ) -> Result<(), Error> { - let asset_definition_id = self.object_id; + let asset_definition_id = self.object; let value = state_transaction .world @@ -280,7 +280,7 @@ pub mod isi { .world .emit_events(Some(AssetDefinitionEvent::MetadataRemoved( MetadataChanged { - target_id: asset_definition_id, + target: asset_definition_id, key: self.key, value, }, @@ -297,7 +297,7 @@ pub mod isi { _authority: &AccountId, state_transaction: &mut StateTransaction<'_, '_>, ) -> Result<(), Error> { - let domain_id = self.object_id; + let domain_id = self.object; let limits = state_transaction.config.domain_metadata_limits; @@ -309,7 +309,7 @@ pub mod isi { state_transaction .world .emit_events(Some(DomainEvent::MetadataInserted(MetadataChanged { - target_id: domain_id, + target: domain_id, key: self.key, value: self.value, }))); @@ -325,7 +325,7 @@ pub mod isi { _authority: &AccountId, state_transaction: &mut StateTransaction<'_, '_>, ) -> Result<(), Error> { - let domain_id = self.object_id; + let domain_id = self.object; let domain = state_transaction.world.domain_mut(&domain_id)?; let value = domain @@ -336,7 +336,7 @@ pub mod isi { state_transaction .world .emit_events(Some(DomainEvent::MetadataRemoved(MetadataChanged { - target_id: domain_id, + target: domain_id, key: self.key, value, }))); @@ -352,26 +352,26 @@ pub mod isi { state_transaction: &mut StateTransaction<'_, '_>, ) -> Result<(), Error> { let Transfer { - source_id, + source, object, - destination_id, + destination, } = self; - let _ = state_transaction.world.account(&source_id)?; - let _ = state_transaction.world.account(&destination_id)?; + let _ = state_transaction.world.account(&source)?; + let _ = state_transaction.world.account(&destination)?; let domain = state_transaction.world.domain_mut(&object)?; - if domain.owned_by != source_id { - return Err(Error::Find(FindError::Account(source_id))); + if domain.owned_by != source { + return Err(Error::Find(FindError::Account(source))); } - domain.owned_by = destination_id.clone(); + domain.owned_by = destination.clone(); state_transaction .world .emit_events(Some(DomainEvent::OwnerChanged(DomainOwnerChanged { - domain_id: object, - new_owner: destination_id, + domain: object, + new_owner: destination, }))); Ok(()) diff --git a/core/src/smartcontracts/isi/triggers/mod.rs b/core/src/smartcontracts/isi/triggers/mod.rs index 8aecd9f859d..92c872e2562 100644 --- a/core/src/smartcontracts/isi/triggers/mod.rs +++ b/core/src/smartcontracts/isi/triggers/mod.rs @@ -120,7 +120,7 @@ pub mod isi { _authority: &AccountId, state_transaction: &mut StateTransaction<'_, '_>, ) -> Result<(), Error> { - let trigger_id = self.object_id; + let trigger_id = self.object; let triggers = &mut state_transaction.world.triggers; if triggers.remove(trigger_id.clone()) { @@ -145,7 +145,7 @@ pub mod isi { _authority: &AccountId, state_transaction: &mut StateTransaction<'_, '_>, ) -> Result<(), Error> { - let id = self.destination_id; + let id = self.destination; let triggers = &mut state_transaction.world.triggers; triggers @@ -167,7 +167,7 @@ pub mod isi { .world .emit_events(Some(TriggerEvent::Extended( TriggerNumberOfExecutionsChanged { - trigger_id: id, + trigger: id, by: self.object, }, ))); @@ -183,7 +183,7 @@ pub mod isi { _authority: &AccountId, state_transaction: &mut StateTransaction<'_, '_>, ) -> Result<(), Error> { - let trigger = self.destination_id; + let trigger = self.destination; let triggers = &mut state_transaction.world.triggers; triggers.mod_repeats(&trigger, |n| { n.checked_sub(self.object) @@ -195,7 +195,7 @@ pub mod isi { .world .emit_events(Some(TriggerEvent::Shortened( TriggerNumberOfExecutionsChanged { - trigger_id: trigger, + trigger, by: self.object, }, ))); @@ -211,7 +211,7 @@ pub mod isi { _authority: &AccountId, state_transaction: &mut StateTransaction<'_, '_>, ) -> Result<(), Error> { - let trigger_id = self.object_id; + let trigger_id = self.object; let trigger_metadata_limits = state_transaction.config.account_metadata_limits; state_transaction @@ -229,7 +229,7 @@ pub mod isi { state_transaction .world .emit_events(Some(TriggerEvent::MetadataInserted(MetadataChanged { - target_id: trigger_id, + target: trigger_id, key: self.key, value: self.value, }))); @@ -245,7 +245,7 @@ pub mod isi { _authority: &AccountId, state_transaction: &mut StateTransaction<'_, '_>, ) -> Result<(), Error> { - let trigger_id = self.object_id; + let trigger_id = self.object; let value = state_transaction .world @@ -261,7 +261,7 @@ pub mod isi { state_transaction .world .emit_events(Some(TriggerEvent::MetadataRemoved(MetadataChanged { - target_id: trigger_id, + target: trigger_id, key: self.key, value, }))); @@ -277,7 +277,7 @@ pub mod isi { authority: &AccountId, state_transaction: &mut StateTransaction<'_, '_>, ) -> Result<(), Error> { - let id = &self.trigger_id; + let id = &self.trigger; state_transaction .world @@ -424,7 +424,7 @@ pub mod query { .world() .triggers() .inspect_by_action( - move |action| action.authority().domain_id() == &domain_id, + move |action| action.authority().domain() == &domain_id, |trigger_id, action| (trigger_id.clone(), action.clone_and_box()), ) .map(|(trigger_id, action)| { diff --git a/core/src/smartcontracts/isi/world.rs b/core/src/smartcontracts/isi/world.rs index 47a55843bad..9019ac96836 100644 --- a/core/src/smartcontracts/isi/world.rs +++ b/core/src/smartcontracts/isi/world.rs @@ -62,7 +62,7 @@ pub mod isi { _authority: &AccountId, state_transaction: &mut StateTransaction<'_, '_>, ) -> Result<(), Error> { - let peer_id = self.object_id; + let peer_id = self.object; let world = &mut state_transaction.world; let Some(index) = world.trusted_peers_ids.iter().position(|id| id == &peer_id) else { return Err(FindError::Peer(peer_id).into()); @@ -121,13 +121,13 @@ pub mod isi { _authority: &AccountId, state_transaction: &mut StateTransaction<'_, '_>, ) -> Result<(), Error> { - let domain_id = self.object_id; + let domain_id = self.object; state_transaction .world() .triggers() .inspect_by_action( - |action| action.authority().domain_id() == &domain_id, + |action| action.authority().domain() == &domain_id, |trigger_id, _| trigger_id.clone(), ) .collect::>() @@ -203,22 +203,22 @@ pub mod isi { authority: &AccountId, state_transaction: &mut StateTransaction<'_, '_>, ) -> Result<(), Error> { - let role_id = self.object_id; + let role_id = self.object; let accounts_with_role = state_transaction .world .account_roles .iter() .map(|(role, ())| role) - .filter(|role| role.role_id.eq(&role_id)) - .map(|role| &role.account_id) + .filter(|role| role.id.eq(&role_id)) + .map(|role| &role.account) .cloned() .collect::>(); for account_id in accounts_with_role { let revoke = Revoke { object: role_id.clone(), - destination_id: account_id, + destination: account_id, }; revoke.execute(authority, state_transaction)? } @@ -241,7 +241,7 @@ pub mod isi { _authority: &AccountId, state_transaction: &mut StateTransaction<'_, '_>, ) -> Result<(), Error> { - let role_id = self.destination_id; + let role_id = self.destination; let permission = self.object; let permission_id = permission.id.clone(); @@ -269,8 +269,8 @@ pub mod isi { state_transaction .world .emit_events(Some(RoleEvent::PermissionAdded(RolePermissionChanged { - role_id, - permission_id, + role: role_id, + permission: permission_id, }))); Ok(()) @@ -284,7 +284,7 @@ pub mod isi { _authority: &AccountId, state_transaction: &mut StateTransaction<'_, '_>, ) -> Result<(), Error> { - let role_id = self.destination_id; + let role_id = self.destination; let permission = self.object; let permission_id = permission.id.clone(); @@ -299,8 +299,8 @@ pub mod isi { state_transaction .world .emit_events(Some(RoleEvent::PermissionRemoved(RolePermissionChanged { - role_id, - permission_id, + role: role_id, + permission: permission_id, }))); Ok(()) diff --git a/core/src/smartcontracts/wasm.rs b/core/src/smartcontracts/wasm.rs index 1f6d2474193..36ce65cfc52 100644 --- a/core/src/smartcontracts/wasm.rs +++ b/core/src/smartcontracts/wasm.rs @@ -1717,7 +1717,7 @@ mod tests { }; fn world_with_test_account(authority: &AccountId) -> World { - let domain_id = authority.domain_id.clone(); + let domain_id = authority.domain.clone(); let account = Account::new(authority.clone()).build(authority); let mut domain = Domain::new(domain_id).build(authority); assert!(domain.add_account(account).is_none()); diff --git a/core/src/state.rs b/core/src/state.rs index 0358a0e562d..6c6d0a32beb 100644 --- a/core/src/state.rs +++ b/core/src/state.rs @@ -378,7 +378,7 @@ pub trait WorldReadOnly { /// # Errors /// Fails if there is no domain or account fn account(&self, id: &AccountId) -> Result<&Account, FindError> { - self.domain(&id.domain_id).and_then(|domain| { + self.domain(&id.domain).and_then(|domain| { domain .accounts .get(id) @@ -395,7 +395,7 @@ pub trait WorldReadOnly { id: &AccountId, f: impl FnOnce(&'slf Account) -> T, ) -> Result { - let domain = self.domain(&id.domain_id)?; + let domain = self.domain(&id.domain)?; let account = domain .accounts .get(id) @@ -427,7 +427,7 @@ pub trait WorldReadOnly { > { self.account_roles() .range(RoleIdByAccountBounds::new(id)) - .map(|(role, ())| &role.role_id) + .map(|(role, ())| &role.id) } /// Return a set of all permission tokens granted to this account. @@ -490,11 +490,11 @@ pub trait WorldReadOnly { /// - The [`Domain`] with which the [`Account`] is associated doesn't exist. fn asset(&self, id: &AssetId) -> Result { self.map_account( - &id.account_id, + &id.account, |account| -> Result { account .assets - .get(&id.definition_id) + .get(&id.definition) .ok_or_else(|| QueryExecutionFail::from(FindError::Asset(id.clone()))) .cloned() }, @@ -508,7 +508,7 @@ pub trait WorldReadOnly { /// # Errors /// - Asset definition entry not found fn asset_definition(&self, asset_id: &AssetDefinitionId) -> Result { - self.domain(&asset_id.domain_id)? + self.domain(&asset_id.domain)? .asset_definitions .get(asset_id) .ok_or_else(|| FindError::AssetDefinition(asset_id.clone())) @@ -520,7 +520,7 @@ pub trait WorldReadOnly { /// # Errors /// - Asset definition not found fn asset_total_amount(&self, definition_id: &AssetDefinitionId) -> Result { - self.domain(&definition_id.domain_id)? + self.domain(&definition_id.domain)? .asset_total_quantities .get(definition_id) .ok_or_else(|| FindError::AssetDefinition(definition_id.clone())) @@ -664,7 +664,7 @@ impl WorldTransaction<'_, '_> { /// # Errors /// Fail if domain or account not found pub fn account_mut(&mut self, id: &AccountId) -> Result<&mut Account, FindError> { - self.domain_mut(&id.domain_id).and_then(move |domain| { + self.domain_mut(&id.domain).and_then(move |domain| { domain .accounts .get_mut(id) @@ -706,10 +706,10 @@ impl WorldTransaction<'_, '_> { /// # Errors /// If domain, account or asset not found pub fn asset_mut(&mut self, id: &AssetId) -> Result<&mut Asset, FindError> { - self.account_mut(&id.account_id).and_then(move |account| { + self.account_mut(&id.account).and_then(move |account| { account .assets - .get_mut(&id.definition_id) + .get_mut(&id.definition) .ok_or_else(|| FindError::Asset(id.clone())) }) } @@ -726,8 +726,8 @@ impl WorldTransaction<'_, '_> { ) -> Result<&mut Asset, Error> { // Check that asset definition exists { - let asset_definition_id = &asset_id.definition_id; - let asset_definition_domain_id = &asset_id.definition_id.domain_id; + let asset_definition_id = &asset_id.definition; + let asset_definition_domain_id = &asset_id.definition.domain; let asset_definition_domain = self .domains .get(asset_definition_domain_id) @@ -738,11 +738,11 @@ impl WorldTransaction<'_, '_> { .ok_or(FindError::AssetDefinition(asset_definition_id.clone()))?; } - let account_id = &asset_id.account_id; + let account_id = &asset_id.account; let account_domain = self .domains - .get_mut(&asset_id.account_id.domain_id) - .ok_or(FindError::Domain(asset_id.account_id.domain_id.clone()))?; + .get_mut(&asset_id.account.domain) + .ok_or(FindError::Domain(asset_id.account.domain.clone()))?; let account = account_domain .accounts .get_mut(account_id) @@ -750,7 +750,7 @@ impl WorldTransaction<'_, '_> { Ok(account .assets - .entry(asset_id.definition_id.clone()) + .entry(asset_id.definition.clone()) .or_insert_with(|| { let asset = Asset::new(asset_id, default_asset_value.into()); Self::emit_events_impl( @@ -770,7 +770,7 @@ impl WorldTransaction<'_, '_> { &mut self, id: &AssetDefinitionId, ) -> Result<&mut AssetDefinition, FindError> { - self.domain_mut(&id.domain_id).and_then(|domain| { + self.domain_mut(&id.domain).and_then(|domain| { domain .asset_definitions .get_mut(id) @@ -788,7 +788,7 @@ impl WorldTransaction<'_, '_> { definition_id: &AssetDefinitionId, increment: Numeric, ) -> Result<(), Error> { - let domain = self.domain_mut(&definition_id.domain_id)?; + let domain = self.domain_mut(&definition_id.domain)?; let asset_total_amount: &mut Numeric = domain .asset_total_quantities.get_mut(definition_id) .expect("Asset total amount not being found is a bug: check `Register` to insert initial total amount"); @@ -800,7 +800,7 @@ impl WorldTransaction<'_, '_> { self.emit_events({ Some(DomainEvent::AssetDefinition( AssetDefinitionEvent::TotalQuantityChanged(AssetDefinitionTotalQuantityChanged { - asset_definition_id: definition_id.clone(), + asset_definition: definition_id.clone(), total_amount: asset_total_amount, }), )) @@ -819,7 +819,7 @@ impl WorldTransaction<'_, '_> { definition_id: &AssetDefinitionId, decrement: Numeric, ) -> Result<(), Error> { - let domain = self.domain_mut(&definition_id.domain_id)?; + let domain = self.domain_mut(&definition_id.domain)?; let asset_total_amount: &mut Numeric = domain .asset_total_quantities.get_mut(definition_id) .expect("Asset total amount not being found is a bug: check `Register` to insert initial total amount"); @@ -831,7 +831,7 @@ impl WorldTransaction<'_, '_> { self.emit_events({ Some(DomainEvent::AssetDefinition( AssetDefinitionEvent::TotalQuantityChanged(AssetDefinitionTotalQuantityChanged { - asset_definition_id: definition_id.clone(), + asset_definition: definition_id.clone(), total_amount: asset_total_amount, }), )) @@ -1475,8 +1475,8 @@ mod range_bounds { impl AsRoleIdByAccount for RoleIdWithOwner { fn as_key(&self) -> RoleIdByAccount<'_> { RoleIdByAccount { - account_id: &self.account_id, - role_id: (&self.role_id).into(), + account_id: &self.account, + role_id: (&self.id).into(), } } } @@ -1845,7 +1845,7 @@ mod tests { .collect::>(); assert_eq!(range.len(), 2); for role in range { - assert_eq!(&role.account_id, &account_id); + assert_eq!(&role.account, &account_id); } } } diff --git a/core/src/sumeragi/mod.rs b/core/src/sumeragi/mod.rs index 35f734ce49c..7984a452fbc 100644 --- a/core/src/sumeragi/mod.rs +++ b/core/src/sumeragi/mod.rs @@ -176,7 +176,7 @@ impl SumeragiHandle { for block in blocks_iter { let mut state_block = state.block(); recreate_topology = Self::replay_block( - &common_config.chain_id, + &common_config.chain, &genesis_network.public_key, &block, &mut state_block, @@ -196,12 +196,10 @@ impl SumeragiHandle { #[cfg(not(debug_assertions))] let debug_force_soft_fork = false; - let peer_id = common_config.peer_id(); - let sumeragi = main_loop::Sumeragi { - chain_id: common_config.chain_id, + chain_id: common_config.chain, key_pair: common_config.key_pair, - peer_id, + peer_id: common_config.peer, queue: Arc::clone(&queue), events_sender, commit_time: state.view().config.commit_time, diff --git a/core/src/tx.rs b/core/src/tx.rs index 9314a4b9dc8..3fb83e8eb96 100644 --- a/core/src/tx.rs +++ b/core/src/tx.rs @@ -39,7 +39,7 @@ pub enum AcceptTransactionFail { SignatureVerification(#[source] SignatureVerificationFail), /// The genesis account can only sign transactions in the genesis block UnexpectedGenesisAccountSignature, - /// Transaction's `chain_id` doesn't correspond to the id of current blockchain + /// Chain id doesn't correspond to the id of current blockchain ChainIdMismatch(Mismatch), } @@ -54,7 +54,7 @@ impl AcceptedTransaction { expected_chain_id: &ChainId, genesis_public_key: &PublicKey, ) -> Result { - let actual_chain_id = tx.0.chain_id(); + let actual_chain_id = tx.0.chain(); if expected_chain_id != actual_chain_id { return Err(AcceptTransactionFail::ChainIdMismatch(Mismatch { @@ -85,7 +85,7 @@ impl AcceptedTransaction { expected_chain_id: &ChainId, limits: &TransactionLimits, ) -> Result { - let actual_chain_id = tx.chain_id(); + let actual_chain_id = tx.chain(); if expected_chain_id != actual_chain_id { return Err(AcceptTransactionFail::ChainIdMismatch(Mismatch { @@ -94,7 +94,7 @@ impl AcceptedTransaction { })); } - if *iroha_genesis::GENESIS_DOMAIN_ID == *tx.authority().domain_id() { + if *iroha_genesis::GENESIS_DOMAIN_ID == *tx.authority().domain() { return Err(AcceptTransactionFail::UnexpectedGenesisAccountSignature); } @@ -202,10 +202,10 @@ impl TransactionExecutor { if !state_transaction .world - .domain(&authority.domain_id) + .domain(&authority.domain) .map_err(|_e| { TransactionRejectionReason::AccountDoesNotExist(FindError::Domain( - authority.domain_id.clone(), + authority.domain.clone(), )) })? .accounts diff --git a/core/test_network/src/lib.rs b/core/test_network/src/lib.rs index 5bec6392ab5..5e82753638f 100644 --- a/core/test_network/src/lib.rs +++ b/core/test_network/src/lib.rs @@ -91,11 +91,11 @@ impl TestGenesis for GenesisTransaction { let mint_rose_permission = Permission::new( "CanMintAssetWithDefinition".parse().unwrap(), - json!({ "asset_definition_id": rose_definition_id }), + json!({ "asset_definition": rose_definition_id }), ); let burn_rose_permission = Permission::new( "CanBurnAssetWithDefinition".parse().unwrap(), - json!({ "asset_definition_id": rose_definition_id }), + json!({ "asset_definition": rose_definition_id }), ); let unregister_any_peer_permission = Permission::new("CanUnregisterAnyPeer".parse().unwrap(), json!(null)); @@ -103,7 +103,7 @@ impl TestGenesis for GenesisTransaction { Permission::new("CanUnregisterAnyRole".parse().unwrap(), json!(null)); let unregister_wonderland_domain = Permission::new( "CanUnregisterDomain".parse().unwrap(), - json!({ "domain_id": DomainId::from_str("wonderland").unwrap() }), + json!({ "domain": DomainId::from_str("wonderland").unwrap() }), ); let upgrade_executor_permission = Permission::new("CanUpgradeExecutor".parse().unwrap(), json!(null)); @@ -413,7 +413,7 @@ impl Peer { Config { common: Common { key_pair: self.key_pair.clone(), - peer_id: peer_id.clone(), + peer: peer_id.clone(), ..config.common }, network: Network { @@ -812,7 +812,7 @@ impl TestClient for Client { fn test_with_account(api_addr: &SocketAddr, keys: KeyPair, account_id: &AccountId) -> Self { let mut config = ClientConfig::test(api_addr); - config.account_id = account_id.clone(); + config.account = account_id.clone(); config.key_pair = keys; Client::new(config) } diff --git a/data_model/derive/src/has_origin.rs b/data_model/derive/src/has_origin.rs index b6f7fe365e2..0679e7a422f 100644 --- a/data_model/derive/src/has_origin.rs +++ b/data_model/derive/src/has_origin.rs @@ -103,7 +103,7 @@ pub fn impl_has_origin(emitter: &mut Emitter, input: &syn::DeriveInput) -> Token impl #impl_generics HasOrigin for #enum_ident #ty_generics #where_clause { type Origin = #enum_origin; - fn origin_id(&self) -> &::Id { + fn origin(&self) -> &::Id { use #enum_ident::*; match self { #( diff --git a/data_model/derive/src/lib.rs b/data_model/derive/src/lib.rs index c6767957413..2ecf9314397 100644 --- a/data_model/derive/src/lib.rs +++ b/data_model/derive/src/lib.rs @@ -417,7 +417,7 @@ pub fn partially_tagged_deserialize_derive(input: TokenStream) -> Result &sub_layer_event.origin_id().parent_id)] +/// #[has_origin(sub_layer_event => &sub_layer_event.origin().parent)] /// SubLayer(SubLayerEvent), /// Created(LayerId), /// } @@ -436,7 +436,7 @@ pub fn partially_tagged_deserialize_derive(input: TokenStream) -> Result Result Option { - assert_eq!(self.id, asset.id.account_id); - self.assets.insert(asset.id.definition_id.clone(), asset) + assert_eq!(self.id, asset.id.account); + self.assets.insert(asset.id.definition.clone(), asset) } /// Remove asset from the [`Account`] and return it diff --git a/data_model/src/asset.rs b/data_model/src/asset.rs index c3ef6cff67c..6b3972c1e49 100644 --- a/data_model/src/asset.rs +++ b/data_model/src/asset.rs @@ -64,13 +64,13 @@ mod model { SerializeDisplay, IntoSchema, )] - #[display(fmt = "{name}#{domain_id}")] - #[debug(fmt = "{name}#{domain_id}")] + #[display(fmt = "{name}#{domain}")] + #[debug(fmt = "{name}#{domain}")] #[getset(get = "pub")] #[ffi_type] pub struct AssetDefinitionId { /// Domain id. - pub domain_id: DomainId, + pub domain: DomainId, /// Asset name. pub name: Name, } @@ -95,9 +95,9 @@ mod model { #[ffi_type] pub struct AssetId { /// Entity Identification. - pub definition_id: AssetDefinitionId, + pub definition: AssetDefinitionId, /// Account Identification. - pub account_id: AccountId, + pub account: AccountId, } /// Asset definition defines the type of that asset. @@ -409,10 +409,10 @@ impl FromStr for AssetDefinitionId { impl fmt::Display for AssetId { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - if self.definition_id.domain_id == self.account_id.domain_id { - write!(f, "{}##{}", self.definition_id.name, self.account_id) + if self.definition.domain == self.account.domain { + write!(f, "{}##{}", self.definition.name, self.account) } else { - write!(f, "{}#{}", self.definition_id, self.account_id) + write!(f, "{}#{}", self.definition, self.account) } } } @@ -435,7 +435,7 @@ impl FromStr for AssetId { reason: "Failed to parse `account@domain` part in `asset#domain#account@domain`. `account` should have multihash format e.g. `ed0120...`" })?; let domain_complement = if definition_id_candidate.ends_with('#') { - account_id.domain_id.name.as_ref() + account_id.domain.name.as_ref() } else { "" }; diff --git a/data_model/src/events/data/events.rs b/data_model/src/events/data/events.rs index 5222a3f311e..766872cc0d2 100644 --- a/data_model/src/events/data/events.rs +++ b/data_model/src/events/data/events.rs @@ -59,7 +59,7 @@ mod model { //#[getset(get = "pub")] #[ffi_type] pub struct MetadataChanged { - pub target_id: Id, + pub target: Id, pub key: Name, pub value: MetadataValueBox, } @@ -113,13 +113,13 @@ mod asset { #[has_origin(asset => asset.id())] Created(Asset), Deleted(AssetId), - #[has_origin(asset_changed => &asset_changed.asset_id)] + #[has_origin(asset_changed => &asset_changed.asset)] Added(AssetChanged), - #[has_origin(asset_changed => &asset_changed.asset_id)] + #[has_origin(asset_changed => &asset_changed.asset)] Removed(AssetChanged), - #[has_origin(metadata_changed => &metadata_changed.target_id)] + #[has_origin(metadata_changed => &metadata_changed.target)] MetadataInserted(AssetMetadataChanged), - #[has_origin(metadata_changed => &metadata_changed.target_id)] + #[has_origin(metadata_changed => &metadata_changed.target)] MetadataRemoved(AssetMetadataChanged), } } @@ -130,14 +130,14 @@ mod asset { #[has_origin(asset_definition => asset_definition.id())] Created(AssetDefinition), MintabilityChanged(AssetDefinitionId), - #[has_origin(ownership_changed => &ownership_changed.asset_definition_id)] + #[has_origin(ownership_changed => &ownership_changed.asset_definition)] OwnerChanged(AssetDefinitionOwnerChanged), Deleted(AssetDefinitionId), - #[has_origin(metadata_changed => &metadata_changed.target_id)] + #[has_origin(metadata_changed => &metadata_changed.target)] MetadataInserted(AssetDefinitionMetadataChanged), - #[has_origin(metadata_changed => &metadata_changed.target_id)] + #[has_origin(metadata_changed => &metadata_changed.target)] MetadataRemoved(AssetDefinitionMetadataChanged), - #[has_origin(total_quantity_changed => &total_quantity_changed.asset_definition_id)] + #[has_origin(total_quantity_changed => &total_quantity_changed.asset_definition)] TotalQuantityChanged(AssetDefinitionTotalQuantityChanged), } } @@ -164,7 +164,7 @@ mod asset { #[getset(get = "pub")] #[ffi_type] pub struct AssetChanged { - pub asset_id: AssetId, + pub asset: AssetId, pub amount: AssetValue, } @@ -186,7 +186,7 @@ mod asset { #[getset(get = "pub")] #[ffi_type] pub struct AssetDefinitionTotalQuantityChanged { - pub asset_definition_id: AssetDefinitionId, + pub asset_definition: AssetDefinitionId, pub total_amount: Numeric, } @@ -209,7 +209,7 @@ mod asset { #[ffi_type] pub struct AssetDefinitionOwnerChanged { /// Id of asset definition being updated - pub asset_definition_id: AssetDefinitionId, + pub asset_definition: AssetDefinitionId, /// Id of new owning account pub new_owner: AccountId, } @@ -246,11 +246,11 @@ mod role { Deleted(RoleId), /// [`Permission`]s with particular [`PermissionId`] /// were removed from the role. - #[has_origin(permission_removed => &permission_removed.role_id)] + #[has_origin(permission_removed => &permission_removed.role)] PermissionRemoved(RolePermissionChanged), /// [`Permission`]s with particular [`PermissionId`] /// were removed added to the role. - #[has_origin(permission_added => &permission_added.role_id)] + #[has_origin(permission_added => &permission_added.role)] PermissionAdded(RolePermissionChanged), } } @@ -277,10 +277,10 @@ mod role { #[getset(get = "pub")] #[ffi_type] pub struct RolePermissionChanged { - pub role_id: RoleId, + pub role: RoleId, // TODO: Skipped temporarily because of FFI #[getset(skip)] - pub permission_id: PermissionId, + pub permission: PermissionId, } } } @@ -298,24 +298,24 @@ mod account { data_event! { #[has_origin(origin = Account)] pub enum AccountEvent { - #[has_origin(asset_event => &asset_event.origin_id().account_id)] + #[has_origin(asset_event => &asset_event.origin().account)] Asset(AssetEvent), #[has_origin(account => account.id())] Created(Account), Deleted(AccountId), AuthenticationAdded(AccountId), AuthenticationRemoved(AccountId), - #[has_origin(permission_changed => &permission_changed.account_id)] + #[has_origin(permission_changed => &permission_changed.account)] PermissionAdded(AccountPermissionChanged), - #[has_origin(permission_changed => &permission_changed.account_id)] + #[has_origin(permission_changed => &permission_changed.account)] PermissionRemoved(AccountPermissionChanged), - #[has_origin(role_changed => &role_changed.account_id)] + #[has_origin(role_changed => &role_changed.account)] RoleRevoked(AccountRoleChanged), - #[has_origin(role_changed => &role_changed.account_id)] + #[has_origin(role_changed => &role_changed.account)] RoleGranted(AccountRoleChanged), - #[has_origin(metadata_changed => &metadata_changed.target_id)] + #[has_origin(metadata_changed => &metadata_changed.target)] MetadataInserted(AccountMetadataChanged), - #[has_origin(metadata_changed => &metadata_changed.target_id)] + #[has_origin(metadata_changed => &metadata_changed.target)] MetadataRemoved(AccountMetadataChanged), } } @@ -342,10 +342,10 @@ mod account { #[getset(get = "pub")] #[ffi_type] pub struct AccountPermissionChanged { - pub account_id: AccountId, + pub account: AccountId, // TODO: Skipped temporarily because of FFI #[getset(skip)] - pub permission_id: PermissionId, + pub permission: PermissionId, } /// Depending on the wrapping event, [`AccountRoleChanged`] represents the granted or revoked role @@ -366,15 +366,15 @@ mod account { #[getset(get = "pub")] #[ffi_type] pub struct AccountRoleChanged { - pub account_id: AccountId, - pub role_id: RoleId, + pub account: AccountId, + pub role: RoleId, } } impl AccountPermissionChanged { /// Get permission id - pub fn permission_id(&self) -> &PermissionId { - &self.permission_id + pub fn permission(&self) -> &PermissionId { + &self.permission } } } @@ -390,18 +390,18 @@ mod domain { data_event! { #[has_origin(origin = Domain)] pub enum DomainEvent { - #[has_origin(account_event => &account_event.origin_id().domain_id)] + #[has_origin(account_event => &account_event.origin().domain)] Account(AccountEvent), - #[has_origin(asset_definition_event => &asset_definition_event.origin_id().domain_id)] + #[has_origin(asset_definition_event => &asset_definition_event.origin().domain)] AssetDefinition(AssetDefinitionEvent), #[has_origin(domain => domain.id())] Created(Domain), Deleted(DomainId), - #[has_origin(metadata_changed => &metadata_changed.target_id)] + #[has_origin(metadata_changed => &metadata_changed.target)] MetadataInserted(DomainMetadataChanged), - #[has_origin(metadata_changed => &metadata_changed.target_id)] + #[has_origin(metadata_changed => &metadata_changed.target)] MetadataRemoved(DomainMetadataChanged), - #[has_origin(owner_changed => &owner_changed.domain_id)] + #[has_origin(owner_changed => &owner_changed.domain)] OwnerChanged(DomainOwnerChanged), } } @@ -428,7 +428,7 @@ mod domain { #[getset(get = "pub")] #[ffi_type] pub struct DomainOwnerChanged { - pub domain_id: DomainId, + pub domain: DomainId, pub new_owner: AccountId, } } @@ -449,13 +449,13 @@ mod trigger { pub enum TriggerEvent { Created(TriggerId), Deleted(TriggerId), - #[has_origin(number_of_executions_changed => &number_of_executions_changed.trigger_id)] + #[has_origin(number_of_executions_changed => &number_of_executions_changed.trigger)] Extended(TriggerNumberOfExecutionsChanged), - #[has_origin(number_of_executions_changed => &number_of_executions_changed.trigger_id)] + #[has_origin(number_of_executions_changed => &number_of_executions_changed.trigger)] Shortened(TriggerNumberOfExecutionsChanged), - #[has_origin(metadata_changed => &metadata_changed.target_id)] + #[has_origin(metadata_changed => &metadata_changed.target)] MetadataInserted(TriggerMetadataChanged), - #[has_origin(metadata_changed => &metadata_changed.target_id)] + #[has_origin(metadata_changed => &metadata_changed.target)] MetadataRemoved(TriggerMetadataChanged), } } @@ -482,7 +482,7 @@ mod trigger { #[getset(get = "pub")] #[ffi_type] pub struct TriggerNumberOfExecutionsChanged { - pub trigger_id: TriggerId, + pub trigger: TriggerId, pub by: u32, } } @@ -571,7 +571,7 @@ pub trait HasOrigin { /// Type of the origin. type Origin: Identifiable; /// Identification of the origin. - fn origin_id(&self) -> &::Id; + fn origin(&self) -> &::Id; } impl From for DataEvent { @@ -594,9 +594,9 @@ impl From for DataEvent { impl DataEvent { /// Return the domain id of [`Event`] - pub fn domain_id(&self) -> Option<&DomainId> { + pub fn domain(&self) -> Option<&DomainId> { match self { - Self::Domain(event) => Some(event.origin_id()), + Self::Domain(event) => Some(event.origin()), Self::Configuration(_) | Self::Executor(_) | Self::Peer(_) @@ -607,12 +607,12 @@ impl DataEvent { } impl MetadataChanged { - /// Getter for `target_id` - pub fn target_id(&self) -> &Id { - &self.target_id + /// Getter for `target` + pub fn target(&self) -> &Id { + &self.target } - /// Getter for `target_id` + /// Getter for metadata key pub fn key(&self) -> &Name { &self.key } diff --git a/data_model/src/events/data/filters.rs b/data_model/src/events/data/filters.rs index 58840eb68bc..db34033eb82 100644 --- a/data_model/src/events/data/filters.rs +++ b/data_model/src/events/data/filters.rs @@ -287,7 +287,7 @@ impl EventFilter for PeerEventFilter { fn matches(&self, event: &Self::Event) -> bool { if let Some(id_matcher) = &self.id_matcher { - if id_matcher != event.origin_id() { + if id_matcher != event.origin() { return false; } } @@ -336,7 +336,7 @@ impl EventFilter for DomainEventFilter { fn matches(&self, event: &Self::Event) -> bool { if let Some(id_matcher) = &self.id_matcher { - if id_matcher != event.origin_id() { + if id_matcher != event.origin() { return false; } } @@ -385,7 +385,7 @@ impl super::EventFilter for AccountEventFilter { fn matches(&self, event: &Self::Event) -> bool { if let Some(id_matcher) = &self.id_matcher { - if id_matcher != event.origin_id() { + if id_matcher != event.origin() { return false; } } @@ -434,7 +434,7 @@ impl super::EventFilter for AssetEventFilter { fn matches(&self, event: &Self::Event) -> bool { if let Some(id_matcher) = &self.id_matcher { - if id_matcher != event.origin_id() { + if id_matcher != event.origin() { return false; } } @@ -483,7 +483,7 @@ impl super::EventFilter for AssetDefinitionEventFilter { fn matches(&self, event: &Self::Event) -> bool { if let Some(id_matcher) = &self.id_matcher { - if id_matcher != event.origin_id() { + if id_matcher != event.origin() { return false; } } @@ -532,7 +532,7 @@ impl super::EventFilter for TriggerEventFilter { fn matches(&self, event: &Self::Event) -> bool { if let Some(id_matcher) = &self.id_matcher { - if id_matcher != event.origin_id() { + if id_matcher != event.origin() { return false; } } @@ -581,7 +581,7 @@ impl super::EventFilter for RoleEventFilter { fn matches(&self, event: &Self::Event) -> bool { if let Some(id_matcher) = &self.id_matcher { - if id_matcher != event.origin_id() { + if id_matcher != event.origin() { return false; } } @@ -630,7 +630,7 @@ impl super::EventFilter for ConfigurationEventFilter { fn matches(&self, event: &Self::Event) -> bool { if let Some(id_matcher) = &self.id_matcher { - if id_matcher != event.origin_id() { + if id_matcher != event.origin() { return false; } } diff --git a/data_model/src/isi.rs b/data_model/src/isi.rs index 07bb86c0385..c7024cb8d2f 100644 --- a/data_model/src/isi.rs +++ b/data_model/src/isi.rs @@ -280,7 +280,7 @@ mod transparent { #[schema(bounds = "O: Identifiable, O::Id: IntoSchema")] pub struct SetKeyValue { /// Where to set key value. - pub object_id: O::Id, + pub object: O::Id, /// Key. pub key: Name, /// Value. @@ -292,7 +292,7 @@ mod transparent { /// 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 { Self { - object_id: domain_id, + object: domain_id, key, value: value.into(), } @@ -307,7 +307,7 @@ mod transparent { value: impl Into, ) -> Self { Self { - object_id: account_id, + object: account_id, key, value: value.into(), } @@ -322,7 +322,7 @@ mod transparent { value: impl Into, ) -> Self { Self { - object_id: asset_definition_id, + object: asset_definition_id, key, value: value.into(), } @@ -333,7 +333,7 @@ mod transparent { /// 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 { Self { - object_id: asset_id, + object: asset_id, key, value: value.into(), } @@ -348,7 +348,7 @@ mod transparent { value: impl Into, ) -> Self { Self { - object_id: trigger_id, + object: trigger_id, key, value: value.into(), } @@ -362,7 +362,7 @@ mod transparent { O::Id: Display, => "SET `{}` = `{}` IN `{}`", - key, value, object_id, + key, value, object, } impl_into_box! { @@ -380,7 +380,7 @@ mod transparent { #[schema(bounds = "O: Identifiable, O::Id: IntoSchema")] pub struct RemoveKeyValue { /// From where to remove key value. - pub object_id: O::Id, + pub object: O::Id, /// Key of the pair to remove. pub key: Name, } @@ -390,7 +390,7 @@ mod transparent { /// Constructs a new [`RemoveKeyValue`] for a [`Domain`] with the given `key`. pub fn domain(domain_id: DomainId, key: Name) -> Self { Self { - object_id: domain_id, + object: domain_id, key, } } @@ -400,7 +400,7 @@ mod transparent { /// Constructs a new [`RemoveKeyValue`] for an [`Account`] with the given `key`. pub fn account(account_id: AccountId, key: Name) -> Self { Self { - object_id: account_id, + object: account_id, key, } } @@ -410,7 +410,7 @@ mod transparent { /// Constructs a new [`RemoveKeyValue`] for an [`AssetDefinition`] with the given `key`. pub fn asset_definition(asset_definition_id: AssetDefinitionId, key: Name) -> Self { Self { - object_id: asset_definition_id, + object: asset_definition_id, key, } } @@ -420,7 +420,7 @@ mod transparent { /// Constructs a new [`RemoveKeyValue`] for an [`Asset`] with the given `key`. pub fn asset(asset_id: AssetId, key: Name) -> Self { Self { - object_id: asset_id, + object: asset_id, key, } } @@ -430,7 +430,7 @@ mod transparent { /// Constructs a new [`RemoveKeyValue`] for an [`Asset`] with the given `key`. pub fn trigger(trigger_id: TriggerId, key: Name) -> Self { Self { - object_id: trigger_id, + object: trigger_id, key, } } @@ -443,7 +443,7 @@ mod transparent { O::Id: Display, => "REMOVE `{}` from `{}`", - key, object_id, + key, object, } impl_into_box! { @@ -548,7 +548,7 @@ mod transparent { #[schema(bounds = "O: Identifiable, O::Id: IntoSchema")] pub struct Unregister { /// [`Identifiable::Id`] of the object which should be unregistered. - pub object_id: O::Id, + pub object: O::Id, } } @@ -559,7 +559,7 @@ mod transparent { O::Id: Display, => "UNREGISTER `{}`", - object_id, + object, } impl_into_box! { @@ -577,25 +577,21 @@ mod transparent { impl Unregister { /// Constructs a new [`Unregister`] for a [`Peer`]. pub fn peer(peer_id: PeerId) -> Self { - Self { object_id: peer_id } + Self { object: peer_id } } } impl Unregister { /// Constructs a new [`Unregister`] for a [`Domain`]. pub fn domain(domain_id: DomainId) -> Self { - Self { - object_id: domain_id, - } + Self { object: domain_id } } } impl Unregister { /// Constructs a new [`Unregister`] for an [`Account`]. pub fn account(account_id: AccountId) -> Self { - Self { - object_id: account_id, - } + Self { object: account_id } } } @@ -603,7 +599,7 @@ mod transparent { /// Constructs a new [`Unregister`] for an [`AssetDefinition`]. pub fn asset_definition(asset_definition_id: AssetDefinitionId) -> Self { Self { - object_id: asset_definition_id, + object: asset_definition_id, } } } @@ -611,25 +607,21 @@ mod transparent { impl Unregister { /// Constructs a new [`Unregister`] for an [`Asset`]. pub fn asset(asset_id: AssetId) -> Self { - Self { - object_id: asset_id, - } + Self { object: asset_id } } } impl Unregister { /// Constructs a new [`Unregister`] for a [`Role`]. pub fn role(role_id: RoleId) -> Self { - Self { object_id: role_id } + Self { object: role_id } } } impl Unregister { /// Constructs a new [`Unregister`] for a [`Trigger`]. pub fn trigger(trigger_id: TriggerId) -> Self { - Self { - object_id: trigger_id, - } + Self { object: trigger_id } } } @@ -640,7 +632,7 @@ mod transparent { /// Object which should be minted. pub object: O, /// Destination object [`Identifiable::Id`]. - pub destination_id: D::Id, + pub destination: D::Id, } } @@ -649,7 +641,7 @@ mod transparent { pub fn asset_numeric(object: impl Into, asset_id: AssetId) -> Self { Self { object: object.into(), - destination_id: asset_id, + destination: asset_id, } } } @@ -659,7 +651,7 @@ mod transparent { pub fn trigger_repetitions(repetitions: u32, trigger_id: TriggerId) -> Self { Self { object: repetitions, - destination_id: trigger_id, + destination: trigger_id, } } } @@ -673,7 +665,7 @@ mod transparent { => "MINT `{}` TO `{}`", object, - destination_id, + destination, } impl_into_box! { @@ -690,7 +682,7 @@ mod transparent { /// Object which should be burned. pub object: O, /// Destination object [`Identifiable::Id`]. - pub destination_id: D::Id, + pub destination: D::Id, } } @@ -699,7 +691,7 @@ mod transparent { pub fn asset_numeric(object: impl Into, asset_id: AssetId) -> Self { Self { object: object.into(), - destination_id: asset_id, + destination: asset_id, } } } @@ -709,7 +701,7 @@ mod transparent { pub fn trigger_repetitions(repetitions: u32, trigger_id: TriggerId) -> Self { Self { object: repetitions, - destination_id: trigger_id, + destination: trigger_id, } } } @@ -723,7 +715,7 @@ mod transparent { => "BURN `{}` FROM `{}`", object, - destination_id, + destination, } impl_into_box! { @@ -740,11 +732,11 @@ mod transparent { D: Identifiable, D::Id: IntoSchema")] pub struct Transfer { /// Source object `Id`. - pub source_id: S::Id, + pub source: S::Id, /// Object which should be transferred. pub object: O, /// Destination object `Id`. - pub destination_id: D::Id, + pub destination: D::Id, } } @@ -752,9 +744,9 @@ mod transparent { /// Constructs a new [`Transfer`] for a [`Domain`]. pub fn domain(from: AccountId, domain_id: DomainId, to: AccountId) -> Self { Self { - source_id: from, + source: from, object: domain_id, - destination_id: to, + destination: to, } } } @@ -767,9 +759,9 @@ mod transparent { to: AccountId, ) -> Self { Self { - source_id: from, + source: from, object: asset_definition_id, - destination_id: to, + destination: to, } } } @@ -782,9 +774,9 @@ mod transparent { to: AccountId, ) -> Self { Self { - source_id: asset_id, + source: asset_id, object: quantity.into(), - destination_id: to, + destination: to, } } } @@ -793,9 +785,9 @@ mod transparent { /// Constructs a new [`Transfer`] for an [`Asset`] of [`Store`] type. pub fn asset_store(asset_id: AssetId, to: AccountId) -> Self { Self { - source_id: asset_id, + source: asset_id, object: Metadata::new(), - destination_id: to, + destination: to, } } } @@ -811,8 +803,8 @@ mod transparent { => "TRANSFER `{}` FROM `{}` TO `{}`", object, - source_id, - destination_id, + source, + destination, } impl_into_box! { @@ -848,7 +840,7 @@ mod transparent { /// Object to grant. pub object: O, /// Entity to which to grant this token. - pub destination_id: D::Id, + pub destination: D::Id, } } @@ -857,7 +849,7 @@ mod transparent { pub fn permission(permission: Permission, to: AccountId) -> Self { Self { object: permission, - destination_id: to, + destination: to, } } } @@ -867,7 +859,7 @@ mod transparent { pub fn role(role_id: RoleId, to: AccountId) -> Self { Self { object: role_id, - destination_id: to, + destination: to, } } } @@ -877,7 +869,7 @@ mod transparent { pub fn role_permission(permission: Permission, to: RoleId) -> Self { Self { object: permission, - destination_id: to, + destination: to, } } } @@ -891,7 +883,7 @@ mod transparent { => "GRANT `{}` TO `{}`", object, - destination_id, + destination, } impl_into_box! { @@ -909,7 +901,7 @@ mod transparent { /// Object to revoke. pub object: O, /// Entity which is being revoked this token from. - pub destination_id: D::Id, + pub destination: D::Id, } } @@ -918,7 +910,7 @@ mod transparent { pub fn permission(permission: Permission, from: AccountId) -> Self { Self { object: permission, - destination_id: from, + destination: from, } } } @@ -928,7 +920,7 @@ mod transparent { pub fn role(role_id: RoleId, from: AccountId) -> Self { Self { object: role_id, - destination_id: from, + destination: from, } } } @@ -938,7 +930,7 @@ mod transparent { pub fn role_permission(permission: Permission, from: RoleId) -> Self { Self { object: permission, - destination_id: from, + destination: from, } } } @@ -952,7 +944,7 @@ mod transparent { => "REVOKE `{}` FROM `{}`", object, - destination_id, + destination, } impl_into_box! { @@ -966,12 +958,12 @@ mod transparent { isi! { /// Instruction to execute specified trigger #[derive(Constructor, Display)] - #[display(fmt = "EXECUTE `{trigger_id}`")] + #[display(fmt = "EXECUTE `{trigger}`")] #[serde(transparent)] #[repr(transparent)] pub struct ExecuteTrigger { /// Id of a trigger to execute - pub trigger_id: TriggerId, + pub trigger: TriggerId, } } diff --git a/data_model/src/transaction.rs b/data_model/src/transaction.rs index 9b8bbc83c8c..edd2ef7cf20 100644 --- a/data_model/src/transaction.rs +++ b/data_model/src/transaction.rs @@ -98,7 +98,7 @@ mod model { )] pub(crate) struct TransactionPayload { /// Unique id of the blockchain. Used for simple replay attack protection. - pub chain_id: ChainId, + pub chain: ChainId, /// Account ID of transaction creator. /// TODO dedup public keys in transaction #4410 pub authority: AccountId, @@ -286,9 +286,9 @@ impl SignedTransaction { /// Transaction chain id #[inline] - pub fn chain_id(&self) -> &ChainId { + pub fn chain(&self) -> &ChainId { let SignedTransaction::V1(tx) = self; - &tx.payload.chain_id + &tx.payload.chain } /// Return the transaction signature @@ -630,10 +630,10 @@ mod http { impl TransactionBuilder { #[cfg(feature = "std")] - fn new_with_time(chain_id: ChainId, authority: AccountId, creation_time_ms: u64) -> Self { + fn new_with_time(chain: ChainId, authority: AccountId, creation_time_ms: u64) -> Self { Self { payload: TransactionPayload { - chain_id, + chain, authority, creation_time_ms, nonce: None, diff --git a/docs/source/references/schema.json b/docs/source/references/schema.json index cc30a9c8d14..723a4f4710a 100644 --- a/docs/source/references/schema.json +++ b/docs/source/references/schema.json @@ -140,7 +140,7 @@ "AccountId": { "Struct": [ { - "name": "domain_id", + "name": "domain", "type": "DomainId" }, { @@ -152,11 +152,11 @@ "AccountPermissionChanged": { "Struct": [ { - "name": "account_id", + "name": "account", "type": "AccountId" }, { - "name": "permission_id", + "name": "permission", "type": "PermissionId" } ] @@ -164,11 +164,11 @@ "AccountRoleChanged": { "Struct": [ { - "name": "account_id", + "name": "account", "type": "AccountId" }, { - "name": "role_id", + "name": "role", "type": "RoleId" } ] @@ -250,7 +250,7 @@ "AssetChanged": { "Struct": [ { - "name": "asset_id", + "name": "asset", "type": "AssetId" }, { @@ -376,7 +376,7 @@ "AssetDefinitionId": { "Struct": [ { - "name": "domain_id", + "name": "domain", "type": "DomainId" }, { @@ -388,7 +388,7 @@ "AssetDefinitionOwnerChanged": { "Struct": [ { - "name": "asset_definition_id", + "name": "asset_definition", "type": "AssetDefinitionId" }, { @@ -400,7 +400,7 @@ "AssetDefinitionTotalQuantityChanged": { "Struct": [ { - "name": "asset_definition_id", + "name": "asset_definition", "type": "AssetDefinitionId" }, { @@ -489,11 +489,11 @@ "AssetId": { "Struct": [ { - "name": "definition_id", + "name": "definition", "type": "AssetDefinitionId" }, { - "name": "account_id", + "name": "account", "type": "AccountId" } ] @@ -686,7 +686,7 @@ "type": "Numeric" }, { - "name": "destination_id", + "name": "destination", "type": "AssetId" } ] @@ -698,7 +698,7 @@ "type": "u32" }, { - "name": "destination_id", + "name": "destination", "type": "TriggerId" } ] @@ -1057,7 +1057,7 @@ "DomainOwnerChanged": { "Struct": [ { - "name": "domain_id", + "name": "domain", "type": "DomainId" }, { @@ -1149,7 +1149,7 @@ "ExecuteTrigger": { "Struct": [ { - "name": "trigger_id", + "name": "trigger", "type": "TriggerId" } ] @@ -1632,7 +1632,7 @@ "type": "Permission" }, { - "name": "destination_id", + "name": "destination", "type": "AccountId" } ] @@ -1644,7 +1644,7 @@ "type": "Permission" }, { - "name": "destination_id", + "name": "destination", "type": "RoleId" } ] @@ -1656,7 +1656,7 @@ "type": "RoleId" }, { - "name": "destination_id", + "name": "destination", "type": "AccountId" } ] @@ -2160,7 +2160,7 @@ "MetadataChanged": { "Struct": [ { - "name": "target_id", + "name": "target", "type": "AccountId" }, { @@ -2176,7 +2176,7 @@ "MetadataChanged": { "Struct": [ { - "name": "target_id", + "name": "target", "type": "AssetDefinitionId" }, { @@ -2192,7 +2192,7 @@ "MetadataChanged": { "Struct": [ { - "name": "target_id", + "name": "target", "type": "AssetId" }, { @@ -2208,7 +2208,7 @@ "MetadataChanged": { "Struct": [ { - "name": "target_id", + "name": "target", "type": "DomainId" }, { @@ -2224,7 +2224,7 @@ "MetadataChanged": { "Struct": [ { - "name": "target_id", + "name": "target", "type": "TriggerId" }, { @@ -2311,7 +2311,7 @@ "type": "Numeric" }, { - "name": "destination_id", + "name": "destination", "type": "AssetId" } ] @@ -2323,7 +2323,7 @@ "type": "u32" }, { - "name": "destination_id", + "name": "destination", "type": "TriggerId" } ] @@ -3146,7 +3146,7 @@ "RemoveKeyValue": { "Struct": [ { - "name": "object_id", + "name": "object", "type": "AccountId" }, { @@ -3158,7 +3158,7 @@ "RemoveKeyValue": { "Struct": [ { - "name": "object_id", + "name": "object", "type": "AssetId" }, { @@ -3170,7 +3170,7 @@ "RemoveKeyValue": { "Struct": [ { - "name": "object_id", + "name": "object", "type": "AssetDefinitionId" }, { @@ -3182,7 +3182,7 @@ "RemoveKeyValue": { "Struct": [ { - "name": "object_id", + "name": "object", "type": "DomainId" }, { @@ -3194,7 +3194,7 @@ "RemoveKeyValue": { "Struct": [ { - "name": "object_id", + "name": "object", "type": "TriggerId" }, { @@ -3264,7 +3264,7 @@ "type": "Permission" }, { - "name": "destination_id", + "name": "destination", "type": "AccountId" } ] @@ -3276,7 +3276,7 @@ "type": "Permission" }, { - "name": "destination_id", + "name": "destination", "type": "RoleId" } ] @@ -3288,7 +3288,7 @@ "type": "RoleId" }, { - "name": "destination_id", + "name": "destination", "type": "AccountId" } ] @@ -3394,11 +3394,11 @@ "RolePermissionChanged": { "Struct": [ { - "name": "role_id", + "name": "role", "type": "RoleId" }, { - "name": "permission_id", + "name": "permission", "type": "PermissionId" } ] @@ -3451,7 +3451,7 @@ "SetKeyValue": { "Struct": [ { - "name": "object_id", + "name": "object", "type": "AccountId" }, { @@ -3467,7 +3467,7 @@ "SetKeyValue": { "Struct": [ { - "name": "object_id", + "name": "object", "type": "AssetId" }, { @@ -3483,7 +3483,7 @@ "SetKeyValue": { "Struct": [ { - "name": "object_id", + "name": "object", "type": "AssetDefinitionId" }, { @@ -3499,7 +3499,7 @@ "SetKeyValue": { "Struct": [ { - "name": "object_id", + "name": "object", "type": "DomainId" }, { @@ -3515,7 +3515,7 @@ "SetKeyValue": { "Struct": [ { - "name": "object_id", + "name": "object", "type": "TriggerId" }, { @@ -3870,7 +3870,7 @@ "TransactionPayload": { "Struct": [ { - "name": "chain_id", + "name": "chain", "type": "ChainId" }, { @@ -3964,7 +3964,7 @@ "Transfer": { "Struct": [ { - "name": "source_id", + "name": "source", "type": "AccountId" }, { @@ -3972,7 +3972,7 @@ "type": "AssetDefinitionId" }, { - "name": "destination_id", + "name": "destination", "type": "AccountId" } ] @@ -3980,7 +3980,7 @@ "Transfer": { "Struct": [ { - "name": "source_id", + "name": "source", "type": "AccountId" }, { @@ -3988,7 +3988,7 @@ "type": "DomainId" }, { - "name": "destination_id", + "name": "destination", "type": "AccountId" } ] @@ -3996,7 +3996,7 @@ "Transfer": { "Struct": [ { - "name": "source_id", + "name": "source", "type": "AssetId" }, { @@ -4004,7 +4004,7 @@ "type": "Metadata" }, { - "name": "destination_id", + "name": "destination", "type": "AccountId" } ] @@ -4012,7 +4012,7 @@ "Transfer": { "Struct": [ { - "name": "source_id", + "name": "source", "type": "AssetId" }, { @@ -4020,7 +4020,7 @@ "type": "Numeric" }, { - "name": "destination_id", + "name": "destination", "type": "AccountId" } ] @@ -4193,7 +4193,7 @@ "TriggerNumberOfExecutionsChanged": { "Struct": [ { - "name": "trigger_id", + "name": "trigger", "type": "TriggerId" }, { @@ -4248,7 +4248,7 @@ "Unregister": { "Struct": [ { - "name": "object_id", + "name": "object", "type": "AccountId" } ] @@ -4256,7 +4256,7 @@ "Unregister": { "Struct": [ { - "name": "object_id", + "name": "object", "type": "AssetId" } ] @@ -4264,7 +4264,7 @@ "Unregister": { "Struct": [ { - "name": "object_id", + "name": "object", "type": "AssetDefinitionId" } ] @@ -4272,7 +4272,7 @@ "Unregister": { "Struct": [ { - "name": "object_id", + "name": "object", "type": "DomainId" } ] @@ -4280,7 +4280,7 @@ "Unregister": { "Struct": [ { - "name": "object_id", + "name": "object", "type": "PeerId" } ] @@ -4288,7 +4288,7 @@ "Unregister": { "Struct": [ { - "name": "object_id", + "name": "object", "type": "RoleId" } ] @@ -4296,7 +4296,7 @@ "Unregister": { "Struct": [ { - "name": "object_id", + "name": "object", "type": "TriggerId" } ] diff --git a/scripts/test_env.py b/scripts/test_env.py index 1a45b3b4e0b..5bf7d5991c4 100755 --- a/scripts/test_env.py +++ b/scripts/test_env.py @@ -40,7 +40,7 @@ def __init__(self, args: argparse.Namespace): genesis_public_key = self.peers[0].public_key genesis_private_key = self.peers[0].private_key shared_config = { - "chain_id": "00000000-0000-0000-0000-000000000000", + "chain": "00000000-0000-0000-0000-000000000000", "genesis": { "public_key": genesis_public_key }, @@ -247,7 +247,7 @@ def setup(args: argparse.Namespace): def cleanup(out_dir: pathlib.Path): logging.info("Killing peer processes...") - subprocess.run(["pkill", "-9", "irohad"]) + subprocess.run(["pkill", "-9", "iroha"]) logging.info(f"Cleaning up test directory `{out_dir}`...") shutil.rmtree(out_dir) diff --git a/smart_contract/executor/derive/src/conversion.rs b/smart_contract/executor/derive/src/conversion.rs index 4ea3e505f2b..561224350b1 100644 --- a/smart_contract/executor/derive/src/conversion.rs +++ b/smart_contract/executor/derive/src/conversion.rs @@ -10,7 +10,7 @@ pub fn impl_derive_ref_into_asset_owner(input: &DeriveInput) -> TokenStream { &input.ident, &input.generics, &syn::parse_quote!(::iroha_executor::permission::asset::Owner), - &syn::parse_quote!(asset_id), + &syn::parse_quote!(asset), ) } @@ -21,7 +21,7 @@ pub fn impl_derive_ref_into_asset_definition_owner(input: &DeriveInput) -> Token &input.ident, &input.generics, &syn::parse_quote!(::iroha_executor::permission::asset_definition::Owner), - &syn::parse_quote!(asset_definition_id), + &syn::parse_quote!(asset_definition), ) } @@ -31,7 +31,7 @@ pub fn impl_derive_ref_into_account_owner(input: &DeriveInput) -> TokenStream { &input.ident, &input.generics, &syn::parse_quote!(::iroha_executor::permission::account::Owner), - &syn::parse_quote!(account_id), + &syn::parse_quote!(account), ) } @@ -41,7 +41,7 @@ pub fn impl_derive_ref_into_domain_owner(input: &DeriveInput) -> TokenStream { &input.ident, &input.generics, &syn::parse_quote!(::iroha_executor::permission::domain::Owner), - &syn::parse_quote!(domain_id), + &syn::parse_quote!(domain), ) } diff --git a/smart_contract/executor/derive/src/lib.rs b/smart_contract/executor/derive/src/lib.rs index 962cbd794a1..4b11347a112 100644 --- a/smart_contract/executor/derive/src/lib.rs +++ b/smart_contract/executor/derive/src/lib.rs @@ -75,7 +75,7 @@ pub fn entrypoint(attr: TokenStream, item: TokenStream) -> TokenStream { /// #[validate(permission::asset::Owner)] /// struct CanDoSomethingWithAsset { /// some_data: String, -/// asset_id: AssetId, +/// asset: AssetId, /// } /// /// #[entrypoint(params = "[authority, operation]")] @@ -88,7 +88,7 @@ pub fn entrypoint(attr: TokenStream, item: TokenStream) -> TokenStream { /// /// CanDoSomethingWithAsset { /// some_data: "some data".to_owned(), -/// asset_id: parse!(AssetId, "rose##ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland"), +/// asset: parse!(AssetId, "rose##ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland"), /// }.is_owned_by(&authority) /// } /// ``` @@ -174,7 +174,7 @@ pub fn derive_validate_grant_revoke(input: TokenStream) -> Result { /// Should be used together with [`ValidateGrantRevoke`] derive macro to derive a conversion /// from your token to a `permission::asset_definition::Owner` type. /// -/// Requires `asset_definition_id` field in the token. +/// Requires `asset_definition` field in the token. /// /// Implements [`From`] for `permission::asset_definition::Owner` /// and not [`Into`] for your type. [`Into`] will be implemented automatically. @@ -191,7 +191,7 @@ pub fn derive_ref_into_asset_definition_owner(input: TokenStream) -> Result Result { /// Should be used together with [`ValidateGrantRevoke`] derive macro to derive a conversion /// from your token to a `permission::account::Owner` type. /// -/// Requires `account_id` field in the token. +/// Requires `account` field in the token. /// /// Implements [`From`] for `permission::asset::Owner` /// and not [`Into`] for your type. [`Into`] will be implemented automatically. @@ -221,7 +221,7 @@ pub fn derive_ref_into_account_owner(input: TokenStream) -> Result /// Should be used together with [`ValidateGrantRevoke`] derive macro to derive a conversion /// from your token to a `permission::domain::Owner` type. /// -/// Requires `domain_id` field in the token. +/// Requires `domain` field in the token. /// /// Implements [`From`] for `permission::domain::Owner` /// and not [`Into`] for your type. [`Into`] will be implemented automatically. diff --git a/smart_contract/executor/src/default.rs b/smart_contract/executor/src/default.rs index 26c4a6707b3..6a685fa757f 100644 --- a/smart_contract/executor/src/default.rs +++ b/smart_contract/executor/src/default.rs @@ -186,7 +186,7 @@ pub mod domain { authority: &AccountId, isi: &Unregister, ) { - let domain_id = isi.object_id(); + let domain_id = isi.object(); if is_genesis(executor) || match is_domain_owner(domain_id, authority) { @@ -195,7 +195,7 @@ pub mod domain { } || { let can_unregister_domain_token = permissions::domain::CanUnregisterDomain { - domain_id: domain_id.clone(), + domain: domain_id.clone(), }; can_unregister_domain_token.is_owned_by(authority) } @@ -226,7 +226,7 @@ pub mod domain { authority: &AccountId, isi: &Transfer, ) { - let source_id = isi.source_id(); + let source_id = isi.source(); let domain_id = isi.object(); if is_genesis(executor) { @@ -251,7 +251,7 @@ pub mod domain { authority: &AccountId, isi: &SetKeyValue, ) { - let domain_id = isi.object_id(); + let domain_id = isi.object(); if is_genesis(executor) { execute!(executor, isi); @@ -262,7 +262,7 @@ pub mod domain { Ok(false) => {} } let can_set_key_value_in_domain_token = permissions::domain::CanSetKeyValueInDomain { - domain_id: domain_id.clone(), + domain: domain_id.clone(), }; if can_set_key_value_in_domain_token.is_owned_by(authority) { execute!(executor, isi); @@ -276,7 +276,7 @@ pub mod domain { authority: &AccountId, isi: &RemoveKeyValue, ) { - let domain_id = isi.object_id(); + let domain_id = isi.object(); if is_genesis(executor) { execute!(executor, isi); @@ -287,7 +287,7 @@ pub mod domain { Ok(false) => {} } let can_remove_key_value_in_domain_token = permissions::domain::CanRemoveKeyValueInDomain { - domain_id: domain_id.clone(), + domain: domain_id.clone(), }; if can_remove_key_value_in_domain_token.is_owned_by(authority) { execute!(executor, isi); @@ -302,88 +302,86 @@ pub mod domain { return false; }; match permission { - AnyPermission::CanUnregisterDomain(permission) => &permission.domain_id == domain_id, - AnyPermission::CanSetKeyValueInDomain(permission) => &permission.domain_id == domain_id, - AnyPermission::CanRemoveKeyValueInDomain(permission) => { - &permission.domain_id == domain_id - } + AnyPermission::CanUnregisterDomain(permission) => &permission.domain == domain_id, + AnyPermission::CanSetKeyValueInDomain(permission) => &permission.domain == domain_id, + AnyPermission::CanRemoveKeyValueInDomain(permission) => &permission.domain == domain_id, AnyPermission::CanRegisterAccountInDomain(permission) => { - &permission.domain_id == domain_id + &permission.domain == domain_id } AnyPermission::CanRegisterAssetDefinitionInDomain(permission) => { - &permission.domain_id == domain_id + &permission.domain == domain_id } AnyPermission::CanUnregisterAssetDefinition(permission) => { - permission.asset_definition_id.domain_id() == domain_id + permission.asset_definition.domain() == domain_id } AnyPermission::CanSetKeyValueInAssetDefinition(permission) => { - permission.asset_definition_id.domain_id() == domain_id + permission.asset_definition.domain() == domain_id } AnyPermission::CanRemoveKeyValueInAssetDefinition(permission) => { - permission.asset_definition_id.domain_id() == domain_id + permission.asset_definition.domain() == domain_id } AnyPermission::CanRegisterAssetWithDefinition(permission) => { - permission.asset_definition_id.domain_id() == domain_id + permission.asset_definition.domain() == domain_id } AnyPermission::CanUnregisterAssetWithDefinition(permission) => { - permission.asset_definition_id.domain_id() == domain_id + permission.asset_definition.domain() == domain_id } AnyPermission::CanBurnAssetWithDefinition(permission) => { - permission.asset_definition_id.domain_id() == domain_id + permission.asset_definition.domain() == domain_id } AnyPermission::CanMintAssetWithDefinition(permission) => { - permission.asset_definition_id.domain_id() == domain_id + permission.asset_definition.domain() == domain_id } AnyPermission::CanTransferAssetWithDefinition(permission) => { - permission.asset_definition_id.domain_id() == domain_id + permission.asset_definition.domain() == domain_id } AnyPermission::CanBurnUserAsset(permission) => { - permission.asset_id.definition_id().domain_id() == domain_id - || permission.asset_id.account_id().domain_id() == domain_id + permission.asset.definition().domain() == domain_id + || permission.asset.account().domain() == domain_id } AnyPermission::CanTransferUserAsset(permission) => { - permission.asset_id.definition_id().domain_id() == domain_id - || permission.asset_id.account_id().domain_id() == domain_id + permission.asset.definition().domain() == domain_id + || permission.asset.account().domain() == domain_id } AnyPermission::CanUnregisterUserAsset(permission) => { - permission.asset_id.definition_id().domain_id() == domain_id - || permission.asset_id.account_id().domain_id() == domain_id + permission.asset.definition().domain() == domain_id + || permission.asset.account().domain() == domain_id } AnyPermission::CanSetKeyValueInUserAsset(permission) => { - permission.asset_id.definition_id().domain_id() == domain_id - || permission.asset_id.account_id().domain_id() == domain_id + permission.asset.definition().domain() == domain_id + || permission.asset.account().domain() == domain_id } AnyPermission::CanRemoveKeyValueInUserAsset(permission) => { - permission.asset_id.definition_id().domain_id() == domain_id - || permission.asset_id.account_id().domain_id() == domain_id + permission.asset.definition().domain() == domain_id + || permission.asset.account().domain() == domain_id } AnyPermission::CanMintUserAsset(permission) => { - permission.asset_id.definition_id().domain_id() == domain_id - || permission.asset_id.account_id().domain_id() == domain_id + permission.asset.definition().domain() == domain_id + || permission.asset.account().domain() == domain_id } AnyPermission::CanUnregisterAccount(permission) => { - permission.account_id.domain_id() == domain_id + permission.account.domain() == domain_id } AnyPermission::CanMintUserPublicKeys(permission) => { - permission.account_id.domain_id() == domain_id + permission.account.domain() == domain_id } AnyPermission::CanBurnUserPublicKeys(permission) => { - permission.account_id.domain_id() == domain_id + permission.account.domain() == domain_id } AnyPermission::CanMintUserSignatureCheckConditions(permission) => { - permission.account_id.domain_id() == domain_id + permission.account.domain() == domain_id } AnyPermission::CanSetKeyValueInAccount(permission) => { - permission.account_id.domain_id() == domain_id + permission.account.domain() == domain_id } AnyPermission::CanRemoveKeyValueInAccount(permission) => { - permission.account_id.domain_id() == domain_id + permission.account.domain() == domain_id } AnyPermission::CanRegisterUserTrigger(permission) => { - permission.account_id.domain_id() == domain_id + permission.account.domain() == domain_id } AnyPermission::CanUnregisterUserTrigger(permission) => { - permission.account_id.domain_id() == domain_id + permission.account.domain() == domain_id } AnyPermission::CanExecuteUserTrigger(_) | AnyPermission::CanBurnUserTrigger(_) @@ -412,7 +410,7 @@ pub mod account { authority: &AccountId, isi: &Register, ) { - let domain_id = isi.object().id().domain_id(); + let domain_id = isi.object().id().domain(); match crate::permission::domain::is_domain_owner(domain_id, authority) { Err(err) => deny!(executor, err), @@ -421,7 +419,7 @@ pub mod account { } let can_register_account_in_domain = permissions::domain::CanRegisterAccountInDomain { - domain_id: domain_id.clone(), + domain: domain_id.clone(), }; if can_register_account_in_domain.is_owned_by(authority) { execute!(executor, isi); @@ -438,7 +436,7 @@ pub mod account { authority: &AccountId, isi: &Unregister, ) { - let account_id = isi.object_id(); + let account_id = isi.object(); if is_genesis(executor) || match is_account_owner(account_id, authority) { @@ -447,7 +445,7 @@ pub mod account { } || { let can_unregister_user_account = permissions::account::CanUnregisterAccount { - account_id: account_id.clone(), + account: account_id.clone(), }; can_unregister_user_account.is_owned_by(authority) } @@ -478,7 +476,7 @@ pub mod account { authority: &AccountId, isi: &SetKeyValue, ) { - let account_id = isi.object_id(); + let account_id = isi.object(); if is_genesis(executor) { execute!(executor, isi); @@ -490,7 +488,7 @@ pub mod account { } let can_set_key_value_in_user_account_token = permissions::account::CanSetKeyValueInAccount { - account_id: account_id.clone(), + account: account_id.clone(), }; if can_set_key_value_in_user_account_token.is_owned_by(authority) { execute!(executor, isi); @@ -507,7 +505,7 @@ pub mod account { authority: &AccountId, isi: &RemoveKeyValue, ) { - let account_id = isi.object_id(); + let account_id = isi.object(); if is_genesis(executor) { execute!(executor, isi); @@ -519,7 +517,7 @@ pub mod account { } let can_remove_key_value_in_user_account_token = permissions::account::CanRemoveKeyValueInAccount { - account_id: account_id.clone(), + account: account_id.clone(), }; if can_remove_key_value_in_user_account_token.is_owned_by(authority) { execute!(executor, isi); @@ -536,45 +534,33 @@ pub mod account { return false; }; match permission { - AnyPermission::CanUnregisterAccount(permission) => &permission.account_id == account_id, - AnyPermission::CanMintUserPublicKeys(permission) => { - &permission.account_id == account_id - } - AnyPermission::CanBurnUserPublicKeys(permission) => { - &permission.account_id == account_id - } + AnyPermission::CanUnregisterAccount(permission) => &permission.account == account_id, + AnyPermission::CanMintUserPublicKeys(permission) => &permission.account == account_id, + AnyPermission::CanBurnUserPublicKeys(permission) => &permission.account == account_id, AnyPermission::CanMintUserSignatureCheckConditions(permission) => { - &permission.account_id == account_id - } - AnyPermission::CanSetKeyValueInAccount(permission) => { - &permission.account_id == account_id + &permission.account == account_id } + AnyPermission::CanSetKeyValueInAccount(permission) => &permission.account == account_id, AnyPermission::CanRemoveKeyValueInAccount(permission) => { - &permission.account_id == account_id - } - AnyPermission::CanBurnUserAsset(permission) => { - permission.asset_id.account_id() == account_id + &permission.account == account_id } + AnyPermission::CanBurnUserAsset(permission) => permission.asset.account() == account_id, AnyPermission::CanTransferUserAsset(permission) => { - permission.asset_id.account_id() == account_id + permission.asset.account() == account_id } AnyPermission::CanUnregisterUserAsset(permission) => { - permission.asset_id.account_id() == account_id + permission.asset.account() == account_id } AnyPermission::CanSetKeyValueInUserAsset(permission) => { - permission.asset_id.account_id() == account_id + permission.asset.account() == account_id } AnyPermission::CanRemoveKeyValueInUserAsset(permission) => { - permission.asset_id.account_id() == account_id - } - AnyPermission::CanMintUserAsset(permission) => { - permission.asset_id.account_id() == account_id - } - AnyPermission::CanRegisterUserTrigger(permission) => { - &permission.account_id == account_id + permission.asset.account() == account_id } + AnyPermission::CanMintUserAsset(permission) => permission.asset.account() == account_id, + AnyPermission::CanRegisterUserTrigger(permission) => &permission.account == account_id, AnyPermission::CanUnregisterUserTrigger(permission) => { - &permission.account_id == account_id + &permission.account == account_id } AnyPermission::CanExecuteUserTrigger(_) | AnyPermission::CanBurnUserTrigger(_) @@ -621,7 +607,7 @@ pub mod asset_definition { authority: &AccountId, isi: &Register, ) { - let domain_id = isi.object().id().domain_id(); + let domain_id = isi.object().id().domain(); match crate::permission::domain::is_domain_owner(domain_id, authority) { Err(err) => deny!(executor, err), @@ -631,7 +617,7 @@ pub mod asset_definition { let can_register_asset_definition_in_domain_token = permissions::domain::CanRegisterAssetDefinitionInDomain { - domain_id: domain_id.clone(), + domain: domain_id.clone(), }; if can_register_asset_definition_in_domain_token.is_owned_by(authority) { execute!(executor, isi); @@ -648,7 +634,7 @@ pub mod asset_definition { authority: &AccountId, isi: &Unregister, ) { - let asset_definition_id = isi.object_id(); + let asset_definition_id = isi.object(); if is_genesis(executor) || match is_asset_definition_owner(asset_definition_id, authority) { @@ -658,7 +644,7 @@ pub mod asset_definition { || { let can_unregister_asset_definition_token = permissions::asset_definition::CanUnregisterAssetDefinition { - asset_definition_id: asset_definition_id.clone(), + asset_definition: asset_definition_id.clone(), }; can_unregister_asset_definition_token.is_owned_by(authority) } @@ -692,7 +678,7 @@ pub mod asset_definition { authority: &AccountId, isi: &Transfer, ) { - let source_id = isi.source_id(); + let source_id = isi.source(); let asset_definition_id = isi.object(); if is_genesis(executor) { @@ -720,7 +706,7 @@ pub mod asset_definition { authority: &AccountId, isi: &SetKeyValue, ) { - let asset_definition_id = isi.object_id(); + let asset_definition_id = isi.object(); if is_genesis(executor) { execute!(executor, isi); @@ -732,7 +718,7 @@ pub mod asset_definition { } let can_set_key_value_in_asset_definition_token = permissions::asset_definition::CanSetKeyValueInAssetDefinition { - asset_definition_id: asset_definition_id.clone(), + asset_definition: asset_definition_id.clone(), }; if can_set_key_value_in_asset_definition_token.is_owned_by(authority) { execute!(executor, isi); @@ -749,7 +735,7 @@ pub mod asset_definition { authority: &AccountId, isi: &RemoveKeyValue, ) { - let asset_definition_id = isi.object_id(); + let asset_definition_id = isi.object(); if is_genesis(executor) { execute!(executor, isi); @@ -761,7 +747,7 @@ pub mod asset_definition { } let can_remove_key_value_in_asset_definition_token = permissions::asset_definition::CanRemoveKeyValueInAssetDefinition { - asset_definition_id: asset_definition_id.clone(), + asset_definition: asset_definition_id.clone(), }; if can_remove_key_value_in_asset_definition_token.is_owned_by(authority) { execute!(executor, isi); @@ -782,46 +768,46 @@ pub mod asset_definition { }; match permission { AnyPermission::CanUnregisterAssetDefinition(permission) => { - &permission.asset_definition_id == asset_definition_id + &permission.asset_definition == asset_definition_id } AnyPermission::CanSetKeyValueInAssetDefinition(permission) => { - &permission.asset_definition_id == asset_definition_id + &permission.asset_definition == asset_definition_id } AnyPermission::CanRemoveKeyValueInAssetDefinition(permission) => { - &permission.asset_definition_id == asset_definition_id + &permission.asset_definition == asset_definition_id } AnyPermission::CanRegisterAssetWithDefinition(permission) => { - &permission.asset_definition_id == asset_definition_id + &permission.asset_definition == asset_definition_id } AnyPermission::CanUnregisterAssetWithDefinition(permission) => { - &permission.asset_definition_id == asset_definition_id + &permission.asset_definition == asset_definition_id } AnyPermission::CanBurnAssetWithDefinition(permission) => { - &permission.asset_definition_id == asset_definition_id + &permission.asset_definition == asset_definition_id } AnyPermission::CanMintAssetWithDefinition(permission) => { - &permission.asset_definition_id == asset_definition_id + &permission.asset_definition == asset_definition_id } AnyPermission::CanTransferAssetWithDefinition(permission) => { - &permission.asset_definition_id == asset_definition_id + &permission.asset_definition == asset_definition_id } AnyPermission::CanBurnUserAsset(permission) => { - permission.asset_id.definition_id() == asset_definition_id + permission.asset.definition() == asset_definition_id } AnyPermission::CanTransferUserAsset(permission) => { - permission.asset_id.definition_id() == asset_definition_id + permission.asset.definition() == asset_definition_id } AnyPermission::CanUnregisterUserAsset(permission) => { - permission.asset_id.definition_id() == asset_definition_id + permission.asset.definition() == asset_definition_id } AnyPermission::CanSetKeyValueInUserAsset(permission) => { - permission.asset_id.definition_id() == asset_definition_id + permission.asset.definition() == asset_definition_id } AnyPermission::CanRemoveKeyValueInUserAsset(permission) => { - permission.asset_id.definition_id() == asset_definition_id + permission.asset.definition() == asset_definition_id } AnyPermission::CanMintUserAsset(permission) => { - permission.asset_id.definition_id() == asset_definition_id + permission.asset.definition() == asset_definition_id } AnyPermission::CanUnregisterAccount(_) | AnyPermission::CanMintUserPublicKeys(_) @@ -873,14 +859,14 @@ pub mod asset { if is_genesis(executor) { execute!(executor, isi); } - match is_asset_definition_owner(asset.id().definition_id(), authority) { + match is_asset_definition_owner(asset.id().definition(), authority) { Err(err) => deny!(executor, err), Ok(true) => execute!(executor, isi), Ok(false) => {} } let can_register_assets_with_definition_token = permissions::asset::CanRegisterAssetWithDefinition { - asset_definition_id: asset.id().definition_id().clone(), + asset_definition: asset.id().definition().clone(), }; if can_register_assets_with_definition_token.is_owned_by(authority) { execute!(executor, isi); @@ -897,7 +883,7 @@ pub mod asset { authority: &AccountId, isi: &Unregister, ) { - let asset_id = isi.object_id(); + let asset_id = isi.object(); if is_genesis(executor) { execute!(executor, isi); @@ -907,20 +893,20 @@ pub mod asset { Ok(true) => execute!(executor, isi), Ok(false) => {} } - match is_asset_definition_owner(asset_id.definition_id(), authority) { + match is_asset_definition_owner(asset_id.definition(), authority) { Err(err) => deny!(executor, err), Ok(true) => execute!(executor, isi), Ok(false) => {} } let can_unregister_assets_with_definition_token = permissions::asset::CanUnregisterAssetWithDefinition { - asset_definition_id: asset_id.definition_id().clone(), + asset_definition: asset_id.definition().clone(), }; if can_unregister_assets_with_definition_token.is_owned_by(authority) { execute!(executor, isi); } let can_unregister_user_asset_token = permissions::asset::CanUnregisterUserAsset { - asset_id: asset_id.clone(), + asset: asset_id.clone(), }; if can_unregister_user_asset_token.is_owned_by(authority) { execute!(executor, isi); @@ -935,24 +921,24 @@ pub mod asset { Q: Into, Mint: Instruction + Encode, { - let asset_id = isi.destination_id(); + let asset_id = isi.destination(); if is_genesis(executor) { execute!(executor, isi); } - match is_asset_definition_owner(asset_id.definition_id(), authority) { + match is_asset_definition_owner(asset_id.definition(), authority) { Err(err) => deny!(executor, err), Ok(true) => execute!(executor, isi), Ok(false) => {} } let can_mint_assets_with_definition_token = permissions::asset::CanMintAssetWithDefinition { - asset_definition_id: asset_id.definition_id().clone(), + asset_definition: asset_id.definition().clone(), }; if can_mint_assets_with_definition_token.is_owned_by(authority) { execute!(executor, isi); } let can_mint_user_asset_token = permissions::asset::CanMintUserAsset { - asset_id: asset_id.clone(), + asset: asset_id.clone(), }; if can_mint_user_asset_token.is_owned_by(authority) { execute!(executor, isi); @@ -978,7 +964,7 @@ pub mod asset { Q: Into, Burn: Instruction + Encode, { - let asset_id = isi.destination_id(); + let asset_id = isi.destination(); if is_genesis(executor) { execute!(executor, isi); } @@ -987,20 +973,20 @@ pub mod asset { Ok(true) => execute!(executor, isi), Ok(false) => {} } - match is_asset_definition_owner(asset_id.definition_id(), authority) { + match is_asset_definition_owner(asset_id.definition(), authority) { Err(err) => deny!(executor, err), Ok(true) => execute!(executor, isi), Ok(false) => {} } let can_burn_assets_with_definition_token = permissions::asset::CanBurnAssetWithDefinition { - asset_definition_id: asset_id.definition_id().clone(), + asset_definition: asset_id.definition().clone(), }; if can_burn_assets_with_definition_token.is_owned_by(authority) { execute!(executor, isi); } let can_burn_user_asset_token = permissions::asset::CanBurnUserAsset { - asset_id: asset_id.clone(), + asset: asset_id.clone(), }; if can_burn_user_asset_token.is_owned_by(authority) { execute!(executor, isi); @@ -1026,7 +1012,7 @@ pub mod asset { Q: Into, Transfer: Instruction + Encode, { - let asset_id = isi.source_id(); + let asset_id = isi.source(); if is_genesis(executor) { execute!(executor, isi); } @@ -1035,20 +1021,20 @@ pub mod asset { Ok(true) => execute!(executor, isi), Ok(false) => {} } - match is_asset_definition_owner(asset_id.definition_id(), authority) { + match is_asset_definition_owner(asset_id.definition(), authority) { Err(err) => deny!(executor, err), Ok(true) => execute!(executor, isi), Ok(false) => {} } let can_transfer_assets_with_definition_token = permissions::asset::CanTransferAssetWithDefinition { - asset_definition_id: asset_id.definition_id().clone(), + asset_definition: asset_id.definition().clone(), }; if can_transfer_assets_with_definition_token.is_owned_by(authority) { execute!(executor, isi); } let can_transfer_user_asset_token = permissions::asset::CanTransferUserAsset { - asset_id: asset_id.clone(), + asset: asset_id.clone(), }; if can_transfer_user_asset_token.is_owned_by(authority) { execute!(executor, isi); @@ -1078,7 +1064,7 @@ pub mod asset { authority: &AccountId, isi: &SetKeyValue, ) { - let asset_id = isi.object_id(); + let asset_id = isi.object(); if is_genesis(executor) { execute!(executor, isi); @@ -1090,7 +1076,7 @@ pub mod asset { } let can_set_key_value_in_user_asset_token = permissions::asset::CanSetKeyValueInUserAsset { - asset_id: asset_id.clone(), + asset: asset_id.clone(), }; if can_set_key_value_in_user_asset_token.is_owned_by(authority) { execute!(executor, isi); @@ -1107,7 +1093,7 @@ pub mod asset { authority: &AccountId, isi: &RemoveKeyValue, ) { - let asset_id = isi.object_id(); + let asset_id = isi.object(); if is_genesis(executor) { execute!(executor, isi); @@ -1119,7 +1105,7 @@ pub mod asset { } let can_remove_key_value_in_user_asset_token = permissions::asset::CanRemoveKeyValueInUserAsset { - asset_id: asset_id.clone(), + asset: asset_id.clone(), }; if can_remove_key_value_in_user_asset_token.is_owned_by(authority) { execute!(executor, isi); @@ -1220,7 +1206,7 @@ pub mod role { macro_rules! impl_validate_grant_revoke_role_permission { ($executor:ident, $isi:ident, $authority:ident, $method:ident, $isi_type:ty) => { - let role_id = $isi.destination_id().clone(); + let role_id = $isi.destination().clone(); let token = $isi.object(); if let Ok(any_token) = AnyPermission::try_from(token) { @@ -1352,7 +1338,7 @@ pub mod trigger { if is_genesis(executor) || { - match is_domain_owner(trigger.action().authority().domain_id(), authority) { + match is_domain_owner(trigger.action().authority().domain(), authority) { Err(err) => deny!(executor, err), Ok(is_domain_owner) => is_domain_owner, } @@ -1360,7 +1346,7 @@ pub mod trigger { || { let can_register_user_trigger_token = permissions::trigger::CanRegisterUserTrigger { - account_id: isi.object().action().authority().clone(), + account: isi.object().action().authority().clone(), }; can_register_user_trigger_token.is_owned_by(authority) } @@ -1375,7 +1361,7 @@ pub mod trigger { authority: &AccountId, isi: &Unregister, ) { - let trigger_id = isi.object_id(); + let trigger_id = isi.object(); if is_genesis(executor) || match is_trigger_owner(trigger_id, authority) { @@ -1385,7 +1371,7 @@ pub mod trigger { || { let can_unregister_user_trigger_token = permissions::trigger::CanUnregisterUserTrigger { - account_id: find_trigger(trigger_id) + account: find_trigger(trigger_id) .unwrap() .action() .authority() @@ -1423,7 +1409,7 @@ pub mod trigger { authority: &AccountId, isi: &Mint, ) { - let trigger_id = isi.destination_id(); + let trigger_id = isi.destination(); if is_genesis(executor) { execute!(executor, isi); @@ -1434,7 +1420,7 @@ pub mod trigger { Ok(false) => {} } let can_mint_user_trigger_token = permissions::trigger::CanMintUserTrigger { - trigger_id: trigger_id.clone(), + trigger: trigger_id.clone(), }; if can_mint_user_trigger_token.is_owned_by(authority) { execute!(executor, isi); @@ -1451,7 +1437,7 @@ pub mod trigger { authority: &AccountId, isi: &Burn, ) { - let trigger_id = isi.destination_id(); + let trigger_id = isi.destination(); if is_genesis(executor) { execute!(executor, isi); @@ -1462,7 +1448,7 @@ pub mod trigger { Ok(false) => {} } let can_mint_user_trigger_token = permissions::trigger::CanBurnUserTrigger { - trigger_id: trigger_id.clone(), + trigger: trigger_id.clone(), }; if can_mint_user_trigger_token.is_owned_by(authority) { execute!(executor, isi); @@ -1479,7 +1465,7 @@ pub mod trigger { authority: &AccountId, isi: &ExecuteTrigger, ) { - let trigger_id = isi.trigger_id(); + let trigger_id = isi.trigger(); if is_genesis(executor) { execute!(executor, isi); @@ -1490,7 +1476,7 @@ pub mod trigger { Ok(false) => {} } let can_execute_trigger_token = permissions::trigger::CanExecuteUserTrigger { - trigger_id: trigger_id.clone(), + trigger: trigger_id.clone(), }; if can_execute_trigger_token.is_owned_by(authority) { execute!(executor, isi); @@ -1504,7 +1490,7 @@ pub mod trigger { authority: &AccountId, isi: &SetKeyValue, ) { - let trigger_id = isi.object_id(); + let trigger_id = isi.object(); if is_genesis(executor) { execute!(executor, isi); @@ -1516,7 +1502,7 @@ pub mod trigger { } let can_set_key_value_in_user_trigger_token = permissions::trigger::CanSetKeyValueInTrigger { - trigger_id: trigger_id.clone(), + trigger: trigger_id.clone(), }; if can_set_key_value_in_user_trigger_token.is_owned_by(authority) { execute!(executor, isi); @@ -1533,7 +1519,7 @@ pub mod trigger { authority: &AccountId, isi: &RemoveKeyValue, ) { - let trigger_id = isi.object_id(); + let trigger_id = isi.object(); if is_genesis(executor) { execute!(executor, isi); @@ -1545,7 +1531,7 @@ pub mod trigger { } let can_remove_key_value_in_trigger_token = permissions::trigger::CanRemoveKeyValueInTrigger { - trigger_id: trigger_id.clone(), + trigger: trigger_id.clone(), }; if can_remove_key_value_in_trigger_token.is_owned_by(authority) { execute!(executor, isi); @@ -1562,16 +1548,12 @@ pub mod trigger { return false; }; match permission { - AnyPermission::CanExecuteUserTrigger(permission) => { - &permission.trigger_id == trigger_id - } - AnyPermission::CanBurnUserTrigger(permission) => &permission.trigger_id == trigger_id, - AnyPermission::CanMintUserTrigger(permission) => &permission.trigger_id == trigger_id, - AnyPermission::CanSetKeyValueInTrigger(permission) => { - &permission.trigger_id == trigger_id - } + AnyPermission::CanExecuteUserTrigger(permission) => &permission.trigger == trigger_id, + AnyPermission::CanBurnUserTrigger(permission) => &permission.trigger == trigger_id, + AnyPermission::CanMintUserTrigger(permission) => &permission.trigger == trigger_id, + AnyPermission::CanSetKeyValueInTrigger(permission) => &permission.trigger == trigger_id, AnyPermission::CanRemoveKeyValueInTrigger(permission) => { - &permission.trigger_id == trigger_id + &permission.trigger == trigger_id } AnyPermission::CanRegisterUserTrigger(_) | AnyPermission::CanUnregisterUserTrigger(_) @@ -1618,7 +1600,7 @@ pub mod permission { macro_rules! impl_validate { ($executor:ident, $authority:ident, $isi:ident, $method:ident, $isi_type:ty) => { - let account_id = $isi.destination_id().clone(); + let account_id = $isi.destination().clone(); let token = $isi.object(); if let Ok(any_token) = AnyPermission::try_from(token) { diff --git a/smart_contract/executor/src/default/permissions.rs b/smart_contract/executor/src/default/permissions.rs index 1ac643b451d..735ef253942 100644 --- a/smart_contract/executor/src/default/permissions.rs +++ b/smart_contract/executor/src/default/permissions.rs @@ -161,7 +161,7 @@ pub mod domain { #[derive(ValidateGrantRevoke, permission::derive_conversions::domain::Owner)] #[validate(permission::domain::Owner)] pub struct CanUnregisterDomain { - pub domain_id: DomainId, + pub domain: DomainId, } } @@ -169,7 +169,7 @@ pub mod domain { #[derive(ValidateGrantRevoke, permission::derive_conversions::domain::Owner)] #[validate(permission::domain::Owner)] pub struct CanSetKeyValueInDomain { - pub domain_id: DomainId, + pub domain: DomainId, } } @@ -177,7 +177,7 @@ pub mod domain { #[derive(ValidateGrantRevoke, permission::derive_conversions::domain::Owner)] #[validate(permission::domain::Owner)] pub struct CanRemoveKeyValueInDomain { - pub domain_id: DomainId, + pub domain: DomainId, } } @@ -185,7 +185,7 @@ pub mod domain { #[derive(ValidateGrantRevoke, permission::derive_conversions::domain::Owner)] #[validate(permission::domain::Owner)] pub struct CanRegisterAccountInDomain { - pub domain_id: DomainId, + pub domain: DomainId, } } @@ -193,7 +193,7 @@ pub mod domain { #[derive(ValidateGrantRevoke, permission::derive_conversions::domain::Owner)] #[validate(permission::domain::Owner)] pub struct CanRegisterAssetDefinitionInDomain { - pub domain_id: DomainId, + pub domain: DomainId, } } } @@ -205,42 +205,42 @@ pub mod account { #[derive(ValidateGrantRevoke, permission::derive_conversions::account::Owner)] #[validate(permission::account::Owner)] pub struct CanUnregisterAccount { - pub account_id: AccountId, + pub account: AccountId, } } permission! { #[derive(ValidateGrantRevoke, permission::derive_conversions::account::Owner)] #[validate(permission::account::Owner)] pub struct CanMintUserPublicKeys { - pub account_id: AccountId, + pub account: AccountId, } } permission! { #[derive(ValidateGrantRevoke, permission::derive_conversions::account::Owner)] #[validate(permission::account::Owner)] pub struct CanBurnUserPublicKeys { - pub account_id: AccountId, + pub account: AccountId, } } permission! { #[derive(ValidateGrantRevoke, permission::derive_conversions::account::Owner)] #[validate(permission::account::Owner)] pub struct CanMintUserSignatureCheckConditions { - pub account_id: AccountId, + pub account: AccountId, } } permission! { #[derive(ValidateGrantRevoke, permission::derive_conversions::account::Owner)] #[validate(permission::account::Owner)] pub struct CanSetKeyValueInAccount { - pub account_id: AccountId, + pub account: AccountId, } } permission! { #[derive(ValidateGrantRevoke, permission::derive_conversions::account::Owner)] #[validate(permission::account::Owner)] pub struct CanRemoveKeyValueInAccount { - pub account_id: AccountId, + pub account: AccountId, } } } @@ -252,7 +252,7 @@ pub mod asset_definition { #[derive(ValidateGrantRevoke, permission::derive_conversions::asset_definition::Owner)] #[validate(permission::asset_definition::Owner)] pub struct CanUnregisterAssetDefinition { - pub asset_definition_id: AssetDefinitionId, + pub asset_definition: AssetDefinitionId, } } @@ -260,7 +260,7 @@ pub mod asset_definition { #[derive(ValidateGrantRevoke, permission::derive_conversions::asset_definition::Owner)] #[validate(permission::asset_definition::Owner)] pub struct CanSetKeyValueInAssetDefinition { - pub asset_definition_id: AssetDefinitionId, + pub asset_definition: AssetDefinitionId, } } @@ -268,7 +268,7 @@ pub mod asset_definition { #[derive(ValidateGrantRevoke, permission::derive_conversions::asset_definition::Owner)] #[validate(permission::asset_definition::Owner)] pub struct CanRemoveKeyValueInAssetDefinition { - pub asset_definition_id: AssetDefinitionId, + pub asset_definition: AssetDefinitionId, } } } @@ -280,7 +280,7 @@ pub mod asset { #[derive(ValidateGrantRevoke, permission::derive_conversions::asset_definition::Owner)] #[validate(permission::asset_definition::Owner)] pub struct CanRegisterAssetWithDefinition { - pub asset_definition_id: AssetDefinitionId, + pub asset_definition: AssetDefinitionId, } } @@ -288,7 +288,7 @@ pub mod asset { #[derive(ValidateGrantRevoke, permission::derive_conversions::asset_definition::Owner)] #[validate(permission::asset_definition::Owner)] pub struct CanUnregisterAssetWithDefinition { - pub asset_definition_id: AssetDefinitionId, + pub asset_definition: AssetDefinitionId, } } @@ -296,7 +296,7 @@ pub mod asset { #[derive(ValidateGrantRevoke, permission::derive_conversions::asset::Owner)] #[validate(permission::asset::Owner)] pub struct CanUnregisterUserAsset { - pub asset_id: AssetId, + pub asset: AssetId, } } @@ -304,7 +304,7 @@ pub mod asset { #[derive(ValidateGrantRevoke, permission::derive_conversions::asset_definition::Owner)] #[validate(permission::asset_definition::Owner)] pub struct CanBurnAssetWithDefinition { - pub asset_definition_id: AssetDefinitionId, + pub asset_definition: AssetDefinitionId, } } @@ -312,7 +312,7 @@ pub mod asset { #[derive(ValidateGrantRevoke, permission::derive_conversions::asset::Owner)] #[validate(permission::asset::Owner)] pub struct CanBurnUserAsset { - pub asset_id: AssetId, + pub asset: AssetId, } } @@ -320,7 +320,7 @@ pub mod asset { #[derive(ValidateGrantRevoke, permission::derive_conversions::asset_definition::Owner)] #[validate(permission::asset_definition::Owner)] pub struct CanMintAssetWithDefinition { - pub asset_definition_id: AssetDefinitionId, + pub asset_definition: AssetDefinitionId, } } @@ -328,7 +328,7 @@ pub mod asset { #[derive(ValidateGrantRevoke, permission::derive_conversions::asset::Owner)] #[validate(permission::asset::Owner)] pub struct CanMintUserAsset { - pub asset_id: AssetId, + pub asset: AssetId, } } @@ -336,7 +336,7 @@ pub mod asset { #[derive(ValidateGrantRevoke, permission::derive_conversions::asset_definition::Owner)] #[validate(permission::asset_definition::Owner)] pub struct CanTransferAssetWithDefinition { - pub asset_definition_id: AssetDefinitionId, + pub asset_definition: AssetDefinitionId, } } @@ -344,7 +344,7 @@ pub mod asset { #[derive(ValidateGrantRevoke, permission::derive_conversions::asset::Owner)] #[validate(permission::asset::Owner)] pub struct CanTransferUserAsset { - pub asset_id: AssetId, + pub asset: AssetId, } } @@ -352,7 +352,7 @@ pub mod asset { #[derive(ValidateGrantRevoke, permission::derive_conversions::asset::Owner)] #[validate(permission::asset::Owner)] pub struct CanSetKeyValueInUserAsset { - pub asset_id: AssetId, + pub asset: AssetId, } } @@ -360,7 +360,7 @@ pub mod asset { #[derive(ValidateGrantRevoke, permission::derive_conversions::asset::Owner)] #[validate(permission::asset::Owner)] pub struct CanRemoveKeyValueInUserAsset { - pub asset_id: AssetId, + pub asset: AssetId, } } } @@ -471,7 +471,7 @@ pub mod trigger { impl<'token> From<&'token $name> for permission::trigger::Owner<'token> { fn from(value: &'token $name) -> Self { Self { - trigger_id: &value.trigger_id, + trigger: &value.trigger, } } } @@ -482,7 +482,7 @@ pub mod trigger { #[derive(ValidateGrantRevoke, permission::derive_conversions::account::Owner)] #[validate(permission::account::Owner)] pub struct CanRegisterUserTrigger { - pub account_id: AccountId, + pub account: AccountId, } } @@ -490,7 +490,7 @@ pub mod trigger { #[derive(ValidateGrantRevoke)] #[validate(permission::trigger::Owner)] pub struct CanExecuteUserTrigger { - pub trigger_id: TriggerId, + pub trigger: TriggerId, } } @@ -498,7 +498,7 @@ pub mod trigger { #[derive(ValidateGrantRevoke, permission::derive_conversions::account::Owner)] #[validate(permission::account::Owner)] pub struct CanUnregisterUserTrigger { - pub account_id: AccountId, + pub account: AccountId, } } @@ -506,7 +506,7 @@ pub mod trigger { #[derive(ValidateGrantRevoke)] #[validate(permission::trigger::Owner)] pub struct CanMintUserTrigger { - pub trigger_id: TriggerId, + pub trigger: TriggerId, } } @@ -514,7 +514,7 @@ pub mod trigger { #[derive(ValidateGrantRevoke)] #[validate(permission::trigger::Owner)] pub struct CanBurnUserTrigger { - pub trigger_id: TriggerId, + pub trigger: TriggerId, } } @@ -522,7 +522,7 @@ pub mod trigger { #[derive(ValidateGrantRevoke)] #[validate(permission::trigger::Owner)] pub struct CanSetKeyValueInTrigger { - pub trigger_id: TriggerId, + pub trigger: TriggerId, } } @@ -530,7 +530,7 @@ pub mod trigger { #[derive(ValidateGrantRevoke)] #[validate(permission::trigger::Owner)] pub struct CanRemoveKeyValueInTrigger { - pub trigger_id: TriggerId, + pub trigger: TriggerId, } } diff --git a/smart_contract/executor/src/permission.rs b/smart_contract/executor/src/permission.rs index a08c1248afc..6aa5c7d2a13 100644 --- a/smart_contract/executor/src/permission.rs +++ b/smart_contract/executor/src/permission.rs @@ -77,9 +77,9 @@ pub mod asset { use super::*; - /// Check if `authority` is the owner of `asset_id`. + /// Check if `authority` is the owner of asset. /// - /// `authority` is owner of `asset_id` if: + /// `authority` is owner of asset if: /// - `asset_id.account_id` is `account_id` /// - `asset_id.account_id.domain_id` domain is owned by `authority` /// @@ -87,19 +87,19 @@ pub mod asset { /// /// Fails if `is_account_owner` fails pub fn is_asset_owner(asset_id: &AssetId, authority: &AccountId) -> Result { - crate::permission::account::is_account_owner(asset_id.account_id(), authority) + crate::permission::account::is_account_owner(asset_id.account(), authority) } - /// Pass condition that checks if `authority` is the owner of `asset_id`. + /// Pass condition that checks if `authority` is the owner of asset. #[derive(Debug, Clone)] pub struct Owner<'asset> { /// Asset id to check against - pub asset_id: &'asset AssetId, + pub asset: &'asset AssetId, } impl PassCondition for Owner<'_> { fn validate(&self, authority: &AccountId, _block_height: u64) -> Result { - if is_asset_owner(self.asset_id, authority)? { + if is_asset_owner(self.asset, authority)? { return Ok(()); } @@ -115,9 +115,9 @@ pub mod asset_definition { use super::*; - /// Check if `authority` is the owner of `asset_definition_id` + /// Check if `authority` is the owner of asset definition - /// `authority` is owner of `asset_definition_id` if: + /// `authority` is owner of asset_definition if: /// - `asset_definition.owned_by` is `authority` /// - `asset_definition.domain_id` domain is owned by `authority` /// @@ -134,20 +134,20 @@ pub mod asset_definition { if asset_definition.owned_by() == authority { Ok(true) } else { - crate::permission::domain::is_domain_owner(asset_definition_id.domain_id(), authority) + crate::permission::domain::is_domain_owner(asset_definition_id.domain(), authority) } } - /// Pass condition that checks if `authority` is the owner of `asset_definition_id`. + /// Pass condition that checks if `authority` is the owner of asset definition. #[derive(Debug, Clone)] pub struct Owner<'asset_definition> { /// Asset definition id to check against - pub asset_definition_id: &'asset_definition AssetDefinitionId, + pub asset_definition: &'asset_definition AssetDefinitionId, } impl PassCondition for Owner<'_> { fn validate(&self, authority: &AccountId, _block_height: u64) -> Result { - if is_asset_definition_owner(self.asset_definition_id, authority)? { + if is_asset_definition_owner(self.asset_definition, authority)? { return Ok(()); } @@ -163,9 +163,9 @@ pub mod account { use super::*; - /// Check if `authority` is the owner of `account_id`. + /// Check if `authority` is the owner of account. /// - /// `authority` is owner of `account_id` if: + /// `authority` is owner of account if: /// - `account_id` is `authority` /// - `account_id.domain_id` is owned by `authority` /// @@ -176,20 +176,20 @@ pub mod account { if account_id == authority { Ok(true) } else { - crate::permission::domain::is_domain_owner(account_id.domain_id(), authority) + crate::permission::domain::is_domain_owner(account_id.domain(), authority) } } - /// Pass condition that checks if `authority` is the owner of `account_id`. + /// Pass condition that checks if `authority` is the owner of account. #[derive(Debug, Clone)] pub struct Owner<'asset> { /// Account id to check against - pub account_id: &'asset AccountId, + pub account: &'asset AccountId, } impl PassCondition for Owner<'_> { fn validate(&self, authority: &AccountId, _block_height: u64) -> Result { - if is_account_owner(self.account_id, authority)? { + if is_account_owner(self.account, authority)? { return Ok(()); } @@ -205,9 +205,9 @@ pub mod trigger { use super::*; use crate::permission::domain::is_domain_owner; - /// Check if `authority` is the owner of `trigger_id`. + /// Check if `authority` is the owner of trigger. /// - /// `authority` is owner of `trigger_id` if: + /// `authority` is owner of trigger if: /// - `trigger.action.authority` is `authority` /// - `trigger.action.authority.domain_id` is owned by `authority` /// @@ -218,26 +218,25 @@ pub mod trigger { let trigger = find_trigger(trigger_id)?; Ok(trigger.action().authority() == authority - || is_domain_owner(trigger.action().authority().domain_id(), authority)?) + || is_domain_owner(trigger.action().authority().domain(), authority)?) } /// Returns the trigger. pub(crate) fn find_trigger(trigger_id: &TriggerId) -> Result { - let trigger = FindTriggerById::new(trigger_id.clone()) + FindTriggerById::new(trigger_id.clone()) .execute() - .map(QueryOutputCursor::into_inner)?; - Ok(trigger) + .map(QueryOutputCursor::into_inner) } - /// Pass condition that checks if `authority` is the owner of `trigger_id`. + /// Pass condition that checks if `authority` is the owner of trigger. #[derive(Debug, Clone)] pub struct Owner<'trigger> { /// Trigger id to check against - pub trigger_id: &'trigger TriggerId, + pub trigger: &'trigger TriggerId, } impl PassCondition for Owner<'_> { fn validate(&self, authority: &AccountId, _block_height: u64) -> Result { - if is_trigger_owner(self.trigger_id, authority)? { + if is_trigger_owner(self.trigger, authority)? { return Ok(()); } @@ -252,7 +251,7 @@ pub mod domain { //! Module with pass conditions for domain related tokens use super::*; - /// Check if `authority` is owner of `domain_id` + /// Check if `authority` is owner of domain /// /// # Errors /// Fails if query fails @@ -263,16 +262,16 @@ pub mod domain { .map(|domain| domain.owned_by() == authority) } - /// Pass condition that checks if `authority` is the owner of `domain_id`. + /// Pass condition that checks if `authority` is the owner of domain. #[derive(Debug, Clone)] pub struct Owner<'domain> { /// Domain id to check against - pub domain_id: &'domain DomainId, + pub domain: &'domain DomainId, } impl PassCondition for Owner<'_> { fn validate(&self, authority: &AccountId, _block_height: u64) -> Result { - if is_domain_owner(self.domain_id, authority)? { + if is_domain_owner(self.domain, authority)? { return Ok(()); } diff --git a/tools/parity_scale_cli/samples/trigger.json b/tools/parity_scale_cli/samples/trigger.json index 6c74b0f5a53..a6c19320318 100644 --- a/tools/parity_scale_cli/samples/trigger.json +++ b/tools/parity_scale_cli/samples/trigger.json @@ -7,7 +7,7 @@ "Mint": { "Asset": { "object": "1", - "destination_id": "rose##ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland" + "destination": "rose##ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland" } } }