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

Add docker network and update contract deployments #2

Merged
merged 6 commits into from
Aug 9, 2023
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ cache/
crytic-export/
node_modules/
typechain/
.env
.env
deployments/docker
8 changes: 4 additions & 4 deletions deploy/NonfungiblePositionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ const func: DeployFunction = async function ({

const chainId = await getChainId()

if (!process.env.WNATIVE_ADDRESS) {
throw Error(`No WNATIVE_ADDRESS for chain #${chainId}!`)
}
const wfil = await deployments.get('WFIL')

if (!process.env.FACTORY_ADDRESS) {
throw Error(`No FACTORY_ADDRESS for chain #${chainId}!`)
Expand All @@ -29,7 +27,7 @@ const func: DeployFunction = async function ({

await deploy('NonfungiblePositionManager', {
from: deployer,
args: [process.env.FACTORY_ADDRESS, process.env.WNATIVE_ADDRESS, NonfungibleTokenPositionDescriptor.address],
args: [process.env.FACTORY_ADDRESS, wfil.address, NonfungibleTokenPositionDescriptor.address],
log: true,
deterministicDeployment: false,
})
Expand All @@ -40,3 +38,5 @@ func.tags = ['NonfungiblePositionManager']
func.dependencies = ['NonfungibleTokenPositionDescriptor']

export default func

// Usage: yarn hardhat --network docker deploy --tags NonfungiblePositionManager
19 changes: 10 additions & 9 deletions deploy/NonfungibleTokenPositionDescriptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,24 @@ const func: DeployFunction = async function ({

const chainId = await getChainId()

if (!process.env.WNATIVE_ADDRESS) {
throw Error(`No WNATIVE_ADDRESS for chain #${chainId}!`)
}
// Use tokens as done in tests?
// (test/shared/completeFixture.ts)
const wfil = await deployments.get('WFIL')

if (!process.env.NATIVE_CURRENCY_LABEL) {
throw Error(`No NATIVE_CURRENCY_LABEL for chain #${chainId}!`)
}
// 'FIL' as a bytes32 string
const currencyLabelBuffer = Buffer.alloc(32).fill(0)
Buffer.from('FIL', "utf8").copy(currencyLabelBuffer);
const currencyLabel = `0x${currencyLabelBuffer.toString("hex")}`;

console.log('Deploying NonfungibleTokenPositionDescriptor...', {
args: [process.env.WNATIVE_ADDRESS, process.env.NATIVE_CURRENCY_LABEL],
args: [wfil.address, currencyLabel],
})

const NFTDescriptor = await deployments.get('NFTDescriptor')

await deploy('NonfungibleTokenPositionDescriptor', {
from: deployer,
args: [process.env.WNATIVE_ADDRESS, process.env.NATIVE_CURRENCY_LABEL],
args: [wfil.address, currencyLabel],
log: true,
deterministicDeployment: false,
libraries: {
Expand All @@ -40,6 +41,6 @@ const func: DeployFunction = async function ({

func.tags = ['NonfungibleTokenPositionDescriptor']

func.dependencies = ['NFTDescriptor']
func.dependencies = ['NFTDescriptor', 'WFIL']

export default func
2 changes: 1 addition & 1 deletion deploy/QuoterV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ethers } from 'ethers'
import { HardhatRuntimeEnvironment } from 'hardhat/types'
import { DeployFunction } from 'hardhat-deploy/dist/types'

const func: DeployFunction = async function (hre: HardhatRuntimeEnviorment) {
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployments, getNamedAccounts, getChainId } = hre
const { deploy } = deployments

Expand Down
2 changes: 1 addition & 1 deletion deploy/SwapRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ethers } from 'ethers'
import { HardhatRuntimeEnvironment } from 'hardhat/types'
import { DeployFunction } from 'hardhat-deploy/dist/types'

const func: DeployFunction = async function (hre: HardhatRuntimeEnviorment) {
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployments, getNamedAccounts, getChainId } = hre
const { deploy } = deployments

Expand Down
32 changes: 32 additions & 0 deletions deploy/TestERC20.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { HardhatRuntimeEnvironment } from 'hardhat/types'
import { DeployFunction } from 'hardhat-deploy/dist/types'

const func: DeployFunction = async function ({
ethers,
getNamedAccounts,
deployments,
getChainId,
}: HardhatRuntimeEnvironment) {
const { deploy } = deployments

const { deployer } = await getNamedAccounts()

const existingDeployments = await deployments.all()
const n = Object.keys(existingDeployments).filter(key => key.startsWith('TestERC20')).length;
const nextDeployment = `TestERC20-${n}`

await deploy(nextDeployment, {
from: deployer,
// args from test/shared/completeFixture.ts
args: [ethers.constants.MaxUint256.div(2)],
log: true,
deterministicDeployment: false,
contract: 'TestERC20'
})
}

func.tags = ['TestERC20']

export default func

// Usage: yarn hardhat --network docker deploy --tags TestERC20
2 changes: 1 addition & 1 deletion deploy/V3Migrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ethers } from 'ethers'
import { HardhatRuntimeEnvironment } from 'hardhat/types'
import { DeployFunction } from 'hardhat-deploy/dist/types'

const func: DeployFunction = async function (hre: HardhatRuntimeEnviorment) {
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployments, getNamedAccounts, getChainId } = hre
const { deploy } = deployments

Expand Down
33 changes: 33 additions & 0 deletions deploy/WFIL.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { HardhatRuntimeEnvironment } from 'hardhat/types'
import { DeployFunction } from 'hardhat-deploy/dist/types'

import {
abi as WFIL_ABI,
bytecode as WFIL_BYTECODE,
} from '../test/contracts/WFIL.json'

const func: DeployFunction = async function ({
ethers,
getNamedAccounts,
deployments,
getChainId,
}: HardhatRuntimeEnvironment) {
const { deploy } = deployments

const { deployer } = await getNamedAccounts()

await deploy('WFIL', {
from: deployer,
args: [deployer],
log: true,
deterministicDeployment: false,
contract: {
abi: WFIL_ABI,
bytecode: WFIL_BYTECODE,
},
})
}

func.tags = ['WFIL']

export default func
5 changes: 5 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ task('add-fee-tier', 'Add fee tier')

export default {
networks: {
docker: {
url: process.env.ETH_RPC_ENDPOINT,
chainId: Number(process.env.CHAIN_ID),
accounts: [process.env.ACCOUNT_PRIVATE_KEY],
},
arbitrum: {
url: 'https://arb1.arbitrum.io/rpc',
accounts,
Expand Down
Loading