Skip to content

Commit

Permalink
Merge pull request #1284 from airswap/develop
Browse files Browse the repository at this point in the history
Publish latest to NPM
  • Loading branch information
dmosites authored Feb 7, 2024
2 parents 795ce0b + cf99691 commit f8f21ca
Show file tree
Hide file tree
Showing 41 changed files with 588 additions and 203 deletions.
48 changes: 24 additions & 24 deletions hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ module.exports = {
url: apiUrls[ChainIds.ARBITRUM],
accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : undefined,
},
arbitrumgoerli: {
url: apiUrls[ChainIds.ARBITRUMGOERLI],
arbitrumsepolia: {
url: apiUrls[ChainIds.ARBITRUMSEPOLIA],
accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : undefined,
},
rsk: {
Expand All @@ -70,8 +70,8 @@ module.exports = {
url: apiUrls[ChainIds.LINEA],
accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : undefined,
},
basegoerli: {
url: apiUrls[ChainIds.BASEGOERLI],
basesepolia: {
url: apiUrls[ChainIds.BASESEPOLIA],
accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : undefined,
},
base: {
Expand Down Expand Up @@ -133,82 +133,82 @@ module.exports = {
bscTestnet: process.env.BSCSCAN_API_KEY,
polygon: process.env.POLYGONSCAN_API_KEY,
arbitrumOne: process.env.ARBISCAN_API_KEY,
arbitrumGoerli: process.env.ARBISCAN_API_KEY,
arbitrumSepolia: process.env.ARBISCAN_API_KEY,
avalanche: process.env.SNOWTRACE_API_KEY,
avalancheFujiTestnet: process.env.SNOWTRACE_API_KEY,
holesky: process.env.ETHERSCAN_API_KEY,
polygonMumbai: process.env.POLYGONSCAN_API_KEY,
linea: process.env.LINEASCAN_API_KEY,
lineagoerli: process.env.LINEASCAN_API_KEY,
lineaGoerli: process.env.LINEASCAN_API_KEY,
base: process.env.BASESCAN_API_KEY,
basegoerli: process.env.BASESCAN_API_KEY,
baseSepolia: process.env.BASESCAN_API_KEY,
rsk: process.env.BLOCKSCOUT_API_KEY,
rsktestnet: process.env.BLOCKSCOUT_API_KEY,
rskTestnet: process.env.BLOCKSCOUT_API_KEY,
sepolia: process.env.ETHERSCAN_API_KEY,
},
customChains: [
{
network: 'rsk',
chainId: 30,
chainId: ChainIds.RSK,
urls: {
apiURL: explorerApiUrls[ChainIds.RSK],
browserURL: explorerUrls[ChainIds.RSK],
},
},
{
network: 'rsktestnet',
chainId: 31,
network: 'rskTestnet',
chainId: ChainIds.RSKTESTNET,
urls: {
apiURL: explorerApiUrls[ChainIds.RSKTESTNET],
browserURL: explorerUrls[ChainIds.RSKTESTNET],
},
},
{
network: 'holesky',
chainId: 17000,
chainId: ChainIds.HOLESKY,
urls: {
apiURL: explorerApiUrls[ChainIds.HOLESKY],
browserURL: explorerUrls[ChainIds.HOLESKY],
},
},
{
network: 'linea',
chainId: 59144,
chainId: ChainIds.LINEA,
urls: {
apiURL: explorerApiUrls[ChainIds.LINEA],
browserURL: explorerUrls[ChainIds.LINEA],
},
},
{
network: 'lineagoerli',
chainId: 59140,
network: 'lineaGoerli',
chainId: ChainIds.LINEAGOERLI,
urls: {
apiURL: explorerApiUrls[ChainIds.LINEAGOERLI],
browserURL: explorerUrls[ChainIds.LINEAGOERLI],
},
},
{
network: 'base',
chainId: 8453,
chainId: ChainIds.BASE,
urls: {
apiURL: explorerApiUrls[ChainIds.BASE],
browserURL: explorerUrls[ChainIds.BASE],
},
},
{
network: 'basegoerli',
chainId: 84531,
network: 'baseSepolia',
chainId: ChainIds.BASESEPOLIA,
urls: {
apiURL: explorerApiUrls[ChainIds.BASEGOERLI],
browserURL: explorerUrls[ChainIds.BASEGOERLI],
apiURL: explorerApiUrls[ChainIds.BASESEPOLIA],
browserURL: explorerUrls[ChainIds.BASESEPOLIA],
},
},
{
network: 'arbitrumGoerli',
chainId: 421613,
network: 'arbitrumSepolia',
chainId: ChainIds.ARBITRUMSEPOLIA,
urls: {
apiURL: explorerApiUrls[ChainIds.ARBITRUMGOERLI],
browserURL: explorerUrls[ChainIds.ARBITRUMGOERLI],
apiURL: explorerApiUrls[ChainIds.ARBITRUMSEPOLIA],
browserURL: explorerUrls[ChainIds.ARBITRUMSEPOLIA],
},
},
],
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"test:ci": "lerna run test:ci",
"owners": "node ./scripts/owners-report.js",
"receivers": "node ./scripts/receivers-report.js",
"drain": "node ./scripts/drain-deployer.js",
"prepare": "husky install",
"pretty:check": "prettier --check \"./**/*.sol\" \"./**/*.ts\" \"./**/*.js\" \"./**/*.json\"",
"pretty:fix": "prettier --write \"./**/*.sol\" \"./**/*.ts\" \"./**/*.js\" \"./**/*.json\""
Expand Down
27 changes: 27 additions & 0 deletions scripts/deployer-info.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const {
chainNames,
chainCurrencies,
EVM_NATIVE_TOKEN_DECIMALS,
} = require('@airswap/utils')

module.exports = {
displayDeployerInfo: async function (deployer) {
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(
`\nNext contract address will be:\n${ethers.utils.getContractAddress({
from: deployer.address,
nonce: await deployer.provider.getTransactionCount(deployer.address),
})}\n`
)
},
}
97 changes: 97 additions & 0 deletions scripts/drain-deployer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
require('dotenv').config({ path: './.env' })
const Confirm = require('prompt-confirm')
const { ethers } = require('ethers')
const {
ChainIds,
chainNames,
chainCurrencies,
apiUrls,
getReceiptUrl,
ADDRESS_ZERO,
EVM_NATIVE_TOKEN_DECIMALS,
} = require('@airswap/utils')

const CONFIRMATIONS = 2
const RECIPIENT = '0x0000000000000000000000000000000000000000'

async function main() {
let chainId
if (process.argv[2] === '--network') {
chainId = ChainIds[process.argv[3].toUpperCase()]
}

if (!chainId) {
console.log('Value for --network flag is required')
return
}

const provider = new ethers.providers.JsonRpcProvider(apiUrls[chainId])
const deployer = new ethers.Wallet(process.env.PRIVATE_KEY, provider)
const gasPrice = await deployer.getGasPrice()

const balance = await deployer.getBalance()
const balanceFormatted = ethers.utils.formatUnits(
balance.toString(),
EVM_NATIVE_TOKEN_DECIMALS
)

if (balance.isZero()) {
console.log(
`\n✘ Balance is already 0 on ${process.argv[3].toUpperCase()}.\n`
)
process.exit(0)
}

if (RECIPIENT === ADDRESS_ZERO) {
console.log(`\n✘ RECIPIENT must be set.\n`)
process.exit(0)
}

const estimation = await provider.estimateGas({
to: RECIPIENT,
value: 1,
})

const cost = estimation.mul(gasPrice)
const costFormatted = ethers.utils.formatUnits(
cost,
EVM_NATIVE_TOKEN_DECIMALS
)
const value = balance.sub(cost)

console.log(`\nNetwork: ${chainNames[chainId].toUpperCase()}`)
console.log(`Gas price: ${gasPrice / 10 ** 9} gwei`)
console.log(`\nDeployer: ${deployer.address}`)
console.log(`Balance: ${balanceFormatted} ${chainCurrencies[chainId]}`)
console.log(`Transfer cost: ${costFormatted} ${chainCurrencies[chainId]}`)
console.log(
`Net amount: ${ethers.utils.formatUnits(
value,
EVM_NATIVE_TOKEN_DECIMALS
)} ${chainCurrencies[chainId]}\n`
)

if (value.isNegative()) {
console.log(`✘ Not enough balance to perform transfer.\n`)
process.exit(0)
}

const prompt = new Confirm(`Transfer ${balanceFormatted} to ${RECIPIENT}?`)
if (await prompt.run()) {
const tx = await deployer.sendTransaction({
to: RECIPIENT,
value,
gasPrice,
})
console.log('Transferring...', getReceiptUrl(chainId, tx.hash), '\n')
await tx.wait(CONFIRMATIONS)
console.log(`✔ Balance transfer complete.\n`)
}
}

main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error)
process.exit(1)
})
19 changes: 17 additions & 2 deletions source/batch-call/deploys-blocks.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
module.exports = {
80001: 45223507,
11155111: 5163580,
1: 19169067,
31: 4777071,
41: 280846804,
56: 35875924,
97: 37478338,
137: 53161285,
8453: 10229545,
17000: 882749,
42161: 178078680,
43113: 29753793,
43114: 41340327,
59140: 3405398,
59144: 2075793,
80001: 45576937,
84532: 5688630,
421614: 11923855,
11155111: 5225773,
}
19 changes: 17 additions & 2 deletions source/batch-call/deploys.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
module.exports = {
80001: '0x2f9848b5644833b9A55F14375D5dAFCFa4d0E107',
11155111: '0x2f9848b5644833b9A55F14375D5dAFCFa4d0E107',
1: '0xd88cf00477B0Edd2C514e6474Ecfc44222830F58',
31: '0xd88cf00477B0Edd2C514e6474Ecfc44222830F58',
41: '0xd88cf00477B0Edd2C514e6474Ecfc44222830F58',
56: '0xd88cf00477B0Edd2C514e6474Ecfc44222830F58',
97: '0xd88cf00477B0Edd2C514e6474Ecfc44222830F58',
137: '0xd88cf00477B0Edd2C514e6474Ecfc44222830F58',
8453: '0xd88cf00477B0Edd2C514e6474Ecfc44222830F58',
17000: '0xd88cf00477B0Edd2C514e6474Ecfc44222830F58',
42161: '0xd88cf00477B0Edd2C514e6474Ecfc44222830F58',
43113: '0xd88cf00477B0Edd2C514e6474Ecfc44222830F58',
43114: '0xd88cf00477B0Edd2C514e6474Ecfc44222830F58',
59140: '0xd88cf00477B0Edd2C514e6474Ecfc44222830F58',
59144: '0xd88cf00477B0Edd2C514e6474Ecfc44222830F58',
80001: '0xd88cf00477B0Edd2C514e6474Ecfc44222830F58',
84532: '0xd88cf00477B0Edd2C514e6474Ecfc44222830F58',
421614: '0xd88cf00477B0Edd2C514e6474Ecfc44222830F58',
11155111: '0xd88cf00477B0Edd2C514e6474Ecfc44222830F58',
}
6 changes: 3 additions & 3 deletions source/batch-call/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@airswap/batch-call",
"version": "4.2.0",
"version": "4.2.1",
"description": "Batch balance, allowance, order validity checks",
"license": "MIT",
"repository": {
Expand All @@ -27,8 +27,8 @@
},
"dependencies": {
"@openzeppelin/contracts": "^4.8.3",
"@airswap/swap": "4.2.0",
"@airswap/swap-erc20": "4.2.0"
"@airswap/swap": "4.2.1",
"@airswap/swap-erc20": "4.2.1"
},
"devDependencies": {
"@airswap/utils": "4.2.5",
Expand Down
10 changes: 4 additions & 6 deletions source/batch-call/scripts/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,25 @@ const fs = require('fs')
const prettier = require('prettier')
const Confirm = require('prompt-confirm')
const { ethers, run } = require('hardhat')
const { ChainIds, chainNames, chainLabels } = require('@airswap/utils')
const { ChainIds, chainLabels } = require('@airswap/utils')
const { getReceiptUrl } = require('@airswap/utils')
const batchCallDeploys = require('../deploys.js')
const batchCallBlocks = require('../deploys-blocks.js')
const { displayDeployerInfo } = require('../../../scripts/deployer-info')

async function main() {
await run('compile')
const prettierConfig = await prettier.resolveConfig('../deploys.js')
const [deployer] = await ethers.getSigners()
const gasPrice = await deployer.getGasPrice()
const chainId = await deployer.getChainId()
if (chainId === ChainIds.HARDHAT) {
console.log('Value for --network flag is required')
return
}
console.log(`Deployer: ${deployer.address}`)
console.log(`Network: ${chainNames[chainId].toUpperCase()}`)
console.log(`Gas price: ${gasPrice / 10 ** 9} gwei\n`)
await displayDeployerInfo(deployer)

const prompt = new Confirm('Proceed to deploy?')
if (await prompt.run()) {
const prettierConfig = await prettier.resolveConfig('../deploys.js')
const batchFactory = await ethers.getContractFactory('BatchCall')
const batchCallContract = await batchFactory.deploy()
console.log(
Expand Down
2 changes: 1 addition & 1 deletion source/batch-call/scripts/owner.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
console.log(`\n✘ Balances is not ownable.\n`)
console.log(`\n✘ BatchCall is not ownable.\n`)
2 changes: 1 addition & 1 deletion source/pool/deploys-blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
97: 34150670,
137: 48645401,
8453: 5180096,
17000: 731316,
17000: 890721,
42161: 140046382,
43113: 26720218,
43114: 36367783,
Expand Down
2 changes: 1 addition & 1 deletion source/pool/deploys.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
97: '0xbbcec987E4C189FCbAB0a2534c77b3ba89229F11',
137: '0xbbcec987E4C189FCbAB0a2534c77b3ba89229F11',
8453: '0xbbcec987E4C189FCbAB0a2534c77b3ba89229F11',
17000: '0xc0799BA9b7bdBA773F77943a9FD448d188345081',
17000: '0xbbcec987E4C189FCbAB0a2534c77b3ba89229F11',
42161: '0xbbcec987E4C189FCbAB0a2534c77b3ba89229F11',
43113: '0xbbcec987E4C189FCbAB0a2534c77b3ba89229F11',
43114: '0xbbcec987E4C189FCbAB0a2534c77b3ba89229F11',
Expand Down
2 changes: 1 addition & 1 deletion source/pool/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@airswap/pool",
"version": "4.1.4",
"version": "4.2.1",
"description": "AirSwap: Withdrawable Token Pool",
"license": "MIT",
"repository": {
Expand Down
Loading

0 comments on commit f8f21ca

Please sign in to comment.