Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added smart contracts for bootcamp #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
[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 = 'digital_marketplace-contracts'
artifacts = 'smart_contracts/artifacts'

[project.deploy]
command = "poetry run python -m smart_contracts deploy"
environment_secrets = [
"DEPLOYER_MNEMONIC",
"DISPENSER_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' }
test = { commands = [
'poetry run pytest',
], description = 'Run smart contract tests' }
audit = { commands = [
'poetry export --without=dev -o requirements.txt',
'poetry run pip-audit -r requirements.txt',
], description = 'Audit with pip-audit' }
lint = { commands = [
'poetry run black --check --diff .',
'poetry run ruff check .',
'poetry run mypy',
], 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: 75947851+Asthay97@users.noreply.github.com
author_name: Astha Yadav
contract_name: digital_marketplace
deployment_language: python
preset_name: production
project_name: digital_marketplace-contracts

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}"
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
_tasks:
- "echo '==== Successfully generated new .env file 🚀 ===='"

target_network:
type: str
help: Name of your target network.
choices:
- mainnet
- testnet
- localnet
- custom
default: "localnet"
when: "{{ not use_generic_env }}"

custom_network_name:
type: str
help: Name of your custom Algorand network.
placeholder: "custom"
when: "{{ not use_generic_env and target_network == 'custom' }}"

is_localnet:
type: bool
help: Whether to deploy on localnet.
placeholder: "true"
default: "{{ target_network == 'localnet' and not use_generic_env }}"
when: 'false'

is_testnet:
type: bool
help: Whether to deploy on testnet.
placeholder: "true"
default: "{{ target_network == 'testnet' and not use_generic_env }}"
when: 'false'

is_mainnet:
type: bool
help: Whether to deploy on mainnet.
placeholder: "true"
default: "{{ target_network == 'mainnet' and not use_generic_env }}"
when: 'false'

is_customnet:
type: bool
help: Whether to deploy on custom network.
placeholder: "true"
default: "{{ target_network == 'custom' and not use_generic_env }}"
when: 'false'

_templates_suffix: ".j2"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# this file contains algorand network settings for interacting with testnet via algonode
ALGOD_TOKEN={YOUR_ALGOD_TOKEN}
ALGOD_SERVER={YOUR_ALGOD_SERVER_URL}
ALGOD_PORT={YOUR_ALGOD_PORT}
INDEXER_TOKEN={YOUR_INDEXER_TOKEN}
INDEXER_SERVER={YOUR_INDEXER_SERVER_URL}
INDEXER_PORT={YOUR_INDEXER_PORT}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# this file should contain environment variables specific to algokit localnet
ALGOD_TOKEN=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
ALGOD_SERVER=http://localhost
ALGOD_PORT=4001
INDEXER_TOKEN=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
INDEXER_SERVER=http://localhost
INDEXER_PORT=8980
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# this file contains algorand network settings for interacting with testnet via algonode
ALGOD_SERVER=https://mainnet-api.algonode.cloud
INDEXER_SERVER=https://mainnet-idx.algonode.cloud
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# this file contains algorand network settings for interacting with testnet via algonode
ALGOD_SERVER=https://testnet-api.algonode.cloud
INDEXER_SERVER=https://testnet-idx.algonode.cloud
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root=true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true

[*.py]
indent_size = 4
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# this file contains algorand network settings for interacting with testnet via algonode
ALGOD_SERVER=https://testnet-api.algonode.cloud
INDEXER_SERVER=https://testnet-idx.algonode.cloud
DEPLOYER_MNEMONIC=""
DISPENSER_MNEMONIC=""
180 changes: 180 additions & 0 deletions digital_marketplace/projects/digital_marketplace-contracts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
# 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/
coverage/

# 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/
.env.*
!.env.*.template
!.env.template
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/
.idea/*
!.idea/runConfigurations/

# macOS
.DS_Store

# Received approval test files
*.received.*

# NPM
node_modules

# AlgoKit
debug_traces/
.algokit/static-analysis/tealer/
.algokit/sources
Loading