Skip to content

Commit

Permalink
Release - Version 0.2.0 (#9)
Browse files Browse the repository at this point in the history
* chore: add root package.json and pnpm-workspace.yaml

* feat: generate .env.localnet via bootstrap script

* docs: root README with updated quick start

* chore: fix formatting

* docs: min AlgoKit version 2

* feat(ui): add vercel.json, avoid vercel 404 - NotFound error

* feat(ui): handle rewrites if deployed to Netlify

* chore: release v0.2.0
  • Loading branch information
drichar authored Apr 3, 2024
1 parent 32eaf8b commit aeff813
Show file tree
Hide file tree
Showing 14 changed files with 2,414 additions and 5,512 deletions.
84 changes: 76 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,83 @@
# Reti Open Pooling
# Réti Open Pooling

See [Reti Open Pooling](./docs/SUMMARY.md) for details on the proposal this implementation is for.
Welcome to the Réti Open Pooling monorepo. This README provides instructions for running the protocol and its accompanying example UI in a local environment. Detailed protocol information and its objectives can be found in the [Gitbook documentation](https://txnlab.gitbook.io/reti-open-pooling).

## Tealscript Contracts
## Overview

See [Contracts](./contracts/README.md)
The Réti Open Pooling protocol enables the creation of decentralized staking pools on the Algorand network, promoting broader participation and enhancing network security through diversification. It is designed to be open-source, non-custodial, and fully decentralized, allowing for the creation and joining of staking pools to meet the minimum stake required for node rewards on Algorand.

## Node Daemon
## Prerequisites

See [Node Manager](./docs/technical-implementation/reti-node-daemon/README.md)
Before starting, ensure you have the following installed:
- **Docker**: Required for running AlgoKit. [Installation guide](https://www.docker.com/get-started).
- **AlgoKit**: Version 2.0 or later is required. [Installation guide](https://github.com/algorandfoundation/algokit-cli#install). Verify by running `algokit --version`.
- **PNPM**: Version 8.0 or later for package management. [Installation guide](https://pnpm.io/installation). Verify by running `pnpm --version`.

## UI
## Quick Start

See [UI](./ui/README.md)
This section provides instructions for running the protocol and UI in a local AlgoKit sandbox environment.

- **Clone the repository**

```bash
git clone https://github.com/TxnLab/reti.git
```

- **Navigate to the `reti` directory**

```bash
cd reti
```

- **Install dependencies**

```bash
pnpm install
```

- **Start the local network**

```bash
algokit localnet start
```

- **Bootstrap the validator**

This command bootstraps a new master validator and funds two new test accounts. It also sets environment variables for LocalNet that will be used by the front-end.
```bash
pnpm run bootstrap
```

- **Launch the UI**

```bash
pnpm run dev
```

## TestNet Development

- **Navigate to the `ui` directory**

```bash
cd ui
```

- **Create a `.env.testnet` file**

Copy the TestNet variables from the [`.env.template`](./ui/.env.template) file into a new `.env.testnet` file. Check back often to make sure you're using the latest master validator app ID, set to `VITE_RETI_APP_ID`.

- **Launch the UI**

```bash
pnpm run dev:testnet
```

## Additional Resources

- **TEALScript Contracts**: Explore the smart contracts that power the protocol. [Read more](./contracts/README.md)
- **Node Daemon**: Learn about the CLI / service daemon which node runners will run as a background service. [Read more](./docs/technical-implementation/reti-node-daemon/README.md)
- **Example UI**: A Vite React project that serves as a dashboard for staking and validator management. [Read more](./ui/README.md)

## Discord

For questions or technical support, you can reach us in the **#reti** channel on NFD's Discord: https://discord.gg/w6vSwG5bFK
41 changes: 39 additions & 2 deletions contracts/bootstrap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { mnemonicAccountFromEnvironment } from '@algorandfoundation/algokit-util
import { StakingPoolClient } from '../contracts/clients/StakingPoolClient';
import { ValidatorRegistryClient } from '../contracts/clients/ValidatorRegistryClient';

async function getNetworkConfig(network: string): Promise<[AlgoClientConfig, bigint, string]> {
function getNetworkConfig(network: string): [AlgoClientConfig, bigint, string] {
let registryAppID: bigint;
let feeSink: string;
switch (network) {
Expand Down Expand Up @@ -43,14 +43,48 @@ async function getNetworkConfig(network: string): Promise<[AlgoClientConfig, big
return [config, registryAppID, feeSink];
}

/**
* Creates a .env.localnet file in /ui root folder with updated VITE_RETI_APP_ID
* @param {number | bigint} validatorAppId app id of the master validator contract
*/
function createViteEnvFileForLocalnet(validatorAppId: number | bigint): void {
const templateFilePath = '../../ui/.env.template';
const outputFilePath = '../../ui/.env.localnet';

// Read the .env.template file
const templateContent = fs.readFileSync(templateFilePath, 'utf8');

const sectionStartMarker = '# ========================\n# LocalNet configuration:';
const sectionEndMarker = '# ========================\n# TestNet configuration:';

const startIndex = templateContent.indexOf(sectionStartMarker);
const endIndex = templateContent.indexOf(sectionEndMarker, startIndex);

if (startIndex === -1 || endIndex === -1) {
console.error('Failed to extract LocalNet configuration from .env.template');
return;
}

// Extract the LocalNet configuration section
let localNetSection = templateContent.substring(startIndex, endIndex);

// Replace VITE_RETI_APP_ID placeholder with the actual validatorAppId
localNetSection = localNetSection.replace('VITE_RETI_APP_ID=0', `VITE_RETI_APP_ID=${validatorAppId.toString()}`);

// Write the new .env.localnet file
fs.writeFileSync(outputFilePath, localNetSection);

console.log(`Created ${outputFilePath} with updated VITE_RETI_APP_ID.`);
}

async function main() {
const args = await yargs.option('network', {
default: 'localnet',
choices: ['localnet', 'betanet', 'testnet', 'mainnet'],
demandOption: true,
}).argv;

const [algodconfig, registryAppID, feeSink] = await getNetworkConfig(args.network);
const [algodconfig, registryAppID, feeSink] = getNetworkConfig(args.network);

const algod = algokit.getAlgoClient(algodconfig);
const localConfig = algokit.getConfigFromEnvOrDefaults();
Expand Down Expand Up @@ -146,6 +180,9 @@ async function main() {
`ALGO_MNEMONIC_${creatorAcct.addr.substring(0, 4)}=${secretKeyToMnemonic(creatorAcct.sk)}\nRETI_APPID=${validatorApp.appId}\nALGO_MNEMONIC_${staker1.addr.substring(0, 4)}=${secretKeyToMnemonic(staker1.sk)}\nALGO_MNEMONIC_${staker2.addr.substring(0, 4)}=${secretKeyToMnemonic(staker2.sk)}\n`
);
console.log('Modified .env.sandbox in nodemgr directory with these values for testing');

// Create a .env.localnet file in the ui directory with the validator app id
createViteEnvFileForLocalnet(validatorApp.appId);
}
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/bootstrap/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bootstrap",
"version": "0.1.0",
"version": "0.2.0",
"description": "",
"main": "index.ts",
"scripts": {
Expand Down
Loading

0 comments on commit aeff813

Please sign in to comment.