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

🪚 OmniGraph™ renaming endpointId to eid #50

Merged
merged 1 commit into from
Nov 30, 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
4 changes: 2 additions & 2 deletions packages/ua-utils-evm-hardhat-test/deploy/001_bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import assert from 'assert'
* @param env `HardhatRuntimeEnvironment`
*/
const deploy: DeployFunction = async ({ getUnnamedAccounts, deployments, network }) => {
assert(network.config.endpointId != null, `Missing endpoint ID for network ${network.name}`)
assert(network.config.eid != null, `Missing endpoint ID for network ${network.name}`)

const [deployer] = await getUnnamedAccounts()
assert(deployer, 'Missing deployer')

const endpointV2Deployment = await deployments.deploy('EndpointV2', {
from: deployer,
args: [network.config.endpointId, AddressZero],
args: [network.config.eid, AddressZero],
})

const uln302Deployment = await deployments.deploy('UltraLightNode302', {
Expand Down
4 changes: 2 additions & 2 deletions packages/ua-utils-evm-hardhat-test/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ const config: HardhatUserConfig = {
},
},
vengaboys: {
endpointId: EndpointId.ETHEREUM_MAINNET,
eid: EndpointId.ETHEREUM_MAINNET,
url: 'http://network-vengaboys:8545',
accounts: {
mnemonic: MNEMONIC,
},
},
britney: {
endpointId: EndpointId.AVALANCHE_MAINNET,
eid: EndpointId.AVALANCHE_MAINNET,
url: 'http://network-britney:8545',
accounts: {
mnemonic: MNEMONIC,
Expand Down
6 changes: 3 additions & 3 deletions packages/ua-utils-evm-hardhat-test/test/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ describe('config', () => {

it('should have an endpoint deployed', async () => {
const endpoint = await environment.ethers.getContract('EndpointV2')
const endpointId = await endpoint.eid()
const eid = await endpoint.eid()

expect(environment.network.config.endpointId).to.be.a('number')
expect(endpointId).to.eql(environment.network.config.endpointId)
expect(environment.network.config.eid).to.be.a('number')
expect(eid).to.eql(environment.network.config.eid)
})
})
})
Expand Down
2 changes: 1 addition & 1 deletion packages/ua-utils-evm-hardhat/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { HardhatUserConfig } from 'hardhat/types'
const config: HardhatUserConfig = {
networks: {
withEndpointId: {
endpointId: EndpointId.ETHEREUM_MAINNET,
eid: EndpointId.ETHEREUM_MAINNET,
url: 'no:///way',
saveDeployments: false,
},
Expand Down
4 changes: 2 additions & 2 deletions packages/utils-evm-hardhat/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ const config: HardhatUserConfig = {
'ethereum-mainnet': {
url: 'https://eth.llamarpc.com',
saveDeployments: true,
endpointId: EndpointId.ETHEREUM_MAINNET,
eid: EndpointId.ETHEREUM_MAINNET,
},
'ethereum-testnet': {
url: 'https://eth-goerli.public.blastapi.io',
endpointId: EndpointId.ETHEREUM_TESTNET,
eid: EndpointId.ETHEREUM_TESTNET,
},
'bsc-testnet': {
url: 'https://bsc-testnet.publicnode.com',
Expand Down
18 changes: 9 additions & 9 deletions packages/utils-evm-hardhat/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ const resolvePackageDirectory = (packageName: string): string => {
* const config: HardhatUserConfig = {
* networks: {
* arbitrum: {
* endpointId: EndpointId.ARBITRUM_MAINNET
* eid: EndpointId.ARBITRUM_MAINNET
* },
* fuji: {
* endpointId: EndpointId.AVALANCHE_TESTNET
* eid: EndpointId.AVALANCHE_TESTNET
* }
* }
* }
Expand Down Expand Up @@ -61,11 +61,11 @@ export const withLayerZeroDeployments = (...packageNames: string[]) => {
// Now for the meat of the operation, we'll enrich the external.deployments object
deployments: Object.fromEntries(
Object.entries(config.networks ?? {}).flatMap(([networkName, networkConfig]) => {
const endpointId = networkConfig?.endpointId
const eid = networkConfig?.eid
const networkLogger = createNetworkLogger(networkName)

// Let's first check whether endpointId is defined on the network config
if (endpointId == null) {
// Let's first check whether eid is defined on the network config
if (eid == null) {
networkLogger.debug(
'Endpoint ID not specified in hardhat config, skipping external deployment configuration'
)
Expand All @@ -75,7 +75,7 @@ export const withLayerZeroDeployments = (...packageNames: string[]) => {

try {
// This operation is unsafe and can throw - let's make sure we don't explode with some unreadable error
const layerZeroNetworkName = endpointIdToNetwork(endpointId)
const layerZeroNetworkName = endpointIdToNetwork(eid)
const layerZeroNetworkDeploymentsDirectories = resolvedDeploymentsDirectories.map(
(deploymentsDirectory) => join(deploymentsDirectory, layerZeroNetworkName)
)
Expand All @@ -99,7 +99,7 @@ export const withLayerZeroDeployments = (...packageNames: string[]) => {
]
} catch (error) {
networkLogger.error(
`Invalid endpoint ID specified in hardhat config (${endpointId}), skipping external deployment configuration`
`Invalid endpoint ID specified in hardhat config (${eid}), skipping external deployment configuration`
)

return []
Expand All @@ -121,10 +121,10 @@ export const withLayerZeroDeployments = (...packageNames: string[]) => {
* const config: HardhatUserConfig = {
* networks: {
* arbitrum: {
* endpointId: EndpointId.ARBITRUM_MAINNET
* eid: EndpointId.ARBITRUM_MAINNET
* },
* fuji: {
* endpointId: EndpointId.AVALANCHE_TESTNET
* eid: EndpointId.AVALANCHE_TESTNET
* }
* }
* }
Expand Down
6 changes: 3 additions & 3 deletions packages/utils-evm-hardhat/src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export const createNetworkEnvironmentFactory = (
* Creates a mapping between EndpointId and network name
* based on the hardhat project configuration.
*
* It will silently ignore networks that don't have `endpointId`
* It will silently ignore networks that don't have `eid`
* specified in their network configuration.
*
* @param hre `HardhatRuntimeEnvironment`
Expand All @@ -132,9 +132,9 @@ export const getNetworkNamesByEid = (

return new Map(
networks.flatMap(([networkName, networkConfig]) => {
if (networkConfig.endpointId == null) return []
if (networkConfig.eid == null) return []

return [[networkConfig.endpointId, networkName]]
return [[networkConfig.eid, networkName]]
})
)
}
8 changes: 4 additions & 4 deletions packages/utils-evm-hardhat/src/type-extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import { EndpointId } from '@layerzerolabs/lz-definitions'

declare module 'hardhat/types/config' {
interface HardhatNetworkUserConfig {
endpointId?: never
eid?: never
}

interface HardhatNetworkConfig {
endpointId?: never
eid?: never
}

interface HttpNetworkUserConfig {
endpointId?: EndpointId
eid?: EndpointId
}

interface HttpNetworkConfig {
endpointId?: EndpointId
eid?: EndpointId
}
}
16 changes: 8 additions & 8 deletions packages/utils-evm-hardhat/test/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('config', () => {
})
})

it('should not add external deployments for networks without endpointId', () => {
it('should not add external deployments for networks without eid', () => {
const config = {
networks: {
'vengaboys-testnet': {},
Expand All @@ -37,19 +37,19 @@ describe('config', () => {
})
})

it('should not add external deployments for networks with invalid endpointId', () => {
it('should not add external deployments for networks with invalid eid', () => {
const config = {
networks: {
'vengaboys-testnet': {
endpointId: 0,
eid: 0,
},
},
}

expect(withLayerZeroDeployments('@layerzerolabs/lz-evm-sdk-v1')(config)).to.eql({
networks: {
'vengaboys-testnet': {
endpointId: 0,
eid: 0,
},
},
external: {
Expand All @@ -62,15 +62,15 @@ describe('config', () => {
const config = {
networks: {
'vengaboys-testnet': {
endpointId: EndpointId.ARBITRUM_MAINNET,
eid: EndpointId.ARBITRUM_MAINNET,
},
},
}

expect(withLayerZeroDeployments('@layerzerolabs/lz-evm-sdk-v1')(config)).to.eql({
networks: {
'vengaboys-testnet': {
endpointId: EndpointId.ARBITRUM_MAINNET,
eid: EndpointId.ARBITRUM_MAINNET,
},
},
external: {
Expand All @@ -85,7 +85,7 @@ describe('config', () => {
const config = {
networks: {
'vengaboys-testnet': {
endpointId: EndpointId.BSC_TESTNET,
eid: EndpointId.BSC_TESTNET,
},
},
}
Expand All @@ -99,7 +99,7 @@ describe('config', () => {
expect(configWithSomePathAgain).to.eql({
networks: {
'vengaboys-testnet': {
endpointId: EndpointId.BSC_TESTNET,
eid: EndpointId.BSC_TESTNET,
},
},
external: {
Expand Down