From 6afd4ea5160ab7ca43c9f4c71f22c5316158a1dc Mon Sep 17 00:00:00 2001 From: yumzen Date: Thu, 23 May 2024 21:29:28 +0900 Subject: [PATCH] =?UTF-8?q?=EC=95=8C=EA=B3=A0=EB=9E=9C=EB=93=9C=204?= =?UTF-8?q?=EC=A3=BC=EC=B0=A8=20=EC=8B=A4=EC=8A=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- projects/coding-assignment/src/Home.tsx | 13 +++++++++++-- projects/coding-assignment/src/methods.ts | 12 ++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/projects/coding-assignment/src/Home.tsx b/projects/coding-assignment/src/Home.tsx index 5c77384..cb802dc 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' @@ -13,7 +14,6 @@ interface HomeProps {} const Home: React.FC = () => { AlgokitConfig.configure({ populateAppCallResources: true }) - const [openWalletModal, setOpenWalletModal] = useState(false) const [appId, setAppId] = useState(0) const [assetId, setAssetId] = useState(0n) @@ -83,7 +83,16 @@ const Home: React.FC = () => { */ // 문제 1 시작 - const dmClient = '여기에 코드 작성' + const dmClient = new DigitalMarketplaceClient( + { + resolveBy: 'id', + id: appId, + sender: { addr: activeAddress!, signer }, + name: 'AlternativeName', + }, + algorand.client.algod, + ) + // 문제 1 끝 const toggleWalletModal = () => { diff --git a/projects/coding-assignment/src/methods.ts b/projects/coding-assignment/src/methods.ts index b62e745..5e097e4 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,10 @@ 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 +130,10 @@ 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 +173,7 @@ export function deleteApp(dmClient: DigitalMarketplaceClient, setAppId: (id: num */ // 문제 5 시작 - '여기에 코드 작성' + dmClient.delete.withdrawAndDelete({}, { sendParams: { fee: algokit.algos(0.003) } }) // 문제 5 끝 setAppId(0) }