@@ -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 () {
diff --git a/nftbapp/frontend-nftbapp/src/components/MyUpload.vue b/nftbapp/frontend-nftbapp/src/components/MyUpload.vue
index f125a28..42642f8 100644
--- a/nftbapp/frontend-nftbapp/src/components/MyUpload.vue
+++ b/nftbapp/frontend-nftbapp/src/components/MyUpload.vue
@@ -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})`)
- })
- }
+ })
+ }
}
}
diff --git a/nftbapp/frontend-nftbapp/src/components/MyWallet.vue b/nftbapp/frontend-nftbapp/src/components/MyWallet.vue
index 5dc3672..091869d 100644
--- a/nftbapp/frontend-nftbapp/src/components/MyWallet.vue
+++ b/nftbapp/frontend-nftbapp/src/components/MyWallet.vue
@@ -22,8 +22,8 @@
@@ -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)
- })
+ })
}
}
diff --git a/nftbapp/frontend-nftbapp/src/components/PostAuction.vue b/nftbapp/frontend-nftbapp/src/components/PostAuction.vue
index ab82c63..4c701fb 100644
--- a/nftbapp/frontend-nftbapp/src/components/PostAuction.vue
+++ b/nftbapp/frontend-nftbapp/src/components/PostAuction.vue
@@ -44,10 +44,6 @@ export default {
])
},
- async mounted() {
-
- },
-
methods: {
async createAuction() {
if(!this.tokenid) {
diff --git a/nftbapp/frontend-nftbapp/src/klaytn/caver.js b/nftbapp/frontend-nftbapp/src/klaytn/caver.js
index 7faa990..5f7faa8 100644
--- a/nftbapp/frontend-nftbapp/src/klaytn/caver.js
+++ b/nftbapp/frontend-nftbapp/src/klaytn/caver.js
@@ -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
diff --git a/numbergame/README.md b/numbergame/README.md
index bdb3d1a..354bd5a 100644
--- a/numbergame/README.md
+++ b/numbergame/README.md
@@ -1,4 +1,4 @@
-# bet-dapp
+# numbergame-bapp
## Project setup
```
diff --git a/numbergame/src/components/betting-component.vue b/numbergame/src/components/betting-component.vue
index 1c1b840..8e6ed32 100644
--- a/numbergame/src/components/betting-component.vue
+++ b/numbergame/src/components/betting-component.vue
@@ -36,9 +36,6 @@ export default {
...mapGetters('wallet', [
'klaytn'
])
- },
-
- mounted () {
},
methods: {
diff --git a/numbergame/src/components/game-bapp.vue b/numbergame/src/components/game-bapp.vue
index d472d27..baa5c78 100644
--- a/numbergame/src/components/game-bapp.vue
+++ b/numbergame/src/components/game-bapp.vue
@@ -50,10 +50,10 @@ export default {
this.setIsConnectWallet(false)
}
},
+
async getBalance () {
if (this.myaddress) {
- const balance = await this.klaytn.getBalance(this.myaddress)
- console.log(this.myaddress, balance)
+ const balance = await this.klaytn.getBalance(this.myaddress)
this.setBalance(balance)
}
},
diff --git a/numbergame/src/components/wallet.vue b/numbergame/src/components/wallet.vue
index cfb0749..2ce01da 100644
--- a/numbergame/src/components/wallet.vue
+++ b/numbergame/src/components/wallet.vue
@@ -46,8 +46,7 @@
import { mapGetters, mapMutations } from 'vuex'
export default {
- data: () => ({
- // accessType: 'keystore',
+ data: () => ({
keystore: null,
password: '',
privateKey: null,
@@ -72,8 +71,7 @@ export default {
const fileReader = new FileReader()
fileReader.onload = (e) => {
try {
- if (!this.checkValidKeystore(e.target.result)) {
- // If key store file is invalid, show message "Invalid keystore file."
+ if (!this.checkValidKeystore(e.target.result)) {
alert('Invalid keystore file.')
return
}
@@ -90,11 +88,9 @@ export default {
async handleAddWallet () {
try {
- // Access type2: access thorugh private key
if(this.privateKey) {
await this.klaytn.integrateWallet(this.privateKey)
} else {
- // Access type1: access through keystore + password
await this.klaytn.loginWithKeystore(this.keystore, this.password)
}
this.getWalletInfo()
diff --git a/numbergame/src/klaytn/caver.js b/numbergame/src/klaytn/caver.js
index 77cb918..5e5f955 100644
--- a/numbergame/src/klaytn/caver.js
+++ b/numbergame/src/klaytn/caver.js
@@ -1,8 +1,4 @@
-/**
- * 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 deployedABI = require('./deployedABI.json')
diff --git a/numbergame/src/klaytn/klaytnService.js b/numbergame/src/klaytn/klaytnService.js
index 4681806..f2c330c 100644
--- a/numbergame/src/klaytn/klaytnService.js
+++ b/numbergame/src/klaytn/klaytnService.js
@@ -6,17 +6,14 @@ export default class KlaytnService {
async init () {
const walletFromSession = sessionStorage.getItem('walletInstance')
-
- // If 'walletInstance' value exists, add it to caver's wallet
+
if (walletFromSession) {
try {
const address = JSON.parse(walletFromSession).address
cav.klay.accounts.wallet.add(JSON.parse(walletFromSession))
return address
- } catch (e) {
- // If value in sessionStorage is invalid wallet instance,
- // remove it from sessionStorage.
+ } catch (e) {
sessionStorage.removeItem('walletInstance')
return false
}
diff --git a/todofeed/backend-todofeed/contracts/TodoFeed.sol b/todofeed/backend-todofeed/contracts/TodoFeed.sol
index 4fbaee0..e52e8ad 100644
--- a/todofeed/backend-todofeed/contracts/TodoFeed.sol
+++ b/todofeed/backend-todofeed/contracts/TodoFeed.sol
@@ -8,13 +8,13 @@ contract TodoFeed {
mapping(uint256 => TodoData) public todoMap;
struct TodoData {
- uint256 todoId; // Unique token id
+ uint256 todoId;
address owner;
string title;
- bytes photo; // Image source encoded in uint 8 array format
- uint256 timestamp; // Uploaded time
- bool isVerified; // check if is verified, default false.
- address verifier; // verifier address
+ bytes photo;
+ uint256 timestamp;
+ bool isVerified;
+ address verifier;
}
function writeTodo(string title, bytes photo) public {
@@ -54,7 +54,7 @@ contract TodoFeed {
todoMap[todoId].todoId,
todoMap[todoId].owner,
todoMap[todoId].title,
- todoMap[todoId].photo,
+ todoMap[todoId].photo,
todoMap[todoId].timestamp,
todoMap[todoId].isVerified,
todoMap[todoId].verifier);
diff --git a/todofeed/front-todofeed/src/App.vue b/todofeed/front-todofeed/src/App.vue
index ee69307..2df380f 100644
--- a/todofeed/front-todofeed/src/App.vue
+++ b/todofeed/front-todofeed/src/App.vue
@@ -97,7 +97,7 @@ export default {
async mounted () {
await this.connect()
- await this.getFeeds()
+ this.getFeeds()
},
methods: {
@@ -144,8 +144,7 @@ export default {
this.snackbarMsg = msg
this.snackbar = true
- this.getFeeds()
- this.getBalance()
+ this.getFeeds()
this.showWriteBox = false
},
@@ -155,8 +154,7 @@ export default {
this.snackbarMsg = `Complete.. blocknumber: #${receipt.blockNumber} , ${receipt.transactionHash}`
this.snackbar = true
- this.getFeeds()
- this.getBalance()
+ this.getFeeds()
})
},
@@ -164,6 +162,8 @@ export default {
this.klaytn.getFeeds((feed) => {
this.setTodos(feed)
})
+
+ this.getBalance()
}
}
}
diff --git a/todofeed/front-todofeed/src/components/LoginBox.vue b/todofeed/front-todofeed/src/components/LoginBox.vue
index 30ed3c8..2df4de8 100644
--- a/todofeed/front-todofeed/src/components/LoginBox.vue
+++ b/todofeed/front-todofeed/src/components/LoginBox.vue
@@ -8,7 +8,7 @@
Integrated
{{walletInstance.address}}
- REMOVE WALLEt
+ REMOVE WALLET
@@ -64,8 +64,7 @@ export default {
data: () => ({
snackbar: false,
errorTxt: '',
-
- // accessType: 'keystore',
+
keystore: null,
password: '',
privateKey: null,
@@ -81,11 +80,7 @@ export default {
'setIsConnectWallet',
'setMyAddress',
'setBalance'
- ]),
-
- validate () {
-
- },
+ ]),
handleImport (e) {
const keystore = e.target.files[0]
@@ -93,8 +88,7 @@ export default {
const fileReader = new FileReader()
fileReader.onload = (e) => {
try {
- if (!this.checkValidKeystore(e.target.result)) {
- // If key store file is invalid, show message "Invalid keystore file."
+ if (!this.checkValidKeystore(e.target.result)) {
this.errorTxt = 'Invalid keystore file.'
this.snackbar = true
return
@@ -112,12 +106,10 @@ export default {
},
async handleAddWallet () {
- try {
- // Access type2: access thorugh private key
+ try {
if(this.privateKey) {
await this.klaytn.integrateWallet(this.privateKey)
- } else {
- // Access type1: access through keystore + password
+ } else {
await this.klaytn.loginWithKeystore(this.keystore, this.password)
}
this.getWalletInfo()
diff --git a/todofeed/front-todofeed/src/components/WriteBox.vue b/todofeed/front-todofeed/src/components/WriteBox.vue
index ee2f955..4fd59ee 100644
--- a/todofeed/front-todofeed/src/components/WriteBox.vue
+++ b/todofeed/front-todofeed/src/components/WriteBox.vue
@@ -85,8 +85,6 @@ export default {
try {
this.isLoading = true
await this.klaytn.writeTodo(this.title, this.imgFile, (receipt) => {
- console.log(receipt)
-
const snackbarMsg = `Complete.. blocknumber: #${receipt.blockNumber} , ${receipt.transactionHash}`
this.$emit('success-write', snackbarMsg)
@@ -99,7 +97,6 @@ export default {
})
} catch (e) {
console.error(e)
-
this.isLoading = false
}
}
diff --git a/todofeed/front-todofeed/src/klaytn/caver.js b/todofeed/front-todofeed/src/klaytn/caver.js
index cc47621..a4573a7 100644
--- a/todofeed/front-todofeed/src/klaytn/caver.js
+++ b/todofeed/front-todofeed/src/klaytn/caver.js
@@ -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 deployedABI = require('./deployedABI.json')
diff --git a/todofeed/front-todofeed/src/klaytn/klaytnService.js b/todofeed/front-todofeed/src/klaytn/klaytnService.js
index a843194..adc40e6 100644
--- a/todofeed/front-todofeed/src/klaytn/klaytnService.js
+++ b/todofeed/front-todofeed/src/klaytn/klaytnService.js
@@ -6,17 +6,14 @@ export default class KlaytnService {
async init () {
const walletFromSession = sessionStorage.getItem('walletInstance')
-
- // If 'walletInstance' value exists, add it to caver's wallet
+
if (walletFromSession) {
try {
const address = JSON.parse(walletFromSession).address
cav.klay.accounts.wallet.add(JSON.parse(walletFromSession))
return address
- } catch (e) {
- // If value in sessionStorage is invalid wallet instance,
- // remove it from sessionStorage.
+ } catch (e) {
sessionStorage.removeItem('walletInstance')
return false
}