aw-protocol-sdk 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aw_protocol_sdk-0.1.0/PKG-INFO +39 -0
- aw_protocol_sdk-0.1.0/README.md +28 -0
- aw_protocol_sdk-0.1.0/pyproject.toml +21 -0
- aw_protocol_sdk-0.1.0/setup.cfg +4 -0
- aw_protocol_sdk-0.1.0/src/agentwallet/__init__.py +21 -0
- aw_protocol_sdk-0.1.0/src/agentwallet/client.py +108 -0
- aw_protocol_sdk-0.1.0/src/agentwallet/exceptions.py +39 -0
- aw_protocol_sdk-0.1.0/src/agentwallet/resources/__init__.py +0 -0
- aw_protocol_sdk-0.1.0/src/agentwallet/resources/agents.py +55 -0
- aw_protocol_sdk-0.1.0/src/agentwallet/resources/analytics.py +30 -0
- aw_protocol_sdk-0.1.0/src/agentwallet/resources/escrow.py +74 -0
- aw_protocol_sdk-0.1.0/src/agentwallet/resources/policies.py +50 -0
- aw_protocol_sdk-0.1.0/src/agentwallet/resources/transactions.py +65 -0
- aw_protocol_sdk-0.1.0/src/agentwallet/resources/wallets.py +54 -0
- aw_protocol_sdk-0.1.0/src/agentwallet/types.py +114 -0
- aw_protocol_sdk-0.1.0/src/aw_protocol_sdk.egg-info/PKG-INFO +39 -0
- aw_protocol_sdk-0.1.0/src/aw_protocol_sdk.egg-info/SOURCES.txt +18 -0
- aw_protocol_sdk-0.1.0/src/aw_protocol_sdk.egg-info/dependency_links.txt +1 -0
- aw_protocol_sdk-0.1.0/src/aw_protocol_sdk.egg-info/requires.txt +1 -0
- aw_protocol_sdk-0.1.0/src/aw_protocol_sdk.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: aw-protocol-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK for AgentWallet Protocol - AI Agent Wallet Infrastructure on Solana
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Homepage, https://agentwallet.dev
|
|
7
|
+
Project-URL: Repository, https://github.com/YouthAIAgent/agentwallet
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
Requires-Dist: httpx>=0.27
|
|
11
|
+
|
|
12
|
+
# aw-protocol-sdk
|
|
13
|
+
|
|
14
|
+
Python SDK for the AgentWallet Protocol — AI Agent Wallet Infrastructure on Solana.
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install aw-protocol-sdk
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
from agentwallet import AgentWallet
|
|
26
|
+
|
|
27
|
+
async with AgentWallet(api_key="aw_live_...") as aw:
|
|
28
|
+
agent = await aw.agents.create(name="trading-bot")
|
|
29
|
+
tx = await aw.transactions.transfer_sol(
|
|
30
|
+
from_wallet=agent["default_wallet_id"],
|
|
31
|
+
to_address="RecipientPubkey...",
|
|
32
|
+
amount_sol=0.5,
|
|
33
|
+
)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Links
|
|
37
|
+
|
|
38
|
+
- [GitHub](https://github.com/YouthAIAgent/agentwallet)
|
|
39
|
+
- [API Docs](https://trustworthy-celebration-production-6a3e.up.railway.app/docs)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# aw-protocol-sdk
|
|
2
|
+
|
|
3
|
+
Python SDK for the AgentWallet Protocol — AI Agent Wallet Infrastructure on Solana.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install aw-protocol-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
from agentwallet import AgentWallet
|
|
15
|
+
|
|
16
|
+
async with AgentWallet(api_key="aw_live_...") as aw:
|
|
17
|
+
agent = await aw.agents.create(name="trading-bot")
|
|
18
|
+
tx = await aw.transactions.transfer_sol(
|
|
19
|
+
from_wallet=agent["default_wallet_id"],
|
|
20
|
+
to_address="RecipientPubkey...",
|
|
21
|
+
amount_sol=0.5,
|
|
22
|
+
)
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Links
|
|
26
|
+
|
|
27
|
+
- [GitHub](https://github.com/YouthAIAgent/agentwallet)
|
|
28
|
+
- [API Docs](https://trustworthy-celebration-production-6a3e.up.railway.app/docs)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "aw-protocol-sdk"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Python SDK for AgentWallet Protocol - AI Agent Wallet Infrastructure on Solana"
|
|
5
|
+
requires-python = ">=3.10"
|
|
6
|
+
dependencies = [
|
|
7
|
+
"httpx>=0.27",
|
|
8
|
+
]
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
|
|
12
|
+
[project.urls]
|
|
13
|
+
Homepage = "https://agentwallet.dev"
|
|
14
|
+
Repository = "https://github.com/YouthAIAgent/agentwallet"
|
|
15
|
+
|
|
16
|
+
[build-system]
|
|
17
|
+
requires = ["setuptools>=70"]
|
|
18
|
+
build-backend = "setuptools.build_meta"
|
|
19
|
+
|
|
20
|
+
[tool.setuptools.packages.find]
|
|
21
|
+
where = ["src"]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""AgentWallet Python SDK -- AI Agent Wallet Infrastructure on Solana."""
|
|
2
|
+
|
|
3
|
+
from .client import AgentWallet
|
|
4
|
+
from .exceptions import (
|
|
5
|
+
AgentWalletAPIError,
|
|
6
|
+
AuthenticationError,
|
|
7
|
+
NotFoundError,
|
|
8
|
+
RateLimitError,
|
|
9
|
+
ValidationError,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
__all__ = [
|
|
13
|
+
"AgentWallet",
|
|
14
|
+
"AgentWalletAPIError",
|
|
15
|
+
"AuthenticationError",
|
|
16
|
+
"NotFoundError",
|
|
17
|
+
"RateLimitError",
|
|
18
|
+
"ValidationError",
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
__version__ = "0.1.0"
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"""Main AgentWallet SDK client -- Stripe-like interface."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import httpx
|
|
6
|
+
|
|
7
|
+
from .exceptions import (
|
|
8
|
+
AgentWalletAPIError,
|
|
9
|
+
AuthenticationError,
|
|
10
|
+
AuthorizationError,
|
|
11
|
+
ConflictError,
|
|
12
|
+
NotFoundError,
|
|
13
|
+
RateLimitError,
|
|
14
|
+
ValidationError,
|
|
15
|
+
)
|
|
16
|
+
from .resources.agents import AgentsResource
|
|
17
|
+
from .resources.analytics import AnalyticsResource
|
|
18
|
+
from .resources.escrow import EscrowResource
|
|
19
|
+
from .resources.policies import PoliciesResource
|
|
20
|
+
from .resources.transactions import TransactionsResource
|
|
21
|
+
from .resources.wallets import WalletsResource
|
|
22
|
+
|
|
23
|
+
DEFAULT_BASE_URL = "http://localhost:8000/v1"
|
|
24
|
+
|
|
25
|
+
ERROR_MAP = {
|
|
26
|
+
401: AuthenticationError,
|
|
27
|
+
403: AuthorizationError,
|
|
28
|
+
404: NotFoundError,
|
|
29
|
+
409: ConflictError,
|
|
30
|
+
422: ValidationError,
|
|
31
|
+
429: RateLimitError,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class AgentWallet:
|
|
36
|
+
"""AgentWallet SDK client.
|
|
37
|
+
|
|
38
|
+
Usage:
|
|
39
|
+
async with AgentWallet(api_key="aw_live_...") as aw:
|
|
40
|
+
agent = await aw.agents.create(name="trading-bot")
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
def __init__(
|
|
44
|
+
self,
|
|
45
|
+
api_key: str,
|
|
46
|
+
base_url: str = DEFAULT_BASE_URL,
|
|
47
|
+
timeout: float = 30.0,
|
|
48
|
+
):
|
|
49
|
+
self.api_key = api_key
|
|
50
|
+
self.base_url = base_url.rstrip("/")
|
|
51
|
+
self._client = httpx.AsyncClient(
|
|
52
|
+
base_url=self.base_url,
|
|
53
|
+
headers={"X-API-Key": api_key},
|
|
54
|
+
timeout=timeout,
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
# Sub-resources
|
|
58
|
+
self.agents = AgentsResource(self)
|
|
59
|
+
self.wallets = WalletsResource(self)
|
|
60
|
+
self.transactions = TransactionsResource(self)
|
|
61
|
+
self.escrow = EscrowResource(self)
|
|
62
|
+
self.analytics = AnalyticsResource(self)
|
|
63
|
+
self.policies = PoliciesResource(self)
|
|
64
|
+
|
|
65
|
+
async def __aenter__(self):
|
|
66
|
+
return self
|
|
67
|
+
|
|
68
|
+
async def __aexit__(self, *args):
|
|
69
|
+
await self.close()
|
|
70
|
+
|
|
71
|
+
async def close(self):
|
|
72
|
+
await self._client.aclose()
|
|
73
|
+
|
|
74
|
+
async def _request(
|
|
75
|
+
self,
|
|
76
|
+
method: str,
|
|
77
|
+
path: str,
|
|
78
|
+
json: dict | None = None,
|
|
79
|
+
params: dict | None = None,
|
|
80
|
+
) -> dict:
|
|
81
|
+
"""Make an authenticated API request."""
|
|
82
|
+
resp = await self._client.request(method, path, json=json, params=params)
|
|
83
|
+
|
|
84
|
+
if resp.status_code >= 400:
|
|
85
|
+
body = {}
|
|
86
|
+
try:
|
|
87
|
+
body = resp.json()
|
|
88
|
+
except Exception:
|
|
89
|
+
pass
|
|
90
|
+
message = body.get("error", body.get("detail", resp.text))
|
|
91
|
+
error_cls = ERROR_MAP.get(resp.status_code, AgentWalletAPIError)
|
|
92
|
+
raise error_cls(resp.status_code, message, body)
|
|
93
|
+
|
|
94
|
+
if resp.status_code == 204:
|
|
95
|
+
return {}
|
|
96
|
+
return resp.json()
|
|
97
|
+
|
|
98
|
+
async def get(self, path: str, params: dict | None = None) -> dict:
|
|
99
|
+
return await self._request("GET", path, params=params)
|
|
100
|
+
|
|
101
|
+
async def post(self, path: str, json: dict | None = None) -> dict:
|
|
102
|
+
return await self._request("POST", path, json=json)
|
|
103
|
+
|
|
104
|
+
async def patch(self, path: str, json: dict | None = None) -> dict:
|
|
105
|
+
return await self._request("PATCH", path, json=json)
|
|
106
|
+
|
|
107
|
+
async def delete(self, path: str) -> dict:
|
|
108
|
+
return await self._request("DELETE", path)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""SDK exception hierarchy."""
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class AgentWalletAPIError(Exception):
|
|
5
|
+
"""Base error for API responses."""
|
|
6
|
+
|
|
7
|
+
def __init__(self, status_code: int, message: str, body: dict | None = None):
|
|
8
|
+
self.status_code = status_code
|
|
9
|
+
self.message = message
|
|
10
|
+
self.body = body or {}
|
|
11
|
+
super().__init__(f"[{status_code}] {message}")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class AuthenticationError(AgentWalletAPIError):
|
|
15
|
+
"""401 Unauthorized."""
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class AuthorizationError(AgentWalletAPIError):
|
|
19
|
+
"""403 Forbidden."""
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class NotFoundError(AgentWalletAPIError):
|
|
23
|
+
"""404 Not Found."""
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class ValidationError(AgentWalletAPIError):
|
|
27
|
+
"""422 Validation Error."""
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class RateLimitError(AgentWalletAPIError):
|
|
31
|
+
"""429 Too Many Requests."""
|
|
32
|
+
|
|
33
|
+
def __init__(self, message: str, retry_after: int = 60):
|
|
34
|
+
self.retry_after = retry_after
|
|
35
|
+
super().__init__(429, message)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class ConflictError(AgentWalletAPIError):
|
|
39
|
+
"""409 Conflict."""
|
|
File without changes
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"""Agents sub-resource."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import TYPE_CHECKING
|
|
6
|
+
|
|
7
|
+
from ..types import Agent, ListResponse
|
|
8
|
+
|
|
9
|
+
if TYPE_CHECKING:
|
|
10
|
+
from ..client import AgentWallet
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class AgentsResource:
|
|
14
|
+
def __init__(self, client: AgentWallet):
|
|
15
|
+
self._client = client
|
|
16
|
+
|
|
17
|
+
async def create(
|
|
18
|
+
self,
|
|
19
|
+
name: str,
|
|
20
|
+
description: str | None = None,
|
|
21
|
+
capabilities: list[str] | None = None,
|
|
22
|
+
is_public: bool = False,
|
|
23
|
+
metadata: dict | None = None,
|
|
24
|
+
) -> Agent:
|
|
25
|
+
data = await self._client.post("/agents", json={
|
|
26
|
+
"name": name,
|
|
27
|
+
"description": description,
|
|
28
|
+
"capabilities": capabilities or [],
|
|
29
|
+
"is_public": is_public,
|
|
30
|
+
"metadata": metadata or {},
|
|
31
|
+
})
|
|
32
|
+
return Agent(**data)
|
|
33
|
+
|
|
34
|
+
async def get(self, agent_id: str) -> Agent:
|
|
35
|
+
data = await self._client.get(f"/agents/{agent_id}")
|
|
36
|
+
return Agent(**data)
|
|
37
|
+
|
|
38
|
+
async def list(
|
|
39
|
+
self,
|
|
40
|
+
status: str | None = None,
|
|
41
|
+
limit: int = 50,
|
|
42
|
+
offset: int = 0,
|
|
43
|
+
) -> ListResponse:
|
|
44
|
+
params = {"limit": limit, "offset": offset}
|
|
45
|
+
if status:
|
|
46
|
+
params["status"] = status
|
|
47
|
+
data = await self._client.get("/agents", params=params)
|
|
48
|
+
return ListResponse(
|
|
49
|
+
data=[Agent(**a) for a in data["data"]],
|
|
50
|
+
total=data["total"],
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
async def update(self, agent_id: str, **kwargs) -> Agent:
|
|
54
|
+
data = await self._client.patch(f"/agents/{agent_id}", json=kwargs)
|
|
55
|
+
return Agent(**data)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""Analytics sub-resource."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import TYPE_CHECKING
|
|
6
|
+
|
|
7
|
+
from ..types import AnalyticsSummary
|
|
8
|
+
|
|
9
|
+
if TYPE_CHECKING:
|
|
10
|
+
from ..client import AgentWallet
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class AnalyticsResource:
|
|
14
|
+
def __init__(self, client: AgentWallet):
|
|
15
|
+
self._client = client
|
|
16
|
+
|
|
17
|
+
async def summary(self, days: int = 30) -> AnalyticsSummary:
|
|
18
|
+
data = await self._client.get("/analytics/summary", params={"days": days})
|
|
19
|
+
return AnalyticsSummary(**data)
|
|
20
|
+
|
|
21
|
+
async def daily(
|
|
22
|
+
self, days: int = 30, agent_id: str | None = None
|
|
23
|
+
) -> list[dict]:
|
|
24
|
+
params = {"days": days}
|
|
25
|
+
if agent_id:
|
|
26
|
+
params["agent_id"] = agent_id
|
|
27
|
+
return await self._client.get("/analytics/daily", params=params)
|
|
28
|
+
|
|
29
|
+
async def by_agent(self, days: int = 30) -> list[dict]:
|
|
30
|
+
return await self._client.get("/analytics/agents", params={"days": days})
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"""Escrow sub-resource."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import TYPE_CHECKING
|
|
6
|
+
|
|
7
|
+
from ..types import Escrow, ListResponse
|
|
8
|
+
|
|
9
|
+
if TYPE_CHECKING:
|
|
10
|
+
from ..client import AgentWallet
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class EscrowResource:
|
|
14
|
+
def __init__(self, client: AgentWallet):
|
|
15
|
+
self._client = client
|
|
16
|
+
|
|
17
|
+
async def create(
|
|
18
|
+
self,
|
|
19
|
+
funder_wallet: str,
|
|
20
|
+
recipient_address: str,
|
|
21
|
+
amount_sol: float,
|
|
22
|
+
token_mint: str | None = None,
|
|
23
|
+
arbiter_address: str | None = None,
|
|
24
|
+
conditions: dict | None = None,
|
|
25
|
+
expires_in_hours: int = 24,
|
|
26
|
+
) -> Escrow:
|
|
27
|
+
data = await self._client.post("/escrow", json={
|
|
28
|
+
"funder_wallet_id": funder_wallet,
|
|
29
|
+
"recipient_address": recipient_address,
|
|
30
|
+
"amount_sol": amount_sol,
|
|
31
|
+
"token_mint": token_mint,
|
|
32
|
+
"arbiter_address": arbiter_address,
|
|
33
|
+
"conditions": conditions or {},
|
|
34
|
+
"expires_in_hours": expires_in_hours,
|
|
35
|
+
})
|
|
36
|
+
return Escrow(**data)
|
|
37
|
+
|
|
38
|
+
async def get(self, escrow_id: str) -> Escrow:
|
|
39
|
+
data = await self._client.get(f"/escrow/{escrow_id}")
|
|
40
|
+
return Escrow(**data)
|
|
41
|
+
|
|
42
|
+
async def list(
|
|
43
|
+
self,
|
|
44
|
+
status: str | None = None,
|
|
45
|
+
limit: int = 50,
|
|
46
|
+
offset: int = 0,
|
|
47
|
+
) -> ListResponse:
|
|
48
|
+
params = {"limit": limit, "offset": offset}
|
|
49
|
+
if status:
|
|
50
|
+
params["status"] = status
|
|
51
|
+
data = await self._client.get("/escrow", params=params)
|
|
52
|
+
return ListResponse(
|
|
53
|
+
data=[Escrow(**e) for e in data["data"]],
|
|
54
|
+
total=data["total"],
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
async def release(self, escrow_id: str) -> Escrow:
|
|
58
|
+
data = await self._client.post(f"/escrow/{escrow_id}/action", json={
|
|
59
|
+
"action": "release",
|
|
60
|
+
})
|
|
61
|
+
return Escrow(**data)
|
|
62
|
+
|
|
63
|
+
async def refund(self, escrow_id: str) -> Escrow:
|
|
64
|
+
data = await self._client.post(f"/escrow/{escrow_id}/action", json={
|
|
65
|
+
"action": "refund",
|
|
66
|
+
})
|
|
67
|
+
return Escrow(**data)
|
|
68
|
+
|
|
69
|
+
async def dispute(self, escrow_id: str, reason: str) -> Escrow:
|
|
70
|
+
data = await self._client.post(f"/escrow/{escrow_id}/action", json={
|
|
71
|
+
"action": "dispute",
|
|
72
|
+
"reason": reason,
|
|
73
|
+
})
|
|
74
|
+
return Escrow(**data)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""Policies sub-resource."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import TYPE_CHECKING
|
|
6
|
+
|
|
7
|
+
from ..types import ListResponse, Policy
|
|
8
|
+
|
|
9
|
+
if TYPE_CHECKING:
|
|
10
|
+
from ..client import AgentWallet
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class PoliciesResource:
|
|
14
|
+
def __init__(self, client: AgentWallet):
|
|
15
|
+
self._client = client
|
|
16
|
+
|
|
17
|
+
async def create(
|
|
18
|
+
self,
|
|
19
|
+
name: str,
|
|
20
|
+
rules: dict,
|
|
21
|
+
scope_type: str = "org",
|
|
22
|
+
scope_id: str | None = None,
|
|
23
|
+
priority: int = 100,
|
|
24
|
+
) -> Policy:
|
|
25
|
+
data = await self._client.post("/policies", json={
|
|
26
|
+
"name": name,
|
|
27
|
+
"rules": rules,
|
|
28
|
+
"scope_type": scope_type,
|
|
29
|
+
"scope_id": scope_id,
|
|
30
|
+
"priority": priority,
|
|
31
|
+
})
|
|
32
|
+
return Policy(**data)
|
|
33
|
+
|
|
34
|
+
async def get(self, policy_id: str) -> Policy:
|
|
35
|
+
data = await self._client.get(f"/policies/{policy_id}")
|
|
36
|
+
return Policy(**data)
|
|
37
|
+
|
|
38
|
+
async def list(self, limit: int = 50, offset: int = 0) -> ListResponse:
|
|
39
|
+
data = await self._client.get("/policies", params={"limit": limit, "offset": offset})
|
|
40
|
+
return ListResponse(
|
|
41
|
+
data=[Policy(**p) for p in data["data"]],
|
|
42
|
+
total=data["total"],
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
async def update(self, policy_id: str, **kwargs) -> Policy:
|
|
46
|
+
data = await self._client.patch(f"/policies/{policy_id}", json=kwargs)
|
|
47
|
+
return Policy(**data)
|
|
48
|
+
|
|
49
|
+
async def delete(self, policy_id: str) -> None:
|
|
50
|
+
await self._client.delete(f"/policies/{policy_id}")
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"""Transactions sub-resource."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import TYPE_CHECKING
|
|
6
|
+
|
|
7
|
+
from ..types import ListResponse, Transaction
|
|
8
|
+
|
|
9
|
+
if TYPE_CHECKING:
|
|
10
|
+
from ..client import AgentWallet
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class TransactionsResource:
|
|
14
|
+
def __init__(self, client: AgentWallet):
|
|
15
|
+
self._client = client
|
|
16
|
+
|
|
17
|
+
async def transfer_sol(
|
|
18
|
+
self,
|
|
19
|
+
from_wallet: str,
|
|
20
|
+
to_address: str,
|
|
21
|
+
amount_sol: float,
|
|
22
|
+
memo: str | None = None,
|
|
23
|
+
idempotency_key: str | None = None,
|
|
24
|
+
) -> Transaction:
|
|
25
|
+
data = await self._client.post("/transactions/transfer-sol", json={
|
|
26
|
+
"from_wallet_id": from_wallet,
|
|
27
|
+
"to_address": to_address,
|
|
28
|
+
"amount_sol": amount_sol,
|
|
29
|
+
"memo": memo,
|
|
30
|
+
"idempotency_key": idempotency_key,
|
|
31
|
+
})
|
|
32
|
+
return Transaction(**data)
|
|
33
|
+
|
|
34
|
+
async def get(self, tx_id: str) -> Transaction:
|
|
35
|
+
data = await self._client.get(f"/transactions/{tx_id}")
|
|
36
|
+
return Transaction(**data)
|
|
37
|
+
|
|
38
|
+
async def list(
|
|
39
|
+
self,
|
|
40
|
+
agent_id: str | None = None,
|
|
41
|
+
wallet_id: str | None = None,
|
|
42
|
+
status: str | None = None,
|
|
43
|
+
limit: int = 50,
|
|
44
|
+
offset: int = 0,
|
|
45
|
+
) -> ListResponse:
|
|
46
|
+
params = {"limit": limit, "offset": offset}
|
|
47
|
+
if agent_id:
|
|
48
|
+
params["agent_id"] = agent_id
|
|
49
|
+
if wallet_id:
|
|
50
|
+
params["wallet_id"] = wallet_id
|
|
51
|
+
if status:
|
|
52
|
+
params["status"] = status
|
|
53
|
+
data = await self._client.get("/transactions", params=params)
|
|
54
|
+
return ListResponse(
|
|
55
|
+
data=[Transaction(**t) for t in data["data"]],
|
|
56
|
+
total=data["total"],
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
async def batch_transfer(
|
|
60
|
+
self, transfers: list[dict]
|
|
61
|
+
) -> list[Transaction]:
|
|
62
|
+
data = await self._client.post("/transactions/batch-transfer", json={
|
|
63
|
+
"transfers": transfers,
|
|
64
|
+
})
|
|
65
|
+
return [Transaction(**t) for t in data]
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""Wallets sub-resource."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import TYPE_CHECKING
|
|
6
|
+
|
|
7
|
+
from ..types import ListResponse, Wallet, WalletBalance
|
|
8
|
+
|
|
9
|
+
if TYPE_CHECKING:
|
|
10
|
+
from ..client import AgentWallet
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class WalletsResource:
|
|
14
|
+
def __init__(self, client: AgentWallet):
|
|
15
|
+
self._client = client
|
|
16
|
+
|
|
17
|
+
async def create(
|
|
18
|
+
self,
|
|
19
|
+
agent_id: str | None = None,
|
|
20
|
+
wallet_type: str = "agent",
|
|
21
|
+
label: str | None = None,
|
|
22
|
+
) -> Wallet:
|
|
23
|
+
data = await self._client.post("/wallets", json={
|
|
24
|
+
"agent_id": agent_id,
|
|
25
|
+
"wallet_type": wallet_type,
|
|
26
|
+
"label": label,
|
|
27
|
+
})
|
|
28
|
+
return Wallet(**data)
|
|
29
|
+
|
|
30
|
+
async def get(self, wallet_id: str) -> Wallet:
|
|
31
|
+
data = await self._client.get(f"/wallets/{wallet_id}")
|
|
32
|
+
return Wallet(**data)
|
|
33
|
+
|
|
34
|
+
async def list(
|
|
35
|
+
self,
|
|
36
|
+
agent_id: str | None = None,
|
|
37
|
+
wallet_type: str | None = None,
|
|
38
|
+
limit: int = 50,
|
|
39
|
+
offset: int = 0,
|
|
40
|
+
) -> ListResponse:
|
|
41
|
+
params = {"limit": limit, "offset": offset}
|
|
42
|
+
if agent_id:
|
|
43
|
+
params["agent_id"] = agent_id
|
|
44
|
+
if wallet_type:
|
|
45
|
+
params["wallet_type"] = wallet_type
|
|
46
|
+
data = await self._client.get("/wallets", params=params)
|
|
47
|
+
return ListResponse(
|
|
48
|
+
data=[Wallet(**w) for w in data["data"]],
|
|
49
|
+
total=data["total"],
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
async def get_balance(self, wallet_id: str) -> WalletBalance:
|
|
53
|
+
data = await self._client.get(f"/wallets/{wallet_id}/balance")
|
|
54
|
+
return WalletBalance(**data)
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"""Response types as dataclasses."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass, field
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass
|
|
9
|
+
class Agent:
|
|
10
|
+
id: str
|
|
11
|
+
org_id: str
|
|
12
|
+
name: str
|
|
13
|
+
description: str | None
|
|
14
|
+
status: str
|
|
15
|
+
capabilities: list[str]
|
|
16
|
+
default_wallet_id: str | None
|
|
17
|
+
reputation_score: float
|
|
18
|
+
is_public: bool
|
|
19
|
+
created_at: str
|
|
20
|
+
updated_at: str
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@dataclass
|
|
24
|
+
class Wallet:
|
|
25
|
+
id: str
|
|
26
|
+
org_id: str
|
|
27
|
+
agent_id: str | None
|
|
28
|
+
address: str
|
|
29
|
+
wallet_type: str
|
|
30
|
+
label: str | None
|
|
31
|
+
is_active: bool
|
|
32
|
+
created_at: str
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@dataclass
|
|
36
|
+
class WalletBalance:
|
|
37
|
+
address: str
|
|
38
|
+
sol_balance: float
|
|
39
|
+
lamports: int
|
|
40
|
+
tokens: list[dict] = field(default_factory=list)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@dataclass
|
|
44
|
+
class Transaction:
|
|
45
|
+
id: str
|
|
46
|
+
org_id: str
|
|
47
|
+
agent_id: str | None
|
|
48
|
+
wallet_id: str
|
|
49
|
+
tx_type: str
|
|
50
|
+
status: str
|
|
51
|
+
signature: str | None
|
|
52
|
+
from_address: str
|
|
53
|
+
to_address: str
|
|
54
|
+
amount_lamports: int
|
|
55
|
+
token_mint: str | None
|
|
56
|
+
platform_fee_lamports: int
|
|
57
|
+
memo: str | None
|
|
58
|
+
error: str | None
|
|
59
|
+
created_at: str
|
|
60
|
+
confirmed_at: str | None
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
@dataclass
|
|
64
|
+
class Escrow:
|
|
65
|
+
id: str
|
|
66
|
+
org_id: str
|
|
67
|
+
funder_wallet_id: str
|
|
68
|
+
recipient_address: str
|
|
69
|
+
arbiter_address: str | None
|
|
70
|
+
escrow_address: str | None
|
|
71
|
+
amount_lamports: int
|
|
72
|
+
token_mint: str | None
|
|
73
|
+
status: str
|
|
74
|
+
conditions: dict
|
|
75
|
+
fund_signature: str | None
|
|
76
|
+
release_signature: str | None
|
|
77
|
+
refund_signature: str | None
|
|
78
|
+
dispute_reason: str | None
|
|
79
|
+
expires_at: str | None
|
|
80
|
+
funded_at: str | None
|
|
81
|
+
completed_at: str | None
|
|
82
|
+
created_at: str
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
@dataclass
|
|
86
|
+
class Policy:
|
|
87
|
+
id: str
|
|
88
|
+
org_id: str
|
|
89
|
+
name: str
|
|
90
|
+
rules: dict
|
|
91
|
+
scope_type: str
|
|
92
|
+
scope_id: str | None
|
|
93
|
+
priority: int
|
|
94
|
+
enabled: bool
|
|
95
|
+
created_at: str
|
|
96
|
+
updated_at: str
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
@dataclass
|
|
100
|
+
class ListResponse:
|
|
101
|
+
data: list
|
|
102
|
+
total: int
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
@dataclass
|
|
106
|
+
class AnalyticsSummary:
|
|
107
|
+
total_spend_lamports: int
|
|
108
|
+
total_fees_lamports: int
|
|
109
|
+
tx_count: int
|
|
110
|
+
failed_tx_count: int
|
|
111
|
+
active_agents: int
|
|
112
|
+
unique_destinations: int
|
|
113
|
+
period_start: str
|
|
114
|
+
period_end: str
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: aw-protocol-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK for AgentWallet Protocol - AI Agent Wallet Infrastructure on Solana
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Homepage, https://agentwallet.dev
|
|
7
|
+
Project-URL: Repository, https://github.com/YouthAIAgent/agentwallet
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
Requires-Dist: httpx>=0.27
|
|
11
|
+
|
|
12
|
+
# aw-protocol-sdk
|
|
13
|
+
|
|
14
|
+
Python SDK for the AgentWallet Protocol — AI Agent Wallet Infrastructure on Solana.
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install aw-protocol-sdk
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
from agentwallet import AgentWallet
|
|
26
|
+
|
|
27
|
+
async with AgentWallet(api_key="aw_live_...") as aw:
|
|
28
|
+
agent = await aw.agents.create(name="trading-bot")
|
|
29
|
+
tx = await aw.transactions.transfer_sol(
|
|
30
|
+
from_wallet=agent["default_wallet_id"],
|
|
31
|
+
to_address="RecipientPubkey...",
|
|
32
|
+
amount_sol=0.5,
|
|
33
|
+
)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Links
|
|
37
|
+
|
|
38
|
+
- [GitHub](https://github.com/YouthAIAgent/agentwallet)
|
|
39
|
+
- [API Docs](https://trustworthy-celebration-production-6a3e.up.railway.app/docs)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
src/agentwallet/__init__.py
|
|
4
|
+
src/agentwallet/client.py
|
|
5
|
+
src/agentwallet/exceptions.py
|
|
6
|
+
src/agentwallet/types.py
|
|
7
|
+
src/agentwallet/resources/__init__.py
|
|
8
|
+
src/agentwallet/resources/agents.py
|
|
9
|
+
src/agentwallet/resources/analytics.py
|
|
10
|
+
src/agentwallet/resources/escrow.py
|
|
11
|
+
src/agentwallet/resources/policies.py
|
|
12
|
+
src/agentwallet/resources/transactions.py
|
|
13
|
+
src/agentwallet/resources/wallets.py
|
|
14
|
+
src/aw_protocol_sdk.egg-info/PKG-INFO
|
|
15
|
+
src/aw_protocol_sdk.egg-info/SOURCES.txt
|
|
16
|
+
src/aw_protocol_sdk.egg-info/dependency_links.txt
|
|
17
|
+
src/aw_protocol_sdk.egg-info/requires.txt
|
|
18
|
+
src/aw_protocol_sdk.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
httpx>=0.27
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
agentwallet
|