TRANCHE EXECUTION WORKS

This commit is contained in:
Tim Olson
2023-10-29 16:53:07 -04:00
parent 180d4e0441
commit 3bf6cab98e
13 changed files with 109 additions and 27 deletions

View File

@@ -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})
})