Skip to content

Commit

Permalink
first pass supporting wallet mnemonic import
Browse files Browse the repository at this point in the history
  • Loading branch information
stat committed Jan 7, 2025
1 parent 12ddc11 commit 5beedf0
Show file tree
Hide file tree
Showing 4 changed files with 1,764 additions and 1,490 deletions.
4 changes: 4 additions & 0 deletions cdp-langchain/cdp_langchain/utils/cdp_agentkit_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def validate_environment(cls, values: dict) -> Any:
cdp_api_key_private_key = get_from_dict_or_env(
values, "cdp_api_key_private_key", "CDP_API_KEY_PRIVATE_KEY"
).replace("\\n", "\n")
mnemonic_phrase = get_from_dict_or_env(values, "mnemonic_phrase", "MNEMONIC_PHRASE", "")
network_id = get_from_dict_or_env(values, "network_id", "NETWORK_ID", "base-sepolia")
wallet_data_json = values.get("cdp_wallet_data")

Expand All @@ -49,12 +50,15 @@ def validate_environment(cls, values: dict) -> Any:
if wallet_data_json:
wallet_data = WalletData.from_dict(json.loads(wallet_data_json))
wallet = Wallet.import_data(wallet_data)
elif mnemonic_phrase:
wallet = Wallet.import_wallet(mnemonic_phrase)
else:
wallet = Wallet.create(network_id=network_id)

values["wallet"] = wallet
values["cdp_api_key_name"] = cdp_api_key_name
values["cdp_api_key_private_key"] = cdp_api_key_private_key
values["mnemonic_phrase"] = mnemonic_phrase
values["network_id"] = network_id

return values
Expand Down
Loading

0 comments on commit 5beedf0

Please sign in to comment.