From aea637ec6aa90ec39b1019cd55a55a2bf7c94002 Mon Sep 17 00:00:00 2001 From: "Chris Kim (Hyunggun)" Date: Sat, 22 Jun 2024 19:59:51 +0900 Subject: [PATCH] translated korean to english for readme, deploy-config.ts --- README.md | 142 +++++++++++------- projects/coding-assignment/README.md | 135 +++++++++++------ .../nft_marketplace/deploy-config.ts | 50 +++--- python-decipher2024.code-workspace | 4 + 4 files changed, 207 insertions(+), 124 deletions(-) diff --git a/README.md b/README.md index 643467e..82f0521 100644 --- a/README.md +++ b/README.md @@ -1,80 +1,118 @@ -# ๐ŸŽ“ ์—ฐ์„ธ๋Œ€ BAY X ์•Œ๊ณ ๋žœ๋“œ ๊ฐœ๋ฐœ์ž ์„ธ์…˜ 05/30/24 +# ๐ŸŽ“ Become an Algorand Python developer! -## ๐Ÿšฉ ํŒŒ์ด์ฌ์œผ๋กœ ์•Œ๊ณ ๋žœ๋“œ์—์„œ NFT ๋งˆ์ผ“ํ”Œ๋ ˆ์ด์Šค๋ฅผ ๋งŒ๋“ค์–ด ๋ณด์ž! +## ๐Ÿšฉ Let's build an NFT marketplace with Algorand Python! -์—ฐ์„ธ๋Œ€ BAY X ์•Œ๊ณ ๋žœ๋“œ ๊ฐœ๋ฐœ์ž ์„ธ์…˜์— ์˜ค์‹  ๋ฒ ์ด ํ•™ํšŒ์›๋ถ„๋“ค ๋ฐ˜๊ฐ‘์Šต๋‹ˆ๋‹ค~! +Welcome to your first step to become a master in Algorand Python! -์•Œ๊ณ ๋žœ๋“œ ๊ฐœ๋ฐœ์ž ๊ธฐ์ดˆ๊ฐœ๋… ๋ฐ ์Šค๋งˆํŠธ ๊ณ„์•ฝ์— ๊ด€ํ•œ ๋ชจ๋“  ๊ฒƒ ๐Ÿ‘‰ [PPT ์Šฌ๋ผ์ด๋“œ](https://docs.google.com/presentation/d/1I-lxxAkNIRoR9VdDX-wRD68hHuxBvI1uPY-VQlmrgiI/edit?usp=sharing) +In this AlgoKit workspace, there are 2 sub projects: -์ด๋ฒˆ ์ฝ”๋”ฉ ์„ธ์…˜์—์„œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ NFT ๋งˆ์ผ“ํ”Œ๋ ˆ์ด์Šค ์Šค๋งˆํŠธ ๊ณ„์•ฝ์„ [์•Œ๊ณ ๋žœ๋“œ ํŒŒ์ด์ฌ](https://algorandfoundation.github.io/puya/index.html)์„ ์‚ฌ์šฉํ•ด์„œ ๊ตฌํ˜„ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. +- `python-demo` +- `coding-assignment` -NftMarketplace ์•ฑ ์„ค๋ช… +You can see a fully implemented personal bank smart contract written in Algorand Python in the `python-demo` project folder. -์ด ๊ฐ„๋‹จํ•œ NftMarketplace ์•ฑ์€ ์—์„ฏ(ASA)๋ฅผ ํŒ๋งคํ•  ์ˆ˜ ์žˆ๋Š” ์Šค๋งˆํŠธ ๊ณ„์•ฝ์ž…๋‹ˆ๋‹ค. +In the `coding-assignment` project folder, we will implement an NFT marketplace smart contract with [Algorand Python](https://algorandfoundation.github.io/puya/index.html) -์ด ์•ฑ์˜ lifecycle์€ ์•„๋ž˜์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค. -1. ์•ฑ ์ƒ์„ฑ์ž(ํŒ๋งค์ž)๊ฐ€ ์•ฑ์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค. -2. ์•ฑ ์ƒ์„ฑ์ž(ํŒ๋งค์ž)๊ฐ€ ์•ฑ์„ ๋ถ€ํŠธ์ŠคํŠธ๋žฉ ๋ฉ”์„œ๋“œ๋ฅผ ํ˜ธ์ถœํ•ด ๋ถ€ํŠธ์ŠคํŠธ๋žฉํ•ฉ๋‹ˆ๋‹ค. ์ด๋•Œ ์•ฑ์€ ํŒ๋งคํ•  ์—์…‹(ASA)์„ ์„ค์ •ํ•˜๊ณ , ๋‹จ๊ฐ€๋ฅผ ์„ค์ •ํ•˜๊ณ , ์•ฑ ๊ณ„์ •์ด ์˜ตํŠธ์ธ์„ ํ•ฉ๋‹ˆ๋‹ค. -3. ๊ตฌ๋งค์ž๊ฐ€ ์•ฑ์—์„œ ํŒ๋งคํ•˜๋Š” ์—์…‹(ASA)์„ buy๋ฉ”์„œ๋“œ๋ฅผ ํ˜ธ์ถœํ•ด ๊ตฌ๋งคํ•ฉ๋‹ˆ๋‹ค. -4. ์•ฑ ์ƒ์„ฑ์ž(ํŒ๋งค์ž)๊ฐ€ withdraw_and_delete ๋ฉ”์„œ๋“œ๋ฅผ ํ˜ธ์ถœํ•ด ์•ฑ ๊ณ„์ •์— ๋‚จ์•„์žˆ๋Š” ์—์…‹(ASA)์„ ์•ฑ ๊ณ„์ •์œผ๋กœ ์ „์†กํ•˜๊ณ , ๋ชจ๋“  ์ˆ˜์ต๊ธˆ์„ ํŒ๋งค์ž ๊ณ„์ •์œผ๋กœ ์†ก๊ธˆํ•œ ๋’ค, ์Šค๋งˆํŠธ ๊ณ„์•ฝ์„ ์‚ญ์ œํ•ฉ๋‹ˆ๋‹ค. +NftMarketplace smart contract explained: -์ฝ”๋”ฉ ๊ณผ์ œ๋Š” ์ด 4๋ฌธ์ œ๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ์œผ๋ฉฐ ๊ฐ ๋ฌธ์ œ์— "*** ์—ฌ๊ธฐ์— ์ฝ”๋“œ ์ž‘์„ฑ ***" ๋ถ€๋ถ„์— ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค. ๋ฐ‘์— ์ฒดํฌํฌ์ธํŠธ์„ ์ฐจ๋ก€๋Œ€๋กœ ๋”ฐ๋ผ์„œ ์ง„ํ–‰ํ•ด์ฃผ์„ธ์š”! +This simple NftMarketplace smart contract let's sellers to list NFTs for sale and let's buyers to buy the NFT. -### ๊ฐœ๋ฐœ์ž ๋ฆฌ์†Œ์Šค: -- [์•Œ๊ณ ๋žœ๋“œ ๊ฐœ๋ฐœ์ž ๋ฌธ์„œ](https://developer.algorand.org/docs/) -- [์•Œ๊ณ ๋žœ๋“œ ๋””์Šค์ฝ”๋“œ(๋””๋ฒ„๊น…, ์ฝ”๋“œ ๊ด€๋ จ ์งˆ์˜์‘๋‹ต)](https://discord.com/invite/algorand) -- [์•Œ๊ณ ๋žœ๋“œ ํŒŒ์ด์ฌ ๊ฐœ๋ฐœ์ž ๋ฌธ์„œ](https://algorandfoundation.github.io/puya/) -- [์•Œ๊ณ ๋žœ๋“œ ํŒŒ์ด์ฌ ๊นƒํ—™(์˜ˆ์‹œ ์ฝ”๋“œ, ์†Œ์Šค์ฝ”๋“œ)](https://github.com/algorandfoundation/puya) +lifecycle of this app: + +1. The seller deploys the smart contract. +2. The seller calls the bootstrap method to set the asset ID for sale, unitary price, and opt the contract into the ASA. +3. The buyer calls the buy method to buy the ASA. +4. The seller calls the withdraw_and_delete method to withdraw remaining ASA, profits, and then delete the smart contract. + +The coding assignment consist of 4 questions and for each question you can implement your code where it says `Write code here` + +> Please carefully read and follow the checkpoints below to properly complete the coding assignment! + +### Developer Resources: + +- [Algorand Developer Documentation](https://developer.algorand.org/docs/) +- [Algorand Discord (Get tech support, debugging support here)](https://discord.com/invite/algorand) +- [Algorand Python Documentation](https://algorandfoundation.github.io/puya/) +- [Algorand Python Github Repo (Example code, source code)](https://github.com/algorandfoundation/puya) - [Algokit Utils TypeScript](https://github.com/algorandfoundation/algokit-utils-ts/tree/main) -## ์ฒดํฌํฌ์ธํŠธ 1: ๐Ÿงฐ ์•Œ๊ณ ๋žœ๋“œ ๊ฐœ๋ฐœ์— ํ•„์š”ํ•œ ํˆดํ‚ท ์„ค์น˜ +## Checkpoint 1: ๐Ÿงฐ Install prerequisites + +1. [Install Docker](https://www.docker.com/products/docker-desktop/). It is used to run a local Algorand network for development. +2. [Install Python 3.12+](https://www.python.org/downloads/) +3. [Install Node.JS / npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) +4. [Install AlgoKit](https://github.com/algorandfoundation/algokit-cli/tree/main?tab=readme-ov-file#install). -1. [AlgoKit ์„ค์น˜](https://github.com/algorandfoundation/algokit-cli/tree/main?tab=readme-ov-file#install). -2. [Docker ์„ค์น˜](https://www.docker.com/products/docker-desktop/). It is used to run a local Algorand network for development. -3. [Python 3.12 ์ด์ƒ ์„ค์น˜](https://www.python.org/downloads/) -4. [Node.JS / npm ์„ค์น˜](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) +## Checkpoint 2: ๐Ÿ’ป Development environment setup -## ์ฒดํฌํฌ์ธํŠธ 2: ๐Ÿ’ป ๊ฐœ๋ฐœ ํ™˜๊ฒฝ ์…‹์—… +1. [Fork this repository.](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo) +2. `git clone` the forked repo. -1. [์ด ๋ฆฌํฌ๋ฅผ fork ํ•ด์ฃผ์„ธ์š”.](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo) -2. Forkํ•œ ๋ฆฌํฌ๋ฅผ git clone ํ•ด์ฃผ์„ธ์š”. ```bash cd [DIRECTORY_OF_YOUR_CHOICE] git clone [FORKED_REPO_URL] ``` -3. VSCode์—์„œ ์ด ํด๋”๋ฅผ ์—ด๋žŒํ•ด์ฃผ์„ธ์š”. -4. ์—ด๋žŒ ํ›„ `python-decipher2024.code-workspace` ํŒŒ์ผ์„ ์—ด๋žŒ ํ›„ `open workspace` ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ workspace ๋ชจ๋“œ๋ฅผ ์‹คํ–‰์‹œ์ผœ์ฃผ์„ธ์š”. -5. ์ด์ œ VSCode ํ„ฐ๋ฏธ๋„์ด 3๊ฐœ๊ฐ€ ์ž๋™ ์ƒ์„ฑ๋  ๊ฒƒ ์ž…๋‹ˆ๋‹ค: `ROOT` `python-decipher2024` `coding-assignment`. ์ด ์ค‘ `ROOT` VSCode ํ„ฐ๋ฏธ๋„์—์„œ `algokit project bootstrap all` ์ปค๋งจ๋“œ๋ฅผ ์‹คํ–‰์‹œ์ผœ dependencies๋“ค์„ ์„ค์น˜ํ•ด์ฃผ์„ธ์š”. ์ด๋Ÿฌ๋ฉด ๋ชจ๋“  ํ”„๋กœ์ ํŠธ ํด๋”์˜ dependencies๋“ค์ด ์„ค์น˜๋ฉ๋‹ˆ๋‹ค. -> ๋งŒ์•ฝ 3๊ฐœ์˜ ํ„ฐ๋ฏธ๋„์˜ ์ž๋™์œผ๋กœ ์—ด๋ฆฌ์ง€ ์•Š์œผ๋ฉด ์ƒˆ๋กœ์šด ํ„ฐ๋ฏธ๋„์„ + ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ ๋งŒ๋“ค๊ณ  `ROOT`๋ฅผ ์„ ํƒํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค. + +1. Open this project in VSCode +2. Open the file named `python-decipher2024.code-workspace` and press the `open workspace` button to activate workspace mode. +3. 3 VSCode terminal will be auto created: `ROOT` `python-demo` `coding-assignment`. Now go to the `ROOT` VSCode terminal and run the following command to install dependencies required for both sub projects: ```bash algokit project bootstrap all ``` -> ๋งŒ์•ฝ `Unhandled PermissionError: [Errno 13] Permission denied: '/Users/$name/.config/algokit'` ์—๋Ÿฌ๊ฐ€ ๋œฌ๋‹ค๋ฉด ์•ž์— sudo๋ฅผ ๋ถ™์—ฌ์„œ `sudo algokit project bootstrap all` ์ปค๋งจ๋“œ๋ฅผ ์‹คํ–‰ํ•˜์„ธ์š”! +> If the 3 terminals don't open automatically, Press the `+` button and select `ROOT` in VSCode. + +> If you get `Unhandled PermissionError: [Errno 13] Permission denied: '/Users/$name/.config/algokit'` error, add `sudo` in the front and run the following command: + +```bash +sudo algokit project bootstrap all +``` + +1. Now go to the `coding-assignment` terminal and run the following command to activate the Python virtual environment: -6. ์ด์ œ `coding-assignment` ํ„ฐ๋ฏธ๋„์„ ์„ ํƒํ•œ ๋’ค `poetry shell` ์ปค๋งจ๋“œ๋ฅผ ์‹คํ–‰ํ•ด ํŒŒ์ด์ฌ virtual environment๋ฅผ ํ™œ์„ฑํ™” ์‹œ์ผœ์ฃผ์„ธ์š”. - 1. ํŒŒ์ด์ฌ virtual environment๋ฅผ ๋น„ํ™œ์„ฑํ™” ์‹œํ‚ฌ๋•Œ๋Š” `exit` ์ปค๋งจ๋“œ๋ฅผ ์‹คํ–‰ํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค. - 2. venv๋ฅผ ํ™œ์„ฑํ™” ํ•œ ๋’ค `pip list`๋ฅผ ์‹คํ–‰ํ•ด์„œ `algorand-python` ๋ฐ ์—ฌ๋Ÿฌ dependencies๋“ค์ด ๋‚˜์˜ค๋ฉด ์„ฑ๊ณต์ ์œผ๋กœ ๊ฐ€์ƒํ™˜๊ฒฝ์„ ํ™œ์„ฑํ™” ์‹œํ‚จ๊ฒ๋‹ˆ๋‹ค. +```bash +poetry shell +``` -๐ŸŽ‰ ์ด์ œ ๋ชจ๋“  ์ค€๋น„๊ฐ€ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค! Good luck coding! ๐Ÿ’ป +- To deactivate the Python virtual environment, run `exit` in the terminal. +- After activating the venv, run the following command and if you see various dependencies including `algorand-python`, you successfully activate the virtual environment! -๋ฆฌํฌ fork, clone ํŠœํ† ๋ฆฌ์–ผ: +```bash +pip list +``` + +๐ŸŽ‰ Now you are ready to crack this assignment! Good luck coding! ๐Ÿ’ป + +Tutorial for forking and cloning this repository: https://github.com/algorand-fix-the-bug-campaign/challenge-1/assets/52557585/acde8053-a8dd-4f53-8bad-45de1068bfda -## ์ฒดํฌํฌ์ธํŠธ 3: ๐Ÿ“ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜์„ธ์š”! +## Checkpoint 3: ๐Ÿ“ Solve the problems! + +This coding assignment consist of **4 problems** in total. Follow the instructions below! + +### Launch localnet + +1. **_Open Docker Desktop first_** and then run the following command in your terminal to launch the local network. [Click me for more information of localnet!](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/localnet.md#creating--starting-the-localnet) + +```bash +algokit localnet start +``` -์ด ์ฝ”๋”ฉ ๊ณผ์ œ๋Š” **์ด 4๋ฌธ์ œ**๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ์•„๋ž˜ ์„ค๋ช…์„ ์ฐจ๋ก€๋Œ€๋กœ ์ฝ๊ณ  ์ง„ํ–‰ํ•ด์ฃผ์„ธ์š”! +All code in this repo will be run in localnet. -### ๋กœ์ปฌ ๋„คํŠธ์›Œํฌ ์‹คํ–‰ -1. ๋„์ปค ๋ฐ์Šคํฌํƒ‘์„ ์‹คํ–‰ํ•œ ๋’ค ํ„ฐ๋ฏธ๋„์—์„œ `algokit localnet start` ์ปค๋งจ๋“œ๋กœ ๋กœ์ปฌ ๋„คํŠธ์›Œํฌ๋ฅผ ์‹คํ–‰์‹œ์ผœ์ฃผ์„ธ์š”.[๋” ์ž์„ธํžˆ ์•Œ๊ณ  ์‹ถ๋‹ค๋ฉด ์—ฌ๊ธฐ๋ฅผ ํด๋ฆญํ•ด์ฃผ์„ธ์š”!](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/localnet.md#creating--starting-the-localnet). ์˜ค๋Š˜ ๋ชจ๋“  ์ฝ”๋“œ๋Š” ๋กœ์ปฌ ๋„คํŠธ์›Œํฌ์—์„œ ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค. -> ๋งŒ์•ฝ ๋กœ์ปฌ ๋„คํŠธ์›Œํฌ ์—ฐ๊ฒฐ์ด ์•ˆ๋˜๊ฑฐ๋‚˜ ๋ญ”๊ฐ€ ๋ฌธ์ œ๊ฐ€ ์ƒ๊ธฐ๋ฉด `algokit localnet reset` ์ปค๋งจ๋“œ๋กœ ๋กœ์ปฌ๋„คํŠธ์›Œํฌ๋ฅผ ์ง€์šฐ๊ณ  ๋‹ค์‹œ ์ƒ์„ฑํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค. +> If there are issues with your localnet run the following command to reset the localnet. + +```bash +algokit localnet reset +``` + +### Problem 1-4: Instructions + +1. Make sure Python venv is activated in the `coding-assignment` terminal. +2. Go to`coding-assignment/smart_contracts/nft_marketplace/contract.py` to find instructions for problems 1-4. Read the instructions and solve the problem! +3. After solving all 4 problems run the following 2 commands to first build the smart contract and then run the `smart_contracts/nft_marketplace/deploy-config.ts` script. -### 1-4๋ฌธ์ œ: ์Šค๋งˆํŠธ๊ณ„์•ฝ ๋ฌธ์ œ ์ง„ํ–‰ ์„ค๋ช… -1. `coding-assignment` ํ„ฐ๋ฏธ๋„์—์„œ `poetry shell`๋ฅผ ์‹คํ–‰ํ•ด์„œ ํŒŒ์ด์ฌ ๊ฐ€์ƒํ™˜๊ฒฝ์„ ์ผฐ๋Š”์ง€ ํ™•์ธํ•˜์„ธ์š”. -2. `coding-assignment/smart_contract/nft_marketplace/contract.ts`๋กœ ๊ฐ€์‹œ๋ฉด ๋ฌธ์ œ 1-4๊ฐ€ ์ฃผ์„์œผ๋กœ ์ž‘์„ฑ๋˜์–ด์žˆ์Šต๋‹ˆ๋‹ค. - ์„ค๋ช…์„ ์ž์„ธํžˆ ์ฝ๊ณ  ๋ฌธ์ œ๋“ค์„ ํ•ด๊ฒฐํ•˜์„ธ์š”! -3. ๋ฌธ์ œ๋ฅผ ๋‹ค ํ•ด๊ฒฐํ•œ ๋’ค ํ„ฐ๋ฏธ๋„์—์„œ `algokit project run build` ์ปค๋งจ๋“œ๋ฅผ ์‹คํ–‰ํ•ด ์Šค๋งˆํŠธ ๊ณ„์•ฝ์„ ์ปดํŒŒ์ผ ํ•˜์‹œ๊ณ  `algokit project deploy localnet` ์ปค๋งจ๋“œ๋ฅผ ์‹คํ–‰ํ•ด `smart_contracts/nft_marketplace/deploy-config.ts` ํŒŒ์ผ์„ ์‹คํ–‰ํ•˜์„ธ์š”! ```bash algokit project run build ``` @@ -83,12 +121,14 @@ algokit project run build algokit project deploy localnet ``` -์‹คํ–‰ ํ›„ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ฝ˜์†” ๊ฐ’์ด ์ถœ๋ ฅ๋˜๋ฉด ์„ฑ๊ณต์ ์œผ๋กœ ๋ชจ๋“  ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜์‹ ๊ฒ๋‹ˆ๋‹ค! ๐Ÿ‘๐Ÿ‘ -image +> `deploy-config.ts` contains a script written with [AlgoKit Utils TypeScript](https://github.com/algorandfoundation/algokit-utils-ts/tree/main) that goes through the entire lifecycle of the nft marketplace contract by simulating a scenario where Taylor Swift concert ticket is being sold. Feel free to check out the code! +If you see something similar in your console, you have successfully solved all 4 questions! ๐Ÿ‘๐Ÿ‘ Congratulations! +image -## ์ฒดํฌํฌ์ธํŠธ 4: ๐Ÿ’ฏ ๊ณผ์ œ ์ œ์ถœํ•˜๋Š” ๋ฐฉ๋ฒ• +## Checkpoint 4: ๐Ÿ’ฏ How to submit your work -1. ์„ฑ๊ณต์ ์œผ๋กœ ๋‹ค์„ฏ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•œ ํ›„ ๋ณธ์ธ์ด forkํ•œ ๊นƒํ—™ ๋ฆฌํฌ๋กœ ์ฝ”๋“œ๋ฅผ ํ‘ธ์‰ฌํ•ด์ฃผ์„ธ์š”. ๊ทธ๋Ÿฐ ๋‹ค์Œ [์›๋ž˜์˜ ๋ฆฌํฌ๋กœ Pull request๋ฅผ ํ•ด์ฃผ์„ธ์š”.](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork) -2. Pull Request ํ…œํ”Œ๋ ›์„ ๋”ฐ๋ผ ์ถœ๋ ฅ๋œ ๊ฐ’์„ ๋ณด์—ฌ์ฃผ๋Š” ํ„ฐ๋ฏธ๋„์˜ ์Šคํฌ๋ฆฐ์ƒท์„ ์ฒจ๋ถ€ํ•ด์ฃผ์„ธ์š”. +lets submit your code so that the world knows you are now an Algorand Python developer! +1. Push your code to the forked Github repo. [Then create a PR to the original repository.](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork) +2. Follow the Pull Request template and attach the log of your console after running `algokit project deploy localnet` diff --git a/projects/coding-assignment/README.md b/projects/coding-assignment/README.md index 2120d94..82f0521 100644 --- a/projects/coding-assignment/README.md +++ b/projects/coding-assignment/README.md @@ -1,86 +1,117 @@ -# ๐ŸŽ“ ์—ฐ์„ธ๋Œ€ BAY X ์•Œ๊ณ ๋žœ๋“œ ๊ฐœ๋ฐœ์ž ์„ธ์…˜ 05/30/24 +# ๐ŸŽ“ Become an Algorand Python developer! -## ๐Ÿšฉ ํŒŒ์ด์ฌ์œผ๋กœ ์•Œ๊ณ ๋žœ๋“œ์—์„œ NFT ๋งˆ์ผ“ํ”Œ๋ ˆ์ด์Šค๋ฅผ ๋งŒ๋“ค์–ด ๋ณด์ž! +## ๐Ÿšฉ Let's build an NFT marketplace with Algorand Python! -์—ฐ์„ธ๋Œ€ BAY X ์•Œ๊ณ ๋žœ๋“œ ๊ฐœ๋ฐœ์ž ์„ธ์…˜์— ์˜ค์‹  ๋ฒ ์ด ํ•™ํšŒ์›๋ถ„๋“ค ๋ฐ˜๊ฐ‘์Šต๋‹ˆ๋‹ค~! +Welcome to your first step to become a master in Algorand Python! -์•Œ๊ณ ๋žœ๋“œ ๊ฐœ๋ฐœ์ž ๊ธฐ์ดˆ๊ฐœ๋… ๋ฐ ์Šค๋งˆํŠธ ๊ณ„์•ฝ์— ๊ด€ํ•œ ๋ชจ๋“  ๊ฒƒ ๐Ÿ‘‰ [PPT ์Šฌ๋ผ์ด๋“œ](https://docs.google.com/presentation/d/1I-lxxAkNIRoR9VdDX-wRD68hHuxBvI1uPY-VQlmrgiI/edit?usp=sharing) +In this AlgoKit workspace, there are 2 sub projects: -์ด๋ฒˆ ์ฝ”๋”ฉ ์„ธ์…˜์—์„œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ NFT ๋งˆ์ผ“ํ”Œ๋ ˆ์ด์Šค ์Šค๋งˆํŠธ ๊ณ„์•ฝ์„ [์•Œ๊ณ ๋žœ๋“œ ํŒŒ์ด์ฌ](https://algorandfoundation.github.io/puya/index.html)์„ ์‚ฌ์šฉํ•ด์„œ ๊ตฌํ˜„ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. +- `python-demo` +- `coding-assignment` -NftMarketplace ์•ฑ ์„ค๋ช… +You can see a fully implemented personal bank smart contract written in Algorand Python in the `python-demo` project folder. -์ด ๊ฐ„๋‹จํ•œ NftMarketplace ์•ฑ์€ ์—์„ฏ(ASA)๋ฅผ ํŒ๋งคํ•  ์ˆ˜ ์žˆ๋Š” ์Šค๋งˆํŠธ ๊ณ„์•ฝ์ž…๋‹ˆ๋‹ค. +In the `coding-assignment` project folder, we will implement an NFT marketplace smart contract with [Algorand Python](https://algorandfoundation.github.io/puya/index.html) -์ด ์•ฑ์˜ lifecycle์€ ์•„๋ž˜์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค. +NftMarketplace smart contract explained: -1. ์•ฑ ์ƒ์„ฑ์ž(ํŒ๋งค์ž)๊ฐ€ ์•ฑ์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค. -2. ์•ฑ ์ƒ์„ฑ์ž(ํŒ๋งค์ž)๊ฐ€ ์•ฑ์„ ๋ถ€ํŠธ์ŠคํŠธ๋žฉ ๋ฉ”์„œ๋“œ๋ฅผ ํ˜ธ์ถœํ•ด ๋ถ€ํŠธ์ŠคํŠธ๋žฉํ•ฉ๋‹ˆ๋‹ค. ์ด๋•Œ ์•ฑ์€ ํŒ๋งคํ•  ์—์…‹(ASA)์„ ์„ค์ •ํ•˜๊ณ , ๋‹จ๊ฐ€๋ฅผ ์„ค์ •ํ•˜๊ณ , ์•ฑ ๊ณ„์ •์ด ์˜ตํŠธ์ธ์„ ํ•ฉ๋‹ˆ๋‹ค. -3. ๊ตฌ๋งค์ž๊ฐ€ ์•ฑ์—์„œ ํŒ๋งคํ•˜๋Š” ์—์…‹(ASA)์„ buy๋ฉ”์„œ๋“œ๋ฅผ ํ˜ธ์ถœํ•ด ๊ตฌ๋งคํ•ฉ๋‹ˆ๋‹ค. -4. ์•ฑ ์ƒ์„ฑ์ž(ํŒ๋งค์ž)๊ฐ€ withdraw_and_delete ๋ฉ”์„œ๋“œ๋ฅผ ํ˜ธ์ถœํ•ด ์•ฑ ๊ณ„์ •์— ๋‚จ์•„์žˆ๋Š” ์—์…‹(ASA)์„ ์•ฑ ๊ณ„์ •์œผ๋กœ ์ „์†กํ•˜๊ณ , ๋ชจ๋“  ์ˆ˜์ต๊ธˆ์„ ํŒ๋งค์ž ๊ณ„์ •์œผ๋กœ ์†ก๊ธˆํ•œ ๋’ค, ์Šค๋งˆํŠธ ๊ณ„์•ฝ์„ ์‚ญ์ œํ•ฉ๋‹ˆ๋‹ค. +This simple NftMarketplace smart contract let's sellers to list NFTs for sale and let's buyers to buy the NFT. -์ฝ”๋”ฉ ๊ณผ์ œ๋Š” ์ด 4๋ฌธ์ œ๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ์œผ๋ฉฐ ๊ฐ ๋ฌธ์ œ์— "**_ ์—ฌ๊ธฐ์— ์ฝ”๋“œ ์ž‘์„ฑ _**" ๋ถ€๋ถ„์— ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค. ๋ฐ‘์— ์ฒดํฌํฌ์ธํŠธ์„ ์ฐจ๋ก€๋Œ€๋กœ ๋”ฐ๋ผ์„œ ์ง„ํ–‰ํ•ด์ฃผ์„ธ์š”! +lifecycle of this app: -### ๊ฐœ๋ฐœ์ž ๋ฆฌ์†Œ์Šค: +1. The seller deploys the smart contract. +2. The seller calls the bootstrap method to set the asset ID for sale, unitary price, and opt the contract into the ASA. +3. The buyer calls the buy method to buy the ASA. +4. The seller calls the withdraw_and_delete method to withdraw remaining ASA, profits, and then delete the smart contract. -- [์•Œ๊ณ ๋žœ๋“œ ๊ฐœ๋ฐœ์ž ๋ฌธ์„œ](https://developer.algorand.org/docs/) -- [์•Œ๊ณ ๋žœ๋“œ ๋””์Šค์ฝ”๋“œ(๋””๋ฒ„๊น…, ์ฝ”๋“œ ๊ด€๋ จ ์งˆ์˜์‘๋‹ต)](https://discord.com/invite/algorand) -- [์•Œ๊ณ ๋žœ๋“œ ํŒŒ์ด์ฌ ๊ฐœ๋ฐœ์ž ๋ฌธ์„œ](https://algorandfoundation.github.io/puya/) -- [์•Œ๊ณ ๋žœ๋“œ ํŒŒ์ด์ฌ ๊นƒํ—™(์˜ˆ์‹œ ์ฝ”๋“œ, ์†Œ์Šค์ฝ”๋“œ)](https://github.com/algorandfoundation/puya) +The coding assignment consist of 4 questions and for each question you can implement your code where it says `Write code here` + +> Please carefully read and follow the checkpoints below to properly complete the coding assignment! + +### Developer Resources: + +- [Algorand Developer Documentation](https://developer.algorand.org/docs/) +- [Algorand Discord (Get tech support, debugging support here)](https://discord.com/invite/algorand) +- [Algorand Python Documentation](https://algorandfoundation.github.io/puya/) +- [Algorand Python Github Repo (Example code, source code)](https://github.com/algorandfoundation/puya) - [Algokit Utils TypeScript](https://github.com/algorandfoundation/algokit-utils-ts/tree/main) -## ์ฒดํฌํฌ์ธํŠธ 1: ๐Ÿงฐ ์•Œ๊ณ ๋žœ๋“œ ๊ฐœ๋ฐœ์— ํ•„์š”ํ•œ ํˆดํ‚ท ์„ค์น˜ +## Checkpoint 1: ๐Ÿงฐ Install prerequisites -1. [AlgoKit ์„ค์น˜](https://github.com/algorandfoundation/algokit-cli/tree/main?tab=readme-ov-file#install). -2. [Docker ์„ค์น˜](https://www.docker.com/products/docker-desktop/). It is used to run a local Algorand network for development. -3. [Python 3.12 ์ด์ƒ ์„ค์น˜](https://www.python.org/downloads/) -4. [Node.JS / npm ์„ค์น˜](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) +1. [Install Docker](https://www.docker.com/products/docker-desktop/). It is used to run a local Algorand network for development. +2. [Install Python 3.12+](https://www.python.org/downloads/) +3. [Install Node.JS / npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) +4. [Install AlgoKit](https://github.com/algorandfoundation/algokit-cli/tree/main?tab=readme-ov-file#install). -## ์ฒดํฌํฌ์ธํŠธ 2: ๐Ÿ’ป ๊ฐœ๋ฐœ ํ™˜๊ฒฝ ์…‹์—… +## Checkpoint 2: ๐Ÿ’ป Development environment setup -1. [์ด ๋ฆฌํฌ๋ฅผ fork ํ•ด์ฃผ์„ธ์š”.](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo) -2. Forkํ•œ ๋ฆฌํฌ๋ฅผ git clone ํ•ด์ฃผ์„ธ์š”. +1. [Fork this repository.](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo) +2. `git clone` the forked repo. ```bash cd [DIRECTORY_OF_YOUR_CHOICE] git clone [FORKED_REPO_URL] ``` -3. VSCode์—์„œ ์ด ํด๋”๋ฅผ ์—ด๋žŒํ•ด์ฃผ์„ธ์š”. -4. ์—ด๋žŒ ํ›„ `python-decipher2024.code-workspace` ํŒŒ์ผ์„ ์—ด๋žŒ ํ›„ `open workspace` ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ workspace ๋ชจ๋“œ๋ฅผ ์‹คํ–‰์‹œ์ผœ์ฃผ์„ธ์š”. -5. ์ด์ œ VSCode ํ„ฐ๋ฏธ๋„์ด 3๊ฐœ๊ฐ€ ์ž๋™ ์ƒ์„ฑ๋  ๊ฒƒ ์ž…๋‹ˆ๋‹ค: `ROOT` `python-decipher2024` `coding-assignment`. ์ด ์ค‘ `ROOT` VSCode ํ„ฐ๋ฏธ๋„์—์„œ `algokit project bootstrap all` ์ปค๋งจ๋“œ๋ฅผ ์‹คํ–‰์‹œ์ผœ dependencies๋“ค์„ ์„ค์น˜ํ•ด์ฃผ์„ธ์š”. ์ด๋Ÿฌ๋ฉด ๋ชจ๋“  ํ”„๋กœ์ ํŠธ ํด๋”์˜ dependencies๋“ค์ด ์„ค์น˜๋ฉ๋‹ˆ๋‹ค. - > ๋งŒ์•ฝ 3๊ฐœ์˜ ํ„ฐ๋ฏธ๋„์˜ ์ž๋™์œผ๋กœ ์—ด๋ฆฌ์ง€ ์•Š์œผ๋ฉด ์ƒˆ๋กœ์šด ํ„ฐ๋ฏธ๋„์„ + ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ ๋งŒ๋“ค๊ณ  `ROOT`๋ฅผ ์„ ํƒํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค. +1. Open this project in VSCode +2. Open the file named `python-decipher2024.code-workspace` and press the `open workspace` button to activate workspace mode. +3. 3 VSCode terminal will be auto created: `ROOT` `python-demo` `coding-assignment`. Now go to the `ROOT` VSCode terminal and run the following command to install dependencies required for both sub projects: ```bash algokit project bootstrap all ``` -> ๋งŒ์•ฝ `Unhandled PermissionError: [Errno 13] Permission denied: '/Users/$name/.config/algokit'` ์—๋Ÿฌ๊ฐ€ ๋œฌ๋‹ค๋ฉด ์•ž์— sudo๋ฅผ ๋ถ™์—ฌ์„œ `sudo algokit project bootstrap all` ์ปค๋งจ๋“œ๋ฅผ ์‹คํ–‰ํ•˜์„ธ์š”! +> If the 3 terminals don't open automatically, Press the `+` button and select `ROOT` in VSCode. + +> If you get `Unhandled PermissionError: [Errno 13] Permission denied: '/Users/$name/.config/algokit'` error, add `sudo` in the front and run the following command: + +```bash +sudo algokit project bootstrap all +``` + +1. Now go to the `coding-assignment` terminal and run the following command to activate the Python virtual environment: + +```bash +poetry shell +``` + +- To deactivate the Python virtual environment, run `exit` in the terminal. +- After activating the venv, run the following command and if you see various dependencies including `algorand-python`, you successfully activate the virtual environment! -6. ์ด์ œ `coding-assignment` ํ„ฐ๋ฏธ๋„์„ ์„ ํƒํ•œ ๋’ค `poetry shell` ์ปค๋งจ๋“œ๋ฅผ ์‹คํ–‰ํ•ด ํŒŒ์ด์ฌ virtual environment๋ฅผ ํ™œ์„ฑํ™” ์‹œ์ผœ์ฃผ์„ธ์š”. - 1. ํŒŒ์ด์ฌ virtual environment๋ฅผ ๋น„ํ™œ์„ฑํ™” ์‹œํ‚ฌ๋•Œ๋Š” `exit` ์ปค๋งจ๋“œ๋ฅผ ์‹คํ–‰ํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค. - 2. venv๋ฅผ ํ™œ์„ฑํ™” ํ•œ ๋’ค `pip list`๋ฅผ ์‹คํ–‰ํ•ด์„œ `algorand-python` ๋ฐ ์—ฌ๋Ÿฌ dependencies๋“ค์ด ๋‚˜์˜ค๋ฉด ์„ฑ๊ณต์ ์œผ๋กœ ๊ฐ€์ƒํ™˜๊ฒฝ์„ ํ™œ์„ฑํ™” ์‹œํ‚จ๊ฒ๋‹ˆ๋‹ค. +```bash +pip list +``` -๐ŸŽ‰ ์ด์ œ ๋ชจ๋“  ์ค€๋น„๊ฐ€ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค! Good luck coding! ๐Ÿ’ป +๐ŸŽ‰ Now you are ready to crack this assignment! Good luck coding! ๐Ÿ’ป -๋ฆฌํฌ fork, clone ํŠœํ† ๋ฆฌ์–ผ: +Tutorial for forking and cloning this repository: https://github.com/algorand-fix-the-bug-campaign/challenge-1/assets/52557585/acde8053-a8dd-4f53-8bad-45de1068bfda -## ์ฒดํฌํฌ์ธํŠธ 3: ๐Ÿ“ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜์„ธ์š”! +## Checkpoint 3: ๐Ÿ“ Solve the problems! + +This coding assignment consist of **4 problems** in total. Follow the instructions below! + +### Launch localnet + +1. **_Open Docker Desktop first_** and then run the following command in your terminal to launch the local network. [Click me for more information of localnet!](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/localnet.md#creating--starting-the-localnet) + +```bash +algokit localnet start +``` -์ด ์ฝ”๋”ฉ ๊ณผ์ œ๋Š” **์ด 4๋ฌธ์ œ**๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ์•„๋ž˜ ์„ค๋ช…์„ ์ฐจ๋ก€๋Œ€๋กœ ์ฝ๊ณ  ์ง„ํ–‰ํ•ด์ฃผ์„ธ์š”! +All code in this repo will be run in localnet. -### ๋กœ์ปฌ ๋„คํŠธ์›Œํฌ ์‹คํ–‰ +> If there are issues with your localnet run the following command to reset the localnet. -1. ๋„์ปค ๋ฐ์Šคํฌํƒ‘์„ ์‹คํ–‰ํ•œ ๋’ค ํ„ฐ๋ฏธ๋„์—์„œ `algokit localnet start` ์ปค๋งจ๋“œ๋กœ ๋กœ์ปฌ ๋„คํŠธ์›Œํฌ๋ฅผ ์‹คํ–‰์‹œ์ผœ์ฃผ์„ธ์š”.[๋” ์ž์„ธํžˆ ์•Œ๊ณ  ์‹ถ๋‹ค๋ฉด ์—ฌ๊ธฐ๋ฅผ ํด๋ฆญํ•ด์ฃผ์„ธ์š”!](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/localnet.md#creating--starting-the-localnet). ์˜ค๋Š˜ ๋ชจ๋“  ์ฝ”๋“œ๋Š” ๋กœ์ปฌ ๋„คํŠธ์›Œํฌ์—์„œ ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค. - > ๋งŒ์•ฝ ๋กœ์ปฌ ๋„คํŠธ์›Œํฌ ์—ฐ๊ฒฐ์ด ์•ˆ๋˜๊ฑฐ๋‚˜ ๋ญ”๊ฐ€ ๋ฌธ์ œ๊ฐ€ ์ƒ๊ธฐ๋ฉด `algokit localnet reset` ์ปค๋งจ๋“œ๋กœ ๋กœ์ปฌ๋„คํŠธ์›Œํฌ๋ฅผ ์ง€์šฐ๊ณ  ๋‹ค์‹œ ์ƒ์„ฑํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค. +```bash +algokit localnet reset +``` -### 1-4๋ฌธ์ œ: ์Šค๋งˆํŠธ๊ณ„์•ฝ ๋ฌธ์ œ ์ง„ํ–‰ ์„ค๋ช… +### Problem 1-4: Instructions -1. `coding-assignment` ํ„ฐ๋ฏธ๋„์—์„œ `poetry shell`๋ฅผ ์‹คํ–‰ํ•ด์„œ ํŒŒ์ด์ฌ ๊ฐ€์ƒํ™˜๊ฒฝ์„ ์ผฐ๋Š”์ง€ ํ™•์ธํ•˜์„ธ์š”. -2. `coding-assignment/smart_contract/nft_marketplace/contract.ts`๋กœ ๊ฐ€์‹œ๋ฉด ๋ฌธ์ œ 1-4๊ฐ€ ์ฃผ์„์œผ๋กœ ์ž‘์„ฑ๋˜์–ด์žˆ์Šต๋‹ˆ๋‹ค. - ์„ค๋ช…์„ ์ž์„ธํžˆ ์ฝ๊ณ  ๋ฌธ์ œ๋“ค์„ ํ•ด๊ฒฐํ•˜์„ธ์š”! -3. ๋ฌธ์ œ๋ฅผ ๋‹ค ํ•ด๊ฒฐํ•œ ๋’ค ํ„ฐ๋ฏธ๋„์—์„œ `algokit project run build` ์ปค๋งจ๋“œ๋ฅผ ์‹คํ–‰ํ•ด ์Šค๋งˆํŠธ ๊ณ„์•ฝ์„ ์ปดํŒŒ์ผ ํ•˜์‹œ๊ณ  `algokit project deploy localnet` ์ปค๋งจ๋“œ๋ฅผ ์‹คํ–‰ํ•ด `smart_contracts/nft_marketplace/deploy-config.ts` ํŒŒ์ผ์„ ์‹คํ–‰ํ•˜์„ธ์š”! +1. Make sure Python venv is activated in the `coding-assignment` terminal. +2. Go to`coding-assignment/smart_contracts/nft_marketplace/contract.py` to find instructions for problems 1-4. Read the instructions and solve the problem! +3. After solving all 4 problems run the following 2 commands to first build the smart contract and then run the `smart_contracts/nft_marketplace/deploy-config.ts` script. ```bash algokit project run build @@ -90,10 +121,14 @@ algokit project run build algokit project deploy localnet ``` -์‹คํ–‰ ํ›„ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ฝ˜์†” ๊ฐ’์ด ์ถœ๋ ฅ๋˜๋ฉด ์„ฑ๊ณต์ ์œผ๋กœ ๋ชจ๋“  ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜์‹ ๊ฒ๋‹ˆ๋‹ค! ๐Ÿ‘๐Ÿ‘ +> `deploy-config.ts` contains a script written with [AlgoKit Utils TypeScript](https://github.com/algorandfoundation/algokit-utils-ts/tree/main) that goes through the entire lifecycle of the nft marketplace contract by simulating a scenario where Taylor Swift concert ticket is being sold. Feel free to check out the code! + +If you see something similar in your console, you have successfully solved all 4 questions! ๐Ÿ‘๐Ÿ‘ Congratulations! image -## ์ฒดํฌํฌ์ธํŠธ 4: ๐Ÿ’ฏ ๊ณผ์ œ ์ œ์ถœํ•˜๋Š” ๋ฐฉ๋ฒ• +## Checkpoint 4: ๐Ÿ’ฏ How to submit your work + +lets submit your code so that the world knows you are now an Algorand Python developer! -1. ์„ฑ๊ณต์ ์œผ๋กœ ๋‹ค์„ฏ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•œ ํ›„ ๋ณธ์ธ์ด forkํ•œ ๊นƒํ—™ ๋ฆฌํฌ๋กœ ์ฝ”๋“œ๋ฅผ ํ‘ธ์‰ฌํ•ด์ฃผ์„ธ์š”. ๊ทธ๋Ÿฐ ๋‹ค์Œ [์›๋ž˜์˜ ๋ฆฌํฌ๋กœ Pull request๋ฅผ ํ•ด์ฃผ์„ธ์š”.](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork) -2. Pull Request ํ…œํ”Œ๋ ›์„ ๋”ฐ๋ผ ์ถœ๋ ฅ๋œ ๊ฐ’์„ ๋ณด์—ฌ์ฃผ๋Š” ํ„ฐ๋ฏธ๋„์˜ ์Šคํฌ๋ฆฐ์ƒท์„ ์ฒจ๋ถ€ํ•ด์ฃผ์„ธ์š”. +1. Push your code to the forked Github repo. [Then create a PR to the original repository.](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork) +2. Follow the Pull Request template and attach the log of your console after running `algokit project deploy localnet` diff --git a/projects/coding-assignment/smart_contracts/nft_marketplace/deploy-config.ts b/projects/coding-assignment/smart_contracts/nft_marketplace/deploy-config.ts index 07bdef7..c2cebce 100644 --- a/projects/coding-assignment/smart_contracts/nft_marketplace/deploy-config.ts +++ b/projects/coding-assignment/smart_contracts/nft_marketplace/deploy-config.ts @@ -8,13 +8,13 @@ export async function deploy() { console.log('=== Deploying NftMarketplaceClient ===') AlgokitConfig.configure({ populateAppCallResources: true }) - // ์—ฌ๋Ÿฌ ํด๋ผ์ด์–ธํŠธ ์ƒ์„ฑ + // Instantiate clients const algod = algokit.getAlgoClient() const indexer = algokit.getAlgoIndexerClient() const algorand = algokit.AlgorandClient.defaultLocalNet() algorand.setDefaultValidityWindow(1000) - // ๋žœ๋ค ๊ณ„์ • ์ƒ์„ฑ ํ›„ ์ž๊ธˆ ์ง€๊ธ‰ + // Create and fund random accounts for testing const deployer = await algorand.account.random() const buyer = await algorand.account.random() const accounts = [deployer, buyer] @@ -31,7 +31,7 @@ export async function deploy() { ) } - // NftMarketplace ์•ฑ ํด๋ผ์ด์–ธํŠธ ์ƒ์„ฑ + // Create NftMarketplace app client const appClient = new NftMarketplaceClient( { resolveBy: 'creatorAndName', @@ -42,7 +42,7 @@ export async function deploy() { algod, ) - // ํŒ๋งคํ•  ์•„์ด์œ ๋‹˜ ์ฝ˜์„œํŠธ ํ‹ฐ์ผ“ ์—์…‹ ์ƒ์„ฑ (์•„์ด์œ  ์งฑโค๏ธ) + // Create Taylor Swift concert ticket ASA that will be sold. const createResult = await algorand.send.assetCreate( { sender: deployer.addr, @@ -53,15 +53,15 @@ export async function deploy() { { suppressLog: true }, ) - // ์ƒ์„ฑ๋œ ์—์…‹ ID๋ฅผ ์ €์žฅ + // Save created asset ID const assetId = BigInt(createResult.confirmation.assetIndex!) - console.log(`1. IU Concert Ticket ์—์…‹ ์ƒ์„ฑ ์™„๋ฃŒ! ์—์…‹ ์•„์ด๋””: ${assetId}`) + console.log(`1. Taylor Swift concert ticket ASA created! Asset Id: ${assetId}`) - // NftMarketplaceClient ์•ฑ ๋ฐฐํฌ + //Deploy NftMarketplaceClient app let unitaryPrice: number = 1 * 1_000_000 const app = await appClient.create.bare() - // NftMarketplaceClient ์•ฑ์— ๋ฏธ๋‹ˆ๋ฉˆ ๋ฐธ๋Ÿฐ์Šค ์ง€๊ธ‰ + // Fund NftMarketplaceClient to cover minimum balance const mbrPay = await algorand.transactions.payment({ sender: deployer.addr, receiver: app.appAddress, @@ -76,7 +76,7 @@ export async function deploy() { amount: 100n, } - // ์•ฑ์ด ํŒ๋งคํ•  ์ค€๋น„๊ฐ€ ๋˜๋„๋ก Bootstrap ๋ฉ”์„œ๋“œ๋ฅผ ํ˜ธ์ถœ, NftMarketplaceClient ์•ฑ์— ํŒ๋งคํ•  NFT ์—์…‹ ์†ก๊ธˆ + // Call the bootstrap method and then send the Taylor Swift concert ticket ASA to the app. await algorand .newGroup() .addMethodCall({ @@ -88,10 +88,10 @@ export async function deploy() { .addAssetTransfer(sendAssetToSell) .execute() - console.log('2. ์•ฑ ๋ถ€ํŠธ์ŠคํŠธ๋ž˜ํ•‘ ์™„๋ฃŒ!') - console.log('3. IU ํ‹ฐ์ผ“ ์—์…‹ ์•ฑ์œผ๋กœ ์†ก๊ธˆ ์™„๋ฃŒ!') + console.log('2. App bootstrapped!') + console.log('3. Taylor Swift concert ticket transferred to app!') - // ๊ตฌ๋งค์ž ์•ฑ ํด๋ผ์ด์–ธํŠธ ์ƒ์„ฑ. ์ด ์•ฑ ํด๋ผ์ด์–ธํŠธ๋Š” ๊ตฌ๋งค์ž ๊ณ„์ •๊ณผ ์—ฐ๋™๋จ. + // Instantiate buyer app client. This app client is connected to the buyer's account. const buyerAppClient = new NftMarketplaceClient( { resolveBy: 'id', @@ -101,7 +101,7 @@ export async function deploy() { algod, ) - // ๊ตฌ๋งค์ž๊ฐ€ ์—์„ฏ์— ์˜ตํŠธ์ธํ•˜๊ณ  buy ๋ฉ”์„œ๋“œ๋ฅผ ํ˜ธ์ถœํ•˜๋Š” ํ•จ์ˆ˜ + // A function where the buyer opts in to the concert ticket and calls the buy method to buy the ticket. async function buyAsset( appClient: NftMarketplaceClient, buyerName: string, @@ -111,7 +111,7 @@ export async function deploy() { appAddr: string, unitaryPrice: number, ): Promise { - // NftMarketplaceClient buy ๋ฉ”์„œ๋“œ ํ˜ธ์ถœ๋•Œ ๊ตฌ๋งค ๋น„์šฉ ์ง€๋ถˆ๋กœ ์‚ฌ์šฉํ•  ๊ฒฐ์ œ ํŠธ๋žœ์žญ์…˜ ์ƒ์„ฑ + // Create a payment transaction object for paying the NftMarketplace app to purchase the concert ticket const buyNftPay = await algorand.transactions.payment({ sender: buyer.addr, receiver: appAddr, @@ -120,11 +120,11 @@ export async function deploy() { try { let assetInfo = await algorand.account.getAssetInformation(buyer, assetId) - console.log(`${buyerName}๊ฐ€ ์ด๋ฏธ ์—์…‹์— ์˜ตํŠธ์ธ ๋˜์–ด์žˆ์–ด์š”! ํ˜„์žฌ ๋ณด์œ ํ•œ ํ‹ฐ์ผ“ ์ˆ˜: ${assetInfo.balance}๊ฐœ`) + console.log(`${buyerName}is already opted in to the ASA! # of purchased tickets: ${assetInfo.balance}๊ฐœ`) } catch (e) { - console.log(`${buyerName}๊ฐ€ ์—์…‹์— ์˜ตํŠธ์ธ์ด ์•ˆ ๋˜์–ด์žˆ์–ด์š”. ์˜ตํŠธ์ธ ์ง„ํ–‰ํ• ๊ฒŒ์š”~`) + console.log(`${buyerName}is not opted in to the ASA! Opting into the ASA...`) - // buy๋ฉ”์„œ๋“œ ์•ฑ ํ˜ธ์ถœ ํŠธ๋žœ์žญ์…˜ ์ƒ์„ฑ + // Create buy method call transaction object const buyAppCall = await appClient .compose() .buy( @@ -136,7 +136,7 @@ export async function deploy() { ) .atc() - // ๊ตฌ๋งค์ž๊ฐ€ NFT์— ์˜ตํŠธ์ธ, buyNftPay ๊ฒฐ์ œ ํŠธ๋žœ์žญ์…˜, NftMarketplaceClient buy ๋ฉ”์„œ๋“œ๋ฅผ ์–ดํ† ๋ฏน ํŠธ๋žœ์žญ์…˜์œผ๋กœ ๋™์‹œ์— ํ˜ธ์ถœ + // The buyer atomicatlly opts in to the ASA, calls the buy method, and sends the buyNftPay payment transaction. await algorand .newGroup() .addAssetOptIn({ @@ -147,11 +147,13 @@ export async function deploy() { .execute() const assetInfo = await algorand.account.getAssetInformation(buyer, assetId) - console.log(`${buyerName}๊ฐ€ ํ‹ฐ์ผ“ ${buyAmount}์žฅ์„ ๊ตฌ๋งคํ•˜์—ฌ ${assetInfo.balance}๊ฐœ์˜ ํ‹ฐ์ผ“์„ ๋ณด์œ ํ•˜๊ณ  ์žˆ์–ด์š”!`) + console.log( + `${buyerName} purchased ${buyAmount} concert tickets and now holding ${assetInfo.balance} tickets in total!`, + ) return } - // ๊ณ„์ •์ด ์ด๋ฏธ ๊ตฌ๋งคํ•  ์—์…‹(์•„์ด์œ  ์ฝ˜์„œํŠธ ํ‹ฐ์ผ“)์— ์˜ตํŠธ์ธ ๋˜์–ด ์žˆ์„ ์‹œ buy ๋ฉ”์„œ๋“œ๋งŒ ํ˜ธ์ถœ + // If the buyer is already opted in to the ASA, just call the buy method. await appClient.buy( { buyerTxn: buyNftPay, @@ -161,16 +163,18 @@ export async function deploy() { ) const assetInfo = await algorand.account.getAssetInformation(buyer, assetId) - console.log(`${buyerName}๊ฐ€ ํ‹ฐ์ผ“ ${buyAmount}์žฅ์„ ๊ตฌ๋งคํ•˜์—ฌ ${assetInfo.balance}๊ฐœ์˜ ํ‹ฐ์ผ“์„ ๋ณด์œ ํ•˜๊ณ  ์žˆ์–ด์š”!`) + console.log( + `${buyerName} purchased ${buyAmount} concert tickets and now holding ${assetInfo.balance} tickets in total!`, + ) } await buyAsset(buyerAppClient, 'buyer', buyer, assetId, 1, app.appAddress, unitaryPrice) await buyAsset(buyerAppClient, 'buyer', buyer, assetId, 2, app.appAddress, unitaryPrice) - // ํŒ๋งค์ž๊ฐ€ NftMarketplaceClient ์•ฑ์„ ์‚ญ์ œํ•˜๋ฉฐ ์ˆ˜์ต๊ธˆ๊ณผ ์ž”์—ฌ NFT ์—์…‹์„ ํšŒ์ˆ˜ + // The seller withdraw and delete the app. await appClient.delete.withdrawAndDelete( {}, { sendParams: { fee: algokit.transactionFees(3), populateAppCallResources: true } }, ) - console.log('4. IU ํ‹ฐ์ผ“ ํŒ๋งค ์ข…๋ฃŒ ๋ฐ ์ˆ˜์ต๊ธˆ ํšŒ์ˆ˜ ์™„๋ฃŒ!') + console.log('4. Taylor Swift concert ticket sale ends & all proceeds are withdrawn!') } diff --git a/python-decipher2024.code-workspace b/python-decipher2024.code-workspace index d62b938..05b6c2e 100644 --- a/python-decipher2024.code-workspace +++ b/python-decipher2024.code-workspace @@ -18,6 +18,10 @@ "jest.disabledWorkspaceFolders": [ "ROOT", "projects" + ], + "cSpell.words": [ + "algokit", + "Algorand" ] }, "extensions": {