Skip to content
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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions typescript/.changeset/tidy-cities-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@coinbase/agentkit": minor
---

Added a new wallet provider and action providers to interact with the Safe Protocol
2 changes: 2 additions & 0 deletions typescript/agentkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
"@coinbase/coinbase-sdk": "^0.20.0",
"@jup-ag/api": "^6.0.39",
"@privy-io/server-auth": "^1.18.4",
"@safe-global/api-kit": "^2.5.11",
"@safe-global/protocol-kit": "^5.2.4",
"@solana/spl-token": "^0.4.12",
"@solana/web3.js": "^1.98.0",
"md5": "^2.3.0",
Expand Down
1 change: 1 addition & 0 deletions typescript/agentkit/src/action-providers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export * from "./pyth";
export * from "./moonwell";
export * from "./morpho";
export * from "./opensea";
export * from "./safe";
export * from "./spl";
export * from "./twitter";
export * from "./wallet";
Expand Down
60 changes: 60 additions & 0 deletions typescript/agentkit/src/action-providers/safe/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Safe Action Provider

This directory contains the **SafeActionProvider** implementation, which provides actions to interact with [Safe](https://safe.global/) multi-signature wallets on EVM-compatible blockchains.

## Directory Structure

```
safe/
├── safeApiActionProvider.ts # Provider for Safe API interactions
├── safeWalletActionProvider.ts # Provider for Safe Wallet operations
├── schemas.ts # Action schemas for Safe operations
├── index.ts # Main exports
└── README.md # This file
```

## Actions

### Safe API Actions

- `safeInfo`: Retrieve detailed information about a Safe wallet
- `getAllowanceInfo`: Get current allowance configurations
- `withdrawAllowance`: Withdraw funds from an allowance

### Safe Wallet Actions

- `addSigner`: Add a new signer to a Safe wallet
- `removeSigner`: Remove an existing signer from a Safe wallet
- `changeThreshold`: Modify the number of required signatures
- `approvePending`: Approve a pending transaction
- `enableAllowanceModule`: Activate the allowance module for a Safe
- `setAllowance`: Configure spending allowances for specific addresses

## Adding New Actions

To add new Safe actions:

1. Define your action schema in `schemas.ts`
2. Implement the action in the appropriate provider file:
- Safe API actions in `safeApiActionProvider.ts`
- Safe Wallet actions in `safeWalletActionProvider.ts`
3. Add corresponding tests

## Network Support

The Safe providers support all EVM-compatible networks, including:

- Ethereum (Mainnet & Testnets)
- Base (Mainnet & Testnets)
- Optimism
- Arbitrum
- Optimism
- And other EVM-compatible networks

## Notes

- safeWalletActionProvider requires a safeWalletProvider
- safeWalletProvider connects to an existing Safe account or automatically creates a new one with the provided private key as single signer
- Safe API actions can be used with other evmWalletProvider

For more information on Safe multi-signature wallets visit [Safe Documentation](https://docs.safe.global/).
3 changes: 3 additions & 0 deletions typescript/agentkit/src/action-providers/safe/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./schemas";
export * from "./safeWalletActionProvider";
export * from "./safeApiActionProvider";
Loading
Loading