Skip to content

Commit

Permalink
🪚 OmniGraph™ Fix types & README (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
janjakubnanista authored Dec 6, 2023
1 parent 2c06f48 commit 8c641a8
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 12 deletions.
4 changes: 2 additions & 2 deletions packages/ua-utils-evm-hardhat-test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
</a>
</p>

<h1 align="center">@layerzerolabs/utils-evm-hardhat-test</h1>
<h1 align="center">@layerzerolabs/ua-utils-evm-hardhat-test</h1>

## 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.
4 changes: 2 additions & 2 deletions packages/utils-evm-hardhat/src/omnigraph/builder.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -12,7 +12,7 @@ import assert from 'assert'
export class OmniGraphBuilderHardhat {
static async fromConfig<TNodeConfig, TEdgeConfig>(
graph: OmniGraphHardhat<TNodeConfig, TEdgeConfig>,
contractFactory: OmniContractFactory
contractFactory: OmniContractFactoryHardhat
): Promise<OmniGraphBuilder<TNodeConfig, TEdgeConfig>> {
const builder = new OmniGraphBuilder<TNodeConfig, TEdgeConfig>()

Expand Down
6 changes: 3 additions & 3 deletions packages/utils-evm-hardhat/src/omnigraph/contracts.ts
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
4 changes: 2 additions & 2 deletions packages/utils-evm-hardhat/src/omnigraph/coordinates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion packages/utils-evm-hardhat/src/omnigraph/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ export interface OmniGraphHardhat<TNodeConfig = unknown, TEdgeConfig = unknown>
connections: OmniEdgeHardhat<TEdgeConfig>[]
}

export type OmniContractFactory = (point: OmniPointHardhat) => OmniContract | Promise<OmniContract>
export type OmniContractFactoryHardhat = (point: OmniPointHardhat) => OmniContract | Promise<OmniContract>
7 changes: 5 additions & 2 deletions packages/utils-evm/src/omnigraph/types.ts
Original file line number Diff line number Diff line change
@@ -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<TContract extends Contract = Contract> {
eid: EndpointId
contract: TContract
}

export type OmniContractFactory = (point: OmniPoint) => OmniContract | Promise<OmniContract>

0 comments on commit 8c641a8

Please sign in to comment.