-
Notifications
You must be signed in to change notification settings - Fork 26
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
base: main
Are you sure you want to change the base?
Introduce Cookbook #424
Changes from 1 commit
b5c440b
ea2c326
ffd86e1
a4c58a7
9f5abbc
64b80f7
9555936
a6e80fb
772e30f
d227ba1
5dd9d21
c1738e2
cd28f8f
60f5874
778d8a3
e2df86c
cbd941b
90a4e7e
951c9db
619c0e8
9fa9e2e
b59603f
6d4ff5d
1fd5958
a4af32b
1551872
9ebde90
e7f8ab7
1763b34
bc1a100
8de8655
7145cbb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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() | ||
); | ||
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( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it's non-mintable, how could we mint it 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
||
} | ||
``` |
There was a problem hiding this comment.
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.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took the example from the integration tests: /~https://github.com/hyperledger/iroha/blob/v2.0.0-pre-rc.21.1/client/tests/integration/non_mintable.rs#L12