-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
consolidate deploy confirms; delegates report; consistent swapERC20Co…
…ntract (#1334) * consolidate deploy confirms; add delegates report; consistent swapERC20Contract * update delegate test with swapERC20Contract * prettify delegate test * deploy confirm formatting
- Loading branch information
Showing
15 changed files
with
163 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
require('dotenv').config({ path: './.env' }) | ||
const { ethers } = require('ethers') | ||
const { mainnets, chainNames, apiUrls } = require('@airswap/utils') | ||
const swapERC20Deploys = require('@airswap/swap-erc20/deploys.js') | ||
|
||
async function main() { | ||
console.log() | ||
for (const chainId of mainnets) { | ||
const apiUrl = apiUrls[chainId] | ||
const provider = new ethers.providers.JsonRpcProvider(apiUrl) | ||
const deployer = new ethers.Wallet(process.env.PRIVATE_KEY, provider) | ||
|
||
const deploys = require('../source/delegate/deploys.js') | ||
const { | ||
Delegate__factory, | ||
} = require('@airswap/delegate/typechain/factories/contracts') | ||
if (deploys[chainId]) { | ||
const contract = Delegate__factory.connect(deploys[chainId], deployer) | ||
const currentSwapERC20 = await contract.swapERC20Contract() | ||
|
||
const intendedSwapERC20 = swapERC20Deploys[chainId] | ||
|
||
if (intendedSwapERC20) { | ||
console.log( | ||
chainNames[chainId].toUpperCase(), | ||
`(${chainId})`, | ||
'· Intended SwapERC20: ', | ||
intendedSwapERC20 | ||
) | ||
|
||
let label = 'Delegate has correct SwapERC20' | ||
if (currentSwapERC20 !== intendedSwapERC20) { | ||
label = `Delegate has incorrect SwapERC20: ${currentSwapERC20}` | ||
} | ||
console.log(currentSwapERC20 === intendedSwapERC20 ? '✔' : '✘', label) | ||
} else { | ||
console.log( | ||
chainNames[chainId].toUpperCase(), | ||
`(${chainId})`, | ||
'✘ SwapERC20 not deployed' | ||
) | ||
} | ||
} else { | ||
console.log( | ||
chainNames[chainId].toUpperCase(), | ||
`(${chainId})`, | ||
'✘ Delegate not deployed' | ||
) | ||
} | ||
console.log() | ||
} | ||
} | ||
|
||
main() | ||
.then(() => process.exit(0)) | ||
.catch((error) => { | ||
console.error(error) | ||
process.exit(1) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,35 @@ | ||
const Confirm = require('prompt-confirm') | ||
const { | ||
chainNames, | ||
chainCurrencies, | ||
EVM_NATIVE_TOKEN_DECIMALS, | ||
} = require('@airswap/utils') | ||
|
||
module.exports = { | ||
displayDeployerInfo: async function (deployer) { | ||
confirmDeployment: async function (deployer, targetAddress) { | ||
const gasPrice = await deployer.getGasPrice() | ||
const chainId = await deployer.getChainId() | ||
const balance = ethers.utils.formatUnits( | ||
(await deployer.getBalance()).toString(), | ||
EVM_NATIVE_TOKEN_DECIMALS | ||
) | ||
console.log(`\nNetwork: ${chainNames[chainId].toUpperCase()}`) | ||
console.log(`Gas price: ${gasPrice / 10 ** 9} gwei`) | ||
console.log(`\nDeployer: ${deployer.address}`) | ||
console.log(`Balance: ${balance} ${chainCurrencies[chainId]}`) | ||
console.log(`To ${chainNames[chainId].toUpperCase()}`) | ||
console.log(`· Gas price ${gasPrice / 10 ** 9} gwei`) | ||
console.log(`· Deployer wallet ${deployer.address}`) | ||
console.log(`· Deployer balance ${balance} ${chainCurrencies[chainId]}`) | ||
|
||
console.log( | ||
`\nNext contract address will be:\n${ethers.utils.getContractAddress({ | ||
from: deployer.address, | ||
nonce: await deployer.provider.getTransactionCount(deployer.address), | ||
})}\n` | ||
const nextAddress = ethers.utils.getContractAddress({ | ||
from: deployer.address, | ||
nonce: await deployer.provider.getTransactionCount(deployer.address), | ||
}) | ||
|
||
console.log(`· Contract address ${nextAddress}\n`) | ||
|
||
const prompt = new Confirm( | ||
nextAddress === targetAddress || !targetAddress | ||
? 'Proceed to deploy?' | ||
: 'Address would not match mainnet. Proceed anyway?' | ||
) | ||
return await prompt.run() | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.