mech-client 0.9.0__tar.gz → 0.11.0__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.9.0 → mech_client-0.11.0}/PKG-INFO +40 -13
- {mech_client-0.9.0 → mech_client-0.11.0}/README.md +39 -12
- mech_client-0.11.0/mech_client/__init__.py +3 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/abis/MechMarketplace.json +14 -2
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/cli.py +51 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/configs/mechs.json +2 -2
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/marketplace_interact.py +58 -6
- mech_client-0.11.0/mech_client/mech_marketplace_subgraph.py +94 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/mech_marketplace_tool_management.py +3 -2
- {mech_client-0.9.0 → mech_client-0.11.0}/pyproject.toml +1 -1
- mech_client-0.9.0/mech_client/__init__.py +0 -3
- {mech_client-0.9.0 → mech_client-0.11.0}/LICENSE +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/abis/AgentMech.json +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/abis/AgentRegistry.json +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/abis/AgreementStoreManager.base.json +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/abis/AgreementStoreManager.gnosis.json +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/abis/BalanceTrackerFixedPriceNative.json +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/abis/BalanceTrackerFixedPriceToken.json +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/abis/BalanceTrackerNvmSubscriptionNative.json +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/abis/BalanceTrackerNvmSubscriptionToken.json +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/abis/ComplementaryServiceMetadata.json +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/abis/DIDRegistry.base.json +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/abis/DIDRegistry.gnosis.json +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/abis/EscrowPaymentCondition.base.json +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/abis/EscrowPaymentCondition.gnosis.json +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/abis/IERC1155.json +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/abis/IMech.json +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/abis/IToken.json +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/abis/LockPaymentCondition.base.json +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/abis/LockPaymentCondition.gnosis.json +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/abis/NFTSalesTemplate.base.json +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/abis/NFTSalesTemplate.gnosis.json +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/abis/NeverminedConfig.base.json +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/abis/NeverminedConfig.gnosis.json +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/abis/SubscriptionNFT.base.json +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/abis/SubscriptionNFT.gnosis.json +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/abis/SubscriptionProvider.base.json +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/abis/SubscriptionProvider.gnosis.json +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/abis/SubscriptionToken.base.json +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/abis/TransferNFTCondition.base.json +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/abis/TransferNFTCondition.gnosis.json +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/acn.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/fetch_ipfs_hash.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/helpers/__init__.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/helpers/acn/README.md +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/helpers/acn/__init__.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/helpers/acn/acn.proto +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/helpers/acn/acn_pb2.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/helpers/acn/custom_types.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/helpers/acn/dialogues.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/helpers/acn/message.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/helpers/acn/protocol.yaml +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/helpers/acn/serialization.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/helpers/acn/tests/__init__.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/helpers/acn/tests/test_acn.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/helpers/acn/tests/test_acn_dialogues.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/helpers/acn/tests/test_acn_messages.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/helpers/acn_data_share/README.md +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/helpers/acn_data_share/__init__.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/helpers/acn_data_share/acn_data_share.proto +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/helpers/acn_data_share/acn_data_share_pb2.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/helpers/acn_data_share/dialogues.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/helpers/acn_data_share/message.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/helpers/acn_data_share/protocol.yaml +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/helpers/acn_data_share/serialization.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/helpers/acn_data_share/tests/test_acn_data_share_dialogues.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/helpers/acn_data_share/tests/test_acn_data_share_messages.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/helpers/p2p_libp2p_client/README.md +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/helpers/p2p_libp2p_client/__init__.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/helpers/p2p_libp2p_client/connection.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/helpers/p2p_libp2p_client/connection.yaml +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/interact.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/mech_tool_management.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/prompt_to_ipfs.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/push_to_ipfs.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/subgraph.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/to_png.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/mech_client/wss.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/scripts/__init__.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/scripts/benchmark.sh +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/scripts/bump.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/scripts/deposit_native.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/scripts/deposit_token.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/scripts/nvm_subscribe.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/scripts/nvm_subscription/contracts/agreement_manager.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/scripts/nvm_subscription/contracts/base_contract.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/scripts/nvm_subscription/contracts/did_registry.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/scripts/nvm_subscription/contracts/escrow_payment.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/scripts/nvm_subscription/contracts/lock_payment.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/scripts/nvm_subscription/contracts/nft.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/scripts/nvm_subscription/contracts/nft_sales.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/scripts/nvm_subscription/contracts/subscription_provider.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/scripts/nvm_subscription/contracts/token.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/scripts/nvm_subscription/contracts/transfer_nft.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/scripts/nvm_subscription/envs/base.env +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/scripts/nvm_subscription/envs/gnosis.env +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/scripts/nvm_subscription/manager.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/scripts/nvm_subscription/resources/networks.json +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/scripts/utils.py +0 -0
- {mech_client-0.9.0 → mech_client-0.11.0}/scripts/whitelist.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: mech-client
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.11.0
|
|
4
4
|
Summary: Basic client to interact with a mech
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
Author: David Minarsch
|
|
@@ -32,6 +32,12 @@ A basic client to interact with an AI Mech. [AI Mechs](https://github.com/valory
|
|
|
32
32
|
|
|
33
33
|
- Python >=3.10
|
|
34
34
|
|
|
35
|
+
## Developing, running and deploying Mechs and Mech tools
|
|
36
|
+
|
|
37
|
+
The easiest way to create, run, deploy and test your own Mech and Mech tools is to follow the Mech and Mech tool docs [here](https://open-autonomy.docs.autonolas.tech/mech-tools-dev/). The [Mech tools dev repo](https://github.com/valory-xyz/mech-tools-dev) used in those docs greatly simplifies the development flow and dev experience.
|
|
38
|
+
|
|
39
|
+
Only continue reading this README if you know what you are doing and you are specifically interested in this repo.
|
|
40
|
+
|
|
35
41
|
## Installation
|
|
36
42
|
|
|
37
43
|
Find the latest available release on [PyPi](https://pypi.org/project/mech-client/#description).
|
|
@@ -120,9 +126,9 @@ The EOA you use must have enough funds to pay for the Mech requests, or alternat
|
|
|
120
126
|
|
|
121
127
|
In order to fetch on-chain data for Gnosis and Base, mech client requires an API key from a blockchain data provider. You can find them here for [GnosisScan](https://gnosisscan.io/) and [BaseScan](https://basescan.org/). Follow these steps to generate your API key if you are planning to use mech client for gnosis and base:
|
|
122
128
|
|
|
123
|
-
1. Sign up or log in
|
|
129
|
+
1. Sign up or log in
|
|
124
130
|
2. Go to API Dashboard on the left menu
|
|
125
|
-
3. Add a new API key
|
|
131
|
+
3. Add a new API key
|
|
126
132
|
4. Once generated copy your API key
|
|
127
133
|
|
|
128
134
|
Once you have your API key, you'll need to configure it in your environment. Use the following command to set it for your environment.
|
|
@@ -135,7 +141,7 @@ export MECHX_API_KEY=<your api key>
|
|
|
135
141
|
|
|
136
142
|
#### Select the mech you are going to send requests to
|
|
137
143
|
|
|
138
|
-
Mechs can receive requests via the [Mech Marketplace](https://github.com/valory-xyz/ai-registry-mech/) or directly. We call the last ones _Legacy Mechs_.
|
|
144
|
+
Mechs can receive requests via the [Mech Marketplace](https://github.com/valory-xyz/ai-registry-mech/) or directly. We call the last ones _Legacy Mechs_.
|
|
139
145
|
Mechs are deployed on several networks. Find the list of supported networks and corresponding mech addresses [here](https://github.com/valory-xyz/mech?tab=readme-ov-file#examples-of-deployed-mechs). Additionally, you can find more available Mechs [here](https://mech.olas.network/) (click on the tab "Legacy Mech" in order to see Legacy Mech (available only on Gnosis) and "Mech Marketplace" for the ones which receive requests via the Mech Marketplace).
|
|
140
146
|
|
|
141
147
|
#### Legacy Mechs
|
|
@@ -201,22 +207,22 @@ Data from agent: {'requestId': 1004074058566339663950817114309409628095686850319
|
|
|
201
207
|
|
|
202
208
|
#### With the Mech Marketplace
|
|
203
209
|
|
|
204
|
-
With the Mech Marketplace, in order to pay for the Mech fees, you can make a deposit before sending requests. The deposit depends on the
|
|
205
|
-
payment model of the Mech. For a fixed price Mech receiving payments in native token, use the following:
|
|
210
|
+
With the Mech Marketplace, in order to pay for the Mech fees, you can make a deposit before sending requests. The deposit depends on the
|
|
211
|
+
payment model of the Mech. For a fixed price Mech receiving payments in native token, use the following:
|
|
206
212
|
|
|
207
213
|
```bash
|
|
208
214
|
mechx deposit-native --chain-config <chain_config> <amount>
|
|
209
215
|
```
|
|
210
216
|
|
|
211
|
-
For a fixed price Mech receiving payments in OLAS, use the following (the amount is in ether):
|
|
217
|
+
For a fixed price Mech receiving payments in OLAS, use the following (the amount is in ether):
|
|
212
218
|
|
|
213
219
|
```bash
|
|
214
220
|
mechx deposit-token --chain-config <chain_config> <amount>
|
|
215
221
|
```
|
|
216
222
|
|
|
217
|
-
For a Mech using Nevermined subscriptions, to make requests, it is necessary to buy a subscription. To do that you can use the following command:
|
|
223
|
+
For a Mech using Nevermined subscriptions, to make requests, it is necessary to buy a subscription. To do that you can use the following command:
|
|
218
224
|
|
|
219
|
-
```bash
|
|
225
|
+
```bash
|
|
220
226
|
mechx purchase-nvm-subscription --chain-config <chain_config>
|
|
221
227
|
```
|
|
222
228
|
|
|
@@ -244,11 +250,11 @@ export MECHX_MECH_OFFCHAIN_URL="http://localhost:8000/"
|
|
|
244
250
|
If you want to use a Valory mech for offchain requests, below is the list of mechs and their address and offchain urls.
|
|
245
251
|
|
|
246
252
|
| Service ID | Priority Mech Address | Offchain URL |
|
|
247
|
-
| :---: | :---: | :---: |
|
|
253
|
+
| :---: | :---: | :---: |
|
|
248
254
|
| 2182 | 0xB3C6319962484602b00d5587e965946890b82101 | https://d19715222af5b940.agent.propel.autonolas.tech/ |
|
|
249
255
|
|
|
250
256
|
|
|
251
|
-
The Mech Client can also be used to send batch requests. There are couple of different ways to achieve this:
|
|
257
|
+
The Mech Client can also be used to send batch requests. There are couple of different ways to achieve this:
|
|
252
258
|
|
|
253
259
|
```bash
|
|
254
260
|
mechx interact --prompts={<prompt-1>,<prompt-2>} --priority-mech <priority mech address> --tools={<tool-1>,<tool-2>} --chain-config <chain_config>
|
|
@@ -260,6 +266,27 @@ or <br>
|
|
|
260
266
|
mechx interact --prompts <prompt-1> --prompts <prompt-2> --priority-mech <priority mech address> --tools <tool-1> --tools <tool-2> --chain-config <chain_config>
|
|
261
267
|
```
|
|
262
268
|
|
|
269
|
+
### List marketplace mechs
|
|
270
|
+
To list the top marketplace mechs based on deliveries, use the `fetch-mm-mechs-info` command. You can specify the chain you want to query. Please note that only the first 20 mechs sorted by number of deliveries will be shown.
|
|
271
|
+
Currently supported chains are gnosis and base
|
|
272
|
+
```bash
|
|
273
|
+
mechx fetch-mm-mechs-info --chain-config gnosis
|
|
274
|
+
```
|
|
275
|
+
```bash
|
|
276
|
+
+--------------+--------------------+--------------------------------------------+--------------------+---------------------------------------------------------------------------------------------------------------+
|
|
277
|
+
| Service Id | Mech Type | Mech Address | Total Deliveries | Metadata Link |
|
|
278
|
+
+==============+====================+============================================+====================+===============================================================================================================+
|
|
279
|
+
| 2182 | Fixed Price Native | 0xc05e7412439bd7e91730a6880e18d5d5873f632c | 41246 | https://gateway.autonolas.tech/ipfs/f01701220157d3b106831e2713b86af1b52af76a3ef28c52ae0853e9638180902ebee41d4 |
|
|
280
|
+
+--------------+--------------------+--------------------------------------------+--------------------+---------------------------------------------------------------------------------------------------------------+
|
|
281
|
+
| 2235 | Fixed Price Native | 0xb3c6319962484602b00d5587e965946890b82101 | 10127 | https://gateway.autonolas.tech/ipfs/f01701220157d3b106831e2713b86af1b52af76a3ef28c52ae0853e9638180902ebee41d4 |
|
|
282
|
+
+--------------+--------------------+--------------------------------------------+--------------------+---------------------------------------------------------------------------------------------------------------+
|
|
283
|
+
| 2198 | Fixed Price Native | 0x601024e27f1c67b28209e24272ced8a31fc8151f | 5714 | https://gateway.autonolas.tech/ipfs/f01701220157d3b106831e2713b86af1b52af76a3ef28c52ae0853e9638180902ebee41d4 |
|
|
284
|
+
+--------------+--------------------+--------------------------------------------+--------------------+---------------------------------------------------------------------------------------------------------------+
|
|
285
|
+
| 1722 | Fixed Price Token | 0x13f36b1a516290b7563b1de574a02ebeb48926a1 | 399 | https://gateway.autonolas.tech/ipfs/f01701220157d3b106831e2713b86af1b52af76a3ef28c52ae0853e9638180902ebee41d4 |
|
|
286
|
+
+--------------+--------------------+--------------------------------------------+--------------------+---------------------------------------------------------------------------------------------------------------+
|
|
287
|
+
| 2135 | Fixed Price Native | 0xbead38e4c4777341bb3fd44e8cd4d1ba1a7ad9d7 | 353 | https://gateway.autonolas.tech/ipfs/f01701220157d3b106831e2713b86af1b52af76a3ef28c52ae0853e9638180902ebee41d4 |
|
|
288
|
+
+--------------+--------------------+--------------------------------------------+--------------------+---------------------------------------------------------------------------------------------------------------+
|
|
289
|
+
```
|
|
263
290
|
|
|
264
291
|
### List tools available for legacy mechs and marketplace mechs
|
|
265
292
|
|
|
@@ -287,7 +314,7 @@ You will see an output like this:
|
|
|
287
314
|
```bash
|
|
288
315
|
mechx tools-for-agents --agent-id "agent_id"
|
|
289
316
|
```
|
|
290
|
-
Eaxmple usage
|
|
317
|
+
Eaxmple usage
|
|
291
318
|
```bash
|
|
292
319
|
mechx tools-for-agents --agent-id 6
|
|
293
320
|
```
|
|
@@ -545,7 +572,7 @@ This script will:
|
|
|
545
572
|
|
|
546
573
|
#### For Mechs receiving requests via the Mech Marketplace
|
|
547
574
|
|
|
548
|
-
In this case, the script is the same, except for the function result. When this function has no argument agent_id,
|
|
575
|
+
In this case, the script is the same, except for the function result. When this function has no argument agent_id,
|
|
549
576
|
the request is sent to the Mech Marketplace. The target Mech to which the request is relayed should be in the chain_config file (key `priority_mech_address`).
|
|
550
577
|
|
|
551
578
|
## Developer installation
|
|
@@ -9,6 +9,12 @@ A basic client to interact with an AI Mech. [AI Mechs](https://github.com/valory
|
|
|
9
9
|
|
|
10
10
|
- Python >=3.10
|
|
11
11
|
|
|
12
|
+
## Developing, running and deploying Mechs and Mech tools
|
|
13
|
+
|
|
14
|
+
The easiest way to create, run, deploy and test your own Mech and Mech tools is to follow the Mech and Mech tool docs [here](https://open-autonomy.docs.autonolas.tech/mech-tools-dev/). The [Mech tools dev repo](https://github.com/valory-xyz/mech-tools-dev) used in those docs greatly simplifies the development flow and dev experience.
|
|
15
|
+
|
|
16
|
+
Only continue reading this README if you know what you are doing and you are specifically interested in this repo.
|
|
17
|
+
|
|
12
18
|
## Installation
|
|
13
19
|
|
|
14
20
|
Find the latest available release on [PyPi](https://pypi.org/project/mech-client/#description).
|
|
@@ -97,9 +103,9 @@ The EOA you use must have enough funds to pay for the Mech requests, or alternat
|
|
|
97
103
|
|
|
98
104
|
In order to fetch on-chain data for Gnosis and Base, mech client requires an API key from a blockchain data provider. You can find them here for [GnosisScan](https://gnosisscan.io/) and [BaseScan](https://basescan.org/). Follow these steps to generate your API key if you are planning to use mech client for gnosis and base:
|
|
99
105
|
|
|
100
|
-
1. Sign up or log in
|
|
106
|
+
1. Sign up or log in
|
|
101
107
|
2. Go to API Dashboard on the left menu
|
|
102
|
-
3. Add a new API key
|
|
108
|
+
3. Add a new API key
|
|
103
109
|
4. Once generated copy your API key
|
|
104
110
|
|
|
105
111
|
Once you have your API key, you'll need to configure it in your environment. Use the following command to set it for your environment.
|
|
@@ -112,7 +118,7 @@ export MECHX_API_KEY=<your api key>
|
|
|
112
118
|
|
|
113
119
|
#### Select the mech you are going to send requests to
|
|
114
120
|
|
|
115
|
-
Mechs can receive requests via the [Mech Marketplace](https://github.com/valory-xyz/ai-registry-mech/) or directly. We call the last ones _Legacy Mechs_.
|
|
121
|
+
Mechs can receive requests via the [Mech Marketplace](https://github.com/valory-xyz/ai-registry-mech/) or directly. We call the last ones _Legacy Mechs_.
|
|
116
122
|
Mechs are deployed on several networks. Find the list of supported networks and corresponding mech addresses [here](https://github.com/valory-xyz/mech?tab=readme-ov-file#examples-of-deployed-mechs). Additionally, you can find more available Mechs [here](https://mech.olas.network/) (click on the tab "Legacy Mech" in order to see Legacy Mech (available only on Gnosis) and "Mech Marketplace" for the ones which receive requests via the Mech Marketplace).
|
|
117
123
|
|
|
118
124
|
#### Legacy Mechs
|
|
@@ -178,22 +184,22 @@ Data from agent: {'requestId': 1004074058566339663950817114309409628095686850319
|
|
|
178
184
|
|
|
179
185
|
#### With the Mech Marketplace
|
|
180
186
|
|
|
181
|
-
With the Mech Marketplace, in order to pay for the Mech fees, you can make a deposit before sending requests. The deposit depends on the
|
|
182
|
-
payment model of the Mech. For a fixed price Mech receiving payments in native token, use the following:
|
|
187
|
+
With the Mech Marketplace, in order to pay for the Mech fees, you can make a deposit before sending requests. The deposit depends on the
|
|
188
|
+
payment model of the Mech. For a fixed price Mech receiving payments in native token, use the following:
|
|
183
189
|
|
|
184
190
|
```bash
|
|
185
191
|
mechx deposit-native --chain-config <chain_config> <amount>
|
|
186
192
|
```
|
|
187
193
|
|
|
188
|
-
For a fixed price Mech receiving payments in OLAS, use the following (the amount is in ether):
|
|
194
|
+
For a fixed price Mech receiving payments in OLAS, use the following (the amount is in ether):
|
|
189
195
|
|
|
190
196
|
```bash
|
|
191
197
|
mechx deposit-token --chain-config <chain_config> <amount>
|
|
192
198
|
```
|
|
193
199
|
|
|
194
|
-
For a Mech using Nevermined subscriptions, to make requests, it is necessary to buy a subscription. To do that you can use the following command:
|
|
200
|
+
For a Mech using Nevermined subscriptions, to make requests, it is necessary to buy a subscription. To do that you can use the following command:
|
|
195
201
|
|
|
196
|
-
```bash
|
|
202
|
+
```bash
|
|
197
203
|
mechx purchase-nvm-subscription --chain-config <chain_config>
|
|
198
204
|
```
|
|
199
205
|
|
|
@@ -221,11 +227,11 @@ export MECHX_MECH_OFFCHAIN_URL="http://localhost:8000/"
|
|
|
221
227
|
If you want to use a Valory mech for offchain requests, below is the list of mechs and their address and offchain urls.
|
|
222
228
|
|
|
223
229
|
| Service ID | Priority Mech Address | Offchain URL |
|
|
224
|
-
| :---: | :---: | :---: |
|
|
230
|
+
| :---: | :---: | :---: |
|
|
225
231
|
| 2182 | 0xB3C6319962484602b00d5587e965946890b82101 | https://d19715222af5b940.agent.propel.autonolas.tech/ |
|
|
226
232
|
|
|
227
233
|
|
|
228
|
-
The Mech Client can also be used to send batch requests. There are couple of different ways to achieve this:
|
|
234
|
+
The Mech Client can also be used to send batch requests. There are couple of different ways to achieve this:
|
|
229
235
|
|
|
230
236
|
```bash
|
|
231
237
|
mechx interact --prompts={<prompt-1>,<prompt-2>} --priority-mech <priority mech address> --tools={<tool-1>,<tool-2>} --chain-config <chain_config>
|
|
@@ -237,6 +243,27 @@ or <br>
|
|
|
237
243
|
mechx interact --prompts <prompt-1> --prompts <prompt-2> --priority-mech <priority mech address> --tools <tool-1> --tools <tool-2> --chain-config <chain_config>
|
|
238
244
|
```
|
|
239
245
|
|
|
246
|
+
### List marketplace mechs
|
|
247
|
+
To list the top marketplace mechs based on deliveries, use the `fetch-mm-mechs-info` command. You can specify the chain you want to query. Please note that only the first 20 mechs sorted by number of deliveries will be shown.
|
|
248
|
+
Currently supported chains are gnosis and base
|
|
249
|
+
```bash
|
|
250
|
+
mechx fetch-mm-mechs-info --chain-config gnosis
|
|
251
|
+
```
|
|
252
|
+
```bash
|
|
253
|
+
+--------------+--------------------+--------------------------------------------+--------------------+---------------------------------------------------------------------------------------------------------------+
|
|
254
|
+
| Service Id | Mech Type | Mech Address | Total Deliveries | Metadata Link |
|
|
255
|
+
+==============+====================+============================================+====================+===============================================================================================================+
|
|
256
|
+
| 2182 | Fixed Price Native | 0xc05e7412439bd7e91730a6880e18d5d5873f632c | 41246 | https://gateway.autonolas.tech/ipfs/f01701220157d3b106831e2713b86af1b52af76a3ef28c52ae0853e9638180902ebee41d4 |
|
|
257
|
+
+--------------+--------------------+--------------------------------------------+--------------------+---------------------------------------------------------------------------------------------------------------+
|
|
258
|
+
| 2235 | Fixed Price Native | 0xb3c6319962484602b00d5587e965946890b82101 | 10127 | https://gateway.autonolas.tech/ipfs/f01701220157d3b106831e2713b86af1b52af76a3ef28c52ae0853e9638180902ebee41d4 |
|
|
259
|
+
+--------------+--------------------+--------------------------------------------+--------------------+---------------------------------------------------------------------------------------------------------------+
|
|
260
|
+
| 2198 | Fixed Price Native | 0x601024e27f1c67b28209e24272ced8a31fc8151f | 5714 | https://gateway.autonolas.tech/ipfs/f01701220157d3b106831e2713b86af1b52af76a3ef28c52ae0853e9638180902ebee41d4 |
|
|
261
|
+
+--------------+--------------------+--------------------------------------------+--------------------+---------------------------------------------------------------------------------------------------------------+
|
|
262
|
+
| 1722 | Fixed Price Token | 0x13f36b1a516290b7563b1de574a02ebeb48926a1 | 399 | https://gateway.autonolas.tech/ipfs/f01701220157d3b106831e2713b86af1b52af76a3ef28c52ae0853e9638180902ebee41d4 |
|
|
263
|
+
+--------------+--------------------+--------------------------------------------+--------------------+---------------------------------------------------------------------------------------------------------------+
|
|
264
|
+
| 2135 | Fixed Price Native | 0xbead38e4c4777341bb3fd44e8cd4d1ba1a7ad9d7 | 353 | https://gateway.autonolas.tech/ipfs/f01701220157d3b106831e2713b86af1b52af76a3ef28c52ae0853e9638180902ebee41d4 |
|
|
265
|
+
+--------------+--------------------+--------------------------------------------+--------------------+---------------------------------------------------------------------------------------------------------------+
|
|
266
|
+
```
|
|
240
267
|
|
|
241
268
|
### List tools available for legacy mechs and marketplace mechs
|
|
242
269
|
|
|
@@ -264,7 +291,7 @@ You will see an output like this:
|
|
|
264
291
|
```bash
|
|
265
292
|
mechx tools-for-agents --agent-id "agent_id"
|
|
266
293
|
```
|
|
267
|
-
Eaxmple usage
|
|
294
|
+
Eaxmple usage
|
|
268
295
|
```bash
|
|
269
296
|
mechx tools-for-agents --agent-id 6
|
|
270
297
|
```
|
|
@@ -522,7 +549,7 @@ This script will:
|
|
|
522
549
|
|
|
523
550
|
#### For Mechs receiving requests via the Mech Marketplace
|
|
524
551
|
|
|
525
|
-
In this case, the script is the same, except for the function result. When this function has no argument agent_id,
|
|
552
|
+
In this case, the script is the same, except for the function result. When this function has no argument agent_id,
|
|
526
553
|
the request is sent to the Mech Marketplace. The target Mech to which the request is relayed should be in the chain_config file (key `priority_mech_address`).
|
|
527
554
|
|
|
528
555
|
## Developer installation
|
|
@@ -303,7 +303,13 @@
|
|
|
303
303
|
{
|
|
304
304
|
"indexed": false,
|
|
305
305
|
"internalType": "bytes",
|
|
306
|
-
"name": "
|
|
306
|
+
"name": "requestData",
|
|
307
|
+
"type": "bytes"
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
"indexed": false,
|
|
311
|
+
"internalType": "bytes",
|
|
312
|
+
"name": "deliveryData",
|
|
307
313
|
"type": "bytes"
|
|
308
314
|
}
|
|
309
315
|
],
|
|
@@ -333,7 +339,7 @@
|
|
|
333
339
|
"type": "address"
|
|
334
340
|
},
|
|
335
341
|
{
|
|
336
|
-
"indexed":
|
|
342
|
+
"indexed": false,
|
|
337
343
|
"internalType": "address[]",
|
|
338
344
|
"name": "requesters",
|
|
339
345
|
"type": "address[]"
|
|
@@ -442,6 +448,12 @@
|
|
|
442
448
|
"internalType": "bytes32[]",
|
|
443
449
|
"name": "requestIds",
|
|
444
450
|
"type": "bytes32[]"
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
"indexed": false,
|
|
454
|
+
"internalType": "bytes[]",
|
|
455
|
+
"name": "requestDatas",
|
|
456
|
+
"type": "bytes[]"
|
|
445
457
|
}
|
|
446
458
|
],
|
|
447
459
|
"name": "MarketplaceRequest",
|
|
@@ -29,9 +29,11 @@ from tabulate import tabulate # type: ignore
|
|
|
29
29
|
from mech_client import __version__
|
|
30
30
|
from mech_client.interact import ConfirmationType
|
|
31
31
|
from mech_client.interact import interact as interact_
|
|
32
|
+
from mech_client.marketplace_interact import IPFS_URL_TEMPLATE
|
|
32
33
|
from mech_client.marketplace_interact import (
|
|
33
34
|
marketplace_interact as marketplace_interact_,
|
|
34
35
|
)
|
|
36
|
+
from mech_client.mech_marketplace_subgraph import query_mm_mechs_info
|
|
35
37
|
from mech_client.mech_marketplace_tool_management import (
|
|
36
38
|
extract_input_schema,
|
|
37
39
|
extract_output_schema,
|
|
@@ -515,6 +517,54 @@ def nvm_subscribe(
|
|
|
515
517
|
nvm_subscribe_main(private_key_path=key, chain_config=chain_config)
|
|
516
518
|
|
|
517
519
|
|
|
520
|
+
@click.command(name="fetch-mm-mechs-info")
|
|
521
|
+
@click.option(
|
|
522
|
+
"--chain-config",
|
|
523
|
+
type=str,
|
|
524
|
+
help="Id of the mech's chain configuration (stored configs/mechs.json)",
|
|
525
|
+
)
|
|
526
|
+
def query_mm_mechs_info_cli(
|
|
527
|
+
chain_config: str,
|
|
528
|
+
) -> None:
|
|
529
|
+
"""Fetches info of mm mechs"""
|
|
530
|
+
try:
|
|
531
|
+
mech_list = query_mm_mechs_info(chain_config=chain_config)
|
|
532
|
+
if mech_list is None:
|
|
533
|
+
print("No mechs found")
|
|
534
|
+
return None
|
|
535
|
+
|
|
536
|
+
headers = [
|
|
537
|
+
"Service Id",
|
|
538
|
+
"Mech Type",
|
|
539
|
+
"Mech Address",
|
|
540
|
+
"Total Deliveries",
|
|
541
|
+
"Metadata Link",
|
|
542
|
+
]
|
|
543
|
+
|
|
544
|
+
data = [
|
|
545
|
+
(
|
|
546
|
+
items["service"]["id"],
|
|
547
|
+
items["mech_type"],
|
|
548
|
+
items["address"],
|
|
549
|
+
items["service"]["totalDeliveries"],
|
|
550
|
+
(
|
|
551
|
+
IPFS_URL_TEMPLATE.format(
|
|
552
|
+
items["service"]["metadata"]["metadata"][2:]
|
|
553
|
+
)
|
|
554
|
+
if items["service"].get("metadata") is not None
|
|
555
|
+
else None
|
|
556
|
+
),
|
|
557
|
+
)
|
|
558
|
+
for items in mech_list
|
|
559
|
+
]
|
|
560
|
+
|
|
561
|
+
click.echo(tabulate(data, headers=headers, tablefmt="grid"))
|
|
562
|
+
return None
|
|
563
|
+
except Exception as e: # pylint: disable=broad-except
|
|
564
|
+
click.echo(f"Error: {str(e)}")
|
|
565
|
+
return None
|
|
566
|
+
|
|
567
|
+
|
|
518
568
|
cli.add_command(interact)
|
|
519
569
|
cli.add_command(prompt_to_ipfs)
|
|
520
570
|
cli.add_command(push_to_ipfs)
|
|
@@ -528,6 +578,7 @@ cli.add_command(tool_description_for_marketplace_mech)
|
|
|
528
578
|
cli.add_command(deposit_native)
|
|
529
579
|
cli.add_command(deposit_token)
|
|
530
580
|
cli.add_command(nvm_subscribe)
|
|
581
|
+
cli.add_command(query_mm_mechs_info_cli)
|
|
531
582
|
|
|
532
583
|
|
|
533
584
|
if __name__ == "__main__":
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"gas_limit": 500000,
|
|
17
17
|
"price": 10000000000000000,
|
|
18
18
|
"transaction_url": "https://gnosisscan.io/tx/{transaction_digest}",
|
|
19
|
-
"subgraph_url": ""
|
|
19
|
+
"subgraph_url": "https://api.studio.thegraph.com/query/89372/olas-gnosis-mech-marketplace/v0.0.2"
|
|
20
20
|
},
|
|
21
21
|
"arbitrum": {
|
|
22
22
|
"agent_registry_contract": "0xa4799B083E0068732456EF45ff9fe5c683658327",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"gas_limit": 500000,
|
|
74
74
|
"price": 3000000000000,
|
|
75
75
|
"transaction_url": "https://basescan.org/tx/{transaction_digest}",
|
|
76
|
-
"subgraph_url": ""
|
|
76
|
+
"subgraph_url": "https://api.studio.thegraph.com/query/89372/olas-base-mech-marketplace/v0.0.2"
|
|
77
77
|
},
|
|
78
78
|
"celo": {
|
|
79
79
|
"agent_registry_contract": "0xE49CB081e8d96920C38aA7AB90cb0294ab4Bc8EA",
|
|
@@ -50,6 +50,7 @@ from mech_client.interact import (
|
|
|
50
50
|
get_event_signatures,
|
|
51
51
|
get_mech_config,
|
|
52
52
|
)
|
|
53
|
+
from mech_client.mech_marketplace_tool_management import get_mech_tools
|
|
53
54
|
from mech_client.prompt_to_ipfs import push_metadata_to_ipfs
|
|
54
55
|
from mech_client.wss import (
|
|
55
56
|
register_event_handlers,
|
|
@@ -254,6 +255,9 @@ def fetch_requester_nvm_subscription_balance(
|
|
|
254
255
|
nvm_balance_tracker_contract = get_contract(
|
|
255
256
|
contract_address=mech_payment_balance_tracker, abi=abi, ledger_api=ledger_api
|
|
256
257
|
)
|
|
258
|
+
requester_balance_tracker_balance = (
|
|
259
|
+
nvm_balance_tracker_contract.functions.mapRequesterBalances(requester).call()
|
|
260
|
+
)
|
|
257
261
|
subscription_nft_address = (
|
|
258
262
|
nvm_balance_tracker_contract.functions.subscriptionNFT().call()
|
|
259
263
|
)
|
|
@@ -271,7 +275,7 @@ def fetch_requester_nvm_subscription_balance(
|
|
|
271
275
|
requester, subscription_id
|
|
272
276
|
).call()
|
|
273
277
|
|
|
274
|
-
return requester_balance
|
|
278
|
+
return requester_balance_tracker_balance + requester_balance
|
|
275
279
|
|
|
276
280
|
|
|
277
281
|
def send_marketplace_request( # pylint: disable=too-many-arguments,too-many-locals
|
|
@@ -587,6 +591,8 @@ def wait_for_offchain_marketplace_data(mech_offchain_url: str, request_id: str)
|
|
|
587
591
|
).json()
|
|
588
592
|
if response:
|
|
589
593
|
return response
|
|
594
|
+
|
|
595
|
+
time.sleep(WAIT_SLEEP)
|
|
590
596
|
except Exception: # pylint: disable=broad-except
|
|
591
597
|
time.sleep(WAIT_SLEEP)
|
|
592
598
|
|
|
@@ -640,6 +646,30 @@ def check_prepaid_balances(
|
|
|
640
646
|
sys.exit(1)
|
|
641
647
|
|
|
642
648
|
|
|
649
|
+
def verify_tools(tools: tuple, service_id: int, chain_config: Optional[str]) -> None:
|
|
650
|
+
"""
|
|
651
|
+
Verifies user supplied tool(s) with the mech's metadata
|
|
652
|
+
|
|
653
|
+
:param tools: The user supplied tools.
|
|
654
|
+
:type tools: tuple
|
|
655
|
+
:param service_id: Service id of the mech.
|
|
656
|
+
:type service_id: int
|
|
657
|
+
:param chain_config: Id of the mech's chain configuration (stored configs/mechs.json)
|
|
658
|
+
:type chain_config: str
|
|
659
|
+
:rtype: None
|
|
660
|
+
"""
|
|
661
|
+
mech_tools_data = get_mech_tools(service_id=service_id, chain_config=chain_config)
|
|
662
|
+
if not mech_tools_data:
|
|
663
|
+
raise ValueError("Error while fetching mech tools data")
|
|
664
|
+
|
|
665
|
+
mech_tools = mech_tools_data.get("tools", [])
|
|
666
|
+
invalid_tools = [tool for tool in tools if tool not in mech_tools]
|
|
667
|
+
if invalid_tools:
|
|
668
|
+
raise ValueError(
|
|
669
|
+
f"Tool(s) {invalid_tools} not found in mech tools: {mech_tools}"
|
|
670
|
+
)
|
|
671
|
+
|
|
672
|
+
|
|
643
673
|
def marketplace_interact( # pylint: disable=too-many-arguments, too-many-locals, too-many-statements, too-many-return-statements
|
|
644
674
|
prompts: tuple,
|
|
645
675
|
priority_mech: str,
|
|
@@ -742,7 +772,7 @@ def marketplace_interact( # pylint: disable=too-many-arguments, too-many-locals
|
|
|
742
772
|
)
|
|
743
773
|
(
|
|
744
774
|
payment_type,
|
|
745
|
-
|
|
775
|
+
service_id,
|
|
746
776
|
max_delivery_rate,
|
|
747
777
|
mech_payment_balance_tracker,
|
|
748
778
|
mech_contract,
|
|
@@ -754,6 +784,8 @@ def marketplace_interact( # pylint: disable=too-many-arguments, too-many-locals
|
|
|
754
784
|
mech_marketplace_request_config.delivery_rate = max_delivery_rate
|
|
755
785
|
mech_marketplace_request_config.payment_type = payment_type
|
|
756
786
|
|
|
787
|
+
verify_tools(tools, service_id, chain_config)
|
|
788
|
+
|
|
757
789
|
with open(IMECH_ABI_PATH, encoding="utf-8") as f:
|
|
758
790
|
abi = json.load(f)
|
|
759
791
|
|
|
@@ -802,22 +834,29 @@ def marketplace_interact( # pylint: disable=too-many-arguments, too-many-locals
|
|
|
802
834
|
max_delivery_rate,
|
|
803
835
|
)
|
|
804
836
|
|
|
805
|
-
|
|
837
|
+
is_nvm_mech = payment_type in [
|
|
838
|
+
PaymentType.NATIVE_NVM.value,
|
|
839
|
+
PaymentType.TOKEN_NVM.value,
|
|
840
|
+
]
|
|
841
|
+
if is_nvm_mech:
|
|
806
842
|
nvm_mech_type = PaymentType(payment_type).name.lower()
|
|
807
843
|
print(
|
|
808
844
|
f"{nvm_mech_type} Nevermined Mech detected, subscription credits to be used"
|
|
809
845
|
)
|
|
810
846
|
requester = crypto.address
|
|
811
|
-
|
|
847
|
+
requester_total_balance_before = fetch_requester_nvm_subscription_balance(
|
|
812
848
|
requester, ledger_api, mech_payment_balance_tracker, payment_type
|
|
813
849
|
)
|
|
814
|
-
if
|
|
850
|
+
if requester_total_balance_before < price:
|
|
815
851
|
print(
|
|
816
|
-
f" - Sender Subscription balance low. Needed: {price}, Actual: {
|
|
852
|
+
f" - Sender Subscription balance low. Needed: {price}, Actual: {requester_total_balance_before}"
|
|
817
853
|
)
|
|
818
854
|
print(f" - Sender Address: {requester}")
|
|
819
855
|
sys.exit(1)
|
|
820
856
|
|
|
857
|
+
print(
|
|
858
|
+
f" - Sender Subscription balance before request: {requester_total_balance_before}"
|
|
859
|
+
)
|
|
821
860
|
# set price 0 to not send any msg.value in request transaction for nvm type mech
|
|
822
861
|
price = 0
|
|
823
862
|
|
|
@@ -878,6 +917,19 @@ def marketplace_interact( # pylint: disable=too-many-arguments, too-many-locals
|
|
|
878
917
|
)
|
|
879
918
|
|
|
880
919
|
if data_url:
|
|
920
|
+
if is_nvm_mech:
|
|
921
|
+
requester_total_balance_after = (
|
|
922
|
+
fetch_requester_nvm_subscription_balance(
|
|
923
|
+
requester,
|
|
924
|
+
ledger_api,
|
|
925
|
+
mech_payment_balance_tracker,
|
|
926
|
+
payment_type,
|
|
927
|
+
)
|
|
928
|
+
)
|
|
929
|
+
print(
|
|
930
|
+
f" - Sender Subscription balance after delivery: {requester_total_balance_after}"
|
|
931
|
+
)
|
|
932
|
+
|
|
881
933
|
print(f" - Data arrived: {data_url}")
|
|
882
934
|
data = requests.get(f"{data_url}/{request_id_int}", timeout=30).json()
|
|
883
935
|
print(" - Data from agent:")
|
|
@@ -0,0 +1,94 @@
|
|
|
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
|
+
"""Subgraph client for mech."""
|
|
21
|
+
|
|
22
|
+
from typing import List, Optional
|
|
23
|
+
|
|
24
|
+
from gql import Client, gql
|
|
25
|
+
from gql.transport.aiohttp import AIOHTTPTransport
|
|
26
|
+
|
|
27
|
+
from mech_client.interact import get_mech_config
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
RESULTS_LIMIT = 20
|
|
31
|
+
CHAIN_TO_MECH_FACTORY_TO_MECH_TYPE = {
|
|
32
|
+
"gnosis": {
|
|
33
|
+
"0x8b299c20F87e3fcBfF0e1B86dC0acC06AB6993EF": "Fixed Price Native",
|
|
34
|
+
"0x31ffDC795FDF36696B8eDF7583A3D115995a45FA": "Fixed Price Token",
|
|
35
|
+
"0x65fd74C29463afe08c879a3020323DD7DF02DA57": "NvmSubscription Native",
|
|
36
|
+
},
|
|
37
|
+
"base": {
|
|
38
|
+
"0x2E008211f34b25A7d7c102403c6C2C3B665a1abe": "Fixed Price Native",
|
|
39
|
+
"0x97371B1C0cDA1D04dFc43DFb50a04645b7Bc9BEe": "Fixed Price Token",
|
|
40
|
+
"0x847bBE8b474e0820215f818858e23F5f5591855A": "NvmSubscription Native",
|
|
41
|
+
"0x7beD01f8482fF686F025628e7780ca6C1f0559fc": "NvmSubscription Token USDC",
|
|
42
|
+
},
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
MM_MECHS_INFO_QUERY = """
|
|
47
|
+
query MechsOrderedByServiceDeliveries {
|
|
48
|
+
meches(orderBy: service__totalDeliveries, orderDirection: desc) {
|
|
49
|
+
address
|
|
50
|
+
mechFactory
|
|
51
|
+
service {
|
|
52
|
+
id
|
|
53
|
+
totalDeliveries
|
|
54
|
+
metadata {
|
|
55
|
+
metadata
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
"""
|
|
61
|
+
|
|
62
|
+
DEFAULT_TIMEOUT = 600.0
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def query_mm_mechs_info(chain_config: str) -> Optional[List]:
|
|
66
|
+
"""
|
|
67
|
+
Query MM mechs and related info from subgraph.
|
|
68
|
+
|
|
69
|
+
:param chain_config: Id of the mech's chain configuration (stored configs/mechs.json)
|
|
70
|
+
:type chain_config: str
|
|
71
|
+
:return: The return list of data if found, None otherwise.
|
|
72
|
+
:rtype: Optional[List]
|
|
73
|
+
"""
|
|
74
|
+
mech_config = get_mech_config(chain_config)
|
|
75
|
+
if not mech_config.subgraph_url:
|
|
76
|
+
raise Exception(f"Subgraph URL not set for chain config: {chain_config}")
|
|
77
|
+
|
|
78
|
+
client = Client(
|
|
79
|
+
transport=AIOHTTPTransport(url=mech_config.subgraph_url),
|
|
80
|
+
execute_timeout=DEFAULT_TIMEOUT,
|
|
81
|
+
)
|
|
82
|
+
response = client.execute(document=gql(request_string=MM_MECHS_INFO_QUERY))
|
|
83
|
+
|
|
84
|
+
mech_factory_to_mech_type = {
|
|
85
|
+
k.lower(): v
|
|
86
|
+
for k, v in CHAIN_TO_MECH_FACTORY_TO_MECH_TYPE[chain_config].items()
|
|
87
|
+
}
|
|
88
|
+
filtered_mechs_data = []
|
|
89
|
+
for item in response["meches"]: # pylint: disable=unsubscriptable-object
|
|
90
|
+
if item.get("service") and int(item["service"]["totalDeliveries"]) > 0:
|
|
91
|
+
item["mech_type"] = mech_factory_to_mech_type[item["mechFactory"].lower()]
|
|
92
|
+
filtered_mechs_data.append(item)
|
|
93
|
+
|
|
94
|
+
return filtered_mechs_data[:RESULTS_LIMIT]
|
|
@@ -7,8 +7,9 @@ from typing import Any, Dict, List, Optional, Tuple
|
|
|
7
7
|
|
|
8
8
|
import requests
|
|
9
9
|
from aea_ledger_ethereum import EthereumApi
|
|
10
|
+
from web3.constants import ADDRESS_ZERO
|
|
10
11
|
|
|
11
|
-
from mech_client.
|
|
12
|
+
from mech_client.interact import get_contract, get_mech_config
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
ABI_DIR_PATH = Path(__file__).parent / "abis"
|
|
@@ -58,7 +59,7 @@ def fetch_tools(
|
|
|
58
59
|
|
|
59
60
|
|
|
60
61
|
def get_mech_tools(
|
|
61
|
-
service_id: int, chain_config: str = DEFAULT_CONFIG
|
|
62
|
+
service_id: int, chain_config: Optional[str] = DEFAULT_CONFIG
|
|
62
63
|
) -> Optional[Dict[str, Any]]:
|
|
63
64
|
"""
|
|
64
65
|
Fetch tools for a given mech's service ID.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mech_client-0.9.0 → mech_client-0.11.0}/mech_client/abis/BalanceTrackerFixedPriceNative.json
RENAMED
|
File without changes
|
{mech_client-0.9.0 → mech_client-0.11.0}/mech_client/abis/BalanceTrackerFixedPriceToken.json
RENAMED
|
File without changes
|
{mech_client-0.9.0 → mech_client-0.11.0}/mech_client/abis/BalanceTrackerNvmSubscriptionNative.json
RENAMED
|
File without changes
|
{mech_client-0.9.0 → mech_client-0.11.0}/mech_client/abis/BalanceTrackerNvmSubscriptionToken.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mech_client-0.9.0 → mech_client-0.11.0}/mech_client/abis/EscrowPaymentCondition.gnosis.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mech_client-0.9.0 → mech_client-0.11.0}/mech_client/helpers/acn/tests/test_acn_dialogues.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mech_client-0.9.0 → mech_client-0.11.0}/mech_client/helpers/acn_data_share/acn_data_share.proto
RENAMED
|
File without changes
|
{mech_client-0.9.0 → mech_client-0.11.0}/mech_client/helpers/acn_data_share/acn_data_share_pb2.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mech_client-0.9.0 → mech_client-0.11.0}/mech_client/helpers/acn_data_share/serialization.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mech_client-0.9.0 → mech_client-0.11.0}/mech_client/helpers/p2p_libp2p_client/connection.py
RENAMED
|
File without changes
|
{mech_client-0.9.0 → mech_client-0.11.0}/mech_client/helpers/p2p_libp2p_client/connection.yaml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mech_client-0.9.0 → mech_client-0.11.0}/scripts/nvm_subscription/contracts/agreement_manager.py
RENAMED
|
File without changes
|
{mech_client-0.9.0 → mech_client-0.11.0}/scripts/nvm_subscription/contracts/base_contract.py
RENAMED
|
File without changes
|
|
File without changes
|
{mech_client-0.9.0 → mech_client-0.11.0}/scripts/nvm_subscription/contracts/escrow_payment.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mech_client-0.9.0 → mech_client-0.11.0}/scripts/nvm_subscription/contracts/subscription_provider.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|