Refactor codes

This commit is contained in:
elegant651
2020-04-04 12:28:37 +09:00
parent dd3033be9c
commit 6c51a302b9
20 changed files with 59 additions and 97 deletions

View File

@@ -1,4 +1,4 @@
# frontend-nftdapp
# frontend-nftbapp
## Project setup
```

View File

@@ -1,5 +1,5 @@
{
"name": "frontend-nftdapp",
"name": "frontend-nftbapp",
"version": "0.1.0",
"private": true,
"scripts": {

View File

@@ -13,7 +13,7 @@
</head>
<body>
<noscript>
<strong>We're sorry but frontend-nftdapp doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
<strong>We're sorry but frontend-nftbapp doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->

View File

@@ -1,7 +1,7 @@
<template>
<v-app>
<v-app-bar app clipped-left dense>
<v-toolbar-title>NFT APP</v-toolbar-title>
<v-toolbar-title>NFT BAPP</v-toolbar-title>
<v-spacer></v-spacer>
<div class="nav">
@@ -26,13 +26,13 @@ import KlaytnService from './klaytn/klaytnService'
export default {
name: 'app',
async mounted () {
async created () {
await this.connect()
},
methods: {
...mapMutations('wallet', [
'setKlaytn',
'setKlaytn',
'setMyAddress'
]),
async connect () {

View File

@@ -38,10 +38,10 @@ import PostAuction from '@/components/PostAuction.vue'
export default {
data() {
return {
file: null,
tokenId: null,
isRegistered: false,
dataURI: null
file: null,
tokenId: null,
isRegistered: false,
dataURI: null
}
},
@@ -80,7 +80,7 @@ export default {
if(!this.file){
alert("Please put the file on input.")
return
}
}
const formData = new FormData()
formData.append('file', this.file)
@@ -104,14 +104,14 @@ export default {
this.klaytn.registerUniqueToken(this.tokenId, this.dataURI, (receipt) => {
alert(`Token registered...! (#${receipt.blockNumber} ,${receipt.transactionHash})`)
this.isRegistered = true
})
})
},
transferToCA() {
transferToCA() {
this.klaytn.transferFrom(this.tokenId, (receipt) => {
alert(`Token transfered to CA...! (#${receipt.blockNumber} ,${receipt.transactionHash})`)
})
}
})
}
}
}

View File

@@ -22,8 +22,8 @@
<v-btn outlined class="btnSubmit" @click="this.handleAddWallet">CONNECT WALLET</v-btn>
</template>
</v-card>
</v-card>
<h2>Transfer</h2>
<v-select v-model="selectedAuction" :items="auctionIds" label="Asset" @change="getAuctionById"></v-select>
<div v-show="selectedAuction">
@@ -75,14 +75,14 @@ import KlaytnService from '@/klaytn/klaytnService'
snackbar: false,
snackbarMsg: '',
klaytn: null,
privateKey: null,
}
},
computed: {
...mapGetters('wallet', [
...mapGetters('wallet', [
'klaytn',
'isConnectWallet',
'myaddress',
'balance'
@@ -90,15 +90,19 @@ import KlaytnService from '@/klaytn/klaytnService'
},
async mounted() {
this.klaytn = new KlaytnService()
await this.klaytn.init()
const klaytn = new KlaytnService()
this.setKlaytn(klaytn)
const address = await klaytn.init()
await this.getWalletInfo()
await this.getMyAuctions()
},
if (address) {
await this.getWalletInfo()
await this.getMyAuctions()
}
},
methods: {
...mapMutations('wallet', [
...mapMutations('wallet', [
'setKlaytn',
'setIsConnectWallet',
'setMyAddress',
'setBalance'
@@ -108,7 +112,7 @@ import KlaytnService from '@/klaytn/klaytnService'
if(this.privateKey) {
await this.klaytn.integrateWallet(this.privateKey)
this.getWalletInfo()
}
}
} catch (e) {
this.snackbarMsg = `private key doesn't match.`
this.snackbar = true
@@ -146,7 +150,7 @@ import KlaytnService from '@/klaytn/klaytnService'
alert(`Auction finalized...! (#${receipt.blockNumber} ,${receipt.transactionHash})`)
}, (error) => {
console.error(error)
})
})
}
}

View File

@@ -44,10 +44,6 @@ export default {
])
},
async mounted() {
},
methods: {
async createAuction() {
if(!this.tokenid) {

View File

@@ -1,8 +1,3 @@
/**
* caver-js library helps making connection with klaytn node.
* You can connect to specific klaytn node by setting 'rpcURL' value.
* default rpcURL is 'https://api.baobab.klaytn.net:8651'.
*/
import Caver from 'caver-js'
const AuctionsABI = require('@/contracts/Auctions.json').abi