algorandfoundation / algokit-cli Goto Github PK
View Code? Open in Web Editor NEWThe Algorand AlgoKit CLI is the one-stop shop tool for developers building on the Algorand network.
License: MIT License
The Algorand AlgoKit CLI is the one-stop shop tool for developers building on the Algorand network.
License: MIT License
Long term we want to support upgradeable / multiple templates. To support that we need to capture templates used and answers given. To avoid a future breaking change for AlgoKit users we should start capturing that information now.
Acceptance Criteria:
.algokit/.copier-answers.{templatename}.yml
beaker
templateWindows without microsoft c++ build tools gives this error
(algokit-py3.10) PS D:\repositories\MakerX\algokit-cli> poetry install
Installing dependencies from lock file
Warning: poetry.lock is not consistent with pyproject.toml. You may be getting improper dependencies. Run `poetry lock [--no-update]` to fix it.
Package operations: 2 installs, 0 updates, 0 removals
• Installing iteration-utilities (0.11.0)
CalledProcessError
Command 'D:\repositories\MakerX\algokit-cli\.venv\Scripts\python.exe -m pip install --use-pep517 --disable-pip-version-check --prefix D:\repositories\MakerX\algokit-cli\.venv --no-deps C:\Users\wilson\AppData\Local\pypoetry\Cache\artifacts\13\fe\58\dd3a5413393eab8ca2c5b884ff40af30da952dbdc4598df1d7b6cf61b0\iteration_utilities-0.11.0.tar.gz' returned non-zero exit status 1.
at ~\AppData\Local\Programs\Python\Python310\lib\subprocess.py:524 in run
520│ # We don't call process.wait() as .__exit__ does that for us.
521│ raise
522│ retcode = process.poll()
523│ if check and retcode:
→ 524│ raise CalledProcessError(retcode, process.args,
525│ output=stdout, stderr=stderr)
526│ return CompletedProcess(process.args, retcode, stdout, stderr)
527│
528│
The following error occurred when trying to handle this error:
EnvCommandError
Command D:\repositories\MakerX\algokit-cli\.venv\Scripts\python.exe -m pip install --use-pep517 --disable-pip-version-check --prefix D:\repositories\MakerX\algokit-cli\.venv --no-deps C:\Users\wilson\AppData\Local\pypoetry\Cache\artifacts\13\fe\58\dd3a5413393eab8ca2c5b884ff40af30da952dbdc4598df1d7b6cf61b0\iteration_utilities-0.11.0.tar.gz errored with the following return code 1, and output:
Processing c:\users\wilson\appdata\local\pypoetry\cache\artifacts\13\fe\58\dd3a5413393eab8ca2c5b884ff40af30da952dbdc4598df1d7b6cf61b0\iteration_utilities-0.11.0.tar.gz
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Preparing metadata (pyproject.toml): started
Preparing metadata (pyproject.toml): finished with status 'done'
Building wheels for collected packages: iteration-utilities
Building wheel for iteration-utilities (pyproject.toml): started
Building wheel for iteration-utilities (pyproject.toml): finished with status 'error'
error: subprocess-exited-with-error
Building wheel for iteration-utilities (pyproject.toml) did not run successfully.
exit code: 1
[15 lines of output]
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-cpython-310
creating build\lib.win-amd64-cpython-310\iteration_utilities
copying src\iteration_utilities\_additional_recipes.py -> build\lib.win-amd64-cpython-310\iteration_utilities
copying src\iteration_utilities\_classes.py -> build\lib.win-amd64-cpython-310\iteration_utilities
copying src\iteration_utilities\_convenience.py -> build\lib.win-amd64-cpython-310\iteration_utilities
copying src\iteration_utilities\_recipes.py -> build\lib.win-amd64-cpython-310\iteration_utilities
copying src\iteration_utilities\_utils.py -> build\lib.win-amd64-cpython-310\iteration_utilities
copying src\iteration_utilities\__init__.py -> build\lib.win-amd64-cpython-310\iteration_utilities
running build_ext
building 'iteration_utilities._iteration_utilities' extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for iteration-utilities
Failed to build iteration-utilities
ERROR: Could not build wheels for iteration-utilities, which is required to install pyproject.toml-based projects
at ~\AppData\Local\Programs\Python\Python310\lib\site-packages\poetry\utils\env.py:1476 in _run
1472│ output = subprocess.check_output(
1473│ command, stderr=subprocess.STDOUT, env=env, **kwargs
1474│ )
1475│ except CalledProcessError as e:
→ 1476│ raise EnvCommandError(e, input=input_)
1477│
1478│ return decode(output)
1479│
1480│ def execute(self, bin: str, *args: str, **kwargs: Any) -> int:
The following error occurred when trying to handle this error:
PoetryException
Failed to install C:/Users/wilson/AppData/Local/pypoetry/Cache/artifacts/13/fe/58/dd3a5413393eab8ca2c5b884ff40af30da952dbdc4598df1d7b6cf61b0/iteration_utilities-0.11.0.tar.gz
at ~\AppData\Local\Programs\Python\Python310\lib\site-packages\poetry\utils\pip.py:51 in pip_install
47│
48│ try:
49│ return environment.run_pip(*args)
50│ except EnvCommandError as e:
→ 51│ raise PoetryException(f"Failed to install {path.as_posix()}") from e
52│
ben@Algo-Guidarelli:~/wiggly$ algokit goal account import
Couldn't read response: EOF
Please type your recovery mnemonic below, and hit return when you are done:
Error: Error executing goal; ensure the Sandbox is started by executing `algokit sandbox status
A user could still run algokit sandbox console
and goal account import
separately to add a new account
Acceptance Criteria:
brew install algorandfoundation/core/algokit
and get the latest production version of algokit installed to their machineIn an attempt to reduce the chance of bugs, the story requests adding mypy support:
In case helpful as a reference point, https://github.com/algorand/pyteal/ supports mypy.
Acceptance Criteria:
algokit doctor
after installation to check their system is readyalgokit doctor
and paste the result before submitting the issue -- << needs GitHub issue template - do we have access>>algokit doctor
it should show:
algokit sandbox
command; install via https://docs.docker.com/get-docker/algokit sandbox
command; install via https://docs.docker.com/compose/install/algokit init
; install via choco install git
if using Chocolatey or via https://github.com/git-guides/install-git#install-git-on-windowsalgokit init
; install via https://github.com/git-guides/install-git#install-git-on-windowsalgokit bootstrap
within project directory, or via https://python-poetry.org/docs/#installationalgokit bootstrap
within project directory, or via https://nodejs.dev/en/learn/how-to-install-nodejs/algokit doctor -c
-c
/--copy-to-clipboard
option that places the contents of the doctor message (in Markdown format) in the users clipboardNice-to-have, but worthwhile if we can invest a day and get it done. First step is a timeboxed investigation to see how easy/hard it will be to add. In an ideal world, we would be able to utilise click + pipx to get tab completion support in bash, zsh and powershell.
We need to decide on what Sandbox approach we will take for AlgoKit.
Key principles:
Initial options:
Acceptance Criteria:
choco install algokit
check via algokit --version
choco upgrade algokit
choco uninstall algokit
brew install algorandfoundation/core/algokit
check via algokit --version
brew upgrade algokit
brew uninstall algokit
pipx install algokit
check via algokit --version
pipx upgrade algokit
pipx uninstall algokit
algokit doctor
Acceptance Criteria:
--skip-version-check
which will prevent both the version check and the warning from occurringalgokit --disable-version-check
then algokit will store a config in it's config directory that results in the equivalent of passing --skip-version-check
for every commandalgokit --enable-version-check
then it will reverse any previous execution of algokit --disable-version-check
Acceptance Criteria:
choco install algokit
and get the latest production version of algokit installed to their machinechoco upgrade algokit
to upgrade to latest available versionchoco uninstall algokit
to remove algokit cli from their systemIf installing algokit on a system with pyenv, poetry will not detect the current active version of Python by default. This means the installation of the dependencies might occur on the incorrect version of Python.
To fix this, part of the init process could ask if pyenv should be configured with poetry config virtualenvs.prefer-active-python true
to automatically detect the active version of Python
We need to decide on a community contribution standard for AlgoKit.
Related: https://allcontributors.org/docs/en/overview
Inspiration:
Note: This is a known issue in Sandbox / Indexer - algorand/sandbox#163. Waiting for confirmation of a likely resolution delay before looking to fix it in AlgoKit.
In the meantime we have placed a note in known issues in the documentation for AlgoKit Sandbox.
Acceptance Criteria:
Acceptance Criteria:
-v
global option to output debug+ logging, but otherwise only info+ loggingAcceptance Criteria:
algokit goal {args}
will run goal {args}
on the algod Sandbox containeralgokit sandbox start
Acceptance Criteria:
Edition Windows 11 Pro
Version 22H2
Installed on 27/11/2022
OS build 22621.1105
Experience Windows Feature Experience Pack 1000.22638.1000.0
Command line: PowerShell
This is a machine that has not been used for development until this very moment.
Followed Windows installation guide in README verbatim.
Commands listed in installation guide run without errors and need for troubleshooting.
After performing all the steps in the installation guide without errors, trying to verify the installation via algokit --version
results in the following output:
Unhandled ImportError: cannot import name 'git' from 'plumbum.cmd' (C:\Users\Home\.local\pipx\venvs\algokit\Lib\site-packages\plumbum\cmd.py)
choco install
command had to be run with the additional -y
argument, otherwise PowerShell just got stuck and would not react to my input at allpip
to path, the command pip install --user pipx
did not work. Had to run py -m pip install --user pipx
instead.python
to path, the commands python -m pipx ensurepath
and python -m pipx install algokit
did not work. Had to use py
instead of python
to invoke the Python Windows Launcher, which doesn't require path modification.P.S. I'm not a Python dev, though I use it for utility scripts from time to time and have some exposure to the ecosystem and package management. I also do all of my development in the last 5 years on a Mac. Just throwing it out there, in case I missed something stupidly obvious here.
Acceptance Criteria:
algokit bootstrap
within an algokit project directory will ensure that if there is any Python Poetry projects that Poetry is installed (and installs it via pipx if not available) and that poetry install
is run for each pyproject.toml
algokit bootstrap
within an algokit project directory will ensure that any .env.template
files will be copied to .env
and any replacement tokens designated by {token_name}
will be prompted and replaced if a value providedalgokit bootstrap
within an algokit project directory will ensure that if there is any Node.js projects that node LTS is installed and that npm install
is run for each package.json
Note: installing algokit itself means that Python is available so no need to check for that.
Note also: The Sandbox commands automatically check for Docker installation and provide error messages with instructions to guide installation.
Original description:
AlgoKit CLI allows developers to bootstrap their local environment for Algorand development on Windows, Mac and Linux, including:
Acceptance Criteria:
algokit sandbox explore
command should open an instance of dappflow pointed directly at your local sandbox.
https://app.dappflow.org/setup-config?algod_url=https://testnet-api.algonode.cloud&indexer_url=https://testnet-idx.algonode.cloud&redirect=/explorer/transaction/ZDQV5D6L35NG4DRBRKH6SNKAMCQZGWKCQBYJX5L5FTFLHL7EFJ6A
algokit explore
command should do the same as algokit sandbox explore
algokit explore sandbox
(same as above)algokit explore mainnet
- opens mainnet using Algonode (algonode.cloud) endpointsalgokit explore testnet
- opens testnet using Algonode (algonode.cloud) endpointssuch as https://snapcraft.io/ or alternatives
Also see https://azurecliprod.blob.core.windows.net/install.py for inspiration
Running algokit doctor
in a Gitpod where algokit has been installed (thanks @joe-p) throws the following error on docker combine version parsing:
Gitpod link:
https://gitpod.io/#https://github.com/algorand-devrel/docker-algorand-gitpod/tree/algokit/
Terminal input & output:
gitpod /workspace/docker-algorand-gitpod (algokit) $ algokit doctor
timestamp: 2023-01-28T14:14:35+00:00
AlgoKit: 0.2.0
AlgoKit Python: 3.10.7 (main, Jan 28 2023, 13:07:35) [GCC 9.4.0] (location: /home/gitpod/.local/pipx/venvs/algokit)
OS: Linux-5.15.0-47-generic-x86_64-with-glibc2.31
docker: 20.10.17
docker compose: 2.10.0-gitpod.0
Failed to parse version from: "2.10.0-gitpod.0"
Error: invalid literal for int() with base 10: '0-gitpod'
Unable to check against minimum version of 2.5.0
git: 2.37.3
python: 3.10.7 (location: /home/gitpod/.pyenv/shims/python)
python3: 3.10.7 (location: /home/gitpod/.pyenv/shims/python3)
pipx: 1.1.0
poetry: 1.3.1
node: 16.19.0
npm: 8.19.3
Acceptance Criteria:
algokit sandbox stop
:
algokit sandbox start
after running algokit sandbox stop
then the existing container state should be in placeInitial conversation with Fabrice:
testnet - .env (unencrypted is fine as long as it's in .gitignore) or ci/cd or kmd
mainnet - default: deploy and immediately rekey, don't allow upgradeable by default, require an override if doing something insecure in mainnet, by default don't allow mainnet deployment via ci/cd or locally (maybe present txn for signing?), allow ci/cd with once-only deployment by default?
Acceptance Criteria:
algokit sandbox status
:
If the sandbox containers are not present or are stopped then output a message indicating that the sandbox is not running and they should run algokit sandbox start
, a non-zero exit code should be returned:
# algod status
Status: Not running
# indexer status
Status: ErrorRun
algokit sandbox start
to start the sandbox.
If the containers are present and started then:
Check the status of algod and show:
# algod status
Status: Running
Port: 4001
Last round: 0
Time since last round: 0.0s
Genesis ID: sandnet-v1
Genesis hash: 1dpDw4wZL+8OI6IUy7S6LyUqcXQ2busuRZIQRsZjsbE=
Version: x.y.z
Check the status of indexer and show:
# indexer status
Status: Running
Port: 8980
Last round: 0
Error(s): {any errors}
Version: x.y.z
Return a non-zero exit code if either algod or indexer are not running and a zero exit code if they are both running OK
Acceptance Criteria:
Original notes:
A library for Algorand exists with audited, documented smart contracts and base smart contract templates in PyTEAL that allows Algorand Foundation contributed smart contracts (e.g. ARC reference implementations) and community contributed smart contracts
Inspiration:
Acceptance Criteria:
algokit sandbox console
it will open a bash terminal on the algod node of the currently running AlgoKit Sandbox
exit
command to get back to their original terminalOptions:
main
) and we can optionally release a build to PyPi (by clicking a button in GitHub actions); vsdevelop
-> main
) and a merge to main automaticallyGitHub flow is simpler, Git flow allows for longer-running experimental branches.
We decided to use GitHub flow for simplicity and to encourage regular releasing. If there is a need for an experimental branch then it can be released by running the GitHub action against the branch and thus published as a pre-release.
Acceptance Criteria:
main
branch of the AlgoKit CLI a GitHub workflow is run that:
main
then the branch name will be used as a pre-release tag, but otherwise it will be beta
Acceptance Criteria:
algokit init
) documentationNotes:
Acceptance Criteria:
> algokit
AlgoKit CLI
Unsupported CPython version (3.9.2) detected. The minimum version of Python supported is CPython 3.10.
If you need help installing then this is a good starting point: https://www.python.org/about/gettingstarted/.
> algokit
Welcome to AlgoKit CLI!
AlgoKit is your one stop shop to develop applications on the Algorand blockchain.
Usage:
algokit -h|--help
algokit -v|--version
algokit [options] [COMMAND] [ARGS...]
Available commands:
TODO
version
or --version
it will output the current version:
> algokit --version
AlgoKit CLI v0.1.0
> algokit unknown
AlgoKit CLI
Unknown command `unknown`; please see usage information below:
Usage:
algokit -h|--help
algokit --version
algokit [options] [COMMAND] [ARGS...]
Available commands:
TODO
This helps ensure a stable base of Docker Compose functionality to ensure a good experience. Trying to balance likelihood the dev needs to update (friction) with stability of Docker Compose (bad UX). We determined that 2.5.0 is a good base to have as a minimum, which will be ~ 9 months old when we have public beta.
Acceptance Criteria:
We need to decide how we want to test the Beaker codebase.
Concepts to consider:
Acceptance Criteria:
> pipx install <source_repo_url>
> algokit -v
AlgoKit CLI v0.1.0
Need to decide how we want to host / write / publish documentation for AlgoKit.
Broad options:
Acceptance criteria:
There are some problems that have been identified in the release versioning implementation:
Error marking release branch releases as prerelease in Github e.g. this error
gh release edit --prerelease "v$(poetry run semantic-release print-version --current)"
. The reason is the poetry run semantic-release print-version --current
command returns (e.g.) 1.2.3
without the beta tag attached to it (expected: 1.2.3-beta.1
)gh release edit --prerelease "$(git describe $(git rev-list --tags --max-count=1))"
Feature branches keep bumping the minor version and main versions were being bumped by it too, causing unexpectedly escalating version numbers. There are two suspected bugs in python-semantic-release causing this:
a. Prerelease tag that isn't beta i.e. beta-branch has this weird behaviour of trying to bump the version every time
b. When calculating a version from tags it's not grabbing tags in the current branch, but every tag in the whole repository thus leaking versions between branches
In order to fix 2, we have a workaround to limit the impact (already low since feature branches are an exception rather than a usual mode of operation) by specifying --patch
on prerelease builds so at least it only bumps patch and not minor. In the meantime we will raise issues with the source repository and try and get the underlying bugs resolved.
Docker compose is correctly installed on my Mac
❯ docker-compose --version
docker-compose version 1.29.2, build 5becea4c
And running algokit doctor I get:
algokit bootstrap
within project directory, or via:When running for example:
algokit sandbox start
Unhandled JSONDecodeError: Extra data: line 1 column 21 (char 20)
Get this DecodeError. I assume its related with the docker-compose.
Acceptance criteria:
Hello all; please let me know if this is something I should take up with Beaker
.
python -m smart_contracts
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/[~~REDACTED~~]/newtoast/smart_contracts/__main__.py", line 3, in <module>
from smart_contracts.lab import my_lab
File "/[~~REDACTED~~]/newtoast/smart_contracts/lab.py", line 29, in <module>
apps=[HelloWorld()],
^^^^^^^^^^^^
File "/[~~REDACTED~~]/newtoast/.venv/lib/python3.11/site-packages/beaker/application.py", line 241, in __init__
self.compile()
File "/[~~REDACTED~~]/newtoast/.venv/lib/python3.11/site-packages/beaker/application.py", line 280, in compile
) = self.router.compile_program(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/[~~REDACTED~~]/newtoast/.venv/lib/python3.11/site-packages/pyteal/ast/router.py", line 746, in compile_program
ap_compiled = compileTeal(
^^^^^^^^^^^^
File "/[~~REDACTED~~]/newtoast/.venv/lib/python3.11/site-packages/pyteal/compiler/compiler.py", line 279, in compileTeal
compileSubroutine(
File "/[~~REDACTED~~]/newtoast/.venv/lib/python3.11/site-packages/pyteal/compiler/compiler.py", line 152, in compileSubroutine
start, end = ast.__teal__(options)
^^^^^^^^^^^^^^^^^^^^^
File "/[~~REDACTED~~]/newtoast/.venv/lib/python3.11/site-packages/pyteal/ast/cond.py", line 82, in __teal__
condStart, condEnd = cond.__teal__(options)
^^^^^^^^^^^^^^^^^^^^^^
File "/[~~REDACTED~~]/newtoast/.venv/lib/python3.11/site-packages/pyteal/ast/binaryexpr.py", line 39, in __teal__
self.op.min_version,
^^^^^^^^^^^^^^^^^^^
File "/[~~REDACTED~~]/newtoast/.venv/lib/python3.11/site-packages/pyteal/ir/ops.py", line 31, in min_version
return self.value.min_version
^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'tuple' object has no attribute 'min_version'
python -m smart_contracts
in the project's root directoryinit
files.min_version
in the Beaker Application
classBeaker
. As a new user, it took me too long (and much frustration) to eventually discover that PyTeal and Beaker are different things.Acceptance Criteria:
algokit sandbox reset
:
algod sandbox start
algokit sandbox start
and output a warning to indicate that the person should run algokit sandbox reset
Acceptance Criteria:
algokit init
it will prompt you for a project name, or you can pass the name in using --name {name}
or algokit init {name}
{name}
This has been discussed on a couple of times, but I want to raise the topic again because I think there's an approach we can take that dramatically reduces the friction for the "first-touch" dev experience.
The main rationale for using docker is because of the postgres DB indexer needs. Having users install Postgres on bare-metal is unreasonable. The indexer, however, is not needed for smart contract development (only full Dapp development). As such, I think it would be reasonable for the default installation of sandnet to not include indexer. Without needing indexer we can then use native binaries.
The main sticking point with trying to use native binaries is not having Windows binaries. To alleviate this, we could have the Windows version of algokit use WSL when ran on Windows. The requirement for WSL is still not ideal, but it's better than WSL + Docker.
If a dev wants to eventually use Indexer, there can be an optional flag that creates a docker container on the host network that can communicate with the local algod. Eventually we can hopefully write a Conduit plugin that uses SQLite instead of Postgres and have everything native.
Acceptance Criteria:
--template-url
, but it will warn you of the security risk and confirm via stdin that you are sure you want to do italgokit init
--name
, -n
)
/^[\w-.]+$/
and the directory doesn't exist alreadybeaker-default
) (--template
, -t
)
create-remix
template selection--deployment-lang
, -l
, default: Python
)Y
/y
then install the Python dependenciesAcceptance Criteria:
--no-venv
then a virtual environment will not be created and the global version of python will be used--pip
then requirements.txt
will be used instead of Poetry--no-venv
or there is --venv
thenvirtualenv
to set up the virtual environment--no-formatting
-a use_python_black no
then the formatter won't be configured--no-linting
-a use_python_linter null
then the linter won't be configured--no-typing
-a use_python_mypy no
then the typing won't be configuredAcceptance Criteria:
algokit sandbox start
:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.