Skip to content

Commit

Permalink
make cli interact work on base
Browse files Browse the repository at this point in the history
  • Loading branch information
KahanMajmudar committed Nov 26, 2024
1 parent 5c49d67 commit 3cd5ac3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mech_client/configs/mechs.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@
"default_gas_price_strategy": "eip1559",
"is_gas_estimation_enabled": false
},
"gas_limit": 100000,
"contract_abi_url": "https://api.basescan.org/api?module=contract&action=getabi&address={contract_address}",
"gas_limit": 250000,
"price": 3000000000000,
"contract_abi_url": "https://api.basescan.org/api?module=contract&action=getabi&address={contract_address}&apikey={api_key}",
"transaction_url": "https://basescan.org/tx/{transaction_digest}",
"subgraph_url": ""
},
Expand Down
10 changes: 10 additions & 0 deletions mech_client/interact.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class MechConfig: # pylint: disable=too-many-instance-attributes
contract_abi_url: str
transaction_url: str
subgraph_url: str
price: int

def __post_init__(self) -> None:
"""Post initialization to override with environment variables."""
Expand Down Expand Up @@ -143,6 +144,13 @@ def __post_init__(self) -> None:
if subgraph_url:
self.subgraph_url = subgraph_url

api_key = os.getenv("MECHX_API_KEY")
if api_key:
updated_contract_abi_url = self.contract_abi_url.replace(
"{api_key}", api_key
)
self.contract_abi_url = updated_contract_abi_url


class ConfirmationType(Enum):
"""Verification type."""
Expand Down Expand Up @@ -587,11 +595,13 @@ def interact( # pylint: disable=too-many-arguments,too-many-locals
deliver_signature=deliver_event_signature,
)
print("Sending Mech request...")
price = mech_config.price or 10_000_000_000_000_000
transaction_digest = send_request(
crypto=crypto,
ledger_api=ledger_api,
mech_contract=mech_contract,
gas_limit=mech_config.gas_limit,
price=price,
prompt=prompt,
tool=tool,
extra_attributes=extra_attributes,
Expand Down
4 changes: 4 additions & 0 deletions mech_client/subgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,12 @@ def query_agent_address( # pylint: disable=too-many-return-statements
:rtype: Optional[str]
"""
# temporary hard coded until subgraph present
if chain_config == "base" and agent_id == 1:
return "0x37C484cc34408d0F827DB4d7B6e54b8837Bf8BDA"
if chain_config == "base" and agent_id == 2:
return "0x111D7DB1B752AB4D2cC0286983D9bd73a49bac6c"
if chain_config == "base" and agent_id == 3:
return "0x111D7DB1B752AB4D2cC0286983D9bd73a49bac6c"
if chain_config == "arbitrum" and agent_id == 2:
return "0x1FDAD3a5af5E96e5a64Fc0662B1814458F114597"
if chain_config == "polygon" and agent_id == 2:
Expand Down

0 comments on commit 3cd5ac3

Please sign in to comment.