-
Notifications
You must be signed in to change notification settings - Fork 14
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(PSDK-670): Support external wallet imports, wallet imports from CDP Python SDK #68
Conversation
🟡 Heimdall Review Status
|
Next-up: test cases |
@@ -19,24 +20,25 @@ | |||
from cdp.webhook import Webhook | |||
|
|||
__all__ = [ | |||
"__version__", |
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.
lint changes
def import_data(cls, data: WalletData) -> "Wallet": | ||
"""Import a wallet from previously exported wallet data. | ||
def import_data(cls, data: WalletData | MnemonicSeedPhrase) -> "Wallet": | ||
"""Import a wallet from previously exported wallet data or a mnemonic seed phrase. |
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.
This is importing a wallet from previously exported wallet data or "creating a new wallet" from a mnemonic seed phrase.
It feels like we should split out the "load" from the "create" flows here? Or is the intent to lazily create the wallet (if one does not exist)? In that world we'd need to be able to check if a wallet already exists when providing the Mnemonic Seed Phrase as well?
@derek-cb @John-peterson-coinbase what are y'alls thoughts here?
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.
Edit: See that this is a 2-step plan:
Move WalletData out of the import() method and into its own method (ie, load())
Seems reasonable, although I feel like import
would make more sense than import_data
for that behavior of taking a mnemonic seed phrase or seed hex, and creating a wallet?
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.
ah yes good point. while this is a two-step plan, as you mentioned it doesn't quite make sense in the context of the Python SDK since the existing method is called "import_data". i would propose:
- renaming "import_data" to "import_wallet" ("import" is a reserved method name in Python)
- create a new method called "import_data" for backwards compatibility (that we will remove in a future breaking release) that accepts only WalletData - not the mnemonic phrase - and simply calls "import_wallet".
@alex-stone what do you think?
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.
That seems reasonable!
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.
@alex-stone committed now
…ode review comments)
What changed? Why?
Wallet.load_seed
method in favor ofWallet.load_seed_from_file
Wallet.save_seed
method in favor ofWallet.save_seed_to_file
Testing
Tested via:
v0.11.0