Skip to content

Commit

Permalink
feat: OmniCounter plus deployment code
Browse files Browse the repository at this point in the history
Options tests that utilize OmniCounter.sol will be added in a followup commit.

Signed-off-by: Ryan Goulding <[email protected]>
  • Loading branch information
ryandgoulding committed Dec 13, 2023
1 parent cf11969 commit 8fa5cb5
Show file tree
Hide file tree
Showing 5 changed files with 2,114 additions and 57 deletions.
8 changes: 8 additions & 0 deletions packages/ua-utils-evm-hardhat-test/contracts/OmniCounter.sol
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 packages/ua-utils-evm-hardhat-test/deploy/003_omnicounter.ts
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
1 change: 1 addition & 0 deletions packages/ua-utils-evm-hardhat-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"hardhat": "^2.19.2",
"hardhat-deploy": "^0.11.43",
"jest": "^29.7.0",
"solidity-bytes-utils": "^0.8.0",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
Expand Down
21 changes: 21 additions & 0 deletions packages/ua-utils-evm-hardhat-test/test/__utils__/omnicounter.ts
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')])
}
Loading

0 comments on commit 8fa5cb5

Please sign in to comment.