Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add reproduction of disconnect bug #27

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"lint": "vue-cli-service lint"
},
"dependencies": {
"@aeternity/aepp-sdk": "^13.0.0",
"@aeternity/aepp-sdk": "^13.2.2",
"core-js": "^3.29.1",
"vue": "^3.2.47",
"vue-router": "^4.1.6"
Expand Down
30 changes: 17 additions & 13 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
<template>
<div id="container">
<img alt="Aeternity" src="./assets/logo.svg" style="width: 250px" />
<h1>Welcome To Aeternity</h1>
<div id="nav">
<router-link to="/">Home</router-link> |
<router-link to="/about">About</router-link>
</div>
<div id="container">
<img alt="Aeternity" src="./assets/logo.svg" style="width: 250px"/>
<h1>Welcome To Aeternity</h1>
<div id="nav">
<router-link to="/">Home</router-link>
<router-link to="/about">About</router-link>
</div>
<button @click="init()">Init Manually</button>
</div>

<router-view />
<router-view/>
</template>

<script>
import { defineComponent, onMounted } from 'vue'
import { defineComponent, } from 'vue'
import { initWallet } from './utils/aeternity/wallet'

export default defineComponent({
name: 'App',

setup () {
onMounted(async () => {
setup() {
async function init() {
await initWallet()
})
}

return {
init
}
}
})
</script>
Expand Down
6 changes: 3 additions & 3 deletions src/components/WalletInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@

<template v-if="status === 'connected'">
<template v-if="walletInfo">
<strong>Provider :: </strong> {{ walletInfo.name }}
<strong>Provider :: </strong> {{ walletInfo?.name }}
<br/>
</template>
<strong>Network ID :: </strong> {{ networkId }}
<br/>
<strong>Address :: </strong> <span class="wallet-address">{{ aeSdk.address }}</span>
<strong>Address :: </strong> <span class="wallet-address">{{ aeSdk?.address }}</span>
<br/>
<strong>Balance :: </strong> {{ balance }} AE
</template>

<button @click="disconnect()">Disconnect</button>
<img
v-if="!['connected', 'failed'].includes(status.split(/\W/)[0])"
src="../assets/loading_logo.svg"
Expand Down
16 changes: 15 additions & 1 deletion src/utils/aeternity/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,24 @@ import {

import { reactive, toRefs, shallowReactive } from 'vue'


const disconnect = () => {
const { aeSdk } = toRefs(state)
aeSdk.value.disconnectWallet()
}


export const state = reactive({
walletInfo: null,
aeSdk: null,
balance: null,
status: 'connecting',
networkId: process.env.VUE_APP_NETWORK_ID,
disconnect
})

export const initWallet = async () => {
const { status, aeSdk } = toRefs(state)
const { status, aeSdk, balance, walletInfo } = toRefs(state)

try {
const aeSdkOptions = {
Expand Down Expand Up @@ -54,6 +62,12 @@ export const initWallet = async () => {
console.info('onAddressChange ::', addresses)
await fetchAccountInfo()
},
onDisconnect() {
aeSdk.value = null
walletInfo.value = null
balance.value = null
status.value = 'disconnected'
}
}))
await scanForWallets()
}
Expand Down
Loading