Skip to content

Commit

Permalink
DerivationPath Alias (#471)
Browse files Browse the repository at this point in the history
### Description

add alias for celoLegacy to derivationPath flag on account:new command

This is currently same behavior as the default but that will change in a
future version.

#### Other changes

shift imports to be direct from celo/base instead of reexported from
cryptographic utils

### Related issues

- part of #448

<!-- start pr-codex -->

---

## PR-Codex overview
This PR introduces enhancements to the `account:new` command in the Celo
CLI, including new derivation path aliases and improved output for the
BIP44 derivation path. It also updates documentation and ensures better
error handling for invalid derivation paths.

### Detailed summary
- Added `DerivationPathAliases` enum with `eth` and `celoLegacy`.
- Updated `account:new` command to support new derivation path aliases.
- Improved output to include full BIP44 derivation path.
- Updated documentation for `--derivationPath` flag.
- Enhanced error handling for invalid derivation paths.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
  • Loading branch information
aaronmgdr authored Dec 6, 2024
1 parent 059141e commit 26b9779
Show file tree
Hide file tree
Showing 18 changed files with 238 additions and 56 deletions.
5 changes: 5 additions & 0 deletions .changeset/nice-fireants-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@celo/celocli': patch
---

when account:new is called it displays the full bip44 derivation path in the output. Before it would miss the last 2 positions.
5 changes: 5 additions & 0 deletions .changeset/tasty-hounds-occur.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@celo/base': minor
---

add DerivationPathAliases export
6 changes: 6 additions & 0 deletions .changeset/tasty-schools-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@celo/celocli': minor
---

For `account:new` command add alias "celoLegacy" to the `--derivationPath` flag

21 changes: 17 additions & 4 deletions docs/command-line-interface/account.md
Original file line number Diff line number Diff line change
Expand Up @@ -986,10 +986,7 @@ FLAGS
Choose the change index for the derivation path
--derivationPath=<value>
Choose a different derivation Path (Celo's default is "m/44'/52752'/0'"). Use "eth"
as an alias of the Ethereum derivation path ("m/44'/60'/0'"). Recreating the same
account requires knowledge of the mnemonic, passphrase (if any), and the derivation
path
Derivation path in the format "m/44'/coin_type'/account'" or an alias
--globalHelp
View all available global flags
Expand Down Expand Up @@ -1032,6 +1029,12 @@ EXAMPLES
new --passphrasePath some_folder/my_passphrase_file --mnemonicPath some_folder/my_mnemonic_file --addressIndex 5
new --derivationPath eth
new --derivationPath celoLegacy
new --derivationPath "m/44'/60'/0'"
FLAG DESCRIPTIONS
-n, --node=<value> URL of the node to run commands against or an alias
Expand All @@ -1041,6 +1044,16 @@ FLAG DESCRIPTIONS
local, localhost => 'http://localhost:8545'
alfajores => Celo Alfajores Testnet,
mainnet, celo, forno => Celo Mainnet chain',
--derivationPath=<value>
Derivation path in the format "m/44'/coin_type'/account'" or an alias
Choose a different derivation Path (Celo's default is "m/44'/52752'/0'"). Use "eth"
as an alias of the Ethereum derivation path ("m/44'/60'/0'"). Recreating the same
account requires knowledge of the mnemonic, passphrase (if any), and the derivation
path. (use changeIndex, and addressIndex flags to change BIP44 positions 4 and 5)
```

_See code: [src/commands/account/new.ts](https://github.com/celo-org/developer-tooling/tree/master/packages/cli/src/commands/account/new.ts)_
Expand Down
32 changes: 32 additions & 0 deletions docs/sdk/base/enums/account.DerivationPathAliases.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[@celo/base](../README.md) / [account](../modules/account.md) / DerivationPathAliases

# Enumeration: DerivationPathAliases

[account](../modules/account.md).DerivationPathAliases

## Table of contents

### Enumeration Members

- [celoLegacy](account.DerivationPathAliases.md#celolegacy)
- [eth](account.DerivationPathAliases.md#eth)

## Enumeration Members

### celoLegacy

**celoLegacy** = ``"m/44'/52752'/0'"``

#### Defined in

[packages/sdk/base/src/account.ts:7](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L7)

___

### eth

**eth** = ``"m/44'/60'/0'"``

#### Defined in

[packages/sdk/base/src/account.ts:6](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L6)
18 changes: 9 additions & 9 deletions docs/sdk/base/enums/account.MnemonicLanguages.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#### Defined in

[packages/sdk/base/src/account.ts:9](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L9)
[packages/sdk/base/src/account.ts:16](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L16)

___

Expand All @@ -36,7 +36,7 @@ ___

#### Defined in

[packages/sdk/base/src/account.ts:10](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L10)
[packages/sdk/base/src/account.ts:17](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L17)

___

Expand All @@ -46,7 +46,7 @@ ___

#### Defined in

[packages/sdk/base/src/account.ts:11](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L11)
[packages/sdk/base/src/account.ts:18](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L18)

___

Expand All @@ -56,7 +56,7 @@ ___

#### Defined in

[packages/sdk/base/src/account.ts:12](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L12)
[packages/sdk/base/src/account.ts:19](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L19)

___

Expand All @@ -66,7 +66,7 @@ ___

#### Defined in

[packages/sdk/base/src/account.ts:13](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L13)
[packages/sdk/base/src/account.ts:20](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L20)

___

Expand All @@ -76,7 +76,7 @@ ___

#### Defined in

[packages/sdk/base/src/account.ts:14](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L14)
[packages/sdk/base/src/account.ts:21](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L21)

___

Expand All @@ -86,7 +86,7 @@ ___

#### Defined in

[packages/sdk/base/src/account.ts:15](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L15)
[packages/sdk/base/src/account.ts:22](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L22)

___

Expand All @@ -96,7 +96,7 @@ ___

#### Defined in

[packages/sdk/base/src/account.ts:17](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L17)
[packages/sdk/base/src/account.ts:24](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L24)

___

Expand All @@ -106,4 +106,4 @@ ___

#### Defined in

[packages/sdk/base/src/account.ts:16](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L16)
[packages/sdk/base/src/account.ts:23](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L23)
4 changes: 2 additions & 2 deletions docs/sdk/base/enums/account.MnemonicStrength.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#### Defined in

[packages/sdk/base/src/account.ts:4](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L4)
[packages/sdk/base/src/account.ts:11](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L11)

___

Expand All @@ -29,4 +29,4 @@ ___

#### Defined in

[packages/sdk/base/src/account.ts:5](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L5)
[packages/sdk/base/src/account.ts:12](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L12)
8 changes: 4 additions & 4 deletions docs/sdk/base/interfaces/account.Bip39.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

#### Defined in

[packages/sdk/base/src/account.ts:28](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L28)
[packages/sdk/base/src/account.ts:35](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L35)

___

Expand All @@ -62,7 +62,7 @@ ___

#### Defined in

[packages/sdk/base/src/account.ts:27](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L27)
[packages/sdk/base/src/account.ts:34](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L34)

___

Expand All @@ -87,7 +87,7 @@ ___

#### Defined in

[packages/sdk/base/src/account.ts:26](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L26)
[packages/sdk/base/src/account.ts:33](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L33)

___

Expand All @@ -112,4 +112,4 @@ ___

#### Defined in

[packages/sdk/base/src/account.ts:33](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L33)
[packages/sdk/base/src/account.ts:40](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L40)
14 changes: 13 additions & 1 deletion docs/sdk/base/modules/account.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

### Enumerations

- [DerivationPathAliases](../enums/account.DerivationPathAliases.md)
- [MnemonicLanguages](../enums/account.MnemonicLanguages.md)
- [MnemonicStrength](../enums/account.MnemonicStrength.md)

Expand All @@ -20,6 +21,7 @@
### Variables

- [CELO\_DERIVATION\_PATH\_BASE](account.md#celo_derivation_path_base)
- [ETHEREUM\_DERIVATION\_PATH](account.md#ethereum_derivation_path)

## Type Aliases

Expand All @@ -44,7 +46,7 @@

#### Defined in

[packages/sdk/base/src/account.ts:20](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L20)
[packages/sdk/base/src/account.ts:27](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L27)

## Variables

Expand All @@ -55,3 +57,13 @@
#### Defined in

[packages/sdk/base/src/account.ts:1](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L1)

___

### ETHEREUM\_DERIVATION\_PATH

`Const` **ETHEREUM\_DERIVATION\_PATH**: ``"m/44'/60'/0'"``

#### Defined in

[packages/sdk/base/src/account.ts:3](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/base/src/account.ts#L3)
14 changes: 14 additions & 0 deletions docs/sdk/base/modules/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
- [CELO\_DERIVATION\_PATH\_BASE](index.md#celo_derivation_path_base)
- [CeloTokenType](index.md#celotokentype)
- [Comparator](index.md#comparator)
- [DerivationPathAliases](index.md#derivationpathaliases)
- [ETHEREUM\_DERIVATION\_PATH](index.md#ethereum_derivation_path)
- [Err](index.md#err)
- [ErrorResult](index.md#errorresult)
- [Future](index.md#future)
Expand Down Expand Up @@ -148,6 +150,18 @@ Re-exports [Comparator](collections.md#comparator)

___

### DerivationPathAliases

Re-exports [DerivationPathAliases](../enums/account.DerivationPathAliases.md)

___

### ETHEREUM\_DERIVATION\_PATH

Re-exports [ETHEREUM_DERIVATION_PATH](account.md#ethereum_derivation_path)

___

### Err

Re-exports [Err](result.md#err)
Expand Down
18 changes: 9 additions & 9 deletions docs/sdk/cryptographic-utils/enums/account.MnemonicLanguages.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#### Defined in

base/lib/account.d.ts:8
base/lib/account.d.ts:13

___

Expand All @@ -36,7 +36,7 @@ ___

#### Defined in

base/lib/account.d.ts:9
base/lib/account.d.ts:14

___

Expand All @@ -46,7 +46,7 @@ ___

#### Defined in

base/lib/account.d.ts:10
base/lib/account.d.ts:15

___

Expand All @@ -56,7 +56,7 @@ ___

#### Defined in

base/lib/account.d.ts:11
base/lib/account.d.ts:16

___

Expand All @@ -66,7 +66,7 @@ ___

#### Defined in

base/lib/account.d.ts:12
base/lib/account.d.ts:17

___

Expand All @@ -76,7 +76,7 @@ ___

#### Defined in

base/lib/account.d.ts:13
base/lib/account.d.ts:18

___

Expand All @@ -86,7 +86,7 @@ ___

#### Defined in

base/lib/account.d.ts:14
base/lib/account.d.ts:19

___

Expand All @@ -96,7 +96,7 @@ ___

#### Defined in

base/lib/account.d.ts:16
base/lib/account.d.ts:21

___

Expand All @@ -106,4 +106,4 @@ ___

#### Defined in

base/lib/account.d.ts:15
base/lib/account.d.ts:20
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#### Defined in

base/lib/account.d.ts:4
base/lib/account.d.ts:9

___

Expand All @@ -29,4 +29,4 @@ ___

#### Defined in

base/lib/account.d.ts:5
base/lib/account.d.ts:10
Loading

0 comments on commit 26b9779

Please sign in to comment.