Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
Expand All @@ -79,7 +79,7 @@ export async function deploy() {
depositAmt: number,
): Promise<void> {
// 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),
Expand All @@ -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} 출금 전 ===`)

Expand Down
15 changes: 13 additions & 2 deletions projects/coding-assignment/src/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -83,13 +84,23 @@ const Home: React.FC<HomeProps> = () => {
*/

// 문제 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 (
<div className="hero min-h-screen bg-teal-400">
<div className="hero-content text-center rounded-lg p-6 max-w-md bg-white mx-auto">
Expand Down
13 changes: 7 additions & 6 deletions projects/coding-assignment/src/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export function create(
*/

// 문제 2 시작
const createResult = '여기에 코드 작성'
const createResult = await dmClient.create.bare()

// 문제 2 끝

/*
Expand All @@ -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({
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
}
Expand Down