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

feat: added features to credential offer workflow #114

Merged
merged 10 commits into from
Mar 23, 2022

Conversation

berendsliedrecht
Copy link
Member

@berendsliedrecht berendsliedrecht commented Mar 21, 2022

  • feat: start workflow with qrcode
  • feat: send to self

will need a cleanup when we have time

You can test it with

aries-cli workflow credential-offer (optional --self and --timeout=20000)

Signed-off-by: Berend Sliedrecht <[email protected]>
Signed-off-by: Berend Sliedrecht <[email protected]>
Copy link
Contributor

@jloleysens jloleysens left a comment

Choose a reason for hiding this comment

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

Had some UX related thoughts, otherwise code structure LGTM.

timeout: Option<u32>,

#[clap(long = "self", short = 's')]
sent_to_self: bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
sent_to_self: bool,
send_to_self: bool,

WDYT about shortening to self and adding docs about the intended use via clap(...about=...)?

Copy link
Member Author

Choose a reason for hiding this comment

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

self is a reserved keyword and does not enjoy me using it.

Comment on lines 74 to 89
for i in 1..=limit {
let connection =
ConnectionModule::get_by_id(&agent, connection.connection_id.to_owned())
.await?;
if connection.state != "active" && connection.state != "response" {
trace!("Connection state is not active");
std::thread::sleep(std::time::Duration::from_millis(1000));
} else {
trace!("Connection state is active, continuing the flow");
credential_offer(connection.connection_id, agent).await?;
break;
}
if i == limit {
return Err(Error::InactiveConnection.into());
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit; since we ask the user for a timeout - im guessing in seconds? - this might wait longer than that amount of time since we are also waiting for a network request to complete. i don't think this is an issue particularly just that the time a user specifies will not be precise

Copy link
Member Author

Choose a reason for hiding this comment

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

I wanted to provide an option to override it. (its in millis), just if anyones use case might work differently.

ConnectionModule::get_by_id(&agent, connection.connection_id.to_owned())
.await?;
if connection.state != "active" && connection.state != "response" {
trace!("Connection state is not active");
Copy link
Contributor

Choose a reason for hiding this comment

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

Do these logs work when there is a spinner spinning?

Copy link
Member Author

Choose a reason for hiding this comment

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

It works :D

attributes.insert(String::from("Valid Until"), String::from("20251212"));
debug!("Mock credential:\n{:#?}", attributes);

let options = CredentialOfferWorkflow {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
let options = CredentialOfferWorkflow {
let workflow = CredentialOfferWorkflow {

seems like a clearer name IMO

);
copy!("{}", connection.invitation_url);
}
let limit = timeout.map(|t| t / 1000).unwrap_or(10);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should increase the default to 30s, rather than have it very low and then tell the user they should increase it.

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe even 1 minute TBH

agent.receive_invitation(invitation_object).await?;
} else {
qr::print_qr_code(&connection.invitation_url)?;
println!("Connection id: {}", connection.connection_id);
Copy link
Contributor

@jloleysens jloleysens Mar 22, 2022

Choose a reason for hiding this comment

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

i think we should update the format of these logs, optimizing for making sure the user understands what is currently expected of them

[QR code]
\n
Created.green() invitation to connect with <id>.bold() - your env.name().cyan() agent.
\n
Scan.bold() the QR code above to accept the invitation or use this URL:
\n
[URL]
\n
Waiting.cyan() for invitation to be accepted (timeout <sec>s.bold())...
[spinner spinning away]

Copy link
Contributor

Choose a reason for hiding this comment

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

Updated suggestion!

cli/src/modules/workflow.rs Outdated Show resolved Hide resolved
cli/src/modules/workflow.rs Outdated Show resolved Hide resolved
cli/src/modules/workflow.rs Outdated Show resolved Hide resolved
@@ -20,7 +26,13 @@ pub struct WorkflowOptions {
pub enum WorkflowSubcommands {
CredentialOffer {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you mind adding some docs to this bad boy?

@jloleysens
Copy link
Contributor

@blu3beri i've pushed a few cosmetic changes to the workflow copy.

{391AC38B-524A-45B9-A625-849555373076}

It'd be great to indent the text consistently under the heading. TUIs!

@jloleysens jloleysens self-requested a review March 23, 2022 11:20
Copy link
Contributor

@jloleysens jloleysens left a comment

Choose a reason for hiding this comment

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

LGTM after last round of tests and updates.

@jloleysens
Copy link
Contributor

{391AC38B-524A-45B9-A625-849555373076}

I think we can consider generalizing this kind of output to other workflows as they are added, no need to get into that for this PR IMO.

@berendsliedrecht berendsliedrecht merged commit 94446fc into main Mar 23, 2022
@berendsliedrecht berendsliedrecht deleted the feat/offer-workflow branch March 23, 2022 11:24
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.

2 participants