order placement working

This commit is contained in:
Tim Olson
2023-10-08 01:11:53 -04:00
parent c637e82ac3
commit 24ce025619
3 changed files with 14 additions and 15 deletions

View File

@@ -53,6 +53,6 @@ export const vaultAbi = [
'function withdrawTo(address payable,uint256) public',
'function withdraw(address,uint256) public',
'function withdrawTo(address,address,uint256) public',
`function placeOrder(${SwapOrder}) public`,
`function placeOrders(${SwapOrder}[],uint8) public`,
'function placeOrder((address,address,(uint8,uint24),uint256,bool,bool,uint64,(uint64,(uint8,bytes)[])[])) public',
'function placeOrders((address,address,(uint8,uint24),uint256,bool,bool,uint64,(uint64,(uint8,bytes)[])[])[],uint8) public',
]

View File

@@ -4,16 +4,10 @@ import {useStore} from "@/store/store.js";
import {provider} from "@/blockchain/wallet.js";
export function vaultAddress( owner, num ) {
export function vaultAddress( owner, num=0) {
const s = useStore()
if( s.vaultInitCodeHash === null || s.factory === null )
return null
const abiCoder = ethers.AbiCoder.defaultAbiCoder();
console.log('vaultAddress owner', owner)
const salt = ethers.keccak256(abiCoder.encode(['address','uint8'],[owner,num]))
const result = ethers.getCreate2Address(s.factory, salt, s.vaultInitCodeHash)
console.log('vaultAddress', result, s.factory, salt, s.vaultInitCodeHash)
return result
const salt = ethers.solidityPackedKeccak256(['address','uint8'],[owner,num])
return ethers.getCreate2Address(s.factory, salt, s.vaultInitCodeHash)
}

View File

@@ -9,10 +9,15 @@ export function onChainChanged(chainId) {
chainId = Number(chainId)
// console.log('chain changed', chainId)
const store = useStore()
store.chainId = chainId
store.account = null
provider = new ethers.BrowserProvider(window.ethereum, chainId)
provider.listAccounts().then(onAccountsChanged)
if( chainId !== store.chainId ) {
store.chainId = chainId
store.account = null
provider = new ethers.BrowserProvider(window.ethereum, chainId)
provider.listAccounts().then(onAccountsChanged)
new ethers.Interface([
// 'event DexorderSwapCreated' // todo
])
}
}
function onAccountsChanged(accounts) {