Skip to content

Commit

Permalink
refactor!: fix naming convention for assets and permissions
Browse files Browse the repository at this point in the history
Signed-off-by: Marin Veršić <[email protected]>
  • Loading branch information
mversic committed Jun 19, 2024
1 parent db372a1 commit a251508
Show file tree
Hide file tree
Showing 38 changed files with 209 additions and 253 deletions.
2 changes: 1 addition & 1 deletion client/examples/million_accounts_genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn generate_genesis(
.account(signatory_alice.clone())
.asset(
format!("xor-{i}").parse().expect("Valid"),
AssetValueType::Numeric(NumericSpec::default()),
AssetType::Numeric(NumericSpec::default()),
)
.finish_domain();
}
Expand Down
8 changes: 4 additions & 4 deletions client/tests/integration/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use iroha::{
client::{self, QueryResult},
crypto::KeyPair,
data_model::{
asset::{AssetId, AssetValue, AssetValueType},
asset::{AssetId, AssetType, AssetValue},
isi::error::{InstructionEvaluationError, InstructionExecutionError, Mismatch, TypeError},
prelude::*,
transaction::error::TransactionRejectionReason,
Expand Down Expand Up @@ -402,7 +402,7 @@ fn fail_if_dont_satisfy_spec() {
// Create asset definition which accepts only integers
let asset_definition = AssetDefinition::new(
asset_definition_id.clone(),
AssetValueType::Numeric(NumericSpec::integer()),
AssetType::Numeric(NumericSpec::integer()),
);

test_client
Expand Down Expand Up @@ -435,8 +435,8 @@ fn fail_if_dont_satisfy_spec() {
&TransactionRejectionReason::Validation(ValidationFail::InstructionFailed(
InstructionExecutionError::Evaluate(InstructionEvaluationError::Type(
TypeError::from(Mismatch {
expected: AssetValueType::Numeric(NumericSpec::integer()),
actual: AssetValueType::Numeric(NumericSpec::fractional(2))
expected: AssetType::Numeric(NumericSpec::integer()),
actual: AssetType::Numeric(NumericSpec::fractional(2))
})
))
))
Expand Down
8 changes: 4 additions & 4 deletions client/tests/integration/events/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,13 @@ fn produce_multiple_events() -> Result<()> {
DataEvent::Domain(DomainEvent::Account(AccountEvent::PermissionAdded(
AccountPermissionChanged {
account: bob_id.clone(),
permission: token_1.id.clone(),
permission: token_1.clone(),
},
))),
DataEvent::Domain(DomainEvent::Account(AccountEvent::PermissionAdded(
AccountPermissionChanged {
account: bob_id.clone(),
permission: token_2.id.clone(),
permission: token_2.clone(),
},
))),
DataEvent::Domain(DomainEvent::Account(AccountEvent::RoleGranted(
Expand All @@ -258,13 +258,13 @@ fn produce_multiple_events() -> Result<()> {
DataEvent::Domain(DomainEvent::Account(AccountEvent::PermissionRemoved(
AccountPermissionChanged {
account: bob_id.clone(),
permission: token_1.id,
permission: token_1,
},
))),
DataEvent::Domain(DomainEvent::Account(AccountEvent::PermissionRemoved(
AccountPermissionChanged {
account: bob_id.clone(),
permission: token_2.id,
permission: token_2,
},
))),
DataEvent::Domain(DomainEvent::Account(AccountEvent::RoleRevoked(
Expand Down
8 changes: 4 additions & 4 deletions client/tests/integration/queries/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ fn find_accounts_with_asset() -> Result<()> {

assert_eq!(received_asset_definition.id(), asset_definition.id());
assert!(matches!(
received_asset_definition.value_type(),
AssetValueType::Numeric(_)
received_asset_definition.type_(),
AssetType::Numeric(_)
));

let accounts: [AccountId; 5] = [
Expand Down Expand Up @@ -61,8 +61,8 @@ fn find_accounts_with_asset() -> Result<()> {

assert_eq!(received_asset_definition.id(), asset_definition.id());
assert_eq!(
received_asset_definition.value_type(),
AssetValueType::Numeric(NumericSpec::default()),
received_asset_definition.type_(),
AssetType::Numeric(NumericSpec::default()),
);

let found_accounts = test_client
Expand Down
6 changes: 3 additions & 3 deletions client/tests/integration/queries/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fn find_asset_total_quantity() -> Result<()> {
&test_client,
&accounts,
"quantity#wonderland",
AssetValueType::Numeric(NumericSpec::default()),
AssetType::Numeric(NumericSpec::default()),
numeric!(1),
numeric!(10),
numeric!(5),
Expand All @@ -56,7 +56,7 @@ fn find_asset_total_quantity() -> Result<()> {
&test_client,
&accounts,
"fixed#wonderland",
AssetValueType::Numeric(NumericSpec::default()),
AssetType::Numeric(NumericSpec::default()),
numeric!(1.0),
numeric!(10.0),
numeric!(5.0),
Expand Down Expand Up @@ -131,7 +131,7 @@ fn test_total_quantity<T>(
test_client: &Client,
accounts: &[AccountId; 5],
definition: &str,
asset_value_type: AssetValueType,
asset_value_type: AssetType,
initial_value: T,
to_mint: T,
to_burn: T,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ impl Executor {

fn replace_token(accounts: &[(Account, DomainId)]) -> MigrationResult {
let can_unregister_domain_definition_id =
iroha_executor::default::permissions::domain::CanUnregisterDomain::id();
iroha_executor::default::permissions::domain::CanUnregisterDomain::name();

let can_control_domain_lives_definition_id = token::CanControlDomainLives::id();
let can_control_domain_lives_definition_id = token::CanControlDomainLives::name();

accounts
.iter()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ fn main(_owner: AccountId) {

Register::asset_definition(AssetDefinition::new(
time_id.clone(),
AssetValueType::Numeric(NumericSpec::default()),
AssetType::Numeric(NumericSpec::default()),
))
.execute()
.dbg_unwrap();

Register::asset_definition(AssetDefinition::new(
space_id.clone(),
AssetValueType::Numeric(NumericSpec::default()),
AssetType::Numeric(NumericSpec::default()),
))
.execute()
.dbg_unwrap();
Expand Down
4 changes: 2 additions & 2 deletions client/tests/integration/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ fn executor_upgrade_should_revoke_removed_permissions() -> Result<()> {
assert!(client
.request(FindExecutorDataModel)?
.permissions()
.contains(&can_unregister_domain_token.id));
.contains(can_unregister_domain_token.name()));

// Check that `TEST_ROLE` has permission
assert!(client
Expand Down Expand Up @@ -174,7 +174,7 @@ fn executor_upgrade_should_revoke_removed_permissions() -> Result<()> {
assert!(!client
.request(FindExecutorDataModel)?
.permissions()
.contains(&can_unregister_domain_token.id));
.contains(can_unregister_domain_token.name()));

// Check that `TEST_ROLE` doesn't have permission
assert!(!client
Expand Down
8 changes: 4 additions & 4 deletions client_cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Check the [Bash guide in Iroha Tutorial](https://hyperledger.github.io/iroha-2-d
```bash
./iroha domain register --id="Soramitsu"
./iroha account register --id="ed01204A3C5A6B77BBE439969F95F0AA4E01AE31EC45A0D68C131B2C622751FCC5E3B6@Soramitsu"
./iroha asset register --id="XOR#Soramitsu" --value-type=Numeric
./iroha asset register --id="XOR#Soramitsu" --type=Numeric
./iroha asset mint --account="ed01204A3C5A6B77BBE439969F95F0AA4E01AE31EC45A0D68C131B2C622751FCC5E3B6@Soramitsu" --asset="XOR#Soramitsu" --quantity=1010
./iroha asset get --account="ed01204A3C5A6B77BBE439969F95F0AA4E01AE31EC45A0D68C131B2C622751FCC5E3B6@Soramitsu" --asset="XOR#Soramitsu"
```
Expand Down Expand Up @@ -111,7 +111,7 @@ To do so, you must first register an Asset Definition and only then add some Ass
Every asset has its own value spec. In this example, it is defined as `Numeric`, a 96-bit unsigned decimal. We also support `Store` for key-value structured data.

```bash
./iroha asset register --id="XOR#Soramitsu" --value-type=Numeric
./iroha asset register --id="XOR#Soramitsu" --type=Numeric
./iroha asset mint --account="ed01204A3C5A6B77BBE439969F95F0AA4E01AE31EC45A0D68C131B2C622751FCC5E3B6@Soramitsu" --asset="XOR#Soramitsu" --quantity=1010
```

Expand Down Expand Up @@ -186,8 +186,8 @@ To test transactions in the JSON format (used in the genesis block and by other
cat /path/to/file.json | ./iroha json transaction
```

### Request arbitrary query
### Request arbitrary query

```bash
```bash
echo '{ "FindAllParameters": null }' | ./iroha --config client.toml json query
```
2 changes: 1 addition & 1 deletion client_cli/pytests/src/client_cli/client_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def definition(self, asset: str, domain: str, value_type: str):
:rtype: ClientCli
"""
self.command.append("--definition-id=" + asset + "#" + domain)
self.command.append("--value-type=" + value_type)
self.command.append("--type=" + value_type)
self.execute()
return self

Expand Down
6 changes: 3 additions & 3 deletions client_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ mod asset {
pub unmintable: bool,
/// Value type stored in asset
#[arg(short, long)]
pub value_type: AssetValueType,
pub r#type: AssetType,
#[command(flatten)]
pub metadata: MetadataArgs,
}
Expand All @@ -721,11 +721,11 @@ mod asset {
fn run(self, context: &mut dyn RunContext) -> Result<()> {
let Self {
definition_id,
value_type,
r#type,
unmintable,
metadata,
} = self;
let mut asset_definition = AssetDefinition::new(definition_id, value_type);
let mut asset_definition = AssetDefinition::new(definition_id, r#type);
if unmintable {
asset_definition = asset_definition.mintable_once();
}
Expand Down
Binary file modified configs/swarm/executor.wasm
Binary file not shown.
14 changes: 7 additions & 7 deletions configs/swarm/genesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"Register": {
"AssetDefinition": {
"id": "rose#wonderland",
"value_type": "Numeric",
"type": "Numeric",
"mintable": "Infinitely",
"logo": null,
"metadata": {}
Expand Down Expand Up @@ -69,7 +69,7 @@
"Register": {
"AssetDefinition": {
"id": "cabbage#garden_of_live_flowers",
"value_type": "Numeric",
"type": "Numeric",
"mintable": "Infinitely",
"logo": null,
"metadata": {}
Expand Down Expand Up @@ -114,7 +114,7 @@
"Grant": {
"Permission": {
"object": {
"id": "CanSetParameters",
"name": "CanSetParameters",
"payload": null
},
"destination": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland"
Expand Down Expand Up @@ -169,15 +169,15 @@
"id": "ALICE_METADATA_ACCESS",
"permissions": [
{
"id": "CanRemoveKeyValueInAccount",
"name": "CanRemoveKeyValueInAccount",
"payload": {
"account_id": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland"
"account": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland"
}
},
{
"id": "CanSetKeyValueInAccount",
"name": "CanSetKeyValueInAccount",
"payload": {
"account_id": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland"
"account": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland"
}
}
]
Expand Down
6 changes: 5 additions & 1 deletion core/src/query/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ use std::{
use indexmap::IndexMap;
use iroha_config::parameters::actual::LiveQueryStore as Config;
use iroha_data_model::{
query::{cursor::ForwardCursor, error::QueryExecutionFail, QueryId, QueryOutputBox},
query::{
cursor::{ForwardCursor, QueryId},
error::QueryExecutionFail,
QueryOutputBox,
},
BatchedResponse, BatchedResponseV1, ValidationFail,
};
use iroha_logger::trace;
Expand Down
Loading

0 comments on commit a251508

Please sign in to comment.