wallet & account login flow bugfixes; pinned mdi icons 6.9.96 because it's the last version to include a Discord icon

This commit is contained in:
Tim Olson
2023-11-10 20:52:23 -04:00
parent 71a8dd8c18
commit 5aaeb1461d
5 changed files with 28 additions and 27 deletions

View File

@@ -7,14 +7,14 @@ import {vaultAbi} from "@/blockchain/abi.js";
export function onChainChanged(chainId) {
chainId = Number(chainId)
console.log('chain changed', chainId)
const store = useStore()
if( chainId !== store.chainId ) {
console.log('chain changed', chainId)
store.chainId = chainId // touch the chainId last. will cause any clients of the store's provider getter to refresh
store.account = null
const provider = new ethers.BrowserProvider(window.ethereum, chainId);
setProvider(provider, chainId)
store.account = null
provider.listAccounts().then(changeAccounts)
store.chainId = chainId // touch the chainId last. will cause any clients of the store's provider getter to refresh
}
}
@@ -28,18 +28,13 @@ function changeAccounts(accounts) {
}
else {
const store = useStore()
store.account = accounts[0].address
if( pendingOrders.length ) {
if( store.vault )
flushOrders()
else
ensureVault()
}
else
discoverVaults()
store.account = accounts[0]
console.log('set store.account to', accounts[0], store.account)
discoverVaults()
flushTransactions()
socket.emit('address', store.chainId, accounts[0].address)
socket.emit('address', store.chainId, accounts[0])
}
console.log('changeAccounts ended')
}
function onAccountsChanged(accounts) {
@@ -104,10 +99,14 @@ function discoverVaults() {
s.vaults = []
else
_discoverVaults(owner).then((result)=>{
console.log('read store.account', s.account)
if( s.account === owner ) { // double-check the account since it could have changed during our await
s.vaults = result
if( result.length && pendingOrders.length )
flushOrders(result[0])
if( pendingOrders.length )
if( result.length )
flushOrders(result[0])
else
ensureVault()
}
})
}