Skip to content

Commit

Permalink
balances to batch
Browse files Browse the repository at this point in the history
  • Loading branch information
dmosites committed Dec 22, 2023
1 parent 1d8ec35 commit ab81c44
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 50 deletions.
19 changes: 1 addition & 18 deletions source/batch/deploys.js
Original file line number Diff line number Diff line change
@@ -1,18 +1 @@
module.exports = {
1: '0x21486E4427031F10fBE45F47AAd6f729014d42a4',
4: '0x2B1c6b0cB9673Efc83d177f72c0daF52A33F120C',
5: '0x755Aa03f420A62560E90502D7da23A73C301dad4',
30: '0xEAa610106E67Fe191b0f33cF9B8C900Fed1Ba4BA',
31: '0x9e9c21C4747B078712D2bb49A279A043973BE9a0',
40: '0xc17720af2950Ab4af32363789e437eCEA5D2425C',
41: '0xA4fD7555766ebE1Eb284879Cb75f3d5dae719aD6',
42: '0xe25b7504856bfb230b7c32BC87047479815cbc70',
56: '0x4f850F83BB5678E1deBA0B8F4bcBA9813Ef08dCa',
97: '0x4f850F83BB5678E1deBA0B8F4bcBA9813Ef08dCa',
137: '0x132F13C3896eAB218762B9e46F55C9c478905849',
43113: '0x87D02f7C95b6bC3C9220Fd8fBE1042aCAd590102',
43114: '0x8fd3121013A07C57f0D69646E86E7a4880b467b7',
59140: '0x51F372bE64F0612532F28142cECF8F204B272622',
59144: '0xDECA72bDA0cDf62d79b46B1585B380c9C6d57D9E',
80001: '0x132F13C3896eAB218762B9e46F55C9c478905849',
}
module.exports = {}
2 changes: 1 addition & 1 deletion source/batch/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@airswap/batch",
"version": "4.0.4",
"version": "4.1.0",
"description": "Batch balance, allowance, order validity check calls",
"license": "MIT",
"repository": {
Expand Down
18 changes: 8 additions & 10 deletions source/batch/scripts/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const Confirm = require('prompt-confirm')
const { ethers, run } = require('hardhat')
const { ChainIds, chainNames, chainLabels } = require('@airswap/constants')
const { getReceiptUrl } = require('@airswap/utils')
const balancesDeploys = require('../deploys.js')
const batchDeploys = require('../deploys.js')

async function main() {
await run('compile')
Expand All @@ -21,21 +21,19 @@ async function main() {

const prompt = new Confirm('Proceed to deploy?')
if (await prompt.run()) {
const balanceCheckerFactory = await ethers.getContractFactory(
'BalanceChecker'
)
const balanceCheckerContract = await balanceCheckerFactory.deploy()
const batchFactory = await ethers.getContractFactory('Batch')
const batchContract = await batchFactory.deploy()
console.log(
'Deploying...',
getReceiptUrl(chainId, balanceCheckerContract.deployTransaction.hash)
getReceiptUrl(chainId, batchContract.deployTransaction.hash)
)
await balanceCheckerContract.deployed()
console.log(`Deployed: ${balanceCheckerContract.address}`)
await batchContract.deployed()
console.log(`Deployed: ${batchContract.address}`)

balancesDeploys[chainId] = balanceCheckerContract.address
batchDeploys[chainId] = batchContract.address
fs.writeFileSync(
'./deploys.js',
`module.exports = ${JSON.stringify(balancesDeploys, null, '\t')}`
`module.exports = ${JSON.stringify(batchDeploys, null, '\t')}`
)
console.log('Updated deploys.js')

Expand Down
4 changes: 2 additions & 2 deletions source/batch/scripts/verify.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-console */
const { ethers, run } = require('hardhat')
const { chainNames } = require('@airswap/constants')
const balancesDeploys = require('../deploys.js')
const batchDeploys = require('../deploys.js')

async function main() {
await run('compile')
Expand All @@ -12,7 +12,7 @@ async function main() {

console.log(`Verifying on ${chainNames[chainId].toUpperCase()}`)
await run('verify:verify', {
address: balancesDeploys[chainId],
address: batchDeploys[chainId],
constructorArguments: [],
})
}
Expand Down
10 changes: 5 additions & 5 deletions source/pool/scripts/balances.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const { ethers } = require('hardhat')
const { getKnownTokens } = require('@airswap/metadata')
const { chainNames, ChainIds } = require('@airswap/constants')
const BalanceChecker = require('@airswap/balances/build/contracts/BalanceChecker.sol/BalanceChecker.json')
const balancesDeploys = require('@airswap/balances/deploys.js')
const Batch = require('@airswap/batch/build/contracts/Batch.sol/Batch.json')
const batchDeploys = require('@airswap/batch/deploys.js')
const poolDeploys = require('../deploys.js')

async function main() {
Expand All @@ -16,7 +16,7 @@ async function main() {
console.log('Network:', chainNames[chainId].toUpperCase())
console.log('\nPool:', poolDeploys[chainId])

if (!balancesDeploys[chainId]) {
if (!batchDeploys[chainId]) {
throw new Error('Unable to check balances on this chain.')
}

Expand All @@ -33,8 +33,8 @@ async function main() {
console.log(`\nScanning non-zero balances for ${tokens.length} tokens...\n`)

const balancesContract = new ethers.Contract(
balancesDeploys[chainId],
BalanceChecker.abi,
batchDeploys[chainId],
Batch.abi,
account.provider
)

Expand Down
2 changes: 1 addition & 1 deletion tools/libraries/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"test:ci": "yarn test"
},
"dependencies": {
"@airswap/balances": "4.0.4",
"@airswap/batch": "4.1.0",
"@airswap/constants": "4.1.6",
"@airswap/jsonrpc-client-websocket": "0.0.1",
"@airswap/registry": "4.1.3",
Expand Down
26 changes: 13 additions & 13 deletions tools/libraries/src/Contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import swapERC20Blocks from '@airswap/swap-erc20/deploys-blocks.js'
import wrapperBlocks from '@airswap/wrapper/deploys-blocks.js'
import wethBlocks from '@airswap/wrapper/deploys-blocks-weth.js'

import BatchChecker from '@airswap/batch/build/contracts/Batch.sol/Batch.json'
import BatchContract from '@airswap/batch/build/contracts/Batch.sol/Batch.json'
import batchDeploys from '@airswap/batch/deploys.js'
const batchInterface = new ethers.utils.Interface(
JSON.stringify(BatchChecker.abi)
JSON.stringify(BatchContract.abi)
)

export class Contract {
Expand Down Expand Up @@ -82,14 +82,14 @@ export const WETH = new Contract(
wethBlocks,
WETH9__factory
)
// export const Batch = new Contract('Batch', batchDeploys)
// Batch.getContract = (
// providerOrSigner: ethers.providers.Provider | ethers.Signer,
// chainId: number
// ): ethers.Contract => {
// return new ethers.Contract(
// batchDeploys[chainId],
// balancesInterface,
// providerOrSigner
// )
// }
export const Batch = new Contract('Batch', batchDeploys)
Batch.getContract = (
providerOrSigner: ethers.providers.Provider | ethers.Signer,
chainId: number
): ethers.Contract => {
return new ethers.Contract(
batchDeploys[chainId],
batchInterface,
providerOrSigner
)
}

0 comments on commit ab81c44

Please sign in to comment.