diff --git a/src/assets/Bank.json b/src/assets/Bank.json new file mode 100644 index 0000000..17d5bcc --- /dev/null +++ b/src/assets/Bank.json @@ -0,0 +1,219 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "SBT_addr", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function", + "constant": true + }, + { + "inputs": [], + "name": "recv", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function", + "constant": true + }, + { + "inputs": [], + "name": "sbt", + "outputs": [ + { + "internalType": "contract SoulboundToken", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function", + "constant": true + }, + { + "stateMutability": "payable", + "type": "receive", + "payable": true + }, + { + "inputs": [ + { + "internalType": "address", + "name": "client", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "setCredit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "number", + "type": "uint256" + } + ], + "name": "register", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "shop", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "pay", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "repay", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function", + "payable": true + }, + { + "inputs": [], + "name": "start_recv", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "stop_recv", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "client", + "type": "address" + } + ], + "name": "getCredit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function", + "constant": true + }, + { + "inputs": [ + { + "internalType": "address", + "name": "client", + "type": "address" + } + ], + "name": "getArrear", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function", + "constant": true + }, + { + "inputs": [ + { + "internalType": "address", + "name": "client", + "type": "address" + } + ], + "name": "getClientOrders", + "outputs": [ + { + "components": [ + { + "internalType": "bool", + "name": "isFinished", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "shop", + "type": "address" + } + ], + "internalType": "struct Order[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function", + "constant": true + } +] \ No newline at end of file diff --git a/src/views/LinkSBTView.vue b/src/views/LinkSBTView.vue index 9b6d850..8b6e92b 100644 --- a/src/views/LinkSBTView.vue +++ b/src/views/LinkSBTView.vue @@ -5,6 +5,7 @@ import SBT from '@/assets/SBT.json' import WarningModal from '../components/WarningModal.vue' import SuccessModal from '../components/SuccessModal.vue' import PageTitle from '../components/PageTitle.vue' +import Bank from '@/assets/Bank.json' import { useClientStore } from '../stores/Client.js' @@ -14,6 +15,7 @@ export default { data() { return { SBTAddress: import.meta.env.VITE_SBT_ADDR, + BankAddress: import.meta.env.VITE_BANK_ADDR, number: 0, warningModalStatus: false, successModalStatus: false, @@ -21,7 +23,8 @@ export default { clientAddr: '', web3: null, token: null, - isWaiting: false + isWaiting: false, + link: '' } }, async mounted() { @@ -29,17 +32,27 @@ export default { this.clientAddr = (await this.web3.eth.getAccounts())[0] this.web3.eth.defaultAccount = this.clientAddr this.token = new this.web3.eth.Contract(SBT, this.SBTAddress) + this.bank = new this.web3.eth.Contract(Bank, this.BankAddress) }, methods: { async check() { + this.isWaiting = true var returnNumber = await this.token.methods.getAccountNumber(this.clientAddr).call() if (returnNumber != 0 && returnNumber == this.number) { - this.successModalStatus = true - this.msg = '驗證成功!' + try { + await this.bank.methods.register(this.number).send({ from: this.clientAddr }) + this.successModalStatus = true + this.link = '/signup/credit' + this.msg = '註冊成功!' + } catch (error) { + this.warningModalStatus = true + this.msg = '註冊失敗,您可能在本銀行已經註冊過了' + } } else { this.warningModalStatus = true this.msg = '連接失敗,這並不是你的 SBT number' } + this.isWaiting = false }, async mint() { this.isWaiting = true @@ -47,6 +60,8 @@ export default { var result = await this.token.methods.mint(this.clientAddr).send({ from: this.clientAddr }) this.successModalStatus = true var returnNumber = await this.token.methods.getAccountNumber(this.clientAddr).call() + this.number = returnNumber + this.link = '/signup/linksbt' this.msg = 'mint 成功! etherscan
您的 SBT number 是 ' + returnNumber } catch (error) { this.warningModalStatus = true @@ -73,7 +88,7 @@ export default {

您已經擁有 SBT

- 請輸入您的 SBT 相關資訊 + 跟銀行註冊您的 SBT 相關資訊
@@ -96,7 +111,12 @@ export default {
- + +
@@ -107,8 +127,7 @@ export default {

您還沒有 SBT

- 向下方 SBT 智能合約地址請求 Mint 一個 Soulbound Token 到你的地址 - + 1. 向下方 SBT 智能合約地址請求 Mint 一個 Soulbound Token 到你的地址
@@ -125,6 +144,32 @@ export default {
+
+
+ 2. 跟銀行註冊您的 SBT 相關資訊 +
+
+
+ +
+ + + + + + + +
+ +
+
+ + +
@@ -134,6 +179,6 @@ export default { - +