Skip to content

Commit 163e083

Browse files
feat(networks): LIT-4101 - Define initial package structure/stubs for @lit-protocol/networks
1 parent 15091e7 commit 163e083

File tree

20 files changed

+4088
-3192
lines changed

20 files changed

+4088
-3192
lines changed

local-tests/setup/networkContext.json

Lines changed: 3733 additions & 3192 deletions
Large diffs are not rendered by default.

packages/networks/.babelrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"presets": [
3+
[
4+
"@nx/web/babel",
5+
{
6+
"useBuiltIns": "usage"
7+
}
8+
]
9+
]
10+
}

packages/networks/.eslintrc.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"extends": ["../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7+
"rules": {}
8+
},
9+
{
10+
"files": ["*.ts", "*.tsx"],
11+
"rules": {}
12+
},
13+
{
14+
"files": ["*.js", "*.jsx"],
15+
"rules": {}
16+
}
17+
]
18+
}

packages/networks/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Quick Start
2+
3+
This package contains network definitions for LIT protocol networks. A network contains chain configuration and configuration used to control how consumers communicate with LIT Network nodes.
4+
5+
### node.js / browser
6+
7+
```
8+
yarn add @lit-protocol/networks
9+
```

packages/networks/index.ts

Whitespace-only changes.

packages/networks/jest.config.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* eslint-disable */
2+
export default {
3+
displayName: 'networks',
4+
preset: '../../jest.preset.js',
5+
globals: {
6+
'ts-jest': {
7+
tsconfig: '<rootDir>/tsconfig.spec.json',
8+
},
9+
},
10+
transform: {
11+
'^.+\\.[t]s$': 'ts-jest',
12+
},
13+
moduleFileExtensions: ['ts', 'js', 'html'],
14+
coverageDirectory: '../../coverage/packages/networks',
15+
setupFilesAfterEnv: ['../../jest.setup.js'],
16+
};

packages/networks/package.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "@lit-protocol/networks",
3+
"license": "MIT",
4+
"homepage": "https://github.com/Lit-Protocol/js-sdk",
5+
"repository": {
6+
"type": "git",
7+
"url": "https://github.com/LIT-Protocol/js-sdk"
8+
},
9+
"keywords": [
10+
"library"
11+
],
12+
"bugs": {
13+
"url": "https://github.com/LIT-Protocol/js-sdk/issues"
14+
},
15+
"type": "commonjs",
16+
"publishConfig": {
17+
"access": "public",
18+
"directory": "../../dist/packages/networks"
19+
},
20+
"gitHead": "0d7334c2c55f448e91fe32f29edc5db8f5e09e4b",
21+
"tags": [
22+
"universal"
23+
],
24+
"version": "8.0.0-alpha.0",
25+
"main": "./dist/src/index.js",
26+
"typings": "./dist/src/index.d.ts"
27+
}

packages/networks/project.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "networks",
3+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "packages/networks/src",
5+
"projectType": "library",
6+
"targets": {
7+
"build": {
8+
"executor": "@nx/js:tsc",
9+
"outputs": ["{options.outputPath}"],
10+
"options": {
11+
"outputPath": "dist/packages/networks",
12+
"main": "packages/networks/src/index.ts",
13+
"tsConfig": "packages/networks/tsconfig.lib.json",
14+
"assets": ["packages/networks/*.md"],
15+
"updateBuildableProjectDepsInPackageJson": true
16+
}
17+
},
18+
"lint": {
19+
"executor": "@nx/linter:eslint",
20+
"outputs": ["{options.outputFile}"],
21+
"options": {
22+
"lintFilePatterns": ["packages/networks/**/*.ts"]
23+
}
24+
},
25+
"test": {
26+
"executor": "@nx/jest:jest",
27+
"outputs": ["{workspaceRoot}/coverage/packages/networks"],
28+
"options": {
29+
"jestConfig": "packages/networks/jest.config.ts",
30+
"passWithNoTests": true
31+
}
32+
}
33+
},
34+
"tags": []
35+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { HTTP, HTTPS, LIT_ENDPOINT } from '@lit-protocol/constants';
2+
3+
import type { LitChainConfig, LitNetworkConfig } from './types';
4+
5+
export abstract class LitNetwork {
6+
private readonly _name: string;
7+
private readonly _chainConfig: LitChainConfig;
8+
private readonly _endpoints: typeof LIT_ENDPOINT;
9+
private readonly _httpProtocol: typeof HTTP | typeof HTTPS;
10+
private readonly _options: unknown;
11+
12+
constructor(config: LitNetworkConfig) {
13+
this._name = config.name;
14+
this._chainConfig = config.chainConfig;
15+
this._endpoints = config.endpoints;
16+
this._httpProtocol = config.httpProtocol;
17+
this._options = config.options;
18+
}
19+
20+
get name() {
21+
return this._name;
22+
}
23+
24+
get endpoints() {
25+
return this._endpoints;
26+
}
27+
28+
get httpProtocol() {
29+
return this._httpProtocol;
30+
}
31+
32+
get options() {
33+
return this._options;
34+
}
35+
36+
get chainConfig() {
37+
return this._chainConfig;
38+
}
39+
40+
abstract createSignRequests(params: unknown): Promise<unknown>;
41+
abstract handleSignResponses(params: unknown): Promise<unknown>;
42+
43+
abstract createDecryptRequests(params: unknown): Promise<unknown>;
44+
abstract handleDecryptResponses(params: unknown): Promise<unknown>;
45+
46+
abstract createExecuteJsRequests(params: unknown): Promise<unknown>;
47+
abstract handleExecuteJsResponses(params: unknown): Promise<unknown>;
48+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Extract static methods for handling contract context and ABI/type inferrance into this folder

0 commit comments

Comments
 (0)