Skip to content

Commit 4f9d3c3

Browse files
committed
fix(example DApp): fix the problem of example DApp
1 parent 43352e3 commit 4f9d3c3

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

example/basic-dapp/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
<header>
4848
Connect
4949
</header>
50-
<button id="connect" disabled="true">Connect
50+
<button id="connect">Connect
5151
Wallet
5252
</button>
5353
<button id="Deauthorize" disabled="true">

example/basic-dapp/index.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,7 @@ async function walletInitialized() {
562562
// connect
563563
const connectButton = getElement('connect')
564564
const DeauthorizeButton = getElement('Deauthorize')
565+
const logoutButton = getElement('Logout')
565566
const sendNativeTokenButton = getElement('send_native_token')
566567
const approveButton = getElement('approve')
567568
const transferFromButton = getElement('transfer_from')
@@ -575,6 +576,7 @@ async function walletInitialized() {
575576
const transferToAccountInput = getElement('to-account')
576577
const importAddressInput = getElement('import_address_input')
577578
const importAddressNameInput = getElement('import_address_name_input')
579+
const identifyButton = getElement('identify_button')
578580

579581
const deployContract = getElement('deploy_contract')
580582

@@ -595,7 +597,9 @@ async function walletInitialized() {
595597
gatewayTestButton.disabled = false
596598
connectButton.disabled = true
597599
DeauthorizeButton.disabled = false
600+
logoutButton.disabled = false
598601
importAddressButton.disabled = false
602+
identifyButton.disabled = false
599603
}
600604

601605
function unAuthed() {
@@ -610,7 +614,9 @@ async function walletInitialized() {
610614
deployContract.disabled = true
611615
connectButton.disabled = false
612616
DeauthorizeButton.disabled = true
617+
logoutButton.disabled = true
613618
importAddressButton.disabled = true
619+
identifyButton.disabled = true
614620
}
615621

616622
provider.on('accountsChanged', (accounts) => {
@@ -709,6 +715,14 @@ async function walletInitialized() {
709715
.then(unAuthed)
710716
.catch(console.error)
711717
}
718+
logoutButton.onclick = () => {
719+
provider
720+
.request({
721+
method: 'anyweb_logout',
722+
})
723+
.then(unAuthed)
724+
.catch(console.error)
725+
}
712726

713727
// send native token to the connected address
714728
sendNativeTokenButton.onclick = async () => {
@@ -887,6 +901,19 @@ async function walletInitialized() {
887901
console.log('err', err)
888902
}
889903
}
904+
905+
identifyButton.onclick = async () => {
906+
try {
907+
provider
908+
.request({ method: 'anyweb_identify', params: [] })
909+
.then((result) => {
910+
getElement('identify_result').innerHTML = result
911+
console.log('result', result)
912+
})
913+
} catch (err) {
914+
console.log('err', err)
915+
}
916+
}
890917
}
891918

892919
window.addEventListener('load', async () => {

0 commit comments

Comments
 (0)