From 90363c76a98fa34429ad5192b9a746e6c91ae465 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?lz=2Esir=CE=94rthurmoney=28=29?= <95722332+sirarthurmoney@users.noreply.github.com> Date: Fri, 8 Dec 2023 17:57:52 -0800 Subject: [PATCH] adding getOAppConfig MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Ján Jakub Naništa --- .../protocol-utils-evm/src/endpoint/sdk.ts | 8 ++ packages/protocol-utils/src/endpoint/types.ts | 3 + .../test/task/getDefaultConfig.test.ts | 31 +---- .../test/task/getOAppConfig.test.ts | 41 ++++++ .../src/constants/tasks.ts | 2 + .../src/tasks/getConfig.ts | 50 -------- .../src/tasks/getDefaultConfig.ts | 118 ------------------ .../ua-utils-evm-hardhat/src/tasks/index.ts | 1 - .../src/tasks/oapp/getDefaultConfig.ts | 50 ++++++++ .../src/tasks/oapp/getOAppConfig.ts | 61 +++++++++ .../src/tasks/oapp/index.ts | 2 + .../src/utils/taskHelpers.ts | 104 +++++++++++++++ 12 files changed, 277 insertions(+), 194 deletions(-) create mode 100644 packages/ua-utils-evm-hardhat-test/test/task/getOAppConfig.test.ts delete mode 100644 packages/ua-utils-evm-hardhat/src/tasks/getConfig.ts delete mode 100644 packages/ua-utils-evm-hardhat/src/tasks/getDefaultConfig.ts create mode 100644 packages/ua-utils-evm-hardhat/src/tasks/oapp/getDefaultConfig.ts create mode 100644 packages/ua-utils-evm-hardhat/src/tasks/oapp/getOAppConfig.ts create mode 100644 packages/ua-utils-evm-hardhat/src/utils/taskHelpers.ts diff --git a/packages/protocol-utils-evm/src/endpoint/sdk.ts b/packages/protocol-utils-evm/src/endpoint/sdk.ts index 3db2dc705..6c5e5a562 100644 --- a/packages/protocol-utils-evm/src/endpoint/sdk.ts +++ b/packages/protocol-utils-evm/src/endpoint/sdk.ts @@ -10,6 +10,14 @@ export class Endpoint implements IEndpoint { return ignoreZero(await this.contract.contract.defaultReceiveLibrary(eid)) } + async getSendLibrary(sender: Address, dstEid: EndpointId): Promise { + return ignoreZero(await this.contract.contract.getSendLibrary(sender, dstEid)) + } + + async getReceiveLibrary(receiver: Address, srcEid: EndpointId): Promise<[string | undefined, boolean]> { + return await this.contract.contract.getReceiveLibrary(receiver, srcEid) + } + async setDefaultReceiveLibrary( eid: EndpointId, lib: string | null | undefined, diff --git a/packages/protocol-utils/src/endpoint/types.ts b/packages/protocol-utils/src/endpoint/types.ts index d3f8ec1f5..4ece6a499 100644 --- a/packages/protocol-utils/src/endpoint/types.ts +++ b/packages/protocol-utils/src/endpoint/types.ts @@ -14,6 +14,9 @@ export interface IEndpoint { isRegisteredLibrary(lib: Address): Promise registerLibrary(lib: Address): Promise + + getSendLibrary(sender: Address, dstEid: EndpointId): Promise + getReceiveLibrary(receiver: Address, srcEid: EndpointId): Promise<[string | undefined, boolean]> } export interface EndpointEdgeConfig { diff --git a/packages/ua-utils-evm-hardhat-test/test/task/getDefaultConfig.test.ts b/packages/ua-utils-evm-hardhat-test/test/task/getDefaultConfig.test.ts index 0fd6631bc..59ae0006d 100644 --- a/packages/ua-utils-evm-hardhat-test/test/task/getDefaultConfig.test.ts +++ b/packages/ua-utils-evm-hardhat-test/test/task/getDefaultConfig.test.ts @@ -1,6 +1,7 @@ import { defaultExecutorConfig, defaultUlnConfig, setupDefaultEndpoint } from '../__utils__/endpoint' import { createContractFactory, getEidForNetworkName } from '@layerzerolabs/utils-evm-hardhat' import hre from 'hardhat' +import { TASK_LZ_GET_DEFAULT_CONFIG } from '@layerzerolabs/ua-utils-evm-hardhat' describe('task: getDefaultConfig', () => { beforeEach(async () => { @@ -9,42 +10,22 @@ describe('task: getDefaultConfig', () => { it('should return default configurations', async () => { const networks = Object.keys(hre.userConfig.networks ?? {}) - const getDefaultConfigTask = await hre.run('getDefaultConfig', { networks: networks.toString() }) + const getDefaultConfigTask = await hre.run(TASK_LZ_GET_DEFAULT_CONFIG, { networks: networks.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 }) - // verify defaultSendLibrary & defaultReceiveLibrary expect(defaultConfig.defaultSendLibrary).toEqual(sendUln302.contract.address) expect(defaultConfig.defaultReceiveLibrary).toEqual(receiveUln302.contract.address) - - // verify sendUln - expect(defaultConfig.sendExecutorConfig.maxMessageSize).toEqual(defaultExecutorConfig.maxMessageSize) - expect(defaultConfig.sendExecutorConfig.executor).toEqual(defaultExecutorConfig.executor) - expect(defaultConfig.sendUlnConfig.confirmations.toString()).toEqual( - defaultUlnConfig.confirmations.toString() - ) - expect(defaultConfig.sendUlnConfig.optionalDVNThreshold).toEqual(defaultUlnConfig.optionalDVNThreshold) - expect(defaultConfig.sendUlnConfig.requiredDVNs).toEqual(defaultUlnConfig.requiredDVNs) - expect(defaultConfig.sendUlnConfig.optionalDVNs).toEqual(defaultUlnConfig.optionalDVNs) - - // verify receiveUln - expect(defaultConfig.receiveUlnConfig.confirmations.toString()).toEqual( - defaultUlnConfig.confirmations.toString() - ) - expect(defaultConfig.receiveUlnConfig.optionalDVNThreshold).toEqual( - defaultUlnConfig.optionalDVNThreshold - ) - expect(defaultConfig.receiveUlnConfig.requiredDVNs).toEqual(defaultUlnConfig.requiredDVNs) - expect(defaultConfig.receiveUlnConfig.optionalDVNs).toEqual(defaultUlnConfig.optionalDVNs) + expect(defaultConfig.sendExecutorConfig).toEqual(defaultExecutorConfig) + expect(defaultConfig.sendUlnConfig).toEqual(defaultUlnConfig) + expect(defaultConfig.receiveUlnConfig).toEqual(defaultUlnConfig) } } }) diff --git a/packages/ua-utils-evm-hardhat-test/test/task/getOAppConfig.test.ts b/packages/ua-utils-evm-hardhat-test/test/task/getOAppConfig.test.ts new file mode 100644 index 000000000..5b2e9256f --- /dev/null +++ b/packages/ua-utils-evm-hardhat-test/test/task/getOAppConfig.test.ts @@ -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 () => { + // }) +}) diff --git a/packages/ua-utils-evm-hardhat/src/constants/tasks.ts b/packages/ua-utils-evm-hardhat/src/constants/tasks.ts index 459873c6c..b42de0672 100644 --- a/packages/ua-utils-evm-hardhat/src/constants/tasks.ts +++ b/packages/ua-utils-evm-hardhat/src/constants/tasks.ts @@ -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' diff --git a/packages/ua-utils-evm-hardhat/src/tasks/getConfig.ts b/packages/ua-utils-evm-hardhat/src/tasks/getConfig.ts deleted file mode 100644 index 96f36e8b2..000000000 --- a/packages/ua-utils-evm-hardhat/src/tasks/getConfig.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { getDeploymentAddresses, getApplicationConfig, getEndpointAddress } from '@/utils/crossChainHelper' -import { ENDPOINT_ABI, MESSAGING_LIBRARY_ABI } from '@/constants/abi' -import { logError } from '@/utils/helpers' - -export default async (taskArgs: any, hre: any) => { - const network = hre.network.name - const remoteNetworks = taskArgs.remoteNetworks.split(',') - const contractName = taskArgs.name - let contractAddress = taskArgs.address - - if (!contractName && !contractAddress) { - logError('Provide contract name or address') - return - } - - if (contractName && !contractAddress) { - contractAddress = getDeploymentAddresses(network, false)[contractName] - if (!contractAddress) { - logError(`Deployment information isn't found for ${contractName}`) - return - } - } - - const endpoint = await hre.ethers.getContractAt(ENDPOINT_ABI, getEndpointAddress(network)) - const appConfig = await endpoint.uaConfigLookup(contractAddress) - const sendVersion = appConfig.sendVersion - const receiveVersion = appConfig.receiveVersion - const sendLibraryAddress = sendVersion === 0 ? await endpoint.defaultSendLibrary() : appConfig.sendLibrary - const sendLibrary = await hre.ethers.getContractAt(MESSAGING_LIBRARY_ABI, sendLibraryAddress) - let receiveLibrary: any - - if (sendVersion !== receiveVersion) { - const receiveLibraryAddress = - receiveVersion === 0 ? await endpoint.defaultReceiveLibraryAddress() : appConfig.receiveLibraryAddress - receiveLibrary = await hre.ethers.getContractAt(MESSAGING_LIBRARY_ABI, receiveLibraryAddress) - } - - const remoteConfig: any[] = await Promise.all( - remoteNetworks.map(async (remoteNetwork: string) => { - if (network === remoteNetwork) return - return await getApplicationConfig(remoteNetwork, sendLibrary, receiveLibrary, contractAddress) - }) - ) - - console.log('Network ', network) - console.log('Application address', contractAddress) - console.log('Send version ', sendVersion) - console.log('Receive version ', receiveVersion) - console.table(remoteConfig) -} diff --git a/packages/ua-utils-evm-hardhat/src/tasks/getDefaultConfig.ts b/packages/ua-utils-evm-hardhat/src/tasks/getDefaultConfig.ts deleted file mode 100644 index c33bac58b..000000000 --- a/packages/ua-utils-evm-hardhat/src/tasks/getDefaultConfig.ts +++ /dev/null @@ -1,118 +0,0 @@ -import { ActionType } from 'hardhat/types' -import { task } from 'hardhat/config' -import { createConnectedContractFactory, getEidForNetworkName } from '@layerzerolabs/utils-evm-hardhat' -import { Endpoint, Uln302 } from '@layerzerolabs/protocol-utils-evm' - -interface TaskArgs { - networks: string -} - -export const getDefaultConfig: ActionType = async (taskArgs) => { - const networks = new Set(taskArgs.networks.split(',')) - const contractFactory = createConnectedContractFactory() - const configs: Record> = {} - - for (const localNetworkName of networks) { - const localEid = getEidForNetworkName(localNetworkName) - const localEndpointSDK = new Endpoint(await contractFactory({ eid: localEid, contractName: 'EndpointV2' })) - - configs[localNetworkName] = {} - - for (const remoteNetworkName of networks) { - if (remoteNetworkName === localNetworkName) continue - - const remoteEid = getEidForNetworkName(remoteNetworkName) - - // First we get the SDK for the local send library - const defaultSendLibrary = await localEndpointSDK.defaultSendLibrary(remoteEid) - const localSendUlnSDK = new Uln302( - await contractFactory({ eid: localEid, contractName: 'SendUln302', address: defaultSendLibrary }) - ) - - // Then we get the SDK for the local receive library - const defaultReceiveLibrary = await localEndpointSDK.defaultReceiveLibrary(remoteEid) - const localReceiveUlnSDK = new Uln302( - await contractFactory({ eid: localEid, contractName: 'ReceiveUln302', address: defaultReceiveLibrary }) - ) - - // Now let's get the configs - const sendUlnConfig = await localSendUlnSDK.getUlnConfig(remoteEid) - const sendExecutorConfig = await localSendUlnSDK.getExecutorConfig(remoteEid) - const receiveUlnConfig = await localReceiveUlnSDK.getUlnConfig(remoteEid) - - configs[localNetworkName][remoteNetworkName] = { - defaultSendLibrary: defaultSendLibrary, - defaultReceiveLibrary: defaultReceiveLibrary, - sendUlnConfig, - sendExecutorConfig, - receiveUlnConfig, - } - - printConsoleTable( - localNetworkName, - remoteNetworkName, - defaultSendLibrary, - defaultReceiveLibrary, - sendUlnConfig, - sendExecutorConfig, - receiveUlnConfig - ) - } - } - return configs -} - -task( - 'getDefaultConfig', - 'outputs the default Send and Receive Messaging Library versions and the default application config' -) - .addParam('networks', 'comma separated list of networks') - .setAction(getDefaultConfig) - -const printConsoleTable = ( - localNetworkName: string, - remoteNetworkName: string, - defaultSendLibrary: string, - defaultReceiveLibrary: string, - sendUlnConfig: Record, - sendExecutorConfig: Record, - receiveUlnConfig: Record -) => { - const defaultLibraryTable = { - network: localNetworkName, - remoteNetwork: remoteNetworkName, - defaultSendLibrary: defaultSendLibrary, - defaultReceiveLibrary: defaultReceiveLibrary, - } - - const sendUln = { - maxMessageSize: sendExecutorConfig.maxMessageSize, - executor: sendExecutorConfig.executor, - confirmations: parseInt(sendUlnConfig.confirmations.toString()), - optionalDVNThreshold: sendUlnConfig.optionalDVNThreshold, - requiredDVNs: sendUlnConfig.requiredDVNs, - optionalDVNs: sendUlnConfig.optionalDVNs, - } - - const receiveUln = { - confirmations: parseInt(receiveUlnConfig.confirmations.toString()), - optionalDVNThreshold: receiveUlnConfig.optionalDVNThreshold, - requiredDVNs: receiveUlnConfig.requiredDVNs, - optionalDVNs: receiveUlnConfig.optionalDVNs, - } - - const sendUlnConfigTable = { - sendUln: sendUln, - } - - const receiveUlnConfigTable = { - receiveUln: receiveUln, - } - - console.log(`************************************************`) - console.log(`${localNetworkName.toUpperCase()}`) - console.log(`************************************************`) - console.table(defaultLibraryTable) - console.table(sendUlnConfigTable) - console.table(receiveUlnConfigTable) -} diff --git a/packages/ua-utils-evm-hardhat/src/tasks/index.ts b/packages/ua-utils-evm-hardhat/src/tasks/index.ts index be8df89d5..2ea670c16 100644 --- a/packages/ua-utils-evm-hardhat/src/tasks/index.ts +++ b/packages/ua-utils-evm-hardhat/src/tasks/index.ts @@ -1,2 +1 @@ import './oapp' -import './getDefaultConfig' diff --git a/packages/ua-utils-evm-hardhat/src/tasks/oapp/getDefaultConfig.ts b/packages/ua-utils-evm-hardhat/src/tasks/oapp/getDefaultConfig.ts new file mode 100644 index 000000000..6ba413bd1 --- /dev/null +++ b/packages/ua-utils-evm-hardhat/src/tasks/oapp/getDefaultConfig.ts @@ -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 = async (taskArgs) => { + const networks = new Set(taskArgs.networks.split(',')) + const configs: Record> = {} + 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) diff --git a/packages/ua-utils-evm-hardhat/src/tasks/oapp/getOAppConfig.ts b/packages/ua-utils-evm-hardhat/src/tasks/oapp/getOAppConfig.ts new file mode 100644 index 000000000..40cf8db19 --- /dev/null +++ b/packages/ua-utils-evm-hardhat/src/tasks/oapp/getOAppConfig.ts @@ -0,0 +1,61 @@ +import { ActionType } from 'hardhat/types' +import { task } from 'hardhat/config' +import { getReceiveConfig, getSendConfig, printConsoleTable } from '@/utils/taskHelpers' +import { TASK_LZ_GET_OAPP_CONFIG } from '@/constants/tasks' +import assert from 'assert' + +interface TaskArgs { + networks: string + addresses: string +} + +export const getOAppConfig: ActionType = async (taskArgs, ...args) => { + const networks = taskArgs.networks.split(',') + const addresses = taskArgs.addresses.split(',') + assert(networks.length === addresses.length, 'Passed in networks must match length of passed in addresses.') + const configs: Record> = {} + + for (const [index, localNetworkName] of networks.entries()) { + configs[localNetworkName] = {} + for (const remoteNetworkName of networks) { + if (remoteNetworkName === localNetworkName) continue + const [sendLibrary, sendUlnConfig, sendExecutorConfig] = await getSendConfig( + localNetworkName, + remoteNetworkName, + addresses[index] + ) + const [receiveLibrary, receiveUlnConfig] = await getReceiveConfig( + localNetworkName, + remoteNetworkName, + addresses[index] + ) + + configs[localNetworkName][remoteNetworkName] = { + defaultSendLibrary: sendLibrary, + defaultReceiveLibrary: receiveLibrary, + sendUlnConfig, + sendExecutorConfig, + receiveUlnConfig, + } + + printConsoleTable( + localNetworkName, + remoteNetworkName, + sendLibrary, + receiveLibrary, + sendUlnConfig, + sendExecutorConfig, + receiveUlnConfig + ) + } + } + return configs +} + +task( + TASK_LZ_GET_OAPP_CONFIG, + 'outputs the default Send and Receive Messaging Library versions and the default application config' +) + .addParam('networks', 'comma separated list of networks') + .addParam('addresses', 'comma separated list of addresses') + .setAction(getOAppConfig) diff --git a/packages/ua-utils-evm-hardhat/src/tasks/oapp/index.ts b/packages/ua-utils-evm-hardhat/src/tasks/oapp/index.ts index 8010ab13b..d3758fdad 100644 --- a/packages/ua-utils-evm-hardhat/src/tasks/oapp/index.ts +++ b/packages/ua-utils-evm-hardhat/src/tasks/oapp/index.ts @@ -1 +1,3 @@ import './wire' +import './getDefaultConfig' +import './getOAppConfig' diff --git a/packages/ua-utils-evm-hardhat/src/utils/taskHelpers.ts b/packages/ua-utils-evm-hardhat/src/utils/taskHelpers.ts new file mode 100644 index 000000000..9eaf2120f --- /dev/null +++ b/packages/ua-utils-evm-hardhat/src/utils/taskHelpers.ts @@ -0,0 +1,104 @@ +import { Address } from '@layerzerolabs/utils' +import { Uln302ExecutorConfig, Uln302UlnConfig } from '@layerzerolabs/protocol-utils' +import { createConnectedContractFactory, getEidForNetworkName } from '@layerzerolabs/utils-evm-hardhat' +import { Endpoint, Uln302 } from '@layerzerolabs/protocol-utils-evm' + +export async function getSendConfig( + localNetworkName: string, + remoteNetworkName: string, + address?: Address +): Promise<[Address, Uln302UlnConfig, Uln302ExecutorConfig]> { + const localEid = getEidForNetworkName(localNetworkName) + const remoteEid = getEidForNetworkName(remoteNetworkName) + const contractFactory = createConnectedContractFactory() + const localEndpointSDK = new Endpoint(await contractFactory({ eid: localEid, contractName: 'EndpointV2' })) + + // First we get the SDK for the local send library + let sendLibrary: Address + if (address) { + sendLibrary = await localEndpointSDK.getSendLibrary(address, remoteEid) + } else { + sendLibrary = await localEndpointSDK.defaultSendLibrary(remoteEid) + } + + const localSendUlnSDK = new Uln302( + await contractFactory({ eid: localEid, contractName: 'SendUln302', address: sendLibrary }) + ) + + const sendUlnConfig = await localSendUlnSDK.getUlnConfig(remoteEid) + const sendExecutorConfig = await localSendUlnSDK.getExecutorConfig(remoteEid) + return [sendLibrary, sendUlnConfig, sendExecutorConfig] +} + +export async function getReceiveConfig( + localNetworkName: string, + remoteNetworkName: string, + address?: Address +): Promise<[Address, Uln302UlnConfig]> { + const localEid = getEidForNetworkName(localNetworkName) + const remoteEid = getEidForNetworkName(remoteNetworkName) + const contractFactory = createConnectedContractFactory() + const localEndpointSDK = new Endpoint(await contractFactory({ eid: localEid, contractName: 'EndpointV2' })) + + // First we get the SDK for the local send library + let receiveLibrary: Address + if (address) { + receiveLibrary = (await localEndpointSDK.getReceiveLibrary(address, remoteEid))[0] + } else { + receiveLibrary = await localEndpointSDK.defaultReceiveLibrary(remoteEid) + } + + const localReceiveUlnSDK = new Uln302( + await contractFactory({ eid: localEid, contractName: 'ReceiveUln302', address: receiveLibrary }) + ) + + const receiveUlnConfig = await localReceiveUlnSDK.getUlnConfig(remoteEid) + return [receiveLibrary, receiveUlnConfig] +} +export const printConsoleTable = ( + localNetworkName: string, + remoteNetworkName: string, + defaultSendLibrary: string, + defaultReceiveLibrary: string, + sendUlnConfig: Record, + sendExecutorConfig: Record, + receiveUlnConfig: Record +) => { + const defaultLibraryTable = { + network: localNetworkName, + remoteNetwork: remoteNetworkName, + defaultSendLibrary: defaultSendLibrary, + defaultReceiveLibrary: defaultReceiveLibrary, + } + + const sendUln = { + maxMessageSize: sendExecutorConfig.maxMessageSize, + executor: sendExecutorConfig.executor, + confirmations: parseInt(sendUlnConfig.confirmations.toString()), + optionalDVNThreshold: sendUlnConfig.optionalDVNThreshold, + requiredDVNs: sendUlnConfig.requiredDVNs, + optionalDVNs: sendUlnConfig.optionalDVNs, + } + + const receiveUln = { + confirmations: parseInt(receiveUlnConfig.confirmations.toString()), + optionalDVNThreshold: receiveUlnConfig.optionalDVNThreshold, + requiredDVNs: receiveUlnConfig.requiredDVNs, + optionalDVNs: receiveUlnConfig.optionalDVNs, + } + + const sendUlnConfigTable = { + sendUln: sendUln, + } + + const receiveUlnConfigTable = { + receiveUln: receiveUln, + } + + console.log(`************************************************`) + console.log(`${localNetworkName.toUpperCase()}`) + console.log(`************************************************`) + console.table(defaultLibraryTable) + console.table(sendUlnConfigTable) + console.table(receiveUlnConfigTable) +}