heimdallfund 0.2.0__py3-none-any.whl
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.
- heimdallfund/__init__.py +32 -0
- heimdallfund/_client.py +200 -0
- heimdallfund/_errors.py +33 -0
- heimdallfund/_types.py +79 -0
- heimdallfund/py.typed +0 -0
- heimdallfund-0.2.0.dist-info/METADATA +86 -0
- heimdallfund-0.2.0.dist-info/RECORD +9 -0
- heimdallfund-0.2.0.dist-info/WHEEL +4 -0
- heimdallfund-0.2.0.dist-info/licenses/LICENSE +112 -0
heimdallfund/__init__.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""Heimdall Shield for Python: check a transaction or a signature on Robinhood Chain before your agent signs it.
|
|
2
|
+
|
|
3
|
+
from heimdallfund import Shield
|
|
4
|
+
|
|
5
|
+
shield = Shield() # free tier, no key needed
|
|
6
|
+
result = shield.check(sender="0x…", to="0x…", data="0x…", value=0)
|
|
7
|
+
if result["verdict"] != "ALLOW":
|
|
8
|
+
raise SystemExit(result["findings"])
|
|
9
|
+
|
|
10
|
+
Never sign on DENY. On WARN, ask the user. If the check fails, treat the transaction as unsafe.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
from ._client import AsyncShield, Shield, require_allow
|
|
16
|
+
from ._errors import HeimdallDenied, HeimdallError, PaymentRequired
|
|
17
|
+
from ._types import CheckResult, Finding, Policy, RiskReport, SignatureCheckResult
|
|
18
|
+
|
|
19
|
+
__all__ = [
|
|
20
|
+
"Shield",
|
|
21
|
+
"require_allow",
|
|
22
|
+
"AsyncShield",
|
|
23
|
+
"HeimdallError",
|
|
24
|
+
"HeimdallDenied",
|
|
25
|
+
"PaymentRequired",
|
|
26
|
+
"CheckResult",
|
|
27
|
+
"SignatureCheckResult",
|
|
28
|
+
"Finding",
|
|
29
|
+
"Policy",
|
|
30
|
+
"RiskReport",
|
|
31
|
+
]
|
|
32
|
+
__version__ = "0.2.0"
|
heimdallfund/_client.py
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
from typing import Any, Mapping
|
|
5
|
+
|
|
6
|
+
import httpx
|
|
7
|
+
|
|
8
|
+
from ._errors import HeimdallDenied, HeimdallError, PaymentRequired
|
|
9
|
+
from ._types import CheckResult, Policy, RiskReport, SignatureCheckResult
|
|
10
|
+
|
|
11
|
+
DEFAULT_URL = "https://api.heimdall.fund"
|
|
12
|
+
ROBINHOOD_CHAIN = 4663
|
|
13
|
+
USER_AGENT = "heimdallfund-python/0.2.0"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _tx_body(sender: str, to: str | None, data: str, value: int | str, chain_id: int, policy: Policy | None, share: bool, probe: bool) -> dict[str, Any]:
|
|
17
|
+
body: dict[str, Any] = {"chainId": chain_id, "from": sender, "to": to, "data": data or "0x", "value": str(int(value)) if not isinstance(value, str) else value}
|
|
18
|
+
if policy:
|
|
19
|
+
body["policy"] = dict(policy)
|
|
20
|
+
if share:
|
|
21
|
+
body["share"] = True
|
|
22
|
+
if probe:
|
|
23
|
+
body["probe"] = True
|
|
24
|
+
return body
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _sig_body(signer: str, typed_data: Mapping[str, Any] | None, message: str | None, chain_id: int, policy: Policy | None, share: bool, authorization: Mapping[str, Any] | None = None) -> dict[str, Any]:
|
|
28
|
+
if sum(x is not None for x in (typed_data, message, authorization)) != 1:
|
|
29
|
+
raise ValueError("pass exactly one of typed_data, message or authorization")
|
|
30
|
+
body: dict[str, Any] = {"chainId": chain_id, "signer": signer}
|
|
31
|
+
if typed_data is not None:
|
|
32
|
+
body["typedData"] = dict(typed_data)
|
|
33
|
+
elif authorization is not None:
|
|
34
|
+
body["authorization"] = dict(authorization)
|
|
35
|
+
else:
|
|
36
|
+
body["message"] = message
|
|
37
|
+
if policy:
|
|
38
|
+
body["policy"] = dict(policy)
|
|
39
|
+
if share:
|
|
40
|
+
body["share"] = True
|
|
41
|
+
return body
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def _parse(res: httpx.Response) -> Any:
|
|
45
|
+
try:
|
|
46
|
+
body = res.json()
|
|
47
|
+
except ValueError:
|
|
48
|
+
body = None
|
|
49
|
+
if res.status_code == 402:
|
|
50
|
+
raise PaymentRequired(body, res.headers.get("payment-required"))
|
|
51
|
+
if res.status_code >= 400:
|
|
52
|
+
msg = body.get("message") or body.get("error") if isinstance(body, dict) else None
|
|
53
|
+
raise HeimdallError(f"Shield request failed ({res.status_code}){f': {msg}' if msg else ''}", res.status_code, body)
|
|
54
|
+
return body
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def require_allow(result: Mapping[str, Any], allow_warn: bool = False) -> None:
|
|
58
|
+
"""Raise HeimdallDenied unless the verdict is ALLOW (or WARN, when allow_warn is set)."""
|
|
59
|
+
if result.get("verdict") == "ALLOW" or (allow_warn and result.get("verdict") == "WARN"):
|
|
60
|
+
return
|
|
61
|
+
raise HeimdallDenied(result)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class _Base:
|
|
65
|
+
def __init__(self, api_key: str | None = None, base_url: str | None = None, timeout: float = 20.0, chain_id: int = ROBINHOOD_CHAIN) -> None:
|
|
66
|
+
self.base_url = (base_url or os.environ.get("HEIMDALL_API_URL") or DEFAULT_URL).rstrip("/")
|
|
67
|
+
self.chain_id = chain_id
|
|
68
|
+
self.timeout = timeout
|
|
69
|
+
key = api_key if api_key is not None else os.environ.get("HEIMDALL_API_KEY")
|
|
70
|
+
self._headers = {"user-agent": USER_AGENT, "content-type": "application/json"}
|
|
71
|
+
if key:
|
|
72
|
+
self._headers["authorization"] = f"Bearer {key}"
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class Shield(_Base):
|
|
76
|
+
"""Synchronous client. Without an API key the free tier applies to your IP."""
|
|
77
|
+
|
|
78
|
+
def __init__(self, api_key: str | None = None, base_url: str | None = None, timeout: float = 20.0, chain_id: int = ROBINHOOD_CHAIN, transport: httpx.BaseTransport | None = None) -> None:
|
|
79
|
+
super().__init__(api_key, base_url, timeout, chain_id)
|
|
80
|
+
self._http = httpx.Client(base_url=self.base_url, headers=self._headers, timeout=timeout, transport=transport)
|
|
81
|
+
|
|
82
|
+
def __enter__(self) -> "Shield":
|
|
83
|
+
return self
|
|
84
|
+
|
|
85
|
+
def __exit__(self, *exc: object) -> None:
|
|
86
|
+
self.close()
|
|
87
|
+
|
|
88
|
+
def close(self) -> None:
|
|
89
|
+
self._http.close()
|
|
90
|
+
|
|
91
|
+
def _get(self, path: str) -> Any:
|
|
92
|
+
return _parse(self._http.get(path))
|
|
93
|
+
|
|
94
|
+
def _post(self, path: str, body: Mapping[str, Any]) -> Any:
|
|
95
|
+
return _parse(self._http.post(path, json=body))
|
|
96
|
+
|
|
97
|
+
def check(self, sender: str, to: str | None, data: str = "0x", value: int | str = 0, policy: Policy | None = None, share: bool = False, probe: bool = False) -> CheckResult:
|
|
98
|
+
"""Simulate a transaction on the current chain state and judge it: ALLOW, WARN or DENY with the reasons."""
|
|
99
|
+
return self._post("/v1/check", _tx_body(sender, to, data, value, self.chain_id, policy, share, probe))
|
|
100
|
+
|
|
101
|
+
def check_signature(self, signer: str, typed_data: Mapping[str, Any] | None = None, message: str | None = None, policy: Policy | None = None, share: bool = False, authorization: Mapping[str, Any] | None = None) -> SignatureCheckResult:
|
|
102
|
+
"""Judge an EIP-712 request (Permit, Permit2, orders), a personal_sign message, or an EIP-7702 authorization
|
|
103
|
+
({"chainId": 4663, "address": delegate, "nonce": n}) before signing it."""
|
|
104
|
+
return self._post("/v1/check-signature", _sig_body(signer, typed_data, message, self.chain_id, policy, share, authorization))
|
|
105
|
+
|
|
106
|
+
def guard(self, sender: str, to: str | None, data: str = "0x", value: int | str = 0, policy: Policy | None = None, allow_warn: bool = False) -> CheckResult:
|
|
107
|
+
"""Check, then raise HeimdallDenied unless the verdict allows signing. Errors raise too: fail closed."""
|
|
108
|
+
result = self.check(sender, to, data, value, policy)
|
|
109
|
+
require_allow(result, allow_warn)
|
|
110
|
+
return result
|
|
111
|
+
|
|
112
|
+
def token_check(self, token: str) -> dict[str, Any]:
|
|
113
|
+
"""Token Check: simulated buy, sell and transfer through the token's Uniswap pool, taxes, clawbacks, fake tickers."""
|
|
114
|
+
return self._get(f"/v1/token/{token}")
|
|
115
|
+
|
|
116
|
+
def risk(self, address: str) -> RiskReport:
|
|
117
|
+
"""Risk level and flags of an address, as the Risk Oracle holds them."""
|
|
118
|
+
return self._get(f"/v1/risk/{address}")
|
|
119
|
+
|
|
120
|
+
def threats(self) -> dict[str, Any]:
|
|
121
|
+
"""Threat Board: patterns Shield is catching, most denied addresses and the sourced blocklist."""
|
|
122
|
+
return self._get("/v1/threats")
|
|
123
|
+
|
|
124
|
+
def wallet_check(self, address: str, refresh: bool = False) -> dict[str, Any]:
|
|
125
|
+
"""Every live token approval of a wallet, ranked by risk."""
|
|
126
|
+
return self._get(f"/v1/wallet/{address}{'?refresh=1' if refresh else ''}")
|
|
127
|
+
|
|
128
|
+
def verdict(self, share_id: str) -> dict[str, Any]:
|
|
129
|
+
"""A verdict saved with share=True."""
|
|
130
|
+
return self._get(f"/v1/verdicts/{share_id}")
|
|
131
|
+
|
|
132
|
+
def passport(self, agent: str | int) -> dict[str, Any]:
|
|
133
|
+
"""Agent Passport by wallet address or ERC-8004 agent ID."""
|
|
134
|
+
return self._get(f"/v1/passport/{agent}")
|
|
135
|
+
|
|
136
|
+
def agent(self, address: str) -> dict[str, Any]:
|
|
137
|
+
"""Public check history of an agent wallet."""
|
|
138
|
+
return self._get(f"/v1/agents/{address}")
|
|
139
|
+
|
|
140
|
+
def status(self) -> dict[str, Any]:
|
|
141
|
+
"""Live service status."""
|
|
142
|
+
return self._get("/v1/status")
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
class AsyncShield(_Base):
|
|
146
|
+
"""Async client with the same methods as Shield."""
|
|
147
|
+
|
|
148
|
+
def __init__(self, api_key: str | None = None, base_url: str | None = None, timeout: float = 20.0, chain_id: int = ROBINHOOD_CHAIN, transport: httpx.AsyncBaseTransport | None = None) -> None:
|
|
149
|
+
super().__init__(api_key, base_url, timeout, chain_id)
|
|
150
|
+
self._http = httpx.AsyncClient(base_url=self.base_url, headers=self._headers, timeout=timeout, transport=transport)
|
|
151
|
+
|
|
152
|
+
async def __aenter__(self) -> "AsyncShield":
|
|
153
|
+
return self
|
|
154
|
+
|
|
155
|
+
async def __aexit__(self, *exc: object) -> None:
|
|
156
|
+
await self.aclose()
|
|
157
|
+
|
|
158
|
+
async def aclose(self) -> None:
|
|
159
|
+
await self._http.aclose()
|
|
160
|
+
|
|
161
|
+
async def _get(self, path: str) -> Any:
|
|
162
|
+
return _parse(await self._http.get(path))
|
|
163
|
+
|
|
164
|
+
async def _post(self, path: str, body: Mapping[str, Any]) -> Any:
|
|
165
|
+
return _parse(await self._http.post(path, json=body))
|
|
166
|
+
|
|
167
|
+
async def check(self, sender: str, to: str | None, data: str = "0x", value: int | str = 0, policy: Policy | None = None, share: bool = False, probe: bool = False) -> CheckResult:
|
|
168
|
+
return await self._post("/v1/check", _tx_body(sender, to, data, value, self.chain_id, policy, share, probe))
|
|
169
|
+
|
|
170
|
+
async def check_signature(self, signer: str, typed_data: Mapping[str, Any] | None = None, message: str | None = None, policy: Policy | None = None, share: bool = False, authorization: Mapping[str, Any] | None = None) -> SignatureCheckResult:
|
|
171
|
+
return await self._post("/v1/check-signature", _sig_body(signer, typed_data, message, self.chain_id, policy, share, authorization))
|
|
172
|
+
|
|
173
|
+
async def guard(self, sender: str, to: str | None, data: str = "0x", value: int | str = 0, policy: Policy | None = None, allow_warn: bool = False) -> CheckResult:
|
|
174
|
+
result = await self.check(sender, to, data, value, policy)
|
|
175
|
+
require_allow(result, allow_warn)
|
|
176
|
+
return result
|
|
177
|
+
|
|
178
|
+
async def token_check(self, token: str) -> dict[str, Any]:
|
|
179
|
+
return await self._get(f"/v1/token/{token}")
|
|
180
|
+
|
|
181
|
+
async def risk(self, address: str) -> RiskReport:
|
|
182
|
+
return await self._get(f"/v1/risk/{address}")
|
|
183
|
+
|
|
184
|
+
async def threats(self) -> dict[str, Any]:
|
|
185
|
+
return await self._get("/v1/threats")
|
|
186
|
+
|
|
187
|
+
async def wallet_check(self, address: str, refresh: bool = False) -> dict[str, Any]:
|
|
188
|
+
return await self._get(f"/v1/wallet/{address}{'?refresh=1' if refresh else ''}")
|
|
189
|
+
|
|
190
|
+
async def verdict(self, share_id: str) -> dict[str, Any]:
|
|
191
|
+
return await self._get(f"/v1/verdicts/{share_id}")
|
|
192
|
+
|
|
193
|
+
async def passport(self, agent: str | int) -> dict[str, Any]:
|
|
194
|
+
return await self._get(f"/v1/passport/{agent}")
|
|
195
|
+
|
|
196
|
+
async def agent(self, address: str) -> dict[str, Any]:
|
|
197
|
+
return await self._get(f"/v1/agents/{address}")
|
|
198
|
+
|
|
199
|
+
async def status(self) -> dict[str, Any]:
|
|
200
|
+
return await self._get("/v1/status")
|
heimdallfund/_errors.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any, Mapping
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class HeimdallError(Exception):
|
|
7
|
+
"""The Shield API answered with an error, or could not be reached. Treat the transaction as unsafe."""
|
|
8
|
+
|
|
9
|
+
def __init__(self, message: str, status: int | None = None, body: Any = None) -> None:
|
|
10
|
+
super().__init__(message)
|
|
11
|
+
self.status = status
|
|
12
|
+
self.body = body
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class PaymentRequired(HeimdallError):
|
|
16
|
+
"""Over the free tier. Pay per call with x402 (USDG on Robinhood Chain) or pass an API key.
|
|
17
|
+
|
|
18
|
+
`requirements` is the base64 JSON from the PAYMENT-REQUIRED header (x402 v2).
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
def __init__(self, body: Any, requirements: str | None) -> None:
|
|
22
|
+
super().__init__("Over the free tier: pay per call with x402 or use an API key", 402, body)
|
|
23
|
+
self.requirements = requirements
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class HeimdallDenied(Exception):
|
|
27
|
+
"""Raised by `require_allow` when Shield does not answer ALLOW."""
|
|
28
|
+
|
|
29
|
+
def __init__(self, result: Mapping[str, Any]) -> None:
|
|
30
|
+
notable = [f for f in result.get("findings", []) if f.get("severity") != "info"]
|
|
31
|
+
reason = notable[0]["message"] if notable else "blocked"
|
|
32
|
+
super().__init__(f"Heimdall Shield {result.get('verdict')}: {reason}")
|
|
33
|
+
self.result = result
|
heimdallfund/_types.py
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any, Literal, TypedDict
|
|
4
|
+
|
|
5
|
+
try: # Python 3.11+
|
|
6
|
+
from typing import NotRequired
|
|
7
|
+
except ImportError: # pragma: no cover
|
|
8
|
+
from typing_extensions import NotRequired
|
|
9
|
+
|
|
10
|
+
Verdict = Literal["ALLOW", "WARN", "DENY"]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Finding(TypedDict):
|
|
14
|
+
code: str
|
|
15
|
+
severity: Literal["info", "warn", "deny"]
|
|
16
|
+
message: str
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class Policy(TypedDict, total=False):
|
|
20
|
+
"""Per-agent rules Shield applies on top of its own. Amounts are raw integer strings (wei, token units)."""
|
|
21
|
+
|
|
22
|
+
strict: bool
|
|
23
|
+
allowTargets: list[str]
|
|
24
|
+
denyTargets: list[str]
|
|
25
|
+
maxNativeOut: str
|
|
26
|
+
maxTokenOut: dict[str, str]
|
|
27
|
+
trustedSpenders: list[str]
|
|
28
|
+
denyUnlimitedApprovals: bool
|
|
29
|
+
allowContractDeploy: bool
|
|
30
|
+
trustedRecipients: list[str]
|
|
31
|
+
trustedDelegates: list[str]
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class AssetChange(TypedDict):
|
|
35
|
+
asset: str
|
|
36
|
+
symbol: str
|
|
37
|
+
decimals: int
|
|
38
|
+
kind: Literal["native", "erc20", "erc721"]
|
|
39
|
+
delta: str
|
|
40
|
+
counterparties: list[str]
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class Simulation(TypedDict):
|
|
44
|
+
ok: bool
|
|
45
|
+
available: bool
|
|
46
|
+
gasUsed: NotRequired[str]
|
|
47
|
+
revertReason: NotRequired[str]
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class CheckResult(TypedDict):
|
|
51
|
+
checkId: str
|
|
52
|
+
verdict: Verdict
|
|
53
|
+
riskScore: int
|
|
54
|
+
summary: list[str]
|
|
55
|
+
findings: list[Finding]
|
|
56
|
+
approvals: list[dict[str, Any]]
|
|
57
|
+
assetChanges: list[AssetChange]
|
|
58
|
+
simulation: Simulation
|
|
59
|
+
decoded: NotRequired[dict[str, Any]]
|
|
60
|
+
receipt: NotRequired[dict[str, Any]]
|
|
61
|
+
shareId: NotRequired[str]
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class SignatureCheckResult(TypedDict):
|
|
65
|
+
verdict: Verdict
|
|
66
|
+
riskScore: int
|
|
67
|
+
kind: str
|
|
68
|
+
summary: list[str]
|
|
69
|
+
findings: list[Finding]
|
|
70
|
+
approvals: list[dict[str, Any]]
|
|
71
|
+
shareId: NotRequired[str]
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class RiskReport(TypedDict, total=False):
|
|
75
|
+
address: str
|
|
76
|
+
level: int
|
|
77
|
+
levelName: str
|
|
78
|
+
flags: int
|
|
79
|
+
flagNames: list[str]
|
heimdallfund/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: heimdallfund
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Heimdall Shield for Python: check Robinhood Chain transactions and signatures before your AI agent signs them
|
|
5
|
+
Project-URL: Homepage, https://heimdall.fund
|
|
6
|
+
Project-URL: Documentation, https://heimdall.fund/docs/sdk
|
|
7
|
+
Project-URL: Source, https://github.com/heimdallfund/Heimdall/tree/main/packages/sdk-python
|
|
8
|
+
Author-email: Heimdall <hello@heimdall.fund>
|
|
9
|
+
License-Expression: BUSL-1.1
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: ai-agents,crewai,firewall,langchain,robinhood-chain,security,transaction-simulation,web3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Topic :: Security
|
|
14
|
+
Classifier: Typing :: Typed
|
|
15
|
+
Requires-Python: >=3.9
|
|
16
|
+
Requires-Dist: httpx>=0.27
|
|
17
|
+
Requires-Dist: typing-extensions>=4.7; python_version < '3.11'
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
# heimdallfund
|
|
21
|
+
|
|
22
|
+
Heimdall Shield for Python. Before your agent signs a transaction or a signature on Robinhood Chain, Shield simulates it on the current chain state and answers **ALLOW**, **WARN** or **DENY** with the reasons: drainer approvals, honeypots, vanishing and fake tokens, address poisoning, blocklisted addresses, reverts and your own spend limits.
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install heimdallfund
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Check, then sign
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
from heimdallfund import Shield, HeimdallDenied
|
|
32
|
+
|
|
33
|
+
shield = Shield() # free tier; Shield(api_key="hd_live_…") or HEIMDALL_API_KEY lifts the limit
|
|
34
|
+
|
|
35
|
+
result = shield.check(
|
|
36
|
+
sender="0xYourAgentWallet",
|
|
37
|
+
to="0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168", # USDG
|
|
38
|
+
data="0x095ea7b3…", # the calldata you are about to sign
|
|
39
|
+
value=0,
|
|
40
|
+
policy={"maxNativeOut": str(10**17), "denyUnlimitedApprovals": True},
|
|
41
|
+
)
|
|
42
|
+
print(result["verdict"], [f["message"] for f in result["findings"]])
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
`guard()` does the same and raises `HeimdallDenied` unless the verdict is ALLOW, so a refused or failed check never reaches your signer:
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
try:
|
|
49
|
+
shield.guard(sender, to, data, value)
|
|
50
|
+
send_transaction(...)
|
|
51
|
+
except HeimdallDenied as e:
|
|
52
|
+
tell_the_user(e.result["findings"])
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Signatures
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
shield.check_signature(signer, typed_data=permit_request) # EIP-712: Permit, Permit2, orders
|
|
59
|
+
shield.check_signature(signer, message="Sign in to example.com")
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Lookups
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
shield.risk("0x…") # risk level and flags from the Risk Oracle list
|
|
66
|
+
shield.wallet_check("0x…") # every live approval of a wallet, ranked
|
|
67
|
+
shield.threats() # what Shield is catching, and the sourced blocklist
|
|
68
|
+
shield.passport("0x…") # ERC-8004 agent passport and score
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Async
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
from heimdallfund import AsyncShield
|
|
75
|
+
|
|
76
|
+
async with AsyncShield() as shield:
|
|
77
|
+
result = await shield.check(sender, to, data, value)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Limits and payment
|
|
81
|
+
|
|
82
|
+
Without a key, the free tier applies to your IP. Above it Shield answers 402 and the client raises `PaymentRequired` with the x402 requirements: pay per call in USDG, or use an API key from [heimdall.fund/app/keys](https://heimdall.fund/app/keys).
|
|
83
|
+
|
|
84
|
+
Rules for agents: never sign on DENY; on WARN, ask the user; if the check fails, treat the transaction as unsafe.
|
|
85
|
+
|
|
86
|
+
Docs: [heimdall.fund/docs](https://heimdall.fund/docs) · API reference: [heimdall.fund/docs/api](https://heimdall.fund/docs/api) · License: BUSL 1.1
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
heimdallfund/__init__.py,sha256=BP3s_hAuiLEXYz7cR6caEhor--IdAWnGj_WzgofN6H0,956
|
|
2
|
+
heimdallfund/_client.py,sha256=6URMSfuIg7a7R5Y06cmmARTIRIbWq5vNoQLg6xEZlQI,9498
|
|
3
|
+
heimdallfund/_errors.py,sha256=0-vTorQRAesFcGqB37I-xeASUTcaL6VOpRfNFQXidbU,1255
|
|
4
|
+
heimdallfund/_types.py,sha256=aXO2Ev756PRysnE6zpmu51OB6KoRuiUAxHWe_bajYSc,1809
|
|
5
|
+
heimdallfund/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
heimdallfund-0.2.0.dist-info/METADATA,sha256=ZlEp3pgmeyl039CkTFvax6vOkUoSzjq3zv4wHi-sWG4,3275
|
|
7
|
+
heimdallfund-0.2.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
8
|
+
heimdallfund-0.2.0.dist-info/licenses/LICENSE,sha256=VYRqhHUIY4_P6sOSUwCItzJ7K0S0jhSxAWCKvmEH8PU,5117
|
|
9
|
+
heimdallfund-0.2.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
Business Source License 1.1
|
|
2
|
+
|
|
3
|
+
License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
|
|
4
|
+
"Business Source License" is a trademark of MariaDB Corporation Ab.
|
|
5
|
+
|
|
6
|
+
-----------------------------------------------------------------------------
|
|
7
|
+
|
|
8
|
+
Parameters
|
|
9
|
+
|
|
10
|
+
Licensor: Heimdall
|
|
11
|
+
|
|
12
|
+
Licensed Work: Heimdall
|
|
13
|
+
The Licensed Work is (c) 2026 Heimdall. Files whose
|
|
14
|
+
header reads "SPDX-License-Identifier: MIT" (contract
|
|
15
|
+
interfaces and integration helpers) are not part of
|
|
16
|
+
the Licensed Work; they are licensed under MIT.
|
|
17
|
+
|
|
18
|
+
Additional Use Grant: You may make production use of the Licensed Work,
|
|
19
|
+
including the TypeScript SDK, the MCP server, the agent
|
|
20
|
+
kit and the ElizaOS plugin, to integrate with, call or
|
|
21
|
+
build on Heimdall's own deployed contracts and hosted
|
|
22
|
+
services, provided that your use does not include
|
|
23
|
+
offering a transaction firewall, risk oracle, agent
|
|
24
|
+
wallet guard, payment facilitator, agent reputation
|
|
25
|
+
service or stock vault service that competes with
|
|
26
|
+
Heimdall.
|
|
27
|
+
|
|
28
|
+
Change Date: 2029-11-24
|
|
29
|
+
|
|
30
|
+
Change License: MIT
|
|
31
|
+
|
|
32
|
+
For information about alternative licensing arrangements for the Licensed
|
|
33
|
+
Work, please contact hello@heimdall.fund.
|
|
34
|
+
|
|
35
|
+
-----------------------------------------------------------------------------
|
|
36
|
+
|
|
37
|
+
Terms
|
|
38
|
+
|
|
39
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
40
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
|
41
|
+
Licensor may make an Additional Use Grant, above, permitting limited
|
|
42
|
+
production use.
|
|
43
|
+
|
|
44
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly
|
|
45
|
+
available distribution of a specific version of the Licensed Work under this
|
|
46
|
+
License, whichever comes first, the Licensor hereby grants you rights under
|
|
47
|
+
the terms of the Change License, and the rights granted in the paragraph
|
|
48
|
+
above terminate.
|
|
49
|
+
|
|
50
|
+
If your use of the Licensed Work does not comply with the requirements
|
|
51
|
+
currently in effect as described in this License, you must purchase a
|
|
52
|
+
commercial license from the Licensor, its affiliated entities, or authorized
|
|
53
|
+
resellers, or you must refrain from using the Licensed Work.
|
|
54
|
+
|
|
55
|
+
All copies of the original and modified Licensed Work, and derivative works
|
|
56
|
+
of the Licensed Work, are subject to this License. This License applies
|
|
57
|
+
separately for each version of the Licensed Work and the Change Date may vary
|
|
58
|
+
for each version of the Licensed Work released by Licensor.
|
|
59
|
+
|
|
60
|
+
You must conspicuously display this License on each original or modified copy
|
|
61
|
+
of the Licensed Work. If you receive the Licensed Work in original or
|
|
62
|
+
modified form from a third party, the terms and conditions set forth in this
|
|
63
|
+
License apply to your use of that work.
|
|
64
|
+
|
|
65
|
+
Any use of the Licensed Work in violation of this License will automatically
|
|
66
|
+
terminate your rights under this License for the current and all other
|
|
67
|
+
versions of the Licensed Work.
|
|
68
|
+
|
|
69
|
+
This License does not grant you any right in any trademark or logo of
|
|
70
|
+
Licensor or its affiliates (provided that you may use a trademark or logo of
|
|
71
|
+
Licensor as expressly required by this License).
|
|
72
|
+
|
|
73
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
|
74
|
+
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
75
|
+
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
|
76
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
|
77
|
+
TITLE.
|
|
78
|
+
|
|
79
|
+
MariaDB hereby grants you permission to use this License’s text to license
|
|
80
|
+
your works, and to refer to it using the trademark "Business Source License",
|
|
81
|
+
as long as you comply with the Covenants of Licensor below.
|
|
82
|
+
|
|
83
|
+
-----------------------------------------------------------------------------
|
|
84
|
+
|
|
85
|
+
Covenants of Licensor
|
|
86
|
+
|
|
87
|
+
In consideration of the right to use this License’s text and the "Business
|
|
88
|
+
Source License" name and trademark, Licensor covenants to MariaDB, and to all
|
|
89
|
+
other recipients of the licensed work to be provided by Licensor:
|
|
90
|
+
|
|
91
|
+
1. To specify as the Change License the GPL Version 2.0 or any later version,
|
|
92
|
+
or a license that is compatible with GPL Version 2.0 or a later version,
|
|
93
|
+
where "compatible" means that software provided under the Change License can
|
|
94
|
+
be included in a program with software provided under GPL Version 2.0 or a
|
|
95
|
+
later version. Licensor may specify additional Change Licenses without
|
|
96
|
+
limitation.
|
|
97
|
+
|
|
98
|
+
2. To either: (a) specify an additional grant of rights to use that does not
|
|
99
|
+
impose any additional restriction on the right granted in this License, as
|
|
100
|
+
the Additional Use Grant; or (b) insert the text "None".
|
|
101
|
+
|
|
102
|
+
3. To specify a Change Date.
|
|
103
|
+
|
|
104
|
+
4. Not to modify this License in any other way.
|
|
105
|
+
|
|
106
|
+
-----------------------------------------------------------------------------
|
|
107
|
+
|
|
108
|
+
Notice
|
|
109
|
+
|
|
110
|
+
The Business Source License (this document, or the "License") is not an Open
|
|
111
|
+
Source license. However, the Licensed Work will eventually be made available
|
|
112
|
+
under an Open Source License, as stated in this License.
|