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(core): send address prefix to mailbox API #607

Merged
merged 1 commit into from
Jan 14, 2025
Merged
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
2 changes: 2 additions & 0 deletions python/docs/api/uagents/mailbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Check if the agent is a proxy agent.
async def register_in_agentverse(
request: AgentverseConnectRequest,
identity: Identity,
prefix: AddressPrefix,
endpoints: list[AgentEndpoint],
agentverse: AgentverseConfig,
agent_details: Optional[AgentUpdates] = None) -> RegistrationResponse
Expand All @@ -51,6 +52,7 @@ Registers agent in Agentverse

- `request` _AgentverseConnectRequest_ - Request object
- `identity` _Identity_ - Agent identity object
- `prefix` _AddressPrefix_ - Agent address prefix - can be "agent" (mainnet) or "test-agent" (testnet)
- `endpoints` _list[AgentEndpoint]_ - Endpoints of the agent
- `agentverse` _AgentverseConfig_ - Agentverse configuration

Expand Down
1 change: 1 addition & 0 deletions python/src/uagents/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ async def _handle_connect(_ctx: Context, request: AgentverseConnectRequest):
return await register_in_agentverse(
request,
self._identity,
TESTNET_PREFIX if self._test else MAINNET_PREFIX,
self._agentverse,
agent_details,
)
Expand Down
8 changes: 8 additions & 0 deletions python/src/uagents/mailbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ class ChallengeProofResponse(Model):
expiry: str


AddressPrefix = Literal["agent", "test-agent"]


class RegistrationRequest(BaseModel):
address: str
prefix: AddressPrefix
challenge: str
challenge_response: str
agent_type: AgentType
Expand Down Expand Up @@ -87,6 +91,7 @@ def is_mailbox_agent(
async def register_in_agentverse(
request: AgentverseConnectRequest,
identity: Identity,
prefix: AddressPrefix,
agentverse: AgentverseConfig,
agent_details: Optional[AgentUpdates] = None,
) -> RegistrationResponse:
Expand All @@ -96,6 +101,8 @@ async def register_in_agentverse(
Args:
request (AgentverseConnectRequest): Request object
identity (Identity): Agent identity object
prefix (AddressPrefix): Agent address prefix
can be "agent" (mainnet) or "test-agent" (testnet)
agentverse (AgentverseConfig): Agentverse configuration
agent_details (Optional[AgentUpdates]): Agent details (name, readme, avatar_url)

Expand Down Expand Up @@ -124,6 +131,7 @@ async def register_in_agentverse(
prove_url,
data=RegistrationRequest(
address=identity.address,
prefix=prefix,
challenge=challenge.challenge,
challenge_response=identity.sign(challenge.challenge.encode()),
endpoint=request.endpoint,
Expand Down
Loading