From 9c47b18149d90db1c79d31c42de4f1592b58134a Mon Sep 17 00:00:00 2001 From: Don Mosites Date: Mon, 21 Aug 2023 14:48:12 +0200 Subject: [PATCH 1/2] pool and registry deploys; write blocks; add pool to libraries --- .prettierrc | 4 ++-- source/pool/deploys-blocks.js | 3 +++ source/pool/deploys.js | 13 +------------ source/pool/deploys.js.d.ts | 1 + source/pool/package.json | 4 ++-- source/pool/scripts/deploy.js | 32 +++++++++++++++++-------------- source/registry/deploys-blocks.js | 3 +++ source/registry/deploys.js | 4 +--- source/registry/deploys.js.d.ts | 1 + source/registry/package.json | 2 +- source/registry/scripts/deploy.js | 19 ++++++++++++++++-- tools/libraries/package.json | 5 +++-- tools/libraries/src/Contracts.ts | 4 ++++ tools/libraries/src/RegistryV4.ts | 3 ++- 14 files changed, 59 insertions(+), 39 deletions(-) create mode 100644 source/pool/deploys-blocks.js create mode 100644 source/registry/deploys-blocks.js diff --git a/.prettierrc b/.prettierrc index ef189772d..7fe7f1b51 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,9 +1,9 @@ { + "bracketSpacing": true, "printWidth": 80, - "tabWidth": 2, "semi": false, "singleQuote": true, - "bracketSpacing": true, + "tabWidth": 2, "trailingComma": "es5", "overrides": [ { diff --git a/source/pool/deploys-blocks.js b/source/pool/deploys-blocks.js new file mode 100644 index 000000000..5ce472f01 --- /dev/null +++ b/source/pool/deploys-blocks.js @@ -0,0 +1,3 @@ +module.exports = { + 5: null, +} diff --git a/source/pool/deploys.js b/source/pool/deploys.js index 3354270ab..cf66fbf64 100644 --- a/source/pool/deploys.js +++ b/source/pool/deploys.js @@ -1,14 +1,3 @@ module.exports = { - 1: '0xe2E7AE67E7ee6d4D90dfef945aB6dE6A14dB4c17', - 5: '0xE5f1542054d5DA46C2CB3728C197857958bb44a5', - 30: '0x9e9c21C4747B078712D2bb49A279A043973BE9a0', - 31: '0xb1B586AfA8a2AaB42826Fb2Ab9896CD0c686d0F4', - 56: '0x16B57a5958271C479f64BC5F830DfC4f30ba2235', - 97: '0x64888583E676368390D6eB573bC2AC3bCE9002B3', - 137: '0xb1b586afa8a2aab42826fb2ab9896cd0c686d0f4', - 42161: '0xb1B586AfA8a2AaB42826Fb2Ab9896CD0c686d0F4', - 43113: '0x1CfA1b1809b9fF6bDCE1d4c5fCc842eAA31a836d', - 43114: '0xd3B6279cD6b21e92A6c53476E59a2C819018D6fE', - 80001: '0xC32a3c867aBAd28d977e1724f92D9684fF3d2976', - 421613: '0x5E5A433cdfB14aB228c45E23251Ad83F7b1E3302', + 5: '0x1c40839db53221aA35c27c5d3d69E726F37AF833', } diff --git a/source/pool/deploys.js.d.ts b/source/pool/deploys.js.d.ts index fe65925fc..31683c18a 100644 --- a/source/pool/deploys.js.d.ts +++ b/source/pool/deploys.js.d.ts @@ -1 +1,2 @@ declare module '@airswap/pool/deploys.js' +declare module '@airswap/pool/deploys-blocks.js' diff --git a/source/pool/package.json b/source/pool/package.json index 3a872b3d3..487d01eea 100644 --- a/source/pool/package.json +++ b/source/pool/package.json @@ -1,7 +1,7 @@ { "name": "@airswap/pool", - "version": "4.0.3-beta.0", - "description": "AirSwap: Rewards Pool", + "version": "4.0.3-beta.1", + "description": "AirSwap: Withdrawable Token Pool", "license": "MIT", "repository": { "type": "git", diff --git a/source/pool/scripts/deploy.js b/source/pool/scripts/deploy.js index d7dcd225a..b93b32173 100644 --- a/source/pool/scripts/deploy.js +++ b/source/pool/scripts/deploy.js @@ -1,18 +1,17 @@ /* eslint-disable no-console */ const fs = require('fs') +const prettier = require('prettier') const Confirm = require('prompt-confirm') const { ethers, run } = require('hardhat') -const stakingDeploys = require('@airswap/staking/deploys.js') -const { - chainNames, - ChainIds, - stakingTokenAddresses, -} = require('@airswap/constants') +const { chainNames, ChainIds } = require('@airswap/constants') const { getReceiptUrl } = require('@airswap/utils') const poolDeploys = require('../deploys.js') +const poolBlocks = require('../deploys-blocks.js') async function main() { await run('compile') + const config = await prettier.resolveConfig('../deploys.js') + const [deployer] = await ethers.getSigners() const gasPrice = await deployer.getGasPrice() const chainId = await deployer.getChainId() @@ -26,12 +25,6 @@ async function main() { const scale = 10 const max = 100 - const stakingContract = stakingDeploys[chainId] - const stakingToken = stakingTokenAddresses[chainId] - - console.log(`Staking token: ${stakingToken}`) - console.log(`Staking contract: ${stakingContract}`) - console.log(`Gas price: ${gasPrice / 10 ** 9} gwei`) const prompt = new Confirm('Proceed to deploy?') if (await prompt.run()) { @@ -47,9 +40,20 @@ async function main() { poolDeploys[chainId] = poolContract.address fs.writeFileSync( './deploys.js', - `module.exports = ${JSON.stringify(poolDeploys, null, '\t')}` + prettier.format( + `module.exports = ${JSON.stringify(poolDeploys, null, '\t')}`, + { ...config, parser: 'babel' } + ) + ) + poolBlocks[chainId] = poolContract.deployTransaction.blockNumber + fs.writeFileSync( + './deploys-blocks.js', + prettier.format( + `module.exports = ${JSON.stringify(poolBlocks, null, '\t')}`, + { ...config, parser: 'babel' } + ) ) - console.log('Updated deploys.js') + console.log('Updated: deploys.js, deploys-blocks.js') console.log( `\nVerify with "yarn verify --network ${chainNames[ diff --git a/source/registry/deploys-blocks.js b/source/registry/deploys-blocks.js new file mode 100644 index 000000000..5ce472f01 --- /dev/null +++ b/source/registry/deploys-blocks.js @@ -0,0 +1,3 @@ +module.exports = { + 5: null, +} diff --git a/source/registry/deploys.js b/source/registry/deploys.js index c14f7ec6e..7efbfcaa4 100644 --- a/source/registry/deploys.js +++ b/source/registry/deploys.js @@ -1,5 +1,3 @@ module.exports = { - 1: '0xf5E6730c5A915b6f47AeAB0952655036aE2e73E9', - 5: '0x4b572E93511120a9e1a2EA29C8b2358bdD0addc0', - 59140: '0xAa7fC83C31db055261cb88e5cAa02CAFe12c8dCD', + 5: '0x0BA354Aaa707bec0823aF9026F031BeC967eFE58', } diff --git a/source/registry/deploys.js.d.ts b/source/registry/deploys.js.d.ts index 13ee47dbe..adcadf673 100644 --- a/source/registry/deploys.js.d.ts +++ b/source/registry/deploys.js.d.ts @@ -1 +1,2 @@ declare module '@airswap/registry/deploys.js' +declare module '@airswap/registry/deploys-blocks.js' diff --git a/source/registry/package.json b/source/registry/package.json index 2c833cb01..ed5e36b39 100644 --- a/source/registry/package.json +++ b/source/registry/package.json @@ -1,6 +1,6 @@ { "name": "@airswap/registry", - "version": "4.0.3", + "version": "4.0.4-beta.0", "description": "AirSwap: Server URL Registry", "license": "MIT", "repository": { diff --git a/source/registry/scripts/deploy.js b/source/registry/scripts/deploy.js index edaebdf91..fcfe0c292 100644 --- a/source/registry/scripts/deploy.js +++ b/source/registry/scripts/deploy.js @@ -1,13 +1,17 @@ /* eslint-disable no-console */ const fs = require('fs') +const prettier = require('prettier') const Confirm = require('prompt-confirm') const { ethers, run } = require('hardhat') const { ChainIds, chainNames, ADDRESS_ZERO } = require('@airswap/constants') const { getReceiptUrl } = require('@airswap/utils') const registryDeploys = require('../deploys.js') +const registryBlocks = require('../deploys-blocks.js') async function main() { await run('compile') + const config = await prettier.resolveConfig('../deploys.js') + const [deployer] = await ethers.getSigners() const gasPrice = await deployer.getGasPrice() const chainId = await deployer.getChainId() @@ -45,9 +49,20 @@ async function main() { registryDeploys[chainId] = registryContract.address fs.writeFileSync( './deploys.js', - `module.exports = ${JSON.stringify(registryDeploys, null, '\t')}` + prettier.format( + `module.exports = ${JSON.stringify(registryDeploys, null, '\t')}`, + { ...config, parser: 'babel' } + ) + ) + registryBlocks[chainId] = registryContract.deployTransaction.blockNumber + fs.writeFileSync( + './deploys-blocks.js', + prettier.format( + `module.exports = ${JSON.stringify(registryBlocks, null, '\t')}`, + { ...config, parser: 'babel' } + ) ) - console.log('Updated deploys.js') + console.log('Updated: deploys.js, deploys-blocks.js') console.log( `\nVerify with "yarn verify --network ${chainNames[ diff --git a/tools/libraries/package.json b/tools/libraries/package.json index 6b283ff23..368481821 100644 --- a/tools/libraries/package.json +++ b/tools/libraries/package.json @@ -1,6 +1,6 @@ { "name": "@airswap/libraries", - "version": "4.0.19", + "version": "4.0.20-beta.0", "description": "AirSwap: Libraries for Developers", "repository": { "type": "git", @@ -29,8 +29,9 @@ "@airswap/balances": "4.0.2", "@airswap/constants": "4.0.10", "@airswap/jsonrpc-client-websocket": "0.0.1", - "@airswap/registry": "4.0.3", + "@airswap/registry": "4.0.4-beta.0", "@airswap/maker-registry": "4.0.4", + "@airswap/pool": "4.0.3-beta.1", "@airswap/staking": "4.0.3", "@airswap/swap": "4.0.4", "@airswap/swap-erc20": "4.0.6", diff --git a/tools/libraries/src/Contracts.ts b/tools/libraries/src/Contracts.ts index 3662f5c4f..7800f046c 100644 --- a/tools/libraries/src/Contracts.ts +++ b/tools/libraries/src/Contracts.ts @@ -1,18 +1,21 @@ import { ethers } from 'ethers' import { ChainIds } from '@airswap/constants' +import { Pool__factory } from '@airswap/pool/typechain/factories/contracts' import { Staking__factory } from '@airswap/staking/typechain/factories/contracts' import { Swap__factory } from '@airswap/swap/typechain/factories/contracts' import { SwapERC20__factory } from '@airswap/swap-erc20/typechain/factories/contracts' import { Wrapper__factory } from '@airswap/wrapper/typechain/factories/contracts' import { WETH9__factory } from '@airswap/wrapper/typechain/factories/contracts' +import poolDeploys from '@airswap/pool/deploys.js' import stakingDeploys from '@airswap/staking/deploys.js' import swapERC20Deploys from '@airswap/swap-erc20/deploys.js' import swapDeploys from '@airswap/swap/deploys.js' import wrapperDeploys from '@airswap/wrapper/deploys.js' import wethDeploys from '@airswap/wrapper/deploys-weth.js' +import poolBlocks from '@airswap/pool/deploys-blocks.js' import stakingBlocks from '@airswap/staking/deploys-blocks.js' import swapERC20Blocks from '@airswap/swap-erc20/deploys-blocks.js' import wrapperBlocks from '@airswap/wrapper/deploys-blocks.js' @@ -54,6 +57,7 @@ export class Contract { } } +export const Pool = new Contract('Pool', poolDeploys, poolBlocks, Pool__factory) export const Staking = new Contract( 'Staking', stakingDeploys, diff --git a/tools/libraries/src/RegistryV4.ts b/tools/libraries/src/RegistryV4.ts index 7d8bec427..e7f607675 100644 --- a/tools/libraries/src/RegistryV4.ts +++ b/tools/libraries/src/RegistryV4.ts @@ -2,13 +2,14 @@ import { ethers } from 'ethers' import { ServerOptions } from '@airswap/types' import { Registry__factory } from '@airswap/registry/typechain/factories/contracts' import registryDeploys from '@airswap/registry/deploys.js' +import registryBlocks from '@airswap/registry/deploys-blocks.js' import { Server } from './Server' import { Contract, SwapERC20 } from './Contracts' class ServerRegistry extends Contract { public constructor() { - super('Registry', registryDeploys, {}, Registry__factory) + super('Registry', registryDeploys, registryBlocks, Registry__factory) } public async getServerURLs( providerOrSigner: ethers.providers.Provider | ethers.Signer, From cc18d1f2808320554b178a2ef276761a84437e46 Mon Sep 17 00:00:00 2001 From: Don Mosites Date: Mon, 21 Aug 2023 14:59:19 +0200 Subject: [PATCH 2/2] properly fetch blockNumber --- source/pool/deploys-blocks.js | 2 +- source/pool/deploys.js | 2 +- source/pool/scripts/deploy.js | 7 ++++--- source/registry/deploys-blocks.js | 2 +- source/registry/deploys.js | 2 +- source/registry/scripts/deploy.js | 9 ++++++--- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/source/pool/deploys-blocks.js b/source/pool/deploys-blocks.js index 5ce472f01..db096210e 100644 --- a/source/pool/deploys-blocks.js +++ b/source/pool/deploys-blocks.js @@ -1,3 +1,3 @@ module.exports = { - 5: null, + 5: 9556269, } diff --git a/source/pool/deploys.js b/source/pool/deploys.js index cf66fbf64..f15724ad7 100644 --- a/source/pool/deploys.js +++ b/source/pool/deploys.js @@ -1,3 +1,3 @@ module.exports = { - 5: '0x1c40839db53221aA35c27c5d3d69E726F37AF833', + 5: '0xFeEFD5F62A10277fF8082a80735a8380033439d0', } diff --git a/source/pool/scripts/deploy.js b/source/pool/scripts/deploy.js index b93b32173..cbf68de44 100644 --- a/source/pool/scripts/deploy.js +++ b/source/pool/scripts/deploy.js @@ -35,7 +35,6 @@ async function main() { getReceiptUrl(chainId, poolContract.deployTransaction.hash) ) await poolContract.deployed() - console.log(`Deployed: ${poolContract.address}`) poolDeploys[chainId] = poolContract.address fs.writeFileSync( @@ -45,7 +44,9 @@ async function main() { { ...config, parser: 'babel' } ) ) - poolBlocks[chainId] = poolContract.deployTransaction.blockNumber + poolBlocks[chainId] = ( + await poolContract.deployTransaction.wait() + ).blockNumber fs.writeFileSync( './deploys-blocks.js', prettier.format( @@ -53,7 +54,7 @@ async function main() { { ...config, parser: 'babel' } ) ) - console.log('Updated: deploys.js, deploys-blocks.js') + console.log(`Deployed: ${poolDeploys[chainId]} @ ${poolBlocks[chainId]}`) console.log( `\nVerify with "yarn verify --network ${chainNames[ diff --git a/source/registry/deploys-blocks.js b/source/registry/deploys-blocks.js index 5ce472f01..dc89edf2e 100644 --- a/source/registry/deploys-blocks.js +++ b/source/registry/deploys-blocks.js @@ -1,3 +1,3 @@ module.exports = { - 5: null, + 5: 9556263, } diff --git a/source/registry/deploys.js b/source/registry/deploys.js index 7efbfcaa4..ce04d57f7 100644 --- a/source/registry/deploys.js +++ b/source/registry/deploys.js @@ -1,3 +1,3 @@ module.exports = { - 5: '0x0BA354Aaa707bec0823aF9026F031BeC967eFE58', + 5: '0xA5630a92E45c2b4DeFA95Bf312B3bb9B69944A13', } diff --git a/source/registry/scripts/deploy.js b/source/registry/scripts/deploy.js index fcfe0c292..63bba82e4 100644 --- a/source/registry/scripts/deploy.js +++ b/source/registry/scripts/deploy.js @@ -44,7 +44,6 @@ async function main() { getReceiptUrl(chainId, registryContract.deployTransaction.hash) ) await registryContract.deployed() - console.log(`Deployed: ${registryContract.address}`) registryDeploys[chainId] = registryContract.address fs.writeFileSync( @@ -54,7 +53,9 @@ async function main() { { ...config, parser: 'babel' } ) ) - registryBlocks[chainId] = registryContract.deployTransaction.blockNumber + registryBlocks[chainId] = ( + await registryContract.deployTransaction.wait() + ).blockNumber fs.writeFileSync( './deploys-blocks.js', prettier.format( @@ -62,7 +63,9 @@ async function main() { { ...config, parser: 'babel' } ) ) - console.log('Updated: deploys.js, deploys-blocks.js') + console.log( + `Deployed: ${registryDeploys[chainId]} @ ${registryBlocks[chainId]}` + ) console.log( `\nVerify with "yarn verify --network ${chainNames[