-
Notifications
You must be signed in to change notification settings - Fork 48
Faucet v2 #108
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
Conversation
| client: &'a Client, | ||
| ) -> (Address, Ed25519PrivateKey, Vec<Coin<'a>>) { |
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 don't think this lifetime is correct as value borrowed wouldn't live long enough. probably more correct to make this 'static
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.
Clippy complains when making this static, here (and in all subsequent helper_setup calls)
| let (address, pk, coins) = helper_setup(&mut tx, &client).await; |
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.
whats the error you're seeing?
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.
If I make Vec<Coin<'static>>, then we get this -- note that compiling is fine, but clippy is unhappy
error: lifetime may not live long enough
--> crates/sui-transaction-builder/src/lib.rs:602:9
|
570 | async fn helper_setup<'a>(
| -- lifetime `'a` defined here
...
602 | (address, pk, coins.to_vec())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
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.
Note, that I am still pretty unfamiliar with lifetime annotations and don't really understand what's going on in this case.
If I remove the <'a> lifetime annotation from the function and replace it like this:
async fn helper_setup(
tx: &mut TransactionBuilder,
client: &'static Client,
) -> (Address, Ed25519PrivateKey, Vec<Coin<'static>>) {
then building fails, which is fair because all those tests create a local client object.
672 | let client = Client::new_localhost();
| ------ binding `client` declared here
673 | let (_, pk, coins) = helper_setup(&mut tx, &client).await;
| ----------------------^^^^^^^-
| | |
| | borrowed value does not live long enough
| argument requires that `client` is borrowed for `'static`
```
This PR updates the codebase to use the new v2 faucet APIs.