-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🪚 OmniGraph™ SDK factories; OApp ↔︎ Endpoint SDK link (#94)
- Loading branch information
1 parent
086b820
commit 9e4cb71
Showing
19 changed files
with
194 additions
and
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import pMemoize from 'p-memoize' | ||
import { OmniContractFactory } from '@layerzerolabs/utils-evm' | ||
import { Endpoint } from './sdk' | ||
import { EndpointFactory } from '@layerzerolabs/protocol-utils' | ||
|
||
/** | ||
* Syntactic sugar that creates an instance of EVM `Endpoint` SDK | ||
* based on an `OmniPoint` with help of an `OmniContractFactory` | ||
* | ||
* @param {OmniContractFactory} contractFactory | ||
* @returns {EndpointFactory<Endpoint>} | ||
*/ | ||
export const createEndpointFactory = (contractFactory: OmniContractFactory): EndpointFactory<Endpoint> => | ||
pMemoize(async (point) => new Endpoint(await contractFactory(point))) |
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,2 @@ | ||
export * from './factory' | ||
export * from './sdk' |
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
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
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
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,20 @@ | ||
import pMemoize from 'p-memoize' | ||
import type { OAppFactory } from '@layerzerolabs/ua-utils' | ||
import type { OmniContractFactory } from '@layerzerolabs/utils-evm' | ||
import type { EndpointFactory } from '@layerzerolabs/protocol-utils' | ||
import { createEndpointFactory } from '@layerzerolabs/protocol-utils-evm' | ||
import { OApp } from './sdk' | ||
|
||
/** | ||
* Syntactic sugar that creates an instance of EVM `OApp` SDK | ||
* based on an `OmniPoint` with help of an `OmniContractFactory` | ||
* and an (optional) `EndpointFactory` | ||
* | ||
* @param {OmniContractFactory} contractFactory | ||
* @param {EndpointFactory} [endpointFactory] | ||
* @returns {EndpointFactory<Endpoint>} | ||
*/ | ||
export const createOAppFactory = ( | ||
contractFactory: OmniContractFactory, | ||
endpointFactory: EndpointFactory = createEndpointFactory(contractFactory) | ||
): OAppFactory<OApp> => pMemoize(async (point) => new OApp(await contractFactory(point), endpointFactory)) |
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,2 @@ | ||
export * from './factory' | ||
export * from './sdk' |
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
Oops, something went wrong.