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
46 changes: 45 additions & 1 deletion src/cookbook/work-with-non-mintable-assets.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,48 @@ head:

# How to Work with Non-Mintable Assets

TODO
```rust
fn register_non_mintable_asset(
iroha: &Client,
) {
let magical_keys = AssetDefinitionId::from_str("magical_key#wonderland").unwrap();
// register keys as an asset definition
let register_keys_as_a_concept = Register::asset_definition(
AssetDefinition::new(
magical_keys.clone(),
AssetValueType::Numeric(NumericSpec::integer()),
).mintable_once()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This snippet registers an asset with mintable_once, which is different from a non-mintable asset.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

);
let alice = "alice@wonderland".parse().unwrap();
// Alice owns ten keys and cannot mint more
let initial_keys_of_alice = Asset::new(
AssetId::new(roses, alice),
10_u32
);
let register_keys_of_alice = Register::asset(initial_keys_of_alice);
iroha.submit_all([
InstructionBox::from(register_keys_as_a_concept),
InstructionBox::from(register_keys_of_alice)
]).unwrap();
nxsaken marked this conversation as resolved.
Show resolved Hide resolved
}
```

```rust
fn mint_non_mintable_asset(
Copy link
Contributor Author

@0x009922 0x009922 May 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's non-mintable, how could we mint it 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, I think the mintability naming is unfortunate, and we should rethink it. But that's an issue for the main repo

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as #424 (comment)

iroha: &Client,
) {
// Alice owns zero keys and can mint once
let keys_of_alice = "magical_key##alice@wonderland".parse().unwrap();
let zero_keys_of_alice = Asset::new(
keys_of_alice.clone(),
0_u32
);
let register_keys_of_alice = Register::asset(zero_keys_of_alice);
let mint_keys_for_alice = Mint::asset_numeric(10_u32, keys_of_alice);
iroha.submit_all([
InstructionBox::from(register_keys_as_a_concept),
InstructionBox::from(register_keys_of_alice),
InstructionBox::from(mint_keys_for_alice),
]).unwrap();
nxsaken marked this conversation as resolved.
Show resolved Hide resolved
}
```
27 changes: 27 additions & 0 deletions src/cookbook/work-with-numeric-assets.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,33 @@ head:

# How to Work with Numeric Assets

Registering Alice's roses:

```rust
fn register_numeric_asset(
iroha: &Client,
) {
let roses = AssetDefinitionId::from_str("rose#wonderland").unwrap();
// register roses as an asset definition
let register_roses_as_a_concept = Register::asset_definition(
AssetDefinition::new(
roses.clone(),
// for the sake of the example, allow whole roses only
AssetValueType::Numeric(NumericSpec::integer()),
)
);
let alice = "alice@wonderland".parse().unwrap();
let roses_of_alice = AssetId::new(roses, alice);
let initial_roses_of_alice = Asset::new(roses_of_alice, 0_u32);
// register zero roses as Alice's asset
let register_roses_of_alice = Register::asset(initial_roses_of_alice);
iroha.submit_all([
InstructionBox::from(register_roses_as_a_concept),
InstructionBox::from(register_roses_of_alice)
]).unwrap();
nxsaken marked this conversation as resolved.
Show resolved Hide resolved
}
```

Minting roses for Alice:

```rust
Expand Down