TRANCHE EXECUTION WORKS
This commit is contained in:
@@ -3,24 +3,39 @@ import {useStore} from "@/store/store.js";
|
||||
import {onChainChanged} from "@/blockchain/wallet.js";
|
||||
import {ethers} from "ethers";
|
||||
|
||||
export const socket = io(import.meta.env.VITE_WS_URL || undefined, { transports: ["websocket"] })
|
||||
export const socket = io(import.meta.env.VITE_WS_URL || undefined, {transports: ["websocket"]})
|
||||
|
||||
socket.on('connect', ()=>{
|
||||
socket.on('connect', () => {
|
||||
console.log('ws connected')
|
||||
})
|
||||
|
||||
socket.on('disconnect', ()=>{
|
||||
socket.on('disconnect', () => {
|
||||
console.log('ws disconnected')
|
||||
})
|
||||
|
||||
socket.on('welcome', async (data)=>{
|
||||
console.log('welcome',data)
|
||||
socket.on('welcome', async (data) => {
|
||||
console.log('welcome', data)
|
||||
const s = useStore()
|
||||
s.chainInfo = data.chainInfo
|
||||
s.vaultInitCodeHash = data.vaultInitCodeHash
|
||||
const p = new ethers.BrowserProvider(window.ethereum)
|
||||
const network = await p.getNetwork()
|
||||
if( network !== null )
|
||||
if (network !== null)
|
||||
onChainChanged(network.chainId)
|
||||
})
|
||||
|
||||
socket.on('p', async (pool, price) => {
|
||||
const s = useStore()
|
||||
const prices = {}
|
||||
prices[pool] = price
|
||||
s.$patch({poolPrices: prices})
|
||||
})
|
||||
|
||||
socket.on('vb', async (vault, token, balance) => {
|
||||
const s = useStore()
|
||||
const balances = {}
|
||||
balances[vault] = {}
|
||||
balances[vault][token] = balance
|
||||
s.$patch({vaultBalances: balances})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user