mech-client 0.14.0__py3-none-any.whl → 0.15.0__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.
- mech_client/__init__.py +1 -1
- mech_client/cli.py +257 -11
- mech_client/configs/mechs.json +110 -110
- mech_client/interact.py +6 -1
- mech_client/marketplace_interact.py +161 -43
- mech_client/safe.py +73 -0
- mech_client/subgraph.py +0 -11
- {mech_client-0.14.0.dist-info → mech_client-0.15.0.dist-info}/METADATA +264 -219
- {mech_client-0.14.0.dist-info → mech_client-0.15.0.dist-info}/RECORD +22 -48
- scripts/deposit_native.py +48 -16
- scripts/deposit_token.py +107 -31
- scripts/nvm_subscribe.py +14 -6
- scripts/nvm_subscription/contracts/base_contract.py +9 -1
- scripts/nvm_subscription/contracts/nft_sales.py +1 -3
- scripts/nvm_subscription/contracts/subscription_provider.py +2 -4
- scripts/nvm_subscription/contracts/token.py +23 -5
- scripts/nvm_subscription/manager.py +109 -16
- scripts/utils.py +2 -2
- scripts/whitelist.py +9 -1
- mech_client/helpers/acn/README.md +0 -76
- mech_client/helpers/acn/__init__.py +0 -30
- mech_client/helpers/acn/acn.proto +0 -71
- mech_client/helpers/acn/acn_pb2.py +0 -42
- mech_client/helpers/acn/custom_types.py +0 -224
- mech_client/helpers/acn/dialogues.py +0 -126
- mech_client/helpers/acn/message.py +0 -274
- mech_client/helpers/acn/protocol.yaml +0 -24
- mech_client/helpers/acn/serialization.py +0 -149
- mech_client/helpers/acn/tests/__init__.py +0 -20
- mech_client/helpers/acn/tests/test_acn.py +0 -256
- mech_client/helpers/acn/tests/test_acn_dialogues.py +0 -53
- mech_client/helpers/acn/tests/test_acn_messages.py +0 -117
- mech_client/helpers/acn_data_share/README.md +0 -32
- mech_client/helpers/acn_data_share/__init__.py +0 -32
- mech_client/helpers/acn_data_share/acn_data_share.proto +0 -17
- mech_client/helpers/acn_data_share/acn_data_share_pb2.py +0 -29
- mech_client/helpers/acn_data_share/dialogues.py +0 -115
- mech_client/helpers/acn_data_share/message.py +0 -213
- mech_client/helpers/acn_data_share/protocol.yaml +0 -21
- mech_client/helpers/acn_data_share/serialization.py +0 -111
- mech_client/helpers/acn_data_share/tests/test_acn_data_share_dialogues.py +0 -49
- mech_client/helpers/acn_data_share/tests/test_acn_data_share_messages.py +0 -53
- mech_client/helpers/p2p_libp2p_client/README.md +0 -15
- mech_client/helpers/p2p_libp2p_client/__init__.py +0 -21
- mech_client/helpers/p2p_libp2p_client/connection.py +0 -703
- mech_client/helpers/p2p_libp2p_client/connection.yaml +0 -52
- {mech_client-0.14.0.dist-info → mech_client-0.15.0.dist-info}/LICENSE +0 -0
- {mech_client-0.14.0.dist-info → mech_client-0.15.0.dist-info}/WHEEL +0 -0
- {mech_client-0.14.0.dist-info → mech_client-0.15.0.dist-info}/entry_points.txt +0 -0
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
|
-
# source: acn_data_share.proto
|
|
4
|
-
"""Generated protocol buffer code."""
|
|
5
|
-
from google.protobuf import descriptor as _descriptor
|
|
6
|
-
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
7
|
-
from google.protobuf import symbol_database as _symbol_database
|
|
8
|
-
from google.protobuf.internal import builder as _builder
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
# @@protoc_insertion_point(imports)
|
|
12
|
-
|
|
13
|
-
_sym_db = _symbol_database.Default()
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(
|
|
17
|
-
b'\n\x14\x61\x63n_data_share.proto\x12 aea.valory.acn_data_share.v0_1_0"\xb8\x01\n\x13\x41\x63nDataShareMessage\x12W\n\x04\x64\x61ta\x18\x05 \x01(\x0b\x32G.aea.valory.acn_data_share.v0_1_0.AcnDataShareMessage.Data_PerformativeH\x00\x1a\x38\n\x11\x44\x61ta_Performative\x12\x12\n\nrequest_id\x18\x01 \x01(\t\x12\x0f\n\x07\x63ontent\x18\x02 \x01(\tB\x0e\n\x0cperformativeb\x06proto3'
|
|
18
|
-
)
|
|
19
|
-
|
|
20
|
-
_globals = globals()
|
|
21
|
-
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
|
22
|
-
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, "acn_data_share_pb2", _globals)
|
|
23
|
-
if _descriptor._USE_C_DESCRIPTORS == False:
|
|
24
|
-
DESCRIPTOR._options = None
|
|
25
|
-
_globals["_ACNDATASHAREMESSAGE"]._serialized_start = 59
|
|
26
|
-
_globals["_ACNDATASHAREMESSAGE"]._serialized_end = 243
|
|
27
|
-
_globals["_ACNDATASHAREMESSAGE_DATA_PERFORMATIVE"]._serialized_start = 171
|
|
28
|
-
_globals["_ACNDATASHAREMESSAGE_DATA_PERFORMATIVE"]._serialized_end = 227
|
|
29
|
-
# @@protoc_insertion_point(module_scope)
|
|
@@ -1,115 +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 classes required for acn_data_share dialogue management.
|
|
22
|
-
|
|
23
|
-
- AcnDataShareDialogue: The dialogue class maintains state of a dialogue and manages it.
|
|
24
|
-
- AcnDataShareDialogues: The dialogues class keeps track of all dialogues.
|
|
25
|
-
"""
|
|
26
|
-
|
|
27
|
-
from abc import ABC
|
|
28
|
-
from typing import Callable, Dict, FrozenSet, Type, cast
|
|
29
|
-
|
|
30
|
-
from aea.common import Address
|
|
31
|
-
from aea.protocols.base import Message
|
|
32
|
-
from aea.protocols.dialogue.base import Dialogue, DialogueLabel, Dialogues
|
|
33
|
-
|
|
34
|
-
from packages.valory.protocols.acn_data_share.message import AcnDataShareMessage
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
class AcnDataShareDialogue(Dialogue):
|
|
38
|
-
"""The acn_data_share dialogue class maintains state of a dialogue and manages it."""
|
|
39
|
-
|
|
40
|
-
INITIAL_PERFORMATIVES: FrozenSet[Message.Performative] = frozenset(
|
|
41
|
-
{AcnDataShareMessage.Performative.DATA}
|
|
42
|
-
)
|
|
43
|
-
TERMINAL_PERFORMATIVES: FrozenSet[Message.Performative] = frozenset(
|
|
44
|
-
{AcnDataShareMessage.Performative.DATA}
|
|
45
|
-
)
|
|
46
|
-
VALID_REPLIES: Dict[Message.Performative, FrozenSet[Message.Performative]] = {
|
|
47
|
-
AcnDataShareMessage.Performative.DATA: frozenset(),
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
class Role(Dialogue.Role):
|
|
51
|
-
"""This class defines the agent's role in a acn_data_share dialogue."""
|
|
52
|
-
|
|
53
|
-
AGENT = "agent"
|
|
54
|
-
SKILL = "skill"
|
|
55
|
-
|
|
56
|
-
class EndState(Dialogue.EndState):
|
|
57
|
-
"""This class defines the end states of a acn_data_share dialogue."""
|
|
58
|
-
|
|
59
|
-
SUCCESSFUL = 0
|
|
60
|
-
FAILED = 1
|
|
61
|
-
|
|
62
|
-
def __init__(
|
|
63
|
-
self,
|
|
64
|
-
dialogue_label: DialogueLabel,
|
|
65
|
-
self_address: Address,
|
|
66
|
-
role: Dialogue.Role,
|
|
67
|
-
message_class: Type[AcnDataShareMessage] = AcnDataShareMessage,
|
|
68
|
-
) -> None:
|
|
69
|
-
"""
|
|
70
|
-
Initialize a dialogue.
|
|
71
|
-
|
|
72
|
-
:param dialogue_label: the identifier of the dialogue
|
|
73
|
-
:param self_address: the address of the entity for whom this dialogue is maintained
|
|
74
|
-
:param role: the role of the agent this dialogue is maintained for
|
|
75
|
-
:param message_class: the message class used
|
|
76
|
-
"""
|
|
77
|
-
Dialogue.__init__(
|
|
78
|
-
self,
|
|
79
|
-
dialogue_label=dialogue_label,
|
|
80
|
-
message_class=message_class,
|
|
81
|
-
self_address=self_address,
|
|
82
|
-
role=role,
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
class AcnDataShareDialogues(Dialogues, ABC):
|
|
87
|
-
"""This class keeps track of all acn_data_share dialogues."""
|
|
88
|
-
|
|
89
|
-
END_STATES = frozenset(
|
|
90
|
-
{AcnDataShareDialogue.EndState.SUCCESSFUL, AcnDataShareDialogue.EndState.FAILED}
|
|
91
|
-
)
|
|
92
|
-
|
|
93
|
-
_keep_terminal_state_dialogues = False
|
|
94
|
-
|
|
95
|
-
def __init__(
|
|
96
|
-
self,
|
|
97
|
-
self_address: Address,
|
|
98
|
-
role_from_first_message: Callable[[Message, Address], Dialogue.Role],
|
|
99
|
-
dialogue_class: Type[AcnDataShareDialogue] = AcnDataShareDialogue,
|
|
100
|
-
) -> None:
|
|
101
|
-
"""
|
|
102
|
-
Initialize dialogues.
|
|
103
|
-
|
|
104
|
-
:param self_address: the address of the entity for whom dialogues are maintained
|
|
105
|
-
:param dialogue_class: the dialogue class used
|
|
106
|
-
:param role_from_first_message: the callable determining role from first message
|
|
107
|
-
"""
|
|
108
|
-
Dialogues.__init__(
|
|
109
|
-
self,
|
|
110
|
-
self_address=self_address,
|
|
111
|
-
end_states=cast(FrozenSet[Dialogue.EndState], self.END_STATES),
|
|
112
|
-
message_class=AcnDataShareMessage,
|
|
113
|
-
dialogue_class=dialogue_class,
|
|
114
|
-
role_from_first_message=role_from_first_message,
|
|
115
|
-
)
|
|
@@ -1,213 +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
|
-
"""This module contains acn_data_share's message definition."""
|
|
21
|
-
|
|
22
|
-
# pylint: disable=too-many-statements,too-many-locals,no-member,too-few-public-methods,too-many-branches,not-an-iterable,unidiomatic-typecheck,unsubscriptable-object
|
|
23
|
-
import logging
|
|
24
|
-
from typing import Any, Set, Tuple, cast
|
|
25
|
-
|
|
26
|
-
from aea.configurations.base import PublicId
|
|
27
|
-
from aea.exceptions import AEAEnforceError, enforce
|
|
28
|
-
from aea.protocols.base import Message # type: ignore
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
_default_logger = logging.getLogger(
|
|
32
|
-
"aea.packages.valory.protocols.acn_data_share.message"
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
DEFAULT_BODY_SIZE = 4
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
class AcnDataShareMessage(Message):
|
|
39
|
-
"""A protocol for sharing raw data using ACN."""
|
|
40
|
-
|
|
41
|
-
protocol_id = PublicId.from_str("valory/acn_data_share:0.1.0")
|
|
42
|
-
protocol_specification_id = PublicId.from_str("valory/acn_data_share:0.1.0")
|
|
43
|
-
|
|
44
|
-
class Performative(Message.Performative):
|
|
45
|
-
"""Performatives for the acn_data_share protocol."""
|
|
46
|
-
|
|
47
|
-
DATA = "data"
|
|
48
|
-
|
|
49
|
-
def __str__(self) -> str:
|
|
50
|
-
"""Get the string representation."""
|
|
51
|
-
return str(self.value)
|
|
52
|
-
|
|
53
|
-
_performatives = {"data"}
|
|
54
|
-
__slots__: Tuple[str, ...] = tuple()
|
|
55
|
-
|
|
56
|
-
class _SlotsCls:
|
|
57
|
-
__slots__ = (
|
|
58
|
-
"content",
|
|
59
|
-
"dialogue_reference",
|
|
60
|
-
"message_id",
|
|
61
|
-
"performative",
|
|
62
|
-
"request_id",
|
|
63
|
-
"target",
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
def __init__(
|
|
67
|
-
self,
|
|
68
|
-
performative: Performative,
|
|
69
|
-
dialogue_reference: Tuple[str, str] = ("", ""),
|
|
70
|
-
message_id: int = 1,
|
|
71
|
-
target: int = 0,
|
|
72
|
-
**kwargs: Any,
|
|
73
|
-
):
|
|
74
|
-
"""
|
|
75
|
-
Initialise an instance of AcnDataShareMessage.
|
|
76
|
-
|
|
77
|
-
:param message_id: the message id.
|
|
78
|
-
:param dialogue_reference: the dialogue reference.
|
|
79
|
-
:param target: the message target.
|
|
80
|
-
:param performative: the message performative.
|
|
81
|
-
:param **kwargs: extra options.
|
|
82
|
-
"""
|
|
83
|
-
super().__init__(
|
|
84
|
-
dialogue_reference=dialogue_reference,
|
|
85
|
-
message_id=message_id,
|
|
86
|
-
target=target,
|
|
87
|
-
performative=AcnDataShareMessage.Performative(performative),
|
|
88
|
-
**kwargs,
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
@property
|
|
92
|
-
def valid_performatives(self) -> Set[str]:
|
|
93
|
-
"""Get valid performatives."""
|
|
94
|
-
return self._performatives
|
|
95
|
-
|
|
96
|
-
@property
|
|
97
|
-
def dialogue_reference(self) -> Tuple[str, str]:
|
|
98
|
-
"""Get the dialogue_reference of the message."""
|
|
99
|
-
enforce(self.is_set("dialogue_reference"), "dialogue_reference is not set.")
|
|
100
|
-
return cast(Tuple[str, str], self.get("dialogue_reference"))
|
|
101
|
-
|
|
102
|
-
@property
|
|
103
|
-
def message_id(self) -> int:
|
|
104
|
-
"""Get the message_id of the message."""
|
|
105
|
-
enforce(self.is_set("message_id"), "message_id is not set.")
|
|
106
|
-
return cast(int, self.get("message_id"))
|
|
107
|
-
|
|
108
|
-
@property
|
|
109
|
-
def performative(self) -> Performative: # type: ignore # noqa: F821
|
|
110
|
-
"""Get the performative of the message."""
|
|
111
|
-
enforce(self.is_set("performative"), "performative is not set.")
|
|
112
|
-
return cast(AcnDataShareMessage.Performative, self.get("performative"))
|
|
113
|
-
|
|
114
|
-
@property
|
|
115
|
-
def target(self) -> int:
|
|
116
|
-
"""Get the target of the message."""
|
|
117
|
-
enforce(self.is_set("target"), "target is not set.")
|
|
118
|
-
return cast(int, self.get("target"))
|
|
119
|
-
|
|
120
|
-
@property
|
|
121
|
-
def content(self) -> str:
|
|
122
|
-
"""Get the 'content' content from the message."""
|
|
123
|
-
enforce(self.is_set("content"), "'content' content is not set.")
|
|
124
|
-
return cast(str, self.get("content"))
|
|
125
|
-
|
|
126
|
-
@property
|
|
127
|
-
def request_id(self) -> str:
|
|
128
|
-
"""Get the 'request_id' content from the message."""
|
|
129
|
-
enforce(self.is_set("request_id"), "'request_id' content is not set.")
|
|
130
|
-
return cast(str, self.get("request_id"))
|
|
131
|
-
|
|
132
|
-
def _is_consistent(self) -> bool:
|
|
133
|
-
"""Check that the message follows the acn_data_share protocol."""
|
|
134
|
-
try:
|
|
135
|
-
enforce(
|
|
136
|
-
isinstance(self.dialogue_reference, tuple),
|
|
137
|
-
"Invalid type for 'dialogue_reference'. Expected 'tuple'. Found '{}'.".format(
|
|
138
|
-
type(self.dialogue_reference)
|
|
139
|
-
),
|
|
140
|
-
)
|
|
141
|
-
enforce(
|
|
142
|
-
isinstance(self.dialogue_reference[0], str),
|
|
143
|
-
"Invalid type for 'dialogue_reference[0]'. Expected 'str'. Found '{}'.".format(
|
|
144
|
-
type(self.dialogue_reference[0])
|
|
145
|
-
),
|
|
146
|
-
)
|
|
147
|
-
enforce(
|
|
148
|
-
isinstance(self.dialogue_reference[1], str),
|
|
149
|
-
"Invalid type for 'dialogue_reference[1]'. Expected 'str'. Found '{}'.".format(
|
|
150
|
-
type(self.dialogue_reference[1])
|
|
151
|
-
),
|
|
152
|
-
)
|
|
153
|
-
enforce(
|
|
154
|
-
type(self.message_id) is int,
|
|
155
|
-
"Invalid type for 'message_id'. Expected 'int'. Found '{}'.".format(
|
|
156
|
-
type(self.message_id)
|
|
157
|
-
),
|
|
158
|
-
)
|
|
159
|
-
enforce(
|
|
160
|
-
type(self.target) is int,
|
|
161
|
-
"Invalid type for 'target'. Expected 'int'. Found '{}'.".format(
|
|
162
|
-
type(self.target)
|
|
163
|
-
),
|
|
164
|
-
)
|
|
165
|
-
|
|
166
|
-
# Light Protocol Rule 2
|
|
167
|
-
# Check correct performative
|
|
168
|
-
enforce(
|
|
169
|
-
isinstance(self.performative, AcnDataShareMessage.Performative),
|
|
170
|
-
"Invalid 'performative'. Expected either of '{}'. Found '{}'.".format(
|
|
171
|
-
self.valid_performatives, self.performative
|
|
172
|
-
),
|
|
173
|
-
)
|
|
174
|
-
|
|
175
|
-
# Check correct contents
|
|
176
|
-
actual_nb_of_contents = len(self._body) - DEFAULT_BODY_SIZE
|
|
177
|
-
expected_nb_of_contents = 0
|
|
178
|
-
if self.performative == AcnDataShareMessage.Performative.DATA:
|
|
179
|
-
expected_nb_of_contents = 2
|
|
180
|
-
enforce(
|
|
181
|
-
isinstance(self.request_id, str),
|
|
182
|
-
"Invalid type for content 'request_id'. Expected 'str'. Found '{}'.".format(
|
|
183
|
-
type(self.request_id)
|
|
184
|
-
),
|
|
185
|
-
)
|
|
186
|
-
enforce(
|
|
187
|
-
isinstance(self.content, str),
|
|
188
|
-
"Invalid type for content 'content'. Expected 'str'. Found '{}'.".format(
|
|
189
|
-
type(self.content)
|
|
190
|
-
),
|
|
191
|
-
)
|
|
192
|
-
|
|
193
|
-
# Check correct content count
|
|
194
|
-
enforce(
|
|
195
|
-
expected_nb_of_contents == actual_nb_of_contents,
|
|
196
|
-
"Incorrect number of contents. Expected {}. Found {}".format(
|
|
197
|
-
expected_nb_of_contents, actual_nb_of_contents
|
|
198
|
-
),
|
|
199
|
-
)
|
|
200
|
-
|
|
201
|
-
# Light Protocol Rule 3
|
|
202
|
-
if self.message_id == 1:
|
|
203
|
-
enforce(
|
|
204
|
-
self.target == 0,
|
|
205
|
-
"Invalid 'target'. Expected 0 (because 'message_id' is 1). Found {}.".format(
|
|
206
|
-
self.target
|
|
207
|
-
),
|
|
208
|
-
)
|
|
209
|
-
except (AEAEnforceError, ValueError, KeyError) as e:
|
|
210
|
-
_default_logger.error(str(e))
|
|
211
|
-
return False
|
|
212
|
-
|
|
213
|
-
return True
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
name: acn_data_share
|
|
2
|
-
author: valory
|
|
3
|
-
version: 0.1.0
|
|
4
|
-
protocol_specification_id: valory/acn_data_share:0.1.0
|
|
5
|
-
type: protocol
|
|
6
|
-
description: A protocol for sharing raw data using ACN.
|
|
7
|
-
license: Apache-2.0
|
|
8
|
-
aea_version: '>=1.0.0, <2.0.0'
|
|
9
|
-
fingerprint:
|
|
10
|
-
README.md: bafybeiexqywrjzv4ajzesbzaw7bujvmgadsqtxzfnerwqogi7nz6jcvp6u
|
|
11
|
-
__init__.py: bafybeif7fohg7vfalh35nyuqchdw5lnjblqtodhxmcnnhycderagqs46du
|
|
12
|
-
acn_data_share.proto: bafybeiell3oa6eo2oogbgymu5cupeakbkpkmxkh7gossgy4jdip7lrr7tu
|
|
13
|
-
acn_data_share_pb2.py: bafybeifyna3ykdjrh2t5etusxc22hiplfvekh6vjlrnom2tzgcolmhsslu
|
|
14
|
-
dialogues.py: bafybeigtnzvicosvctjk67qni5mu3yy77fp5u2xpb2eszwfht7igeaip4m
|
|
15
|
-
message.py: bafybeiggjuq6fooopoy423v6huhfk6szyzdlgkxk5ardlyllawj2qykhfq
|
|
16
|
-
serialization.py: bafybeihi2cogvek6irdncct5ga2ztdeqho4eai6krtk354yq2ip2d5f3se
|
|
17
|
-
tests/test_acn_data_share_dialogues.py: bafybeie5kcwchjl5vozdlrnwhmim4kffa7fr5zsqjy3r27mjzuilaog5su
|
|
18
|
-
tests/test_acn_data_share_messages.py: bafybeifap2cnraojc4ohd46rrjgusi6iisjm5tum2bs4sfgdocx5zjsqea
|
|
19
|
-
fingerprint_ignore_patterns: []
|
|
20
|
-
dependencies:
|
|
21
|
-
protobuf: {}
|
|
@@ -1,111 +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
|
-
"""Serialization module for acn_data_share 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_data_share import acn_data_share_pb2 # type: ignore
|
|
31
|
-
from packages.valory.protocols.acn_data_share.message import ( # type: ignore
|
|
32
|
-
AcnDataShareMessage,
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
class AcnDataShareSerializer(Serializer):
|
|
37
|
-
"""Serialization for the 'acn_data_share' protocol."""
|
|
38
|
-
|
|
39
|
-
@staticmethod
|
|
40
|
-
def encode(msg: Message) -> bytes:
|
|
41
|
-
"""
|
|
42
|
-
Encode a 'AcnDataShare' message into bytes.
|
|
43
|
-
|
|
44
|
-
:param msg: the message object.
|
|
45
|
-
:return: the bytes.
|
|
46
|
-
"""
|
|
47
|
-
msg = cast(AcnDataShareMessage, msg)
|
|
48
|
-
message_pb = ProtobufMessage()
|
|
49
|
-
dialogue_message_pb = DialogueMessage()
|
|
50
|
-
acn_data_share_msg = acn_data_share_pb2.AcnDataShareMessage() # type: ignore
|
|
51
|
-
|
|
52
|
-
dialogue_message_pb.message_id = msg.message_id
|
|
53
|
-
dialogue_reference = msg.dialogue_reference
|
|
54
|
-
dialogue_message_pb.dialogue_starter_reference = dialogue_reference[0]
|
|
55
|
-
dialogue_message_pb.dialogue_responder_reference = dialogue_reference[1]
|
|
56
|
-
dialogue_message_pb.target = msg.target
|
|
57
|
-
|
|
58
|
-
performative_id = msg.performative
|
|
59
|
-
if performative_id == AcnDataShareMessage.Performative.DATA:
|
|
60
|
-
performative = acn_data_share_pb2.AcnDataShareMessage.Data_Performative() # type: ignore
|
|
61
|
-
request_id = msg.request_id
|
|
62
|
-
performative.request_id = request_id
|
|
63
|
-
content = msg.content
|
|
64
|
-
performative.content = content
|
|
65
|
-
acn_data_share_msg.data.CopyFrom(performative)
|
|
66
|
-
else:
|
|
67
|
-
raise ValueError("Performative not valid: {}".format(performative_id))
|
|
68
|
-
|
|
69
|
-
dialogue_message_pb.content = acn_data_share_msg.SerializeToString()
|
|
70
|
-
|
|
71
|
-
message_pb.dialogue_message.CopyFrom(dialogue_message_pb)
|
|
72
|
-
message_bytes = message_pb.SerializeToString()
|
|
73
|
-
return message_bytes
|
|
74
|
-
|
|
75
|
-
@staticmethod
|
|
76
|
-
def decode(obj: bytes) -> Message:
|
|
77
|
-
"""
|
|
78
|
-
Decode bytes into a 'AcnDataShare' message.
|
|
79
|
-
|
|
80
|
-
:param obj: the bytes object.
|
|
81
|
-
:return: the 'AcnDataShare' message.
|
|
82
|
-
"""
|
|
83
|
-
message_pb = ProtobufMessage()
|
|
84
|
-
acn_data_share_pb = acn_data_share_pb2.AcnDataShareMessage() # type: ignore
|
|
85
|
-
message_pb.ParseFromString(obj)
|
|
86
|
-
message_id = message_pb.dialogue_message.message_id
|
|
87
|
-
dialogue_reference = (
|
|
88
|
-
message_pb.dialogue_message.dialogue_starter_reference,
|
|
89
|
-
message_pb.dialogue_message.dialogue_responder_reference,
|
|
90
|
-
)
|
|
91
|
-
target = message_pb.dialogue_message.target
|
|
92
|
-
|
|
93
|
-
acn_data_share_pb.ParseFromString(message_pb.dialogue_message.content)
|
|
94
|
-
performative = acn_data_share_pb.WhichOneof("performative")
|
|
95
|
-
performative_id = AcnDataShareMessage.Performative(str(performative))
|
|
96
|
-
performative_content = dict() # type: Dict[str, Any]
|
|
97
|
-
if performative_id == AcnDataShareMessage.Performative.DATA:
|
|
98
|
-
request_id = acn_data_share_pb.data.request_id
|
|
99
|
-
performative_content["request_id"] = request_id
|
|
100
|
-
content = acn_data_share_pb.data.content
|
|
101
|
-
performative_content["content"] = content
|
|
102
|
-
else:
|
|
103
|
-
raise ValueError("Performative not valid: {}.".format(performative_id))
|
|
104
|
-
|
|
105
|
-
return AcnDataShareMessage(
|
|
106
|
-
message_id=message_id,
|
|
107
|
-
dialogue_reference=dialogue_reference,
|
|
108
|
-
target=target,
|
|
109
|
-
performative=performative,
|
|
110
|
-
**performative_content
|
|
111
|
-
)
|
|
@@ -1,49 +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_data_share 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_data_share.dialogues import (
|
|
26
|
-
AcnDataShareDialogue,
|
|
27
|
-
AcnDataShareDialogues,
|
|
28
|
-
)
|
|
29
|
-
from packages.valory.protocols.acn_data_share.message import AcnDataShareMessage
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
class TestDialoguesAcnDataShare(BaseProtocolDialoguesTestCase):
|
|
33
|
-
"""Test for the 'acn_data_share' protocol dialogues."""
|
|
34
|
-
|
|
35
|
-
MESSAGE_CLASS = AcnDataShareMessage
|
|
36
|
-
|
|
37
|
-
DIALOGUE_CLASS = AcnDataShareDialogue
|
|
38
|
-
|
|
39
|
-
DIALOGUES_CLASS = AcnDataShareDialogues
|
|
40
|
-
|
|
41
|
-
ROLE_FOR_THE_FIRST_MESSAGE = AcnDataShareDialogue.Role.AGENT # CHECK
|
|
42
|
-
|
|
43
|
-
def make_message_content(self) -> dict:
|
|
44
|
-
"""Make a dict with message contruction content for dialogues.create."""
|
|
45
|
-
return dict(
|
|
46
|
-
performative=AcnDataShareMessage.Performative.DATA,
|
|
47
|
-
request_id="some str",
|
|
48
|
-
content="some str",
|
|
49
|
-
)
|
|
@@ -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 messages module for acn_data_share 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_data_share.message import AcnDataShareMessage
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
class TestMessageAcnDataShare(BaseProtocolMessagesTestCase):
|
|
31
|
-
"""Test for the 'acn_data_share' protocol message."""
|
|
32
|
-
|
|
33
|
-
MESSAGE_CLASS = AcnDataShareMessage
|
|
34
|
-
|
|
35
|
-
def build_messages(self) -> List[AcnDataShareMessage]: # type: ignore[override]
|
|
36
|
-
"""Build the messages to be used for testing."""
|
|
37
|
-
return [
|
|
38
|
-
AcnDataShareMessage(
|
|
39
|
-
performative=AcnDataShareMessage.Performative.DATA,
|
|
40
|
-
request_id="some str",
|
|
41
|
-
content="some str",
|
|
42
|
-
),
|
|
43
|
-
]
|
|
44
|
-
|
|
45
|
-
def build_inconsistent(self) -> List[AcnDataShareMessage]: # type: ignore[override]
|
|
46
|
-
"""Build inconsistent messages to be used for testing."""
|
|
47
|
-
return [
|
|
48
|
-
AcnDataShareMessage(
|
|
49
|
-
performative=AcnDataShareMessage.Performative.DATA,
|
|
50
|
-
# skip content: request_id
|
|
51
|
-
content="some str",
|
|
52
|
-
),
|
|
53
|
-
]
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# P2P Libp2p Client Connection
|
|
2
|
-
|
|
3
|
-
A lightweight TCP connection to a libp2p DHT node.
|
|
4
|
-
|
|
5
|
-
It allows for using the DHT without having to deploy a node by delegating its communication traffic to an already running DHT node with delegate service enabled.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
## Usage
|
|
9
|
-
|
|
10
|
-
First, add the connection to your AEA project: `aea add connection valory/p2p_libp2p_client:0.1.0`.
|
|
11
|
-
|
|
12
|
-
Next, ensure that the connection is properly configured by setting:
|
|
13
|
-
|
|
14
|
-
- `nodes` to a list of `uri`s, connection will choose the delegate randomly
|
|
15
|
-
- `uri` to the public IP address and port number of the delegate service of a running DHT node, in format `${ip|dns}:${port}`
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
# ------------------------------------------------------------------------------
|
|
3
|
-
#
|
|
4
|
-
# Copyright 2022 Valory AG
|
|
5
|
-
# Copyright 2018-2019 Fetch.AI Limited
|
|
6
|
-
#
|
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
# you may not use this file except in compliance with the License.
|
|
9
|
-
# You may obtain a copy of the License at
|
|
10
|
-
#
|
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
#
|
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
# See the License for the specific language governing permissions and
|
|
17
|
-
# limitations under the License.
|
|
18
|
-
#
|
|
19
|
-
# ------------------------------------------------------------------------------
|
|
20
|
-
|
|
21
|
-
"""Implementation of the libp2p client connection."""
|