complete checkin for juan; config tweaks & mock tweaks
This commit is contained in:
15
.env-mock
Normal file
15
.env-mock
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
DEXORDER_PORT=3001
|
||||||
|
DEXORDER_CORS=http://localhost:3000
|
||||||
|
|
||||||
|
DEXORDER_DB_URL=postgresql://dexorder:redoxed@localhost:5432/dexorder
|
||||||
|
DEXORDER_REDIS_URL=redis://localhost:6379
|
||||||
|
|
||||||
|
# Arbitrum
|
||||||
|
DEXORDER_DEPLOYMENT_42161=latest
|
||||||
|
DEXORDER_RPC_URL_42161=http://localhost:8545
|
||||||
|
|
||||||
|
# Mockchain
|
||||||
|
DEXORDER_DEPLOYMENT_1338=latest
|
||||||
|
DEXORDER_RPC_URL_1338=http://localhost:8545
|
||||||
|
# dev account #2
|
||||||
|
DEXORDER_ACCOUNTS_1338=0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a
|
||||||
19
vault.js
19
vault.js
@@ -14,10 +14,16 @@ const factoryAbi = await getAbi('Factory')
|
|||||||
|
|
||||||
|
|
||||||
export function vaultAddress(chainId, owner, num=0) {
|
export function vaultAddress(chainId, owner, num=0) {
|
||||||
|
try {
|
||||||
const salt = ethers.solidityPackedKeccak256(['address','uint8'],[owner,num])
|
const salt = ethers.solidityPackedKeccak256(['address','uint8'],[owner,num])
|
||||||
const result = ethers.getCreate2Address(chainInfo[chainId].factory, salt, VAULT_INIT_CODE_HASH)
|
const result = ethers.getCreate2Address(chainInfo[chainId].factory, salt, VAULT_INIT_CODE_HASH)
|
||||||
// console.log('vaultAddress', chainId, owner, num, chainInfo[chainId].factory, salt, VAULT_INIT_CODE_HASH, result)
|
// console.log('vaultAddress', chainId, owner, num, chainInfo[chainId].factory, salt, VAULT_INIT_CODE_HASH, result)
|
||||||
return result
|
return result
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
console.error('Could not generate vault address',chainId,owner,num)
|
||||||
|
return null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -44,12 +50,15 @@ export async function loginAddress(socket, chainId, address) {
|
|||||||
|
|
||||||
|
|
||||||
export async function ensureVault(socket, chainId, owner, num) {
|
export async function ensureVault(socket, chainId, owner, num) {
|
||||||
|
console.log('ensureVault', chainId, owner, num)
|
||||||
const address = vaultAddress(chainId, owner, num)
|
const address = vaultAddress(chainId, owner, num)
|
||||||
console.log('ensureVault', chainId, owner, num, address)
|
|
||||||
if (!await vaults.contains(chainId,address)) {
|
if (!await vaults.contains(chainId,address)) {
|
||||||
try {
|
try {
|
||||||
await createVault(chainId, owner, num)
|
const vault = await createVault(chainId, owner, num)
|
||||||
await loginAddress(socket, chainId, owner)
|
console.log(vault)
|
||||||
|
if (vault !== null)
|
||||||
|
socket.emit('vaults', [vault])
|
||||||
|
// await loginAddress(socket, chainId, owner)
|
||||||
} catch {
|
} catch {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -63,8 +72,9 @@ async function createVault(chainId, owner, num) {
|
|||||||
const signer = getSigner(chainId);
|
const signer = getSigner(chainId);
|
||||||
const deployer = new ethers.Contract(chainInfo[chainId].factory, factoryAbi, signer)
|
const deployer = new ethers.Contract(chainInfo[chainId].factory, factoryAbi, signer)
|
||||||
try {
|
try {
|
||||||
const tx = await deployer.deployVault(owner, num)
|
await deployer.deployVault(owner, num)
|
||||||
// console.log(`deploying vault for ${owner} #${num} with tx ${tx.hash}`)
|
// console.log(`deploying vault for ${owner} #${num} with tx ${tx.hash}`)
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
const addr = vaultAddress(chainId, owner, num)
|
const addr = vaultAddress(chainId, owner, num)
|
||||||
@@ -72,6 +82,7 @@ async function createVault(chainId, owner, num) {
|
|||||||
try {
|
try {
|
||||||
const ver = await vault.version()
|
const ver = await vault.version()
|
||||||
console.log(`vault already deployed at ${addr} with version ${ver}`)
|
console.log(`vault already deployed at ${addr} with version ${ver}`)
|
||||||
|
return addr
|
||||||
}
|
}
|
||||||
catch (e2) {
|
catch (e2) {
|
||||||
console.error('could not deploy vault:',e)
|
console.error('could not deploy vault:',e)
|
||||||
|
|||||||
Reference in New Issue
Block a user