Skip to content

Commit

Permalink
Merge pull request #26 from valory-xyz/chore/formatters
Browse files Browse the repository at this point in the history
Run formatters
  • Loading branch information
angrybayblade authored Feb 28, 2024
2 parents 42b402e + 89ee6ff commit 554173f
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 19 deletions.
9 changes: 5 additions & 4 deletions operate/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,18 @@

from aea_ledger_ethereum.ethereum import EthereumCrypto
from clea import group, params, run
from operate.constants import KEY, KEYS, OPERATE, SERVICES
from operate.http import Resource
from operate.keys import Keys
from operate.services.manage import Services
from starlette.applications import Starlette
from starlette.middleware import Middleware
from starlette.middleware.cors import CORSMiddleware
from starlette.routing import Route
from typing_extensions import Annotated
from uvicorn.main import run as uvicorn

from operate.constants import KEY, KEYS, OPERATE, SERVICES
from operate.http import Resource
from operate.keys import Keys
from operate.services.manage import Services

DEFAULT_HARDHAT_KEY = (
"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
).encode()
Expand Down
1 change: 0 additions & 1 deletion operate/data/contracts/uniswap_v2_erc20/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from aea.contracts.base import Contract
from aea_ledger_ethereum import EthereumApi


PUBLIC_ID = PublicId.from_str("valory/uniswap_v2_erc20:0.1.0")

_logger = logging.getLogger(
Expand Down
3 changes: 2 additions & 1 deletion operate/http/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@
import typing as t
from abc import ABC

from operate.http.exceptions import NotAllowed, ResourceException
from starlette.requests import Request
from starlette.responses import JSONResponse
from starlette.types import Receive, Scope, Send

from operate.http.exceptions import NotAllowed, ResourceException

GenericResource = t.TypeVar("GenericResource")
PostPayload = t.TypeVar("PostPayload")
PostResponse = t.TypeVar("PostResponse")
Expand Down
1 change: 1 addition & 0 deletions operate/keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from pathlib import Path

from aea_ledger_ethereum.ethereum import EthereumCrypto

from operate.types import KeyType


Expand Down
1 change: 1 addition & 0 deletions operate/ledger/ethereum.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import typing as t

from aea_ledger_ethereum import EthereumApi, EthereumCrypto

from operate.ledger.base import LedgerHelper
from operate.types import LedgerType

Expand Down
41 changes: 28 additions & 13 deletions scripts/fund.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"""Fund an address on gnosis fork."""

import sys
import json
import os
from aea_ledger_ethereum.ethereum import EthereumApi, EthereumCrypto
import sys
from pathlib import Path
import json

from aea_ledger_ethereum.ethereum import EthereumApi, EthereumCrypto
from dotenv import load_dotenv

OLAS_CONTRACT_ADDRESS_GNOSIS = "0xcE11e14225575945b8E6Dc0D4F2dD4C570f79d9f"
Expand All @@ -31,23 +32,37 @@
if staking_keys_path:
staking_crypto = EthereumCrypto(staking_keys_path)

with open(Path("operate", "data", "contracts", "uniswap_v2_erc20", "build", "IUniswapV2ERC20.json"), "r") as abi_file:
with open(
Path(
"operate",
"data",
"contracts",
"uniswap_v2_erc20",
"build",
"IUniswapV2ERC20.json",
),
"r",
) as abi_file:
abi = json.load(abi_file)["abi"]

olas_contract = ledger_api.api.eth.contract(
address=ledger_api.api.to_checksum_address(OLAS_CONTRACT_ADDRESS_GNOSIS),
abi=abi
abi=abi,
)

tx = olas_contract.functions.transfer(address, int(2e18)).build_transaction({
"chainId": 100,
"gas": 100000,
"gasPrice": ledger_api.api.to_wei("50", "gwei"),
"nonce": ledger_api.api.eth.get_transaction_count(staking_crypto.address),
})
tx = olas_contract.functions.transfer(address, int(2e18)).build_transaction(
{
"chainId": 100,
"gas": 100000,
"gasPrice": ledger_api.api.to_wei("50", "gwei"),
"nonce": ledger_api.api.eth.get_transaction_count(staking_crypto.address),
}
)

signed_txn = ledger_api.api.eth.account.sign_transaction(tx, staking_crypto.private_key)
signed_txn = ledger_api.api.eth.account.sign_transaction(
tx, staking_crypto.private_key
)
tx_hash = ledger_api.api.eth.send_raw_transaction(signed_txn.rawTransaction)

balance = olas_contract.functions.balanceOf(address).call()
print(f"Balance of {address} = {balance/1e18} OLAS")
print(f"Balance of {address} = {balance/1e18} OLAS")

0 comments on commit 554173f

Please sign in to comment.