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 sdk feature into feat 2.0 #106

Closed
wants to merge 41 commits into from
Closed

Conversation

gRoussac
Copy link
Contributor

@gRoussac gRoussac commented Sep 16, 2023

Right now this feature only build with --lib

Mainly adds some #[cfg(feature = "sdk")] where it is possible or not to use io/fs, or prevent sending to std with json_pretty_print and returning deploys
Changes the way secret key is loaded in with_payment_and_session()
Publicizes some methods outside the crate
Adds session_bytes to session_executable_deploy_item() and adds check_no_conflicting_arg_types() (might require additional unit tests)
Adds with_bytes() to SessionStrParams
Adds some Clone attributes to some structs
Removes rt-multi-thread, The default runtime flavor is 'multi_thread', but the 'rt-multi-thread' feature is disabled. switching (flavor = "current_thread") to tokio main

I could not make it compile without this change in cargo.toml related to casper types
getrandom = { version = "0.2.10", features = ["js"] } getrandom probably needs to be replaced by something else.

Removing [patch.crates-io] as I believe this bug was fixed and this is not needed anymore.

casper-ecosystem/rustSDK#4
casper-ecosystem/rustSDK#5

@gRoussac gRoussac self-assigned this Sep 18, 2023
@gRoussac gRoussac marked this pull request as ready for review September 18, 2023 09:34
Copy link
Contributor

@bpr bpr left a comment

Choose a reason for hiding this comment

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

LGTM, but please wait for @Fraser999 and @zacshowa to review before merging. There's a lot of changes and I think we should tread carefully here.

Copy link
Contributor

@zacshowa zacshowa left a comment

Choose a reason for hiding this comment

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

A few things could use some changes/clarification.

@@ -123,3 +98,38 @@ pub fn new_transfer(
.map_err(crate::Error::from)?;
Ok(deploy)
}

fn get_maybe_secret_key(
Copy link
Contributor

Choose a reason for hiding this comment

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

The change to this function is interesting.

Perhaps we could look to overload the function by conditionally compiling 1 of 2 functions of the same name behind feature flags as opposed to modifying the body of one function for readability.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well mostly this code was repeated two times in the file and we already discussed this condition

 let maybe_secret_key = if allow_unsigned_deploy && deploy_params.secret_key.is_empty() {
        None
    } else if deploy_params.secret_key.is_empty() && !allow_unsigned_deploy {
   

is imo more idiomatic in if A / else if B / else. It's quite complicate to have cargo check and cargo clippy accepting overloads, I tried to have 1/2 methods with both config accordingly and that never passed cargo check/clippy. Most of times the only accepted way is to simply have #[cfg] working like if statements. Otherwise most of the times a function will be missing on compilation if you have like --features-all

Copy link
Contributor

Choose a reason for hiding this comment

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

The structure of the if else is fine, It's functionally equivalent and should work fine.
I do think that if you like the style suggestion I put on the sister PR against the node I would love to see the same style applied to the feature flag here. If you don't want to go with that style, consider the PR approved.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Casper client do not seem to have cargo clippy so I can duplicate this method in the client without side effects apparently.

Please check that commit 4855e7b thanks

lib/cli/error.rs Show resolved Hide resolved
lib/cli/parse.rs Outdated Show resolved Hide resolved
lib/cli.rs Show resolved Hide resolved
src/main.rs Show resolved Hide resolved
Cargo.toml Show resolved Hide resolved
Copy link
Contributor

@bpr bpr left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@zacshowa zacshowa left a comment

Choose a reason for hiding this comment

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

Like I said in the comment on deploy if you don't like the style suggestion consider the PR approved.

@@ -123,3 +98,38 @@ pub fn new_transfer(
.map_err(crate::Error::from)?;
Ok(deploy)
}

fn get_maybe_secret_key(
Copy link
Contributor

Choose a reason for hiding this comment

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

The structure of the if else is fine, It's functionally equivalent and should work fine.
I do think that if you like the style suggestion I put on the sister PR against the node I would love to see the same style applied to the feature flag here. If you don't want to go with that style, consider the PR approved.

zacshowa

This comment was marked as duplicate.

@gRoussac gRoussac closed this Oct 4, 2023
@gRoussac gRoussac deleted the rustSDK-feat-2.0 branch October 4, 2023 19:29
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