Skip to content

Commit

Permalink
adding readme
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderLiteplo committed Sep 5, 2024
1 parent 5e66d0e commit 8a603e5
Show file tree
Hide file tree
Showing 89 changed files with 26,231 additions and 863 deletions.
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,39 @@
# lif3-endpoint
Lif3's LayerZero Endpoint

## Deployment:
### V1 Endpoint:
cd to v1-endpoint-deployment
run:
pnpm install

npx hardhat deploy --network avalanche-testnet --tags PriceFeed
npx hardhat deploy --network avalanche-testnet --tags Endpoint
npx hardhat deploy --network avalanche-testnet --tags FPValidator
npx hardhat deploy --network avalanche-testnet --tags MPTValidator01
npx hardhat deploy --network avalanche-testnet --tags NonceContract
npx hardhat deploy --network avalanche-testnet --tags UltraLightNodeV2
npx hardhat deploy --network avalanche-testnet --tags TreasuryV2
npx hardhat deploy --network avalanche-testnet --tags RelayerV2

### V2 Endpoint:
cd to v2-endpoint-deployment
run:
pnpm install

npx hardhat deploy --network avalanche-testnet --tags EndpointV2
npx hardhat deploy --network avalanche-testnet --tags EndpointV2View
npx hardhat deploy --network avalanche-testnet --tags Treasury
npx hardhat deploy --network avalanche-testnet --tags SendUln302
npx hardhat deploy --network avalanche-testnet --tags ReceiveUln302
npx hardhat deploy --network avalanche-testnet --tags ReceiveUln302View
npx hardhat deploy --network avalanche-testnet --tags TreasuryFeeHandler
npx hardhat deploy --network avalanche-testnet --tags SendUln301
npx hardhat deploy --network avalanche-testnet --tags ReceiveUln301
npx hardhat deploy --network avalanche-testnet --tags ReceiveUln301View
npx hardhat deploy --network avalanche-testnet --tags DVNFeeLib
npx hardhat deploy --network avalanche-testnet --tags PriceFeed
npx hardhat deploy --network avalanche-testnet --tags DVN
npx hardhat deploy --network avalanche-testnet --tags ExecutorFeeLib
npx hardhat deploy --network avalanche-testnet --tags Executor
npx hardhat deploy --network avalanche-testnet --tags LzExecutor
Binary file removed deploy-scripts/LayerZeroV1/.DS_Store
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions v1-endpoint-deployment/deploy/Endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { HardhatRuntimeEnvironment } from 'hardhat/types'

module.exports = async function (hre: HardhatRuntimeEnvironment) {
const { deploy } = hre.deployments
const deployer = `0x462c2AE39B6B0bdB950Deb2BC82082308cF8cB10`
const { getNamedAccounts } = hre
const { deployer } = await getNamedAccounts()
console.log(`deployer: ${deployer}`)
const endpointId = 10106

Expand All @@ -14,7 +15,7 @@ module.exports = async function (hre: HardhatRuntimeEnvironment) {
args: [endpointId],
// if set it to true, will not attempt to deploy
// even if the contract deployed under the same name is different
skipIfAlreadyDeployed: true,
skipIfAlreadyDeployed: false,
log: true,
waitConfirmations: 1,
})
Expand Down
3 changes: 2 additions & 1 deletion v1-endpoint-deployment/deploy/FPValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { HardhatRuntimeEnvironment } from 'hardhat/types'

module.exports = async function (hre: HardhatRuntimeEnvironment) {
const { deploy } = hre.deployments
const deployer = `0x462c2AE39B6B0bdB950Deb2BC82082308cF8cB10`
const { getNamedAccounts } = hre
const { deployer } = await getNamedAccounts()
const endpointId = 10106

const bridgeAddr = constants.AddressZero
Expand Down
6 changes: 3 additions & 3 deletions v1-endpoint-deployment/deploy/MPTValidator01.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { HardhatRuntimeEnvironment } from 'hardhat/types'

module.exports = async function (hre: HardhatRuntimeEnvironment) {
const { deploy } = hre.deployments

const deployer = `0x462c2AE39B6B0bdB950Deb2BC82082308cF8cB10`
const { getNamedAccounts } = hre
const { deployer } = await getNamedAccounts()
const endpointId = 10106

const bridgeAddr = constants.AddressZero
Expand All @@ -26,7 +26,7 @@ module.exports = async function (hre: HardhatRuntimeEnvironment) {
args: [bridgeAddr, stgAddr],
log: true,
waitConfirmations: 1,
skipIfAlreadyDeployed: true,
skipIfAlreadyDeployed: false,
})
}
module.exports.tags = ['MPTValidator01', 'test']
10 changes: 3 additions & 7 deletions v1-endpoint-deployment/deploy/NonceContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import '@nomiclabs/hardhat-ethers'
import 'hardhat-deploy'
import { HardhatRuntimeEnvironment } from 'hardhat/types'


module.exports = async function ({ getNamedAccounts, deployments }: HardhatRuntimeEnvironment) {
const { deploy } = deployments
const deployer = `0x462c2AE39B6B0bdB950Deb2BC82082308cF8cB10`
const { deployer } = await getNamedAccounts()

const endpoint = await deployments.get('Endpoint')

Expand All @@ -14,14 +15,9 @@ module.exports = async function ({ getNamedAccounts, deployments }: HardhatRunti
args: [endpoint.address],
log: true,
waitConfirmations: 1,
skipIfAlreadyDeployed: true,
skipIfAlreadyDeployed: false,
})
}

// module.exports.skip = () =>
// new Promise(async (resolve) => {
// resolve(!isTestnet()) // skip it when its mainnet for now
// })

module.exports.tags = ['NonceContract', 'test', 'v2']
module.exports.dependencies = ['Endpoint']
22 changes: 1 addition & 21 deletions v1-endpoint-deployment/deploy/PriceFeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,13 @@ import '@nomiclabs/hardhat-ethers'
import 'hardhat-deploy'
import { HardhatRuntimeEnvironment } from 'hardhat/types'

// import { isLocalhost } from '@layerzerolabs/hardhat-config'
// import { Stage, networkToStage } from '@layerzerolabs/lz-definitions'

// const PRICE_UPDATER = {
// [Stage.SANDBOX]: '0x13B6B82D2f5E9b29fa453e3271cAB43Ced089800',
// [Stage.TESTNET]: '0xF5E8A439C599205C1aB06b535DE46681Aed1007a',
// [Stage.MAINNET]: '0x339d413CCEfD986b1B3647A9cfa9CBbE70A30749',
// }

module.exports = async function (hre: HardhatRuntimeEnvironment) {
const { deploy } = hre.deployments
// const { proxyAdmin } = await hre.getNamedAccounts()
const proxyAdmin = `0x462c2AE39B6B0bdB950Deb2BC82082308cF8cB10`
const relayer = `0x462c2AE39B6B0bdB950Deb2BC82082308cF8cB10`
const { proxyAdmin, relayer } = await hre.getNamedAccounts()

console.log(`Deployer: ${relayer}`)
console.log(`ProxyOwner: ${proxyAdmin}`)

// const priceUpdater = isLocalhost(hre.network.name)
// ? hre.ethers.constants.AddressZero
// : PRICE_UPDATER[networkToStage(hre.network.name)]
// console.log(priceUpdater)
const priceUpdater = hre.ethers.constants.AddressZero

await deploy('PriceFeed', {
Expand All @@ -50,8 +35,3 @@ module.exports = async function (hre: HardhatRuntimeEnvironment) {
})
}
module.exports.tags = ['PriceFeed', 'test']
// module.exports.skip = async ({ network }) =>
// new Promise((resolve) => {
// resolve(network.name !== 'hardhat')
// // only use for tests
// })
3 changes: 1 addition & 2 deletions v1-endpoint-deployment/deploy/TreasuryV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { HardhatRuntimeEnvironment } from 'hardhat/types'

module.exports = async function ({ getNamedAccounts, deployments }: HardhatRuntimeEnvironment) {
const { deploy } = deployments
const deployer = `0x462c2AE39B6B0bdB950Deb2BC82082308cF8cB10`
const { deployer } = await getNamedAccounts()

const ultraLightNodeV2 = await deployments.get('UltraLightNodeV2')

Expand All @@ -17,6 +17,5 @@ module.exports = async function ({ getNamedAccounts, deployments }: HardhatRunti
skipIfAlreadyDeployed: false,
})
}

module.exports.tags = ['TreasuryV2', 'test', 'v2']
module.exports.dependencies = ['UltraLightNodeV2']
12 changes: 4 additions & 8 deletions v1-endpoint-deployment/deploy/UltraLightNodeV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { HardhatRuntimeEnvironment } from 'hardhat/types'

module.exports = async function ({ getNamedAccounts, deployments, network }: HardhatRuntimeEnvironment) {
const { deploy } = deployments
const deployer = `0x462c2AE39B6B0bdB950Deb2BC82082308cF8cB10`
const { deployer } = await getNamedAccounts()

// get the Endpoint address
const endpoint = await deployments.get('Endpoint')
Expand All @@ -20,16 +20,12 @@ module.exports = async function ({ getNamedAccounts, deployments, network }: Har
args: [endpoint.address, nonceContract.address, localChainId],
// if set it to true, will not attempt to deploy
// even if the contract deployed under the same name is different
skipIfAlreadyDeployed: true,
skipIfAlreadyDeployed: false,
log: true,
waitConfirmations: 1,
})
}

// module.exports.skip = () =>
// new Promise(async (resolve) => {
// resolve(!isTestnet()) // skip it when its mainnet for now
// })

console.log(`address is ${address}`)
}
module.exports.tags = ['UltraLightNodeV2', 'test', 'v2']
module.exports.dependencies = ['Endpoint', 'NonceContract']
17 changes: 12 additions & 5 deletions v1-endpoint-deployment/deploy/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@ import { ethers } from 'ethers'
import { HardhatRuntimeEnvironment } from 'hardhat/types'

export function getPriceFeedV2Address(hre: HardhatRuntimeEnvironment): string {
// Read the endpoint-config.json file
const endpointConfig = JSON.parse(fs.readFileSync('./endpoint-config.json', 'utf-8'))
let networkName: string

// Get the networkName from endpoint-config.json
const networkName = endpointConfig[hre.network.name]?.name || hre.network.name
// Check if ./endpoint-config.json exists
if (fs.existsSync('./endpoint-config.json')) {
// Read the endpoint-config.json file
const endpointConfig = JSON.parse(fs.readFileSync('./endpoint-config.json', 'utf-8'))
// Get the networkName from endpoint-config.json
networkName = endpointConfig[hre.network.name]?.name || hre.network.name
} else {
// If file doesn't exist, set network name to hre.network.name
networkName = hre.network.name
}

if (hre.network.name === 'hardhat') {
return ethers.constants.AddressZero
Expand All @@ -21,4 +28,4 @@ export function getPriceFeedV2Address(hre: HardhatRuntimeEnvironment): string {
console.error(`Error reading PriceFeed.json for network ${networkName}:`, error)
return ethers.constants.AddressZero
}
}
}
Loading

0 comments on commit 8a603e5

Please sign in to comment.