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(cast): add json flag in cast wallet new-mnemonic #9139

Merged

Conversation

leovct
Copy link
Contributor

@leovct leovct commented Oct 18, 2024

Motivation

Closes #9138

Solution

$ castdev wallet new-mnemonic --entropy 0xdf9bf37e6fcdf9bf37e6fcdf9bf37e3c --accounts 3 --json
[
  {
    "mnemonic": "test test test test test test test test test test test junk",
    "accounts": [
      {
        "address": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
        "private_key": "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
      },
      {
        "address": "0x70997970c51812dc3a010c7d01b50e0d17dc79c8",
        "private_key": "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"
      },
      {
        "address": "0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc",
        "private_key": "0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a"
      }
    ]
  }
]
$ castdev wallet new-mnemonic --entropy 0xdf9bf37e6fcdf9bf37e6fcdf9bf37e3c --accounts 3 --json | jq '.[0].mnemonic'
"test test test test test test test test test test test junk"
$ castdev wallet new-mnemonic --entropy 0xdf9bf37e6fcdf9bf37e6fcdf9bf37e3c --accounts 3 --json | jq '.[0].accounts[0].address' 
"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"

@leovct leovct marked this pull request as ready for review October 18, 2024 12:50
@foundry-rs foundry-rs deleted a comment Oct 18, 2024
@leovct leovct force-pushed the feat/cast-wallet-new-mnemonic-json-mode branch from 8be4c32 to 2eb9d7a Compare October 19, 2024 23:08
Copy link
Collaborator

@grandizzy grandizzy left a comment

Choose a reason for hiding this comment

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

lgtm, couple of comments added

crates/cast/bin/cmd/wallet/mod.rs Outdated Show resolved Hide resolved
crates/cast/bin/cmd/wallet/mod.rs Outdated Show resolved Hide resolved
crates/cast/bin/cmd/wallet/mod.rs Outdated Show resolved Hide resolved
Copy link
Member

@zerosnacks zerosnacks left a comment

Choose a reason for hiding this comment

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

Supportive of the feature, some minor notes

@grandizzy grandizzy self-requested a review October 21, 2024 11:06
Copy link
Collaborator

@grandizzy grandizzy 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!

@zerosnacks zerosnacks self-requested a review October 21, 2024 11:11
Copy link
Member

@zerosnacks zerosnacks left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM

@zerosnacks zerosnacks merged commit 7c1c019 into foundry-rs:master Oct 21, 2024
21 checks passed
@leovct leovct deleted the feat/cast-wallet-new-mnemonic-json-mode branch October 21, 2024 11:59
rplusq pushed a commit to rplusq/foundry that referenced this pull request Nov 29, 2024
…#9139)

* feat(cast): add `json` flag in `cast wallet new-mnemonic`

* Update crates/cast/bin/cmd/wallet/mod.rs

Co-authored-by: zerosnacks <[email protected]>

* Update crates/cast/tests/cli/main.rs

Co-authored-by: zerosnacks <[email protected]>

* chore: adjust `wallet_mnemonic_from_entropy` to generate three accounts instead of one

* Update crates/cast/bin/cmd/wallet/mod.rs

Co-authored-by: zerosnacks <[email protected]>

* fix: preserve check-summed format for addresses

* chore: simplify code

* fix: rustfmt

---------

Co-authored-by: zerosnacks <[email protected]>
@grandizzy grandizzy added T-feature Type: feature C-cast Command: cast labels Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cast Command: cast T-feature Type: feature
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

feat(cast): add --json flag in cast wallet new-mnemonic
3 participants