Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
3cd6a54
3 cli setup testing framework (#35)
cristiam86 Jul 3, 2024
ab3b32b
33 cli add a warning at init to say that the config is going to be ov…
cristiam86 Jul 3, 2024
b77fec8
37 cli run simulator on certain branch (#39)
cristiam86 Jul 3, 2024
ddb0714
41 cli add beta releases for staging branch (#42)
cristiam86 Jul 3, 2024
26302e4
Release v0.0.32-beta.0 [skip ci]
Jul 3, 2024
60d6da3
43 cli fix missing endpoints and simulator response (#44)
cristiam86 Jul 3, 2024
6a2d6ab
Release v0.0.32-beta.1 [skip ci]
Jul 3, 2024
586ffa8
43 cli fix missing endpoints and simulator response (#45)
cristiam86 Jul 3, 2024
59a9fc6
Release v0.0.32-beta.2 [skip ci]
Jul 3, 2024
0e96ecd
46 cli add node and docker version (#47)
denishacquin Jul 26, 2024
8f0a798
Release v0.0.32-beta.3 [skip ci]
Jul 26, 2024
da8a16f
chore(deps): update dependency eslint to v9
renovate[bot] Oct 25, 2024
9a2befb
chore(deps): update tibdex/github-app-token action to v2
renovate[bot] Nov 6, 2024
fd4883e
chore(deps): update actions/setup-node action to v4
renovate[bot] Jan 9, 2025
a461688
chore(deps): update dependency esbuild to ^0.25.0 [security]
renovate[bot] Feb 12, 2025
39ec17b
feat: new log and spinner class
epsjunior Feb 14, 2025
134df7f
feat: adding spinner to keygen command
epsjunior Feb 14, 2025
25967f9
feat: adding spinner and logs to command config
epsjunior Feb 14, 2025
0c9f777
feat: new up command(class)
epsjunior Feb 17, 2025
5544edb
feat: refac init, base action and unit tests
epsjunior Feb 20, 2025
5c454bd
merging
epsjunior Feb 20, 2025
07d1f86
fix: merging commit
epsjunior Feb 20, 2025
df6c846
chore(deps): update dependency @release-it/conventional-changelog to v10
renovate[bot] Feb 20, 2025
e461692
chore(deps): update dependency eslint-config-prettier to v10
renovate[bot] Feb 20, 2025
c0ebac0
fix(deps): update dependency inquirer to v12
renovate[bot] Feb 20, 2025
753158f
chore(deps): update dependency jsdom to v26
renovate[bot] Feb 20, 2025
ac0ab0e
chore(deps): update dependency release-it to v18
renovate[bot] Feb 20, 2025
69416b5
fix(deps): update all non-major dependencies
renovate[bot] Feb 21, 2025
eddef2b
Merge branch 'renovate/actions-setup-node-4.x'
epsjunior Feb 21, 2025
8ae848b
Merge branch 'renovate/major-eslint-monorepo'
epsjunior Feb 21, 2025
4faf084
Merge branch 'renovate/tibdex-github-app-token-2.x'
epsjunior Feb 21, 2025
77d0e2b
Merge branch 'renovate/inquirer-12.x'
epsjunior Feb 21, 2025
914a989
Merge branch 'renovate/all-minor-patch'
epsjunior Feb 21, 2025
fa6cc67
fix: merging
epsjunior Feb 21, 2025
26cd6c1
Merge branch 'renovate/release-it-conventional-changelog-10.x'
epsjunior Feb 21, 2025
f65690d
fix: merging conflicts
epsjunior Feb 21, 2025
02467b1
Merge branch 'renovate/jsdom-26.x'
epsjunior Feb 21, 2025
9af428d
Merge branch 'renovate/release-it-18.x'
epsjunior Feb 21, 2025
c293bef
fix: updating packages and fixing breaking changes
epsjunior Feb 21, 2025
1c05553
fix: merging conflicts
epsjunior Feb 24, 2025
189dc35
fix: package json
epsjunior Feb 24, 2025
ac3cfa3
fix: merging conflicts
epsjunior Feb 24, 2025
9b115e1
fix: package lock
epsjunior Feb 24, 2025
157c74a
chore: ollama hint message
epsjunior Feb 24, 2025
7529843
feat: new init project command
epsjunior Feb 27, 2025
5bd78b6
fix: script path
epsjunior Feb 27, 2025
e49f2a7
fix: script not throwing error
epsjunior Feb 27, 2025
741cc8f
tests: adding tests
epsjunior Feb 27, 2025
50fd8f7
fix: project new files
epsjunior Feb 27, 2025
244d5fd
fix: fixing template to use ts
epsjunior Feb 28, 2025
5ba23a0
fix: merging and conflicts
epsjunior Mar 6, 2025
df96624
fix: new package lock
epsjunior Mar 6, 2025
ae648ee
Merge branch 'main' into 192-start-new-project
cristiam86 Apr 16, 2025
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
3 changes: 1 addition & 2 deletions esbuild.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ export default {
banner: {
js: `const _importMetaUrl = new URL(import.meta.url).pathname;`,
},
external: ["commander", "dockerode", "dotenv", "ethers", "inquirer", "update-check", "ssh2", "esbuild"]

external: ["commander", "dockerode", "dotenv", "ethers", "inquirer", "update-check", "ssh2", "fs-extra"]
},
watch: true,
};
2 changes: 1 addition & 1 deletion esbuild.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default {
banner: {
js: `const _importMetaUrl = new URL(import.meta.url).pathname;`,
},
external: ["commander", "dockerode", "dotenv", "ethers", "inquirer", "update-check", "ssh2", "esbuild"]
external: ["commander", "dockerode", "dotenv", "ethers", "inquirer", "update-check", "ssh2", "fs-extra"]
},
watch: false,
};
3 changes: 2 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export default [
"eslint.config.js",
"Config.js",
"commitLint.config.ts",
"scripts/postinstall.js"
"scripts/postinstall.js",
"templates/**/*"
],
plugins: {
"@typescript-eslint": tseslint,
Expand Down
59 changes: 58 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"devDependencies": {
"@release-it/conventional-changelog": "^10.0.0",
"@types/dockerode": "^3.3.31",
"@types/fs-extra": "^11.0.4",
"@types/inquirer": "^9.0.7",
"@types/node": "^22.0.0",
"@types/sinon": "^17.0.3",
Expand All @@ -62,6 +63,7 @@
"dockerode": "^4.0.2",
"dotenv": "^16.4.5",
"ethers": "^6.13.4",
"fs-extra": "^11.3.0",
"genlayer-js": "^0.6.0",
"inquirer": "^12.0.0",
"node-fetch": "^3.0.0",
Expand Down
16 changes: 16 additions & 0 deletions src/commands/scaffold/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Command } from "commander";
import { NewAction } from "./new";

export function initializeScaffoldCommands(program: Command) {
program
.command("new <projectName>")
.description("Create a new GenLayer project using the default template")
.option("--path <directory>", "Specify the directory for the new project", ".")
.option("--overwrite", "Overwrite existing directory if it exists", false)
.action(async (projectName, options) => {
const newProjectAction = new NewAction();
await newProjectAction.createProject(projectName, options);
});

return program;
}
34 changes: 34 additions & 0 deletions src/commands/scaffold/new.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import fs from "fs-extra";
import path from "path";
import { fileURLToPath } from "url";
import { BaseAction } from "../../lib/actions/BaseAction";

export class NewAction extends BaseAction {
private templatePath: string;

constructor() {
super();
const __filename = fileURLToPath(import.meta.url);
const basePath = path.resolve(path.dirname(__filename), "..");
this.templatePath = path.join(basePath, "templates", "default");
}

async createProject(projectName: string, options: { path: string; overwrite: boolean }) {
const targetPath = path.resolve(options.path, projectName);

if (fs.existsSync(targetPath) && !options.overwrite) {
return this.failSpinner(
`Project directory "${targetPath}" already exists. Use --overwrite to replace it.`
);
}

this.startSpinner(`Creating new GenLayer project: ${projectName}`);

try {
fs.copySync(this.templatePath, targetPath);
this.succeedSpinner(`Project "${projectName}" created successfully at ${targetPath}`);
} catch (error) {
this.failSpinner(`Error creating project "${projectName}"`, error);
}
}
}
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { initializeContractsCommands } from "../src/commands/contracts";
import { initializeConfigCommands } from "../src/commands/config";
import {initializeValidatorCommands} from "../src/commands/validators";
import { initializeUpdateCommands } from "../src/commands/update";
import { initializeScaffoldCommands } from "../src/commands/scaffold";

export function initializeCLI() {
program.version(version).description(CLI_DESCRIPTION);
Expand All @@ -17,6 +18,7 @@ export function initializeCLI() {
initializeConfigCommands(program);
initializeUpdateCommands(program)
initializeValidatorCommands(program);
initializeScaffoldCommands(program);
program.parse(process.argv);
}

Expand Down
21 changes: 21 additions & 0 deletions templates/default/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 YeagerAI

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
101 changes: 101 additions & 0 deletions templates/default/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Sample GenLayer project
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/license/mit/)
[![Discord](https://dcbadge.vercel.app/api/server/8Jm4v89VAu?compact=true&style=flat)](https://discord.gg/8Jm4v89VAu)
[![Telegram](https://img.shields.io/badge/Telegram--T.svg?style=social&logo=telegram)](https://t.me/genlayer)
[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/yeagerai.svg?style=social&label=Follow%20%40GenLayer)](https://x.com/GenLayer)
[![GitHub star chart](https://img.shields.io/github/stars/yeagerai/genlayer-project-boilerplate?style=social)](https://star-history.com/#yeagerai/genlayer-js)

## 👀 About
This project includes the boilerplate code for a GenLayer use case implementation, specifically a football bets game.

## 📦 What's included
- Basic requirements to deploy and test your intelligent contracts locally
- Configuration file template
<!-- - Test functions to write complete end-to-end tests -->
- An example of an intelligent contract (Football Bets)
- Example end-to-end tests for the contract provided

## 🛠️ Requirements
- A running GenLayer Studio (Install from [Docs](https://docs.genlayer.com/developers/intelligent-contracts/tooling-setup#using-the-genlayer-studio) or work with the hosted version of [GenLayer Studio](https://studio.genlayer.com/)). If you are working locally, this repository code does not need to be located in the same directory as the Genlayer Studio.

## 🚀 Steps to run this example

### 1. Configure environment
Rename the `.env.example` file to `.env`, then fill in the values for your configuration. The provided values are the standard values for a tipical GenLayer Studio deployed locally.

### 2. Deploy the contract
Deploy the contract from `/contracts/football_bets.py` using the Studio's UI:
1. Open the GenLayer Studio interface in your web browser (usually at http://localhost:8080).
2. Create a new file in the "Contracts" section and paste the content of `/contracts/football_bets.py` (the content is different than the existing contract from the examples).
3. Navigate to the "Run and Debug" section.
4. Follow the on-screen instructions to complete the deployment process.

### 3. Setup the frontend environment
1. All the content of the dApp is located in the `/app` folder.
2. Rename the `.env.example` file in the `/app` folder to `.env`.
3. Add the deployed contract address to the `/app/.env` under the variable `VITE_CONTRACT_ADDRESS`

### 4. Run the frontend Vue app
Ensure your GenLayer Studio is running, and execute the following commands in your terminal:
```shell
cd app
npm install
npm run dev
```
The terminal should display a link to access your frontend app (usually at http://localhost:5173/).
For more information on the code see [GenLayerJS](https://github.com/yeagerai/genlayer-js).

<!-- ### 5. Test contracts
1. Install the Python packages listed in the `requirements.txt` file in a virtual environment.
2. Make sure your GenLayer Studio is running. Then execute the following command in your terminal:
```shell
pytest test
``` -->

## ⚽ How the Football Bets Contract Works

The Football Bets contract allows users to create bets for football matches, resolve those bets, and earn points for correct bets. Here's a breakdown of its main functionalities:

1. Creating Bets:
- Users can create a bet for a specific football match by providing the game date, team names, and their predicted winner.
- The contract checks if the game has already finished and if the user has already made a bet for this match.

2. Resolving Bets:
- After a match has concluded, users can resolve their bets.
- The contract fetches the actual match result from a specified URL.
- If the Bet was correct, the user earns a point.

3. Querying Data:
- Users can retrieve all bets.
- The contract also allows querying of points, either for all players or for a specific player.

4. Getting Points:
- Points are awarded for correct bets.
- Users can check their total points or the points of any player.

<!-- ## 🧪 Tests

This project includes integration tests that interact with the contract deployed in the Studio. These tests cover the main functionalities of the Football Bets contract:

1. Creating a bet
2. Resolving a bet
3. Querying bets for a player
4. Querying points for a player

The tests simulate real-world interactions with the contract, ensuring that it behaves correctly under various scenarios. They use the GenLayer Studio to deploy and interact with the contract, providing a comprehensive check of the contract's functionality in a controlled environment.

To run the tests, use the `pytest test` command as mentioned in the "Steps to run this example" section. -->


## 💬 Community
Connect with the GenLayer community to discuss, collaborate, and share insights:
- **[Discord Channel](https://discord.gg/8Jm4v89VAu)**: Our primary hub for discussions, support, and announcements.
- **[Telegram Group](https://t.me/genlayer)**: For more informal chats and quick updates.

Your continuous feedback drives better product development. Please engage with us regularly to test, discuss, and improve GenLayer.

## 📖 Documentation
For detailed information on how to use GenLayerJS SDK, please refer to our [documentation](https://docs.genlayer.com/).

## 📜 License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
Empty file added templates/default/__init__.py
Empty file.
2 changes: 2 additions & 0 deletions templates/default/app/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
VITE_CONTRACT_ADDRESS=""
VITE_STUDIO_URL="https://studio.genlayer.com/api"
24 changes: 24 additions & 0 deletions templates/default/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
3 changes: 3 additions & 0 deletions templates/default/app/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["Vue.volar"]
}
5 changes: 5 additions & 0 deletions templates/default/app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Vue 3 + Vite

This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.

Learn more about IDE Support for Vue in the [Vue Docs Scaling up Guide](https://vuejs.org/guide/scaling-up/tooling.html#ide-support).
Loading