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

Implement revoke admin cli support #83

Merged
merged 8 commits into from
Mar 22, 2024
Merged

Conversation

joaosa
Copy link
Collaborator

@joaosa joaosa commented Mar 12, 2024

We couldn't really remove admins from the cli, so this should fix that. I wanted to cleanup the code a little bit, but I figured it would be more important to ship this rather than adjust existing functionality for code reuse.

  • Added a wrapper to use the contract's revoke_admin method;
  • Added the clap cli boilerplate to use it.

@joaosa joaosa requested review from travis and gammazero March 12, 2024 13:03
Copy link

@travis travis left a comment

Choose a reason for hiding this comment

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

I think we need to do a little more work to tell the user what's going on here - specific comment below but might be worth adding a couple other log lines - I'll leave that up to your judgement as I don't have much context with this code!

cli/src/utils.rs Outdated

info!("estimated grant gas cost {:#?}", claim_tx.tx.gas().unwrap());

send_tx(&claim_tx.tx, client, retries).await?;
Copy link

Choose a reason for hiding this comment

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

is it possible for this to throw errors? I don't know rust, but is there some mechanism for handling potential transaction failures? at the very least I think we should add a log line here confirming that the transaction was executed successfully, and ideally point the user at the chain explorer where they can manually verify the address is no longer an admin.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes. The ? operator is going to propagate any error back to the caller function because this function has a Result<(), Box<dyn std::error::Error>> return type.

That's a great suggestion. It would definitely help in terms of usability. I'll look into it :)

Copy link

@gammazero gammazero left a comment

Choose a reason for hiding this comment

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

Other than logging already suggested, this looks good. My rust knowledge is minimal for now, so I might be missing things.

Should there be a test for granting and revoking admin?

@joaosa
Copy link
Collaborator Author

joaosa commented Mar 18, 2024

Other than logging already suggested, this looks good. My rust knowledge is minimal for now, so I might be missing things.

Should there be a test for granting and revoking admin?

Thank you! I agree we should have this. I will have to learn how to use the test tooling to pull it off (which is probably a good thing anyway). Should it be a necessary to merge the PR?

@joaosa joaosa force-pushed the implement_cli_revoke_admin branch from 4679729 to 49fdbdc Compare March 19, 2024 13:28
@joaosa joaosa force-pushed the implement_cli_revoke_admin branch from 49fdbdc to 1fb33dc Compare March 19, 2024 13:30
@joaosa joaosa requested review from travis and gammazero March 20, 2024 13:39
@joaosa
Copy link
Collaborator Author

joaosa commented Mar 20, 2024

@travis @gammazero

  • added some logging so users can get the message address for the grant/revoke operations they ran and check them on GLIF right away;
  • added integration tests and verified things are working fine

I should also note that as things are, it's not possible to run integration tests locally as we're missing three secrets and we have to rely on CI. However, it's possible to troubleshoot what's going on with all these invocations on calibrationnet. Here's an example of the last CI run with all the integration test transactions (you'll need the abi.json to decode the messages).

@joaosa joaosa force-pushed the implement_cli_revoke_admin branch from eb1fbc4 to 4eb13a1 Compare March 21, 2024 16:43
Copy link

@gammazero gammazero left a comment

Choose a reason for hiding this comment

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

LGTM - Thanks for adding the admin grant/revoke tests. Since these pass I think we can call this good

@joaosa joaosa merged commit 2d26539 into main Mar 22, 2024
1 check passed
@joaosa joaosa deleted the implement_cli_revoke_admin branch March 22, 2024 15:16
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