Skip to content
This repository has been archived by the owner on Jan 9, 2025. It is now read-only.

Commit

Permalink
make toml available to deployer docker imge (#1020)
Browse files Browse the repository at this point in the history
<!--- Please provide a general summary of your changes in the title
above -->

## Pull request type

<!-- Please try to limit your pull request to one type,
submit multiple pull requests if needed. -->

Please check the type of change your PR introduces:

- [ ] Bugfix
- [ ] Feature
- [ ] Code style update (formatting, renaming)
- [ ] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
- [ ] Documentation content changes
- [ ] Other (please describe):

## What is the current behavior?

<!-- Please describe the current behavior that you are modifying,
or link to a relevant issue. -->

Resolves #1019 


Context:
- `get_eoa` is in kakarot.py file
- kakarot.py file uses toml package
- deploy_kakarot.py uses get_eoa
- toml is called in the deployer docker image
- toml is a dev dep, and is not available in the docker image
- fail ⚠️

Solutions:
- split kakarot.py in order to not try to import toml for the following
functions: `get_eoa` and the ones it uses (~5 in the same file) =>
cleaner but overkill for 1 dependency
- add toml as real dependency => quick and dirty but fast

<!-- Reviewable:start -->
- - -
This change is [<img src="https://reviewable.io/review_button.svg"
height="34" align="absmiddle"
alt="Reviewable"/>](https://reviewable.io/reviews/kkrt-labs/kakarot/1020)
<!-- Reviewable:end -->
  • Loading branch information
Eikix authored Mar 7, 2024
1 parent 3f9326e commit 9d5c894
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions scripts/utils/kakarot.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from types import MethodType
from typing import List, Optional, Union, cast

import toml
from eth_abi.exceptions import InsufficientDataBytes
from eth_account import Account as EvmAccount
from eth_account._utils.typed_transactions import TypedTransaction
Expand Down Expand Up @@ -52,11 +51,6 @@
f"Using network {NETWORK['name']}, couldn't fetch deployment, error:\n{e}"
)

try:
FOUNDRY_FILE = toml.loads((Path(__file__).parents[2] / "foundry.toml").read_text())
except (NameError, FileNotFoundError):
FOUNDRY_FILE = toml.loads(Path("foundry.toml").read_text())


class EvmTransactionError(Exception):
pass
Expand All @@ -69,17 +63,26 @@ def get_contract(
address=None,
caller_eoa: Optional[Account] = None,
) -> Web3Contract:
import toml

try:
foundry_file = toml.loads(
(Path(__file__).parents[2] / "foundry.toml").read_text()
)
except (NameError, FileNotFoundError):
foundry_file = toml.loads(Path("foundry.toml").read_text())

all_compilation_outputs = [
json.load(open(file))
for file in Path(FOUNDRY_FILE["profile"]["default"]["out"]).glob(
for file in Path(foundry_file["profile"]["default"]["out"]).glob(
f"**/{contract_name}.json"
)
]
if len(all_compilation_outputs) == 1:
target_compilation_output = all_compilation_outputs[0]
else:
target_solidity_file_path = list(
(Path(FOUNDRY_FILE["profile"]["default"]["src"]) / contract_app).glob(
(Path(foundry_file["profile"]["default"]["src"]) / contract_app).glob(
f"**/{contract_name}.sol"
)
)
Expand Down

0 comments on commit 9d5c894

Please sign in to comment.