Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
arobsn committed Nov 1, 2023
1 parent 9854087 commit c965223
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .changeset/brave-apes-drive.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"@fleet-sdk/wallet": patch
---

Create HD key from options object.
Create HD keys from options object
13 changes: 6 additions & 7 deletions packages/wallet/src/ergoHDKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,21 @@ export type FromMnemonicOptions = {
path?: string;
};

export type HDKeyOptionsBase = {
export type HDKeyOptions = {
depth?: number;
index?: number;
parentFingerprint?: number;
chainCode?: Uint8Array;
};

export type PrivateKeyOptions = HDKeyOptionsBase & {
export type PrivateKeyOptions = HDKeyOptions & {
privateKey: Uint8Array | bigint;
};

export type PublicKeyOptions = HDKeyOptionsBase & {
export type PublicKeyOptions = HDKeyOptions & {
publicKey: Uint8Array;
};

export type HDKeyOptions = PrivateKeyOptions | PublicKeyOptions;

export class ErgoHDKey {
readonly #root: HDKey;
readonly #publicKey: Uint8Array;
Expand Down Expand Up @@ -98,9 +96,10 @@ export class ErgoHDKey {
return new ErgoHDKey(key);
}

static fromExtendedKey(options: HDKeyOptions): ErgoHDKey;
static fromExtendedKey(options: PrivateKeyOptions): ErgoHDKey;
static fromExtendedKey(options: PublicKeyOptions): ErgoHDKey;
static fromExtendedKey(encodedKey: string): ErgoHDKey;
static fromExtendedKey(keyOrOptions: string | HDKeyOptions): ErgoHDKey {
static fromExtendedKey(keyOrOptions: string | PrivateKeyOptions | PublicKeyOptions): ErgoHDKey {
const rootKey =
typeof keyOrOptions === "string"
? HDKey.fromExtendedKey(keyOrOptions)
Expand Down

0 comments on commit c965223

Please sign in to comment.