genlayer 0.12.4 โ†’ 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/.env.example +4 -0
  2. package/CHANGELOG.md +8 -0
  3. package/dist/index.js +17970 -17628
  4. package/esbuild.config.dev.js +1 -2
  5. package/esbuild.config.prod.js +1 -1
  6. package/eslint.config.js +2 -1
  7. package/package.json +5 -3
  8. package/src/commands/contracts/call.ts +23 -33
  9. package/src/commands/contracts/deploy.ts +109 -33
  10. package/src/commands/contracts/index.ts +14 -3
  11. package/src/commands/general/init.ts +0 -1
  12. package/src/commands/keygen/create.ts +5 -25
  13. package/src/commands/scaffold/index.ts +16 -0
  14. package/src/commands/scaffold/new.ts +34 -0
  15. package/src/index.ts +2 -0
  16. package/src/lib/accounts/KeypairManager.ts +43 -0
  17. package/src/lib/actions/BaseAction.ts +34 -7
  18. package/src/lib/config/simulator.ts +2 -2
  19. package/templates/default/LICENSE +21 -0
  20. package/templates/default/README.md +101 -0
  21. package/templates/default/__init__.py +0 -0
  22. package/templates/default/app/.env.example +2 -0
  23. package/templates/default/app/.vscode/extensions.json +3 -0
  24. package/templates/default/app/README.md +5 -0
  25. package/templates/default/app/index.html +17 -0
  26. package/templates/default/app/package-lock.json +4920 -0
  27. package/templates/default/app/package.json +23 -0
  28. package/templates/default/app/postcss.config.js +6 -0
  29. package/templates/default/app/public/favicon.png +0 -0
  30. package/templates/default/app/src/App.vue +16 -0
  31. package/templates/default/app/src/components/Address.vue +38 -0
  32. package/templates/default/app/src/components/BetsScreen.vue +329 -0
  33. package/templates/default/app/src/logic/FootballBets.js +100 -0
  34. package/templates/default/app/src/main.js +5 -0
  35. package/templates/default/app/src/services/genlayer.js +19 -0
  36. package/templates/default/app/src/style.css +3 -0
  37. package/templates/default/app/tailwind.config.js +8 -0
  38. package/templates/default/app/vite.config.js +7 -0
  39. package/templates/default/config/__init__.py +0 -0
  40. package/templates/default/config/genlayer_config.py +14 -0
  41. package/templates/default/contracts/__init__.py +0 -0
  42. package/templates/default/contracts/football_bets.py +119 -0
  43. package/templates/default/deploy/deployScript.ts +31 -0
  44. package/templates/default/package-lock.json +3231 -0
  45. package/templates/default/package.json +7 -0
  46. package/templates/default/requirements.txt +6 -0
  47. package/templates/default/test/__init__.py +0 -0
  48. package/templates/default/test/football_bets_get_contract_schema_for_code.py +124 -0
  49. package/templates/default/test/test_football_bet_success_draw.py +108 -0
  50. package/templates/default/test/test_football_bet_success_win.py +106 -0
  51. package/templates/default/test/test_football_bet_unsuccess.py +107 -0
  52. package/templates/default/tools/__init__.py +0 -0
  53. package/templates/default/tools/accounts.py +5 -0
  54. package/templates/default/tools/calldata.py +224 -0
  55. package/templates/default/tools/request.py +134 -0
  56. package/templates/default/tools/response.py +52 -0
  57. package/templates/default/tools/structure.py +39 -0
  58. package/templates/default/tools/transactions.py +28 -0
  59. package/templates/default/tools/types.py +214 -0
  60. package/templates/default/tsconfig.json +7 -0
  61. package/tests/actions/call.test.ts +39 -79
  62. package/tests/actions/create.test.ts +11 -72
  63. package/tests/actions/deploy.test.ts +201 -33
  64. package/tests/actions/new.test.ts +80 -0
  65. package/tests/commands/call.test.ts +6 -1
  66. package/tests/commands/deploy.test.ts +12 -1
  67. package/tests/commands/new.test.ts +68 -0
  68. package/tests/index.test.ts +4 -0
  69. package/tests/libs/accounts/KeypairManager.test.ts +110 -0
  70. package/tests/libs/baseAction.test.ts +40 -0
  71. package/vitest.config.ts +1 -1
  72. package/src/lib/accounts/getPrivateKey.ts +0 -21
  73. package/tests/libs/getPrivateKey.test.ts +0 -96
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 YeagerAI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,101 @@
1
+ # Sample GenLayer project
2
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/license/mit/)
3
+ [![Discord](https://dcbadge.vercel.app/api/server/8Jm4v89VAu?compact=true&style=flat)](https://discord.gg/8Jm4v89VAu)
4
+ [![Telegram](https://img.shields.io/badge/Telegram--T.svg?style=social&logo=telegram)](https://t.me/genlayer)
5
+ [![Twitter](https://img.shields.io/twitter/url/https/twitter.com/yeagerai.svg?style=social&label=Follow%20%40GenLayer)](https://x.com/GenLayer)
6
+ [![GitHub star chart](https://img.shields.io/github/stars/yeagerai/genlayer-project-boilerplate?style=social)](https://star-history.com/#yeagerai/genlayer-js)
7
+
8
+ ## ๐Ÿ‘€ About
9
+ This project includes the boilerplate code for a GenLayer use case implementation, specifically a football bets game.
10
+
11
+ ## ๐Ÿ“ฆ What's included
12
+ - Basic requirements to deploy and test your intelligent contracts locally
13
+ - Configuration file template
14
+ <!-- - Test functions to write complete end-to-end tests -->
15
+ - An example of an intelligent contract (Football Bets)
16
+ - Example end-to-end tests for the contract provided
17
+
18
+ ## ๐Ÿ› ๏ธ Requirements
19
+ - 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.
20
+
21
+ ## ๐Ÿš€ Steps to run this example
22
+
23
+ ### 1. Configure environment
24
+ 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.
25
+
26
+ ### 2. Deploy the contract
27
+ Deploy the contract from `/contracts/football_bets.py` using the Studio's UI:
28
+ 1. Open the GenLayer Studio interface in your web browser (usually at http://localhost:8080).
29
+ 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).
30
+ 3. Navigate to the "Run and Debug" section.
31
+ 4. Follow the on-screen instructions to complete the deployment process.
32
+
33
+ ### 3. Setup the frontend environment
34
+ 1. All the content of the dApp is located in the `/app` folder.
35
+ 2. Rename the `.env.example` file in the `/app` folder to `.env`.
36
+ 3. Add the deployed contract address to the `/app/.env` under the variable `VITE_CONTRACT_ADDRESS`
37
+
38
+ ### 4. Run the frontend Vue app
39
+ Ensure your GenLayer Studio is running, and execute the following commands in your terminal:
40
+ ```shell
41
+ cd app
42
+ npm install
43
+ npm run dev
44
+ ```
45
+ The terminal should display a link to access your frontend app (usually at http://localhost:5173/).
46
+ For more information on the code see [GenLayerJS](https://github.com/yeagerai/genlayer-js).
47
+
48
+ <!-- ### 5. Test contracts
49
+ 1. Install the Python packages listed in the `requirements.txt` file in a virtual environment.
50
+ 2. Make sure your GenLayer Studio is running. Then execute the following command in your terminal:
51
+ ```shell
52
+ pytest test
53
+ ``` -->
54
+
55
+ ## โšฝ How the Football Bets Contract Works
56
+
57
+ 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:
58
+
59
+ 1. Creating Bets:
60
+ - Users can create a bet for a specific football match by providing the game date, team names, and their predicted winner.
61
+ - The contract checks if the game has already finished and if the user has already made a bet for this match.
62
+
63
+ 2. Resolving Bets:
64
+ - After a match has concluded, users can resolve their bets.
65
+ - The contract fetches the actual match result from a specified URL.
66
+ - If the Bet was correct, the user earns a point.
67
+
68
+ 3. Querying Data:
69
+ - Users can retrieve all bets.
70
+ - The contract also allows querying of points, either for all players or for a specific player.
71
+
72
+ 4. Getting Points:
73
+ - Points are awarded for correct bets.
74
+ - Users can check their total points or the points of any player.
75
+
76
+ <!-- ## ๐Ÿงช Tests
77
+
78
+ 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:
79
+
80
+ 1. Creating a bet
81
+ 2. Resolving a bet
82
+ 3. Querying bets for a player
83
+ 4. Querying points for a player
84
+
85
+ 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.
86
+
87
+ To run the tests, use the `pytest test` command as mentioned in the "Steps to run this example" section. -->
88
+
89
+
90
+ ## ๐Ÿ’ฌ Community
91
+ Connect with the GenLayer community to discuss, collaborate, and share insights:
92
+ - **[Discord Channel](https://discord.gg/8Jm4v89VAu)**: Our primary hub for discussions, support, and announcements.
93
+ - **[Telegram Group](https://t.me/genlayer)**: For more informal chats and quick updates.
94
+
95
+ Your continuous feedback drives better product development. Please engage with us regularly to test, discuss, and improve GenLayer.
96
+
97
+ ## ๐Ÿ“– Documentation
98
+ For detailed information on how to use GenLayerJS SDK, please refer to our [documentation](https://docs.genlayer.com/).
99
+
100
+ ## ๐Ÿ“œ License
101
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
File without changes
@@ -0,0 +1,2 @@
1
+ VITE_CONTRACT_ADDRESS=""
2
+ VITE_STUDIO_URL="https://studio.genlayer.com/api"
@@ -0,0 +1,3 @@
1
+ {
2
+ "recommendations": ["Vue.volar"]
3
+ }
@@ -0,0 +1,5 @@
1
+ # Vue 3 + Vite
2
+
3
+ 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.
4
+
5
+ Learn more about IDE Support for Vue in the [Vue Docs Scaling up Guide](https://vuejs.org/guide/scaling-up/tooling.html#ide-support).
@@ -0,0 +1,17 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8" />
6
+ <link rel="icon" type="image/svg+xml" href="/vite.svg" />
7
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
8
+ <title>GenLayer Football Bets</title>
9
+ <link rel="shortcut icon" type="image/png" href="/favicon.png">
10
+ </head>
11
+
12
+ <body>
13
+ <div id="app"></div>
14
+ <script type="module" src="/src/main.js"></script>
15
+ </body>
16
+
17
+ </html>