Skip to content

Commit

Permalink
Merge pull request #1565 from thesandboxgame/lz-deploy
Browse files Browse the repository at this point in the history
LayerZero deployment to Base and BSC
  • Loading branch information
wojciech-turek authored Aug 9, 2024
2 parents cebea00 + b1a1e86 commit c2319b4
Show file tree
Hide file tree
Showing 17 changed files with 16,775 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {deployments, getNamedAccounts} = hre;
Expand Down
2 changes: 1 addition & 1 deletion packages/deploy/deploy/800_oft_sand/801_deploy_oft_sand.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {deployments, getNamedAccounts} = hre;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {ethers} from 'ethers';
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {ethers} from 'ethers';
import {DEPLOY_NETWORKS} from '../../hardhat.config';

const func: DeployFunction = async function (
hre: HardhatRuntimeEnvironment
Expand All @@ -11,22 +12,24 @@ const func: DeployFunction = async function (

let eidBase, eidBsc;

if (hre.network.name == 'mainnnet') {
if (hre.network.name == 'mainnet') {
eidBase = process.env[`EID_${'BASE'}`];
eidBsc = process.env[`EID_${'BSCMAINNET'}`];
} else if (hre.network.name == 'sepolia') {
eidBase = process.env[`EID_${'BASESEPOLIA'}`];
eidBsc = process.env[`EID_${'BSCTESTNET'}`];
} else {
} else if (hre.network.name == 'hardhat') {
eidBsc = 0;
eidBase = 0;
} else {
throw new Error('Cannot find EID for network');
}

const hreBase = hre.companionNetworks.base;
const hreBase = hre.companionNetworks[DEPLOY_NETWORKS.BASE_MAINNET];
const deploymentsBase = hreBase.deployments;
const OFTSandBase = await deploymentsBase.getOrNull('OFTSand');

const hreBsc = hre.companionNetworks.bscMainnet;
const hreBsc = hre.companionNetworks[DEPLOY_NETWORKS.BSC_MAINNET];
const deploymentsBsc = hreBsc.deployments;
const OFTSandBsc = await deploymentsBsc.getOrNull('OFTSand');

Expand Down
16 changes: 9 additions & 7 deletions packages/deploy/deploy/800_oft_sand/803_oft_sand_setup_base.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {ethers} from 'ethers';
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {ethers} from 'ethers';
import {DEPLOY_NETWORKS} from '../../hardhat.config';

const func: DeployFunction = async function (
hre: HardhatRuntimeEnvironment
Expand All @@ -17,30 +18,31 @@ const func: DeployFunction = async function (
} else if (hre.network.name == 'baseSepolia') {
eidEthereum = process.env[`EID_${'SEPOLIA'}`];
eidBsc = process.env[`EID_${'BSCTESTNET'}`];
} else {
} else if (hre.network.name == 'hardhat') {
eidEthereum = 0;
eidBsc = 0;
} else {
throw new Error('Cannot find EID for network');
}

const hreEthereum = hre.companionNetworks.mainnet;
const hreEthereum = hre.companionNetworks[DEPLOY_NETWORKS.ETH_MAINNET];
const deploymentsEthereum = hreEthereum.deployments;
const OFTAdapterForSand = await deploymentsEthereum.getOrNull(
'OFTAdapterForSand'
);

const hreBsc = hre.companionNetworks.bscMainnet;
const hreBsc = hre.companionNetworks[DEPLOY_NETWORKS.BSC_MAINNET];
const deploymentsBsc = hreBsc.deployments;
const OFTSandBsc = await deploymentsBsc.getOrNull('OFTSand');

if (OFTAdapterForSand && OFTSandBsc) {
const isPeerForEthereum = await read(
'OFTAdapterForSand',
'OFTSand',
'isPeer',
eidEthereum,
ethers.zeroPadValue(OFTAdapterForSand.address, 32)
);
if (!isPeerForEthereum) {
// setting OFTAdapterForSand as peer to OFTSand(base) using eidEthereum
await execute(
'OFTSand',
{from: deployer, log: true},
Expand All @@ -51,7 +53,7 @@ const func: DeployFunction = async function (
}

const isPeerForBsc = await read(
'OFTAdapterForSand',
'OFTSand',
'isPeer',
eidBsc,
ethers.zeroPadValue(OFTSandBsc.address, 32)
Expand Down
15 changes: 9 additions & 6 deletions packages/deploy/deploy/800_oft_sand/804_oft_sand_setup_bsc.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {ethers} from 'ethers';
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {ethers} from 'ethers';
import {DEPLOY_NETWORKS} from '../../hardhat.config';

const func: DeployFunction = async function (
hre: HardhatRuntimeEnvironment
Expand All @@ -17,24 +18,26 @@ const func: DeployFunction = async function (
} else if (hre.network.name == 'bscTestnet') {
eidEthereum = process.env[`EID_${'SEPOLIA'}`];
eidBase = process.env[`EID_${'BASESEPOLIA'}`];
} else {
} else if (hre.network.name == 'hardhat') {
eidEthereum = 0;
eidBase = 0;
} else {
throw new Error('Cannot find EID for network');
}

const hreEthereum = hre.companionNetworks.mainnet;
const hreEthereum = hre.companionNetworks[DEPLOY_NETWORKS.ETH_MAINNET];
const deploymentsEthereum = hreEthereum.deployments;
const OFTAdapterForSand = await deploymentsEthereum.getOrNull(
'OFTAdapterForSand'
);

const hreBase = hre.companionNetworks.base;
const hreBase = hre.companionNetworks[DEPLOY_NETWORKS.BASE_MAINNET];
const deploymentsBase = hreBase.deployments;
const OFTSandBase = await deploymentsBase.getOrNull('OFTSand');

if (OFTAdapterForSand && OFTSandBase) {
const isPeerForEthereum = await read(
'OFTAdapterForSand',
'OFTSand',
'isPeer',
eidEthereum,
ethers.zeroPadValue(OFTAdapterForSand.address, 32)
Expand All @@ -51,7 +54,7 @@ const func: DeployFunction = async function (
}

const isPeerForBase = await read(
'OFTAdapterForSand',
'OFTSand',
'isPeer',
eidBase,
ethers.zeroPadValue(OFTSandBase.address, 32)
Expand Down
2 changes: 1 addition & 1 deletion packages/deploy/deploy_mocks/1000_deploy_lz_endpoint.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {deployments, getNamedAccounts} = hre;
Expand Down
Loading

0 comments on commit c2319b4

Please sign in to comment.