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

Add Rust examples #22

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft

Conversation

nxsaken
Copy link

@nxsaken nxsaken commented Jun 21, 2024

This is a draft PR on new Rust SDK examples.

Signed-off-by: Nurzhan Sakén <nurzhan.sakenov@gmail.com>
@nxsaken nxsaken self-assigned this Jun 21, 2024
Copy link
Contributor

@0x009922 0x009922 left a comment

Choose a reason for hiding this comment

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

New examples look indeed more expressive with a thin higher-level layer. However, I think it is problematic that we will have to introduce readers into these examples-specific abstractions. Although it is now certainly a step towards better examples, I think it is a sign that something like this should be a part of iroha library API. In my view, best examples would be "bare", self-contained, and would not require extra layers apart from the target library itself.

Rust/configs/bob_chess.toml Outdated Show resolved Hide resolved
Rust/examples/account_register.rs Outdated Show resolved Hide resolved
Signed-off-by: Nurzhan Sakén <nurzhan.sakenov@gmail.com>
@nxsaken
Copy link
Author

nxsaken commented Jun 24, 2024

@0x009922 I definitely went overboard with the asset definitions, realized I can remove all that stuff. I guess the pain point that led to this is the lack of const APIs for constructing data primitives.

Signed-off-by: Nurzhan Sakén <nurzhan.sakenov@gmail.com>
Signed-off-by: Nurzhan Sakén <nurzhan.sakenov@gmail.com>
Signed-off-by: Nurzhan Sakén <nurzhan.sakenov@gmail.com>
Signed-off-by: Nurzhan Sakén <nurzhan.sakenov@gmail.com>
Signed-off-by: Nurzhan Sakén <nurzhan.sakenov@gmail.com>
@@ -0,0 +1,13 @@
chain = "00000000-0000-0000-0000-000000000000"
Copy link

Choose a reason for hiding this comment

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

we emphasize somewhere in the docs that this value must be generated as UUID (and why). This here is just a dummy value

password = "ilovetea"

[account]
# Domain in which Alice has an authority
Copy link

Choose a reason for hiding this comment

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

what does "has an authority" mean here? I'd rephrase

register(&as_alice_in_wland, AliceInChess::id())?;

// The domain owner can also grant a permission to register accounts in the domain.
let can_register_accounts_in_chess = CanRegisterAccountInDomain {
Copy link

Choose a reason for hiding this comment

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

Suggested change
let can_register_accounts_in_chess = CanRegisterAccountInDomain {
let can_register_accounts_in_chess = CanRegisterAccount {

Copy link

Choose a reason for hiding this comment

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

if you run cargo check this should fail

Comment on lines +17 to +18
iroha = { git = "https://github.com/hyperledger/iroha.git" }
iroha_executor_data_model = { git = "https://github.com/hyperledger/iroha.git" }
Copy link

Choose a reason for hiding this comment

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

Suggested change
iroha = { git = "https://github.com/hyperledger/iroha.git" }
iroha_executor_data_model = { git = "https://github.com/hyperledger/iroha.git" }
iroha = { version = "=2.0.0-rc.1.0", git = "https://github.com/hyperledger/iroha.git" }
iroha_executor_data_model = { version = "=2.0.0-rc.1.0", git = "https://github.com/hyperledger/iroha.git" }

Copy link

Choose a reason for hiding this comment

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

until we publish on crates.io

.filter_with(|acc| acc.id.eq(account.clone()))
.execute_single()
.expect_err("account should not be found");
println!("Account: {}\nUnregistered by: {}", account, as_who.account);
Copy link

@mversic mversic Nov 6, 2024

Choose a reason for hiding this comment

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

Suggested change
println!("Account: {}\nUnregistered by: {}", account, as_who.account);
println!("Account: {account}\nUnregistered by: {}", as_who.account);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants