-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: protocol-aware envelopes (#99)
- Loading branch information
Showing
13 changed files
with
100 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from typing import Any, Dict, List, Optional | ||
|
||
from uagents import Context, Model, Protocol | ||
|
||
|
||
class ProtocolQuery(Model): | ||
protocol_digest: Optional[str] | ||
|
||
|
||
class ProtocolResponse(Model): | ||
manifests: List[Dict[str, Any]] | ||
|
||
|
||
proto_query = Protocol(name="QueryProtocolManifests", version="0.1.0") | ||
|
||
|
||
@proto_query.on_query(ProtocolQuery) | ||
async def send_protocol_manifests(ctx: Context, sender: str, msg: ProtocolQuery): | ||
manifests = [] | ||
if msg.protocol_digest is not None: | ||
if msg.protocol_digest in ctx.protocols: | ||
manifests = [ctx.protocols[msg.protocol_digest].manifest()] | ||
else: | ||
manifests = [proto.manifest() for proto in ctx.protocols.values()] | ||
|
||
await ctx.send(sender, ProtocolResponse(manifests=manifests)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.