Skip to content

Commit

Permalink
chore: Move endpoint & uln stuff to protocol-utils & protocol-utils-evm
Browse files Browse the repository at this point in the history
  • Loading branch information
janjakubnanista committed Dec 5, 2023
1 parent 9f6a998 commit 3b114ed
Show file tree
Hide file tree
Showing 39 changed files with 287 additions and 34 deletions.
2 changes: 2 additions & 0 deletions packages/protocol-utils-evm/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
node_modules
2 changes: 2 additions & 0 deletions packages/protocol-utils-evm/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
node_modules/
29 changes: 29 additions & 0 deletions packages/protocol-utils-evm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<p align="center">
<a href="https://layerzero.network">
<img alt="LayerZero" style="max-width: 500px" src="https://d3a2dpnnrypp5h.cloudfront.net/bridge-app/lz.png"/>
</a>
</p>

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

<!-- The badges section -->
<p align="center">
<!-- Shields.io NPM published package version -->
<a href="https://www.npmjs.com/package/@layerzerolabs/utils-evm"><img alt="NPM Version" src="https://img.shields.io/npm/v/@layerzerolabs/utils-evm"/></a>
<!-- Shields.io NPM downloads -->
<a href="https://www.npmjs.com/package/@layerzerolabs/utils-evm"><img alt="Downloads" src="https://img.shields.io/npm/dm/@layerzerolabs/utils-evm"/></a>
<!-- Shields.io license badge -->
<a href="https://www.npmjs.com/package/@layerzerolabs/utils-evm"><img alt="NPM License" src="https://img.shields.io/npm/l/@layerzerolabs/utils-evm"/></a>
</p>

Utilities for working with LayerZero EVM contracts.

## Installation

```bash
yarn add @layerzerolabs/utils-evm

pnpm add @layerzerolabs/utils-evm

npm install @layerzerolabs/utils-evm
```
8 changes: 8 additions & 0 deletions packages/protocol-utils-evm/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
},
};
69 changes: 69 additions & 0 deletions packages/protocol-utils-evm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"name": "@layerzerolabs/protocol-utils-evm",
"version": "0.0.1",
"private": true,
"description": "Utilities for LayerZero EVM projects",
"repository": {
"type": "git",
"url": "git+https://github.com/LayerZero-Labs/lz-utils.git",
"directory": "packages/protocol-utils-evm"
},
"license": "MIT",
"exports": {
".": {
"types": "./dist/index.d.ts",
"require": "./dist/index.js",
"import": "./dist/index.mjs"
},
"./*": {
"types": "./dist/*.d.ts",
"require": "./dist/*.js",
"import": "./dist/*.mjs"
}
},
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"files": [
"./dist/index.*"
],
"scripts": {
"prebuild": "npx tsc --noEmit -p tsconfig.build.json",
"build": "npx tsup",
"clean": "rm -rf dist",
"dev": "npx tsup --watch",
"lint": "npx eslint '**/*.{js,ts,json}'",
"test": "jest --passWithNoTests"
},
"dependencies": {
"p-memoize": "~4.0.1"
},
"devDependencies": {
"@ethersproject/abstract-provider": "^5.7.0",
"@ethersproject/abstract-signer": "^5.7.0",
"@ethersproject/contracts": "^5.7.0",
"@ethersproject/providers": "^5.7.0",
"@layerzerolabs/lz-definitions": "~1.5.68",
"@layerzerolabs/protocol-utils": "~0.0.1",
"@layerzerolabs/test-utils": "~0.0.1",
"@layerzerolabs/utils": "~0.0.1",
"@layerzerolabs/utils-evm": "~0.0.1",
"@types/jest": "^29.5.10",
"fast-check": "^3.14.0",
"jest": "^29.7.0",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"tsup": "~8.0.1",
"typescript": "^5.2.2"
},
"peerDependencies": {
"@ethersproject/abstract-provider": "^5.7.0",
"@ethersproject/abstract-signer": "^5.7.0",
"@ethersproject/contracts": "^5.7.0",
"@ethersproject/providers": "^5.7.0",
"@layerzerolabs/lz-definitions": "~1.5.68",
"@layerzerolabs/protocol-utils": "~0.0.1",
"@layerzerolabs/utils": "~0.0.1",
"@layerzerolabs/utils-evm": "~0.0.1"
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { formatEid, type IEndpoint } from '@layerzerolabs/utils'
import type { Address, OmniTransaction } from '@layerzerolabs/utils'
import type { IEndpoint } from '@layerzerolabs/protocol-utils'
import { formatEid, type Address, type OmniTransaction } from '@layerzerolabs/utils'
import type { EndpointId } from '@layerzerolabs/lz-definitions'
import { OmniContract } from '@/omnigraph/types'
import { ignoreZero, makeZero } from '@/address'
import { omniContractToPoint } from '@/omnigraph/coordinates'
import { ignoreZero, makeZero, omniContractToPoint, type OmniContract } from '@layerzerolabs/utils-evm'

export class Endpoint implements IEndpoint {
constructor(public readonly contract: OmniContract) {}
Expand Down
2 changes: 2 additions & 0 deletions packages/protocol-utils-evm/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './endpoint'
export * from './uln302'
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { formatEid, type IUln302, type Uln302ExecutorConfig, type Uln302UlnConfig } from '@layerzerolabs/utils'
import type { OmniTransaction } from '@layerzerolabs/utils'
import type { EndpointId } from '@layerzerolabs/lz-definitions'
import { OmniContract } from '@/omnigraph/types'
import { omniContractToPoint } from '@/omnigraph/coordinates'
import type { IUln302, Uln302ExecutorConfig, Uln302UlnConfig } from '@layerzerolabs/protocol-utils'
import { formatEid, type OmniTransaction } from '@layerzerolabs/utils'
import { omniContractToPoint, type OmniContract } from '@layerzerolabs/utils-evm'

export class Uln302 implements IUln302 {
constructor(public readonly contract: OmniContract) {}
Expand Down
4 changes: 4 additions & 0 deletions packages/protocol-utils-evm/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["node_modules", "dist", "test"]
}
11 changes: 11 additions & 0 deletions packages/protocol-utils-evm/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.json",
"exclude": ["dist", "node_modules"],
"include": ["src", "test", "*.config.ts"],
"compilerOptions": {
"types": ["node", "jest"],
"paths": {
"@/*": ["./src/*"]
}
}
}
14 changes: 14 additions & 0 deletions packages/protocol-utils-evm/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { defineConfig } from 'tsup'

export default defineConfig([
{
entry: ['src/index.ts'],
outDir: './dist',
clean: true,
dts: true,
sourcemap: true,
splitting: false,
treeshake: true,
format: ['esm', 'cjs'],
},
])
3 changes: 3 additions & 0 deletions packages/protocol-utils/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.turbo
dist
node_modules
3 changes: 3 additions & 0 deletions packages/protocol-utils/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../../.eslintrc.json"
}
31 changes: 31 additions & 0 deletions packages/protocol-utils/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<p align="center">
<a href="https://layerzero.network">
<img alt="LayerZero" style="max-width: 500px" src="https://d3a2dpnnrypp5h.cloudfront.net/bridge-app/lz.png"/>
</a>
</p>

<h1 align="center">@layerzerolabs/protocol-utils</h1>

<!-- The badges section -->
<p align="center">
<!-- Shields.io NPM published package version -->
<a href="https://www.npmjs.com/package/@layerzerolabs/protocol-utils"><img alt="NPM Version" src="https://img.shields.io/npm/v/@layerzerolabs/protocol-utils"/></a>
<!-- Shields.io NPM downloads -->
<a href="https://www.npmjs.com/package/@layerzerolabs/protocol-utils"><img alt="Downloads" src="https://img.shields.io/npm/dm/@layerzerolabs/protocol-utils"/></a>
<!-- Shields.io license badge -->
<a href="https://www.npmjs.com/package/@layerzerolabs/protocol-utils"><img alt="NPM License" src="https://img.shields.io/npm/l/@layerzerolabs/protocol-utils"/></a>
</p>

## Installation

```bash
npm install --save @layerzerolabs/protocol-utils
```

```bash
yarn install @layerzerolabs/protocol-utils
```

```bash
pnpm install @layerzerolabs/protocol-utils
```
8 changes: 8 additions & 0 deletions packages/protocol-utils/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
},
};
52 changes: 52 additions & 0 deletions packages/protocol-utils/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "@layerzerolabs/protocol-utils",
"version": "0.0.1",
"private": true,
"description": "Utilities for working with LayerZero protocol contracts",
"repository": {
"type": "git",
"url": "git+https://github.com/LayerZero-Labs/lz-utils.git",
"directory": "packages/protocol-utils"
},
"license": "MIT",
"exports": {
".": {
"types": "./dist/index.d.ts",
"require": "./dist/index.js",
"import": "./dist/index.mjs"
}
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": [
"dist/",
"LICENSE"
],
"scripts": {
"prebuild": "tsc -noEmit",
"build": "npx tsup",
"clean": "rm -rf dist",
"lint": "npx eslint '**/*.{js,ts,json}'",
"test": "jest --passWithNoTests"
},
"devDependencies": {
"@layerzerolabs/lz-definitions": "~1.5.68",
"@layerzerolabs/test-utils": "~0.0.1",
"@layerzerolabs/utils": "~0.0.1",
"@types/jest": "^29.5.10",
"fast-check": "^3.14.0",
"jest": "^29.7.0",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"tslib": "~2.6.2",
"tsup": "~8.0.1",
"typescript": "^5.2.2",
"zod": "^3.22.4"
},
"peerDependencies": {
"@layerzerolabs/lz-definitions": "~1.5.68",
"@layerzerolabs/utils": "~0.0.1",
"zod": "^3.22.4"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { flattenTransactions } from '@/transactions/utils'
import { flattenTransactions, type OmniTransaction } from '@layerzerolabs/utils'
import type { EndpointFactory, EndpointOmniGraph } from './types'
import type { OmniTransaction } from '@/transactions/types'

export type EndpointConfigurator = (graph: EndpointOmniGraph, createSdk: EndpointFactory) => Promise<OmniTransaction[]>

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import type { OmniGraph, OmniPointBasedFactory } from '@/omnigraph/types'
import type { OmniTransaction } from '@/transactions/types'
import type { Address } from '@/types'
import type { Address, OmniGraph, OmniPointBasedFactory, OmniTransaction } from '@layerzerolabs/utils'
import type { EndpointId } from '@layerzerolabs/lz-definitions'

export interface IEndpoint {
Expand Down
2 changes: 2 additions & 0 deletions packages/protocol-utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './endpoint'
export * from './uln302'
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { flattenTransactions } from '@/transactions/utils'
import { flattenTransactions, type OmniTransaction } from '@layerzerolabs/utils'
import type { Uln302Factory, Uln302OmniGraph } from './types'
import type { OmniTransaction } from '@/transactions/types'

export type Uln302Configurator = (graph: Uln302OmniGraph, createSdk: Uln302Factory) => Promise<OmniTransaction[]>

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import type { OmniGraph, OmniPointBasedFactory } from '@/omnigraph/types'
import type { OmniTransaction } from '@/transactions/types'
import type { Address } from '@/types'
import type { Address, OmniGraph, OmniPointBasedFactory, OmniTransaction } from '@layerzerolabs/utils'
import type { EndpointId } from '@layerzerolabs/lz-definitions'

export interface IUln302 {
Expand Down
11 changes: 11 additions & 0 deletions packages/protocol-utils/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.json",
"exclude": ["dist", "node_modules"],
"include": ["src", "test"],
"compilerOptions": {
"types": ["node", "jest"],
"paths": {
"@/*": ["./src/*"]
}
}
}
12 changes: 12 additions & 0 deletions packages/protocol-utils/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { defineConfig } from 'tsup'

export default defineConfig({
entry: ['src/index.ts'],
outDir: './dist',
clean: true,
dts: true,
sourcemap: true,
splitting: false,
treeshake: true,
format: ['esm', 'cjs'],
})
2 changes: 1 addition & 1 deletion packages/test-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"typescript": "^5.2.2"
},
"peerDependencies": {
"@layerzerolabs/lz-definitions": "~1.5.67",
"@layerzerolabs/lz-definitions": "~1.5.68",
"fast-check": "^3.14.0"
}
}
2 changes: 2 additions & 0 deletions packages/ua-utils-evm-hardhat-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
"@layerzerolabs/lz-definitions": "~1.5.68",
"@layerzerolabs/lz-evm-sdk-v1": "~1.5.68",
"@layerzerolabs/lz-evm-sdk-v2": "~1.5.68",
"@layerzerolabs/protocol-utils": "~0.0.1",
"@layerzerolabs/protocol-utils-evm": "~0.0.1",
"@layerzerolabs/ua-utils": "~0.1.0",
"@layerzerolabs/ua-utils-evm": "~0.0.1",
"@layerzerolabs/ua-utils-evm-hardhat": "~0.0.1",
Expand Down
7 changes: 4 additions & 3 deletions packages/ua-utils-evm-hardhat-test/test/__utils__/endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ import {
} from '@layerzerolabs/utils-evm-hardhat'
import deploy from '../../deploy/001_bootstrap'
import { EndpointId } from '@layerzerolabs/lz-definitions'
import { Endpoint, omniContractToPoint, Uln302 } from '@layerzerolabs/utils-evm'
import { omniContractToPoint } from '@layerzerolabs/utils-evm'
import {
configureEndpoint,
EndpointEdgeConfig,
EndpointFactory,
Uln302NodeConfig,
formatOmniPoint,
Uln302ExecutorConfig,
configureUln302,
Uln302Factory,
Uln302UlnConfig,
} from '@layerzerolabs/utils'
} from '@layerzerolabs/protocol-utils'
import { Endpoint, Uln302 } from '@layerzerolabs/protocol-utils-evm'
import { formatOmniPoint } from '@layerzerolabs/utils'

export const ethEndpoint = { eid: EndpointId.ETHEREUM_MAINNET, contractName: 'EndpointV2' }
export const ethReceiveUln = { eid: EndpointId.ETHEREUM_MAINNET, contractName: 'ReceiveUln302' }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Endpoint, Uln302 } from '@layerzerolabs/utils-evm'
import { createConnectedContractFactory } from '@layerzerolabs/utils-evm-hardhat'
import type { OmniPoint } from '@layerzerolabs/utils'
import { omniContractToPoint } from '@layerzerolabs/utils-evm'
import { expect } from 'chai'
import { describe } from 'mocha'
import { EndpointId } from '@layerzerolabs/lz-definitions'
import { defaultUlnConfig, setupDefaultEndpoint } from '../__utils__/endpoint'
import { Endpoint, Uln302 } from '@layerzerolabs/protocol-utils-evm'

describe('endpoint/config', () => {
const ethEndpoint = { eid: EndpointId.ETHEREUM_MAINNET, contractName: 'EndpointV2' }
Expand Down
Loading

0 comments on commit 3b114ed

Please sign in to comment.