Skip to content

Commit

Permalink
chore: Label return types for IEndpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
janjakubnanista committed Dec 11, 2023
1 parent be71308 commit ec09ff0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
15 changes: 9 additions & 6 deletions packages/protocol-utils-evm/src/endpoint/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,24 @@ import type { EndpointId } from '@layerzerolabs/lz-definitions'
import { ignoreZero, makeZeroAddress, OmniSDK } from '@layerzerolabs/utils-evm'

export class Endpoint extends OmniSDK implements IEndpoint {
async getDefaultReceiveLibrary(eid: EndpointId): Promise<string | undefined> {
async getDefaultReceiveLibrary(eid: EndpointId): Promise<Address | undefined> {
return ignoreZero(await this.contract.contract.defaultReceiveLibrary(eid))
}

async getSendLibrary(sender: Address, dstEid: EndpointId): Promise<string | undefined> {
async getSendLibrary(sender: Address, dstEid: EndpointId): Promise<Address | undefined> {
return ignoreZero(await this.contract.contract.getSendLibrary(sender, dstEid))
}

async getReceiveLibrary(receiver: Address, srcEid: EndpointId): Promise<[string | undefined, boolean]> {
async getReceiveLibrary(
receiver: Address,
srcEid: EndpointId
): Promise<[address: Address | undefined, isDefault: boolean]> {
return await this.contract.contract.getReceiveLibrary(receiver, srcEid)
}

async setDefaultReceiveLibrary(
eid: EndpointId,
lib: string | null | undefined,
lib: Address | null | undefined,
gracePeriod: number = 0
): Promise<OmniTransaction> {
const data = this.contract.contract.interface.encodeFunctionData('setDefaultReceiveLibrary', [
Expand All @@ -33,7 +36,7 @@ export class Endpoint extends OmniSDK implements IEndpoint {
}
}

async getDefaultSendLibrary(eid: EndpointId): Promise<string | undefined> {
async getDefaultSendLibrary(eid: EndpointId): Promise<Address | undefined> {
return ignoreZero(await this.contract.contract.defaultSendLibrary(eid))
}

Expand All @@ -53,7 +56,7 @@ export class Endpoint extends OmniSDK implements IEndpoint {
return this.contract.contract.isRegisteredLibrary(lib)
}

async registerLibrary(lib: string): Promise<OmniTransaction> {
async registerLibrary(lib: Address): Promise<OmniTransaction> {
const data = this.contract.contract.interface.encodeFunctionData('registerLibrary', [lib])

return {
Expand Down
16 changes: 13 additions & 3 deletions packages/protocol-utils/src/endpoint/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import type { Address, OmniGraph, OmniPointBasedFactory, OmniTransaction, IOmniSDK } from '@layerzerolabs/utils'
import type {
Address,
OmniGraph,
OmniPointBasedFactory,
OmniTransaction,
IOmniSDK,
Bytes32,
} from '@layerzerolabs/utils'
import type { EndpointId } from '@layerzerolabs/lz-definitions'

export interface IEndpoint extends IOmniSDK {
Expand All @@ -15,8 +22,11 @@ export interface IEndpoint extends IOmniSDK {
isRegisteredLibrary(lib: Address): Promise<boolean>
registerLibrary(lib: Address): Promise<OmniTransaction>

getSendLibrary(sender: Address, dstEid: EndpointId): Promise<string | undefined>
getReceiveLibrary(receiver: Address, srcEid: EndpointId): Promise<[string | undefined, boolean]>
getSendLibrary(sender: Address, dstEid: EndpointId): Promise<Address | undefined>
getReceiveLibrary(
receiver: Address,
srcEid: EndpointId
): Promise<[address: Bytes32 | undefined, isDefault: boolean]>
}

export interface EndpointEdgeConfig {
Expand Down

0 comments on commit ec09ff0

Please sign in to comment.