Skip to content

Commit

Permalink
feat: options
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Goulding <[email protected]>
  • Loading branch information
ryandgoulding committed Dec 9, 2023
1 parent 095c96e commit fe860d7
Show file tree
Hide file tree
Showing 32 changed files with 665 additions and 35 deletions.
3 changes: 3 additions & 0 deletions packages/omnicounter-utils-evm/.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/omnicounter-utils-evm/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../../.eslintrc.json"
}
23 changes: 23 additions & 0 deletions packages/omnicounter-utils-evm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<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/omnicounter-utils-evm</h1>

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

## Installation

```sh
$ npm install @layerzerolabs/omnicounter-utils-evm
```
8 changes: 8 additions & 0 deletions packages/omnicounter-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',
},
};
55 changes: 55 additions & 0 deletions packages/omnicounter-utils-evm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"name": "@layerzerolabs/omnicounter-utils-evm",
"version": "0.0.1",
"private": true,
"description": "Utilities for working with LayerZero OmniCounter contract",
"repository": {
"type": "git",
"url": "git+https://github.com/LayerZero-Labs/lz-utils.git",
"directory": "packages/ua-utils-evm"
},
"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/"
],
"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.70",
"@layerzerolabs/omnicounter-utils": "~0.0.1",
"@layerzerolabs/ua-utils": "~0.1.0",
"@layerzerolabs/ua-utils-evm": "~0.0.1",
"@layerzerolabs/utils-evm": "~0.0.1",
"@types/jest": "^29.5.10",
"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.70",
"@layerzerolabs/omnicounter-utils": "~0.0.1",
"@layerzerolabs/ua-utils": "~0.1.0",
"@layerzerolabs/ua-utils-evm": "~0.0.1",
"@layerzerolabs/utils-evm": "~0.0.1",
"zod": "^3.22.4"
}
}
1 change: 1 addition & 0 deletions packages/omnicounter-utils-evm/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './omnicounter'
1 change: 1 addition & 0 deletions packages/omnicounter-utils-evm/src/omnicounter/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './sdk'
10 changes: 10 additions & 0 deletions packages/omnicounter-utils-evm/src/omnicounter/sdk.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { IOmniCounterApp } from '@layerzerolabs/omnicounter-utils'
import { OApp } from '@layerzerolabs/ua-utils-evm'
import { OmniTransaction } from '@layerzerolabs/utils'

export class OmniCounterApp extends OApp implements IOmniCounterApp {
public async increment(eid: number, type: number, options: string): Promise<OmniTransaction> {
const data = this.contract.contract.interface.encodeFunctionData('increment', [eid, type, options])
return super.createTransaction(data)
}
}
11 changes: 11 additions & 0 deletions packages/omnicounter-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"],
"compilerOptions": {
"types": ["node", "jest"],
"paths": {
"@/*": ["./src/*"]
}
}
}
12 changes: 12 additions & 0 deletions packages/omnicounter-utils-evm/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'],
})
3 changes: 3 additions & 0 deletions packages/omnicounter-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/omnicounter-utils/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../../.eslintrc.json"
}
23 changes: 23 additions & 0 deletions packages/omnicounter-utils/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<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/omnicounter-utils</h1>

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

## Installation

```sh
$ npm install @layerzerolabs/omnicounter-utils
```
8 changes: 8 additions & 0 deletions packages/omnicounter-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',
},
};
50 changes: 50 additions & 0 deletions packages/omnicounter-utils/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"name": "@layerzerolabs/omnicounter-utils",
"version": "0.0.1",
"private": true,
"description": "Utilities for working with LayerZero OmniCounter contract",
"repository": {
"type": "git",
"url": "git+https://github.com/LayerZero-Labs/lz-utils.git",
"directory": "packages/omnicounter-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.70",
"@layerzerolabs/utils": "~0.0.1",
"@types/jest": "^29.5.10",
"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.70",
"@layerzerolabs/utils": "~0.0.1",
"zod": "^3.22.4"
}
}
1 change: 1 addition & 0 deletions packages/omnicounter-utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './omnicounter/types'
6 changes: 6 additions & 0 deletions packages/omnicounter-utils/src/omnicounter/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { OmniTransaction } from '@layerzerolabs/utils'
import { EndpointId } from '@layerzerolabs/lz-definitions'

export interface IOmniCounterApp {
increment(eid: EndpointId, type: number, options: string): Promise<OmniTransaction>
}
11 changes: 11 additions & 0 deletions packages/omnicounter-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/omnicounter-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'],
})
8 changes: 3 additions & 5 deletions packages/ua-utils-evm-hardhat-test/contracts/DefaultOApp.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.22;

contract DefaultOApp {
mapping(uint256 => bytes32) public peers;
import { OmniCounter as OmniCounterImpl } from "@layerzerolabs/lz-evm-oapp-v2/contracts/examples/OmniCounter.sol";

function setPeer(uint256 eid, bytes32 peer) external {
peers[eid] = peer;
}
contract DefaultOApp is OmniCounterImpl {
constructor(address _endpoint) OmniCounterImpl(_endpoint) {}
}
Loading

0 comments on commit fe860d7

Please sign in to comment.