diff --git a/packages/protocol-utils-evm/src/endpoint/sdk.ts b/packages/protocol-utils-evm/src/endpoint/sdk.ts index fbabf6304..62ae37459 100644 --- a/packages/protocol-utils-evm/src/endpoint/sdk.ts +++ b/packages/protocol-utils-evm/src/endpoint/sdk.ts @@ -2,7 +2,6 @@ import assert from 'assert' import type { IEndpoint, IUln302, - SetConfigParam, Uln302ExecutorConfig, Uln302Factory, Uln302UlnConfig, @@ -10,9 +9,13 @@ 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 { CONFIG_TYPE_EXECUTOR, CONFIG_TYPE_ULN, Timeout } from '@layerzerolabs/protocol-utils' +import { Timeout } from '@layerzerolabs/protocol-utils' import { defaultAbiCoder } from '@ethersproject/abi' +export const CONFIG_TYPE_EXECUTOR = 1 + +export const CONFIG_TYPE_ULN = 2 + export class Endpoint extends OmniSDK implements IEndpoint { constructor( contract: OmniContract, @@ -129,46 +132,19 @@ export class Endpoint extends OmniSDK implements IEndpoint { 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 getExecutorConfig(oapp: Address, lib: Address, eid: EndpointId): Promise { + const encodedExecutorBytes = await this.contract.contract.getConfig(oapp, lib, eid, CONFIG_TYPE_EXECUTOR) + const [maxMessageSize, executor] = defaultAbiCoder.decode(['uint32', 'address'], encodedExecutorBytes) + return { maxMessageSize, executor } } - async getConfig( - oapp: Address, - lib: Address, - eid: EndpointId, - configType: number - ): Promise { - assert( - configType === CONFIG_TYPE_EXECUTOR || configType === CONFIG_TYPE_ULN, - `configType invalid ${configType}` + async getUlnConfig(oapp: Address, lib: Address, eid: EndpointId): Promise { + const encodedUlnBytes = await this.contract.contract.getConfig(oapp, lib, eid, CONFIG_TYPE_ULN) + const [confirmations, , , optionalDVNThreshold, requiredDVNs, optionalDVNs] = defaultAbiCoder.decode( + ['tuple(uint64,uint8,uint8,uint8,address[],address[])'], + encodedUlnBytes ) - 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, , , optionalDVNThreshold, requiredDVNs, optionalDVNs] = defaultAbiCoder.decode( - ['tuple(uint64,uint8,uint8,uint8,address[],address[])'], - encodedUlnBytes - ) - return { confirmations, optionalDVNThreshold, requiredDVNs, optionalDVNs } - } + return { confirmations, optionalDVNThreshold, requiredDVNs, optionalDVNs } } isRegisteredLibrary(lib: Address): Promise { diff --git a/packages/protocol-utils/src/endpoint/types.ts b/packages/protocol-utils/src/endpoint/types.ts index 2120a6e75..80d8b9a2c 100644 --- a/packages/protocol-utils/src/endpoint/types.ts +++ b/packages/protocol-utils/src/endpoint/types.ts @@ -31,13 +31,9 @@ export interface IEndpoint extends IOmniSDK { 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 + getExecutorConfig(oapp: Address, lib: Address, eid: EndpointId): Promise + + getUlnConfig(oapp: Address, lib: Address, eid: EndpointId): Promise } export interface SetConfigParam { diff --git a/packages/protocol-utils/src/uln302/types.ts b/packages/protocol-utils/src/uln302/types.ts index 36d727e24..edc99201b 100644 --- a/packages/protocol-utils/src/uln302/types.ts +++ b/packages/protocol-utils/src/uln302/types.ts @@ -8,10 +8,6 @@ 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