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

feat: removing .env files, adding env-file generator #31

Merged
merged 6 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
@@ -1,10 +1,14 @@
[algokit]
min_version = "v2.0.0"

[generate.smart_contract]
description = "Adds new smart contract to existing project"
[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 = 'production_python_smart_contract_python'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
_tasks:
- "echo '==== Successfully generated new .env file 🚀 ===='"

use_generic_env:
type: bool
help: Create generic empty .env file (true) or create a network specific .env.{network_name} file (false).
placeholder: "true"
default: "true"

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' }}"

_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,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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,26 @@ While primarily optimized for VS Code, JetBrains IDEs are supported:
## AlgoKit Workspaces and Project Management
This project supports both standalone and monorepo setups through AlgoKit workspaces. Leverage [`algokit project run`](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/project/run.md) commands for efficient monorepo project orchestration and management across multiple projects within a workspace.

> For guidance on `smart_contracts` folder and adding new contracts to the project please see [README](smart_contracts/README.md) on the respective folder.### Continuous Integration / Continuous Deployment (CI/CD)
## AlgoKit Generators

This template provides a set of [algokit generators](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/generate.md) that allow you to further modify the project instantiated from the template to fit your needs, as well as giving you a base to build your own extensions to invoke via the `algokit generate` command.

### Generate Smart Contract

By the default the template creates a single `HelloWorld` contract under hello_world folder in the `smart_contracts` directory. To add a new contract:

1. From the root of the project (`../`) execute `algokit generate smart-contract`. This will create a new starter smart contract and deployment configuration file under `{your_contract_name}` subfolder under `smart_contracts` directory.
2. Each contract potentially has different creation parameters and deployment steps. Hence, you need to define your deployment logic in `deploy_config.py`file.
3. `config.py` file will automatically build all contracts under `smart_contracts` directory. If you want to build specific contracts manually, modify the default code provided by the template in `config.py` file.

> Please note, above is just a suggested convention tailored for the base configuration and structure of this template. Default code supplied by the template in `config.py` and `index.ts` (if using ts clients) files are tailored for the suggested convention. You are free to modify the structure and naming conventions as you see fit.

### Generate '.env' files

By default the template instance would not contain any env files. Using [`algokit project deploy`](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/project/deploy.md) against `localnet` | `testnet` | `mainnet` will use default values for `algod` and `indexer` unless overwritten via `.env` or `.env.{target_network}`.

To generate a new `.env` or `.env.{target_network}` file:
- `algokit generate env-file`### Continuous Integration / Continuous Deployment (CI/CD)

This project uses [GitHub Actions](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions) to define CI/CD workflows, which are located in the [.github/workflows](`.github/workflows`) folder.

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,32 +1,26 @@
from pathlib import Path

import pytest
from algokit_utils import (
get_algod_client,
get_default_localnet_config,
get_indexer_client,
is_localnet,
)
from algosdk.v2client.algod import AlgodClient
from algosdk.v2client.indexer import IndexerClient
from dotenv import load_dotenv


@pytest.fixture(autouse=True, scope="session")
def environment_fixture() -> None:
env_path = Path(__file__).parent.parent / ".env.localnet"
load_dotenv(env_path)
# Uncomment if you want to load network specific or generic .env file
# @pytest.fixture(autouse=True, scope="session")
# def environment_fixture() -> None:
# env_path = Path(__file__).parent.parent / ".env"
# load_dotenv(env_path)


@pytest.fixture(scope="session")
def algod_client() -> AlgodClient:
client = get_algod_client()

# you can remove this assertion to test on other networks,
# included here to prevent accidentally running against other networks
assert is_localnet(client)
# by default we are using localnet algod
client = get_algod_client(get_default_localnet_config("algod"))
return client


@pytest.fixture(scope="session")
def indexer_client() -> IndexerClient:
return get_indexer_client()
return get_indexer_client(get_default_localnet_config("indexer"))
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
[algokit]
min_version = "v2.0.0"

[generate.smart_contract]
description = "Adds new smart contract to existing project"
[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 = 'production_python_smart_contract_typescript'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
_tasks:
- "echo '==== Successfully generated new .env file 🚀 ===='"

use_generic_env:
type: bool
help: Create generic empty .env file (true) or create a network specific .env.{network_name} file (false).
placeholder: "true"
default: "true"

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' }}"

_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,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

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,27 @@ While primarily optimized for VS Code, JetBrains IDEs are supported:
## AlgoKit Workspaces and Project Management
This project supports both standalone and monorepo setups through AlgoKit workspaces. Leverage [`algokit project run`](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/project/run.md) commands for efficient monorepo project orchestration and management across multiple projects within a workspace.

> For guidance on `smart_contracts` folder and adding new contracts to the project please see [README](smart_contracts/README.md) on the respective folder.### Continuous Integration / Continuous Deployment (CI/CD)
## AlgoKit Generators

This template provides a set of [algokit generators](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/generate.md) that allow you to further modify the project instantiated from the template to fit your needs, as well as giving you a base to build your own extensions to invoke via the `algokit generate` command.

### Generate Smart Contract

By the default the template creates a single `HelloWorld` contract under hello_world folder in the `smart_contracts` directory. To add a new contract:

1. From the root of the project (`../`) execute `algokit generate smart-contract`. This will create a new starter smart contract and deployment configuration file under `{your_contract_name}` subfolder under `smart_contracts` directory.
2. Each contract potentially has different creation parameters and deployment steps. Hence, you need to define your deployment logic in `deploy-config.ts`file.
3. `config.py` file will automatically build all contracts under `smart_contracts` directory. If you want to build specific contracts manually, modify the default code provided by the template in `config.py` file.
4. Since you are generating a TypeScript client, you also need to reference your contract deployment logic in `index.ts` file. However, similar to config.py, by default, `index.ts` will auto import all TypeScript deployment files under `smart_contracts` directory. If you want to manually import specific contracts, modify the default code provided by the template in `index.ts` file.

> Please note, above is just a suggested convention tailored for the base configuration and structure of this template. Default code supplied by the template in `config.py` and `index.ts` (if using ts clients) files are tailored for the suggested convention. You are free to modify the structure and naming conventions as you see fit.

### Generate '.env' files

By default the template instance would not contain any env files. Using [`algokit project deploy`](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/project/deploy.md) against `localnet` | `testnet` | `mainnet` will use default values for `algod` and `indexer` unless overwritten via `.env` or `.env.{target_network}`.

To generate a new `.env` or `.env.{target_network}` file:
- `algokit generate env-file`### Continuous Integration / Continuous Deployment (CI/CD)

This project uses [GitHub Actions](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions) to define CI/CD workflows, which are located in the [.github/workflows](`.github/workflows`) folder.

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
[algokit]
min_version = "v2.0.0"

[generate.smart_contract]
description = "Adds new smart contract to existing project"
[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 = 'starter_python_smart_contract_python'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
_tasks:
- "echo '==== Successfully generated new .env file 🚀 ===='"

use_generic_env:
type: bool
help: Create generic empty .env file (true) or create a network specific .env.{network_name} file (false).
placeholder: "true"
default: "true"

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' }}"

_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,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

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,26 @@ While primarily optimized for VS Code, JetBrains IDEs are supported:
## AlgoKit Workspaces and Project Management
This project supports both standalone and monorepo setups through AlgoKit workspaces. Leverage [`algokit project run`](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/project/run.md) commands for efficient monorepo project orchestration and management across multiple projects within a workspace.

> For guidance on `smart_contracts` folder and adding new contracts to the project please see [README](smart_contracts/README.md) on the respective folder.
## AlgoKit Generators

This template provides a set of [algokit generators](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/generate.md) that allow you to further modify the project instantiated from the template to fit your needs, as well as giving you a base to build your own extensions to invoke via the `algokit generate` command.

### Generate Smart Contract

By the default the template creates a single `HelloWorld` contract under hello_world folder in the `smart_contracts` directory. To add a new contract:

1. From the root of the project (`../`) execute `algokit generate smart-contract`. This will create a new starter smart contract and deployment configuration file under `{your_contract_name}` subfolder under `smart_contracts` directory.
2. Each contract potentially has different creation parameters and deployment steps. Hence, you need to define your deployment logic in `deploy_config.py`file.
3. `config.py` file will automatically build all contracts under `smart_contracts` directory. If you want to build specific contracts manually, modify the default code provided by the template in `config.py` file.

> Please note, above is just a suggested convention tailored for the base configuration and structure of this template. Default code supplied by the template in `config.py` and `index.ts` (if using ts clients) files are tailored for the suggested convention. You are free to modify the structure and naming conventions as you see fit.

### Generate '.env' files

By default the template instance would not contain any env files. Using [`algokit project deploy`](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/project/deploy.md) against `localnet` | `testnet` | `mainnet` will use default values for `algod` and `indexer` unless overwritten via `.env` or `.env.{target_network}`.

To generate a new `.env` or `.env.{target_network}` file:
- `algokit generate env-file`

# Tools

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
[algokit]
min_version = "v2.0.0"

[generate.smart_contract]
description = "Adds new smart contract to existing project"
[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 = 'starter_python_smart_contract_typescript'
Expand Down
Loading