From 97b9b9f7f50d3bad04c341e329f8ea0da108df11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?lz=2Esir=CE=94rthurmoney=28=29?= Date: Wed, 13 Dec 2023 11:46:07 -0800 Subject: [PATCH 1/4] Updating endpoint and uln302 types in protocol-utils. Updating endpoint sdk in protocol-utils-evm --- .../protocol-utils-evm/src/endpoint/sdk.ts | 106 +++++++++++++++++- packages/protocol-utils/src/endpoint/types.ts | 37 +++++- packages/protocol-utils/src/uln302/types.ts | 2 + 3 files changed, 143 insertions(+), 2 deletions(-) diff --git a/packages/protocol-utils-evm/src/endpoint/sdk.ts b/packages/protocol-utils-evm/src/endpoint/sdk.ts index 6f9b58f35..82e68057a 100644 --- a/packages/protocol-utils-evm/src/endpoint/sdk.ts +++ b/packages/protocol-utils-evm/src/endpoint/sdk.ts @@ -1,8 +1,17 @@ import assert from 'assert' -import type { IEndpoint, IUln302, Uln302Factory } from '@layerzerolabs/protocol-utils' +import type { + IEndpoint, + IUln302, + SetConfigParam, + Uln302ExecutorConfig, + Uln302Factory, + Uln302UlnConfig, +} from '@layerzerolabs/protocol-utils' import { formatEid, type Address, type OmniTransaction, formatOmniPoint } from '@layerzerolabs/utils' import type { EndpointId } from '@layerzerolabs/lz-definitions' import { ignoreZero, isZero, makeZeroAddress, type OmniContract, OmniSDK } from '@layerzerolabs/utils-evm' +import { Timeout, CONFIG_TYPE_EXECUTOR, CONFIG_TYPE_ULN } from '@layerzerolabs/protocol-utils' +import { defaultAbiCoder } from '@ethersproject/abi' export class Endpoint extends OmniSDK implements IEndpoint { constructor( @@ -71,6 +80,101 @@ export class Endpoint extends OmniSDK implements IEndpoint { } } + async getDefaultReceiveLibraryTimeout(eid: EndpointId): Promise { + return await this.contract.contract.defaultReceiveLibraryTimeout(eid) + } + + async setSendLibrary(eid: EndpointId, newLib: Address | null | undefined): Promise { + const data = this.contract.contract.interface.encodeFunctionData('setSendLibrary', [eid, newLib]) + + return { + ...this.createTransaction(data), + description: `Setting send library for ${formatEid(eid)} to ${newLib}`, + } + } + + async setReceiveLibrary( + eid: EndpointId, + newLib: Address | null | undefined, + gracePeriod: number + ): Promise { + const data = this.contract.contract.interface.encodeFunctionData('setReceiveLibrary', [ + eid, + newLib, + gracePeriod, + ]) + + return { + ...this.createTransaction(data), + description: `Setting receive library for ${formatEid(eid)} to ${newLib} with grace period ${gracePeriod}`, + } + } + + async setReceiveLibraryTimeout( + eid: EndpointId, + lib: Address | null | undefined, + expiry: number + ): Promise { + const data = this.contract.contract.interface.encodeFunctionData('setReceiveLibraryTimeout', [eid, lib, expiry]) + + return { + ...this.createTransaction(data), + description: `Setting receive library timeout for ${formatEid( + eid + )} to ${lib} with expiration period ${expiry}`, + } + } + + async getReceiveLibraryTimeout(receiver: Address, srcEid: EndpointId): Promise { + return await this.contract.contract.receiveLibraryTimeout(receiver, srcEid) + } + + async setConfig(lib: Address, params: SetConfigParam[]): Promise { + const data = this.contract.contract.interface.encodeFunctionData('setConfig', [lib, params]) + + console.log({ params }) + + let description: string = '' + for (const param of params) { + description += `Setting ${ + param.configType === CONFIG_TYPE_EXECUTOR ? 'executor' : 'uln' + } config for endpoint ${formatEid(param.eid)}. ` + } + + return { + ...this.createTransaction(data), + description: description, + } + } + + async getConfig( + oapp: Address, + lib: Address, + eid: EndpointId, + configType: number + ): Promise { + assert( + configType === CONFIG_TYPE_EXECUTOR || configType === CONFIG_TYPE_ULN, + `configType invalid ${configType}` + ) + if (configType === CONFIG_TYPE_EXECUTOR) { + const encodedExecutorBytes = await this.contract.contract.getConfig(oapp, lib, eid, configType) + const [maxMessageSize, executor] = defaultAbiCoder.decode(['uint32', 'address'], encodedExecutorBytes) + return { maxMessageSize, executor } + } else { + const encodedUlnBytes = await this.contract.contract.getConfig(oapp, lib, eid, configType) + const [ + confirmations, + requiredDVNCount, + optionalDVNCount, + optionalDVNThreshold, + requiredDVNs, + optionalDVNs, + ] = defaultAbiCoder.decode(['tuple(uint64,uint8,uint8,uint8,address[],address[])'], encodedUlnBytes) + return { confirmations, optionalDVNThreshold, requiredDVNs, optionalDVNs } + } + } + isRegisteredLibrary(lib: Address): Promise { return this.contract.contract.isRegisteredLibrary(lib) } diff --git a/packages/protocol-utils/src/endpoint/types.ts b/packages/protocol-utils/src/endpoint/types.ts index c307e573e..c82efcf04 100644 --- a/packages/protocol-utils/src/endpoint/types.ts +++ b/packages/protocol-utils/src/endpoint/types.ts @@ -1,6 +1,6 @@ import type { Address, Factory, OmniGraph, OmniPoint, OmniTransaction, IOmniSDK, Bytes32 } from '@layerzerolabs/utils' import type { EndpointId } from '@layerzerolabs/lz-definitions' -import type { IUln302 } from '@/uln302/types' +import type { IUln302, Uln302ExecutorConfig, Uln302UlnConfig } from '@/uln302/types' export interface IEndpoint extends IOmniSDK { getUln302SDK(address: Address): Promise @@ -23,6 +23,41 @@ export interface IEndpoint extends IOmniSDK { receiver: Address, srcEid: EndpointId ): Promise<[address: Bytes32 | undefined, isDefault: boolean]> + + getDefaultReceiveLibraryTimeout(eid: EndpointId): Promise + getReceiveLibraryTimeout(receiver: Address, srcEid: EndpointId): Promise + + setSendLibrary(eid: EndpointId, newLib: Address): Promise + setReceiveLibrary(eid: EndpointId, newLib: Address, gracePeriod: number): Promise + setReceiveLibraryTimeout(eid: EndpointId, newLib: Address, expiry: number): Promise + + setConfig(lib: Address, params: SetConfigParam[]): Promise + getConfig( + oapp: Address, + lib: Address, + eid: EndpointId, + configType: number + ): Promise +} + +export const CONFIG_TYPE_EXECUTOR = 1 + +export const CONFIG_TYPE_ULN = 2 + +export interface SetConfigParam { + eid: EndpointId + configType: number + config: string +} + +export interface ReceiveLibraryConfig { + receiveLibrary: string + gracePeriod: number +} + +export interface Timeout { + lib: string + expiry: number } export interface EndpointEdgeConfig { diff --git a/packages/protocol-utils/src/uln302/types.ts b/packages/protocol-utils/src/uln302/types.ts index a19aeeb93..edc99201b 100644 --- a/packages/protocol-utils/src/uln302/types.ts +++ b/packages/protocol-utils/src/uln302/types.ts @@ -18,6 +18,8 @@ export interface Uln302UlnConfig { optionalDVNThreshold: number requiredDVNs: string[] optionalDVNs: string[] + requiredDVNCount?: number + optionalDVNCount?: number } export interface Uln302NodeConfig { From f5d26232654bff5ddc7be202b47181665ac96434 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?lz=2Esir=CE=94rthurmoney=28=29?= Date: Wed, 13 Dec 2023 11:57:56 -0800 Subject: [PATCH 2/4] fixing lint --- packages/protocol-utils-evm/src/endpoint/sdk.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/packages/protocol-utils-evm/src/endpoint/sdk.ts b/packages/protocol-utils-evm/src/endpoint/sdk.ts index 82e68057a..34ac7ace6 100644 --- a/packages/protocol-utils-evm/src/endpoint/sdk.ts +++ b/packages/protocol-utils-evm/src/endpoint/sdk.ts @@ -163,14 +163,10 @@ export class Endpoint extends OmniSDK implements IEndpoint { return { maxMessageSize, executor } } else { const encodedUlnBytes = await this.contract.contract.getConfig(oapp, lib, eid, configType) - const [ - confirmations, - requiredDVNCount, - optionalDVNCount, - optionalDVNThreshold, - requiredDVNs, - optionalDVNs, - ] = defaultAbiCoder.decode(['tuple(uint64,uint8,uint8,uint8,address[],address[])'], encodedUlnBytes) + const [confirmations, , , optionalDVNThreshold, requiredDVNs, optionalDVNs] = defaultAbiCoder.decode( + ['tuple(uint64,uint8,uint8,uint8,address[],address[])'], + encodedUlnBytes + ) return { confirmations, optionalDVNThreshold, requiredDVNs, optionalDVNs } } } From 59be4c5888e88a31018e0e24b84a5a5e6a03b9ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?lz=2Esir=CE=94rthurmoney=28=29?= Date: Wed, 13 Dec 2023 12:05:53 -0800 Subject: [PATCH 3/4] refactor --- packages/protocol-utils-evm/src/endpoint/sdk.ts | 2 +- packages/protocol-utils/src/endpoint/types.ts | 9 --------- packages/protocol-utils/src/uln302/types.ts | 4 ++++ 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/packages/protocol-utils-evm/src/endpoint/sdk.ts b/packages/protocol-utils-evm/src/endpoint/sdk.ts index 34ac7ace6..fbabf6304 100644 --- a/packages/protocol-utils-evm/src/endpoint/sdk.ts +++ b/packages/protocol-utils-evm/src/endpoint/sdk.ts @@ -10,7 +10,7 @@ import type { import { formatEid, type Address, type OmniTransaction, formatOmniPoint } from '@layerzerolabs/utils' import type { EndpointId } from '@layerzerolabs/lz-definitions' import { ignoreZero, isZero, makeZeroAddress, type OmniContract, OmniSDK } from '@layerzerolabs/utils-evm' -import { Timeout, CONFIG_TYPE_EXECUTOR, CONFIG_TYPE_ULN } from '@layerzerolabs/protocol-utils' +import { CONFIG_TYPE_EXECUTOR, CONFIG_TYPE_ULN, Timeout } from '@layerzerolabs/protocol-utils' import { defaultAbiCoder } from '@ethersproject/abi' export class Endpoint extends OmniSDK implements IEndpoint { diff --git a/packages/protocol-utils/src/endpoint/types.ts b/packages/protocol-utils/src/endpoint/types.ts index c82efcf04..2120a6e75 100644 --- a/packages/protocol-utils/src/endpoint/types.ts +++ b/packages/protocol-utils/src/endpoint/types.ts @@ -40,21 +40,12 @@ export interface IEndpoint extends IOmniSDK { ): Promise } -export const CONFIG_TYPE_EXECUTOR = 1 - -export const CONFIG_TYPE_ULN = 2 - export interface SetConfigParam { eid: EndpointId configType: number config: string } -export interface ReceiveLibraryConfig { - receiveLibrary: string - gracePeriod: number -} - export interface Timeout { lib: string expiry: number diff --git a/packages/protocol-utils/src/uln302/types.ts b/packages/protocol-utils/src/uln302/types.ts index edc99201b..36d727e24 100644 --- a/packages/protocol-utils/src/uln302/types.ts +++ b/packages/protocol-utils/src/uln302/types.ts @@ -8,6 +8,10 @@ export interface IUln302 extends IOmniSDK { setDefaultUlnConfig(eid: EndpointId, config: Uln302UlnConfig): Promise } +export const CONFIG_TYPE_EXECUTOR = 1 + +export const CONFIG_TYPE_ULN = 2 + export interface Uln302ExecutorConfig { maxMessageSize: number executor: string From 09ebe6a42300343c530d7921fc34e34604369a1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?lz=2Esir=CE=94rthurmoney=28=29?= Date: Wed, 13 Dec 2023 12:15:38 -0800 Subject: [PATCH 4/4] Updating oapp types in ua-utils. Updating oapp sdk in ua-utils-evm --- .../src/utils/taskHelpers.ts | 13 +- packages/ua-utils-evm/src/oapp/sdk.ts | 5 + packages/ua-utils/src/oapp/config.ts | 187 +++++++++++++++++- packages/ua-utils/src/oapp/types.ts | 26 ++- 4 files changed, 222 insertions(+), 9 deletions(-) diff --git a/packages/ua-utils-evm-hardhat/src/utils/taskHelpers.ts b/packages/ua-utils-evm-hardhat/src/utils/taskHelpers.ts index 4e276aac7..66770d5e7 100644 --- a/packages/ua-utils-evm-hardhat/src/utils/taskHelpers.ts +++ b/packages/ua-utils-evm-hardhat/src/utils/taskHelpers.ts @@ -1,5 +1,5 @@ import { Address } from '@layerzerolabs/utils' -import { Uln302ExecutorConfig, Uln302UlnConfig } from '@layerzerolabs/protocol-utils' +import { Timeout, Uln302ExecutorConfig, Uln302UlnConfig } from '@layerzerolabs/protocol-utils' import { createConnectedContractFactory, getEidForNetworkName } from '@layerzerolabs/utils-evm-hardhat' import { createEndpointFactory } from '@layerzerolabs/protocol-utils-evm' @@ -34,7 +34,7 @@ export async function getReceiveConfig( localNetworkName: string, remoteNetworkName: string, address?: Address -): Promise<[Address, Uln302UlnConfig]> { +): Promise<[Address, Uln302UlnConfig, Timeout]> { const localEid = getEidForNetworkName(localNetworkName) const remoteEid = getEidForNetworkName(remoteNetworkName) const contractFactory = createConnectedContractFactory() @@ -50,8 +50,15 @@ export async function getReceiveConfig( receiveLibrary = await localEndpointSDK.getDefaultReceiveLibrary(remoteEid) } + let receiveLibraryTimeout: Timeout + if (address) { + receiveLibraryTimeout = await localEndpointSDK.getReceiveLibraryTimeout(address, remoteEid) + } else { + receiveLibraryTimeout = await localEndpointSDK.getDefaultReceiveLibraryTimeout(remoteEid) + } + const localReceiveUlnSDK = await localEndpointSDK.getUln302SDK(receiveLibrary) const receiveUlnConfig = await localReceiveUlnSDK.getUlnConfig(remoteEid) - return [receiveLibrary, receiveUlnConfig] + return [receiveLibrary, receiveUlnConfig, receiveLibraryTimeout] } diff --git a/packages/ua-utils-evm/src/oapp/sdk.ts b/packages/ua-utils-evm/src/oapp/sdk.ts index 1edd043a7..c8f7c163e 100644 --- a/packages/ua-utils-evm/src/oapp/sdk.ts +++ b/packages/ua-utils-evm/src/oapp/sdk.ts @@ -20,6 +20,11 @@ export class OApp extends OmniSDK implements IOApp { super(contract) } + async callEndpoint(callData: string): Promise { + const data = this.contract.contract.interface.encodeFunctionData('callEndpoint', [callData]) + return this.createTransaction(data) + } + async getEndpointSDK(): Promise { let address: string diff --git a/packages/ua-utils/src/oapp/config.ts b/packages/ua-utils/src/oapp/config.ts index 241a5c52e..632e97fb1 100644 --- a/packages/ua-utils/src/oapp/config.ts +++ b/packages/ua-utils/src/oapp/config.ts @@ -1,11 +1,23 @@ -import type { OmniTransaction } from '@layerzerolabs/utils' +import { Address, flattenTransactions, type OmniTransaction } from '@layerzerolabs/utils' import type { OAppFactory, OAppOmniGraph } from './types' import { createModuleLogger, printBoolean } from '@layerzerolabs/io-utils' import { formatOmniVector } from '@layerzerolabs/utils' +import { + CONFIG_TYPE_EXECUTOR, + CONFIG_TYPE_ULN, + Uln302ExecutorConfig, + Uln302UlnConfig, +} from '@layerzerolabs/protocol-utils' +import { SetConfigParam } from '@layerzerolabs/protocol-utils' +import { defaultAbiCoder } from '@ethersproject/abi' -export const configureOApp = async (graph: OAppOmniGraph, createSdk: OAppFactory): Promise => { - const logger = createModuleLogger('OApp') +export type OAppConfigurator = (graph: OAppOmniGraph, createSdk: OAppFactory) => Promise + +export const configureOApp: OAppConfigurator = async (graph: OAppOmniGraph, createSdk: OAppFactory) => + flattenTransactions([await configureOAppPeers(graph, createSdk), await configureOAppConfigs(graph, createSdk)]) +export const configureOAppPeers: OAppConfigurator = async (graph, createSdk) => { + const logger = createModuleLogger('OApp') const setPeers = await Promise.all( graph.connections.map(async ({ vector: { from, to } }): Promise => { logger.verbose(`Checking connection ${formatOmniVector({ from, to })}`) @@ -23,3 +35,172 @@ export const configureOApp = async (graph: OAppOmniGraph, createSdk: OAppFactory return [...setPeers].flat() } + +export const configureOAppConfigs: OAppConfigurator = async (graph, createSdk) => { + const setSendLibrary = await Promise.all( + graph.connections.map(async ({ vector: { from, to }, config }): Promise => { + if (!config?.sendLibrary) return [] + const oappSdk = await createSdk(from) + const endpointSdk = await oappSdk.getEndpointSDK() + const currentSendLibrary = await endpointSdk.getSendLibrary(from.address, to.eid) + + if (currentSendLibrary === config.sendLibrary) return [] + return [await endpointSdk.setSendLibrary(to.eid, config.sendLibrary)] + }) + ) + + const setReceiveLibrary = await Promise.all( + graph.connections.map(async ({ vector: { from, to }, config }): Promise => { + if (!config?.receiveLibraryConfig) return [] + const oappSdk = await createSdk(from) + const endpointSdk = await oappSdk.getEndpointSDK() + const [currentReceiveLibrary] = await endpointSdk.getReceiveLibrary(from.address, to.eid) + + if (currentReceiveLibrary === config.receiveLibraryConfig.receiveLibrary) return [] + return [ + await endpointSdk.setReceiveLibrary( + to.eid, + config.receiveLibraryConfig.receiveLibrary, + config.receiveLibraryConfig.gracePeriod + ), + ] + }) + ) + + const setReceiveLibraryTimeout = await Promise.all( + graph.connections.map(async ({ vector: { from, to }, config }): Promise => { + if (!config?.receiveLibraryTimeoutConfig) return [] + const oappSdk = await createSdk(from) + const endpointSdk = await oappSdk.getEndpointSDK() + const timeout = await endpointSdk.getReceiveLibraryTimeout(from.address, to.eid) + + if ( + timeout.lib === config.receiveLibraryTimeoutConfig.lib && + timeout.expiry === config.receiveLibraryTimeoutConfig.expiry + ) + return [] + return [ + await endpointSdk.setReceiveLibraryTimeout( + to.eid, + config.receiveLibraryTimeoutConfig.lib, + config.receiveLibraryTimeoutConfig.expiry + ), + ] + }) + ) + + const setConfg = await Promise.all( + graph.connections.map(async ({ vector: { from, to }, config }): Promise => { + const oappSdk = await createSdk(from) + const endpointSdk = await oappSdk.getEndpointSDK() + const sendConfigs: SetConfigParam[] = [] + const receiveConfigs: SetConfigParam[] = [] + const transactions: OmniTransaction[] = [] + + if (config?.sendConfig) { + const currentSendLibrary: Address = config.sendLibrary + ? config.sendLibrary + : (await endpointSdk.getSendLibrary(from.address, to.eid)) ?? '' + const sendExecutorConfig: Uln302ExecutorConfig = ( + await endpointSdk.getConfig(from.address, currentSendLibrary, to.eid, CONFIG_TYPE_EXECUTOR) + ) + + const setExecutorConfigParam: SetConfigParam = { + eid: to.eid, + configType: CONFIG_TYPE_EXECUTOR, + config: '', + } + + // 1) executor + // - maxMessageSize + // - executor + if ( + sendExecutorConfig.maxMessageSize !== config.sendConfig.executorConfig.maxMessageSize || + sendExecutorConfig.executor !== config.sendConfig.executorConfig.executor + ) { + setExecutorConfigParam.config = defaultAbiCoder.encode( + ['uint32', 'address'], + [config.sendConfig.executorConfig.maxMessageSize, config.sendConfig.executorConfig.executor] + ) + sendConfigs.push(setExecutorConfigParam) + } + + const setUlnConfigParam: SetConfigParam = { + eid: to.eid, + configType: CONFIG_TYPE_ULN, + config: '', + } + + // 2) uln + // - confirmations + // - optionalDVNThreshold + // - requiredDVNs + // - optionalDVNs + const sendUlnConfig = ( + await endpointSdk.getConfig(from.address, currentSendLibrary, to.eid, CONFIG_TYPE_ULN) + ) + if ( + sendUlnConfig.confirmations !== config.sendConfig.ulnConfig.confirmations || + sendUlnConfig.optionalDVNThreshold !== config.sendConfig.ulnConfig.optionalDVNThreshold || + sendUlnConfig.requiredDVNs !== config.sendConfig.ulnConfig.requiredDVNs || + sendUlnConfig.optionalDVNs !== config.sendConfig.ulnConfig.optionalDVNs + ) { + setUlnConfigParam.config = defaultAbiCoder.encode( + ['uint64', 'uint8', 'uint8', 'uint8', 'address[]', 'address[]'], + [ + config.sendConfig.ulnConfig.confirmations, + config.sendConfig.ulnConfig.requiredDVNs.length, + config.sendConfig.ulnConfig.optionalDVNs.length, + config.sendConfig.ulnConfig.optionalDVNThreshold, + config.sendConfig.ulnConfig.requiredDVNs, + config.sendConfig.ulnConfig.optionalDVNs, + ] + ) + sendConfigs.push(setUlnConfigParam) + } + + if (sendConfigs.length) transactions.push(await endpointSdk.setConfig(currentSendLibrary, sendConfigs)) + } + + if (config?.receiveConfig) { + const setUlnConfigParam: SetConfigParam = { + eid: to.eid, + configType: CONFIG_TYPE_ULN, + config: '', + } + const [currentReceiveLibrary] = config.receiveLibraryConfig?.receiveLibrary + ? [config.receiveLibraryConfig?.receiveLibrary, false] + : await endpointSdk.getReceiveLibrary(from.address, to.eid) + const receiveUlnConfig: Uln302UlnConfig = ( + await endpointSdk.getConfig(from.address, currentReceiveLibrary!, to.eid, CONFIG_TYPE_ULN) + ) + if ( + receiveUlnConfig.confirmations !== config.receiveConfig.ulnConfig.confirmations || + receiveUlnConfig.optionalDVNThreshold !== config.receiveConfig.ulnConfig.optionalDVNThreshold || + receiveUlnConfig.requiredDVNs !== config.receiveConfig.ulnConfig.requiredDVNs || + receiveUlnConfig.optionalDVNs !== config.receiveConfig.ulnConfig.optionalDVNs + ) { + setUlnConfigParam.config = defaultAbiCoder.encode( + ['uint64', 'uint8', 'uint8', 'uint8', 'address[]', 'address[]'], + [ + config.receiveConfig.ulnConfig.confirmations, + config.receiveConfig.ulnConfig.requiredDVNs.length, + config.receiveConfig.ulnConfig.optionalDVNs.length, + config.receiveConfig.ulnConfig.optionalDVNThreshold, + config.receiveConfig.ulnConfig.requiredDVNs, + config.receiveConfig.ulnConfig.optionalDVNs, + ] + ) + receiveConfigs.push(setUlnConfigParam) + } + if (receiveConfigs.length) + transactions.push(await endpointSdk.setConfig(currentReceiveLibrary!, receiveConfigs)) + } + + if (!sendConfigs.length && !receiveConfigs.length) return [] + return [...transactions] + }) + ) + + return [...setSendLibrary, ...setReceiveLibrary, ...setReceiveLibraryTimeout, ...setConfg].flat() +} diff --git a/packages/ua-utils/src/oapp/types.ts b/packages/ua-utils/src/oapp/types.ts index 9a98893db..4d372ed2d 100644 --- a/packages/ua-utils/src/oapp/types.ts +++ b/packages/ua-utils/src/oapp/types.ts @@ -1,14 +1,34 @@ import type { EndpointId } from '@layerzerolabs/lz-definitions' -import type { IEndpoint } from '@layerzerolabs/protocol-utils' -import type { Address, Bytes32, Factory, OmniGraph, OmniTransaction, IOmniSDK, OmniPoint } from '@layerzerolabs/utils' +import type { IEndpoint, Timeout } from '@layerzerolabs/protocol-utils' +import type { Address, Factory, IOmniSDK, OmniGraph, OmniPoint, OmniTransaction } from '@layerzerolabs/utils' +import type { Bytes32 } from '@layerzerolabs/utils' +import type { Uln302ExecutorConfig, Uln302UlnConfig } from '@layerzerolabs/protocol-utils' export interface IOApp extends IOmniSDK { getEndpointSDK(): Promise getPeer(eid: EndpointId): Promise hasPeer(eid: EndpointId, address: Bytes32 | Address | null | undefined): Promise setPeer(eid: EndpointId, peer: Bytes32 | Address | null | undefined): Promise + callEndpoint(callData: string): Promise } -export type OAppOmniGraph = OmniGraph +export interface ReceiveLibraryConfig { + receiveLibrary: string + gracePeriod: number +} +export interface OAppEdgeConfig { + sendLibrary?: string + receiveLibraryConfig?: ReceiveLibraryConfig + receiveLibraryTimeoutConfig?: Timeout + sendConfig?: { + executorConfig: Uln302ExecutorConfig + ulnConfig: Uln302UlnConfig + } + receiveConfig?: { + ulnConfig: Uln302UlnConfig + } +} + +export type OAppOmniGraph = OmniGraph export type OAppFactory = Factory<[TOmniPoint], TOApp>