mech-client 0.8.1__tar.gz → 0.8.2__tar.gz
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-0.8.1 → mech_client-0.8.2}/PKG-INFO +1 -1
- mech_client-0.8.2/mech_client/__init__.py +3 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/pyproject.toml +2 -2
- mech_client-0.8.2/scripts/__init__.py +1 -0
- mech_client-0.8.2/scripts/benchmark.sh +32 -0
- mech_client-0.8.2/scripts/bump.py +316 -0
- mech_client-0.8.2/scripts/deposit_native.py +118 -0
- mech_client-0.8.2/scripts/deposit_token.py +187 -0
- mech_client-0.8.2/scripts/nvm_subscribe.py +51 -0
- mech_client-0.8.2/scripts/nvm_subscription/contracts/agreement_manager.py +44 -0
- mech_client-0.8.2/scripts/nvm_subscription/contracts/base_contract.py +75 -0
- mech_client-0.8.2/scripts/nvm_subscription/contracts/did_registry.py +91 -0
- mech_client-0.8.2/scripts/nvm_subscription/contracts/escrow_payment.py +85 -0
- mech_client-0.8.2/scripts/nvm_subscription/contracts/lock_payment.py +76 -0
- mech_client-0.8.2/scripts/nvm_subscription/contracts/nft.py +47 -0
- mech_client-0.8.2/scripts/nvm_subscription/contracts/nft_sales.py +119 -0
- mech_client-0.8.2/scripts/nvm_subscription/contracts/subscription_provider.py +107 -0
- mech_client-0.8.2/scripts/nvm_subscription/contracts/token.py +87 -0
- mech_client-0.8.2/scripts/nvm_subscription/contracts/transfer_nft.py +81 -0
- mech_client-0.8.2/scripts/nvm_subscription/envs/base.env +10 -0
- mech_client-0.8.2/scripts/nvm_subscription/envs/gnosis.env +10 -0
- mech_client-0.8.2/scripts/nvm_subscription/manager.py +265 -0
- mech_client-0.8.2/scripts/nvm_subscription/resources/networks.json +56 -0
- mech_client-0.8.2/scripts/utils.py +127 -0
- mech_client-0.8.2/scripts/whitelist.py +5 -0
- mech_client-0.8.1/mech_client/__init__.py +0 -3
- {mech_client-0.8.1 → mech_client-0.8.2}/LICENSE +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/README.md +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/abis/AgentMech.json +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/abis/AgentRegistry.json +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/abis/AgreementStoreManager.base.json +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/abis/AgreementStoreManager.gnosis.json +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/abis/BalanceTrackerFixedPriceNative.json +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/abis/BalanceTrackerFixedPriceToken.json +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/abis/BalanceTrackerNvmSubscriptionNative.json +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/abis/BalanceTrackerNvmSubscriptionToken.json +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/abis/ComplementaryServiceMetadata.json +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/abis/DIDRegistry.base.json +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/abis/DIDRegistry.gnosis.json +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/abis/EscrowPaymentCondition.base.json +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/abis/EscrowPaymentCondition.gnosis.json +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/abis/IERC1155.json +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/abis/IMech.json +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/abis/IToken.json +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/abis/LockPaymentCondition.base.json +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/abis/LockPaymentCondition.gnosis.json +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/abis/MechMarketplace.json +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/abis/NFTSalesTemplate.base.json +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/abis/NFTSalesTemplate.gnosis.json +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/abis/NeverminedConfig.base.json +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/abis/NeverminedConfig.gnosis.json +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/abis/SubscriptionNFT.base.json +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/abis/SubscriptionNFT.gnosis.json +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/abis/SubscriptionProvider.base.json +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/abis/SubscriptionProvider.gnosis.json +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/abis/SubscriptionToken.base.json +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/abis/TransferNFTCondition.base.json +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/abis/TransferNFTCondition.gnosis.json +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/acn.py +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/cli.py +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/configs/mechs.json +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/fetch_ipfs_hash.py +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/helpers/__init__.py +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/helpers/acn/README.md +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/helpers/acn/__init__.py +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/helpers/acn/acn.proto +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/helpers/acn/acn_pb2.py +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/helpers/acn/custom_types.py +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/helpers/acn/dialogues.py +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/helpers/acn/message.py +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/helpers/acn/protocol.yaml +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/helpers/acn/serialization.py +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/helpers/acn/tests/__init__.py +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/helpers/acn/tests/test_acn.py +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/helpers/acn/tests/test_acn_dialogues.py +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/helpers/acn/tests/test_acn_messages.py +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/helpers/acn_data_share/README.md +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/helpers/acn_data_share/__init__.py +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/helpers/acn_data_share/acn_data_share.proto +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/helpers/acn_data_share/acn_data_share_pb2.py +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/helpers/acn_data_share/dialogues.py +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/helpers/acn_data_share/message.py +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/helpers/acn_data_share/protocol.yaml +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/helpers/acn_data_share/serialization.py +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/helpers/acn_data_share/tests/test_acn_data_share_dialogues.py +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/helpers/acn_data_share/tests/test_acn_data_share_messages.py +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/helpers/p2p_libp2p_client/README.md +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/helpers/p2p_libp2p_client/__init__.py +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/helpers/p2p_libp2p_client/connection.py +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/helpers/p2p_libp2p_client/connection.yaml +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/interact.py +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/marketplace_interact.py +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/mech_marketplace_tool_management.py +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/mech_tool_management.py +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/prompt_to_ipfs.py +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/push_to_ipfs.py +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/subgraph.py +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/to_png.py +0 -0
- {mech_client-0.8.1 → mech_client-0.8.2}/mech_client/wss.py +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "mech-client"
|
|
3
|
-
version = "0.8.
|
|
3
|
+
version = "0.8.2"
|
|
4
4
|
description = "Basic client to interact with a mech"
|
|
5
5
|
authors = ["David Minarsch <david.minarsch@googlemail.com>"]
|
|
6
6
|
readme = "README.md"
|
|
7
|
-
packages = [{include = "mech_client"}]
|
|
7
|
+
packages = [{include = "mech_client"}, {include = "scripts"}]
|
|
8
8
|
license = "Apache-2.0"
|
|
9
9
|
include = [
|
|
10
10
|
"mech_client/helpers/acn/*",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Mech client scripts"""
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
export MANUAL_GAS_LIMIT=150000
|
|
4
|
+
export WEBSOCKET_ENDPOINT=wss://rpc.eu-central-2.gateway.fm/ws/v4/gnosis/non-archival/mainnet
|
|
5
|
+
iterations=2
|
|
6
|
+
|
|
7
|
+
mechx --version
|
|
8
|
+
|
|
9
|
+
echo $WEBSOCKET_ENDPOINT
|
|
10
|
+
|
|
11
|
+
start_time=$(date +%s.%N)
|
|
12
|
+
|
|
13
|
+
# Execute the command for the specified number of iterations
|
|
14
|
+
for ((i=1; i<=$iterations; i++)); do
|
|
15
|
+
echo "- Iteration $i"
|
|
16
|
+
|
|
17
|
+
prompt="($i) Will arsenal win the Premier League in 2024"
|
|
18
|
+
mechx interact "$prompt" 6 --tool prediction-offline --confirm on-chain --extra-attribute key1=value1 --extra-attribute key2=value2
|
|
19
|
+
|
|
20
|
+
if [ $? -ne 0 ]; then
|
|
21
|
+
echo "Error: Command execution failed."
|
|
22
|
+
exit 1
|
|
23
|
+
fi
|
|
24
|
+
|
|
25
|
+
echo ""
|
|
26
|
+
done
|
|
27
|
+
|
|
28
|
+
end_time=$(date +%s.%N)
|
|
29
|
+
elapsed_time=$(echo "$end_time - $start_time" | bc)
|
|
30
|
+
seconds_per_iteration=$(echo "$elapsed_time / $iterations" | bc)
|
|
31
|
+
|
|
32
|
+
echo "Overall execution time for $iterations iterations: $elapsed_time seconds (rate of $seconds_per_iteration seconds/iteration)."
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# ------------------------------------------------------------------------------
|
|
3
|
+
#
|
|
4
|
+
# Copyright 2023 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
|
+
"""
|
|
21
|
+
Script for bumping core dependencies.
|
|
22
|
+
|
|
23
|
+
This script
|
|
24
|
+
|
|
25
|
+
- Fetches the latest core dependency versions from github
|
|
26
|
+
- Updates the tox.ini, packages and Pipfile/pyproject.toml files
|
|
27
|
+
- Performs the packages sync
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
import os
|
|
31
|
+
import re
|
|
32
|
+
import typing as t
|
|
33
|
+
from pathlib import Path
|
|
34
|
+
|
|
35
|
+
import click
|
|
36
|
+
import requests
|
|
37
|
+
from aea.cli.utils.click_utils import PackagesSource, PyPiDependency
|
|
38
|
+
from aea.configurations.constants import PACKAGES, PACKAGE_TYPE_TO_CONFIG_FILE
|
|
39
|
+
from aea.configurations.data_types import Dependency
|
|
40
|
+
from aea.helpers.logging import setup_logger
|
|
41
|
+
from aea.helpers.yaml_utils import yaml_dump, yaml_dump_all, yaml_load, yaml_load_all
|
|
42
|
+
from aea.package_manager.v1 import PackageManagerV1
|
|
43
|
+
|
|
44
|
+
from autonomy.cli.helpers.ipfs_hash import load_configuration
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
BUMP_BRANCH = "chore/bump"
|
|
48
|
+
PIPFILE = Path.cwd() / "Pipfile"
|
|
49
|
+
PYPROJECT_TOML = Path.cwd() / "pyproject.toml"
|
|
50
|
+
TOX_INI = Path.cwd() / "tox.ini"
|
|
51
|
+
|
|
52
|
+
TAGS_URL = "https://api.github.com/repos/{repo}/tags"
|
|
53
|
+
FILE_URL = "https://raw.githubusercontent.com/{repo}/{tag}/{file}"
|
|
54
|
+
|
|
55
|
+
VERISON_RE = re.compile(r"(__version__|version)( )?=( )?\"(?P<version>[0-9a-z\.]+)\"")
|
|
56
|
+
|
|
57
|
+
OPEN_AEA_REPO = "valory-xyz/open-aea"
|
|
58
|
+
OPEN_AUTONOMY_REPO = "valory-xyz/open-autonomy"
|
|
59
|
+
|
|
60
|
+
DEPENDENCY_SPECS = {
|
|
61
|
+
"open-aea": {
|
|
62
|
+
"repo": OPEN_AEA_REPO,
|
|
63
|
+
"file": "aea/__version__.py",
|
|
64
|
+
},
|
|
65
|
+
"open-aea-ledger-ethereum": {
|
|
66
|
+
"repo": OPEN_AEA_REPO,
|
|
67
|
+
"file": "plugins/aea-ledger-ethereum/setup.py",
|
|
68
|
+
},
|
|
69
|
+
"open-aea-ledger-ethereum-flashbots": {
|
|
70
|
+
"repo": OPEN_AEA_REPO,
|
|
71
|
+
"file": "plugins/aea-ledger-ethereum-flashbots/setup.py",
|
|
72
|
+
},
|
|
73
|
+
"open-aea-ledger-ethereum-hwi": {
|
|
74
|
+
"repo": OPEN_AEA_REPO,
|
|
75
|
+
"file": "plugins/aea-ledger-ethereum-hwi/setup.py",
|
|
76
|
+
},
|
|
77
|
+
"open-aea-ledger-cosmos": {
|
|
78
|
+
"repo": OPEN_AEA_REPO,
|
|
79
|
+
"file": "plugins/aea-ledger-cosmos/setup.py",
|
|
80
|
+
},
|
|
81
|
+
"open-aea-ledger-solana": {
|
|
82
|
+
"repo": OPEN_AEA_REPO,
|
|
83
|
+
"file": "plugins/aea-ledger-solana/setup.py",
|
|
84
|
+
},
|
|
85
|
+
"open-aea-cli-ipfs": {
|
|
86
|
+
"repo": OPEN_AEA_REPO,
|
|
87
|
+
"file": "plugins/aea-cli-ipfs/setup.py",
|
|
88
|
+
},
|
|
89
|
+
"open-autonomy": {
|
|
90
|
+
"repo": OPEN_AUTONOMY_REPO,
|
|
91
|
+
"file": "autonomy/__version__.py",
|
|
92
|
+
},
|
|
93
|
+
"open-aea-test-autonomy": {
|
|
94
|
+
"repo": OPEN_AUTONOMY_REPO,
|
|
95
|
+
"file": "plugins/aea-test-autonomy/setup.py",
|
|
96
|
+
},
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
_cache_file = Path.home() / ".aea" / ".gitcache"
|
|
100
|
+
_version_cache = {}
|
|
101
|
+
_logger = setup_logger("bump")
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def load_git_cache() -> None:
|
|
105
|
+
"""Load versions cache."""
|
|
106
|
+
if not _cache_file.exists():
|
|
107
|
+
return
|
|
108
|
+
with _cache_file.open("r", encoding="utf-8") as stream:
|
|
109
|
+
_version_cache.update(yaml_load(stream=stream))
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def dump_git_cache() -> None:
|
|
113
|
+
"""Dump versions cache."""
|
|
114
|
+
with _cache_file.open("w", encoding="utf-8") as stream:
|
|
115
|
+
yaml_dump(data=_version_cache, stream=stream)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def make_git_request(url: str) -> requests.Response:
|
|
119
|
+
"""Make git request"""
|
|
120
|
+
auth = os.environ.get("GITHUB_AUTH")
|
|
121
|
+
if auth is None:
|
|
122
|
+
return requests.get(url=url)
|
|
123
|
+
return requests.get(url=url, headers={"Authorization": f"Bearer {auth}"})
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def get_latest_tag(repo: str) -> str:
|
|
127
|
+
"""Fetch latest git tag."""
|
|
128
|
+
if repo in _version_cache:
|
|
129
|
+
return _version_cache[repo]
|
|
130
|
+
|
|
131
|
+
response = make_git_request(url=TAGS_URL.format(repo=repo))
|
|
132
|
+
if response.status_code != 200:
|
|
133
|
+
raise ValueError(
|
|
134
|
+
f"Fetching tags from `{repo}` failed with message '"
|
|
135
|
+
+ response.json()["message"]
|
|
136
|
+
+ "'"
|
|
137
|
+
)
|
|
138
|
+
latest_tag_data, *_ = response.json()
|
|
139
|
+
_version_cache[repo] = latest_tag_data["name"]
|
|
140
|
+
return _version_cache[repo]
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def get_dependency_version(repo: str, file: str) -> str:
|
|
144
|
+
"""Get version spec ."""
|
|
145
|
+
response = make_git_request(
|
|
146
|
+
FILE_URL.format(
|
|
147
|
+
repo=repo,
|
|
148
|
+
tag=get_latest_tag(repo=repo),
|
|
149
|
+
file=file,
|
|
150
|
+
)
|
|
151
|
+
)
|
|
152
|
+
if response.status_code != 200:
|
|
153
|
+
raise ValueError(
|
|
154
|
+
f"Fetching packages from `{repo}` failed with message '"
|
|
155
|
+
+ response.text
|
|
156
|
+
+ "'"
|
|
157
|
+
)
|
|
158
|
+
((*_, version),) = VERISON_RE.findall(response.content.decode())
|
|
159
|
+
return f"=={version}"
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def get_dependencies() -> t.Dict:
|
|
163
|
+
"""Get dependency->version mapping."""
|
|
164
|
+
dependencies = {}
|
|
165
|
+
for dependency, specs in DEPENDENCY_SPECS.items():
|
|
166
|
+
version = _version_cache.get(
|
|
167
|
+
dependency,
|
|
168
|
+
get_dependency_version(
|
|
169
|
+
repo=specs["repo"],
|
|
170
|
+
file=specs["file"],
|
|
171
|
+
),
|
|
172
|
+
)
|
|
173
|
+
dependencies[dependency] = version
|
|
174
|
+
_version_cache.update(dependencies)
|
|
175
|
+
return dependencies
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def bump_pipfile_or_pyproject(file: Path, dependencies: t.Dict[str, str]) -> None:
|
|
179
|
+
"""Bump Pipfile."""
|
|
180
|
+
if not file.exists():
|
|
181
|
+
return
|
|
182
|
+
|
|
183
|
+
_logger.info(f"Updating {file.name}")
|
|
184
|
+
updated = ""
|
|
185
|
+
content = file.read_text(encoding="utf-8")
|
|
186
|
+
for line in content.split("\n"):
|
|
187
|
+
try:
|
|
188
|
+
spec = Dependency.from_pipfile_string(line)
|
|
189
|
+
update = dependencies.get(spec.name)
|
|
190
|
+
if update is None:
|
|
191
|
+
updated += line + "\n"
|
|
192
|
+
continue
|
|
193
|
+
spec = Dependency(
|
|
194
|
+
name=spec.name,
|
|
195
|
+
version=update,
|
|
196
|
+
extras=spec.extras,
|
|
197
|
+
)
|
|
198
|
+
updated += spec.to_pipfile_string() + "\n"
|
|
199
|
+
except ValueError:
|
|
200
|
+
updated += line + "\n"
|
|
201
|
+
file.write_text(updated[:-1], encoding="utf-8")
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
def bump_tox(dependencies: t.Dict[str, str]) -> None:
|
|
205
|
+
"""Bump tox file."""
|
|
206
|
+
if not TOX_INI.exists():
|
|
207
|
+
return
|
|
208
|
+
|
|
209
|
+
_logger.info("Updating tox.ini")
|
|
210
|
+
updated = ""
|
|
211
|
+
content = TOX_INI.read_text(encoding="utf-8")
|
|
212
|
+
for line in content.split("\n"):
|
|
213
|
+
try:
|
|
214
|
+
spec = Dependency.from_string(line.lstrip().rstrip())
|
|
215
|
+
update = dependencies.get(spec.name)
|
|
216
|
+
if update is None:
|
|
217
|
+
updated += line + "\n"
|
|
218
|
+
continue
|
|
219
|
+
spec = Dependency(
|
|
220
|
+
name=spec.name,
|
|
221
|
+
version=update,
|
|
222
|
+
extras=spec.extras,
|
|
223
|
+
)
|
|
224
|
+
updated += " " + spec.to_pip_string() + "\n"
|
|
225
|
+
except ValueError:
|
|
226
|
+
updated += line + "\n"
|
|
227
|
+
TOX_INI.write_text(updated[:-1], encoding="utf-8")
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def bump_packages(dependencies: t.Dict[str, str]) -> None:
|
|
231
|
+
"""Bump packages."""
|
|
232
|
+
_logger.info("Updating packages")
|
|
233
|
+
manager = PackageManagerV1.from_dir(Path(PACKAGES))
|
|
234
|
+
for package_id in manager.dev_packages:
|
|
235
|
+
path = (
|
|
236
|
+
manager.package_path_from_package_id(
|
|
237
|
+
package_id=package_id,
|
|
238
|
+
)
|
|
239
|
+
/ PACKAGE_TYPE_TO_CONFIG_FILE[package_id.package_type.value]
|
|
240
|
+
)
|
|
241
|
+
with path.open("r", encoding="utf-8") as stream:
|
|
242
|
+
config, *extra = yaml_load_all(stream=stream)
|
|
243
|
+
|
|
244
|
+
for name in config.get("dependencies", {}):
|
|
245
|
+
update = dependencies.get(name)
|
|
246
|
+
if update is None:
|
|
247
|
+
continue
|
|
248
|
+
config["dependencies"][name]["version"] = update
|
|
249
|
+
|
|
250
|
+
with path.open("w", encoding="utf-8") as stream:
|
|
251
|
+
yaml_dump_all([config, *extra], stream=stream)
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
@click.command(name="bump")
|
|
255
|
+
@click.option(
|
|
256
|
+
"-d",
|
|
257
|
+
"--dependency",
|
|
258
|
+
"extra",
|
|
259
|
+
type=PyPiDependency(),
|
|
260
|
+
multiple=True,
|
|
261
|
+
help="Specify extra dependency.",
|
|
262
|
+
)
|
|
263
|
+
@click.option(
|
|
264
|
+
"-s",
|
|
265
|
+
"--source",
|
|
266
|
+
"sources",
|
|
267
|
+
type=PackagesSource(),
|
|
268
|
+
multiple=True,
|
|
269
|
+
help="Specify extra sources.",
|
|
270
|
+
)
|
|
271
|
+
@click.option("--sync", is_flag=True, help="Perform sync.")
|
|
272
|
+
@click.option(
|
|
273
|
+
"--no-cache",
|
|
274
|
+
is_flag=True,
|
|
275
|
+
default=False,
|
|
276
|
+
help="Avoid using cache to bump.",
|
|
277
|
+
)
|
|
278
|
+
def main(
|
|
279
|
+
extra: t.Tuple[Dependency, ...],
|
|
280
|
+
sources: t.Tuple[str, ...],
|
|
281
|
+
sync: bool,
|
|
282
|
+
no_cache: bool,
|
|
283
|
+
) -> None:
|
|
284
|
+
"""Run the bump script."""
|
|
285
|
+
|
|
286
|
+
if not no_cache:
|
|
287
|
+
load_git_cache()
|
|
288
|
+
|
|
289
|
+
dependencies = {}
|
|
290
|
+
dependencies.update(get_dependencies())
|
|
291
|
+
dependencies.update({dep.name: dep.version for dep in extra or []})
|
|
292
|
+
|
|
293
|
+
bump_pipfile_or_pyproject(PIPFILE, dependencies=dependencies)
|
|
294
|
+
bump_pipfile_or_pyproject(PYPROJECT_TOML, dependencies=dependencies)
|
|
295
|
+
bump_tox(dependencies=dependencies)
|
|
296
|
+
bump_packages(dependencies=dependencies)
|
|
297
|
+
dump_git_cache()
|
|
298
|
+
|
|
299
|
+
if sync:
|
|
300
|
+
pm = PackageManagerV1.from_dir(
|
|
301
|
+
Path.cwd() / PACKAGES, config_loader=load_configuration
|
|
302
|
+
)
|
|
303
|
+
pm.sync(
|
|
304
|
+
sources=[
|
|
305
|
+
f"{OPEN_AEA_REPO}:{_version_cache[OPEN_AEA_REPO]}",
|
|
306
|
+
f"{OPEN_AUTONOMY_REPO}:{_version_cache[OPEN_AUTONOMY_REPO]}",
|
|
307
|
+
*sources,
|
|
308
|
+
],
|
|
309
|
+
update_packages=True,
|
|
310
|
+
)
|
|
311
|
+
pm.update_package_hashes()
|
|
312
|
+
pm.dump()
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
if __name__ == "__main__":
|
|
316
|
+
main() # pylint: disable=no-value-for-parameter
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# ------------------------------------------------------------------------------
|
|
3
|
+
#
|
|
4
|
+
# Copyright 2025 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
|
+
|
|
21
|
+
import sys
|
|
22
|
+
from pathlib import Path
|
|
23
|
+
from typing import Optional
|
|
24
|
+
from aea_ledger_ethereum import EthereumApi, EthereumCrypto
|
|
25
|
+
from dataclasses import asdict
|
|
26
|
+
|
|
27
|
+
from mech_client.interact import get_mech_config, PRIVATE_KEY_FILE_PATH
|
|
28
|
+
from .utils import (
|
|
29
|
+
print_title,
|
|
30
|
+
CHAIN_TO_NATIVE_BALANCE_TRACKER,
|
|
31
|
+
)
|
|
32
|
+
from mech_client.wss import wait_for_receipt
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def deposit(
|
|
36
|
+
ledger_api: EthereumApi,
|
|
37
|
+
crypto: EthereumCrypto,
|
|
38
|
+
to: str,
|
|
39
|
+
amount: int,
|
|
40
|
+
) -> str:
|
|
41
|
+
sender = crypto.address
|
|
42
|
+
|
|
43
|
+
try:
|
|
44
|
+
print("Fetching user balance")
|
|
45
|
+
user_balance = ledger_api.get_balance(address=sender)
|
|
46
|
+
if user_balance < amount:
|
|
47
|
+
formatted_user_balance = user_balance / 1e18
|
|
48
|
+
formatted_amount = amount / 1e18
|
|
49
|
+
print("User balance low!!")
|
|
50
|
+
print(f"Balance: {formatted_user_balance}")
|
|
51
|
+
print(f"Want to Deposit: {formatted_amount}")
|
|
52
|
+
sys.exit(1)
|
|
53
|
+
except Exception as e:
|
|
54
|
+
print(f"Error occured while fetching user balance: {e}")
|
|
55
|
+
return str(e)
|
|
56
|
+
|
|
57
|
+
try:
|
|
58
|
+
print("Sending deposit tx")
|
|
59
|
+
raw_transaction = ledger_api.get_transfer_transaction(
|
|
60
|
+
sender_address=sender,
|
|
61
|
+
destination_address=to,
|
|
62
|
+
amount=amount,
|
|
63
|
+
tx_fee=50000,
|
|
64
|
+
tx_nonce="0x",
|
|
65
|
+
)
|
|
66
|
+
signed_transaction = crypto.sign_transaction(raw_transaction)
|
|
67
|
+
transaction_digest = ledger_api.send_signed_transaction(
|
|
68
|
+
signed_transaction,
|
|
69
|
+
raise_on_try=True,
|
|
70
|
+
)
|
|
71
|
+
return transaction_digest
|
|
72
|
+
except Exception as e: # pylint: disable=broad-except
|
|
73
|
+
print(f"Error occured while sending the transaction: {e}")
|
|
74
|
+
return str(e)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def main(
|
|
78
|
+
amount: str,
|
|
79
|
+
private_key_path: Optional[str] = None,
|
|
80
|
+
chain_config: Optional[str] = None,
|
|
81
|
+
) -> None:
|
|
82
|
+
"""Runs the deposit functionality for the native mech type"""
|
|
83
|
+
print_title("Native Deposit")
|
|
84
|
+
print("This script will assist you in depositing native balance for mech requests.")
|
|
85
|
+
print()
|
|
86
|
+
|
|
87
|
+
amount_to_deposit = int(float(amount) * 10**18)
|
|
88
|
+
private_key_path = private_key_path or PRIVATE_KEY_FILE_PATH
|
|
89
|
+
|
|
90
|
+
mech_config = get_mech_config(chain_config)
|
|
91
|
+
ledger_config = mech_config.ledger_config
|
|
92
|
+
ledger_api = EthereumApi(**asdict(ledger_config))
|
|
93
|
+
|
|
94
|
+
if not Path(private_key_path).exists():
|
|
95
|
+
raise FileNotFoundError(
|
|
96
|
+
f"Private key file `{private_key_path}` does not exist!"
|
|
97
|
+
)
|
|
98
|
+
crypto = EthereumCrypto(private_key_path=private_key_path)
|
|
99
|
+
|
|
100
|
+
print(f"Sender address: {crypto.address}")
|
|
101
|
+
|
|
102
|
+
chain_id = mech_config.ledger_config.chain_id
|
|
103
|
+
to = CHAIN_TO_NATIVE_BALANCE_TRACKER[chain_id]
|
|
104
|
+
|
|
105
|
+
deposit_tx = deposit(ledger_api, crypto, to, amount_to_deposit)
|
|
106
|
+
if not deposit_tx:
|
|
107
|
+
print("Unable to deposit")
|
|
108
|
+
sys.exit(1)
|
|
109
|
+
|
|
110
|
+
transaction_url_formatted = mech_config.transaction_url.format(
|
|
111
|
+
transaction_digest=deposit_tx
|
|
112
|
+
)
|
|
113
|
+
print(f" - Transaction sent: {transaction_url_formatted}")
|
|
114
|
+
print(" - Waiting for transaction receipt...")
|
|
115
|
+
wait_for_receipt(deposit_tx, ledger_api)
|
|
116
|
+
|
|
117
|
+
print("")
|
|
118
|
+
print("Deposit Successful")
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# ------------------------------------------------------------------------------
|
|
3
|
+
#
|
|
4
|
+
# Copyright 2025 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
|
+
|
|
21
|
+
import sys
|
|
22
|
+
from pathlib import Path
|
|
23
|
+
from typing import Optional
|
|
24
|
+
from aea_ledger_ethereum import EthereumApi, EthereumCrypto
|
|
25
|
+
from dataclasses import asdict
|
|
26
|
+
from web3.contract import Contract as Web3Contract
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
from mech_client.interact import (
|
|
30
|
+
get_mech_config,
|
|
31
|
+
PRIVATE_KEY_FILE_PATH,
|
|
32
|
+
)
|
|
33
|
+
from .utils import (
|
|
34
|
+
print_title,
|
|
35
|
+
get_token_contract,
|
|
36
|
+
get_token_balance_tracker_contract,
|
|
37
|
+
)
|
|
38
|
+
from mech_client.wss import wait_for_receipt
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def check_token_balance(token_contract: Web3Contract, sender: str, amount: int) -> None:
|
|
42
|
+
try:
|
|
43
|
+
print("Fetching user balance")
|
|
44
|
+
user_token_balance = token_contract.functions.balanceOf(sender).call()
|
|
45
|
+
if user_token_balance < amount:
|
|
46
|
+
formatted_user_balance = user_token_balance / 1e18
|
|
47
|
+
formatted_amount = amount / 1e18
|
|
48
|
+
print("User balance low!!")
|
|
49
|
+
print(f"Balance: {formatted_user_balance}")
|
|
50
|
+
print(f"Want to Deposit: {formatted_amount}")
|
|
51
|
+
sys.exit(1)
|
|
52
|
+
except Exception as e:
|
|
53
|
+
print(f"Error occured while fetching user balance: {e}")
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def approve(
|
|
57
|
+
crypto: EthereumCrypto,
|
|
58
|
+
ledger_api: EthereumApi,
|
|
59
|
+
token_contract: Web3Contract,
|
|
60
|
+
token_balance_tracker_contract: Web3Contract,
|
|
61
|
+
amount: int,
|
|
62
|
+
) -> str:
|
|
63
|
+
sender = crypto.address
|
|
64
|
+
|
|
65
|
+
print("Sending approve tx")
|
|
66
|
+
try:
|
|
67
|
+
tx_args = {"sender_address": sender, "value": 0, "gas": 60000}
|
|
68
|
+
raw_transaction = ledger_api.build_transaction(
|
|
69
|
+
contract_instance=token_contract,
|
|
70
|
+
method_name="approve",
|
|
71
|
+
method_args={
|
|
72
|
+
"_to": token_balance_tracker_contract.address,
|
|
73
|
+
"_value": amount,
|
|
74
|
+
},
|
|
75
|
+
tx_args=tx_args,
|
|
76
|
+
raise_on_try=True,
|
|
77
|
+
)
|
|
78
|
+
signed_transaction = crypto.sign_transaction(raw_transaction)
|
|
79
|
+
transaction_digest = ledger_api.send_signed_transaction(
|
|
80
|
+
signed_transaction,
|
|
81
|
+
raise_on_try=True,
|
|
82
|
+
)
|
|
83
|
+
return transaction_digest
|
|
84
|
+
except Exception as e: # pylint: disable=broad-except
|
|
85
|
+
print(f"Error occured while sending the transaction: {e}")
|
|
86
|
+
return str(e)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def deposit(
|
|
90
|
+
ledger_api: EthereumApi,
|
|
91
|
+
crypto: EthereumCrypto,
|
|
92
|
+
token_balance_tracker_contract: Web3Contract,
|
|
93
|
+
amount: int,
|
|
94
|
+
) -> str:
|
|
95
|
+
sender = crypto.address
|
|
96
|
+
|
|
97
|
+
print("Sending deposit tx")
|
|
98
|
+
try:
|
|
99
|
+
tx_args = {"sender_address": sender, "value": 0, "gas": 100000}
|
|
100
|
+
raw_transaction = ledger_api.build_transaction(
|
|
101
|
+
contract_instance=token_balance_tracker_contract,
|
|
102
|
+
method_name="deposit",
|
|
103
|
+
method_args={"amount": amount},
|
|
104
|
+
tx_args=tx_args,
|
|
105
|
+
raise_on_try=True,
|
|
106
|
+
)
|
|
107
|
+
signed_transaction = crypto.sign_transaction(raw_transaction)
|
|
108
|
+
transaction_digest = ledger_api.send_signed_transaction(
|
|
109
|
+
signed_transaction,
|
|
110
|
+
raise_on_try=True,
|
|
111
|
+
)
|
|
112
|
+
return transaction_digest
|
|
113
|
+
except Exception as e: # pylint: disable=broad-except
|
|
114
|
+
print(f"Error occured while sending the transaction: {e}")
|
|
115
|
+
return str(e)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def main(
|
|
119
|
+
amount: str,
|
|
120
|
+
private_key_path: Optional[str] = None,
|
|
121
|
+
chain_config: Optional[str] = None,
|
|
122
|
+
) -> None:
|
|
123
|
+
"""Runs the deposit functionality for the token mech type"""
|
|
124
|
+
print_title("Token Deposit")
|
|
125
|
+
print("This script will assist you in depositing token balance for mech requests.")
|
|
126
|
+
print()
|
|
127
|
+
|
|
128
|
+
amount_to_deposit = int(float(amount) * 10**18)
|
|
129
|
+
private_key_path = private_key_path or PRIVATE_KEY_FILE_PATH
|
|
130
|
+
|
|
131
|
+
mech_config = get_mech_config(chain_config)
|
|
132
|
+
ledger_config = mech_config.ledger_config
|
|
133
|
+
ledger_api = EthereumApi(**asdict(ledger_config))
|
|
134
|
+
|
|
135
|
+
if not Path(private_key_path).exists():
|
|
136
|
+
raise FileNotFoundError(
|
|
137
|
+
f"Private key file `{private_key_path}` does not exist!"
|
|
138
|
+
)
|
|
139
|
+
crypto = EthereumCrypto(private_key_path=private_key_path)
|
|
140
|
+
|
|
141
|
+
print(f"Sender address: {crypto.address}")
|
|
142
|
+
|
|
143
|
+
chain_id = mech_config.ledger_config.chain_id
|
|
144
|
+
token_balance_tracker_contract = get_token_balance_tracker_contract(
|
|
145
|
+
ledger_api, chain_id
|
|
146
|
+
)
|
|
147
|
+
token_contract = get_token_contract(ledger_api, chain_id)
|
|
148
|
+
|
|
149
|
+
check_token_balance(token_contract, crypto.address, amount_to_deposit)
|
|
150
|
+
|
|
151
|
+
approve_tx = approve(
|
|
152
|
+
crypto,
|
|
153
|
+
ledger_api,
|
|
154
|
+
token_contract,
|
|
155
|
+
token_balance_tracker_contract,
|
|
156
|
+
amount_to_deposit,
|
|
157
|
+
)
|
|
158
|
+
if not approve_tx:
|
|
159
|
+
print("Unable to approve")
|
|
160
|
+
sys.exit(1)
|
|
161
|
+
|
|
162
|
+
transaction_url_formatted = mech_config.transaction_url.format(
|
|
163
|
+
transaction_digest=approve_tx
|
|
164
|
+
)
|
|
165
|
+
print(f" - Transaction sent: {transaction_url_formatted}")
|
|
166
|
+
print(" - Waiting for transaction receipt...")
|
|
167
|
+
wait_for_receipt(approve_tx, ledger_api)
|
|
168
|
+
|
|
169
|
+
deposit_tx = deposit(
|
|
170
|
+
ledger_api,
|
|
171
|
+
crypto,
|
|
172
|
+
token_balance_tracker_contract,
|
|
173
|
+
amount_to_deposit,
|
|
174
|
+
)
|
|
175
|
+
if not deposit_tx:
|
|
176
|
+
print("Unable to deposit")
|
|
177
|
+
sys.exit(1)
|
|
178
|
+
|
|
179
|
+
transaction_url_formatted = mech_config.transaction_url.format(
|
|
180
|
+
transaction_digest=deposit_tx
|
|
181
|
+
)
|
|
182
|
+
print(f" - Transaction sent: {transaction_url_formatted}")
|
|
183
|
+
print(" - Waiting for transaction receipt...")
|
|
184
|
+
wait_for_receipt(deposit_tx, ledger_api)
|
|
185
|
+
|
|
186
|
+
print("")
|
|
187
|
+
print("Deposit Successful")
|