fix: add register() call in the sign up flow
This commit is contained in:
parent
13b28e315b
commit
49009af8e3
219
src/assets/Bank.json
Normal file
219
src/assets/Bank.json
Normal file
@ -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
|
||||
}
|
||||
]
|
||||
@ -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) {
|
||||
try {
|
||||
await this.bank.methods.register(this.number).send({ from: this.clientAddr })
|
||||
this.successModalStatus = true
|
||||
this.msg = '驗證成功!'
|
||||
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 成功! <a href="https://sepolia.etherscan.io/tx/' + result.transactionHash + '">etherscan</a><br>您的 SBT number 是 ' + returnNumber
|
||||
} catch (error) {
|
||||
this.warningModalStatus = true
|
||||
@ -73,7 +88,7 @@ export default {
|
||||
<h1 class="title is-4">您已經擁有 SBT</h1>
|
||||
</div>
|
||||
<div class="block">
|
||||
請輸入您的 SBT 相關資訊
|
||||
跟銀行註冊您的 SBT 相關資訊
|
||||
</div>
|
||||
<div class="block">
|
||||
<div class="field">
|
||||
@ -96,7 +111,12 @@ export default {
|
||||
<!-- <p class="help is-success">This username is available</p> -->
|
||||
</div>
|
||||
<div class="column is-2 is-offset-5">
|
||||
<button class="button is-info is-outlined" @click="check">驗證</button>
|
||||
<template v-if="!isWaiting">
|
||||
<button class="button is-info is-outlined" @click="check">註冊</button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<button class="button is-info is-outlined is-loading"></button>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -107,8 +127,7 @@ export default {
|
||||
<h1 class="title is-4">您還沒有 SBT</h1>
|
||||
</div>
|
||||
<div class="block">
|
||||
向下方 SBT 智能合約地址請求 Mint 一個 Soulbound Token 到你的地址
|
||||
|
||||
1. 向下方 SBT 智能合約地址請求 Mint 一個 Soulbound Token 到你的地址
|
||||
</div>
|
||||
<div class="block">
|
||||
<div class="field">
|
||||
@ -125,6 +144,32 @@ export default {
|
||||
<button class="button is-info is-outlined is-loading"></button>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
<div class="block">
|
||||
2. 跟銀行註冊您的 SBT 相關資訊
|
||||
</div>
|
||||
<div class="block">
|
||||
<div class="field">
|
||||
<label class="label">Username</label>
|
||||
<div class="control has-icons-left has-icons-right">
|
||||
<input class="input is-info is-rounded" type="number" placeholder="Token number" v-model="number">
|
||||
<span class="icon is-small is-left">
|
||||
<i class="fas fa-user"></i>
|
||||
</span>
|
||||
<span class="icon is-small is-right">
|
||||
<!-- <i class="fas fa-check"></i> -->
|
||||
</span>
|
||||
</div>
|
||||
<!-- <p class="help is-success">This username is available</p> -->
|
||||
</div>
|
||||
<div class="column is-2 is-offset-5">
|
||||
<template v-if="!isWaiting">
|
||||
<button class="button is-info is-outlined" @click="check">註冊</button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<button class="button is-info is-outlined is-loading"></button>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@ -134,6 +179,6 @@ export default {
|
||||
</div>
|
||||
</section>
|
||||
<WarningModal :active="warningModalStatus" :errorMsg="msg" @closeModal="warningModalStatus = false"></WarningModal>
|
||||
<SuccessModal :active="successModalStatus" :successMsg="msg" @closeModal="successModalStatus = false"
|
||||
link="/signup/credit" btnName="繼續"></SuccessModal>
|
||||
<SuccessModal :active="successModalStatus" :successMsg="msg" @closeModal="successModalStatus = false" :link="link"
|
||||
btnName="繼續"></SuccessModal>
|
||||
</template>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user