Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Cli: Fix create-with-seed #8706

Merged
merged 4 commits into from
Mar 9, 2020

Conversation

CriesofCarrots
Copy link
Contributor

Problem

solana create-with-seed ... errors our no matter what from or config keypair is provided.
Also, users might want to derive keys from any kind of signer, including hardware wallets or seed phrases, and there is currently no support for that.

Summary of Changes

  • Handle --from and config keypair setting appropriately to fix subcommand
  • Add pubkey_of_signer() method to generate a pubkey from any kind of acceptable signer and use to extend create-with-seed functionality (we may want to use this method in other cli subcommands; will examine and pr separately)

Fixes #8696

@CriesofCarrots CriesofCarrots requested a review from t-nelson March 7, 2020 02:33
@CriesofCarrots
Copy link
Contributor Author

@garious , after this lands, this works:

solana create-address-with-seed "test" STAKE --from usb://ledger

@garious
Copy link
Contributor

garious commented Mar 7, 2020

Can't fix a regression without a test.

@CriesofCarrots
Copy link
Contributor Author

Can't fix a regression without a test.

✔️
(Not sure why github is showing my commits out of order)

@codecov
Copy link

codecov bot commented Mar 7, 2020

Codecov Report

Merging #8706 into master will decrease coverage by 0.0%.
The diff coverage is 89.4%.

@@           Coverage Diff            @@
##           master   #8706     +/-   ##
========================================
- Coverage    80.0%   80.0%   -0.1%     
========================================
  Files         260     260             
  Lines       56399   56460     +61     
========================================
+ Hits        45164   45212     +48     
- Misses      11235   11248     +13     

Copy link
Contributor

@t-nelson t-nelson left a comment

Choose a reason for hiding this comment

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

LGTM!

let config_pubkey = config.pubkey()?;
let from_pubkey = from_pubkey.unwrap_or(&config_pubkey);
let address = create_address_with_seed(from_pubkey, seed, program_id)?;
let from_pubkey = if let Some(pubkey) = from_pubkey {
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: unwrap_or()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can't use ? in a closure that returns a Pubkey, so the current construction seems simpler to me for the else case.

@CriesofCarrots CriesofCarrots merged commit eab80d0 into solana-labs:master Mar 9, 2020
mergify bot pushed a commit that referenced this pull request Mar 9, 2020
* Add failing test

* Fix create-address-with-seed regression

* Add apis to enable generating a pubkey from all various signers

* Enable other signers as --from in create-with-seed

(cherry picked from commit eab80d0)
solana-grimes pushed a commit that referenced this pull request Mar 9, 2020
@CriesofCarrots CriesofCarrots deleted the create-with-seed branch April 16, 2020 17:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLI: "create-address-with-seed" is broken
3 participants