Package: algokit-client-generator
AlgoKit Python client generatorThis project generates a type-safe smart contract client in Python for the Algorand Blockchain that wraps theapplication clientinAlgoKit Utils. It does this by reading anARC-0032application spec file.NoteThere is also an equivalentTypeScript client generator.UsagePrerequisitesTo be able to consume the generated file you need to include it in a Python project that has (at least) the following package installed:poetry add algokit-utils@^1.2UseTo install the generator as a CLI tool:pipx install algokit-client-generatorThen to use italgokitgen-py path/to/application.json path/to/output/client_generated.pyOr if you haveAlgoKit1.1+ installedalgokit generate client path/to/application.json --output path/to/output/client_generated.pyExamplesThere are a range ofexamplesthat you can look at to see a source smart contract ({contract.py}),
the generated client (client_generated.py) and some tests that demonstrate how you can use the client (test_client.py).ContributingIf you want to contribute to this project the following information will be helpful.Initial setupClone this repository locallyInstall pre-requisites:InstallAlgoKit-Link: Ensure you can executealgokit --version.Bootstrap your local environment; runalgokit bootstrap allwithin this folder, which will:InstallPoetry-Link: The minimum required version is1.2. Ensure you can executepoetry -Vand get1.2+Runpoetry installin the root directory, which will set up a.venvfolder with a Python virtual environment and also install all Python dependenciesOpen the project and start debugging / developing via:VS CodeOpen the repository root in VS CodeInstall recommended extensionsRun tests via test explorerIDEA (e.g. PyCharm)Open the repository root in the IDEIt should automatically detect it's a Poetry project and set up a Python interpreter and virtual environment.Run testsOtherOpen the repository root in your text editor of choiceRunpoetry run pytestSubsequentlyIf you update to the latest source code and there are new dependencies you will need to runalgokit bootstrap allagainFollow step 3 aboveBuilding examplesIn theexamplesfolder there is a series of example contracts along with their generated client. These contracts are built usingBeaker.If you want to make changes to any of the smart contract examples and re-generate the ARC-0032 application.json files then change the correspondingexamples/{contract}/{contract}.pyfile and then run:poetry run python -m examplesOr in Visual Studio Code you can use the default build task (Ctrl+Shift+B).Continuous Integration / Continuous Deployment (CI/CD)This project usesGitHub Actionsto define CI/CD workflows, which are located in the.github/workflowsfolder.Approval testsMaking any changes to the generated code will result in the approval tests failing. The approval tests work by generating a version of client
and outputting it to./examples/APP_NAME/client_generated.pythen comparing to the approved version./examples/APP_NAME/client.ts. If you
make a change and break the approval tests, you will need to update the approved version by overwriting it with the generated version.
You can runpoe update-approvalsto update all approved clients in one go.