Skip to content
Draft
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
5 changes: 0 additions & 5 deletions .github/pull_request_template.md

This file was deleted.

5 changes: 5 additions & 0 deletions .github/workflows/check-python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ jobs:

- name: Run tests
shell: bash
env:
FRONTEND_TEMPLATE_URL: gh:algorandfoundation/algokit-react-frontend-template # If not provided Defaults to algokit production template
FRONTEND_TEMPLATE_REF: prep/beta-release
PYTHON_CONTRACT_TEMPLATE_REF: prep/beta-release
TYPESCRIPT_CONTRACT_TEMPLATE_REF: prep/beta-release
run: |
set -o pipefail
poetry run pytest --junitxml=pytest-junit.xml -n 1
Expand Down
34 changes: 32 additions & 2 deletions copier.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ _tasks:
-a include_github_workflow_template "no"'

- "echo '==== 2/4 - Initializing frontend template ===='"
- 'algokit init -t react -n {{ project_name }}-frontend --no-git --no-ide --no-bootstrap
- 'algokit init {{ "--template-url \"" ~ (frontend_template_url if frontend_template_url else "gh:algorandfoundation/algokit-react-frontend-template") ~ "\" --UNSAFE-SECURITY-accept-template-url" if (frontend_template_url or frontend_template_ref) else "-t react" }} -n {{ project_name }}-frontend --no-git --no-ide --no-bootstrap
{% if frontend_template_ref %}
--template-url-ref "{{ frontend_template_ref }}"
{% endif %}
-a author_email "{{ author_email }}"
-a author_name "{{ author_name }}"
-a preset_name "{{ preset_name }}"
Expand All @@ -19,7 +22,10 @@ _tasks:
-a use_github_actions "{{ use_github_actions }}"'

- "echo '==== 3/4 - Initializing contract template ===='"
- 'algokit init -t {{ contract_template }} -n {{ project_name }}-contracts --no-git --no-ide --no-bootstrap
- 'algokit init {{ "--template-url \"" ~ (contract_template_url if contract_template_url else ("gh:algorandfoundation/algokit-python-template" if contract_template == "python" else "gh:algorandfoundation/algokit-typescript-template" if contract_template == "typescript" else "gh:algorand-devrel/tealscript-algokit-template")) ~ "\" --UNSAFE-SECURITY-accept-template-url" if (contract_template_url or contract_template_ref) else "-t " ~ contract_template }} -n {{ project_name }}-contracts --no-git --no-ide --no-bootstrap
{% if contract_template_ref %}
--template-url-ref "{{ contract_template_ref }}"
{% endif %}
-a author_email "{{ author_email }}"
-a author_name "{{ author_name }}"
-a preset_name "{{ preset_name }}"
Expand Down Expand Up @@ -50,6 +56,30 @@ contract_template:
TealScript: tealscript
default: python

frontend_template_url:
type: str
help: Override source URL for frontend child template.
when: false
default: ''

frontend_template_ref:
type: str
help: Override git ref (branch/tag) for frontend child template.
when: false
default: ''

contract_template_url:
type: str
help: Override source URL for contract child template.
when: false
default: ''

contract_template_ref:
type: str
help: Override git ref (branch/tag) for contract child template.
when: false
default: ''

project_name:
type: str
help: Name for this project.
Expand Down
4 changes: 2 additions & 2 deletions examples/p-py/.algokit/.copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: <commit>
_src_path: <src>
_commit: 2.1.8-10-g72c45ae
_src_path: /var/folders/96/k83m8nkj3ts72l4jw7378sm80000gn/T/tmpccp2c3vt/template
author_email: None
author_name: None
cloud_provider: netlify
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: 1.8.1
_commit: 1.8.1-13-g270c4a5
_src_path: gh:algorandfoundation/algokit-python-template
author_email: None
author_name: None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def deploy() -> None:
deployer_ = algorand.account.from_environment("DEPLOYER")

factory = algorand.client.get_typed_app_factory(
{{ contract_name.split('_')|map('capitalize')|join }}Factory, default_sender=deployer_.address
{{ contract_name.split('_')|map('capitalize')|join }}Factory, default_sender=deployer_.addr
)

app_client, result = factory.deploy(
Expand All @@ -31,7 +31,7 @@ def deploy() -> None:
algorand.send.payment(
algokit_utils.PaymentParams(
amount=algokit_utils.AlgoAmount(algo=1),
sender=deployer_.address,
sender=deployer_.addr,
receiver=app_client.app_address,
)
)
Expand Down
9 changes: 4 additions & 5 deletions examples/p-py/projects/p-py-contracts/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ package-mode = false

[tool.poetry.dependencies]
python = "^3.12"
algokit-utils = "^4.0.0"
algokit-utils = "^5.0.0a13"
python-dotenv = "^1.0.0"
algorand-python = "^3"
algorand-python-testing = "^1"
algorand-python-testing = {git = "https://github.com/algorandfoundation/algorand-python-testing.git", branch = "refactor/util-v5"}

[tool.poetry.group.dev.dependencies]
algokit-client-generator = "^2.1.0"
algokit-client-generator = "^3.0.0a3"
black = {extras = ["d"], version = "*"}
ruff = "^0.9.4"
mypy = "^1"
Expand Down Expand Up @@ -58,9 +58,8 @@ disallow_any_unimported = true
disallow_any_expr = true
disallow_any_decorated = true
disallow_any_explicit = true
untyped_calls_exclude = ["algosdk"]
# Remove if you prefer to use mypy's default behavior against
# untyped algosdk types
# untyped types
[[tool.mypy.overrides]]
module = "tests.*"
disallow_any_expr = false
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def deploy() -> None:
deployer_ = algorand.account.from_environment("DEPLOYER")

factory = algorand.client.get_typed_app_factory(
HelloWorldFactory, default_sender=deployer_.address
HelloWorldFactory, default_sender=deployer_.addr
)

app_client, result = factory.deploy(
Expand All @@ -31,7 +31,7 @@ def deploy() -> None:
algorand.send.payment(
algokit_utils.PaymentParams(
amount=algokit_utils.AlgoAmount(algo=1),
sender=deployer_.address,
sender=deployer_.addr,
receiver=app_client.app_address,
)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import algokit_utils
import pytest
from algokit_utils import (
AddressWithSigners,
AlgoAmount,
AlgorandClient,
SigningAccount,
)

from smart_contracts.artifacts.hello_world.hello_world_client import (
Expand All @@ -13,20 +13,20 @@


@pytest.fixture()
def deployer(algorand_client: AlgorandClient) -> SigningAccount:
def deployer(algorand_client: AlgorandClient) -> AddressWithSigners:
account = algorand_client.account.from_environment("DEPLOYER")
algorand_client.account.ensure_funded_from_environment(
account_to_fund=account.address, min_spending_balance=AlgoAmount.from_algo(10)
account_to_fund=account.addr, min_spending_balance=AlgoAmount.from_algo(10)
)
return account


@pytest.fixture()
def hello_world_client(
algorand_client: AlgorandClient, deployer: SigningAccount
algorand_client: AlgorandClient, deployer: AddressWithSigners
) -> HelloWorldClient:
factory = algorand_client.client.get_typed_app_factory(
HelloWorldFactory, default_sender=deployer.address
HelloWorldFactory, default_sender=deployer.addr
)

client, _ = factory.deploy(
Expand All @@ -52,4 +52,4 @@ def test_simulate_says_hello_with_correct_budget_consumed(
)
assert result.returns[0].value == "Hello, World"
assert result.returns[1].value == "Hello, Jane"
assert result.simulate_response["txn-groups"][0]["app-budget-consumed"] < 100
assert result.simulate_response.txn_groups[0].app_budget_consumed < 100
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: 1.1.1
_commit: 1.1.1-13-gc5abe59
_src_path: gh:algorandfoundation/algokit-react-frontend-template
author_email: None
author_name: None
Expand Down
3 changes: 3 additions & 0 deletions examples/p-py/projects/p-py-frontend/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,6 @@ VITE_KMD_PASSWORD=""
# VITE_INDEXER_SERVER="https://mainnet-idx.algonode.cloud"
# VITE_INDEXER_PORT=""


# Add your Web3Auth Client ID here if you want to test Web3Auth integration on TestNet or Mainnet
# VITE_WEB3_AUTH_CLIENT_ID=""
10 changes: 5 additions & 5 deletions examples/p-py/projects/p-py-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"npm": ">=9.0"
},
"devDependencies": {
"@algorandfoundation/algokit-client-generator": "^5.0.0",
"@algorandfoundation/algokit-client-generator": "^7.0.0-alpha.5",
"@types/node": "^18.17.14",
"@types/react": "^18.2.11",
"@types/react-dom": "^18.2.4",
Expand All @@ -35,12 +35,12 @@
"vite-plugin-node-polyfills": "^0.22.0"
},
"dependencies": {
"@algorandfoundation/algokit-utils": "^9.0.0",
"@algorandfoundation/algokit-utils": "^10.0.0-alpha.40",
"@blockshake/defly-connect": "^1.2.1",
"@perawallet/connect": "^1.4.1",
"@txnlab/use-wallet": "^4.0.0",
"@txnlab/use-wallet-react": "^4.0.0",
"algosdk": "^3.0.0",
"@txnlab/use-wallet": "^4.6.0",
"@txnlab/use-wallet-react": "^4.6.0",
"@web3auth/modal": "^9.7.0",
"daisyui": "^4.0.0",
"notistack": "^3.0.1",
"react": "^18.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { HelloWorldFactory } from '../contracts/HelloWorld'
import { OnSchemaBreak, OnUpdate } from '@algorandfoundation/algokit-utils/types/app'
import { getAlgodConfigFromViteEnvironment, getIndexerConfigFromViteEnvironment } from '../utils/network/getAlgoClientConfigs'
import { AlgorandClient } from '@algorandfoundation/algokit-utils'
import { encodeTransactionRaw } from '@algorandfoundation/algokit-utils/transact'

interface AppCallsInterface {
openModal: boolean
Expand All @@ -15,15 +16,19 @@ const AppCalls = ({ openModal, setModalState }: AppCallsInterface) => {
const [loading, setLoading] = useState<boolean>(false)
const [contractInput, setContractInput] = useState<string>('')
const { enqueueSnackbar } = useSnackbar()
const { transactionSigner, activeAddress } = useWallet()
const { signTransactions, activeAddress } = useWallet()

const algodConfig = getAlgodConfigFromViteEnvironment()
const indexerConfig = getIndexerConfigFromViteEnvironment()
const algorand = AlgorandClient.fromConfig({
algodConfig,
indexerConfig,
})
algorand.setDefaultSigner(transactionSigner)
algorand.setDefaultSigner(async (txnGroup, indexesToSign) => {
const encoded = txnGroup.map((txn) => encodeTransactionRaw(txn))
const signed = await signTransactions(encoded, indexesToSign)
return signed.filter((s): s is Uint8Array => s !== null)
})

const sendAppCall = async () => {
setLoading(true)
Expand Down
11 changes: 8 additions & 3 deletions examples/p-py/projects/p-py-frontend/src/components/Transact.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { algo, AlgorandClient } from '@algorandfoundation/algokit-utils'
import { encodeTransactionRaw } from '@algorandfoundation/algokit-utils/transact'
import { useWallet } from '@txnlab/use-wallet-react'
import { useSnackbar } from 'notistack'
import { useState } from 'react'
Expand All @@ -18,20 +19,24 @@ const Transact = ({ openModal, setModalState }: TransactInterface) => {

const { enqueueSnackbar } = useSnackbar()

const { transactionSigner, activeAddress } = useWallet()
const { signTransactions, activeAddress } = useWallet()

const handleSubmitAlgo = async () => {
setLoading(true)

if (!transactionSigner || !activeAddress) {
if (!signTransactions || !activeAddress) {
enqueueSnackbar('Please connect wallet first', { variant: 'warning' })
return
}

try {
enqueueSnackbar('Sending transaction...', { variant: 'info' })
const result = await algorand.send.payment({
signer: transactionSigner,
signer: async (txnGroup, indexesToSign) => {
const encoded = txnGroup.map((txn) => encodeTransactionRaw(txn))
const signed = await signTransactions(encoded, indexesToSign)
return signed.filter((s): s is Uint8Array => s !== null)
},
sender: activeAddress,
receiver: receiverAddress,
amount: algo(1),
Expand Down
Loading
Loading