-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Ján Jakub Naništa <[email protected]>
- Loading branch information
1 parent
63231ac
commit 90363c7
Showing
12 changed files
with
277 additions
and
194 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
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
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
41 changes: 41 additions & 0 deletions
41
packages/ua-utils-evm-hardhat-test/test/task/getOAppConfig.test.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,41 @@ | ||
import { defaultExecutorConfig, defaultUlnConfig, setupDefaultEndpoint } from '../__utils__/endpoint' | ||
import { createContractFactory, getEidForNetworkName } from '@layerzerolabs/utils-evm-hardhat' | ||
import hre from 'hardhat' | ||
import { AddressZero } from '@ethersproject/constants' | ||
import { TASK_LZ_GET_OAPP_CONFIG } from '@layerzerolabs/ua-utils-evm-hardhat' | ||
|
||
describe('task: getOAppConfig', () => { | ||
beforeEach(async () => { | ||
await setupDefaultEndpoint() | ||
}) | ||
|
||
it('should return app default configurations when addresses are not oapps', async () => { | ||
const networks = Object.keys(hre.userConfig.networks ?? {}) | ||
const addresses = new Array(networks.length).fill(AddressZero).toString() | ||
const getDefaultConfigTask = await hre.run(TASK_LZ_GET_OAPP_CONFIG, { | ||
networks: networks.toString(), | ||
addresses: addresses.toString(), | ||
}) | ||
const contractFactory = createContractFactory() | ||
for (const localNetwork of networks) { | ||
const localEid = getEidForNetworkName(localNetwork) | ||
for (const remoteNetwork of networks) { | ||
if (localNetwork === remoteNetwork) continue | ||
|
||
const defaultConfig = getDefaultConfigTask[localNetwork][remoteNetwork] | ||
const sendUln302 = await contractFactory({ contractName: 'SendUln302', eid: localEid }) | ||
const receiveUln302 = await contractFactory({ contractName: 'ReceiveUln302', eid: localEid }) | ||
|
||
expect(defaultConfig.defaultSendLibrary).toEqual(sendUln302.contract.address) | ||
expect(defaultConfig.defaultReceiveLibrary).toEqual(receiveUln302.contract.address) | ||
expect(defaultConfig.sendExecutorConfig).toEqual(defaultExecutorConfig) | ||
expect(defaultConfig.sendUlnConfig).toEqual(defaultUlnConfig) | ||
expect(defaultConfig.receiveUlnConfig).toEqual(defaultUlnConfig) | ||
} | ||
} | ||
}) | ||
|
||
// TODO - app specific configuration testing | ||
// it('should return app specific configurations', async () => { | ||
// }) | ||
}) |
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 |
---|---|---|
@@ -1 +1,3 @@ | ||
export const TASK_LZ_WIRE_OAPP = 'lz:oapp:wire' | ||
export const TASK_LZ_GET_DEFAULT_CONFIG = 'lz:oapp:getDefaultConfig' | ||
export const TASK_LZ_GET_OAPP_CONFIG = 'lz:oapp:getOAppConfig' |
This file was deleted.
Oops, something went wrong.
118 changes: 0 additions & 118 deletions
118
packages/ua-utils-evm-hardhat/src/tasks/getDefaultConfig.ts
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,2 +1 @@ | ||
import './oapp' | ||
import './getDefaultConfig' |
50 changes: 50 additions & 0 deletions
50
packages/ua-utils-evm-hardhat/src/tasks/oapp/getDefaultConfig.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,50 @@ | ||
import { ActionType } from 'hardhat/types' | ||
import { task } from 'hardhat/config' | ||
import { getReceiveConfig, getSendConfig, printConsoleTable } from '@/utils/taskHelpers' | ||
import { TASK_LZ_GET_DEFAULT_CONFIG } from '@/constants' | ||
|
||
interface TaskArgs { | ||
networks: string | ||
} | ||
|
||
export const getDefaultConfig: ActionType<TaskArgs> = async (taskArgs) => { | ||
const networks = new Set(taskArgs.networks.split(',')) | ||
const configs: Record<string, Record<string, unknown>> = {} | ||
for (const localNetworkName of networks) { | ||
configs[localNetworkName] = {} | ||
for (const remoteNetworkName of networks) { | ||
if (remoteNetworkName === localNetworkName) continue | ||
const [sendLibrary, sendUlnConfig, sendExecutorConfig] = await getSendConfig( | ||
localNetworkName, | ||
remoteNetworkName | ||
) | ||
const [receiveLibrary, receiveUlnConfig] = await getReceiveConfig(localNetworkName, remoteNetworkName) | ||
|
||
configs[localNetworkName][remoteNetworkName] = { | ||
defaultSendLibrary: sendLibrary, | ||
defaultReceiveLibrary: receiveLibrary, | ||
sendUlnConfig, | ||
sendExecutorConfig, | ||
receiveUlnConfig, | ||
} | ||
|
||
printConsoleTable( | ||
localNetworkName, | ||
remoteNetworkName, | ||
sendLibrary, | ||
receiveLibrary, | ||
sendUlnConfig, | ||
sendExecutorConfig, | ||
receiveUlnConfig | ||
) | ||
} | ||
} | ||
return configs | ||
} | ||
|
||
task( | ||
TASK_LZ_GET_DEFAULT_CONFIG, | ||
'outputs the default Send and Receive Messaging Library versions and the default application config' | ||
) | ||
.addParam('networks', 'comma separated list of networks') | ||
.setAction(getDefaultConfig) |
Oops, something went wrong.