-
Notifications
You must be signed in to change notification settings - Fork 357
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: add safe wallet provider (ts) #330
base: main
Are you sure you want to change the base?
Conversation
🟡 Heimdall Review Status
|
@phdargen Thanks for the contribution! A few initial comments:
Let me know if you have any questions or comments |
Thanks for the feedback @John-peterson-coinbase. That’s a good suggestion, I will look into it in the coming days. Only problem I see is that one couldn’t use cdp and safe actions at the same time but I guess thats not too bad in this case. Before getting started, it would be good to clarify some design choices. |
Hi @John-peterson-coinbase, I got a minimal example working for the new setup:
Please let me know if you agree with this implementation, then I'll go ahead and add the remaining actions and clean up by removing the old safeActionProvider |
BTW, I submitted a related project at the safe agentathon (https://devfolio.co/projects/safegpt-d4c5) with a live demo here: https://safe-gpt.vercel.app/ |
82504f2
to
c009f79
Compare
This is in principle ready for review, however the actions in safeApiActionProvider rely on the safe api that is currently still down, see safe-global/safe-core-sdk#1155. |
The safe api is back and this is ready for review. |
error => { | ||
throw new Error("Error initializing Safe wallet: " + error); | ||
}, | ||
); |
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.
@John-peterson-coinbase @0xRAG @CarsonRoscoe any clue why the test-agentkit-typescript (20) units tests are failing? There seems to be a network timeout probably related to the fact that I do not call trackInitialization() immediately but wait until the Safe wallet is created (that requires an onchain tx). Running the test locally is successful and test-agentkit-typescript (18) seems to be fine too
Why? What?
Every AI Agent deserves a Safe wallet!
Adds new safeActionProvider to handle interactions with Safe multi-signature wallets.
This implementation uses the Safe sdk that is added as new dependency.
What changed?
New Wallet Provider: safeWalletProvider
getBalance()
returns balance of safe wallet, not private-key of agentnativeTransfer()
transfers eth from Safe wallet, may require approval of other signersNew Action Provider: safeWalletActionProvider with actions:
addSigner
: Add a new signer to a Safe walletremoveSigner
: Remove an existing signer from a Safe walletchangeThreshold
: Modify the number of required signaturesapprovePending
: Approve a pending transactionenableAllowanceModule
: Activate the allowance module for a SafesetAllowance
: Configure spending allowances for specific addressesNew Action Provider: safeApiActionProvider with actions:
safeInfo
: Retrieve detailed information about a Safe walletgetAllowanceInfo
: Get current allowance configurationswithdrawAllowance
: Withdraw funds from an allowanceAdds new getPublicClient() method to EvmWalletProvider, so the publicClient can be passed to safeApiActionProvider
Adds new signHash() method to EvmWalletProvider that is needed for withdrawAllowance action
Adds new langchain-safe-chatbot example
Adds safeApiActionProvider to langchain-cdp-chatbot example
Network support
How has it been tested?
Running langchain-safe-chatbot without setting SAFE_ADDRESS:
Running langchain-cdp-chatbot (could be different agent with other private-key, doesn't need to be owner of safe):