-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove circular dependencies from wallet-sdk
- Loading branch information
1 parent
792c2ae
commit e9e626d
Showing
9 changed files
with
85 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { getPublicKeyFromPrivate, publicKeyToAddress } from '@stacks/encryption'; | ||
import { fromBase58 } from 'bip32'; | ||
|
||
export interface Account { | ||
/** The private key used for STX payments */ | ||
stxPrivateKey: string; | ||
/** The private key used in Stacks 1.0 to register BNS names */ | ||
dataPrivateKey: string; | ||
/** The salt is the same as the wallet-level salt. Used for app-specific keys */ | ||
salt: string; | ||
/** A single username registered via BNS for this account */ | ||
username?: string; | ||
/** A profile object that is publicly associated with this account's username */ | ||
profile?: Profile; | ||
/** The root of the keychain used to generate app-specific keys */ | ||
appsKey: string; | ||
/** The index of this account in the user's wallet */ | ||
index: number; | ||
} | ||
|
||
const PERSON_TYPE = 'Person'; | ||
const CONTEXT = 'http://schema.org'; | ||
const IMAGE_TYPE = 'ImageObject'; | ||
|
||
export interface ProfileImage { | ||
'@type': typeof IMAGE_TYPE; | ||
name: string; | ||
contentUrl: string; | ||
} | ||
|
||
export interface Profile { | ||
'@type': typeof PERSON_TYPE; | ||
'@context': typeof CONTEXT; | ||
apps?: { | ||
[origin: string]: string; | ||
}; | ||
appsMeta?: { | ||
[origin: string]: { | ||
publicKey: string; | ||
storage: string; | ||
}; | ||
}; | ||
name?: string; | ||
image?: ProfileImage[]; | ||
[key: string]: any; | ||
} | ||
|
||
/** | ||
* This object represents the keys that were derived from the root-level | ||
* keychain of a wallet. | ||
*/ | ||
export interface WalletKeys { | ||
/** Used when generating app private keys, which encrypt app-specific data */ | ||
salt: string; | ||
/** The private key associated with the root of a BIP39 keychain */ | ||
rootKey: string; | ||
/** A private key used to encrypt configuration data */ | ||
configPrivateKey: string; | ||
} | ||
|
||
export interface Wallet extends WalletKeys { | ||
/** The encrypted secret key */ | ||
encryptedSecretKey: string; | ||
/** A list of accounts generated by this wallet */ | ||
accounts: Account[]; | ||
} | ||
|
||
export const getGaiaAddress = (account: Account) => { | ||
const publicKey = getPublicKeyFromPrivate(account.dataPrivateKey); | ||
const address = publicKeyToAddress(publicKey); | ||
return address; | ||
}; | ||
|
||
export const getRootNode = (wallet: Wallet) => { | ||
return fromBase58(wallet.rootKey); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
e9e626d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: