mech-client 0.14.1__py3-none-any.whl → 0.15.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. mech_client/__init__.py +1 -1
  2. mech_client/cli.py +258 -11
  3. mech_client/configs/mechs.json +110 -110
  4. mech_client/interact.py +6 -1
  5. mech_client/marketplace_interact.py +160 -42
  6. mech_client/safe.py +73 -0
  7. mech_client/subgraph.py +0 -11
  8. {mech_client-0.14.1.dist-info → mech_client-0.15.1.dist-info}/METADATA +278 -224
  9. {mech_client-0.14.1.dist-info → mech_client-0.15.1.dist-info}/RECORD +22 -48
  10. scripts/deposit_native.py +48 -16
  11. scripts/deposit_token.py +107 -31
  12. scripts/nvm_subscribe.py +14 -6
  13. scripts/nvm_subscription/contracts/base_contract.py +9 -1
  14. scripts/nvm_subscription/contracts/nft_sales.py +1 -3
  15. scripts/nvm_subscription/contracts/subscription_provider.py +2 -4
  16. scripts/nvm_subscription/contracts/token.py +23 -5
  17. scripts/nvm_subscription/manager.py +109 -16
  18. scripts/utils.py +2 -2
  19. scripts/whitelist.py +5 -1
  20. mech_client/helpers/acn/README.md +0 -76
  21. mech_client/helpers/acn/__init__.py +0 -30
  22. mech_client/helpers/acn/acn.proto +0 -71
  23. mech_client/helpers/acn/acn_pb2.py +0 -42
  24. mech_client/helpers/acn/custom_types.py +0 -224
  25. mech_client/helpers/acn/dialogues.py +0 -126
  26. mech_client/helpers/acn/message.py +0 -274
  27. mech_client/helpers/acn/protocol.yaml +0 -24
  28. mech_client/helpers/acn/serialization.py +0 -149
  29. mech_client/helpers/acn/tests/__init__.py +0 -20
  30. mech_client/helpers/acn/tests/test_acn.py +0 -256
  31. mech_client/helpers/acn/tests/test_acn_dialogues.py +0 -53
  32. mech_client/helpers/acn/tests/test_acn_messages.py +0 -117
  33. mech_client/helpers/acn_data_share/README.md +0 -32
  34. mech_client/helpers/acn_data_share/__init__.py +0 -32
  35. mech_client/helpers/acn_data_share/acn_data_share.proto +0 -17
  36. mech_client/helpers/acn_data_share/acn_data_share_pb2.py +0 -29
  37. mech_client/helpers/acn_data_share/dialogues.py +0 -115
  38. mech_client/helpers/acn_data_share/message.py +0 -213
  39. mech_client/helpers/acn_data_share/protocol.yaml +0 -21
  40. mech_client/helpers/acn_data_share/serialization.py +0 -111
  41. mech_client/helpers/acn_data_share/tests/test_acn_data_share_dialogues.py +0 -49
  42. mech_client/helpers/acn_data_share/tests/test_acn_data_share_messages.py +0 -53
  43. mech_client/helpers/p2p_libp2p_client/README.md +0 -15
  44. mech_client/helpers/p2p_libp2p_client/__init__.py +0 -21
  45. mech_client/helpers/p2p_libp2p_client/connection.py +0 -703
  46. mech_client/helpers/p2p_libp2p_client/connection.yaml +0 -52
  47. {mech_client-0.14.1.dist-info → mech_client-0.15.1.dist-info}/LICENSE +0 -0
  48. {mech_client-0.14.1.dist-info → mech_client-0.15.1.dist-info}/WHEEL +0 -0
  49. {mech_client-0.14.1.dist-info → mech_client-0.15.1.dist-info}/entry_points.txt +0 -0
@@ -1,149 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # ------------------------------------------------------------------------------
3
- #
4
- # Copyright 2024 valory
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
- # ------------------------------------------------------------------------------
19
-
20
- """Serialization module for acn protocol."""
21
-
22
- # pylint: disable=too-many-statements,too-many-locals,no-member,too-few-public-methods,redefined-builtin
23
- from typing import Any, Dict, cast
24
-
25
- from aea.mail.base_pb2 import DialogueMessage # type: ignore
26
- from aea.mail.base_pb2 import Message as ProtobufMessage # type: ignore
27
- from aea.protocols.base import Message # type: ignore
28
- from aea.protocols.base import Serializer # type: ignore
29
-
30
- from packages.valory.protocols.acn import acn_pb2 # type: ignore
31
- from packages.valory.protocols.acn.custom_types import ( # type: ignore
32
- AgentRecord,
33
- StatusBody,
34
- )
35
- from packages.valory.protocols.acn.message import AcnMessage # type: ignore
36
-
37
-
38
- class AcnSerializer(Serializer):
39
- """Serialization for the 'acn' protocol."""
40
-
41
- @staticmethod
42
- def encode(msg: Message) -> bytes:
43
- """
44
- Encode a 'Acn' message into bytes.
45
-
46
- :param msg: the message object.
47
- :return: the bytes.
48
- """
49
- msg = cast(AcnMessage, msg)
50
- message_pb = ProtobufMessage()
51
- dialogue_message_pb = DialogueMessage()
52
- acn_msg = acn_pb2.AcnMessage() # type: ignore
53
-
54
- dialogue_message_pb.message_id = msg.message_id
55
- dialogue_reference = msg.dialogue_reference
56
- dialogue_message_pb.dialogue_starter_reference = dialogue_reference[0]
57
- dialogue_message_pb.dialogue_responder_reference = dialogue_reference[1]
58
- dialogue_message_pb.target = msg.target
59
-
60
- performative_id = msg.performative
61
- if performative_id == AcnMessage.Performative.REGISTER:
62
- performative = acn_pb2.AcnMessage.Register_Performative() # type: ignore
63
- record = msg.record
64
- AgentRecord.encode(performative.record, record)
65
- acn_msg.register.CopyFrom(performative)
66
- elif performative_id == AcnMessage.Performative.LOOKUP_REQUEST:
67
- performative = acn_pb2.AcnMessage.Lookup_Request_Performative() # type: ignore
68
- agent_address = msg.agent_address
69
- performative.agent_address = agent_address
70
- acn_msg.lookup_request.CopyFrom(performative)
71
- elif performative_id == AcnMessage.Performative.LOOKUP_RESPONSE:
72
- performative = acn_pb2.AcnMessage.Lookup_Response_Performative() # type: ignore
73
- record = msg.record
74
- AgentRecord.encode(performative.record, record)
75
- acn_msg.lookup_response.CopyFrom(performative)
76
- elif performative_id == AcnMessage.Performative.AEA_ENVELOPE:
77
- performative = acn_pb2.AcnMessage.Aea_Envelope_Performative() # type: ignore
78
- envelope = msg.envelope
79
- performative.envelope = envelope
80
- record = msg.record
81
- AgentRecord.encode(performative.record, record)
82
- acn_msg.aea_envelope.CopyFrom(performative)
83
- elif performative_id == AcnMessage.Performative.STATUS:
84
- performative = acn_pb2.AcnMessage.Status_Performative() # type: ignore
85
- body = msg.body
86
- StatusBody.encode(performative.body, body)
87
- acn_msg.status.CopyFrom(performative)
88
- else:
89
- raise ValueError("Performative not valid: {}".format(performative_id))
90
-
91
- dialogue_message_pb.content = acn_msg.SerializeToString()
92
-
93
- message_pb.dialogue_message.CopyFrom(dialogue_message_pb)
94
- message_bytes = message_pb.SerializeToString()
95
- return message_bytes
96
-
97
- @staticmethod
98
- def decode(obj: bytes) -> Message:
99
- """
100
- Decode bytes into a 'Acn' message.
101
-
102
- :param obj: the bytes object.
103
- :return: the 'Acn' message.
104
- """
105
- message_pb = ProtobufMessage()
106
- acn_pb = acn_pb2.AcnMessage() # type: ignore
107
- message_pb.ParseFromString(obj)
108
- message_id = message_pb.dialogue_message.message_id
109
- dialogue_reference = (
110
- message_pb.dialogue_message.dialogue_starter_reference,
111
- message_pb.dialogue_message.dialogue_responder_reference,
112
- )
113
- target = message_pb.dialogue_message.target
114
-
115
- acn_pb.ParseFromString(message_pb.dialogue_message.content)
116
- performative = acn_pb.WhichOneof("performative")
117
- performative_id = AcnMessage.Performative(str(performative))
118
- performative_content = dict() # type: Dict[str, Any]
119
- if performative_id == AcnMessage.Performative.REGISTER:
120
- pb2_record = acn_pb.register.record
121
- record = AgentRecord.decode(pb2_record)
122
- performative_content["record"] = record
123
- elif performative_id == AcnMessage.Performative.LOOKUP_REQUEST:
124
- agent_address = acn_pb.lookup_request.agent_address
125
- performative_content["agent_address"] = agent_address
126
- elif performative_id == AcnMessage.Performative.LOOKUP_RESPONSE:
127
- pb2_record = acn_pb.lookup_response.record
128
- record = AgentRecord.decode(pb2_record)
129
- performative_content["record"] = record
130
- elif performative_id == AcnMessage.Performative.AEA_ENVELOPE:
131
- envelope = acn_pb.aea_envelope.envelope
132
- performative_content["envelope"] = envelope
133
- pb2_record = acn_pb.aea_envelope.record
134
- record = AgentRecord.decode(pb2_record)
135
- performative_content["record"] = record
136
- elif performative_id == AcnMessage.Performative.STATUS:
137
- pb2_body = acn_pb.status.body
138
- body = StatusBody.decode(pb2_body)
139
- performative_content["body"] = body
140
- else:
141
- raise ValueError("Performative not valid: {}.".format(performative_id))
142
-
143
- return AcnMessage(
144
- message_id=message_id,
145
- dialogue_reference=dialogue_reference,
146
- target=target,
147
- performative=performative,
148
- **performative_content
149
- )
@@ -1,20 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # ------------------------------------------------------------------------------
3
- #
4
- # Copyright 2022 Valory AG
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
- # ------------------------------------------------------------------------------
19
-
20
- """The tests module contains the tests of the acn protocol."""
@@ -1,256 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # ------------------------------------------------------------------------------
3
- #
4
- # Copyright 2022 Valory AG
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
- # ------------------------------------------------------------------------------
19
-
20
- """This module contains the tests of the messages module."""
21
-
22
- from typing import Type
23
- from unittest import mock
24
- from unittest.mock import patch
25
-
26
- import pytest
27
-
28
- from aea.common import Address
29
- from aea.protocols.base import Message
30
- from aea.protocols.dialogue.base import Dialogue as BaseDialogue
31
- from aea.protocols.dialogue.base import DialogueLabel
32
-
33
- from packages.valory.protocols.acn.dialogues import AcnDialogue as BaseAcnDialogue
34
- from packages.valory.protocols.acn.dialogues import AcnDialogues as BaseAcnDialogues
35
- from packages.valory.protocols.acn.message import AcnMessage
36
-
37
-
38
- def test_acn_aea_envelope_serialization():
39
- """Test that the serialization for the 'simple' protocol works for the AEA_ENVELOPE message."""
40
- expected_msg = AcnMessage(
41
- dialogue_reference=("", ""),
42
- message_id=1,
43
- target=0,
44
- performative=AcnMessage.Performative.AEA_ENVELOPE,
45
- envelope=b"envelope",
46
- record=AcnMessage.AgentRecord(
47
- address="address",
48
- public_key="pbk",
49
- peer_public_key="peerpbk",
50
- signature="sign",
51
- service_id="acn",
52
- ledger_id="fetchai",
53
- ),
54
- )
55
- msg_bytes = AcnMessage.serializer.encode(expected_msg)
56
- actual_msg = AcnMessage.serializer.decode(msg_bytes)
57
- assert expected_msg == actual_msg
58
-
59
-
60
- def test_acn_lookup_request_serialization():
61
- """Test that the serialization for the 'simple' protocol works for the LOOKUP_REQUEST message."""
62
- msg = AcnMessage(
63
- dialogue_reference=("", ""),
64
- message_id=1,
65
- target=0,
66
- performative=AcnMessage.Performative.LOOKUP_REQUEST,
67
- agent_address="some_address",
68
- )
69
- msg_bytes = AcnMessage.serializer.encode(msg)
70
- actual_msg = AcnMessage.serializer.decode(msg_bytes)
71
- expected_msg = msg
72
- assert expected_msg == actual_msg
73
-
74
-
75
- def test_acn_lookup_response_serialization():
76
- """Test that the serialization for the 'simple' protocol works for the LOOKUP_RESPONSE message."""
77
- msg = AcnMessage(
78
- dialogue_reference=("", ""),
79
- message_id=1,
80
- target=0,
81
- performative=AcnMessage.Performative.LOOKUP_RESPONSE,
82
- record=AcnMessage.AgentRecord(
83
- address="address",
84
- public_key="pbk",
85
- peer_public_key="peerpbk",
86
- signature="sign",
87
- service_id="acn",
88
- ledger_id="fetchai",
89
- ),
90
- )
91
- msg_bytes = AcnMessage.serializer.encode(msg)
92
- actual_msg = AcnMessage.serializer.decode(msg_bytes)
93
- expected_msg = msg
94
- assert expected_msg == actual_msg
95
-
96
-
97
- def test_acn_record_serialization():
98
- """Test that the serialization for the 'simple' protocol works for the REGISTER message."""
99
- msg = AcnMessage(
100
- dialogue_reference=("", ""),
101
- message_id=1,
102
- target=0,
103
- performative=AcnMessage.Performative.REGISTER,
104
- record=AcnMessage.AgentRecord(
105
- address="address",
106
- public_key="pbk",
107
- peer_public_key="peerpbk",
108
- signature="sign",
109
- service_id="acn",
110
- ledger_id="fetchai",
111
- ),
112
- )
113
- msg_bytes = AcnMessage.serializer.encode(msg)
114
- actual_msg = AcnMessage.serializer.decode(msg_bytes)
115
- expected_msg = msg
116
- assert expected_msg == actual_msg
117
-
118
-
119
- def test_acn_status_serialization():
120
- """Test that the serialization for the 'simple' protocol works for the STATUS message."""
121
- msg = AcnMessage(
122
- dialogue_reference=("", ""),
123
- message_id=1,
124
- target=0,
125
- performative=AcnMessage.Performative.STATUS,
126
- body=AcnMessage.StatusBody(
127
- status_code=AcnMessage.StatusBody.StatusCode.ERROR_UNSUPPORTED_VERSION,
128
- msgs=["pbk"],
129
- ),
130
- )
131
- msg_bytes = AcnMessage.serializer.encode(msg)
132
- actual_msg = AcnMessage.serializer.decode(msg_bytes)
133
- expected_msg = msg
134
- assert expected_msg == actual_msg
135
-
136
-
137
- def test_acn_message_str_values():
138
- """Tests the returned string values of acn Message."""
139
- assert (
140
- str(AcnMessage.Performative.LOOKUP_REQUEST) == "lookup_request"
141
- ), "AcnMessage.Performative.LOOKUP_REQUEST must be lookup_request"
142
-
143
-
144
- def test_encoding_unknown_performative():
145
- """Test that we raise an exception when the performative is unknown during encoding."""
146
- msg = AcnMessage(
147
- performative=AcnMessage.Performative.LOOKUP_REQUEST,
148
- agent_address="address",
149
- )
150
-
151
- with pytest.raises(ValueError, match="Performative not valid:"):
152
- with mock.patch.object(AcnMessage.Performative, "__eq__", return_value=False):
153
- AcnMessage.serializer.encode(msg)
154
-
155
-
156
- def test_check_consistency_raises_exception_when_type_not_recognized():
157
- """Test that we raise exception when the type of the message is not recognized."""
158
- message = AcnMessage(
159
- dialogue_reference=("", ""),
160
- message_id=1,
161
- target=0,
162
- performative=AcnMessage.Performative.LOOKUP_REQUEST,
163
- agent_address="address",
164
- )
165
- # mock the __eq__ method such that any kind of matching is going to fail.
166
- with mock.patch.object(AcnMessage.Performative, "__eq__", return_value=False):
167
- assert not message._is_consistent() # pylint: disable=protected-access
168
-
169
-
170
- def test_acn_valid_performatives():
171
- """Test 'valid_performatives' getter."""
172
- msg = AcnMessage(AcnMessage.Performative.LOOKUP_REQUEST, agent_address="address")
173
- assert msg.valid_performatives == set(
174
- map(lambda x: x.value, iter(AcnMessage.Performative))
175
- )
176
-
177
-
178
- def test_serializer_performative_not_found():
179
- """Test the serializer when the performative is not found."""
180
- message = AcnMessage(
181
- message_id=1,
182
- target=0,
183
- performative=AcnMessage.Performative.LOOKUP_REQUEST,
184
- agent_address="address",
185
- )
186
- message_bytes = message.serializer.encode(message)
187
- with patch.object(AcnMessage.Performative, "__eq__", return_value=False):
188
- with pytest.raises(ValueError, match="Performative not valid: .*"):
189
- message.serializer.decode(message_bytes)
190
-
191
-
192
- def test_dialogues():
193
- """Test intiaontiation of dialogues."""
194
- acn_dialogues = AcnDialogues("agent_addr")
195
- _, dialogue = acn_dialogues.create(
196
- counterparty="abc",
197
- performative=AcnMessage.Performative.LOOKUP_REQUEST,
198
- agent_address="address",
199
- )
200
- assert dialogue is not None
201
-
202
-
203
- class AcnDialogue(BaseAcnDialogue):
204
- """The dialogue class maintains state of a dialogue and manages it."""
205
-
206
- def __init__(
207
- self,
208
- dialogue_label: DialogueLabel,
209
- self_address: Address,
210
- role: BaseDialogue.Role,
211
- message_class: Type[AcnMessage],
212
- ) -> None:
213
- """
214
- Initialize a dialogue.
215
-
216
- :param dialogue_label: the identifier of the dialogue
217
- :param self_address: the address of the entity for whom this dialogue is maintained
218
- :param role: the role of the agent this dialogue is maintained for
219
- :param message_class: the message class
220
- """
221
- BaseAcnDialogue.__init__(
222
- self,
223
- dialogue_label=dialogue_label,
224
- self_address=self_address,
225
- role=role,
226
- message_class=message_class,
227
- )
228
-
229
-
230
- class AcnDialogues(BaseAcnDialogues):
231
- """The dialogues class keeps track of all dialogues."""
232
-
233
- def __init__(self, self_address: Address) -> None:
234
- """
235
- Initialize dialogues.
236
-
237
- :param self_address: the address of the entity that this dialogues is maintained
238
- """
239
-
240
- def role_from_first_message( # pylint: disable=unused-argument
241
- message: Message, receiver_address: Address
242
- ) -> BaseDialogue.Role:
243
- """Infer the role of the agent from an incoming/outgoing first message
244
-
245
- :param message: an incoming/outgoing first message
246
- :param receiver_address: the address of the receiving agent
247
- :return: The role of the agent
248
- """
249
- return AcnDialogue.Role.NODE
250
-
251
- BaseAcnDialogues.__init__(
252
- self,
253
- self_address=self_address,
254
- role_from_first_message=role_from_first_message,
255
- dialogue_class=AcnDialogue,
256
- )
@@ -1,53 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # ------------------------------------------------------------------------------
3
- #
4
- # Copyright 2023 valory
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
- # ------------------------------------------------------------------------------
19
-
20
- """Test dialogues module for acn protocol."""
21
-
22
- # pylint: disable=too-many-statements,too-many-locals,no-member,too-few-public-methods,redefined-builtin
23
- from aea.test_tools.test_protocol import BaseProtocolDialoguesTestCase
24
-
25
- from packages.valory.protocols.acn.custom_types import AgentRecord
26
- from packages.valory.protocols.acn.dialogues import AcnDialogue, AcnDialogues
27
- from packages.valory.protocols.acn.message import AcnMessage
28
-
29
-
30
- class TestDialoguesAcn(BaseProtocolDialoguesTestCase):
31
- """Test for the 'acn' protocol dialogues."""
32
-
33
- MESSAGE_CLASS = AcnMessage
34
-
35
- DIALOGUE_CLASS = AcnDialogue
36
-
37
- DIALOGUES_CLASS = AcnDialogues
38
-
39
- ROLE_FOR_THE_FIRST_MESSAGE = AcnDialogue.Role.NODE # CHECK
40
-
41
- def make_message_content(self) -> dict:
42
- """Make a dict with message contruction content for dialogues.create."""
43
- return dict(
44
- performative=AcnMessage.Performative.REGISTER,
45
- record=AgentRecord(
46
- address="address",
47
- public_key="pbk",
48
- peer_public_key="peerpbk",
49
- signature="sign",
50
- service_id="acn",
51
- ledger_id="fetchai",
52
- ),
53
- )
@@ -1,117 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # ------------------------------------------------------------------------------
3
- #
4
- # Copyright 2023 valory
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
- # ------------------------------------------------------------------------------
19
-
20
- """Test messages module for acn protocol."""
21
-
22
- # pylint: disable=too-many-statements,too-many-locals,no-member,too-few-public-methods,redefined-builtin
23
- from typing import List
24
-
25
- from aea.test_tools.test_protocol import BaseProtocolMessagesTestCase
26
-
27
- from packages.valory.protocols.acn.custom_types import AgentRecord, StatusBody
28
- from packages.valory.protocols.acn.message import AcnMessage
29
-
30
-
31
- class TestMessageAcn(BaseProtocolMessagesTestCase):
32
- """Test for the 'acn' protocol message."""
33
-
34
- MESSAGE_CLASS = AcnMessage
35
-
36
- def build_messages(self) -> List[AcnMessage]: # type: ignore[override]
37
- """Build the messages to be used for testing."""
38
- return [
39
- AcnMessage(
40
- performative=AcnMessage.Performative.REGISTER,
41
- record=AgentRecord(
42
- address="address",
43
- public_key="pbk",
44
- peer_public_key="peerpbk",
45
- signature="sign",
46
- service_id="acn",
47
- ledger_id="fetchai",
48
- ),
49
- ),
50
- AcnMessage(
51
- performative=AcnMessage.Performative.LOOKUP_REQUEST,
52
- agent_address="some str",
53
- ),
54
- AcnMessage(
55
- performative=AcnMessage.Performative.LOOKUP_RESPONSE,
56
- record=AgentRecord(
57
- address="address",
58
- public_key="pbk",
59
- peer_public_key="peerpbk",
60
- signature="sign",
61
- service_id="acn",
62
- ledger_id="fetchai",
63
- ),
64
- ),
65
- AcnMessage(
66
- performative=AcnMessage.Performative.AEA_ENVELOPE,
67
- envelope=b"some_bytes",
68
- record=AgentRecord(
69
- address="address",
70
- public_key="pbk",
71
- peer_public_key="peerpbk",
72
- signature="sign",
73
- service_id="acn",
74
- ledger_id="fetchai",
75
- ),
76
- ),
77
- AcnMessage(
78
- performative=AcnMessage.Performative.STATUS,
79
- body=StatusBody(
80
- status_code=AcnMessage.StatusBody.StatusCode.ERROR_UNSUPPORTED_VERSION,
81
- msgs=["pbk"],
82
- ),
83
- ),
84
- ]
85
-
86
- def build_inconsistent(self) -> List[AcnMessage]: # type: ignore[override]
87
- """Build inconsistent messages to be used for testing."""
88
- return [
89
- AcnMessage(
90
- performative=AcnMessage.Performative.REGISTER,
91
- # skip content: record
92
- ),
93
- AcnMessage(
94
- performative=AcnMessage.Performative.LOOKUP_REQUEST,
95
- # skip content: agent_address
96
- ),
97
- AcnMessage(
98
- performative=AcnMessage.Performative.LOOKUP_RESPONSE,
99
- # skip content: record
100
- ),
101
- AcnMessage(
102
- performative=AcnMessage.Performative.AEA_ENVELOPE,
103
- # skip content: envelope
104
- record=AgentRecord(
105
- address="address",
106
- public_key="pbk",
107
- peer_public_key="peerpbk",
108
- signature="sign",
109
- service_id="acn",
110
- ledger_id="fetchai",
111
- ),
112
- ),
113
- AcnMessage(
114
- performative=AcnMessage.Performative.STATUS,
115
- # skip content: body
116
- ),
117
- ]
@@ -1,32 +0,0 @@
1
- # ACN Data share protocol
2
-
3
- ## Description
4
-
5
- This protocol provides support for sharing raw data using ACN
6
-
7
- ## Specification
8
-
9
- ```yaml
10
- ---
11
- name: acn_data_share
12
- author: valory
13
- version: 0.1.0
14
- description: A protocol for sharing raw data using ACN.
15
- license: Apache-2.0
16
- aea_version: '>=1.0.0, <2.0.0'
17
- protocol_specification_id: valory/acn_data_share:0.1.0
18
- speech_acts:
19
- data:
20
- request_id: pt:str
21
- content: pt:str
22
- ...
23
- ---
24
- initiation: [data]
25
- reply:
26
- data: []
27
- termination: [data]
28
- roles: {agent,skill}
29
- end_states: [successful, failed]
30
- keep_terminal_state_dialogues: false
31
- ...
32
- ```
@@ -1,32 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # ------------------------------------------------------------------------------
3
- #
4
- # Copyright 2023 valory
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
- # ------------------------------------------------------------------------------
19
-
20
- """
21
- This module contains the support resources for the acn_data_share protocol.
22
-
23
- It was created with protocol buffer compiler version `libprotoc 24.3` and aea protocol generator version `1.0.0`.
24
- """
25
-
26
- from packages.valory.protocols.acn_data_share.message import AcnDataShareMessage
27
- from packages.valory.protocols.acn_data_share.serialization import (
28
- AcnDataShareSerializer,
29
- )
30
-
31
-
32
- AcnDataShareMessage.serializer = AcnDataShareSerializer
@@ -1,17 +0,0 @@
1
- syntax = "proto3";
2
-
3
- package aea.valory.acn_data_share.v0_1_0;
4
-
5
- message AcnDataShareMessage{
6
-
7
- // Performatives and contents
8
- message Data_Performative{
9
- string request_id = 1;
10
- string content = 2;
11
- }
12
-
13
-
14
- oneof performative{
15
- Data_Performative data = 5;
16
- }
17
- }