From 8c641a81ec2fc773351df8e4c7df489d3677c52f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Jakub=20Nani=C5=A1ta?= Date: Tue, 5 Dec 2023 17:01:47 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=AA=9A=20OmniGraph=E2=84=A2=20Fix=20types?= =?UTF-8?q?=20&=20README=20(#64)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/ua-utils-evm-hardhat-test/README.md | 4 ++-- packages/utils-evm-hardhat/src/omnigraph/builder.ts | 4 ++-- packages/utils-evm-hardhat/src/omnigraph/contracts.ts | 6 +++--- packages/utils-evm-hardhat/src/omnigraph/coordinates.ts | 4 ++-- packages/utils-evm-hardhat/src/omnigraph/types.ts | 2 +- packages/utils-evm/src/omnigraph/types.ts | 7 +++++-- 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/packages/ua-utils-evm-hardhat-test/README.md b/packages/ua-utils-evm-hardhat-test/README.md index 3e71b8c6a..1e9ad42cf 100644 --- a/packages/ua-utils-evm-hardhat-test/README.md +++ b/packages/ua-utils-evm-hardhat-test/README.md @@ -4,10 +4,10 @@

-

@layerzerolabs/utils-evm-hardhat-test

+

@layerzerolabs/ua-utils-evm-hardhat-test

## Development -This package provides integration tests for `@layerzerolabs/utils-evm-hardhat` executed within a containerized setup. These tests are dependent on two networks that are bootstrapped in the root `docker-compose.yaml` and will only run when executed within that environment. +This package provides integration tests for `@layerzerolabs/ua-utils-evm-hardhat` executed within a containerized setup. These tests are dependent on two networks that are bootstrapped in the root `docker-compose.yaml` and will only run when executed within that environment. Please see the root [`README.md`](../../README.md) for more information. diff --git a/packages/utils-evm-hardhat/src/omnigraph/builder.ts b/packages/utils-evm-hardhat/src/omnigraph/builder.ts index bea7736ef..8346f2bcb 100644 --- a/packages/utils-evm-hardhat/src/omnigraph/builder.ts +++ b/packages/utils-evm-hardhat/src/omnigraph/builder.ts @@ -1,5 +1,5 @@ import type { OmniEdge, OmniNode } from '@layerzerolabs/utils' -import type { OmniContractFactory, OmniGraphHardhat } from './types' +import type { OmniContractFactoryHardhat, OmniGraphHardhat } from './types' import { OmniGraphBuilder } from '@layerzerolabs/utils' import { omniContractToPoint } from '@layerzerolabs/utils-evm' import assert from 'assert' @@ -12,7 +12,7 @@ import assert from 'assert' export class OmniGraphBuilderHardhat { static async fromConfig( graph: OmniGraphHardhat, - contractFactory: OmniContractFactory + contractFactory: OmniContractFactoryHardhat ): Promise> { const builder = new OmniGraphBuilder() diff --git a/packages/utils-evm-hardhat/src/omnigraph/contracts.ts b/packages/utils-evm-hardhat/src/omnigraph/contracts.ts index ce43bb690..076d32f5c 100644 --- a/packages/utils-evm-hardhat/src/omnigraph/contracts.ts +++ b/packages/utils-evm-hardhat/src/omnigraph/contracts.ts @@ -1,13 +1,13 @@ import pMemoize from 'p-memoize' import { ProviderFactory, connectOmniContract } from '@layerzerolabs/utils-evm' import { createContractFactory } from '@/omnigraph/coordinates' -import type { OmniContractFactory } from '@/omnigraph/types' +import type { OmniContractFactoryHardhat } from '@/omnigraph/types' import { createProviderFactory } from '@/provider' export const createConnectedContractFactory = ( - contractFactory: OmniContractFactory = createContractFactory(), + contractFactory: OmniContractFactoryHardhat = createContractFactory(), providerFactory: ProviderFactory = createProviderFactory() -): OmniContractFactory => +): OmniContractFactoryHardhat => pMemoize(async (point) => { const contract = await contractFactory(point) const provider = await providerFactory(point.eid) diff --git a/packages/utils-evm-hardhat/src/omnigraph/coordinates.ts b/packages/utils-evm-hardhat/src/omnigraph/coordinates.ts index 976ef09cf..22218ed42 100644 --- a/packages/utils-evm-hardhat/src/omnigraph/coordinates.ts +++ b/packages/utils-evm-hardhat/src/omnigraph/coordinates.ts @@ -6,7 +6,7 @@ import pMemoize from 'p-memoize' import { OmniContract } from '@layerzerolabs/utils-evm' import { Contract } from '@ethersproject/contracts' import assert from 'assert' -import { OmniContractFactory } from './types' +import { OmniContractFactoryHardhat } from './types' import { createNetworkEnvironmentFactory, getDefaultRuntimeEnvironment } from '@/runtime' import { assertHardhatDeploy } from '@/internal/assertions' @@ -25,7 +25,7 @@ export const omniDeploymentToContract = ({ eid, deployment }): OmniContract => ( export const createContractFactory = ( hre: HardhatRuntimeEnvironment = getDefaultRuntimeEnvironment(), environmentFactory = createNetworkEnvironmentFactory(hre) -): OmniContractFactory => { +): OmniContractFactoryHardhat => { return pMemoize(async ({ eid, address, contractName }) => { const env = await environmentFactory(eid) assertHardhatDeploy(env) diff --git a/packages/utils-evm-hardhat/src/omnigraph/types.ts b/packages/utils-evm-hardhat/src/omnigraph/types.ts index 682893a0c..93a44b045 100644 --- a/packages/utils-evm-hardhat/src/omnigraph/types.ts +++ b/packages/utils-evm-hardhat/src/omnigraph/types.ts @@ -24,4 +24,4 @@ export interface OmniGraphHardhat connections: OmniEdgeHardhat[] } -export type OmniContractFactory = (point: OmniPointHardhat) => OmniContract | Promise +export type OmniContractFactoryHardhat = (point: OmniPointHardhat) => OmniContract | Promise diff --git a/packages/utils-evm/src/omnigraph/types.ts b/packages/utils-evm/src/omnigraph/types.ts index 1b6593f1b..4f533852b 100644 --- a/packages/utils-evm/src/omnigraph/types.ts +++ b/packages/utils-evm/src/omnigraph/types.ts @@ -1,7 +1,10 @@ -import { Contract } from '@ethersproject/contracts' -import { EndpointId } from '@layerzerolabs/lz-definitions' +import type { Contract } from '@ethersproject/contracts' +import type { EndpointId } from '@layerzerolabs/lz-definitions' +import type { OmniPoint } from '@layerzerolabs/utils' export interface OmniContract { eid: EndpointId contract: TContract } + +export type OmniContractFactory = (point: OmniPoint) => OmniContract | Promise