order placement works, including automatic vault creation

This commit is contained in:
Tim Olson
2023-10-06 19:49:31 -04:00
parent c206607547
commit c637e82ac3
8 changed files with 279 additions and 56 deletions

View File

@@ -1,5 +1,7 @@
import {io} from "socket.io-client";
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"] })
@@ -11,11 +13,14 @@ socket.on('disconnect', ()=>{
console.log('ws disconnected')
})
socket.on('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 )
onChainChanged(network.chainId)
})
socket.on('chainInfo', async (chainInfo)=>{
const s = useStore()
s.chainInfo = chainInfo
})