-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from valory-xyz/chore/default-protocol
chore: change default protocol author
- Loading branch information
Showing
21 changed files
with
968 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Default Protocol | ||
|
||
## Description | ||
|
||
This is a protocol for two agents exchanging any bytes messages. | ||
|
||
## Specification | ||
|
||
```yaml | ||
--- | ||
name: default | ||
author: valory | ||
version: 1.0.0 | ||
description: A protocol for exchanging any bytes message. | ||
license: Apache-2.0 | ||
aea_version: '>=1.0.0, <2.0.0' | ||
protocol_specification_id: valory/default:1.0.0 | ||
speech_acts: | ||
bytes: | ||
content: pt:bytes | ||
error: | ||
error_code: ct:ErrorCode | ||
error_msg: pt:str | ||
error_data: pt:dict[pt:str, pt:bytes] | ||
end: {} | ||
... | ||
--- | ||
ct:ErrorCode: | | ||
enum ErrorCodeEnum { | ||
UNSUPPORTED_PROTOCOL = 0; | ||
DECODING_ERROR = 1; | ||
INVALID_MESSAGE = 2; | ||
UNSUPPORTED_SKILL = 3; | ||
INVALID_DIALOGUE = 4; | ||
} | ||
ErrorCodeEnum error_code = 1; | ||
... | ||
--- | ||
initiation: [bytes, error] | ||
reply: | ||
bytes: [bytes, error, end] | ||
error: [] | ||
end: [] | ||
termination: [end, error] | ||
roles: {agent} | ||
end_states: [successful, failed] | ||
keep_terminal_state_dialogues: true | ||
... | ||
``` | ||
|
||
## Links |
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,30 @@ | ||
# -*- coding: utf-8 -*- | ||
# ------------------------------------------------------------------------------ | ||
# | ||
# Copyright 2023 valory | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# ------------------------------------------------------------------------------ | ||
|
||
""" | ||
This module contains the support resources for the default protocol. | ||
It was created with protocol buffer compiler version `libprotoc 3.19.4` and aea protocol generator version `1.0.0`. | ||
""" | ||
|
||
from packages.valory.protocols.default.message import DefaultMessage | ||
from packages.valory.protocols.default.serialization import DefaultSerializer | ||
|
||
|
||
DefaultMessage.serializer = DefaultSerializer |
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,58 @@ | ||
# -*- coding: utf-8 -*- | ||
# ------------------------------------------------------------------------------ | ||
# | ||
# Copyright 2023 Valory AG | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# ------------------------------------------------------------------------------ | ||
|
||
"""This module contains class representations corresponding to every custom type in the protocol specification.""" | ||
|
||
from enum import Enum | ||
from typing import Any | ||
|
||
|
||
class ErrorCode(Enum): | ||
"""This class represents an instance of ErrorCode.""" | ||
|
||
UNSUPPORTED_PROTOCOL = 0 | ||
DECODING_ERROR = 1 | ||
INVALID_MESSAGE = 2 | ||
UNSUPPORTED_SKILL = 3 | ||
INVALID_DIALOGUE = 4 | ||
|
||
@staticmethod | ||
def encode(error_code_protobuf_object: Any, error_code_object: "ErrorCode") -> None: | ||
""" | ||
Encode an instance of this class into the protocol buffer object. | ||
The protocol buffer object in the error_code_protobuf_object argument is matched with the instance of this class in the 'error_code_object' argument. | ||
:param error_code_protobuf_object: the protocol buffer object whose type corresponds with this class. | ||
:param error_code_object: an instance of this class to be encoded in the protocol buffer object. | ||
""" | ||
error_code_protobuf_object.error_code = error_code_object.value | ||
|
||
@classmethod | ||
def decode(cls, error_code_protobuf_object: Any) -> "ErrorCode": | ||
""" | ||
Decode a protocol buffer object that corresponds with this class into an instance of this class. | ||
A new instance of this class is created that matches the protocol buffer object in the 'error_code_protobuf_object' argument. | ||
:param error_code_protobuf_object: the protocol buffer object whose type corresponds with this class. | ||
:return: A new instance of this class that matches the protocol buffer object in the 'error_code_protobuf_object' argument. | ||
""" | ||
enum_value_from_pb2 = error_code_protobuf_object.error_code | ||
return ErrorCode(enum_value_from_pb2) |
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,40 @@ | ||
syntax = "proto3"; | ||
|
||
package aea.valory.default.v1_0_0; | ||
|
||
message DefaultMessage{ | ||
|
||
// Custom Types | ||
message ErrorCode{ | ||
enum ErrorCodeEnum { | ||
ERROR_CODE_ENUM_UNSUPPORTED_PROTOCOL = 0; | ||
ERROR_CODE_ENUM_DECODING_ERROR = 1; | ||
ERROR_CODE_ENUM_INVALID_MESSAGE = 2; | ||
ERROR_CODE_ENUM_UNSUPPORTED_SKILL = 3; | ||
ERROR_CODE_ENUM_INVALID_DIALOGUE = 4; | ||
} | ||
ErrorCodeEnum error_code = 1; | ||
} | ||
|
||
|
||
// Performatives and contents | ||
message Bytes_Performative{ | ||
bytes content = 1; | ||
} | ||
|
||
message Error_Performative{ | ||
ErrorCode error_code = 1; | ||
string error_msg = 2; | ||
map<string, bytes> error_data = 3; | ||
} | ||
|
||
message End_Performative{ | ||
} | ||
|
||
|
||
oneof performative{ | ||
Bytes_Performative bytes = 5; | ||
End_Performative end = 6; | ||
Error_Performative error = 7; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.