diff --git a/projects/blockchain-valley-session-4/smart_contracts/personal_bank/deploy-config.ts b/projects/blockchain-valley-session-4/smart_contracts/personal_bank/deploy-config.ts index feaa45a..9ad8855 100644 --- a/projects/blockchain-valley-session-4/smart_contracts/personal_bank/deploy-config.ts +++ b/projects/blockchain-valley-session-4/smart_contracts/personal_bank/deploy-config.ts @@ -41,7 +41,7 @@ export async function deploy() { ) // 2. Personal Bank 앱을 배포 - const app = await appClient.create.bare() + const app = await appClient.create.bare() // 오버라이딩 전 함수를 배포 // 3. 앱 미니멈 밸런스 0.1알고를 송금 (https://developer.algorand.org/docs/get-details/dapps/smart-contracts/apps/?from_query=minimum#minimum-balance-requirement-for-a-smart-contract) await algorand.send.payment( @@ -54,10 +54,10 @@ export async function deploy() { ) // User1 User2의 앱 클라이언트를 생성 - const user1AppClient = new PersonalBankClient( + const user1AppClient = new PersonalBankClient( { resolveBy: 'id', - id: app.appId, + id: app.appId, //앱을 배포했을 때의 app 변수 sender: user, }, algod, @@ -79,7 +79,7 @@ export async function deploy() { depositAmt: number, ): Promise { // User가 Personal Bank에 5 알고를 입금하는 payment 트랜잭션 생성 - const depositTxn = await algorand.transactions.payment({ + const depositTxn = await algorand.transactions.payment({ //send가 아니라 transaction sender: user.addr, receiver: app.appAddress, amount: algokit.algos(depositAmt), @@ -96,7 +96,7 @@ export async function deploy() { 첫번째 전달값으로 넣어주면 자동으로 어토믹 그룹으로 묶어줍니다. */ - await appClient.compose().optIn.optInToApp({}).deposit({ ptxn: depositTxn }).execute({ suppressLog: true }) + await appClient.compose().optIn.optInToApp({}).deposit({ ptxn: depositTxn }).execute({ suppressLog: true }) //그룹을 만드는 것 (compose) console.log(`=== ${userName} 출금 전 ===`) diff --git a/projects/coding-assignment/src/Home.tsx b/projects/coding-assignment/src/Home.tsx index 5c77384..4d6da33 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,13 +84,23 @@ const Home: React.FC = () => { */ // 문제 1 시작 - const dmClient = '여기에 코드 작성' - // 문제 1 끝 const toggleWalletModal = () => { setOpenWalletModal(!openWalletModal) } + const dmClient = new DigitalMarketplaceClient( + { + resolveBy: 'id', + // The unique id of an already deployed smart contract, or 0 if the smart contract has not been deployed + id: appId, + // Optionally specify a default sender for all calls made from the client + sender: { addr: activeAddress!, signer }, + }, + // An algod client is required to make the underlying calls to the network + algorand.client.algod, + ) + return (
diff --git a/projects/coding-assignment/src/methods.ts b/projects/coding-assignment/src/methods.ts index b62e745..b881e92 100644 --- a/projects/coding-assignment/src/methods.ts +++ b/projects/coding-assignment/src/methods.ts @@ -60,7 +60,8 @@ export function create( */ // 문제 2 시작 - const createResult = '여기에 코드 작성' + const createResult = await dmClient.create.bare() + // 문제 2 끝 /* @@ -85,10 +86,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 +131,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 +174,7 @@ export function deleteApp(dmClient: DigitalMarketplaceClient, setAppId: (id: num */ // 문제 5 시작 - '여기에 코드 작성' + await dmClient.delete.withdrawAndDelete({}, { sendParams: { fee: algokit.algos(0.003) } }) // 문제 5 끝 setAppId(0) }