Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Cookbook #424

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
b5c440b
Introduce cookbook (updated init version)
outoftardis Nov 2, 2023
ea2c326
Update .vitepress/config.mts
outoftardis Nov 16, 2023
ffd86e1
Update .vitepress/config.mts
outoftardis Nov 16, 2023
a4c58a7
Update .vitepress/config.mts
outoftardis Nov 16, 2023
9f5abbc
Update .vitepress/config.mts
outoftardis Nov 16, 2023
64b80f7
Update .vitepress/config.mts
outoftardis Nov 16, 2023
9555936
Update .vitepress/config.mts
outoftardis Nov 16, 2023
a6e80fb
Update .vitepress/config.mts
outoftardis Nov 21, 2023
772e30f
Address comments
outoftardis Nov 21, 2023
d227ba1
Remove comments
outoftardis Nov 21, 2023
5dd9d21
Fix formatting
outoftardis Nov 21, 2023
c1738e2
Add files with metadata
outoftardis Nov 23, 2023
cd28f8f
Fix format
outoftardis Nov 23, 2023
60f5874
Apply suggestions from code review
outoftardis Nov 24, 2023
778d8a3
Add a topic
outoftardis Nov 30, 2023
e2df86c
[docs]: add MST draft
0x009922 Dec 4, 2023
cbd941b
Apply suggestions from code review
0x009922 Dec 7, 2023
90a4e7e
[docs]: refine MST recipe
0x009922 Dec 7, 2023
951c9db
ADD: Few examples
Stukalov-A-M Jan 20, 2024
619c0e8
ADD: burn-assets.md, submit-transactions.md
Stukalov-A-M Jan 21, 2024
9fa9e2e
EDIT: Indents are removed
Stukalov-A-M Jan 22, 2024
b59603f
Merge pull request #1 from Stukalov-A-M/pr424
0x009922 Jan 26, 2024
6d4ff5d
[ADD]: access-metadata, check-status, combine-instructions, create-tr…
Stukalov-A-M Jan 29, 2024
1fd5958
[ADD]: register-domains, unregister-asset-def, unregister-assets, unr…
Stukalov-A-M Feb 9, 2024
a4af32b
[ADD]: unregister-accounts
Stukalov-A-M Feb 9, 2024
1551872
[add]: register-roles, use-instructions, work-with-numeric-assets
nxsaken Apr 10, 2024
9ebde90
[add]: grant-permissions, grant-roles
nxsaken Apr 11, 2024
e7f8ab7
[add]: work-with-non-mintable-assets
nxsaken Apr 16, 2024
1763b34
[add]: revoke-permissions, revoke-roles, transfer-assets, work-with-s…
nxsaken Apr 16, 2024
bc1a100
[edit]: edit existing entries to match newer examples, replace some o…
nxsaken Apr 17, 2024
8de8655
[add]: transfer-group-assets
nxsaken Apr 18, 2024
7145cbb
Address feedback
nxsaken May 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion src/cookbook/revoke-permissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,32 @@ head:

# How to Revoke Permissions

TODO
```rust
fn revoke_permission_from_account(
iroha: &Client,
) {
let revoke_permission_to_unregister_kingdom = Revoke::permission(
PermissionToken::new(
"CanUnregisterDomain".parse().unwrap(),
nxsaken marked this conversation as resolved.
Show resolved Hide resolved
&json!({ "domain_id": "kingdom" }),
),
AccountId::from_str("alice@wonderland").unwrap()
);
iroha.submit(revoke_permission_to_unregister_kingdom).unwrap();
}
```

```rust
fn revoke_permission_from_role(
iroha: &Client,
) {
let revoke_permission_to_unregister_kingdom = Revoke::role_permission(
PermissionToken::new(
"CanUnregisterDomain".parse().unwrap(),
&json!({ "domain_id": "kingdom" }),
),
RoleId::from_str("DOMAIN_DESTROYER").unwrap(),
);
iroha.submit(revoke_permission_to_unregister_kingdom).unwrap();
}
```
13 changes: 12 additions & 1 deletion src/cookbook/revoke-roles.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,15 @@ head:

# How to Revoke Roles

TODO
```rust
fn revoke_role(
iroha: &Client,
) {
// given that Alice has the role, revoke it
let revoke_role = Revoke::role(
RoleId::from_str("DOMAIN_DESTROYER"),
AccountId::from_str("alice@wonderland").unwrap()
);
iroha.submit(revoke_role).unwrap();
}
```
31 changes: 30 additions & 1 deletion src/cookbook/transfer-assets.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,33 @@ head:

# How to Transfer Assets Between Accounts

TODO
```rust
fn transfer_numeric_asset(
iroha: &Client,
) {
let roses = AssetDefinitionId::from_str("rose#wonderland").unwrap();
let alice = AccountId::from_str("alice@wonderland").unwrap();
let mouse = AccountId::from_str("mouse@wonderland").unwrap();
let transfer_roses_from_alice_to_mouse = Transfer::asset_numeric(
AssetId::new(roses, alice),
13_u32,
mouse,
);
iroha.submit(transfer_roses_from_alice_to_mouse).unwrap();
}
```

```rust
fn transfer_store_asset(
iroha: &Client,
) {
let hats = AssetDefinitionId::from_str("hat#outfit").unwrap();
let alice = AccountId::from_str("alice@outfit").unwrap();
let mouse = AccountId::from_str("mouse@outfit").unwrap();
let transfer_hat_from_alice_to_mouse = Transfer::asset_store(
AssetId::new(hats, alice),
mouse,
);
iroha.submit(transfer_hat_from_alice_to_mouse).unwrap();
}
```
37 changes: 36 additions & 1 deletion src/cookbook/work-with-store-assets.md
nxsaken marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,39 @@ head:

# How to Work with Store Assets

TODO
While numeric assets represent quantities, store assets represent
arbitrary key-value tables.

```rust
fn define_store_asset(
iroha: &Client,
) {
let hats = AssetDefinitionId::from_str("hat#outfit").unwrap();
let hats_as_a_concept = AssetDefinition::store(hats);
iroha.submit(Register::asset_definition(hats_as_a_concept)).unwrap();
}
```

```rust
fn set_key_value_pair(
iroha: &Client,
) {
let hat_of_alice = AssetId::from_str("hat##alice@outfit").unwrap();
let color = Name::from_str("color").unwrap();
iroha.submit(SetKeyValue::asset(
hat_of_alice,
color,
"red".to_owned()
)).unwrap();
}
```

```rust
fn unset_key_value_pair(
iroha: &Client,
) {
let hat_of_alice = AssetId::from_str("hat##alice@outfit").unwrap();
let color = Name::from_str("color").unwrap();
iroha.submit(RemoveKeyValue::asset(hats, color)).unwrap();
}
```
Loading