diff --git a/.gitignore b/.gitignore index f2695e299..dab8d401b 100644 --- a/.gitignore +++ b/.gitignore @@ -10,11 +10,13 @@ packages/valory/connections/p2p_libp2p_client/ packages/valory/skills/abstract_abci/ packages/valory/skills/abstract_round_abci/ +packages/valory/skills/mech_interact_abci/ packages/valory/skills/registration_abci/ packages/valory/skills/reset_pause_abci/ packages/valory/skills/transaction_settlement_abci/ packages/valory/skills/termination_abci/ +packages/valory/contracts/mech/ packages/valory/contracts/gnosis_safe_proxy_factory/ packages/valory/contracts/multisend/ packages/valory/contracts/service_registry/ diff --git a/packages/packages.json b/packages/packages.json index e3455cfcd..da34e1ae1 100644 --- a/packages/packages.json +++ b/packages/packages.json @@ -6,7 +6,6 @@ "custom/w1kke/always_blue/0.1.0": "bafybeieshu32h3es2fslduuhr7nimuvh2vuibyeqdunzrcggaeohekg3jm", "contract/valory/market_maker/0.1.0": "bafybeihyi42hkmu2knrunfdbunjh6j3ibfrnwj7rmqw7mm7pmerzcwzfiq", "contract/valory/erc20/0.1.0": "bafybeihnbk5wp7zb6hmaykqfxgdrvpwmxxh3xnmcwn3elopw3urjeyxo54", - "contract/valory/mech/0.1.0": "bafybeiaqkpudbwnjf2svagdwgl5vujhuhmdqiomee47m5t3z23iest2oxa", "contract/valory/realitio/0.1.0": "bafybeic5ie4oodetj4krdogydvbfxg4qggc3matpiflocah626tpevpreq", "contract/valory/realitio_proxy/0.1.0": "bafybeidx37xzjjmapwacedgzhum6grfzhp5vhouz4zu3pvpgdy5pgb2fr4", "contract/valory/conditional_tokens/0.1.0": "bafybeigucumqbsk74nj4rpm4p2cpiky4dj6uws7nfmgpimuviaxcamwqnu", @@ -14,12 +13,12 @@ "contract/valory/service_staking_token/0.1.0": "bafybeibpe24zfvpipaut77tsutmednncjviqeoekxltsndovdz3ugek7bu", "contract/valory/transfer_nft_condition/0.1.0": "bafybeicgpoag2lymofz3vnen76q7gtig5hzimn32o57php4uerr6t25em4", "skill/valory/market_manager_abci/0.1.0": "bafybeidygkw7mwhbk3ry3au5c5265vms5eti375v5jthd4be5dfnnoache", - "skill/valory/decision_maker_abci/0.1.0": "bafybeie7bvctvvmphamfrujtnsg2wxeafuoquvgikhm33xrowtpybj2iyy", - "skill/valory/trader_abci/0.1.0": "bafybeif44yj3ylxwu3pch5tfejwxdoq42vu34cfapsbiolggkxygbcz4ve", - "skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeico5v6u7dmy7tj4nwakmoef5ihirivtb7s5lxm3v6szsco3ulkctu", + "skill/valory/decision_maker_abci/0.1.0": "bafybeiftz2xjbld2njsywsii5pgp6354oqm6ultqyfyfsnemuzqulw6o2y", + "skill/valory/trader_abci/0.1.0": "bafybeidrrl5mni5i4gsde7pfms6shsljmnwdcgo4pqeaujvti446rkkgxu", + "skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeifshd7ut2eyzyolvwpjcjxreq2c655gz4nh2vudglvfb7oog7gase", "skill/valory/staking_abci/0.1.0": "bafybeibf565rftitlrlovlvchoe45ng72ctec74fsvrmegp3o4uepu4q2e", - "agent/valory/trader/0.1.0": "bafybeid7u2back4fs6tjg2xreuuoxffhyts7zqnopkaf33727nnudb4zhu", - "service/valory/trader/0.1.0": "bafybeiasnt464j7qfatuju2g6e6k2rgtebwqrdpyi5hij7xr5uwpwp4a2e" + "agent/valory/trader/0.1.0": "bafybeib2gnqwi5mmlz3efkzlahgwunpwt75nhpsvitllllnet5zu7jtb5u", + "service/valory/trader/0.1.0": "bafybeie4sj2z3iaxxpuxe2sefkjaorwe5f5ndud2qmq6paf6vyiywjr7gm" }, "third_party": { "protocol/open_aea/signing/1.0.0": "bafybeihv62fim3wl2bayavfcg3u5e5cxu3b7brtu4cn5xoxd6lqwachasi", @@ -32,6 +31,7 @@ "protocol/valory/ipfs/0.1.0": "bafybeiftxi2qhreewgsc5wevogi7yc5g6hbcbo4uiuaibauhv3nhfcdtvm", "contract/valory/gnosis_safe_proxy_factory/0.1.0": "bafybeib6podeifufgmawvicm3xyz3uaplbcrsptjzz4unpseh7qtcpar74", "contract/valory/gnosis_safe/0.1.0": "bafybeibq77mgzhyb23blf2eqmia3kc6io5karedfzhntvpcebeqdzrgyqa", + "contract/valory/mech/0.1.0": "bafybeiejdn3rqqa7smbeiypajy63um7okteimvj6bsud3gezneycmdc6te", "contract/valory/service_registry/0.1.0": "bafybeicbxmbzt757lbmyh6762lrkcrp3oeum6dk3z7pvosixasifsk6xlm", "contract/valory/multisend/0.1.0": "bafybeig5byt5urg2d2bsecufxe5ql7f4mezg3mekfleeh32nmuusx66p4y", "connection/valory/abci/0.1.0": "bafybeiclexb6cnsog5yjz2qtvqyfnf7x5m7tpp56hblhk3pbocbvgjzhze", @@ -44,6 +44,7 @@ "skill/valory/registration_abci/0.1.0": "bafybeiek7zcsxbucjwzgqfftafhfrocvc7q4yxllh2q44jeemsjxg3rcfm", "skill/valory/abstract_round_abci/0.1.0": "bafybeih3enhagoql7kzpeyzzu2scpkif6y3ubakpralfnwxcvxexdyvy5i", "skill/valory/transaction_settlement_abci/0.1.0": "bafybeigtzlk4uakmd54rxnznorcrstsr52kta474lgrnvx5ovr546vj7sq", - "skill/valory/termination_abci/0.1.0": "bafybeihq6qtbwt6i53ayqym63vhjexkcppy26gguzhhjqywfmiuqghvv44" + "skill/valory/termination_abci/0.1.0": "bafybeihq6qtbwt6i53ayqym63vhjexkcppy26gguzhhjqywfmiuqghvv44", + "skill/valory/mech_interact_abci/0.1.0": "bafybeidxignwgujlkhw5hbek7xw2uz5nrd3h2xx7sj5zor263dgh4fm3p4" } } \ No newline at end of file diff --git a/packages/valory/agents/trader/aea-config.yaml b/packages/valory/agents/trader/aea-config.yaml index 6618f666e..fb54db63d 100644 --- a/packages/valory/agents/trader/aea-config.yaml +++ b/packages/valory/agents/trader/aea-config.yaml @@ -21,7 +21,7 @@ contracts: - valory/market_maker:0.1.0:bafybeihyi42hkmu2knrunfdbunjh6j3ibfrnwj7rmqw7mm7pmerzcwzfiq - valory/erc20:0.1.0:bafybeihnbk5wp7zb6hmaykqfxgdrvpwmxxh3xnmcwn3elopw3urjeyxo54 - valory/multisend:0.1.0:bafybeig5byt5urg2d2bsecufxe5ql7f4mezg3mekfleeh32nmuusx66p4y -- valory/mech:0.1.0:bafybeiaqkpudbwnjf2svagdwgl5vujhuhmdqiomee47m5t3z23iest2oxa +- valory/mech:0.1.0:bafybeiejdn3rqqa7smbeiypajy63um7okteimvj6bsud3gezneycmdc6te - valory/conditional_tokens:0.1.0:bafybeigucumqbsk74nj4rpm4p2cpiky4dj6uws7nfmgpimuviaxcamwqnu - valory/realitio:0.1.0:bafybeic5ie4oodetj4krdogydvbfxg4qggc3matpiflocah626tpevpreq - valory/realitio_proxy:0.1.0:bafybeidx37xzjjmapwacedgzhum6grfzhp5vhouz4zu3pvpgdy5pgb2fr4 @@ -44,11 +44,12 @@ skills: - valory/reset_pause_abci:0.1.0:bafybeidw4mbx3os3hmv7ley7b3g3gja7ydpitr7mxbjpwzxin2mzyt5yam - valory/termination_abci:0.1.0:bafybeihq6qtbwt6i53ayqym63vhjexkcppy26gguzhhjqywfmiuqghvv44 - valory/transaction_settlement_abci:0.1.0:bafybeigtzlk4uakmd54rxnznorcrstsr52kta474lgrnvx5ovr546vj7sq -- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeico5v6u7dmy7tj4nwakmoef5ihirivtb7s5lxm3v6szsco3ulkctu +- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeifshd7ut2eyzyolvwpjcjxreq2c655gz4nh2vudglvfb7oog7gase - valory/market_manager_abci:0.1.0:bafybeidygkw7mwhbk3ry3au5c5265vms5eti375v5jthd4be5dfnnoache -- valory/decision_maker_abci:0.1.0:bafybeie7bvctvvmphamfrujtnsg2wxeafuoquvgikhm33xrowtpybj2iyy -- valory/trader_abci:0.1.0:bafybeif44yj3ylxwu3pch5tfejwxdoq42vu34cfapsbiolggkxygbcz4ve +- valory/decision_maker_abci:0.1.0:bafybeiftz2xjbld2njsywsii5pgp6354oqm6ultqyfyfsnemuzqulw6o2y +- valory/trader_abci:0.1.0:bafybeidrrl5mni5i4gsde7pfms6shsljmnwdcgo4pqeaujvti446rkkgxu - valory/staking_abci:0.1.0:bafybeibf565rftitlrlovlvchoe45ng72ctec74fsvrmegp3o4uepu4q2e +- valory/mech_interact_abci:0.1.0:bafybeidxignwgujlkhw5hbek7xw2uz5nrd3h2xx7sj5zor263dgh4fm3p4 customs: - valory/mike_strat:0.1.0:bafybeihjiol7f4ch4piwfikurdtfwzsh6qydkbsztpbwbwb2yrqdqf726m - valory/bet_amount_per_threshold:0.1.0:bafybeihufqu2ra7vud4h6g2nwahx7mvdido7ff6prwnib2tdlc4np7dw24 @@ -154,6 +155,7 @@ models: reset_pause_duration: ${int:30} max_healthcheck: ${int:43200} multisend_address: ${str:0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761} + multisend_batch_size: ${int:1} drand_public_key: ${str:868f005eb8e6e4ca0a47c8a77ceaa5309a47978a7c71bc5cce96366b5d7a569937c529eeda66c7293784a9402801af31} service_registry_address: ${str:null} agent_registry_address: ${str:null} @@ -171,7 +173,8 @@ models: languages: ${list:["en_US"]} average_block_time: ${int:5} abt_error_mult: ${int:5} - mech_agent_address: ${str:0x77af31De935740567Cf4fF1986D04B2c964A786a} + mech_contract_address: ${str:0x77af31De935740567Cf4fF1986D04B2c964A786a} + request_price: ${int:null} sample_bets_closing_days: ${int:10} trading_strategy: ${str:kelly_criterion} use_fallback_strategy: ${bool:true} @@ -241,3 +244,8 @@ config: chain_id: ${int:1337} default_gas_price_strategy: ${str:eip1559} poa_chain: ${bool:false} + gnosis: + address: ${str:https://rpc.gnosischain.com} + chain_id: ${int:100} + poa_chain: ${bool:false} + default_gas_price_strategy: ${str:eip1559} diff --git a/packages/valory/contracts/mech/README.md b/packages/valory/contracts/mech/README.md deleted file mode 100644 index c321ae231..000000000 --- a/packages/valory/contracts/mech/README.md +++ /dev/null @@ -1 +0,0 @@ -# Agent Mech contract diff --git a/packages/valory/contracts/mech/__init__.py b/packages/valory/contracts/mech/__init__.py deleted file mode 100644 index e34c6e4ef..000000000 --- a/packages/valory/contracts/mech/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# ------------------------------------------------------------------------------ -# -# Copyright 2023 Valory AG -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# ------------------------------------------------------------------------------ - -"""This module contains the support resources for an agent Mech.""" diff --git a/packages/valory/contracts/mech/build/mech.json b/packages/valory/contracts/mech/build/mech.json deleted file mode 100644 index 0f25468df..000000000 --- a/packages/valory/contracts/mech/build/mech.json +++ /dev/null @@ -1,727 +0,0 @@ -{ - "_format": "hh-sol-artifact-1", - "contractName": "AgentMech", - "sourceName": "contracts/AgentMech.sol", - "abi": [ - { - "inputs": [ - { - "internalType": "address", - "name": "_token", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_tokenId", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_price", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "agentId", - "type": "uint256" - } - ], - "name": "AgentNotFound", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "provided", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "expected", - "type": "uint256" - } - ], - "name": "NotEnoughPaid", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "provided", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "max", - "type": "uint256" - } - ], - "name": "Overflow", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "requestId", - "type": "uint256" - } - ], - "name": "RequestIdNotFound", - "type": "error" - }, - { - "inputs": [], - "name": "ZeroAddress", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "sender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "requestId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "name": "Deliver", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "price", - "type": "uint256" - } - ], - "name": "PriceUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "sender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "requestId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "name": "Request", - "type": "event" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "requestId", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "name": "deliver", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "entryPoint", - "outputs": [ - { - "internalType": "contract IEntryPoint", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "value", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - }, - { - "internalType": "enum Enum.Operation", - "name": "operation", - "type": "uint8" - }, - { - "internalType": "uint256", - "name": "txGas", - "type": "uint256" - } - ], - "name": "exec", - "outputs": [ - { - "internalType": "bytes", - "name": "returnData", - "type": "bytes" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "name": "getRequestId", - "outputs": [ - { - "internalType": "uint256", - "name": "requestId", - "type": "uint256" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "getRequestsCount", - "outputs": [ - { - "internalType": "uint256", - "name": "requestsCount", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "size", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "offset", - "type": "uint256" - } - ], - "name": "getUndeliveredRequestIds", - "outputs": [ - { - "internalType": "uint256[]", - "name": "requestIds", - "type": "uint256[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "signer", - "type": "address" - } - ], - "name": "isOperator", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "hash", - "type": "bytes32" - }, - { - "internalType": "bytes", - "name": "signature", - "type": "bytes" - } - ], - "name": "isValidSignature", - "outputs": [ - { - "internalType": "bytes4", - "name": "magicValue", - "type": "bytes4" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "mapRequestIds", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "mapRequestsCounts", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "nonce", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "numUndeliveredRequests", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "uint256[]", - "name": "", - "type": "uint256[]" - }, - { - "internalType": "uint256[]", - "name": "", - "type": "uint256[]" - }, - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "name": "onERC1155BatchReceived", - "outputs": [ - { - "internalType": "bytes4", - "name": "", - "type": "bytes4" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "name": "onERC1155Received", - "outputs": [ - { - "internalType": "bytes4", - "name": "", - "type": "bytes4" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "name": "onERC721Received", - "outputs": [ - { - "internalType": "bytes4", - "name": "", - "type": "bytes4" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [], - "name": "price", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "name": "request", - "outputs": [ - { - "internalType": "uint256", - "name": "requestId", - "type": "uint256" - } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "newPrice", - "type": "uint256" - } - ], - "name": "setPrice", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "initParams", - "type": "bytes" - } - ], - "name": "setUp", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "token", - "outputs": [ - { - "internalType": "contract IERC721", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "tokenId", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "", - "type": "bytes" - }, - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "name": "tokensReceived", - "outputs": [], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "address", - "name": "sender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "nonce", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "initCode", - "type": "bytes" - }, - { - "internalType": "bytes", - "name": "callData", - "type": "bytes" - }, - { - "internalType": "uint256", - "name": "callGasLimit", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "verificationGasLimit", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "preVerificationGas", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "maxFeePerGas", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "maxPriorityFeePerGas", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "paymasterAndData", - "type": "bytes" - }, - { - "internalType": "bytes", - "name": "signature", - "type": "bytes" - } - ], - "internalType": "struct UserOperation", - "name": "userOp", - "type": "tuple" - }, - { - "internalType": "bytes32", - "name": "userOpHash", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "missingAccountFunds", - "type": "uint256" - } - ], - "name": "validateUserOp", - "outputs": [ - { - "internalType": "uint256", - "name": "validationData", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "stateMutability": "payable", - "type": "receive" - } - ], - "bytecode": "0x60806040525f805534801562000013575f80fd5b50604051620026cc380380620026cc833981016040819052620000369162000391565b604080516001600160a01b03851660208201528082018490528151808203830181526060909101909152839083906200006f8162000145565b5050506001600160a01b0383166200009a5760405163d92e233d60e01b815260040160405180910390fd5b6040516331a9108f60e11b8152600481018390525f906001600160a01b03851690636352211e90602401602060405180830381865afa158015620000e0573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620001069190620003c6565b90506001600160a01b0381166200013857604051630ede975960e01b8152600481018490526024015b60405180910390fd5b50600155506200049a9050565b6200014f620001ad565b51156200019f5760405162461bcd60e51b815260206004820152601360248201527f416c726561647920696e697469616c697a65640000000000000000000000000060448201526064016200012f565b620001aa8162000218565b50565b6060620002136200020d604051606b60f91b6020820152602560fa1b60218201526001600160601b03193060601b166022820152600160f81b60368201525f90603701604051602081830303815290604052805190602001205f1c905090565b620002e1565b905090565b5f620002248262000339565b90505f8151602083015ff090506200028b604051606b60f91b6020820152602560fa1b60218201526001600160601b03193060601b166022820152600160f81b60368201525f90603701604051602081830303815290604052805190602001205f1c905090565b6001600160a01b0316816001600160a01b031614620002dc5760405162461bcd60e51b815260206004820152600c60248201526b15dc9a5d194819985a5b195960a21b60448201526064016200012f565b505050565b6060813b600181116200030357505060408051602081019091525f8152919050565b806200030f81620003fd565b9150506040519150601f19601f602083010116820160405280825280600160208401853c50919050565b6060815160016200034b919062000415565b826040516020016200035f92919062000431565b6040516020818303038152906040529050919050565b80516001600160a01b03811681146200038c575f80fd5b919050565b5f805f60608486031215620003a4575f80fd5b620003af8462000375565b925060208401519150604084015190509250925092565b5f60208284031215620003d7575f80fd5b620003e28262000375565b9392505050565b634e487b7160e01b5f52601160045260245ffd5b5f816200040e576200040e620003e9565b505f190190565b808201808211156200042b576200042b620003e9565b92915050565b606360f81b815260e083901b6001600160e01b03191660018201526880600e6000396000f360b81b60058201525f600e82018190528251815b8181101562000489576020818601810151600f8684010152016200046a565b505f9201600f019182525092915050565b61222480620004a85f395ff3fe60806040526004361061017a575f3560e01c8063a035b1fe116100d1578063bdf863171161007c578063f23a6e6111610057578063f23a6e61146104d2578063f6171e4414610517578063fc0c546a14610536575f80fd5b8063bdf8631714610472578063c7dec3fc14610487578063e00b9118146104b3575f80fd5b8063b0d691fe116100ac578063b0d691fe146103d1578063b94207d314610418578063bc197c811461042b575f80fd5b8063a035b1fe1461038a578063a4f9edbf1461039f578063affed0e0146103be575f80fd5b80633a871cdd116101315780636d70f7ae1161010c5780636d70f7ae146102fb5780637af734731461032a57806391b7f5ed1461036b575f80fd5b80633a871cdd1461028557806358ce0909146102a45780635fee6085146102d0575f80fd5b8063157305fe11610161578063157305fe146102255780631626ba7e1461024457806317d70f7c14610263575f80fd5b806223de2914610185578063150b7a02146101ab575f80fd5b3661018157005b5f80fd5b348015610190575f80fd5b506101a961019f366004611943565b5050505050505050565b005b3480156101b6575f80fd5b506101ef6101c53660046119ed565b7f150b7a020000000000000000000000000000000000000000000000000000000095945050505050565b6040517fffffffff0000000000000000000000000000000000000000000000000000000090911681526020015b60405180910390f35b348015610230575f80fd5b506101a961023f366004611b2f565b61054a565b34801561024f575f80fd5b506101ef61025e366004611b2f565b610771565b34801561026e575f80fd5b50610277610914565b60405190815260200161021c565b348015610290575f80fd5b5061027761029f366004611b73565b610938565b3480156102af575f80fd5b506102c36102be366004611bc2565b610974565b60405161021c9190611be2565b3480156102db575f80fd5b506102776102ea366004611c25565b60036020525f908152604090205481565b348015610306575f80fd5b5061031a610315366004611c25565b610ada565b604051901515815260200161021c565b348015610335575f80fd5b50610277610344366004611c25565b73ffffffffffffffffffffffffffffffffffffffff165f9081526003602052604090205490565b348015610376575f80fd5b506101a9610385366004611c40565b610bac565b348015610395575f80fd5b5061027760015481565b3480156103aa575f80fd5b506101a96103b9366004611c57565b610c9a565b3480156103c9575f80fd5b505f54610277565b3480156103dc575f80fd5b50730576a174d229e3cfa37253523e645a78a0c91b575b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161021c565b610277610426366004611c57565b610d16565b348015610436575f80fd5b506101ef610445366004611cd2565b7fbc197c810000000000000000000000000000000000000000000000000000000098975050505050505050565b34801561047d575f80fd5b5061027760025481565b348015610492575f80fd5b506104a66104a1366004611d68565b610e63565b60405161021c9190611e45565b3480156104be575f80fd5b506102776104cd366004611e57565b610f4d565b3480156104dd575f80fd5b506101ef6104ec366004611e8e565b7ff23a6e61000000000000000000000000000000000000000000000000000000009695505050505050565b348015610522575f80fd5b50610277610531366004611bc2565b610f9e565b348015610541575f80fd5b506103f3610fc0565b61055333610ada565b80610571575033730576a174d229e3cfa37253523e645a78a0c91b57145b610602576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603e60248201527f4f6e6c792063616c6c61626c6520627920746865206d656368206f706572617460448201527f6f72206f722074686520656e74727920706f696e7420636f6e7472616374000060648201526084015b60405180910390fd5b5f828152600460205260408082208151808301928390529160029082845b8154815260200190600101908083116106205750505050509050805f6002811061064c5761064c611f05565b602002015115801561066057506020810151155b801561069557505f805260046020527f17ef568e3e12ab5b9c7254a8d58478811de00f9e6eb34345acd53bf8fd09d3ed548314155b156106cf576040517ffe239804000000000000000000000000000000000000000000000000000000008152600481018490526024016105f9565b6020818101805183515f908152600490935260408084206001908101929092558451925184528084209290925585835290822082815501819055600280549161071783611f5f565b91905055503373ffffffffffffffffffffffffffffffffffffffff167f0cd979445339c62199996f208428d987b1cea24d18e62b79ec24d94b636e8b708484604051610764929190611f93565b60405180910390a2505050565b5f805f8061079185602081015160408201516060909201515f1a92909190565b9094509250905060ff81165f036108a757828583016020016107b282610ada565b1580156107d5575073ffffffffffffffffffffffffffffffffffffffff82163014155b1561080857507fffffffff00000000000000000000000000000000000000000000000000000000945061090e9350505050565b6040517f1626ba7e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff831690631626ba7e9061085c908b908590600401611f93565b602060405180830381865afa158015610877573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061089b9190611fab565b9550505050505061090e565b6108b661031587838686610fdd565b156108e757507f1626ba7e00000000000000000000000000000000000000000000000000000000925061090e915050565b507fffffffff00000000000000000000000000000000000000000000000000000000925050505b92915050565b5f8061091e610ff9565b8060200190518101906109319190611fea565b9392505050565b5f6109416110cd565b61094b848461114c565b905061095a6040850185612016565b90505f0361096b5761096b8461124c565b610931826112ca565b6002546060905f849003610986578093505b806109918486612077565b11156109de576109a18385612077565b6040517f7ae596850000000000000000000000000000000000000000000000000000000081526004810191909152602481018290526044016105f9565b8315610ad3578367ffffffffffffffff8111156109fd576109fd611a5b565b604051908082528060200260200182016040528015610a26578160200160208202803683370190505b505f80805260046020527f17ef568e3e12ab5b9c7254a8d58478811de00f9e6eb34345acd53bf8fd09d3ed549193505b84811015610a81575f828152600460205260409020600101549150610a7a8161208a565b9050610a56565b505f5b85811015610ad05781848281518110610a9f57610a9f611f05565b6020908102919091018101919091525f9283526004905260409091206001015490610ac98161208a565b9050610a84565b50505b5092915050565b5f805f610ae5610ff9565b806020019051810190610af89190611fea565b915091508373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16636352211e836040518263ffffffff1660e01b8152600401610b4e91815260200190565b602060405180830381865afa158015610b69573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610b8d91906120c1565b73ffffffffffffffffffffffffffffffffffffffff1614949350505050565b610bb533610ada565b80610bd3575033730576a174d229e3cfa37253523e645a78a0c91b57145b610c5f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603e60248201527f4f6e6c792063616c6c61626c6520627920746865206d656368206f706572617460448201527f6f72206f722074686520656e74727920706f696e7420636f6e7472616374000060648201526084016105f9565b60018190556040518181527f66cbca4f3c64fecf1dcb9ce094abcf7f68c3450a1d4e3a8e917dd621edb4ebe09060200160405180910390a150565b610ca2610ff9565b5115610d0a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f416c726561647920696e697469616c697a65640000000000000000000000000060448201526064016105f9565b610d138161133e565b50565b5f600154341015610d60576001546040517fb489782800000000000000000000000000000000000000000000000000000000815234600482015260248101919091526044016105f9565b610d6a3383610f4d565b335f908152600360205260408120805492935090610d878361208a565b909155505060046020525f81815260408082207f17ef568e3e12ab5b9c7254a8d58478811de00f9e6eb34345acd53bf8fd09d3ed80546001830181905590859055808452918320849055600280547f17ef568e3e12ab5b9c7254a8d58478811de00f9e6eb34345acd53bf8fd09d3ec94929392909190610e068361208a565b91905055503373ffffffffffffffffffffffffffffffffffffffff167f4bda649efe6b98b0f9c1d5e859c29e20910f45c66dabfe6fad4a4881f7faf9cc8587604051610e53929190611f93565b60405180910390a2505050919050565b6060610e6e33610ada565b80610e8c575033730576a174d229e3cfa37253523e645a78a0c91b57145b610f18576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603e60248201527f4f6e6c792063616c6c61626c6520627920746865206d656368206f706572617460448201527f6f72206f722074686520656e74727920706f696e7420636f6e7472616374000060648201526084016105f9565b5f610f32878787878715610f2c57876114b3565b5a6114b3565b9250905080610f4357815160208301fd5b5095945050505050565b5f8282604051602001610f619291906120dc565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291905280516020909101209392505050565b6004602052815f5260405f208160028110610fb7575f80fd5b01549150829050565b5f80610fca610ff9565b80602001905181019061090e91906120c1565b5f805f610fec878787876115b6565b91509150610f438161169e565b60606110c86110c36040517fd60000000000000000000000000000000000000000000000000000000000000060208201527f940000000000000000000000000000000000000000000000000000000000000060218201527fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003060601b1660228201527f010000000000000000000000000000000000000000000000000000000000000060368201525f90603701604051602081830303815290604052805190602001205f1c905090565b611850565b905090565b33730576a174d229e3cfa37253523e645a78a0c91b571461114a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f6163636f756e743a206e6f742066726f6d20456e747279506f696e740000000060448201526064016105f9565b565b5f806111a4836040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c81018290525f90605c01604051602081830303815290604052805190602001209050919050565b90507f1626ba7e00000000000000000000000000000000000000000000000000000000611212826111d9610140880188612016565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284375f9201919091525061077192505050565b7fffffffff00000000000000000000000000000000000000000000000000000000161461124357600191505061090e565b505f9392505050565b5f80546020830135918061125f8361208a565b9190505514610d13576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600d60248201527f496e76616c6964206e6f6e63650000000000000000000000000000000000000060448201526064016105f9565b8015610d13576040515f9033907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90849084818181858888f193505050503d805f8114611332576040519150601f19603f3d011682016040523d82523d5f602084013e611337565b606091505b5050505050565b5f611348826118a5565b90505f8151602083015ff0905061141a6040517fd60000000000000000000000000000000000000000000000000000000000000060208201527f940000000000000000000000000000000000000000000000000000000000000060218201527fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003060601b1660228201527f010000000000000000000000000000000000000000000000000000000000000060368201525f90603701604051602081830303815290604052805190602001205f1c905090565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146114ae576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f5772697465206661696c6564000000000000000000000000000000000000000060448201526064016105f9565b505050565b5f606060018460018111156114ca576114ca61210a565b0361153e578673ffffffffffffffffffffffffffffffffffffffff1683866040516114f59190612137565b5f604051808303818686f4925050503d805f811461152e576040519150601f19603f3d011682016040523d82523d5f602084013e611533565b606091505b5090925090506115ac565b8673ffffffffffffffffffffffffffffffffffffffff168387876040516115659190612137565b5f60405180830381858888f193505050503d805f81146115a0576040519150601f19603f3d011682016040523d82523d5f602084013e6115a5565b606091505b5090925090505b9550959350505050565b5f807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156115eb57505f90506003611695565b604080515f8082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa15801561163c573d5f803e3d5ffd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811661168f575f60019250925050611695565b91505f90505b94509492505050565b5f8160048111156116b1576116b161210a565b036116b95750565b60018160048111156116cd576116cd61210a565b03611734576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f45434453413a20696e76616c6964207369676e6174757265000000000000000060448201526064016105f9565b60028160048111156117485761174861210a565b036117af576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e6774680060448201526064016105f9565b60038160048111156117c3576117c361210a565b03610d13576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f756500000000000000000000000000000000000000000000000000000000000060648201526084016105f9565b6060813b6001811161187157505060408051602081019091525f8152919050565b8061187b81611f5f565b9150506040519150601f19601f602083010116820160405280825280600160208401853c50919050565b6060815160016118b59190612077565b826040516020016118c7929190612152565b6040516020818303038152906040529050919050565b73ffffffffffffffffffffffffffffffffffffffff81168114610d13575f80fd5b5f8083601f84011261190e575f80fd5b50813567ffffffffffffffff811115611925575f80fd5b60208301915083602082850101111561193c575f80fd5b9250929050565b5f805f805f805f8060c0898b03121561195a575f80fd5b8835611965816118dd565b97506020890135611975816118dd565b96506040890135611985816118dd565b955060608901359450608089013567ffffffffffffffff808211156119a8575f80fd5b6119b48c838d016118fe565b909650945060a08b01359150808211156119cc575f80fd5b506119d98b828c016118fe565b999c989b5096995094979396929594505050565b5f805f805f60808688031215611a01575f80fd5b8535611a0c816118dd565b94506020860135611a1c816118dd565b935060408601359250606086013567ffffffffffffffff811115611a3e575f80fd5b611a4a888289016118fe565b969995985093965092949392505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b5f82601f830112611a97575f80fd5b813567ffffffffffffffff80821115611ab257611ab2611a5b565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f01168101908282118183101715611af857611af8611a5b565b81604052838152866020858801011115611b10575f80fd5b836020870160208301375f602085830101528094505050505092915050565b5f8060408385031215611b40575f80fd5b82359150602083013567ffffffffffffffff811115611b5d575f80fd5b611b6985828601611a88565b9150509250929050565b5f805f60608486031215611b85575f80fd5b833567ffffffffffffffff811115611b9b575f80fd5b84016101608187031215611bad575f80fd5b95602085013595506040909401359392505050565b5f8060408385031215611bd3575f80fd5b50508035926020909101359150565b602080825282518282018190525f9190848201906040850190845b81811015611c1957835183529284019291840191600101611bfd565b50909695505050505050565b5f60208284031215611c35575f80fd5b8135610931816118dd565b5f60208284031215611c50575f80fd5b5035919050565b5f60208284031215611c67575f80fd5b813567ffffffffffffffff811115611c7d575f80fd5b611c8984828501611a88565b949350505050565b5f8083601f840112611ca1575f80fd5b50813567ffffffffffffffff811115611cb8575f80fd5b6020830191508360208260051b850101111561193c575f80fd5b5f805f805f805f8060a0898b031215611ce9575f80fd5b8835611cf4816118dd565b97506020890135611d04816118dd565b9650604089013567ffffffffffffffff80821115611d20575f80fd5b611d2c8c838d01611c91565b909850965060608b0135915080821115611d44575f80fd5b611d508c838d01611c91565b909650945060808b01359150808211156119cc575f80fd5b5f805f805f60a08688031215611d7c575f80fd5b8535611d87816118dd565b945060208601359350604086013567ffffffffffffffff811115611da9575f80fd5b611db588828901611a88565b935050606086013560028110611dc9575f80fd5b949793965091946080013592915050565b5f5b83811015611df4578181015183820152602001611ddc565b50505f910152565b5f8151808452611e13816020860160208601611dda565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081525f6109316020830184611dfc565b5f8060408385031215611e68575f80fd5b8235611e73816118dd565b9150602083013567ffffffffffffffff811115611b5d575f80fd5b5f805f805f8060a08789031215611ea3575f80fd5b8635611eae816118dd565b95506020870135611ebe816118dd565b94506040870135935060608701359250608087013567ffffffffffffffff811115611ee7575f80fd5b611ef389828a016118fe565b979a9699509497509295939492505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f81611f6d57611f6d611f32565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190565b828152604060208201525f611c896040830184611dfc565b5f60208284031215611fbb575f80fd5b81517fffffffff0000000000000000000000000000000000000000000000000000000081168114610931575f80fd5b5f8060408385031215611ffb575f80fd5b8251612006816118dd565b6020939093015192949293505050565b5f8083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112612049575f80fd5b83018035915067ffffffffffffffff821115612063575f80fd5b60200191503681900382131561193c575f80fd5b8082018082111561090e5761090e611f32565b5f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036120ba576120ba611f32565b5060010190565b5f602082840312156120d1575f80fd5b8151610931816118dd565b73ffffffffffffffffffffffffffffffffffffffff83168152604060208201525f611c896040830184611dfc565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b5f8251612148818460208701611dda565b9190910192915050565b7f630000000000000000000000000000000000000000000000000000000000000081527fffffffff000000000000000000000000000000000000000000000000000000008360e01b1660018201527f80600e6000396000f3000000000000000000000000000000000000000000000060058201525f600e8201525f82516121e081600f850160208701611dda565b91909101600f01939250505056fea2646970667358221220c1913351e275e1fecd00c79cd676ed135b575df5d3a88ccc57419dc3081980a264736f6c63430008150033", - "deployedBytecode": "0x60806040526004361061017a575f3560e01c8063a035b1fe116100d1578063bdf863171161007c578063f23a6e6111610057578063f23a6e61146104d2578063f6171e4414610517578063fc0c546a14610536575f80fd5b8063bdf8631714610472578063c7dec3fc14610487578063e00b9118146104b3575f80fd5b8063b0d691fe116100ac578063b0d691fe146103d1578063b94207d314610418578063bc197c811461042b575f80fd5b8063a035b1fe1461038a578063a4f9edbf1461039f578063affed0e0146103be575f80fd5b80633a871cdd116101315780636d70f7ae1161010c5780636d70f7ae146102fb5780637af734731461032a57806391b7f5ed1461036b575f80fd5b80633a871cdd1461028557806358ce0909146102a45780635fee6085146102d0575f80fd5b8063157305fe11610161578063157305fe146102255780631626ba7e1461024457806317d70f7c14610263575f80fd5b806223de2914610185578063150b7a02146101ab575f80fd5b3661018157005b5f80fd5b348015610190575f80fd5b506101a961019f366004611943565b5050505050505050565b005b3480156101b6575f80fd5b506101ef6101c53660046119ed565b7f150b7a020000000000000000000000000000000000000000000000000000000095945050505050565b6040517fffffffff0000000000000000000000000000000000000000000000000000000090911681526020015b60405180910390f35b348015610230575f80fd5b506101a961023f366004611b2f565b61054a565b34801561024f575f80fd5b506101ef61025e366004611b2f565b610771565b34801561026e575f80fd5b50610277610914565b60405190815260200161021c565b348015610290575f80fd5b5061027761029f366004611b73565b610938565b3480156102af575f80fd5b506102c36102be366004611bc2565b610974565b60405161021c9190611be2565b3480156102db575f80fd5b506102776102ea366004611c25565b60036020525f908152604090205481565b348015610306575f80fd5b5061031a610315366004611c25565b610ada565b604051901515815260200161021c565b348015610335575f80fd5b50610277610344366004611c25565b73ffffffffffffffffffffffffffffffffffffffff165f9081526003602052604090205490565b348015610376575f80fd5b506101a9610385366004611c40565b610bac565b348015610395575f80fd5b5061027760015481565b3480156103aa575f80fd5b506101a96103b9366004611c57565b610c9a565b3480156103c9575f80fd5b505f54610277565b3480156103dc575f80fd5b50730576a174d229e3cfa37253523e645a78a0c91b575b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161021c565b610277610426366004611c57565b610d16565b348015610436575f80fd5b506101ef610445366004611cd2565b7fbc197c810000000000000000000000000000000000000000000000000000000098975050505050505050565b34801561047d575f80fd5b5061027760025481565b348015610492575f80fd5b506104a66104a1366004611d68565b610e63565b60405161021c9190611e45565b3480156104be575f80fd5b506102776104cd366004611e57565b610f4d565b3480156104dd575f80fd5b506101ef6104ec366004611e8e565b7ff23a6e61000000000000000000000000000000000000000000000000000000009695505050505050565b348015610522575f80fd5b50610277610531366004611bc2565b610f9e565b348015610541575f80fd5b506103f3610fc0565b61055333610ada565b80610571575033730576a174d229e3cfa37253523e645a78a0c91b57145b610602576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603e60248201527f4f6e6c792063616c6c61626c6520627920746865206d656368206f706572617460448201527f6f72206f722074686520656e74727920706f696e7420636f6e7472616374000060648201526084015b60405180910390fd5b5f828152600460205260408082208151808301928390529160029082845b8154815260200190600101908083116106205750505050509050805f6002811061064c5761064c611f05565b602002015115801561066057506020810151155b801561069557505f805260046020527f17ef568e3e12ab5b9c7254a8d58478811de00f9e6eb34345acd53bf8fd09d3ed548314155b156106cf576040517ffe239804000000000000000000000000000000000000000000000000000000008152600481018490526024016105f9565b6020818101805183515f908152600490935260408084206001908101929092558451925184528084209290925585835290822082815501819055600280549161071783611f5f565b91905055503373ffffffffffffffffffffffffffffffffffffffff167f0cd979445339c62199996f208428d987b1cea24d18e62b79ec24d94b636e8b708484604051610764929190611f93565b60405180910390a2505050565b5f805f8061079185602081015160408201516060909201515f1a92909190565b9094509250905060ff81165f036108a757828583016020016107b282610ada565b1580156107d5575073ffffffffffffffffffffffffffffffffffffffff82163014155b1561080857507fffffffff00000000000000000000000000000000000000000000000000000000945061090e9350505050565b6040517f1626ba7e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff831690631626ba7e9061085c908b908590600401611f93565b602060405180830381865afa158015610877573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061089b9190611fab565b9550505050505061090e565b6108b661031587838686610fdd565b156108e757507f1626ba7e00000000000000000000000000000000000000000000000000000000925061090e915050565b507fffffffff00000000000000000000000000000000000000000000000000000000925050505b92915050565b5f8061091e610ff9565b8060200190518101906109319190611fea565b9392505050565b5f6109416110cd565b61094b848461114c565b905061095a6040850185612016565b90505f0361096b5761096b8461124c565b610931826112ca565b6002546060905f849003610986578093505b806109918486612077565b11156109de576109a18385612077565b6040517f7ae596850000000000000000000000000000000000000000000000000000000081526004810191909152602481018290526044016105f9565b8315610ad3578367ffffffffffffffff8111156109fd576109fd611a5b565b604051908082528060200260200182016040528015610a26578160200160208202803683370190505b505f80805260046020527f17ef568e3e12ab5b9c7254a8d58478811de00f9e6eb34345acd53bf8fd09d3ed549193505b84811015610a81575f828152600460205260409020600101549150610a7a8161208a565b9050610a56565b505f5b85811015610ad05781848281518110610a9f57610a9f611f05565b6020908102919091018101919091525f9283526004905260409091206001015490610ac98161208a565b9050610a84565b50505b5092915050565b5f805f610ae5610ff9565b806020019051810190610af89190611fea565b915091508373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16636352211e836040518263ffffffff1660e01b8152600401610b4e91815260200190565b602060405180830381865afa158015610b69573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610b8d91906120c1565b73ffffffffffffffffffffffffffffffffffffffff1614949350505050565b610bb533610ada565b80610bd3575033730576a174d229e3cfa37253523e645a78a0c91b57145b610c5f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603e60248201527f4f6e6c792063616c6c61626c6520627920746865206d656368206f706572617460448201527f6f72206f722074686520656e74727920706f696e7420636f6e7472616374000060648201526084016105f9565b60018190556040518181527f66cbca4f3c64fecf1dcb9ce094abcf7f68c3450a1d4e3a8e917dd621edb4ebe09060200160405180910390a150565b610ca2610ff9565b5115610d0a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f416c726561647920696e697469616c697a65640000000000000000000000000060448201526064016105f9565b610d138161133e565b50565b5f600154341015610d60576001546040517fb489782800000000000000000000000000000000000000000000000000000000815234600482015260248101919091526044016105f9565b610d6a3383610f4d565b335f908152600360205260408120805492935090610d878361208a565b909155505060046020525f81815260408082207f17ef568e3e12ab5b9c7254a8d58478811de00f9e6eb34345acd53bf8fd09d3ed80546001830181905590859055808452918320849055600280547f17ef568e3e12ab5b9c7254a8d58478811de00f9e6eb34345acd53bf8fd09d3ec94929392909190610e068361208a565b91905055503373ffffffffffffffffffffffffffffffffffffffff167f4bda649efe6b98b0f9c1d5e859c29e20910f45c66dabfe6fad4a4881f7faf9cc8587604051610e53929190611f93565b60405180910390a2505050919050565b6060610e6e33610ada565b80610e8c575033730576a174d229e3cfa37253523e645a78a0c91b57145b610f18576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603e60248201527f4f6e6c792063616c6c61626c6520627920746865206d656368206f706572617460448201527f6f72206f722074686520656e74727920706f696e7420636f6e7472616374000060648201526084016105f9565b5f610f32878787878715610f2c57876114b3565b5a6114b3565b9250905080610f4357815160208301fd5b5095945050505050565b5f8282604051602001610f619291906120dc565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291905280516020909101209392505050565b6004602052815f5260405f208160028110610fb7575f80fd5b01549150829050565b5f80610fca610ff9565b80602001905181019061090e91906120c1565b5f805f610fec878787876115b6565b91509150610f438161169e565b60606110c86110c36040517fd60000000000000000000000000000000000000000000000000000000000000060208201527f940000000000000000000000000000000000000000000000000000000000000060218201527fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003060601b1660228201527f010000000000000000000000000000000000000000000000000000000000000060368201525f90603701604051602081830303815290604052805190602001205f1c905090565b611850565b905090565b33730576a174d229e3cfa37253523e645a78a0c91b571461114a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f6163636f756e743a206e6f742066726f6d20456e747279506f696e740000000060448201526064016105f9565b565b5f806111a4836040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c81018290525f90605c01604051602081830303815290604052805190602001209050919050565b90507f1626ba7e00000000000000000000000000000000000000000000000000000000611212826111d9610140880188612016565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284375f9201919091525061077192505050565b7fffffffff00000000000000000000000000000000000000000000000000000000161461124357600191505061090e565b505f9392505050565b5f80546020830135918061125f8361208a565b9190505514610d13576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600d60248201527f496e76616c6964206e6f6e63650000000000000000000000000000000000000060448201526064016105f9565b8015610d13576040515f9033907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90849084818181858888f193505050503d805f8114611332576040519150601f19603f3d011682016040523d82523d5f602084013e611337565b606091505b5050505050565b5f611348826118a5565b90505f8151602083015ff0905061141a6040517fd60000000000000000000000000000000000000000000000000000000000000060208201527f940000000000000000000000000000000000000000000000000000000000000060218201527fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003060601b1660228201527f010000000000000000000000000000000000000000000000000000000000000060368201525f90603701604051602081830303815290604052805190602001205f1c905090565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146114ae576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f5772697465206661696c6564000000000000000000000000000000000000000060448201526064016105f9565b505050565b5f606060018460018111156114ca576114ca61210a565b0361153e578673ffffffffffffffffffffffffffffffffffffffff1683866040516114f59190612137565b5f604051808303818686f4925050503d805f811461152e576040519150601f19603f3d011682016040523d82523d5f602084013e611533565b606091505b5090925090506115ac565b8673ffffffffffffffffffffffffffffffffffffffff168387876040516115659190612137565b5f60405180830381858888f193505050503d805f81146115a0576040519150601f19603f3d011682016040523d82523d5f602084013e6115a5565b606091505b5090925090505b9550959350505050565b5f807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156115eb57505f90506003611695565b604080515f8082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa15801561163c573d5f803e3d5ffd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811661168f575f60019250925050611695565b91505f90505b94509492505050565b5f8160048111156116b1576116b161210a565b036116b95750565b60018160048111156116cd576116cd61210a565b03611734576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f45434453413a20696e76616c6964207369676e6174757265000000000000000060448201526064016105f9565b60028160048111156117485761174861210a565b036117af576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e6774680060448201526064016105f9565b60038160048111156117c3576117c361210a565b03610d13576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f756500000000000000000000000000000000000000000000000000000000000060648201526084016105f9565b6060813b6001811161187157505060408051602081019091525f8152919050565b8061187b81611f5f565b9150506040519150601f19601f602083010116820160405280825280600160208401853c50919050565b6060815160016118b59190612077565b826040516020016118c7929190612152565b6040516020818303038152906040529050919050565b73ffffffffffffffffffffffffffffffffffffffff81168114610d13575f80fd5b5f8083601f84011261190e575f80fd5b50813567ffffffffffffffff811115611925575f80fd5b60208301915083602082850101111561193c575f80fd5b9250929050565b5f805f805f805f8060c0898b03121561195a575f80fd5b8835611965816118dd565b97506020890135611975816118dd565b96506040890135611985816118dd565b955060608901359450608089013567ffffffffffffffff808211156119a8575f80fd5b6119b48c838d016118fe565b909650945060a08b01359150808211156119cc575f80fd5b506119d98b828c016118fe565b999c989b5096995094979396929594505050565b5f805f805f60808688031215611a01575f80fd5b8535611a0c816118dd565b94506020860135611a1c816118dd565b935060408601359250606086013567ffffffffffffffff811115611a3e575f80fd5b611a4a888289016118fe565b969995985093965092949392505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b5f82601f830112611a97575f80fd5b813567ffffffffffffffff80821115611ab257611ab2611a5b565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f01168101908282118183101715611af857611af8611a5b565b81604052838152866020858801011115611b10575f80fd5b836020870160208301375f602085830101528094505050505092915050565b5f8060408385031215611b40575f80fd5b82359150602083013567ffffffffffffffff811115611b5d575f80fd5b611b6985828601611a88565b9150509250929050565b5f805f60608486031215611b85575f80fd5b833567ffffffffffffffff811115611b9b575f80fd5b84016101608187031215611bad575f80fd5b95602085013595506040909401359392505050565b5f8060408385031215611bd3575f80fd5b50508035926020909101359150565b602080825282518282018190525f9190848201906040850190845b81811015611c1957835183529284019291840191600101611bfd565b50909695505050505050565b5f60208284031215611c35575f80fd5b8135610931816118dd565b5f60208284031215611c50575f80fd5b5035919050565b5f60208284031215611c67575f80fd5b813567ffffffffffffffff811115611c7d575f80fd5b611c8984828501611a88565b949350505050565b5f8083601f840112611ca1575f80fd5b50813567ffffffffffffffff811115611cb8575f80fd5b6020830191508360208260051b850101111561193c575f80fd5b5f805f805f805f8060a0898b031215611ce9575f80fd5b8835611cf4816118dd565b97506020890135611d04816118dd565b9650604089013567ffffffffffffffff80821115611d20575f80fd5b611d2c8c838d01611c91565b909850965060608b0135915080821115611d44575f80fd5b611d508c838d01611c91565b909650945060808b01359150808211156119cc575f80fd5b5f805f805f60a08688031215611d7c575f80fd5b8535611d87816118dd565b945060208601359350604086013567ffffffffffffffff811115611da9575f80fd5b611db588828901611a88565b935050606086013560028110611dc9575f80fd5b949793965091946080013592915050565b5f5b83811015611df4578181015183820152602001611ddc565b50505f910152565b5f8151808452611e13816020860160208601611dda565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081525f6109316020830184611dfc565b5f8060408385031215611e68575f80fd5b8235611e73816118dd565b9150602083013567ffffffffffffffff811115611b5d575f80fd5b5f805f805f8060a08789031215611ea3575f80fd5b8635611eae816118dd565b95506020870135611ebe816118dd565b94506040870135935060608701359250608087013567ffffffffffffffff811115611ee7575f80fd5b611ef389828a016118fe565b979a9699509497509295939492505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f81611f6d57611f6d611f32565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190565b828152604060208201525f611c896040830184611dfc565b5f60208284031215611fbb575f80fd5b81517fffffffff0000000000000000000000000000000000000000000000000000000081168114610931575f80fd5b5f8060408385031215611ffb575f80fd5b8251612006816118dd565b6020939093015192949293505050565b5f8083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112612049575f80fd5b83018035915067ffffffffffffffff821115612063575f80fd5b60200191503681900382131561193c575f80fd5b8082018082111561090e5761090e611f32565b5f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036120ba576120ba611f32565b5060010190565b5f602082840312156120d1575f80fd5b8151610931816118dd565b73ffffffffffffffffffffffffffffffffffffffff83168152604060208201525f611c896040830184611dfc565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b5f8251612148818460208701611dda565b9190910192915050565b7f630000000000000000000000000000000000000000000000000000000000000081527fffffffff000000000000000000000000000000000000000000000000000000008360e01b1660018201527f80600e6000396000f3000000000000000000000000000000000000000000000060058201525f600e8201525f82516121e081600f850160208701611dda565b91909101600f01939250505056fea2646970667358221220c1913351e275e1fecd00c79cd676ed135b575df5d3a88ccc57419dc3081980a264736f6c63430008150033", - "linkReferences": {}, - "deployedLinkReferences": {} -} \ No newline at end of file diff --git a/packages/valory/contracts/mech/contract.py b/packages/valory/contracts/mech/contract.py deleted file mode 100644 index 83929a02f..000000000 --- a/packages/valory/contracts/mech/contract.py +++ /dev/null @@ -1,352 +0,0 @@ -# -*- coding: utf-8 -*- -# ------------------------------------------------------------------------------ -# -# Copyright 2023-2024 Valory AG -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# ------------------------------------------------------------------------------ - -"""This module contains the class to connect to a Mech contract.""" -import concurrent.futures -from typing import Dict, Optional, cast, List, Any, Callable - -from aea.common import JSONLike -from aea.configurations.base import PublicId -from aea.contracts.base import Contract -from aea.crypto.base import LedgerApi -from aea_ledger_ethereum import EthereumApi -from eth_typing import HexStr -from web3.types import TxReceipt, EventData, BlockIdentifier, BlockData - -PUBLIC_ID = PublicId.from_str("valory/mech:0.1.0") -FIVE_MINUTES = 300.0 - - -partial_abis = [ - [ - { - "anonymous": False, - "inputs": [ - { - "indexed": False, - "internalType": "uint256", - "name": "requestId", - "type": "uint256", - }, - { - "indexed": False, - "internalType": "bytes", - "name": "data", - "type": "bytes", - }, - ], - "name": "Deliver", - "type": "event", - }, - { - "anonymous": False, - "inputs": [ - { - "indexed": True, - "internalType": "address", - "name": "sender", - "type": "address", - }, - { - "indexed": False, - "internalType": "uint256", - "name": "requestId", - "type": "uint256", - }, - { - "indexed": False, - "internalType": "bytes", - "name": "data", - "type": "bytes", - }, - ], - "name": "Request", - "type": "event", - }, - ], - [ - { - "anonymous": False, - "inputs": [ - { - "indexed": True, - "internalType": "address", - "name": "sender", - "type": "address", - }, - { - "indexed": False, - "internalType": "uint256", - "name": "requestId", - "type": "uint256", - }, - { - "indexed": False, - "internalType": "uint256", - "name": "requestIdWithNonce", - "type": "uint256", - }, - { - "indexed": False, - "internalType": "bytes", - "name": "data", - "type": "bytes", - }, - ], - "name": "Request", - "type": "event", - }, - { - "anonymous": False, - "inputs": [ - { - "indexed": True, - "internalType": "address", - "name": "sender", - "type": "address", - }, - { - "indexed": False, - "internalType": "uint256", - "name": "requestId", - "type": "uint256", - }, - { - "indexed": False, - "internalType": "bytes", - "name": "data", - "type": "bytes", - }, - ], - "name": "Deliver", - "type": "event", - }, - ], -] - - -class Mech(Contract): - """The Mech contract.""" - - contract_id = PUBLIC_ID - - @staticmethod - def execute_with_timeout(func: Callable, timeout: float) -> Any: - """Execute a function with a timeout.""" - - # Create a ProcessPoolExecutor with a maximum of 1 worker (process) - with concurrent.futures.ThreadPoolExecutor(max_workers=1) as executor: - # Submit the function to the executor - future = executor.submit( - func, - ) - - try: - # Wait for the result with a 5-minute timeout - data = future.result(timeout=timeout) - except TimeoutError: - # Handle the case where the execution times out - err = f"The RPC didn't respond in {timeout}." - return None, err - - # Check if an error occurred - if isinstance(data, str): - # Handle the case where the execution failed - return None, data - - return data, None - - @classmethod - def get_price( - cls, - ledger_api: EthereumApi, - contract_address: str, - ) -> JSONLike: - """Get the price of a request.""" - contract_instance = cls.get_instance(ledger_api, contract_address) - price = ledger_api.contract_method_call(contract_instance, "price") - return dict(price=price) - - @classmethod - def get_request_data( - cls, - ledger_api: LedgerApi, - contract_address: str, - request_data: bytes, - ) -> Dict[str, bytes]: - """Gets the encoded arguments for a request tx, which should only be called via the multisig. - - :param ledger_api: the ledger API object - :param contract_address: the contract's address - :param request_data: the request data - """ - contract_instance = cls.get_instance(ledger_api, contract_address) - encoded_data = contract_instance.encodeABI("request", args=(request_data,)) - return {"data": bytes.fromhex(encoded_data[2:])} - - @classmethod - def _process_event( - cls, - ledger_api: LedgerApi, - contract: Any, - tx_hash: HexStr, - event_name: str, - *args: Any, - ) -> Optional[JSONLike]: - """Process the logs of the given event.""" - ledger_api = cast(EthereumApi, ledger_api) - receipt: TxReceipt = ledger_api.api.eth.get_transaction_receipt(tx_hash) - event_method = getattr(contract.events, event_name) - logs: List[EventData] = list(event_method().process_receipt(receipt)) - - n_logs = len(logs) - if n_logs != 1: - error = f"A single {event_name!r} event was expected. tx {tx_hash} emitted {n_logs} instead." - return {"error": error} - - log = logs.pop() - event_args = log.get("args", None) - if event_args is None or any( - expected_key not in event_args for expected_key in args - ): - error = f"The emitted event's ({event_name!r}) log for tx {tx_hash} do not match the expected format: {log}" - return {"error": error} - - return {arg_name: event_args[arg_name] for arg_name in args} - - @classmethod - def process_request_event( - cls, - ledger_api: LedgerApi, - contract_address: str, - tx_hash: HexStr, - ) -> Optional[JSONLike]: - """ - Process the request receipt to get the requestId and the given data from the `Request` event's logs. - - :param ledger_api: the ledger apis. - :param contract_address: the contract address. - :param tx_hash: the hash of a request tx to be processed. - :return: a dictionary with the request id. - """ - res = {} - for abi in partial_abis: - contract_instance = ledger_api.api.eth.contract(contract_address, abi=abi) - res = cls._process_event( - ledger_api, contract_instance, tx_hash, "Request", "requestId", "data" - ) - if "error" not in res: - return res - - return res - - @classmethod - def process_deliver_event( - cls, - ledger_api: LedgerApi, - contract_address: str, - tx_hash: HexStr, - ) -> Optional[JSONLike]: - """ - Process the request receipt to get the requestId and the delivered data if the `Deliver` event has been emitted. - - :param ledger_api: the ledger apis. - :param contract_address: the contract address. - :param tx_hash: the hash of a request tx to be processed. - :return: a dictionary with the request id and the data. - """ - res = {} - for abi in partial_abis: - contract_instance = ledger_api.api.eth.contract(contract_address, abi=abi) - res = cls._process_event( - ledger_api, contract_instance, tx_hash, "Deliver", "requestId", "data" - ) - if "error" not in res: - return res - - return res - - @classmethod - def get_block_number( - cls, - ledger_api: EthereumApi, - contract_address: str, - tx_hash: HexStr, - ) -> JSONLike: - """Get the number of the block in which the tx of the given hash was settled.""" - receipt: TxReceipt = ledger_api.api.eth.get_transaction_receipt(tx_hash) - block: BlockData = ledger_api.api.eth.get_block(receipt["blockNumber"]) - return dict(number=block["number"]) - - @classmethod - def get_response( - cls, - ledger_api: LedgerApi, - contract_address: str, - request_id: int, - from_block: BlockIdentifier = "earliest", - to_block: BlockIdentifier = "latest", - timeout: float = FIVE_MINUTES, - ) -> JSONLike: - """Filter the `Deliver` events emitted by the contract and get the data of the given `request_id`.""" - def get_responses() -> Any: - """Get the responses from the contract.""" - contract_instance = cls.get_instance(ledger_api, contract_address) - deliver_filter = contract_instance.events.Deliver.build_filter() - deliver_filter.fromBlock = from_block - deliver_filter.toBlock = to_block - deliver_filter.args.requestId.match_single(request_id) - delivered = list(deliver_filter.deploy(ledger_api.api).get_all_entries()) - n_delivered = len(delivered) - - if n_delivered == 0: - info = f"The mech ({contract_address}) has not delivered a response yet for request with id {request_id}." - return {"info": info} - - if n_delivered != 1: - error = ( - f"A single response was expected by the mech ({contract_address}) for request with id {request_id}. " - f"Received {n_delivered} responses: {delivered}." - ) - return error - - delivered_event = delivered.pop() - deliver_args = delivered_event.get("args", None) - if deliver_args is None or "data" not in deliver_args: - error = f"The mech's response does not match the expected format: {delivered_event}" - return error - - return {"data": deliver_args["data"]} - - data, err = cls.execute_with_timeout(get_responses, timeout=timeout) - if err is not None: - return {"error": err} - - return data - - @classmethod - def get_mech_id( - cls, - ledger_api: EthereumApi, - contract_address: str, - ) -> JSONLike: - """Get the price of a request.""" - contract_instance = cls.get_instance(ledger_api, contract_address) - mech_id = ledger_api.contract_method_call(contract_instance, "tokenId") - return dict(id=mech_id) diff --git a/packages/valory/contracts/mech/contract.yaml b/packages/valory/contracts/mech/contract.yaml deleted file mode 100644 index 87aa80717..000000000 --- a/packages/valory/contracts/mech/contract.yaml +++ /dev/null @@ -1,23 +0,0 @@ -name: mech -author: valory -version: 0.1.0 -type: contract -description: Agent mech contract -license: Apache-2.0 -aea_version: '>=1.0.0, <2.0.0' -fingerprint: - README.md: bafybeibl4uw7rs6mwh7zuvdnqmj2o2xyr7nx5qk3w7torwx3jg6farn6ca - __init__.py: bafybeicx5pxh3cxnml2biuuoebvafvu5tvy6mgkzyjzuubuoeebb5yzjsm - build/mech.json: bafybeia3zf47nhljgahe4ijvw6mfcswhn6r5ntw572y63hbse7bvgsydaq - contract.py: bafybeiexgja3hf2b3zyqjtelzzhv2vvtj655ivrzszkwqarhrapl6gfxim -fingerprint_ignore_patterns: [] -contracts: [] -class_name: Mech -contract_interface_paths: - ethereum: build/mech.json -dependencies: - open-aea-ledger-ethereum: - version: ==1.50.0 - web3: - version: <7,>=6.0.0 - eth_typing: {} diff --git a/packages/valory/services/trader/service.yaml b/packages/valory/services/trader/service.yaml index a42959c19..e2dad64cc 100644 --- a/packages/valory/services/trader/service.yaml +++ b/packages/valory/services/trader/service.yaml @@ -7,7 +7,7 @@ license: Apache-2.0 fingerprint: README.md: bafybeigtuothskwyvrhfosps2bu6suauycolj67dpuxqvnicdrdu7yhtvq fingerprint_ignore_patterns: [] -agent: valory/trader:0.1.0:bafybeid7u2back4fs6tjg2xreuuoxffhyts7zqnopkaf33727nnudb4zhu +agent: valory/trader:0.1.0:bafybeib2gnqwi5mmlz3efkzlahgwunpwt75nhpsvitllllnet5zu7jtb5u number_of_agents: 4 deployment: {} --- @@ -47,6 +47,7 @@ type: skill max_attempts: ${MAX_ATTEMPTS:int:10} max_healthcheck: ${MAX_HEALTHCHECK:int:120} multisend_address: ${MULTISEND_ADDRESS:str:0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761} + multisend_batch_size: ${MULTISEND_BATCH_SIZE:int:1} on_chain_service_id: ${ON_CHAIN_SERVICE_ID:int:null} reset_tendermint_after: ${RESET_TM_AFTER:int:2} retry_attempts: ${RETRY_ATTEMPTS:int:400} @@ -78,7 +79,8 @@ type: skill languages: ${LANGUAGES:list:["en_US"]} average_block_time: ${ABT:int:5} abt_error_mult: ${ABT_ERROR_MULT:int:5} - mech_agent_address: ${MECH_AGENT_ADDRESS:str:0xff82123dfb52ab75c417195c5fdb87630145ae81} + mech_contract_address: ${MECH_CONTRACT_ADDRESS:str:0x77af31de935740567cf4ff1986d04b2c964a786a} + request_price: ${REQUEST_PRICE:int:null} sample_bets_closing_days: ${SAMPLE_BETS_CLOSING_DAYS:int:10} trading_strategy: ${TRADING_STRATEGY:str:kelly_criterion} use_fallback_strategy: ${USE_FALLBACK_STRATEGY:bool:true} @@ -143,6 +145,7 @@ type: skill max_attempts: ${MAX_ATTEMPTS:int:10} max_healthcheck: ${MAX_HEALTHCHECK:int:120} multisend_address: ${MULTISEND_ADDRESS:str:0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761} + multisend_batch_size: ${MULTISEND_BATCH_SIZE:int:1} on_chain_service_id: ${ON_CHAIN_SERVICE_ID:int:null} reset_tendermint_after: ${RESET_TM_AFTER:int:2} retry_attempts: ${RETRY_ATTEMPTS:int:400} @@ -173,7 +176,8 @@ type: skill languages: ${LANGUAGES:list:["en_US"]} average_block_time: ${ABT:int:5} abt_error_mult: ${ABT_ERROR_MULT:int:5} - mech_agent_address: ${MECH_AGENT_ADDRESS:str:0xff82123dfb52ab75c417195c5fdb87630145ae81} + mech_contract_address: ${MECH_CONTRACT_ADDRESS:str:0x77af31de935740567cf4ff1986d04b2c964a786a} + request_price: ${REQUEST_PRICE:int:null} sample_bets_closing_days: ${SAMPLE_BETS_CLOSING_DAYS:int:10} trading_strategy: ${TRADING_STRATEGY:str:kelly_criterion} use_fallback_strategy: ${USE_FALLBACK_STRATEGY:bool:true} @@ -236,6 +240,7 @@ type: skill max_attempts: ${MAX_ATTEMPTS:int:10} max_healthcheck: ${MAX_HEALTHCHECK:int:120} multisend_address: ${MULTISEND_ADDRESS:str:0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761} + multisend_batch_size: ${MULTISEND_BATCH_SIZE:int:1} on_chain_service_id: ${ON_CHAIN_SERVICE_ID:int:null} reset_tendermint_after: ${RESET_TM_AFTER:int:2} retry_attempts: ${RETRY_ATTEMPTS:int:400} @@ -266,7 +271,8 @@ type: skill languages: ${LANGUAGES:list:["en_US"]} average_block_time: ${ABT:int:5} abt_error_mult: ${ABT_ERROR_MULT:int:5} - mech_agent_address: ${MECH_AGENT_ADDRESS:str:0xff82123dfb52ab75c417195c5fdb87630145ae81} + mech_contract_address: ${MECH_CONTRACT_ADDRESS:str:0x77af31de935740567cf4ff1986d04b2c964a786a} + request_price: ${REQUEST_PRICE:int:null} sample_bets_closing_days: ${SAMPLE_BETS_CLOSING_DAYS:int:10} trading_strategy: ${TRADING_STRATEGY:str:kelly_criterion} use_fallback_strategy: ${USE_FALLBACK_STRATEGY:bool:true} @@ -329,6 +335,7 @@ type: skill max_attempts: ${MAX_ATTEMPTS:int:10} max_healthcheck: ${MAX_HEALTHCHECK:int:120} multisend_address: ${MULTISEND_ADDRESS:str:0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761} + multisend_batch_size: ${MULTISEND_BATCH_SIZE:int:1} on_chain_service_id: ${ON_CHAIN_SERVICE_ID:int:null} reset_tendermint_after: ${RESET_TM_AFTER:int:2} retry_attempts: ${RETRY_ATTEMPTS:int:400} @@ -359,7 +366,8 @@ type: skill languages: ${LANGUAGES:list:["en_US"]} average_block_time: ${ABT:int:5} abt_error_mult: ${ABT_ERROR_MULT:int:5} - mech_agent_address: ${MECH_AGENT_ADDRESS:str:0xff82123dfb52ab75c417195c5fdb87630145ae81} + mech_contract_address: ${MECH_CONTRACT_ADDRESS:str:0x77af31de935740567cf4ff1986d04b2c964a786a} + request_price: ${REQUEST_PRICE:int:null} sample_bets_closing_days: ${SAMPLE_BETS_CLOSING_DAYS:int:10} trading_strategy: ${TRADING_STRATEGY:str:kelly_criterion} use_fallback_strategy: ${USE_FALLBACK_STRATEGY:bool:true} diff --git a/packages/valory/skills/decision_maker_abci/behaviours/base.py b/packages/valory/skills/decision_maker_abci/behaviours/base.py index d46268aed..36784a714 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/base.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/base.py @@ -468,7 +468,7 @@ def _mech_contract_interact( """Interact with the mech contract.""" status = yield from self.contract_interact( performative=ContractApiMessage.Performative.GET_RAW_TRANSACTION, # type: ignore - contract_address=self.params.mech_agent_address, + contract_address=self.params.mech_contract_address, contract_public_id=Mech.contract_id, contract_callable=contract_callable, data_key=data_key, diff --git a/packages/valory/skills/decision_maker_abci/behaviours/decision_receive.py b/packages/valory/skills/decision_maker_abci/behaviours/decision_receive.py index e363d5f5a..55d061ede 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/decision_receive.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/decision_receive.py @@ -19,31 +19,26 @@ """This module contains the behaviour for the decision-making of the skill.""" +import json from math import prod from typing import Any, Generator, Optional, Tuple, Union -from packages.valory.contracts.mech.contract import Mech -from packages.valory.protocols.contract_api import ContractApiMessage -from packages.valory.skills.abstract_round_abci.base import get_name from packages.valory.skills.decision_maker_abci.behaviours.base import ( - CID_PREFIX, DecisionMakerBaseBehaviour, - WaitableConditionType, remove_fraction_wei, ) from packages.valory.skills.decision_maker_abci.io_.loader import ComponentPackageLoader -from packages.valory.skills.decision_maker_abci.models import ( - MechInteractionResponse, - MechResponseSpecs, -) +from packages.valory.skills.decision_maker_abci.models import PredictionResponse from packages.valory.skills.decision_maker_abci.payloads import DecisionReceivePayload from packages.valory.skills.decision_maker_abci.states.decision_receive import ( DecisionReceiveRound, ) from packages.valory.skills.market_manager_abci.bets import BINARY_N_SLOTS, Bet +from packages.valory.skills.mech_interact_abci.states.base import ( + MechInteractionResponse, +) -ZERO_ADDRESS = "0x0000000000000000000000000000000000000000" SLIPPAGE = 1.05 @@ -55,21 +50,9 @@ class DecisionReceiveBehaviour(DecisionMakerBaseBehaviour): def __init__(self, **kwargs: Any) -> None: """Initialize Behaviour.""" super().__init__(**kwargs, loader_cls=ComponentPackageLoader) - self._from_block: int = 0 self._request_id: int = 0 - self._response_hex: str = "" self._mech_response: Optional[MechInteractionResponse] = None - @property - def from_block(self) -> int: - """Get the block number in which the request to the mech was settled.""" - return self._from_block - - @from_block.setter - def from_block(self, from_block: int) -> None: - """Set the block number in which the request to the mech was settled.""" - self._from_block = from_block - @property def request_id(self) -> int: """Get the request id.""" @@ -84,34 +67,6 @@ def request_id(self, request_id: Union[str, int]) -> None: msg = f"Request id {request_id} is not a valid integer!" self.context.logger.error(msg) - @property - def response_hex(self) -> str: - """Get the hash of the response data.""" - return self._response_hex - - @response_hex.setter - def response_hex(self, response_hash: bytes) -> None: - """Set the hash of the response data.""" - try: - self._response_hex = response_hash.hex() - except AttributeError: - msg = f"Response hash {response_hash!r} is not valid hex bytes!" - self.context.logger.error(msg) - - @property - def mech_response_api(self) -> MechResponseSpecs: - """Get the mech response api specs.""" - return self.context.mech_response - - def set_mech_response_specs(self) -> None: - """Set the mech's response specs.""" - full_ipfs_hash = CID_PREFIX + self.response_hex - ipfs_link = self.params.ipfs_address + full_ipfs_hash + f"/{self.request_id}" - # The url must be dynamically generated as it depends on the ipfs hash - self.mech_response_api.__dict__["_frozen"] = False - self.mech_response_api.url = ipfs_link - self.mech_response_api.__dict__["_frozen"] = True - @property def mech_response(self) -> MechInteractionResponse: """Get the mech's response.""" @@ -120,104 +75,20 @@ def mech_response(self) -> MechInteractionResponse: return MechInteractionResponse(error=error) return self._mech_response - def _get_block_number(self) -> WaitableConditionType: - """Get the block number in which the request to the mech was settled.""" - result = yield from self.contract_interact( - performative=ContractApiMessage.Performative.GET_RAW_TRANSACTION, # type: ignore - # we do not need the address to get the block number, but the base method does - contract_address=ZERO_ADDRESS, - contract_public_id=Mech.contract_id, - contract_callable="get_block_number", - data_key="number", - placeholder=get_name(DecisionReceiveBehaviour.from_block), - tx_hash=self.synchronized_data.final_tx_hash, - ) - - return result - - def _get_request_id(self) -> WaitableConditionType: - """Get the request id.""" - result = yield from self._mech_contract_interact( - contract_callable="process_request_event", - data_key="requestId", - placeholder=get_name(DecisionReceiveBehaviour.request_id), - tx_hash=self.synchronized_data.final_tx_hash, - ) - return result - - def _get_response_hash(self) -> WaitableConditionType: - """Get the hash of the response data.""" - self.context.logger.info( - f"Filtering the mech's events from block {self.from_block} " - f"for a response to our request with id {self.request_id!r}." - ) - result = yield from self._mech_contract_interact( - contract_callable="get_response", - data_key="data", - placeholder=get_name(DecisionReceiveBehaviour.response_hex), - request_id=self.request_id, - from_block=self.from_block, - timeout=self.params.contract_timeout, - ) - - if result: - self.set_mech_response_specs() - - return result - - def _handle_response( - self, - res: Optional[str], - ) -> Optional[Any]: - """Handle the response from the IPFS. - - :param res: the response to handle. - :return: the response's result, using the given keys. `None` if response is `None` (has failed). - """ - if res is None: - msg = f"Could not get the mech's response from {self.mech_response_api.api_id}" - self.context.logger.error(msg) - self.mech_response_api.increment_retries() - return None - - self.context.logger.info(f"Retrieved the mech's response: {res}.") - self.mech_response_api.reset_retries() - return res - - def _get_response(self) -> WaitableConditionType: - """Get the response data from IPFS.""" - specs = self.mech_response_api.get_spec() - res_raw = yield from self.get_http_response(**specs) - res = self.mech_response_api.process_response(res_raw) - res = self._handle_response(res) - - if self.mech_response_api.is_retries_exceeded(): - error = "Retries were exceeded while trying to get the mech's response." + def _get_response(self) -> None: + """Get the response data.""" + mech_responses = self.synchronized_data.mech_responses + if not mech_responses: + error = "No Mech responses in synchronized_data." self._mech_response = MechInteractionResponse(error=error) - return True - - if res is None: - return False - - try: - self._mech_response = MechInteractionResponse(**res) - except (ValueError, TypeError, KeyError): - self._mech_response = MechInteractionResponse.incorrect_format(res) - return True + self._mech_response = mech_responses[0] def _get_decision( self, - ) -> Generator[None, None, Tuple[Optional[int], Optional[float], Optional[float]]]: + ) -> Tuple[Optional[int], Optional[float], Optional[float]]: """Get vote, win probability and confidence.""" - for step in ( - self._get_block_number, - self._get_request_id, - self._get_response_hash, - self._get_response, - ): - yield from self.wait_for_condition_with_sleep(step) - + self._get_response() self.context.logger.info(f"Decision has been received:\n{self.mech_response}") if self.mech_response.result is None: self.context.logger.error( @@ -225,10 +96,16 @@ def _get_decision( ) return None, None, None + try: + result = PredictionResponse(**json.loads(self.mech_response.result)) + except (json.JSONDecodeError, ValueError) as exc: + self.context.logger.error(f"Could not parse the mech's response: {exc}") + return None, None, None + return ( - self.mech_response.result.vote, - self.mech_response.result.win_probability, - self.mech_response.result.confidence, + result.vote, + result.win_probability, + result.confidence, ) @staticmethod @@ -362,7 +239,7 @@ def async_act(self) -> Generator: """Do the action.""" with self.context.benchmark_tool.measure(self.behaviour_id).local(): - vote, win_probability, confidence = yield from self._get_decision() + vote, win_probability, confidence = self._get_decision() is_profitable = None bet_amount = None if ( diff --git a/packages/valory/skills/decision_maker_abci/behaviours/decision_request.py b/packages/valory/skills/decision_maker_abci/behaviours/decision_request.py index 30cf628b7..06e418f8b 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/decision_request.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/decision_request.py @@ -19,55 +19,20 @@ """This module contains the behaviour of the skill which is responsible for requesting a decision from the mech.""" -from dataclasses import asdict, dataclass, field -from pathlib import Path -from tempfile import mkdtemp -from typing import Any, Dict, Generator, Optional, cast +import json +from dataclasses import asdict +from typing import Any, Dict, Generator, Optional from uuid import uuid4 -import multibase -import multicodec -from aea.helpers.cid import to_v1 -from hexbytes import HexBytes - -from packages.valory.contracts.erc20.contract import ERC20 -from packages.valory.contracts.gnosis_safe.contract import GnosisSafeContract -from packages.valory.contracts.transfer_nft_condition.contract import ( - TransferNftCondition, -) -from packages.valory.protocols.contract_api import ContractApiMessage -from packages.valory.skills.abstract_round_abci.base import get_name -from packages.valory.skills.abstract_round_abci.io_.store import SupportedFiletype from packages.valory.skills.decision_maker_abci.behaviours.base import ( DecisionMakerBaseBehaviour, - SAFE_GAS, - WXDAI, - WaitableConditionType, ) -from packages.valory.skills.decision_maker_abci.models import MultisendBatch -from packages.valory.skills.decision_maker_abci.payloads import RequestPayload +from packages.valory.skills.decision_maker_abci.payloads import DecisionRequestPayload from packages.valory.skills.decision_maker_abci.states.decision_request import ( DecisionRequestRound, ) from packages.valory.skills.market_manager_abci.bets import BINARY_N_SLOTS -from packages.valory.skills.transaction_settlement_abci.payload_tools import ( - hash_payload_to_hex, -) - - -METADATA_FILENAME = "metadata.json" -V1_HEX_PREFIX = "f01" -Ox = "0x" -APPROVE_MECH = True - - -@dataclass -class MechMetadata: - """A Mech's metadata.""" - - prompt: str - tool: str - nonce: str = field(default_factory=lambda: str(uuid4())) +from packages.valory.skills.mech_interact_abci.states.base import MechMetadata class DecisionRequestBehaviour(DecisionMakerBaseBehaviour): @@ -79,55 +44,17 @@ def __init__(self, **kwargs: Any) -> None: """Initialize Behaviour.""" super().__init__(**kwargs) self._metadata: Optional[MechMetadata] = None - self._v1_hex_truncated: str = "" - self._request_data: bytes = b"" - self._price: int = 0 - - @property - def metadata_filepath(self) -> str: - """Get the filepath to the metadata.""" - return str(Path(mkdtemp()) / METADATA_FILENAME) @property def metadata(self) -> Dict[str, str]: """Get the metadata as a dictionary.""" return asdict(self._metadata) - @property - def request_data(self) -> bytes: - """Get the request data.""" - return self._request_data - - @request_data.setter - def request_data(self, data: bytes) -> None: - """Set the request data.""" - self._request_data = data - - @property - def price(self) -> int: - """Get the price.""" - return self._price - - @price.setter - def price(self, price: int) -> None: - """Set the price.""" - self._price = price - @property def n_slots_supported(self) -> bool: """Whether the behaviour supports the current number of slots as it currently only supports binary decisions.""" return self.params.slot_count == BINARY_N_SLOTS - @property - def xdai_deficit(self) -> int: - """Get the amount of missing xDAI for sending the request.""" - return self.price - self.wallet_balance - - @property - def multisend_optional(self) -> bool: - """Whether a multisend transaction does not need to be prepared.""" - return len(self.multisend_batches) == 0 - def setup(self) -> None: """Setup behaviour.""" if not self.n_slots_supported: @@ -139,240 +66,18 @@ def setup(self) -> None: ) prompt = self.params.prompt_template.substitute(prompt_params) tool = self.synchronized_data.mech_tool - self._metadata = MechMetadata(prompt, tool) + nonce = str(uuid4()) + self._metadata = MechMetadata(prompt, tool, nonce) msg = f"Prepared metadata {self.metadata!r} for the request." self.context.logger.info(msg) - def _send_metadata_to_ipfs( - self, - ) -> WaitableConditionType: - """Send Mech metadata to IPFS.""" - metadata_hash = yield from self.send_to_ipfs( - self.metadata_filepath, self.metadata, filetype=SupportedFiletype.JSON - ) - if metadata_hash is None: - return False - - v1_file_hash = to_v1(metadata_hash) - cid_bytes = cast(bytes, multibase.decode(v1_file_hash)) - multihash_bytes = multicodec.remove_prefix(cid_bytes) - v1_file_hash_hex = V1_HEX_PREFIX + multihash_bytes.hex() - ipfs_link = self.params.ipfs_address + v1_file_hash_hex - self.context.logger.info(f"Prompt uploaded: {ipfs_link}") - self._v1_hex_truncated = Ox + v1_file_hash_hex[9:] - return True - - def _get_price(self) -> WaitableConditionType: - """Get the price of the mech request.""" - if self.params.use_nevermined: - # when we use nevermined, we don't need to pay for the mech request - return True - result = yield from self._mech_contract_interact( - "get_price", "price", get_name(DecisionRequestBehaviour.price) - ) - return result - - def _is_approved_for_all(self) -> Generator[None, None, Optional[bool]]: - """Check whether the mech is approved to spend the mech subscription.""" - response_msg = yield from self.get_contract_api_response( - performative=ContractApiMessage.Performative.GET_STATE, # type: ignore - contract_address=self.token_address, - contract_id=str(TransferNftCondition.contract_id), - contract_callable="is_approved_for_all", - account=self.synchronized_data.safe_contract_address, - operator=self.params.mech_agent_address, - ) - if response_msg.performative != ContractApiMessage.Performative.STATE: - self.context.logger.info( - f"Could not get `TransferNftCondition.is_approved_for_all`: {response_msg}" - ) - return None - - return response_msg.state.body.get("data") - - def _check_nevermined_subscription(self) -> WaitableConditionType: - """Approve the mech to spend the mech subscription.""" - if not self.params.use_nevermined: - # do nothing if we don't use nevermined - return True - - is_approved_for_all = yield from self._is_approved_for_all() - if is_approved_for_all is None: - # something went wrong when checking the mech approval - return False - if is_approved_for_all: - # the mech is already approved to spend the mech subscription - self.context.logger.info( - "The mech is already approved to spend the mech subscription." - ) - return True - - response_msg = yield from self.get_contract_api_response( - performative=ContractApiMessage.Performative.GET_STATE, # type: ignore - contract_address=self.token_address, - contract_id=str(TransferNftCondition.contract_id), - contract_callable="build_set_approval_for_all_tx", - operator=self.params.mech_agent_address, - approved=APPROVE_MECH, - ) - - if response_msg.performative != ContractApiMessage.Performative.STATE: - self.context.logger.info(f"Could not build withdraw tx: {response_msg}") - return False - - data = response_msg.state.body.get("data") - if data is None: - self.context.logger.info(f"Could not build withdraw tx: {response_msg}") - return False - - batch = MultisendBatch( - to=self.token_address, - data=HexBytes(data), - ) - self.multisend_batches.append(batch) - return True - - def _build_unwrap_tx(self) -> WaitableConditionType: - """Exchange wxDAI to xDAI.""" - response_msg = yield from self.get_contract_api_response( - performative=ContractApiMessage.Performative.GET_STATE, # type: ignore - contract_address=WXDAI, - contract_id=str(ERC20.contract_id), - contract_callable="build_withdraw_tx", - amount=self.xdai_deficit, - ) - - if response_msg.performative != ContractApiMessage.Performative.STATE: - self.context.logger.info(f"Could not build withdraw tx: {response_msg}") - return False - - withdraw_data = response_msg.state.body.get("data") - if withdraw_data is None: - self.context.logger.info(f"Could not build withdraw tx: {response_msg}") - return False - - batch = MultisendBatch( - to=self.collateral_token, - data=HexBytes(withdraw_data), - ) - self.multisend_batches.append(batch) - return True - - def _check_unwrap(self) -> WaitableConditionType: - """Check whether the payment for the mech request is possible and unwrap some wxDAI if needed.""" - yield from self.wait_for_condition_with_sleep(self.check_balance) - missing = self.xdai_deficit - if missing <= 0: - return True - - # if the collateral token is wxDAI, subtract the wxDAI balance from the xDAI that is missing for paying the mech - if self.is_wxdai: - missing -= self.token_balance - - # if we can cover the required amount by unwrapping some wxDAI, proceed to add this to a multisend tx - if missing <= 0: - yield from self.wait_for_condition_with_sleep(self._build_unwrap_tx) - return True - - balance_info = "The balance is not enough to pay for the mech's price" - refill_info = f". Please refill the safe with at least {self.wei_to_native(missing)} xDAI or wxDAI." - if not self.params.using_kelly: - balance_info += " and place the maximum bet amount" - refill_info += ( - " Alternatively, you could decrease the configured bet amounts." - ) - self.context.logger.warning(balance_info + refill_info) - self.sleep(self.params.sleep_time) - return False - - def _build_request_data(self) -> Generator[None, None, bool]: - """Get the request tx data encoded.""" - result = yield from self._mech_contract_interact( - "get_request_data", - "data", - get_name(DecisionRequestBehaviour.request_data), - request_data=self._v1_hex_truncated, - ) - - if not result: - return False - - if self.multisend_optional: - return True - - batch = MultisendBatch( - to=self.params.mech_agent_address, - data=HexBytes(self.request_data), - value=self.price, - ) - self.multisend_batches.append(batch) - return True - - def _get_safe_tx_hash(self) -> Generator[None, None, bool]: - """Prepares and returns the safe tx hash.""" - status = yield from self.contract_interact( - performative=ContractApiMessage.Performative.GET_RAW_TRANSACTION, # type: ignore - contract_address=self.synchronized_data.safe_contract_address, - contract_public_id=GnosisSafeContract.contract_id, - contract_callable="get_raw_safe_transaction_hash", - to_address=self.params.mech_agent_address, - value=self.price, - data=self.request_data, - data_key="tx_hash", - placeholder=get_name(DecisionRequestBehaviour.safe_tx_hash), - ) - return status - - def _single_tx(self) -> Generator[None, None, str]: - """Prepare a hex for a single transaction.""" - yield from self.wait_for_condition_with_sleep(self._get_safe_tx_hash) - return hash_payload_to_hex( - self.safe_tx_hash, - self.price, - SAFE_GAS, - self.params.mech_agent_address, - self.request_data, - ) - - def _multisend_tx(self) -> Generator[None, None, str]: - """Prepare a hex for a multisend transaction.""" - for step in ( - self._build_multisend_data, - self._build_multisend_safe_tx_hash, - ): - yield from self.wait_for_condition_with_sleep(step) - - tx_hex = self.tx_hex - if tx_hex is None: - raise ValueError("The multisend transaction was not prepared properly.") - return tx_hex - - def _prepare_safe_tx(self) -> Generator[None, None, str]: - """Prepare the safe transaction for sending a request to mech and return the hex for the tx settlement skill.""" - for step in ( - self._send_metadata_to_ipfs, - self._get_price, - self._check_unwrap, - self._check_nevermined_subscription, - self._build_request_data, - ): - yield from self.wait_for_condition_with_sleep(step) - - if self.multisend_optional: - tx_hex = yield from self._single_tx() - else: - tx_hex = yield from self._multisend_tx() - - return tx_hex - def async_act(self) -> Generator: """Do the action.""" with self.context.benchmark_tool.measure(self.behaviour_id).local(): - tx_submitter = mech_tx_hex = price = None - if self.n_slots_supported: - tx_submitter = self.matching_round.auto_round_id() - mech_tx_hex = yield from self._prepare_safe_tx() - price = self.price + payload_content = None + if self._metadata and self.n_slots_supported: + mech_requests = [self.metadata] + payload_content = json.dumps(mech_requests, sort_keys=True) agent = self.context.agent_address - payload = RequestPayload(agent, tx_submitter, mech_tx_hex, price) + payload = DecisionRequestPayload(agent, payload_content) yield from self.finish_behaviour(payload) diff --git a/packages/valory/skills/decision_maker_abci/fsm_specification.yaml b/packages/valory/skills/decision_maker_abci/fsm_specification.yaml index d6d2314af..d7a40598d 100644 --- a/packages/valory/skills/decision_maker_abci/fsm_specification.yaml +++ b/packages/valory/skills/decision_maker_abci/fsm_specification.yaml @@ -18,6 +18,7 @@ alphabet_in: default_start_state: SamplingRound final_states: - FinishedDecisionMakerRound +- FinishedDecisionRequestRound - FinishedSubscriptionRound - FinishedWithoutDecisionRound - FinishedWithoutRedeemingRound @@ -37,6 +38,7 @@ states: - DecisionReceiveRound - DecisionRequestRound - FinishedDecisionMakerRound +- FinishedDecisionRequestRound - FinishedSubscriptionRound - FinishedWithoutDecisionRound - FinishedWithoutRedeemingRound @@ -69,7 +71,7 @@ transition_func: (DecisionReceiveRound, ROUND_TIMEOUT): DecisionReceiveRound (DecisionReceiveRound, TIE): BlacklistingRound (DecisionReceiveRound, UNPROFITABLE): BlacklistingRound - (DecisionRequestRound, DONE): FinishedDecisionMakerRound + (DecisionRequestRound, DONE): FinishedDecisionRequestRound (DecisionRequestRound, NONE): ImpossibleRound (DecisionRequestRound, NO_MAJORITY): DecisionRequestRound (DecisionRequestRound, ROUND_TIMEOUT): DecisionRequestRound diff --git a/packages/valory/skills/decision_maker_abci/models.py b/packages/valory/skills/decision_maker_abci/models.py index 8d72d6152..7dcd0c20b 100644 --- a/packages/valory/skills/decision_maker_abci/models.py +++ b/packages/valory/skills/decision_maker_abci/models.py @@ -19,7 +19,6 @@ """This module contains the models for the skill.""" -import json import os import re from dataclasses import dataclass, field @@ -38,7 +37,6 @@ Union, ) -from aea.exceptions import enforce from aea.skills.base import SkillContext from hexbytes import HexBytes from web3.constants import HASH_ZERO @@ -58,6 +56,9 @@ from packages.valory.skills.decision_maker_abci.redeem_info import Trade from packages.valory.skills.decision_maker_abci.rounds import DecisionMakerAbciApp from packages.valory.skills.market_manager_abci.models import MarketManagerParams +from packages.valory.skills.mech_interact_abci.models import ( + Params as MechInteractParams, +) FromBlockMappingType = Dict[HexBytes, Union[int, str]] @@ -226,12 +227,11 @@ def nested_list_todict_workaround( return {value[0]: value[1] for value in values} -class DecisionMakerParams(MarketManagerParams): +class DecisionMakerParams(MarketManagerParams, MechInteractParams): """Decision maker's parameters.""" def __init__(self, *args: Any, **kwargs: Any) -> None: """Initialize the parameters' object.""" - self.mech_agent_address: str = self._ensure("mech_agent_address", kwargs, str) # the number of days to sample bets from self.sample_bets_closing_days: int = self._ensure( "sample_bets_closing_days", kwargs, int @@ -251,12 +251,8 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: self.blacklisting_duration: int = self._ensure( "blacklisting_duration", kwargs, int ) - self._ipfs_address: str = self._ensure("ipfs_address", kwargs, str) self._prompt_template: str = self._ensure("prompt_template", kwargs, str) check_prompt_template(self.prompt_template) - multisend_address = kwargs.get("multisend_address", None) - enforce(multisend_address is not None, "Multisend address not specified!") - self.multisend_address: str = multisend_address self.dust_threshold: int = self._ensure("dust_threshold", kwargs, int) self.conditional_tokens_address: str = self._ensure( "conditional_tokens_address", kwargs, str @@ -326,13 +322,6 @@ def using_kelly(self) -> bool: """Get the max bet amount if the `bet_amount_per_conf_threshold` strategy is used.""" return self.trading_strategy == STRATEGY_KELLY_CRITERION - @property - def ipfs_address(self) -> str: - """Get the IPFS address.""" - if self._ipfs_address.endswith("/"): - return self._ipfs_address - return f"{self._ipfs_address}/" - @property def prompt_template(self) -> PromptTemplate: """Get the prompt template as a string `PromptTemplate`.""" @@ -367,10 +356,6 @@ def get_policy_store_path(self, kwargs: Dict) -> Path: return Path(path) -class MechResponseSpecs(ApiSpecs): - """A model that wraps ApiSpecs for the Mech's response specifications.""" - - class AgentToolsSpecs(ApiSpecs): """A model that wraps ApiSpecs for the Mech agent's tools specifications.""" @@ -422,31 +407,6 @@ def win_probability(self) -> Optional[float]: return max(self.p_no, self.p_yes) -@dataclass(init=False) -class MechInteractionResponse: - """A structure for the response of a mech interaction task.""" - - request_id: int - result: Optional[PredictionResponse] - error: str - - def __init__(self, **kwargs: Any) -> None: - """Initialize the mech's response ignoring extra keys.""" - self.request_id = kwargs.pop("requestId", 0) - self.error = kwargs.pop("error", "Unknown") - self.result = kwargs.pop("result", None) - - if isinstance(self.result, str): - self.result = PredictionResponse(**json.loads(self.result)) - - @classmethod - def incorrect_format(cls, res: Any) -> "MechInteractionResponse": - """Return an incorrect format response.""" - response = cls() - response.error = f"The response's format was unexpected: {res}" - return response - - class TradesSubgraph(ApiSpecs): """A model that wraps ApiSpecs for the OMEN's subgraph specifications for trades.""" diff --git a/packages/valory/skills/decision_maker_abci/payloads.py b/packages/valory/skills/decision_maker_abci/payloads.py index 3790df766..519a3adc0 100644 --- a/packages/valory/skills/decision_maker_abci/payloads.py +++ b/packages/valory/skills/decision_maker_abci/payloads.py @@ -62,10 +62,10 @@ class RedeemPayload(MultisigTxPayload): @dataclass(frozen=True) -class RequestPayload(MultisigTxPayload): - """Represents a transaction payload for preparing an on-chain transaction for a mech request.""" +class DecisionRequestPayload(BaseTxPayload): + """Represents a transaction payload for preparing mech requests.""" - price: Optional[int] = None + mech_requests: Optional[str] = None @dataclass(frozen=True) diff --git a/packages/valory/skills/decision_maker_abci/rounds.py b/packages/valory/skills/decision_maker_abci/rounds.py index 6b4df9e4e..d8e13f005 100644 --- a/packages/valory/skills/decision_maker_abci/rounds.py +++ b/packages/valory/skills/decision_maker_abci/rounds.py @@ -48,6 +48,7 @@ ) from packages.valory.skills.decision_maker_abci.states.final_states import ( FinishedDecisionMakerRound, + FinishedDecisionRequestRound, FinishedSubscriptionRound, FinishedWithoutDecisionRound, FinishedWithoutRedeemingRound, @@ -81,12 +82,12 @@ class DecisionMakerAbciApp(AbciApp[Event]): Transition states: 0. SamplingRound - done: 1. - - none: 12. + - none: 13. - no majority: 0. - round timeout: 0. - - fetch error: 16. + - fetch error: 17. 1. SubscriptionRound - - done: 14. + - done: 15. - no subscription: 3. - none: 1. - subscription error: 1. @@ -107,11 +108,11 @@ class DecisionMakerAbciApp(AbciApp[Event]): - no majority: 4. - round timeout: 4. 5. DecisionRequestRound - - done: 11. + - done: 12. - slots unsupported error: 7. - no majority: 5. - round timeout: 5. - - none: 16. + - none: 17. 6. DecisionReceiveRound - done: 8. - mech response error: 7. @@ -120,35 +121,36 @@ class DecisionMakerAbciApp(AbciApp[Event]): - unprofitable: 7. - round timeout: 6. 7. BlacklistingRound - - done: 12. - - none: 16. + - done: 13. + - none: 17. - no majority: 7. - round timeout: 7. - - fetch error: 16. + - fetch error: 17. 8. BetPlacementRound - done: 11. - - insufficient balance: 15. + - insufficient balance: 16. - no majority: 8. - round timeout: 8. - - none: 16. + - none: 17. 9. RedeemRound - done: 11. - - no redeeming: 13. + - no redeeming: 14. - no majority: 9. - - redeem round timeout: 13. - - none: 16. + - redeem round timeout: 14. + - none: 17. 10. HandleFailedTxRound - blacklist: 7. - no op: 9. - no majority: 10. 11. FinishedDecisionMakerRound - 12. FinishedWithoutDecisionRound - 13. FinishedWithoutRedeemingRound - 14. FinishedSubscriptionRound - 15. RefillRequiredRound - 16. ImpossibleRound + 12. FinishedDecisionRequestRound + 13. FinishedWithoutDecisionRound + 14. FinishedWithoutRedeemingRound + 15. FinishedSubscriptionRound + 16. RefillRequiredRound + 17. ImpossibleRound - Final states: {FinishedDecisionMakerRound, FinishedSubscriptionRound, FinishedWithoutDecisionRound, FinishedWithoutRedeemingRound, ImpossibleRound, RefillRequiredRound} + Final states: {FinishedDecisionMakerRound, FinishedDecisionRequestRound, FinishedSubscriptionRound, FinishedWithoutDecisionRound, FinishedWithoutRedeemingRound, ImpossibleRound, RefillRequiredRound} Timeouts: round timeout: 30.0 @@ -198,7 +200,7 @@ class DecisionMakerAbciApp(AbciApp[Event]): Event.ROUND_TIMEOUT: ToolSelectionRound, }, DecisionRequestRound: { - Event.DONE: FinishedDecisionMakerRound, + Event.DONE: FinishedDecisionRequestRound, Event.SLOTS_UNSUPPORTED_ERROR: BlacklistingRound, Event.NO_MAJORITY: DecisionRequestRound, Event.ROUND_TIMEOUT: DecisionRequestRound, @@ -245,6 +247,7 @@ class DecisionMakerAbciApp(AbciApp[Event]): Event.NO_MAJORITY: HandleFailedTxRound, }, FinishedDecisionMakerRound: {}, + FinishedDecisionRequestRound: {}, FinishedWithoutDecisionRound: {}, FinishedWithoutRedeemingRound: {}, FinishedSubscriptionRound: {}, @@ -263,6 +266,7 @@ class DecisionMakerAbciApp(AbciApp[Event]): ) final_states: Set[AppState] = { FinishedDecisionMakerRound, + FinishedDecisionRequestRound, FinishedSubscriptionRound, FinishedWithoutDecisionRound, FinishedWithoutRedeemingRound, @@ -290,6 +294,7 @@ class DecisionMakerAbciApp(AbciApp[Event]): get_name(SynchronizedData.tx_submitter), get_name(SynchronizedData.most_voted_tx_hash), }, + FinishedDecisionRequestRound: set(), FinishedSubscriptionRound: { get_name(SynchronizedData.tx_submitter), get_name(SynchronizedData.most_voted_tx_hash), diff --git a/packages/valory/skills/decision_maker_abci/skill.yaml b/packages/valory/skills/decision_maker_abci/skill.yaml index 207e6b508..7858b6135 100644 --- a/packages/valory/skills/decision_maker_abci/skill.yaml +++ b/packages/valory/skills/decision_maker_abci/skill.yaml @@ -12,12 +12,12 @@ fingerprint: README.md: bafybeia367zzdwndvlhw27rvnwodytjo3ms7gbc3q7mhrrjqjgfasnk47i __init__.py: bafybeih563ujnigeci2ldzh7hakbau6a222vsed7leg3b7lq32vcn3nm4a behaviours/__init__.py: bafybeih6ddz2ocvm6x6ytvlbcz6oi4snb5ee5xh5h65nq4w2qf7fd7zfky - behaviours/base.py: bafybeigoxverx6e75jdzj54hsfyzgunofuy5nll5lbn52gxeyzo7jw6vyy + behaviours/base.py: bafybeicg37b76cic7zuy2uvskhl7ohgv74o74w2fjbojwydhvh3hrywoz4 behaviours/bet_placement.py: bafybeib7jgq7iyfoyj3ur3xkj6knh7t7vr32kc743ztyjskkdevyh6l75q behaviours/blacklisting.py: bafybeid2kwsrq3ityeqsixalpaxwwiduo3lvqs5uzqhw5yfccqz5hqm6im behaviours/claim_subscription.py: bafybeihv5dg74deifzk46ppdwcvz6lgamgl6m7qr6sgqv2zie35j2576ca - behaviours/decision_receive.py: bafybeiapkbvoqtlsisntdmmbw64zjuembaphsktn45smij5uocm3yxvml4 - behaviours/decision_request.py: bafybeiesxnu3outdldwrd2rhbokryvik5uzp6wr6dqhwypy66txev322um + behaviours/decision_receive.py: bafybeid35xch5vsuuvtebu2yqedzeybbvc3kbt4d7q62efevhribmzg5gq + behaviours/decision_request.py: bafybeibtvdjisudxyj677b7yctxnyo3tnrqdugevbfs27fmqnbo23cfexe behaviours/handle_failed_tx.py: bafybeidxpc6u575ymct5tdwutvzov6zqfdoio5irgldn3fw7q3lg36mmxm behaviours/order_subscription.py: bafybeifygejified3yoza3gy4g7ina6m4lmz4pp2abtwfuwrmiwznnvrua behaviours/randomness.py: bafybeidmr33teizrs4uxlo5tdz766ds6os4pe5lttstm7jpmhgmjz5ti3q @@ -26,23 +26,23 @@ fingerprint: behaviours/sampling.py: bafybeibtkli72qsvotkrsepkgpiumtr5sershtkpb427oygnszs3dpgxry behaviours/tool_selection.py: bafybeicxw4je76uc7znx4u2hq2b2aaxcf7blwfla7lhdhkqnf3kkupsczq dialogues.py: bafybeigpwuzku3we7axmxeamg7vn656maww6emuztau5pg3ebsoquyfdqm - fsm_specification.yaml: bafybeigxmyqggc6m5jmmnw5cugfcr7irugjrn6jffgc3q2snevuvcan7zu + fsm_specification.yaml: bafybeicqwy4r4fhhpn3ppwly57wckl5dhwlvaer4vug7tg3qhdcxo2ssuq handlers.py: bafybeiggoetspwcvdojmbjdd67tmkoeedikmt6vsbcium3zjaljb6jzqu4 io_/__init__.py: bafybeifxgmmwjqzezzn3e6keh2bfo4cyo7y5dq2ept3stfmgglbrzfl5rq io_/loader.py: bafybeih3sdsx5dhe4kzhtoafexjgkutsujwqy3zcdrlrkhtdks45bc7exa - models.py: bafybeihzxf3dhx73lk7d56ir7zhmz2x6u5x6aga6f7rfms37zkvaqhfelm - payloads.py: bafybeibmjrckgsflqulviynadl6bx3keuabvhfolkiib7cmjhfsov2vuty + models.py: bafybeic5bmc3di6huvdpa54lllf4okojjexvlj2mvzlg6kagk32rt54ktu + payloads.py: bafybeihejpmrefonjecnove26g52ukxdlicdbbn7qvnh4lg53q54bgq4p4 policy.py: bafybeidbsu5zn456jpku65jajwlxyg5kn2ltlkctkculkj2i2tfmmwm4jq redeem_info.py: bafybeifiiix4gihfo4avraxt34sfw35v6dqq45do2drrssei2shbps63mm - rounds.py: bafybeih6bo7nnc7hvg67svio3f6cwob55qp4bgxjcejsmj6el3zhltz7bq + rounds.py: bafybeidghyig7wuc2ldvoshanyghisgrxpbhjvjookwxueust77rwvxd2i states/__init__.py: bafybeid23llnyp6j257dluxmrnztugo5llsrog7kua53hllyktz4dqhqoy - states/base.py: bafybeid4khumtvfw5n37avkf3kujfxdwhfjcsnzpmyjeljkpcako5f2duy + states/base.py: bafybeiefeeubjxohtlts4whzw7pgo37c3mtelo5z5yccaxfypgrdjqs5du states/bet_placement.py: bafybeibalhxhp2c4oljmiwqi6ds3g36fgtabmf42mb5sgq6z22znrcbhda states/blacklisting.py: bafybeifruvxwwltndwazkzzbpc5nnnad3z5t5ofy6d3i7nssljbxl6gvxu states/claim_subscription.py: bafybeiampifhdoztggwj6gthl2hfzecmjcwnm6nic2o47q4je7j4x3ujne - states/decision_receive.py: bafybeib3roo27nccj4eylaqwwzztzzzwsi6px5atjrch5wbqmpln2kyy6y - states/decision_request.py: bafybeic7otc3hjb753svbmur3yyk6szahc25yii3x4w4vcnpfz6jwvacuu - states/final_states.py: bafybeidmlhpjvsdogejrvaczk3tfcbh7f7ijectshh23qi5yzktozzunee + states/decision_receive.py: bafybeiclng2o5skqc7jwuqggpk6guexaot6e2clgfbhejwe4zlkgayeshq + states/decision_request.py: bafybeieugthqhhisvyouhgqovz4ez5potmbffpparvs7dvsfkwr6gwt65u + states/final_states.py: bafybeiantsmq3yuzg7qzk6hlyngj74jsx43rphghfwsvseakcxmu3n4kqm states/handle_failed_tx.py: bafybeihewm2vernvhktuorljdupjqcg2p5vs6wvsira2d62wkoyo5xlzjm states/order_subscription.py: bafybeiaoemltuh3zkch7hvaxzxxsofe3pomlgifj5hamkqqon5mg5eaoqq states/randomness.py: bafybeifgsyipvvu2e6caggyoo5vsmd64uexuho5ybyf3ry424r7kldcfre @@ -62,7 +62,7 @@ contracts: - valory/market_maker:0.1.0:bafybeihyi42hkmu2knrunfdbunjh6j3ibfrnwj7rmqw7mm7pmerzcwzfiq - valory/erc20:0.1.0:bafybeihnbk5wp7zb6hmaykqfxgdrvpwmxxh3xnmcwn3elopw3urjeyxo54 - valory/multisend:0.1.0:bafybeig5byt5urg2d2bsecufxe5ql7f4mezg3mekfleeh32nmuusx66p4y -- valory/mech:0.1.0:bafybeiaqkpudbwnjf2svagdwgl5vujhuhmdqiomee47m5t3z23iest2oxa +- valory/mech:0.1.0:bafybeiejdn3rqqa7smbeiypajy63um7okteimvj6bsud3gezneycmdc6te - valory/conditional_tokens:0.1.0:bafybeigucumqbsk74nj4rpm4p2cpiky4dj6uws7nfmgpimuviaxcamwqnu - valory/realitio:0.1.0:bafybeic5ie4oodetj4krdogydvbfxg4qggc3matpiflocah626tpevpreq - valory/realitio_proxy:0.1.0:bafybeidx37xzjjmapwacedgzhum6grfzhp5vhouz4zu3pvpgdy5pgb2fr4 @@ -76,6 +76,7 @@ skills: - valory/abstract_round_abci:0.1.0:bafybeih3enhagoql7kzpeyzzu2scpkif6y3ubakpralfnwxcvxexdyvy5i - valory/market_manager_abci:0.1.0:bafybeidygkw7mwhbk3ry3au5c5265vms5eti375v5jthd4be5dfnnoache - valory/transaction_settlement_abci:0.1.0:bafybeigtzlk4uakmd54rxnznorcrstsr52kta474lgrnvx5ovr546vj7sq +- valory/mech_interact_abci:0.1.0:bafybeidxignwgujlkhw5hbek7xw2uz5nrd3h2xx7sj5zor263dgh4fm3p4 behaviours: main: args: {} @@ -147,6 +148,8 @@ models: keeper_timeout: 30.0 max_attempts: 10 max_healthcheck: 120 + multisend_address: '0x0000000000000000000000000000000000000000' + multisend_batch_size: 1 on_chain_service_id: null request_retry_delay: 1.0 request_timeout: 10.0 @@ -177,7 +180,8 @@ models: tendermint_url: http://localhost:26657 tx_timeout: 10.0 use_termination: false - mech_agent_address: '0xff82123dfb52ab75c417195c5fdb87630145ae81' + mech_contract_address: '0x77af31de935740567cf4ff1986d04b2c964a786a' + request_price: null sample_bets_closing_days: 10 trading_strategy: strategy_name use_fallback_strategy: true @@ -264,8 +268,8 @@ models: Content-Type: application/json method: GET parameters: {} - response_key: null - response_type: dict + response_key: result + response_type: str retries: 5 url: '' class_name: MechResponseSpecs diff --git a/packages/valory/skills/decision_maker_abci/states/base.py b/packages/valory/skills/decision_maker_abci/states/base.py index 95c9a0638..ce8c4deba 100644 --- a/packages/valory/skills/decision_maker_abci/states/base.py +++ b/packages/valory/skills/decision_maker_abci/states/base.py @@ -33,6 +33,10 @@ from packages.valory.skills.market_manager_abci.rounds import ( SynchronizedData as MarketManagerSyncedData, ) +from packages.valory.skills.mech_interact_abci.states.base import ( + MechInteractionResponse, + MechMetadata, +) from packages.valory.skills.transaction_settlement_abci.rounds import ( SynchronizedData as TxSettlementSyncedData, ) @@ -74,11 +78,6 @@ def is_mech_price_set(self) -> bool: """Get whether mech's price is known.""" return bool(self.db.get("mech_price", False)) - @property - def mech_price(self) -> int: - """Get the mech's request price.""" - return int(self.db.get_strict("mech_price")) - @property def available_mech_tools(self) -> List[str]: """Get all the available mech tools.""" @@ -173,6 +172,29 @@ def claim(self) -> bool: """Get the claim.""" return bool(self.db.get_strict("claim")) + @property + def mech_price(self) -> int: + """Get the mech's request price.""" + return int(self.db.get_strict("mech_price")) + + @property + def mech_requests(self) -> List[MechMetadata]: + """Get the mech requests.""" + serialized = self.db.get("mech_requests", "[]") + if serialized is None: + serialized = "[]" + requests = json.loads(serialized) + return [MechMetadata(**metadata_item) for metadata_item in requests] + + @property + def mech_responses(self) -> List[MechInteractionResponse]: + """Get the mech responses.""" + serialized = self.db.get("mech_responses", "[]") + if serialized is None: + serialized = "[]" + responses = json.loads(serialized) + return [MechInteractionResponse(**response_item) for response_item in responses] + class TxPreparationRound(CollectSameUntilThresholdRound): """A round for preparing a transaction.""" diff --git a/packages/valory/skills/decision_maker_abci/states/decision_receive.py b/packages/valory/skills/decision_maker_abci/states/decision_receive.py index a45b9ecd2..4b104e645 100644 --- a/packages/valory/skills/decision_maker_abci/states/decision_receive.py +++ b/packages/valory/skills/decision_maker_abci/states/decision_receive.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # ------------------------------------------------------------------------------ # -# Copyright 2023 Valory AG +# Copyright 2023-2024 Valory AG # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/packages/valory/skills/decision_maker_abci/states/decision_request.py b/packages/valory/skills/decision_maker_abci/states/decision_request.py index fb11239b2..af7330de3 100644 --- a/packages/valory/skills/decision_maker_abci/states/decision_request.py +++ b/packages/valory/skills/decision_maker_abci/states/decision_request.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # ------------------------------------------------------------------------------ # -# Copyright 2023 Valory AG +# Copyright 2023-2024 Valory AG # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -19,25 +19,25 @@ """This module contains the decision requesting state of the decision-making abci app.""" -from typing import Type - -from packages.valory.skills.abstract_round_abci.base import get_name -from packages.valory.skills.decision_maker_abci.payloads import ( - MultisigTxPayload, - RequestPayload, +from packages.valory.skills.abstract_round_abci.base import ( + CollectSameUntilThresholdRound, + get_name, ) +from packages.valory.skills.decision_maker_abci.payloads import DecisionRequestPayload from packages.valory.skills.decision_maker_abci.states.base import ( Event, SynchronizedData, - TxPreparationRound, ) -class DecisionRequestRound(TxPreparationRound): +class DecisionRequestRound(CollectSameUntilThresholdRound): """A round in which the agents prepare a tx to initiate a request to a mech to determine the answer to a bet.""" - payload_class: Type[MultisigTxPayload] = RequestPayload - selection_key = TxPreparationRound.selection_key + ( - get_name(SynchronizedData.mech_price), - ) + payload_class = DecisionRequestPayload + synchronized_data_class = SynchronizedData + done_event = Event.DONE + none_event = Event.NONE + no_majority_event = Event.NO_MAJORITY + collection_key = get_name(SynchronizedData.participant_to_selection) + selection_key = get_name(SynchronizedData.mech_requests) none_event = Event.SLOTS_UNSUPPORTED_ERROR diff --git a/packages/valory/skills/decision_maker_abci/states/final_states.py b/packages/valory/skills/decision_maker_abci/states/final_states.py index 4339bc69d..d522ba24e 100644 --- a/packages/valory/skills/decision_maker_abci/states/final_states.py +++ b/packages/valory/skills/decision_maker_abci/states/final_states.py @@ -26,6 +26,10 @@ class FinishedDecisionMakerRound(DegenerateRound): """A round representing that decision-making has finished.""" +class FinishedDecisionRequestRound(DegenerateRound): + """A round representing that decision request has finished.""" + + class FinishedSubscriptionRound(DegenerateRound): """A round representing that subscription has finished.""" diff --git a/packages/valory/skills/trader_abci/behaviours.py b/packages/valory/skills/trader_abci/behaviours.py index 1a7849320..104598227 100644 --- a/packages/valory/skills/trader_abci/behaviours.py +++ b/packages/valory/skills/trader_abci/behaviours.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # ------------------------------------------------------------------------------ # -# Copyright 2023 Valory AG +# Copyright 2023-2024 Valory AG # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -31,6 +31,9 @@ from packages.valory.skills.market_manager_abci.behaviours import ( MarketManagerRoundBehaviour, ) +from packages.valory.skills.mech_interact_abci.behaviours.round_behaviour import ( + MechInteractRoundBehaviour, +) from packages.valory.skills.registration_abci.behaviours import ( AgentRegistrationRoundBehaviour, RegistrationStartupBehaviour, @@ -62,6 +65,7 @@ class TraderConsensusBehaviour(AbstractRoundBehaviour): *AgentRegistrationRoundBehaviour.behaviours, *AgentDecisionMakerRoundBehaviour.behaviours, *MarketManagerRoundBehaviour.behaviours, + *MechInteractRoundBehaviour.behaviours, *ResetPauseABCIConsensusBehaviour.behaviours, *TerminationAbciBehaviours.behaviours, *TransactionSettlementRoundBehaviour.behaviours, diff --git a/packages/valory/skills/trader_abci/composition.py b/packages/valory/skills/trader_abci/composition.py index 1d4a1f10f..eadee3f53 100644 --- a/packages/valory/skills/trader_abci/composition.py +++ b/packages/valory/skills/trader_abci/composition.py @@ -33,6 +33,7 @@ ) from packages.valory.skills.decision_maker_abci.states.final_states import ( FinishedDecisionMakerRound, + FinishedDecisionRequestRound, FinishedSubscriptionRound, FinishedWithoutDecisionRound, FinishedWithoutRedeemingRound, @@ -49,6 +50,15 @@ MarketManagerAbciApp, UpdateBetsRound, ) +from packages.valory.skills.mech_interact_abci.rounds import MechInteractAbciApp +from packages.valory.skills.mech_interact_abci.states.final_states import ( + FinishedMechRequestRound, + FinishedMechRequestSkipRound, + FinishedMechResponseRound, + FinishedMechResponseTimeoutRound, +) +from packages.valory.skills.mech_interact_abci.states.request import MechRequestRound +from packages.valory.skills.mech_interact_abci.states.response import MechResponseRound from packages.valory.skills.registration_abci.rounds import ( AgentRegistrationAbciApp, FinishedRegistrationRound, @@ -81,7 +91,7 @@ from packages.valory.skills.tx_settlement_multiplexer_abci.rounds import ( ChecksPassedRound, FinishedBetPlacementTxRound, - FinishedDecisionRequestTxRound, + FinishedMechRequestTxRound, FinishedRedeemingTxRound, FinishedStakingTxRound, FinishedSubscriptionTxRound, @@ -101,7 +111,12 @@ FinishedTransactionSubmissionRound: PostTxSettlementRound, FinishedSubscriptionTxRound: ClaimRound, FailedTransactionSubmissionRound: HandleFailedTxRound, - FinishedDecisionRequestTxRound: DecisionReceiveRound, + FinishedDecisionRequestRound: MechRequestRound, + FinishedMechRequestRound: PreTxSettlementRound, + FinishedMechRequestTxRound: MechResponseRound, + FinishedMechResponseRound: DecisionReceiveRound, + FinishedMechResponseTimeoutRound: MechResponseRound, + FinishedMechRequestSkipRound: RedeemRound, FinishedSubscriptionRound: PreTxSettlementRound, FinishedBetPlacementTxRound: RedeemRound, FinishedRedeemingTxRound: CallCheckpointRound, @@ -126,6 +141,7 @@ AgentRegistrationAbciApp, DecisionMakerAbciApp, MarketManagerAbciApp, + MechInteractAbciApp, TransactionSubmissionAbciApp, TxSettlementMultiplexerAbciApp, ResetPauseAbciApp, diff --git a/packages/valory/skills/trader_abci/fsm_specification.yaml b/packages/valory/skills/trader_abci/fsm_specification.yaml index 0939695ee..c2e09de15 100644 --- a/packages/valory/skills/trader_abci/fsm_specification.yaml +++ b/packages/valory/skills/trader_abci/fsm_specification.yaml @@ -5,7 +5,6 @@ alphabet_in: - CHECK_HISTORY - CHECK_LATE_ARRIVING_MESSAGE - CHECK_TIMEOUT -- DECISION_REQUESTING_DONE - DONE - FETCH_ERROR - FINALIZATION_FAILED @@ -13,6 +12,7 @@ alphabet_in: - INCORRECT_SERIALIZATION - INSUFFICIENT_BALANCE - INSUFFICIENT_FUNDS +- MECH_REQUESTING_DONE - MECH_RESPONSE_ERROR - NEGATIVE - NEXT_CHECKPOINT_NOT_REACHED_YET @@ -29,6 +29,7 @@ alphabet_in: - ROUND_TIMEOUT - SERVICE_EVICTED - SERVICE_NOT_STAKED +- SKIP_REQUEST - SLOTS_UNSUPPORTED_ERROR - STAKING_DONE - SUBSCRIPTION_DONE @@ -61,6 +62,8 @@ states: - FinalizationRound - HandleFailedTxRound - ImpossibleRound +- MechRequestRound +- MechResponseRound - PostTxSettlementRound - PreTxSettlementRound - RandomnessRound @@ -122,7 +125,7 @@ transition_func: (DecisionReceiveRound, ROUND_TIMEOUT): DecisionReceiveRound (DecisionReceiveRound, TIE): BlacklistingRound (DecisionReceiveRound, UNPROFITABLE): BlacklistingRound - (DecisionRequestRound, DONE): PreTxSettlementRound + (DecisionRequestRound, DONE): MechRequestRound (DecisionRequestRound, NONE): ImpossibleRound (DecisionRequestRound, NO_MAJORITY): DecisionRequestRound (DecisionRequestRound, ROUND_TIMEOUT): DecisionRequestRound @@ -136,8 +139,15 @@ transition_func: (HandleFailedTxRound, BLACKLIST): BlacklistingRound (HandleFailedTxRound, NO_MAJORITY): HandleFailedTxRound (HandleFailedTxRound, NO_OP): RedeemRound + (MechRequestRound, DONE): PreTxSettlementRound + (MechRequestRound, NO_MAJORITY): MechRequestRound + (MechRequestRound, ROUND_TIMEOUT): MechRequestRound + (MechRequestRound, SKIP_REQUEST): RedeemRound + (MechResponseRound, DONE): DecisionReceiveRound + (MechResponseRound, NO_MAJORITY): MechResponseRound + (MechResponseRound, ROUND_TIMEOUT): MechResponseRound (PostTxSettlementRound, BET_PLACEMENT_DONE): RedeemRound - (PostTxSettlementRound, DECISION_REQUESTING_DONE): DecisionReceiveRound + (PostTxSettlementRound, MECH_REQUESTING_DONE): MechResponseRound (PostTxSettlementRound, REDEEMING_DONE): CallCheckpointRound (PostTxSettlementRound, ROUND_TIMEOUT): PostTxSettlementRound (PostTxSettlementRound, STAKING_DONE): ResetAndPauseRound diff --git a/packages/valory/skills/trader_abci/models.py b/packages/valory/skills/trader_abci/models.py index 45188a781..1ae88ce94 100644 --- a/packages/valory/skills/trader_abci/models.py +++ b/packages/valory/skills/trader_abci/models.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # ------------------------------------------------------------------------------ # -# Copyright 2023 Valory AG +# Copyright 2023-2024 Valory AG # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -33,9 +33,6 @@ ConditionalTokensSubgraph as DecisionMakerConditionalTokensSubgraph, ) from packages.valory.skills.decision_maker_abci.models import DecisionMakerParams -from packages.valory.skills.decision_maker_abci.models import ( - MechResponseSpecs as DecisionMakerMechResponseSpecs, -) from packages.valory.skills.decision_maker_abci.models import ( RealitioSubgraph as DecisionMakerRealitioSubgraph, ) @@ -57,6 +54,9 @@ from packages.valory.skills.market_manager_abci.rounds import ( Event as MarketManagerEvent, ) +from packages.valory.skills.mech_interact_abci.models import ( + MechResponseSpecs as BaseMechResponseSpecs, +) from packages.valory.skills.reset_pause_abci.rounds import Event as ResetPauseEvent from packages.valory.skills.staking_abci.models import StakingParams from packages.valory.skills.termination_abci.models import TerminationParams @@ -83,7 +83,7 @@ BenchmarkTool = BaseBenchmarkTool OmenSubgraph = MarketManagerOmenSubgraph NetworkSubgraph = MarketManagerNetworkSubgraph -MechResponseSpecs = DecisionMakerMechResponseSpecs +MechResponseSpecs = BaseMechResponseSpecs AgentToolsSpecs = DecisionMakerAgentToolsSpecs TradesSubgraph = DecisionMakerTradesSubgraph ConditionalTokensSubgraph = DecisionMakerConditionalTokensSubgraph @@ -98,7 +98,10 @@ class RandomnessApi(ApiSpecs): class TraderParams( - DecisionMakerParams, TerminationParams, StakingParams, TxSettlementMultiplexerParams + DecisionMakerParams, # It also contains MechInteractParams + TerminationParams, + StakingParams, + TxSettlementMultiplexerParams, ): """A model to represent the trader params.""" diff --git a/packages/valory/skills/trader_abci/skill.yaml b/packages/valory/skills/trader_abci/skill.yaml index d51820f06..340fae0b8 100644 --- a/packages/valory/skills/trader_abci/skill.yaml +++ b/packages/valory/skills/trader_abci/skill.yaml @@ -8,12 +8,12 @@ aea_version: '>=1.0.0, <2.0.0' fingerprint: README.md: bafybeiab4xgadptz4mhvno4p6xvkh7p4peg7iuhotabydriu74dmj6ljga __init__.py: bafybeido7wa33h4dtleap57vzgyb4fsofk4vindsqcekyfo5i56i2rll2a - behaviours.py: bafybeieesrefrpo5c5upzztgm5fwfrmxeagilacuau5nacobhsfvgpbzby - composition.py: bafybeif75v3swf2pmxi3rdd5kqdfv4ap5uapcbszkiohhur67oemrgotay + behaviours.py: bafybeigx2uevbnytt6hpwfsrk32u6pyv5scyqvyyzm2a25xaufrxvkldxi + composition.py: bafybeidvxtqoghju4tkesiwi6qfzxe3zf2nbqmehimwvp5skmohkeozmei dialogues.py: bafybeiebofyykseqp3fmif36cqmmyf3k7d2zbocpl6t6wnlpv4szghrxbm - fsm_specification.yaml: bafybeibi3t63vwfrx5sbkfhji3rb62dtwczpajuijqgul6bpcn3altcziq + fsm_specification.yaml: bafybeiaulbsq76cc5h7jjz6oiezoui452mtyk6g2kbmhhzsggqrjqw4cuy handlers.py: bafybeibkiqwe7hoqccjirimd44nzeqkabc7oo74romqklssion27s5sa2a - models.py: bafybeibrxivgpzamfmrl6bdngi67g72i32lmu5vgdn3jbwka265blk7ire + models.py: bafybeigk7hs7xsfjoszsque6r6yvbrrhattfuli2nfend4istk465e6try fingerprint_ignore_patterns: [] connections: [] contracts: [] @@ -25,9 +25,10 @@ skills: - valory/transaction_settlement_abci:0.1.0:bafybeigtzlk4uakmd54rxnznorcrstsr52kta474lgrnvx5ovr546vj7sq - valory/termination_abci:0.1.0:bafybeihq6qtbwt6i53ayqym63vhjexkcppy26gguzhhjqywfmiuqghvv44 - valory/market_manager_abci:0.1.0:bafybeidygkw7mwhbk3ry3au5c5265vms5eti375v5jthd4be5dfnnoache -- valory/decision_maker_abci:0.1.0:bafybeie7bvctvvmphamfrujtnsg2wxeafuoquvgikhm33xrowtpybj2iyy -- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeico5v6u7dmy7tj4nwakmoef5ihirivtb7s5lxm3v6szsco3ulkctu +- valory/decision_maker_abci:0.1.0:bafybeiftz2xjbld2njsywsii5pgp6354oqm6ultqyfyfsnemuzqulw6o2y +- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeifshd7ut2eyzyolvwpjcjxreq2c655gz4nh2vudglvfb7oog7gase - valory/staking_abci:0.1.0:bafybeibf565rftitlrlovlvchoe45ng72ctec74fsvrmegp3o4uepu4q2e +- valory/mech_interact_abci:0.1.0:bafybeidxignwgujlkhw5hbek7xw2uz5nrd3h2xx7sj5zor263dgh4fm3p4 behaviours: main: args: {} @@ -104,6 +105,7 @@ models: max_attempts: 10 max_healthcheck: 120 multisend_address: '0x0000000000000000000000000000000000000000' + multisend_batch_size: 1 on_chain_service_id: null request_retry_delay: 1.0 request_timeout: 10.0 @@ -145,7 +147,8 @@ models: - en_US average_block_time: 5 abt_error_mult: 5 - mech_agent_address: '0xff82123dfb52ab75c417195c5fdb87630145ae81' + mech_contract_address: '0x77af31de935740567cf4ff1986d04b2c964a786a' + request_price: null sample_bets_closing_days: 10 trading_strategy: strategy_name use_fallback_strategy: true @@ -271,8 +274,8 @@ models: Content-Type: application/json method: GET parameters: {} - response_key: null - response_type: dict + response_key: result + response_type: str retries: 5 url: '' class_name: MechResponseSpecs diff --git a/packages/valory/skills/tx_settlement_multiplexer_abci/fsm_specification.yaml b/packages/valory/skills/tx_settlement_multiplexer_abci/fsm_specification.yaml index 5070c9adf..d21d8966f 100644 --- a/packages/valory/skills/tx_settlement_multiplexer_abci/fsm_specification.yaml +++ b/packages/valory/skills/tx_settlement_multiplexer_abci/fsm_specification.yaml @@ -1,7 +1,7 @@ alphabet_in: - BET_PLACEMENT_DONE - CHECKS_PASSED -- DECISION_REQUESTING_DONE +- MECH_REQUESTING_DONE - NO_MAJORITY - REDEEMING_DONE - REFILL_REQUIRED @@ -14,7 +14,7 @@ final_states: - ChecksPassedRound - FailedMultiplexerRound - FinishedBetPlacementTxRound -- FinishedDecisionRequestTxRound +- FinishedMechRequestTxRound - FinishedRedeemingTxRound - FinishedStakingTxRound - FinishedSubscriptionTxRound @@ -26,7 +26,7 @@ states: - ChecksPassedRound - FailedMultiplexerRound - FinishedBetPlacementTxRound -- FinishedDecisionRequestTxRound +- FinishedMechRequestTxRound - FinishedRedeemingTxRound - FinishedStakingTxRound - FinishedSubscriptionTxRound @@ -34,7 +34,7 @@ states: - PreTxSettlementRound transition_func: (PostTxSettlementRound, BET_PLACEMENT_DONE): FinishedBetPlacementTxRound - (PostTxSettlementRound, DECISION_REQUESTING_DONE): FinishedDecisionRequestTxRound + (PostTxSettlementRound, MECH_REQUESTING_DONE): FinishedMechRequestTxRound (PostTxSettlementRound, REDEEMING_DONE): FinishedRedeemingTxRound (PostTxSettlementRound, ROUND_TIMEOUT): PostTxSettlementRound (PostTxSettlementRound, STAKING_DONE): FinishedStakingTxRound diff --git a/packages/valory/skills/tx_settlement_multiplexer_abci/rounds.py b/packages/valory/skills/tx_settlement_multiplexer_abci/rounds.py index 2dff503c2..06dff3b75 100644 --- a/packages/valory/skills/tx_settlement_multiplexer_abci/rounds.py +++ b/packages/valory/skills/tx_settlement_multiplexer_abci/rounds.py @@ -38,13 +38,11 @@ from packages.valory.skills.decision_maker_abci.states.bet_placement import ( BetPlacementRound, ) -from packages.valory.skills.decision_maker_abci.states.decision_request import ( - DecisionRequestRound, -) from packages.valory.skills.decision_maker_abci.states.order_subscription import ( SubscriptionRound, ) from packages.valory.skills.decision_maker_abci.states.redeem import RedeemRound +from packages.valory.skills.mech_interact_abci.states.request import MechRequestRound from packages.valory.skills.staking_abci.rounds import CallCheckpointRound @@ -53,7 +51,7 @@ class Event(Enum): CHECKS_PASSED = "checks_passed" REFILL_REQUIRED = "refill_required" - DECISION_REQUESTING_DONE = "decision_requesting_done" + MECH_REQUESTING_DONE = "mech_requesting_done" BET_PLACEMENT_DONE = "bet_placement_done" REDEEMING_DONE = "redeeming_done" STAKING_DONE = "staking_done" @@ -92,7 +90,7 @@ def end_block(self) -> Optional[Tuple[BaseSynchronizedData, Enum]]: :return: the synchronized data and the event, otherwise `None` if the round is still running. """ submitter_to_event: Dict[str, Event] = { - DecisionRequestRound.auto_round_id(): Event.DECISION_REQUESTING_DONE, + MechRequestRound.auto_round_id(): Event.MECH_REQUESTING_DONE, BetPlacementRound.auto_round_id(): Event.BET_PLACEMENT_DONE, RedeemRound.auto_round_id(): Event.REDEEMING_DONE, CallCheckpointRound.auto_round_id(): Event.STAKING_DONE, @@ -103,7 +101,7 @@ def end_block(self) -> Optional[Tuple[BaseSynchronizedData, Enum]]: event = submitter_to_event.get(synced_data.tx_submitter, Event.UNRECOGNIZED) # if a mech request was just performed, increase the utilized tool's counter - if event == Event.DECISION_REQUESTING_DONE: + if event == Event.MECH_REQUESTING_DONE: policy = synced_data.policy policy.tool_used(synced_data.mech_tool_idx) policy_update = policy.serialize() @@ -123,8 +121,8 @@ class ChecksPassedRound(DegenerateRound): """Round that represents all the pre tx settlement checks have passed.""" -class FinishedDecisionRequestTxRound(DegenerateRound): - """Finished decision requesting round.""" +class FinishedMechRequestTxRound(DegenerateRound): + """Finished mech requesting round.""" class FinishedBetPlacementTxRound(DegenerateRound): @@ -161,7 +159,7 @@ class TxSettlementMultiplexerAbciApp(AbciApp[Event]): - no majority: 0. - round timeout: 0. 1. PostTxSettlementRound - - decision requesting done: 3. + - mech requesting done: 3. - bet placement done: 4. - redeeming done: 6. - staking done: 7. @@ -169,14 +167,14 @@ class TxSettlementMultiplexerAbciApp(AbciApp[Event]): - round timeout: 1. - unrecognized: 8. 2. ChecksPassedRound - 3. FinishedDecisionRequestTxRound + 3. FinishedMechRequestTxRound 4. FinishedBetPlacementTxRound 5. FinishedSubscriptionTxRound 6. FinishedRedeemingTxRound 7. FinishedStakingTxRound 8. FailedMultiplexerRound - Final states: {ChecksPassedRound, FailedMultiplexerRound, FinishedBetPlacementTxRound, FinishedDecisionRequestTxRound, FinishedRedeemingTxRound, FinishedStakingTxRound, FinishedSubscriptionTxRound} + Final states: {ChecksPassedRound, FailedMultiplexerRound, FinishedBetPlacementTxRound, FinishedMechRequestTxRound, FinishedRedeemingTxRound, FinishedStakingTxRound, FinishedSubscriptionTxRound} Timeouts: round timeout: 30.0 @@ -192,7 +190,7 @@ class TxSettlementMultiplexerAbciApp(AbciApp[Event]): Event.ROUND_TIMEOUT: PreTxSettlementRound, }, PostTxSettlementRound: { - Event.DECISION_REQUESTING_DONE: FinishedDecisionRequestTxRound, + Event.MECH_REQUESTING_DONE: FinishedMechRequestTxRound, Event.BET_PLACEMENT_DONE: FinishedBetPlacementTxRound, Event.REDEEMING_DONE: FinishedRedeemingTxRound, Event.STAKING_DONE: FinishedStakingTxRound, @@ -201,7 +199,7 @@ class TxSettlementMultiplexerAbciApp(AbciApp[Event]): Event.UNRECOGNIZED: FailedMultiplexerRound, }, ChecksPassedRound: {}, - FinishedDecisionRequestTxRound: {}, + FinishedMechRequestTxRound: {}, FinishedBetPlacementTxRound: {}, FinishedSubscriptionTxRound: {}, FinishedRedeemingTxRound: {}, @@ -213,7 +211,7 @@ class TxSettlementMultiplexerAbciApp(AbciApp[Event]): } final_states: Set[AppState] = { ChecksPassedRound, - FinishedDecisionRequestTxRound, + FinishedMechRequestTxRound, FinishedBetPlacementTxRound, FinishedRedeemingTxRound, FinishedStakingTxRound, @@ -226,7 +224,7 @@ class TxSettlementMultiplexerAbciApp(AbciApp[Event]): } db_post_conditions: Dict[AppState, Set[str]] = { ChecksPassedRound: set(), - FinishedDecisionRequestTxRound: set(), + FinishedMechRequestTxRound: set(), FinishedBetPlacementTxRound: set(), FinishedRedeemingTxRound: set(), FinishedStakingTxRound: set(), diff --git a/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml b/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml index 2cb58f3c5..4539ee7d7 100644 --- a/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml +++ b/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml @@ -10,10 +10,10 @@ fingerprint: __init__.py: bafybeide6k22zk4f3hyzhpapaoddsnxpw5elqcfvrxxj4nfvpzctv6jqhu behaviours.py: bafybeictumcqn2pgo7y2duemvzoaafognfhl6s6il3tv53hq66tf7xgpsu dialogues.py: bafybeiebofyykseqp3fmif36cqmmyf3k7d2zbocpl6t6wnlpv4szghrxbm - fsm_specification.yaml: bafybeib7nmznbbug6icxyahy34r6ory7ujkwnlakv3bgmnlecysr46l5v4 + fsm_specification.yaml: bafybeicd7us5ffvsrxm7ybaanyzojbhmo7xtsfd3swtdem4dfsxkidxw7a handlers.py: bafybeiafbqr7ojfcbwohvee7x4zzswad3ymfrrbjlfz7uuuttmn3qdfs6q models.py: bafybeigtmxoecoow663hgqnyinxarlrttyyt5ghpbdamdv4tc4kikcfx3a - rounds.py: bafybeifzdrrx73azctfpdbhiha7ie7pu6mxzmfjfjzq5umdlfyt6j4g2tq + rounds.py: bafybeig77b7m5fyhy4bsdnmveszagq27v2ck7627tyhw6zzn7spmz5qalu fingerprint_ignore_patterns: [] connections: [] contracts: [] @@ -21,8 +21,9 @@ protocols: - valory/ledger_api:1.0.0:bafybeihdk6psr4guxmbcrc26jr2cbgzpd5aljkqvpwo64bvaz7tdti2oni skills: - valory/abstract_round_abci:0.1.0:bafybeih3enhagoql7kzpeyzzu2scpkif6y3ubakpralfnwxcvxexdyvy5i -- valory/decision_maker_abci:0.1.0:bafybeie7bvctvvmphamfrujtnsg2wxeafuoquvgikhm33xrowtpybj2iyy +- valory/decision_maker_abci:0.1.0:bafybeiftz2xjbld2njsywsii5pgp6354oqm6ultqyfyfsnemuzqulw6o2y - valory/staking_abci:0.1.0:bafybeibf565rftitlrlovlvchoe45ng72ctec74fsvrmegp3o4uepu4q2e +- valory/mech_interact_abci:0.1.0:bafybeidxignwgujlkhw5hbek7xw2uz5nrd3h2xx7sj5zor263dgh4fm3p4 behaviours: main: args: {} diff --git a/poetry.lock b/poetry.lock index 899d751c5..90761889f 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.4.0 and should not be changed by hand. +# This file is automatically @generated by Poetry and should not be changed by hand. [[package]] name = "aiohttp"