Skip to content

Commit

Permalink
Merge branch 'feat/wf-fixes' of github.com:valory-xyz/mech into feat/…
Browse files Browse the repository at this point in the history
…wf-fixes
  • Loading branch information
8baller committed May 12, 2023
2 parents e11438f + 6923a3a commit 65309d1
Show file tree
Hide file tree
Showing 35 changed files with 2,274 additions and 80 deletions.
Empty file added packages/fetchai/__init__.py
Empty file.
Empty file.
51 changes: 51 additions & 0 deletions packages/fetchai/protocols/default/README.md
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: fetchai
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: fetchai/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
29 changes: 29 additions & 0 deletions packages/fetchai/protocols/default/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2022 fetchai
#
# 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.17.3` and aea version `1.4.0`.
"""

from packages.fetchai.protocols.default.message import DefaultMessage
from packages.fetchai.protocols.default.serialization import DefaultSerializer

DefaultMessage.serializer = DefaultSerializer
58 changes: 58 additions & 0 deletions packages/fetchai/protocols/default/custom_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2020 fetchai
#
# 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)
40 changes: 40 additions & 0 deletions packages/fetchai/protocols/default/default.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
syntax = "proto3";

package aea.fetchai.default.v1_0_0;

message DefaultMessage{

// Custom Types
message ErrorCode{
enum ErrorCodeEnum {
UNSUPPORTED_PROTOCOL = 0;
DECODING_ERROR = 1;
INVALID_MESSAGE = 2;
UNSUPPORTED_SKILL = 3;
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;
}
}
Loading

0 comments on commit 65309d1

Please sign in to comment.