Skip to content

Commit

Permalink
chore: further simplifying the helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
aorumbayev committed Jul 11, 2024
1 parent 1a16e4b commit 7518c93
Show file tree
Hide file tree
Showing 61 changed files with 90 additions and 990 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,10 @@
"description": "Uncomment the following lines to enable complementary utilities that will generate artifacts required for the [AlgoKit AVM Debugger](https://github.com/algorandfoundation/algokit-avm-vscode-debugger) VSCode plugin available on the [VSCode Extension Marketplace](https://marketplace.visualstudio.com/items?itemName=algorandfoundation.algokit-avm-vscode-debugger). A new folder will be automatically created in the `.algokit` directory with source maps of all TEAL contracts in this workspace, as well as traces that will appear in a folder at the root of the workspace. You can then use the traces as entry points to trigger the debug extension. Make sure to have the `.algokit.toml` file available at the root of the workspace.",
"line": 15
}
{
"file": "smart_contracts/_helpers/__init__.py",
"description": "This folder contains helper scripts for contract management. These automate tasks like compiling, generating clients, and deploying. Usually, you won't need to edit these files, but advanced users can expand them for custom needs.",
"line": 1
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

from dotenv import load_dotenv

from smart_contracts.config import contracts
from smart_contracts.helpers.build import build
from smart_contracts.helpers.deploy import deploy
from smart_contracts.helpers.util import find_app_spec_file
from smart_contracts._helpers.build import build
from smart_contracts._helpers.config import contracts
from smart_contracts._helpers.deploy import deploy

# Uncomment the following lines to enable auto generation of AVM Debugger compliant sourcemap and simulation trace file.
# Learn more about using AlgoKit AVM Debugger to debug your TEAL source codes and inspect various kinds of
Expand Down Expand Up @@ -36,7 +35,14 @@ def main(action: str) -> None:
for contract in contracts:
logger.info(f"Deploying app {contract.name}")
output_dir = artifact_path / contract.name
app_spec_file_name = find_app_spec_file(output_dir)
app_spec_file_name = next(
(
file.name
for file in output_dir.iterdir()
if file.is_file() and file.suffixes == [".arc32", ".json"]
),
None,
)
if app_spec_file_name is None:
raise Exception("Could not deploy app, .arc32.json file not found")
app_spec_path = output_dir / app_spec_file_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
from pathlib import Path
from shutil import rmtree

from smart_contracts.helpers.util import find_app_spec_files

logger = logging.getLogger(__name__)
deployment_extension = "py"

Expand Down Expand Up @@ -41,7 +39,7 @@ def build(output_dir: Path, contract_path: Path) -> Path:
if build_result.returncode:
raise Exception(f"Could not build contract:\n{build_result.stdout}")

app_spec_file_names = find_app_spec_files(output_dir)
app_spec_file_names = [file.name for file in output_dir.glob("*.arc32.json")]

for app_spec_file_name in app_spec_file_names:
if app_spec_file_name is None:
Expand Down Expand Up @@ -73,4 +71,4 @@ def build(output_dir: Path, contract_path: Path) -> Path:
f"Could not generate typed client:\n{generate_result.stdout}"
)

return output_dir
return output_dir / app_spec_file_name

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,10 @@
"description": "Uncomment the following lines to enable complementary utilities that will generate artifacts required for the [AlgoKit AVM Debugger](https://github.com/algorandfoundation/algokit-avm-vscode-debugger) VSCode plugin available on the [VSCode Extension Marketplace](https://marketplace.visualstudio.com/items?itemName=algorandfoundation.algokit-avm-vscode-debugger). A new folder will be automatically created in the `.algokit` directory with source maps of all TEAL contracts in this workspace, as well as traces that will appear in a folder at the root of the workspace. You can then use the traces as entry points to trigger the debug extension. Make sure to have the `.algokit.toml` file available at the root of the workspace.",
"line": 15
}
{
"file": "smart_contracts/_helpers/__init__.py",
"description": "This folder contains helper scripts for contract management. These automate tasks like compiling, generating clients, and deploying. Usually, you won't need to edit these files, but advanced users can expand them for custom needs.",
"line": 1
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from dotenv import load_dotenv

from smart_contracts.config import contracts
from smart_contracts.helpers.build import build
from smart_contracts._helpers.build import build
from smart_contracts._helpers.config import contracts

logging.basicConfig(
level=logging.DEBUG, format="%(asctime)s %(levelname)-10s: %(message)s"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
from pathlib import Path
from shutil import rmtree

from smart_contracts.helpers.util import find_app_spec_files

logger = logging.getLogger(__name__)
deployment_extension = "ts"

Expand Down Expand Up @@ -41,7 +39,7 @@ def build(output_dir: Path, contract_path: Path) -> Path:
if build_result.returncode:
raise Exception(f"Could not build contract:\n{build_result.stdout}")

app_spec_file_names = find_app_spec_files(output_dir)
app_spec_file_names = [file.name for file in output_dir.glob("*.arc32.json")]

for app_spec_file_name in app_spec_file_names:
if app_spec_file_name is None:
Expand Down Expand Up @@ -73,4 +71,4 @@ def build(output_dir: Path, contract_path: Path) -> Path:
f"Could not generate typed client:\n{generate_result.stdout}"
)

return output_dir
return output_dir / app_spec_file_name

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,10 @@
"description": "Uncomment the following lines to enable complementary utilities that will generate artifacts required for the [AlgoKit AVM Debugger](https://github.com/algorandfoundation/algokit-avm-vscode-debugger) VSCode plugin available on the [VSCode Extension Marketplace](https://marketplace.visualstudio.com/items?itemName=algorandfoundation.algokit-avm-vscode-debugger). A new folder will be automatically created in the `.algokit` directory with source maps of all TEAL contracts in this workspace, as well as traces that will appear in a folder at the root of the workspace. You can then use the traces as entry points to trigger the debug extension. Make sure to have the `.algokit.toml` file available at the root of the workspace.",
"line": 15
}
{
"file": "smart_contracts/_helpers/__init__.py",
"description": "This folder contains helper scripts for contract management. These automate tasks like compiling, generating clients, and deploying. Usually, you won't need to edit these files, but advanced users can expand them for custom needs.",
"line": 1
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

from dotenv import load_dotenv

from smart_contracts.config import contracts
from smart_contracts.helpers.build import build
from smart_contracts.helpers.deploy import deploy
from smart_contracts.helpers.util import find_app_spec_file
from smart_contracts._helpers.build import build
from smart_contracts._helpers.config import contracts
from smart_contracts._helpers.deploy import deploy

# Uncomment the following lines to enable auto generation of AVM Debugger compliant sourcemap and simulation trace file.
# Learn more about using AlgoKit AVM Debugger to debug your TEAL source codes and inspect various kinds of
Expand Down Expand Up @@ -36,7 +35,14 @@ def main(action: str) -> None:
for contract in contracts:
logger.info(f"Deploying app {contract.name}")
output_dir = artifact_path / contract.name
app_spec_file_name = find_app_spec_file(output_dir)
app_spec_file_name = next(
(
file.name
for file in output_dir.iterdir()
if file.is_file() and file.suffixes == [".arc32", ".json"]
),
None,
)
if app_spec_file_name is None:
raise Exception("Could not deploy app, .arc32.json file not found")
app_spec_path = output_dir / app_spec_file_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
from pathlib import Path
from shutil import rmtree

from smart_contracts.helpers.util import find_app_spec_files

logger = logging.getLogger(__name__)
deployment_extension = "py"

Expand Down Expand Up @@ -41,7 +39,7 @@ def build(output_dir: Path, contract_path: Path) -> Path:
if build_result.returncode:
raise Exception(f"Could not build contract:\n{build_result.stdout}")

app_spec_file_names = find_app_spec_files(output_dir)
app_spec_file_names = [file.name for file in output_dir.glob("*.arc32.json")]

for app_spec_file_name in app_spec_file_names:
if app_spec_file_name is None:
Expand Down Expand Up @@ -73,4 +71,4 @@ def build(output_dir: Path, contract_path: Path) -> Path:
f"Could not generate typed client:\n{generate_result.stdout}"
)

return output_dir
return output_dir / app_spec_file_name

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,10 @@
"description": "Uncomment the following lines to enable complementary utilities that will generate artifacts required for the [AlgoKit AVM Debugger](https://github.com/algorandfoundation/algokit-avm-vscode-debugger) VSCode plugin available on the [VSCode Extension Marketplace](https://marketplace.visualstudio.com/items?itemName=algorandfoundation.algokit-avm-vscode-debugger). A new folder will be automatically created in the `.algokit` directory with source maps of all TEAL contracts in this workspace, as well as traces that will appear in a folder at the root of the workspace. You can then use the traces as entry points to trigger the debug extension. Make sure to have the `.algokit.toml` file available at the root of the workspace.",
"line": 15
}
{
"file": "smart_contracts/_helpers/__init__.py",
"description": "This folder contains helper scripts for contract management. These automate tasks like compiling, generating clients, and deploying. Usually, you won't need to edit these files, but advanced users can expand them for custom needs.",
"line": 1
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from dotenv import load_dotenv

from smart_contracts.config import contracts
from smart_contracts.helpers.build import build
from smart_contracts._helpers.build import build
from smart_contracts._helpers.config import contracts

logging.basicConfig(
level=logging.DEBUG, format="%(asctime)s %(levelname)-10s: %(message)s"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
from pathlib import Path
from shutil import rmtree

from smart_contracts.helpers.util import find_app_spec_files

logger = logging.getLogger(__name__)
deployment_extension = "ts"

Expand Down Expand Up @@ -41,7 +39,7 @@ def build(output_dir: Path, contract_path: Path) -> Path:
if build_result.returncode:
raise Exception(f"Could not build contract:\n{build_result.stdout}")

app_spec_file_names = find_app_spec_files(output_dir)
app_spec_file_names = [file.name for file in output_dir.glob("*.arc32.json")]

for app_spec_file_name in app_spec_file_names:
if app_spec_file_name is None:
Expand Down Expand Up @@ -73,4 +71,4 @@ def build(output_dir: Path, contract_path: Path) -> Path:
f"Could not generate typed client:\n{generate_result.stdout}"
)

return output_dir
return output_dir / app_spec_file_name

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,10 @@
"description": "Uncomment the following lines to enable complementary utilities that will generate artifacts required for the [AlgoKit AVM Debugger](https://github.com/algorandfoundation/algokit-avm-vscode-debugger) VSCode plugin available on the [VSCode Extension Marketplace](https://marketplace.visualstudio.com/items?itemName=algorandfoundation.algokit-avm-vscode-debugger). A new folder will be automatically created in the `.algokit` directory with source maps of all TEAL contracts in this workspace, as well as traces that will appear in a folder at the root of the workspace. You can then use the traces as entry points to trigger the debug extension. Make sure to have the `.algokit.toml` file available at the root of the workspace.",
"line": 15
}
{
"file": "smart_contracts/_helpers/__init__.py",
"description": "This folder contains helper scripts for contract management. These automate tasks like compiling, generating clients, and deploying. Usually, you won't need to edit these files, but advanced users can expand them for custom needs.",
"line": 1
}
]
}
16 changes: 11 additions & 5 deletions examples/production_python/smart_contracts/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

from dotenv import load_dotenv

from smart_contracts.config import contracts
from smart_contracts.helpers.build import build
from smart_contracts.helpers.deploy import deploy
from smart_contracts.helpers.util import find_app_spec_file
from smart_contracts._helpers.build import build
from smart_contracts._helpers.config import contracts
from smart_contracts._helpers.deploy import deploy

# Uncomment the following lines to enable auto generation of AVM Debugger compliant sourcemap and simulation trace file.
# Learn more about using AlgoKit AVM Debugger to debug your TEAL source codes and inspect various kinds of
Expand Down Expand Up @@ -36,7 +35,14 @@ def main(action: str) -> None:
for contract in contracts:
logger.info(f"Deploying app {contract.name}")
output_dir = artifact_path / contract.name
app_spec_file_name = find_app_spec_file(output_dir)
app_spec_file_name = next(
(
file.name
for file in output_dir.iterdir()
if file.is_file() and file.suffixes == [".arc32", ".json"]
),
None,
)
if app_spec_file_name is None:
raise Exception("Could not deploy app, .arc32.json file not found")
app_spec_path = output_dir / app_spec_file_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
from pathlib import Path
from shutil import rmtree

from smart_contracts.helpers.util import find_app_spec_files

logger = logging.getLogger(__name__)
deployment_extension = "py"

Expand Down Expand Up @@ -41,7 +39,7 @@ def build(output_dir: Path, contract_path: Path) -> Path:
if build_result.returncode:
raise Exception(f"Could not build contract:\n{build_result.stdout}")

app_spec_file_names = find_app_spec_files(output_dir)
app_spec_file_names = [file.name for file in output_dir.glob("*.arc32.json")]

for app_spec_file_name in app_spec_file_names:
if app_spec_file_name is None:
Expand Down Expand Up @@ -73,4 +71,4 @@ def build(output_dir: Path, contract_path: Path) -> Path:
f"Could not generate typed client:\n{generate_result.stdout}"
)

return output_dir
return output_dir / app_spec_file_name
12 changes: 0 additions & 12 deletions examples/production_python/smart_contracts/helpers/util.py

This file was deleted.

42 changes: 0 additions & 42 deletions examples/starter_python/.algokit.toml

This file was deleted.

Loading

0 comments on commit 7518c93

Please sign in to comment.