Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions algokit-utils-py
Submodule algokit-utils-py added at 816b54
10 changes: 10 additions & 0 deletions codespace_algorand/.algokit.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[algokit]
min_version = "v1.12.1"

[project]
type = 'workspace'
projects_root_path = 'projects'

[generate.devcontainer]
description = "Generate a default 'devcontainer.json' configuration that pre-installs algokit and launches Algorand sandbox as part of codespace container provisioning."
path = ".algokit/generators/create-devcontainer"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
_tasks:
- "echo '==== Successfully generated new .devcontainer.json file 🚀 ===='"

_templates_suffix: ".j2"
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"forwardPorts": [4001, 4002, 8980, 5173],
"portsAttributes": {
"4001": {
"label": "algod"
},
"4002": {
"label": "kmd"
},
"8980": {
"label": "indexer"
},
"5173": {
"label": "vite"
}
},
"postCreateCommand": "mkdir -p ~/.config/algokit && pipx install algokit && sudo chown -R codespace:codespace ~/.config/algokit",
"postStartCommand": "for i in {1..5}; do algokit localnet status > /dev/null 2>&1 && break || sleep 30; algokit localnet reset; done"
}
10 changes: 10 additions & 0 deletions codespace_algorand/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[*]
charset = utf-8
insert_final_newline = true
end_of_line = lf
indent_style = space
indent_size = 2
tab_width = 2
max_line_length = 140
trim_trailing_whitespace = true
single_quote = true
1 change: 1 addition & 0 deletions codespace_algorand/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
170 changes: 170 additions & 0 deletions codespace_algorand/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Ruff (linter)
.ruff_cache/

# Cython debug symbols
cython_debug/

# PyCharm
.idea/
!.idea/runConfigurations

# macOS
.DS_Store

# Received approval test files
*.received.*

# NPM
node_modules

5 changes: 5 additions & 0 deletions codespace_algorand/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
// Disabled due to matangover.mypy extension not supporting monorepos
// To be addressed as part of https://github.com/matangover/mypy-vscode/issues/82
"mypy.enabled": false
}
22 changes: 22 additions & 0 deletions codespace_algorand/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# codespace_algorand

Welcome to your new AlgoKit project!

This is your workspace root. A `workspace` in AlgoKit is an orchestrated collection of standalone projects (backends, smart contracts, frontend apps and etc).

By default, `projects_root_path` parameter is set to `projects`. Which instructs AlgoKit CLI to create a new directory under `projects` directory when new project is instantiated via `algokit init` at the root of the workspace.

## Getting Started

To get started refer to `README.md` files in respective sub-projects in the `projects` directory.

To learn more about algokit, visit [documentation](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/algokit.md).

### GitHub Codespaces

To get started execute:

1. `algokit generate devcontainer` - invoking this command from the root of this repository will create a `devcontainer.json` file with all the configuration needed to run this project in a GitHub codespace. [Run the repository inside a codespace](https://docs.github.com/en/codespaces/getting-started/quickstart) to get started.
2. `algokit init` - invoke this command inside a github codespace to launch an interactive wizard to guide you through the process of creating a new AlgoKit project

Powered by [Copier templates](https://copier.readthedocs.io/en/stable/).
32 changes: 32 additions & 0 deletions codespace_algorand/codespace_algorand.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"folders": [
{
"path": "./",
"name": "ROOT"
},
{
"path": "projects/codespace_algorand"
}
],
"settings": {
"files.exclude": {
"projects/": true
},
"jest.disabledWorkspaceFolders": [
"ROOT",
"projects"
]
},
"extensions": {
"recommendations": [
"joshx.workspace-terminals"
]
},
"tasks": {
"version": "2.0.0",
"tasks": []
},
"launch": {
"configurations": []
}
}
Empty file.
42 changes: 42 additions & 0 deletions codespace_algorand/projects/codespace_algorand/.algokit.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[algokit]
min_version = "v2.0.0"

[generate.smart-contract]
description = "Generate a new smart contract for existing project"
path = ".algokit/generators/create_contract"

[generate.env-file]
description = "Generate a new generic or Algorand network specific .env file"
path = ".algokit/generators/create_env_file"

[project]
type = 'contract'
name = 'codespace_algorand'
artifacts = 'smart_contracts/artifacts'

[project.deploy]
command = "poetry run python -m smart_contracts deploy"
environment_secrets = [
"DEPLOYER_MNEMONIC",
]

[project.deploy.localnet]
environment_secrets = []

[project.run]
# Commands intented for use locally and in CI
build = { commands = [
'poetry run python -m smart_contracts build',
], description = 'Build all smart contracts in the project' }
lint = { commands = [
], description = 'Perform linting' }
audit-teal = { commands = [
# 🚨 IMPORTANT 🚨: For strict TEAL validation, remove --exclude statements. The default starter contract is not for production. Ensure thorough testing and adherence to best practices in smart contract development. This is not a replacement for a professional audit.
'algokit task analyze smart_contracts/artifacts --recursive --force --exclude rekey-to --exclude is-updatable --exclude missing-fee-check --exclude is-deletable --exclude can-close-asset --exclude can-close-account --exclude unprotected-deletable --exclude unprotected-updatable',
], description = 'Audit TEAL files' }

# Commands intented for CI only, prefixed with `ci-` by convention
ci-teal-diff = { commands = [
'git add -N ./smart_contracts/artifacts',
'git diff --exit-code --minimal ./smart_contracts/artifacts',
], description = 'Check TEAL files for differences' }
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: 1.3.2
_src_path: gh:algorandfoundation/algokit-python-template
author_email: jvchan@alum.mit.edu
author_name: JuliaBubble1
contract_name: hello_world
deployment_language: python
preset_name: starter
project_name: codespace_algorand

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
_tasks:
- "echo '==== Successfully initialized new smart contract 🚀 ===='"

contract_name:
type: str
help: Name of your new contract.
placeholder: "my-new-contract"
default: "my-new-contract"

_templates_suffix: ".j2"
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# pyright: reportMissingModuleSource=false
from algopy import ARC4Contract, String
from algopy.arc4 import abimethod


class {{ contract_name.split('_')|map('capitalize')|join }}(ARC4Contract):
@abimethod()
def hello(self, name: String) -> String:
return "Hello, " + name
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import logging

import algokit_utils
from algosdk.v2client.algod import AlgodClient
from algosdk.v2client.indexer import IndexerClient

logger = logging.getLogger(__name__)


# define deployment behaviour based on supplied app spec
def deploy(
algod_client: AlgodClient,
indexer_client: IndexerClient,
app_spec: algokit_utils.ApplicationSpecification,
deployer: algokit_utils.Account,
) -> None:
from smart_contracts.artifacts.{{ contract_name }}.{{ contract_name }}_client import (
{{ contract_name.split('_')|map('capitalize')|join }}Client,
)

app_client = {{ contract_name.split('_')|map('capitalize')|join }}Client(
algod_client,
creator=deployer,
indexer_client=indexer_client,
)
app_client.deploy(
on_schema_break=algokit_utils.OnSchemaBreak.AppendApp,
on_update=algokit_utils.OnUpdate.AppendApp,
)
name = "world"
response = app_client.hello(name=name)
logger.info(
f"Called hello on {app_spec.contract.name} ({app_client.app_id}) "
f"with name={name}, received: {response.return_value}"
)
Loading