From d3d54f4350989b21c2f6a42952cb36d756b8f51f Mon Sep 17 00:00:00 2001 From: sumin7701 <162308788+sumin7701@users.noreply.github.com> Date: Thu, 23 May 2024 21:26:19 +0900 Subject: [PATCH] all missions done --- projects/coding-assignment/src/Home.tsx | 12 ++++++++++-- projects/coding-assignment/src/methods.ts | 19 +++++++++++++------ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/projects/coding-assignment/src/Home.tsx b/projects/coding-assignment/src/Home.tsx index 5c77384..602c5a9 100644 --- a/projects/coding-assignment/src/Home.tsx +++ b/projects/coding-assignment/src/Home.tsx @@ -6,6 +6,7 @@ import algosdk from 'algosdk' import React, { useEffect, useState } from 'react' import ConnectWallet from './components/ConnectWallet' import MethodCall from './components/MethodCall' +import { DigitalMarketplaceClient } from './contracts/DigitalMarketplace' import * as methods from './methods' import { getAlgodConfigFromViteEnvironment } from './utils/network/getAlgoClientConfigs' @@ -83,8 +84,15 @@ const Home: React.FC = () => { */ // 문제 1 시작 - const dmClient = '여기에 코드 작성' - // 문제 1 끝 + const dmClient = new DigitalMarketplaceClient( + { + resolveBy: 'id', + id: appId, + sender: { addr: activeAddress!, signer }, + }, + algorand.client.algod, + ) + //문제 1 끝 const toggleWalletModal = () => { setOpenWalletModal(!openWalletModal) diff --git a/projects/coding-assignment/src/methods.ts b/projects/coding-assignment/src/methods.ts index b62e745..086b966 100644 --- a/projects/coding-assignment/src/methods.ts +++ b/projects/coding-assignment/src/methods.ts @@ -60,7 +60,7 @@ export function create( */ // 문제 2 시작 - const createResult = '여기에 코드 작성' + const createResult = await dmClient.create.bare() // 문제 2 끝 /* @@ -85,10 +85,14 @@ export function create( sender, receiver: createResult.appAddress, amount: algokit.algos(0.1 + 0.1), - extraFee: '여기에 코드 작성', + extraFee: algokit.algos(0.001), }) - ;('여기에 bootstrap 메서드 호출 코드 작성') + await dmClient.bootstrap({ + asset: assetId, + unitaryPrice: unitaryPrice, + mbrPay: mbrTxn, + }) // 문제 3 끝 await algorand.send.assetTransfer({ @@ -130,10 +134,13 @@ export function buy( sender, receiver: appAddress, amount: algokit.microAlgos(Number(quantity * unitaryPrice)), - extraFee: '여기에 코드 작성', + extraFee: algokit.algos(0.001), }) - ;('여기에 buy 메서드 호출 코드 작성') + await dmClient.buy({ + buyerTxn: buyerTxn, + quantity: quantity, + }) // 문제 4 끝 const state = await dmClient.getGlobalState() @@ -173,7 +180,7 @@ export function deleteApp(dmClient: DigitalMarketplaceClient, setAppId: (id: num */ // 문제 5 시작 - '여기에 코드 작성' + await dmClient.delete.withdrawAndDelete({}, { sendParams: { fee: algokit.transactionFees(3) } }) // 문제 5 끝 setAppId(0) }