Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

이승은 #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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 @@ -43,7 +43,7 @@ def withdraw(self) -> UInt64:
receiver=Txn.sender,
sender=Global.current_application_address,
amount=userBalance,
fee=0,
fee=0, #여기서는 0으로 하고 호출자가 낼 수 있게 로직을 설정해주기.
).submit()

return userBalance
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export async function deploy() {
const algorand = algokit.AlgorandClient.defaultLocalNet()

// 랜덤 계정 생성 후 자금 지급
const deployer = await algorand.account.random()
const deployer = await algorand.account.random() //은행 계정
const user = await algorand.account.random()
const user2 = await algorand.account.random()
const accounts = [deployer, user, user2]
Expand All @@ -32,7 +32,7 @@ export async function deploy() {
//1. Deployer의 Personal Bank 앱 클라이언트 생성
const appClient = new PersonalBankClient(
{
resolveBy: 'creatorAndName',
resolveBy: 'creatorAndName', //배포자의 계정 주소랑 이름으로 찾음.
findExistingUsing: indexer,
sender: deployer,
creatorAddress: deployer.addr,
Expand Down Expand Up @@ -96,8 +96,9 @@ export async function deploy() {
첫번째 전달값으로 넣어주면 자동으로 어토믹 그룹으로 묶어줍니다.

*/
// compose를 하면 줄줄이 소시지로 연결 가능
await appClient.compose().optIn.optInToApp({}).deposit({ ptxn: depositTxn }).execute({ suppressLog: true })

// suppress log = True를 하면 로그가 뜨는 걸 막을 수 있음.
console.log(`=== ${userName} 출금 전 ===`)

let appInfo = await algorand.account.getInformation(app.appAddress)
Expand All @@ -118,7 +119,7 @@ export async function deploy() {
userName: string,
user: TransactionSignerAccount,
): Promise<void> {
await appClient.closeOut.withdraw({}, { sendParams: { fee: algokit.transactionFees(2) } })
await appClient.closeOut.withdraw({}, { sendParams: { fee: algokit.transactionFees(2) } }) //여기서 fee 설정

console.log(`=== ${userName} 출금 후 ===`)
const appInfo = await algorand.account.getInformation(app.appAddress)
Expand Down
11 changes: 9 additions & 2 deletions projects/coding-assignment/src/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ 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'

interface HomeProps {}

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

// 문제 1 시작
const dmClient = '여기에 코드 작성'
const dmClient = new DigitalMarketplaceClient(
{
resolveBy: 'id',
id: appId,
sender: { addr: activeAddress!, signer },
},
algorand.client.algod,
)
// 문제 1 끝

const toggleWalletModal = () => {
Expand Down
17 changes: 11 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,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({
Expand Down Expand Up @@ -130,10 +135,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 +178,7 @@ export function deleteApp(dmClient: DigitalMarketplaceClient, setAppId: (id: num
*/

// 문제 5 시작
'여기에 코드 작성'
await dmClient.delete.withdrawAndDelete({}, { sendParams: { fee: algokit.transactionFees(3) } })
// 문제 5 끝
setAppId(0)
}
Expand Down