hyperledger-iroha / iroha

Iroha - A simple, enterprise-grade decentralized ledger
https://wiki.hyperledger.org/display/iroha
Apache License 2.0
441 stars 279 forks source link

[BUG] Unable to create an account using the Rust API #3783

Closed 6r1d closed 1 year ago

6r1d commented 1 year ago

GIT commit hash

9273a912c8a97f9ce1bfaa302c7192554f7abf00, April 19, 2023

Minimum working example

let key = KeyPair::generate()?;
let account = Account::new(account_id.clone(), key.public_key());

Expected behaviour

An account should be created.

Actual behaviour

error[E0277]: `&iroha_core::prelude::PublicKey` is not an iterator
   --> src/main.rs:87:52
    |
87  |     let account = Account::new(account_id.clone(), key.public_key());
    |                   ------------                     ^^^^^^^^^^^^^^^^ `&iroha_core::prelude::PublicKey` is not an iterator
    |                   |
    |                   required by a bound introduced by this call
    |
    = help: the trait `Iterator` is not implemented for `&iroha_core::prelude::PublicKey`
    = note: required for `&iroha_core::prelude::PublicKey` to implement `IntoIterator`
note: required by a bound in `iroha_data_model::account::Account::new`
   --> /home/arminveres/Projects/bachelor-thesis-23/impl/iroha/data_model/src/account.rs:264:27
    |
262 |     pub fn new(
    |            --- required by a bound in this associated function
263 |         id: <Self as Identifiable>::Id,
264 |         signatories: impl IntoIterator<Item = PublicKey>,
    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Account::new`

For more information about this error, try `rustc --explain E0277`.
error: could not compile `iroha-example` (bin "iroha-example") due to previous error

Operating system

Fedora with kernel 6.4.7-200.fc38.x86_64

LibC type and version

GNU libc 2.37

Current environment

Source code build

Who can help?

No response

QuentinI commented 1 year ago

Judging from the error message following changes should work

let key = KeyPair::generate()?;
- let account = Account::new(account_id.clone(), key.public_key());
+ let account = Account::new(account_id.clone(), vec![key.public_key().clone()]);