-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: OmniCounter plus deployment code
Options tests that utilize OmniCounter.sol will be added in a followup commit. Signed-off-by: Ryan Goulding <[email protected]>
- Loading branch information
1 parent
cf11969
commit 8fa5cb5
Showing
5 changed files
with
2,114 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.22; | ||
|
||
import { OmniCounter as OmniCounterImpl } from "@layerzerolabs/lz-evm-oapp-v2/contracts/oapp/examples/OmniCounter.sol"; | ||
|
||
contract OmniCounter is OmniCounterImpl { | ||
constructor(address _endpoint, address _owner) OmniCounterImpl(_endpoint, _owner) {} | ||
} |
33 changes: 33 additions & 0 deletions
33
packages/ua-utils-evm-hardhat-test/deploy/003_omnicounter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { formatEid } from '@layerzerolabs/utils' | ||
import { type DeployFunction } from 'hardhat-deploy/types' | ||
import assert from 'assert' | ||
|
||
/** | ||
* This deploy function will deploy and configure LayerZero OmniCounter | ||
* | ||
* @param env `HardhatRuntimeEnvironment` | ||
*/ | ||
const deploy: DeployFunction = async ({ getUnnamedAccounts, deployments, network }) => { | ||
assert(network.config.eid != null, `Missing endpoint ID for network ${network.name}`) | ||
|
||
const [deployer] = await getUnnamedAccounts() | ||
assert(deployer, 'Missing deployer') | ||
|
||
await deployments.delete('OmniCounter') | ||
const endpointV2 = await deployments.get('EndpointV2') | ||
const omniCounterDeployment = await deployments.deploy('OmniCounter', { | ||
contract: 'contracts/OmniCounter.sol:OmniCounter', | ||
from: deployer, | ||
args: [endpointV2.address, deployer], | ||
}) | ||
|
||
console.table({ | ||
Network: `${network.name} (endpoint ${formatEid(network.config.eid)})`, | ||
OmniCounter: omniCounterDeployment.address, | ||
}) | ||
} | ||
|
||
deploy.tags = ['OmniCounter'] | ||
deploy.dependencies = ['Bootstrap'] | ||
|
||
export default deploy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
packages/ua-utils-evm-hardhat-test/test/__utils__/omnicounter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { EndpointId } from '@layerzerolabs/lz-definitions' | ||
import { createNetworkEnvironmentFactory } from '@layerzerolabs/utils-evm-hardhat' | ||
|
||
export const deployOmniCounter = async () => { | ||
const environmentFactory = createNetworkEnvironmentFactory() | ||
const eth = await environmentFactory(EndpointId.ETHEREUM_MAINNET) | ||
const avax = await environmentFactory(EndpointId.AVALANCHE_MAINNET) | ||
|
||
await Promise.all([ | ||
eth.deployments.run('OmniCounter', { writeDeploymentsToFiles: true }), | ||
avax.deployments.run('OmniCounter', { writeDeploymentsToFiles: true }), | ||
]) | ||
} | ||
|
||
export const deployOmniCounterFixture = async () => { | ||
const environmentFactory = createNetworkEnvironmentFactory() | ||
const eth = await environmentFactory(EndpointId.ETHEREUM_MAINNET) | ||
const avax = await environmentFactory(EndpointId.AVALANCHE_MAINNET) | ||
|
||
await Promise.all([eth.deployments.fixture('OmniCounter'), avax.deployments.fixture('OmniCounter')]) | ||
} |
Oops, something went wrong.