Skip to content

Commit

Permalink
Merge pull request #101 from dvilelaf/fix/unleash
Browse files Browse the repository at this point in the history
Fix/unleash
  • Loading branch information
dvilelaf authored Dec 13, 2024
2 parents cf66d61 + 044bcb5 commit af601e3
Show file tree
Hide file tree
Showing 12 changed files with 98 additions and 35 deletions.
6 changes: 3 additions & 3 deletions packages/dvilela/agents/memeooorr/aea-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ contracts:
- valory/gnosis_safe:0.1.0:bafybeiho6sbfts3zk3mftrngw37d5qnlvkqtnttt3fzexmcwkeevhu4wwi
- valory/gnosis_safe_proxy_factory:0.1.0:bafybeihi4cvrnf5ne7t5cxcwix3dbtfjucfjux6zn4wouebjx3ldmrmnpm
- valory/multisend:0.1.0:bafybeig5byt5urg2d2bsecufxe5ql7f4mezg3mekfleeh32nmuusx66p4y
- dvilela/meme_factory:0.1.0:bafybeiernwylranvc42xzzfkcitx64c5i3fwpan4j4lo2srcxfre6g6434
- dvilela/meme_factory:0.1.0:bafybeiecfhn33jiprqrz6kx565cexy6yq5pqsg2bltgzq6bbg3uusepj7i
protocols:
- open_aea/signing:1.0.0:bafybeihv62fim3wl2bayavfcg3u5e5cxu3b7brtu4cn5xoxd6lqwachasi
- valory/abci:0.1.0:bafybeiaqmp7kocbfdboksayeqhkbrynvlfzsx4uy4x6nohywnmaig4an7u
Expand All @@ -40,8 +40,8 @@ skills:
- valory/transaction_settlement_abci:0.1.0:bafybeihq2yenstblmaadzcjousowj5kfn5l7ns5pxweq2gcrsczfyq5wzm
- valory/registration_abci:0.1.0:bafybeicnth5q4httefsusywx3zrrq4al47owvge72dqf2fziruicq6hqta
- valory/reset_pause_abci:0.1.0:bafybeievjciqdvxhqxfjd4whqs27h6qbxqzrae7wwj7fpvxlvmtw3x35im
- dvilela/memeooorr_abci:0.1.0:bafybeigepnfuelhzrq7kvlvqnwip7vi64o2ihvtmsgl67kvbki4vs4gjja
- dvilela/memeooorr_chained_abci:0.1.0:bafybeiaajjgtye7vfpsdndzunw2mqtdgnv7bls3x5ngakaimgbtuir6xg4
- dvilela/memeooorr_abci:0.1.0:bafybeihrlpxsgizz2pyxltqvgz27st37mqhvwutgp63vcxb5l7zbdnuzha
- dvilela/memeooorr_chained_abci:0.1.0:bafybeih2jky7jltrizivivccparrf4wj6xqugp47y4gawgdoms2lvvnwiu
default_ledger: ethereum
required_ledgers:
- ethereum
Expand Down
5 changes: 3 additions & 2 deletions packages/dvilela/contracts/meme_factory/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,15 @@ def get_summon_data(
contract_address,
"Summoned",
)["events"]
nonces: List[int] = [e["token_nonce"] for e in summon_events] # type: ignore
nonce_to_event: Dict[str, Dict] = {e["token_nonce"]: e for e in summon_events} # type: ignore

meme_summons = getattr(contract_instance.functions, "memeSummons") # noqa

tokens = []
for nonce in nonces:
for nonce in nonce_to_event.keys():
summon_data = meme_summons(nonce).call()
token_data = {
"summoner": nonce_to_event[nonce]["summoner"],
"token_nonce": nonce,
"token_address": None,
"token_name": summon_data[0],
Expand Down
2 changes: 1 addition & 1 deletion packages/dvilela/contracts/meme_factory/contract.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fingerprint:
README.md: bafybeies3iafkjwo4xvqtqpdxvood7pf2wgto4t76dqswy55rya7vl5zgu
__init__.py: bafybeiddslgyschgiuwsfiovqgxqqbkazdy6h3d4swwnq3tvpqaxzy37si
build/MemeBase.json: bafybeibr3pkkofhukwqjuqxuxsb52g2xlquzhu5uv6xqo527s2zzmp3cq4
contract.py: bafybeialmp53wihxh32qewpitafdnhhai3lrr5ntrp7ffy5y2vx4u6ysfa
contract.py: bafybeielgqjcxrz5yuchvhhecicq3wiynisajhj35ihwuffhcph4rzgd3a
fingerprint_ignore_patterns: []
contracts: []
class_name: MemeFactoryContract
Expand Down
2 changes: 1 addition & 1 deletion packages/dvilela/services/memeooorr/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license: Apache-2.0
fingerprint:
README.md: bafybeiaekcmielp6mb4qvmo2twwkpmoun36bqajrh7wnnkcpdnia45ycl4
fingerprint_ignore_patterns: []
agent: dvilela/memeooorr:0.1.0:bafybeihocacd7vyqzb7i7bcx2enzoxcdfngy4tnzzbiqjnc4dbm6jh43z4
agent: dvilela/memeooorr:0.1.0:bafybeia73asshot6f2q4426uenpu6plfboxwr7rmb7jndl6ndtdkt3ko2q
number_of_agents: 1
deployment:
agent:
Expand Down
22 changes: 22 additions & 0 deletions packages/dvilela/skills/memeooorr_abci/behaviour_classes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,17 @@ def get_meme_available_actions(
if is_unleashed or seconds_since_summon > 48 * 3600:
available_actions.remove("heart")

# We should not heart if we have summoned this token
if (
"heart" in available_actions
and meme_data["summoner"] == self.synchronized_data.safe_contract_address
):
available_actions.remove("heart")

# We should not heart if we have already hearted
if "heart" in available_actions and meme_data["token_address"] in hearted_memes:
available_actions.remove("heart")

# We use 47.5 to be on the safe side
if seconds_since_summon < 47.5 * 3600:
if "unleash" in available_actions:
Expand Down Expand Up @@ -399,3 +410,14 @@ def get_meme_coins(self) -> Generator[None, None, Optional[List]]:

meme_coins = yield from self.get_meme_coins_from_chain()
return meme_coins

def get_min_deploy_value(self) -> int:
"""Get min deploy value"""
if self.get_chain_id() == "base":
return int(0.01 * 1e18)

if self.get_chain_id() == "celo":
return 10

# Should not happen
return 0
19 changes: 2 additions & 17 deletions packages/dvilela/skills/memeooorr_abci/behaviour_classes/chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
ZERO_VALUE = 0
TWO_MINUTES = 120
SUMMON_BLOCK_DELTA = 100000
AVAILABLE_ACTIONS = ["heart", "unleash", "collect", "purge", "burn"]


class ChainBehaviour(MemeooorrBaseBehaviour, ABC): # pylint: disable=too-many-ancestors
Expand Down Expand Up @@ -245,17 +244,6 @@ def get_tx_hash( # pylint: disable=too-many-locals

return tx_hash, tx_flag, token_nonce

def get_min_deploy_value(self) -> int:
"""Get min deploy value"""
if self.get_chain_id() == "base":
return int(0.01 * 1e18)

if self.get_chain_id() == "celo":
return 10

# Should not happen
return 0

def get_deployment_tx(self) -> Generator[None, None, Optional[str]]:
"""Prepare a deployment tx"""

Expand All @@ -266,11 +254,7 @@ def get_deployment_tx(self) -> Generator[None, None, Optional[str]]:
if data_hex is None:
return None

value = max(
int(self.synchronized_data.token_data["amount"]),
self.get_min_deploy_value(),
)

value = self.synchronized_data.token_data["amount"]
self.context.logger.info(f"Deployment value is {value}")

# Prepare safe transaction
Expand Down Expand Up @@ -361,6 +345,7 @@ def async_act(self) -> Generator:

with self.context.benchmark_tool.measure(self.behaviour_id).local():
meme_coins = yield from self.get_meme_coins()
self.context.logger.info(f"Meme token list: {meme_coins}")

payload = PullMemesPayload(
sender=self.context.agent_address,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,13 @@ def get_event( # pylint: disable=too-many-locals,too-many-return-statements
self.context.logger.info("Tweet is none")
return Event.WAIT.value, None, None, None, None, None

# Fix amount if it is lower than the min required amount
if action == "heart":
amount = max(
amount,
self.get_min_deploy_value(),
)

self.context.logger.info("The LLM returned a valid response")
return Event.DONE.value, token_nonce, token_address, action, amount, tweet

Expand Down
8 changes: 4 additions & 4 deletions packages/dvilela/skills/memeooorr_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ aea_version: '>=1.0.0, <2.0.0'
fingerprint:
__init__.py: bafybeidorrnxjv4n4ngovxnu4mzod46kyrdncfmli4hapqeqnzp7imq7hm
behaviour_classes/__init__.py: bafybeicjks4kxsb2r6a4armmaqxyxngwm3pouegq3fycm37rbe7otiwsre
behaviour_classes/base.py: bafybeiantxmu4uwmmxllxchrrtldudzrjtwhifoyulkoexn4ehborq3ouu
behaviour_classes/chain.py: bafybeiankzdgjmdo3dysbhbqmlovjtqlwl2aajimd45ujkwcygcam7qjiy
behaviour_classes/base.py: bafybeibpjk3e3hla3bmm5ehc3s5gpkt2qwuti2uw4rf63vbna4sedwen2m
behaviour_classes/chain.py: bafybeih34nhn7r2xq6lexic4xkn2pz56ns7mau3iswejhe3awiys7pc4ve
behaviour_classes/db.py: bafybeieuhjes2gsiidepjxcojgnn3swx2znem5uwvz7rwkxpwls3dmlxf4
behaviour_classes/llm.py: bafybeic4gmodpevko6iqf7qpmjsyyi5f3iql5yr4md3hm6fnsuksb6bdye
behaviour_classes/llm.py: bafybeicrtm5dkbz3nuxsvesygjjjtlshiamca53h7ukijnxxrvzjytghwm
behaviour_classes/twitter.py: bafybeifbas6ilnp2plzrpttwkvnuracppudlz3nhsvbq4bugwsm5qgjeiq
behaviours.py: bafybeibdbimezloiomvsv3zgfdug4tw276gt7tb5agnezl2nuqcfcplscu
dialogues.py: bafybeiaygigeleloplgrsg2sovv463uvzk3zc2tupgazn4ak2vqcangksu
Expand All @@ -31,7 +31,7 @@ connections:
- valory/http_server:0.22.0:bafybeihpgu56ovmq4npazdbh6y6ru5i7zuv6wvdglpxavsckyih56smu7m
contracts:
- valory/gnosis_safe:0.1.0:bafybeiho6sbfts3zk3mftrngw37d5qnlvkqtnttt3fzexmcwkeevhu4wwi
- dvilela/meme_factory:0.1.0:bafybeiernwylranvc42xzzfkcitx64c5i3fwpan4j4lo2srcxfre6g6434
- dvilela/meme_factory:0.1.0:bafybeiecfhn33jiprqrz6kx565cexy6yq5pqsg2bltgzq6bbg3uusepj7i
protocols:
- valory/srr:0.1.0:bafybeihrixgptxuqpf2s4nujypwlv5aed2nboozq5kl4c26cxw6r7si2x4
- dvilela/kv_store:0.1.0:bafybeihimf5f37uupxmugvagmaxworgmz7cxuqpikkyzlgldtbq46jbvci
Expand Down
2 changes: 1 addition & 1 deletion packages/dvilela/skills/memeooorr_chained_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ skills:
- valory/reset_pause_abci:0.1.0:bafybeievjciqdvxhqxfjd4whqs27h6qbxqzrae7wwj7fpvxlvmtw3x35im
- valory/transaction_settlement_abci:0.1.0:bafybeihq2yenstblmaadzcjousowj5kfn5l7ns5pxweq2gcrsczfyq5wzm
- valory/termination_abci:0.1.0:bafybeid54buqxipiuduw7b6nnliiwsxajnltseuroad53wukfonpxca2om
- dvilela/memeooorr_abci:0.1.0:bafybeigepnfuelhzrq7kvlvqnwip7vi64o2ihvtmsgl67kvbki4vs4gjja
- dvilela/memeooorr_abci:0.1.0:bafybeihrlpxsgizz2pyxltqvgz27st37mqhvwutgp63vcxb5l7zbdnuzha
behaviours:
main:
args: {}
Expand Down
10 changes: 5 additions & 5 deletions packages/packages.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"dev": {
"contract/dvilela/meme_factory/0.1.0": "bafybeiernwylranvc42xzzfkcitx64c5i3fwpan4j4lo2srcxfre6g6434",
"contract/dvilela/meme_factory/0.1.0": "bafybeiecfhn33jiprqrz6kx565cexy6yq5pqsg2bltgzq6bbg3uusepj7i",
"connection/dvilela/twikit/0.1.0": "bafybeifelwkeycvrqtgm5alln5n4ijqibi7cizgsu5oxndrei4exl77yjy",
"skill/dvilela/memeooorr_abci/0.1.0": "bafybeigepnfuelhzrq7kvlvqnwip7vi64o2ihvtmsgl67kvbki4vs4gjja",
"skill/dvilela/memeooorr_chained_abci/0.1.0": "bafybeiaajjgtye7vfpsdndzunw2mqtdgnv7bls3x5ngakaimgbtuir6xg4",
"agent/dvilela/memeooorr/0.1.0": "bafybeihocacd7vyqzb7i7bcx2enzoxcdfngy4tnzzbiqjnc4dbm6jh43z4",
"service/dvilela/memeooorr/0.1.0": "bafybeiffmifpmc6pi6qjcooyjitz3y5rhttxzqrmrkpuzqs3noq6p3kyem"
"skill/dvilela/memeooorr_abci/0.1.0": "bafybeihrlpxsgizz2pyxltqvgz27st37mqhvwutgp63vcxb5l7zbdnuzha",
"skill/dvilela/memeooorr_chained_abci/0.1.0": "bafybeih2jky7jltrizivivccparrf4wj6xqugp47y4gawgdoms2lvvnwiu",
"agent/dvilela/memeooorr/0.1.0": "bafybeia73asshot6f2q4426uenpu6plfboxwr7rmb7jndl6ndtdkt3ko2q",
"service/dvilela/memeooorr/0.1.0": "bafybeifijaffng4aksgfxixk4sbjdzu7zsn3ygr7qq3ldtysti5ulvqwde"
},
"third_party": {
"protocol/open_aea/signing/1.0.0": "bafybeihv62fim3wl2bayavfcg3u5e5cxu3b7brtu4cn5xoxd6lqwachasi",
Expand Down
48 changes: 48 additions & 0 deletions scripts/ffw_tenderly.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2021-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.
#
# ------------------------------------------------------------------------------

"""FFW Tenderly"""

import os

import requests
from dotenv import load_dotenv


load_dotenv(override=True)

TENDERLY_ADMIN_RPC = os.getenv("TENDERLY_ADMIN_RPC")

json_data = {
"jsonrpc": "2.0",
"method": "tenderly_setNextBlockTimestamp",
"params": ["1734109475"],
"id": "1234",
}


response = requests.post(
url=TENDERLY_ADMIN_RPC,
headers={"Content-Type": "application/json"},
json=json_data,
timeout=300,
)

print(response)
2 changes: 1 addition & 1 deletion scripts/rebuild_tenderly.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

TENDERLY_VNETS_JSON = "tenderly_vnets.json"

load_dotenv()
load_dotenv(override=True)


def _delete_vnet(
Expand Down

0 comments on commit af601e3

Please sign in to comment.