Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scripts enhancements #1321

Merged
merged 7 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions source/batch-call/deploys-commits.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
1: '863586ae7594b5088619f243dbee83c8d8e0075f',
31: '863586ae7594b5088619f243dbee83c8d8e0075f',
41: '863586ae7594b5088619f243dbee83c8d8e0075f',
56: '863586ae7594b5088619f243dbee83c8d8e0075f',
97: '863586ae7594b5088619f243dbee83c8d8e0075f',
137: '863586ae7594b5088619f243dbee83c8d8e0075f',
8453: '863586ae7594b5088619f243dbee83c8d8e0075f',
17000: '863586ae7594b5088619f243dbee83c8d8e0075f',
42161: '863586ae7594b5088619f243dbee83c8d8e0075f',
43113: '863586ae7594b5088619f243dbee83c8d8e0075f',
43114: '863586ae7594b5088619f243dbee83c8d8e0075f',
59140: '863586ae7594b5088619f243dbee83c8d8e0075f',
59144: '863586ae7594b5088619f243dbee83c8d8e0075f',
80001: '863586ae7594b5088619f243dbee83c8d8e0075f',
84532: '863586ae7594b5088619f243dbee83c8d8e0075f',
421614: '863586ae7594b5088619f243dbee83c8d8e0075f',
11155111: '863586ae7594b5088619f243dbee83c8d8e0075f',
}
1 change: 1 addition & 0 deletions source/batch-call/deploys-commits.js.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module '@airswap/batch-call/deploys-commits.js'
35 changes: 32 additions & 3 deletions source/batch-call/scripts/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const { ChainIds, chainLabels } = require('@airswap/utils')
const { getReceiptUrl } = require('@airswap/utils')
const batchCallDeploys = require('../deploys.js')
const batchCallBlocks = require('../deploys-blocks.js')
const batchCallCommits = require('../deploys-commits.js')
const { displayDeployerInfo } = require('../../../scripts/deployer-info')

async function main() {
Expand All @@ -18,9 +19,13 @@ async function main() {
console.log('Value for --network flag is required')
return
}
await displayDeployerInfo(deployer)

const prompt = new Confirm('Proceed to deploy?')
const targetAddress = await displayDeployerInfo(deployer)
const mainnetAddress = batchCallDeploys['1']
const prompt = new Confirm(
targetAddress === mainnetAddress
? 'Proceed to deploy?'
: 'Contract address would not match current mainnet address. Proceed anyway?'
)
if (await prompt.run()) {
const batchFactory = await ethers.getContractFactory('BatchCall')
const batchCallContract = await batchFactory.deploy()
Expand Down Expand Up @@ -48,6 +53,30 @@ async function main() {
{ ...prettierConfig, parser: 'babel' }
)
)

batchCallBlocks[chainId] = (
await batchCallContract.deployTransaction.wait()
).blockNumber
fs.writeFileSync(
'./deploys-blocks.js',
prettier.format(
`module.exports = ${JSON.stringify(batchCallBlocks, null, '\t')}`,
{ ...prettierConfig, parser: 'babel' }
)
)

batchCallCommits[chainId] = require('child_process')
.execSync('git rev-parse HEAD')
.toString()
.trim()
fs.writeFileSync(
'./deploys-commits.js',
prettier.format(
`module.exports = ${JSON.stringify(batchCallCommits, null, '\t')}`,
{ ...prettierConfig, parser: 'babel' }
)
)

console.log(
`Deployed: ${batchCallDeploys[chainId]} @ ${batchCallBlocks[chainId]}`
)
Expand Down
3 changes: 3 additions & 0 deletions source/delegate/deploys-commits.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
11155111: 'da05cb9528630f4f2e15ce3f9093b0f944bec1b7',
}
1 change: 1 addition & 0 deletions source/delegate/deploys-commits.js.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module '@airswap/delegate/deploys-commits.js'
20 changes: 19 additions & 1 deletion source/delegate/scripts/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const { ChainIds, chainLabels } = require('@airswap/utils')
const { getReceiptUrl } = require('@airswap/utils')
const delegateDeploys = require('../deploys.js')
const delegateBlocks = require('../deploys-blocks.js')
const delegateCommits = require('../deploys-commits.js')
const { displayDeployerInfo } = require('../../../scripts/deployer-info')

async function main() {
Expand All @@ -23,7 +24,13 @@ async function main() {

console.log(`swapERC20Contract: ${swapERC20Deploys[chainId]}\n`)

const prompt = new Confirm('Proceed to deploy?')
const targetAddress = await displayDeployerInfo(deployer)
const mainnetAddress = delegateDeploys['1']
const prompt = new Confirm(
targetAddress === mainnetAddress
? 'Proceed to deploy?'
: 'Contract address would not match current mainnet address. Proceed anyway?'
)
if (await prompt.run()) {
const delegateFactory = await ethers.getContractFactory('Delegate')
const delegateContract = await delegateFactory.deploy(
Expand Down Expand Up @@ -53,6 +60,17 @@ async function main() {
{ ...prettierConfig, parser: 'babel' }
)
)
delegateCommits[chainId] = require('child_process')
.execSync('git rev-parse HEAD')
.toString()
.trim()
fs.writeFileSync(
'./deploys-commits.js',
prettier.format(
`module.exports = ${JSON.stringify(delegateCommits, null, '\t')}`,
{ ...prettierConfig, parser: 'babel' }
)
)
console.log(
`Deployed: ${delegateDeploys[chainId]} @ ${delegateBlocks[chainId]}`
)
Expand Down
22 changes: 22 additions & 0 deletions source/pool/deploys-commits.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = {
1: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4',
5: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4',
30: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4',
31: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4',
40: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4',
41: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4',
56: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4',
97: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4',
137: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4',
8453: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4',
17000: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4',
42161: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4',
43113: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4',
43114: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4',
59140: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4',
59144: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4',
80001: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4',
84531: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4',
421613: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4',
11155111: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4',
}
1 change: 1 addition & 0 deletions source/pool/deploys-commits.js.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module '@airswap/pool/deploys-commits.js'
20 changes: 19 additions & 1 deletion source/pool/scripts/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const { chainLabels, ChainIds } = require('@airswap/utils')
const { getReceiptUrl } = require('@airswap/utils')
const poolDeploys = require('../deploys.js')
const poolBlocks = require('../deploys-blocks.js')
const poolCommits = require('../deploys-commits.js')
const { displayDeployerInfo } = require('../../../scripts/deployer-info')

async function main() {
Expand All @@ -26,7 +27,13 @@ async function main() {
console.log(`scale: ${scale}`)
console.log(`max: ${max}`)

const prompt = new Confirm('Proceed to deploy?')
const targetAddress = await displayDeployerInfo(deployer)
const mainnetAddress = poolDeploys['1']
const prompt = new Confirm(
targetAddress === mainnetAddress
? 'Proceed to deploy?'
: 'Contract address would not match current mainnet address. Proceed anyway?'
)
if (await prompt.run()) {
const poolFactory = await ethers.getContractFactory('Pool')
const poolContract = await poolFactory.deploy(scale, max)
Expand Down Expand Up @@ -54,6 +61,17 @@ async function main() {
{ ...prettierConfig, parser: 'babel' }
)
)
poolCommits[chainId] = require('child_process')
.execSync('git rev-parse HEAD')
.toString()
.trim()
fs.writeFileSync(
'./deploys-commits.js',
prettier.format(
`module.exports = ${JSON.stringify(poolCommits, null, '\t')}`,
{ ...prettierConfig, parser: 'babel' }
)
)
console.log(`Deployed: ${poolDeploys[chainId]} @ ${poolBlocks[chainId]}`)

console.log(
Expand Down
19 changes: 19 additions & 0 deletions source/registry/deploys-commits.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
1: '863586ae7594b5088619f243dbee83c8d8e0075f',
31: '863586ae7594b5088619f243dbee83c8d8e0075f',
41: '863586ae7594b5088619f243dbee83c8d8e0075f',
56: '863586ae7594b5088619f243dbee83c8d8e0075f',
97: '863586ae7594b5088619f243dbee83c8d8e0075f',
137: '863586ae7594b5088619f243dbee83c8d8e0075f',
8453: '863586ae7594b5088619f243dbee83c8d8e0075f',
17000: '863586ae7594b5088619f243dbee83c8d8e0075f',
42161: '863586ae7594b5088619f243dbee83c8d8e0075f',
43113: '863586ae7594b5088619f243dbee83c8d8e0075f',
43114: '863586ae7594b5088619f243dbee83c8d8e0075f',
59140: '863586ae7594b5088619f243dbee83c8d8e0075f',
59144: '863586ae7594b5088619f243dbee83c8d8e0075f',
80001: '863586ae7594b5088619f243dbee83c8d8e0075f',
84532: '863586ae7594b5088619f243dbee83c8d8e0075f',
421614: '863586ae7594b5088619f243dbee83c8d8e0075f',
11155111: '863586ae7594b5088619f243dbee83c8d8e0075f',
}
1 change: 1 addition & 0 deletions source/registry/deploys-commits.js.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module '@airswap/registry/deploys-commits.js'
20 changes: 19 additions & 1 deletion source/registry/scripts/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const { ChainIds, chainLabels } = require('@airswap/utils')
const { getReceiptUrl } = require('@airswap/utils')
const registryDeploys = require('../deploys.js')
const registryBlocks = require('../deploys-blocks.js')
const registryCommits = require('../deploys-commits.js')
const config = require('./config.js')
const { displayDeployerInfo } = require('../../../scripts/deployer-info')

Expand Down Expand Up @@ -35,7 +36,13 @@ async function main() {
console.log(`stakingCost: ${stakingCost}`)
console.log(`supportCost: ${supportCost}\n`)

const prompt = new Confirm('Proceed to deploy?')
const targetAddress = await displayDeployerInfo(deployer)
const mainnetAddress = registryDeploys['1']
const prompt = new Confirm(
targetAddress === mainnetAddress
? 'Proceed to deploy?'
: 'Contract address would not match current mainnet address. Proceed anyway?'
)
if (await prompt.run()) {
const registryFactory = await ethers.getContractFactory('Registry')
const registryContract = await registryFactory.deploy(
Expand Down Expand Up @@ -67,6 +74,17 @@ async function main() {
{ ...prettierConfig, parser: 'babel' }
)
)
registryCommits[chainId] = require('child_process')
.execSync('git rev-parse HEAD')
.toString()
.trim()
fs.writeFileSync(
'./deploys-commits.js',
prettier.format(
`module.exports = ${JSON.stringify(registryCommits, null, '\t')}`,
{ ...prettierConfig, parser: 'babel' }
)
)
console.log(
`Deployed: ${registryDeploys[chainId]} @ ${registryBlocks[chainId]}`
)
Expand Down
5 changes: 5 additions & 0 deletions source/staking/deploys-commits.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
1: '6ede424741588b8e3fbb8060cc9ee8d343eac4ab',
17000: '6ede424741588b8e3fbb8060cc9ee8d343eac4ab',
11155111: '6ede424741588b8e3fbb8060cc9ee8d343eac4ab',
}
1 change: 1 addition & 0 deletions source/staking/deploys-commits.js.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module '@airswap/staking/deploys-commits.js'
20 changes: 19 additions & 1 deletion source/staking/scripts/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const { chainLabels, ChainIds } = require('@airswap/utils')
const { getReceiptUrl } = require('@airswap/utils')
const stakingDeploys = require('../deploys.js')
const stakingBlocks = require('../deploys-blocks.js')
const stakingCommits = require('../deploys-commits.js')
const config = require('./config.js')
const { displayDeployerInfo } = require('../../../scripts/deployer-info')

Expand Down Expand Up @@ -35,7 +36,13 @@ async function main() {
console.log(`stakingDuration: ${stakingDuration}`)
console.log(`minDurationChangeDelay: ${minDurationChangeDelay}\n`)

const prompt = new Confirm('Proceed to deploy?')
const targetAddress = await displayDeployerInfo(deployer)
const mainnetAddress = stakingDeploys['1']
const prompt = new Confirm(
targetAddress === mainnetAddress
? 'Proceed to deploy?'
: 'Contract address would not match current mainnet address. Proceed anyway?'
)
if (await prompt.run()) {
const stakingFactory = await ethers.getContractFactory('Staking')
const stakingContract = await stakingFactory.deploy(
Expand Down Expand Up @@ -69,6 +76,17 @@ async function main() {
{ ...prettierConfig, parser: 'babel' }
)
)
stakingCommits[chainId] = require('child_process')
.execSync('git rev-parse HEAD')
.toString()
.trim()
fs.writeFileSync(
'./deploys-commits.js',
prettier.format(
`module.exports = ${JSON.stringify(stakingCommits, null, '\t')}`,
{ ...prettierConfig, parser: 'babel' }
)
)
console.log(
`Deployed: ${stakingDeploys[chainId]} @ ${stakingBlocks[chainId]}`
)
Expand Down
17 changes: 17 additions & 0 deletions source/swap-erc20/deploys-commits.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
1: '8870acc9b7241bc6d5bb7a1e094ddb37d2d2a927',
56: '8870acc9b7241bc6d5bb7a1e094ddb37d2d2a927',
97: '8870acc9b7241bc6d5bb7a1e094ddb37d2d2a927',
137: '8870acc9b7241bc6d5bb7a1e094ddb37d2d2a927',
8453: '8870acc9b7241bc6d5bb7a1e094ddb37d2d2a927',
17000: '8870acc9b7241bc6d5bb7a1e094ddb37d2d2a927',
42161: '8870acc9b7241bc6d5bb7a1e094ddb37d2d2a927',
43113: '8870acc9b7241bc6d5bb7a1e094ddb37d2d2a927',
43114: '8870acc9b7241bc6d5bb7a1e094ddb37d2d2a927',
59140: '8870acc9b7241bc6d5bb7a1e094ddb37d2d2a927',
59144: '8870acc9b7241bc6d5bb7a1e094ddb37d2d2a927',
80001: '8870acc9b7241bc6d5bb7a1e094ddb37d2d2a927',
84532: '8870acc9b7241bc6d5bb7a1e094ddb37d2d2a927',
421614: '8870acc9b7241bc6d5bb7a1e094ddb37d2d2a927',
11155111: '8870acc9b7241bc6d5bb7a1e094ddb37d2d2a927',
}
1 change: 1 addition & 0 deletions source/swap-erc20/deploys-commits.js.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module '@airswap/swap-erc20/deploys-commits.js'
20 changes: 19 additions & 1 deletion source/swap-erc20/scripts/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const {
const { getReceiptUrl } = require('@airswap/utils')
const swapERC20Deploys = require('../deploys.js')
const swapERC20Blocks = require('../deploys-blocks.js')
const swapERC20Commits = require('../deploys-commits.js')
const config = require('./config.js')
const { displayDeployerInfo } = require('../../../scripts/deployer-info')

Expand Down Expand Up @@ -47,7 +48,13 @@ async function main() {
console.log(`protocolFeeLight: ${protocolFeeLight}`)
console.log(`protocolFeeReceiver: ${protocolFeeReceiver}\n`)

const prompt = new Confirm('Proceed to deploy?')
const targetAddress = await displayDeployerInfo(deployer)
const mainnetAddress = swapERC20Deploys['1']
const prompt = new Confirm(
targetAddress === mainnetAddress
? 'Proceed to deploy?'
: 'Contract address would not match current mainnet address. Proceed anyway?'
)
if (await prompt.run()) {
const swapFactory = await ethers.getContractFactory('SwapERC20')
const swapContract = await swapFactory.deploy(
Expand Down Expand Up @@ -81,6 +88,17 @@ async function main() {
{ ...prettierConfig, parser: 'babel' }
)
)
swapERC20Commits[chainId] = require('child_process')
.execSync('git rev-parse HEAD')
.toString()
.trim()
fs.writeFileSync(
'./deploys-commits.js',
prettier.format(
`module.exports = ${JSON.stringify(swapERC20Commits, null, '\t')}`,
{ ...prettierConfig, parser: 'babel' }
)
)
console.log(
`Deployed: ${swapERC20Deploys[chainId]} @ ${swapERC20Blocks[chainId]}`
)
Expand Down
1 change: 1 addition & 0 deletions source/swap/deploys-adapters-commits.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {}
1 change: 1 addition & 0 deletions source/swap/deploys-adapters-commits.js.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module '@airswap/swap/deploys-commits.js'
19 changes: 19 additions & 0 deletions source/swap/deploys-commits.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
1: '15fc7c8ac53cf44f1e2d450edabb456d2f2d1ff0',
31: '15fc7c8ac53cf44f1e2d450edabb456d2f2d1ff0',
41: '15fc7c8ac53cf44f1e2d450edabb456d2f2d1ff0',
56: '15fc7c8ac53cf44f1e2d450edabb456d2f2d1ff0',
97: '15fc7c8ac53cf44f1e2d450edabb456d2f2d1ff0',
137: '15fc7c8ac53cf44f1e2d450edabb456d2f2d1ff0',
8453: '15fc7c8ac53cf44f1e2d450edabb456d2f2d1ff0',
17000: '15fc7c8ac53cf44f1e2d450edabb456d2f2d1ff0',
42161: '15fc7c8ac53cf44f1e2d450edabb456d2f2d1ff0',
43113: '15fc7c8ac53cf44f1e2d450edabb456d2f2d1ff0',
43114: '15fc7c8ac53cf44f1e2d450edabb456d2f2d1ff0',
59140: '15fc7c8ac53cf44f1e2d450edabb456d2f2d1ff0',
59144: '15fc7c8ac53cf44f1e2d450edabb456d2f2d1ff0',
80001: '15fc7c8ac53cf44f1e2d450edabb456d2f2d1ff0',
84532: '15fc7c8ac53cf44f1e2d450edabb456d2f2d1ff0',
421614: '15fc7c8ac53cf44f1e2d450edabb456d2f2d1ff0',
11155111: '15fc7c8ac53cf44f1e2d450edabb456d2f2d1ff0',
}
1 change: 1 addition & 0 deletions source/swap/deploys-commits.js.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module '@airswap/swap/deploys-commits.js'
Loading
Loading