auradefi 0.1.1
PyPI GitHub

UserHandle

auradefi.embed.handle · source

One host user's slice of the library (SPEC §7.1, §8).

Created by user; tenant_id is derived, never supplied. Every operation is scoped to that tenant (rule #6).

__init__

__init__(self, facade: Auradefi, external_user_id: str, tenant_id: str) -> None

Bind the facade and the derived tenant id. No I/O.

Parameters

facaderequired, Auradefi

none

external_user_idrequired, str

none

tenant_idrequired, str

none

connect_address

connect_address(self, chain: str, address: str) -> ConnectionRecord

Watch one address on one chain: validated NOW, not later.

In order, and each step before any HTTP can happen:

  1. chains.evm.chain_id_from_caip2(chain): a vendor name like "ethereum" raises auradefi.errors.CaipParseError.
  2. ChainRegistry MEMBERSHIP: a well-formed CAIP-2 the registry does not hold raises auradefi.errors.UnknownChainError naming it. The decoder needs that entry, so accepting the chain stores a connection every sync() fails on (§5 #24).
  3. chains.evm.normalize_address(address). A non-address raises auradefi.errors.ValidationError. The normalized (lowercased) address is what gets stored.
  4. The connection id is DERIVED (embed.models.derive_connection_id) and CHAIN-SCOPED, so a re-connect of the same (chain, address), in any letter case in the 40 hex DIGITS, raises auradefi.errors.ConflictError carrying existing_id with ZERO requests made, while the SAME address on ANOTHER chain is a second, independent connection (§5 #26). The 0x prefix is NOT case-insensitive: 0X… never reaches here, step 3 rejects it.
  5. A liveness probe: EXACTLY one request. Its auradefi.errors.SourceError propagates and NOTHING is stored; an EMPTY result is a valid fresh address.
  6. The ConnectionRecord is stored with created_at_ms = clock.now_ms() and returned.

Parameters

chainrequired, str

CAIP-2 id, e.g. eip155:1. A vendor name like ethereum is refused, as is a chain the registry does not hold.

addressrequired, str

Checksummed or lowercase; stored lowercased. The 0x prefix is not case-insensitive.

Raises

CaipParseError, ConflictError, SourceError, UnknownChainError, ValidationError

connections

connections(self) -> tuple[ConnectionRecord, ...]

This tenant's connections, in creation order.

sync

sync(self, budget: int = 5) -> SyncReport

sync restricted to THIS user's connections.

Parameters

budgetoptional, int, default 5

none

holdings

holdings(self) -> tuple[HoldingsReport, ...]

holdings for THIS user's connections.

scalar_metrics

scalar_metrics(self) -> tuple[scalar_projection.Metric, ...]

scalar_metrics for THIS user's connections.