Skip to content

Commit 855a840

Browse files
authored
Merge pull request #801 from LIT-Protocol/feature/lit-3796-js-sdk-add-minimal-zod
feat: add new schemas package using zod, bring acc validation package…
2 parents 1196d13 + f69dd87 commit 855a840

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1993
-653
lines changed

local-tests/build.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { fileURLToPath } from 'url';
44

55
const ALLOW_LIST = [
66
'ethers',
7-
'@lit-protocol/accs-schemas',
87
'@lit-protocol/contracts',
98
'crypto',
109
'secp256k1',

local-tests/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"@cypress/code-coverage": "^3.10.0",
2121
"@cypress/react": "^6.2.0",
2222
"@cypress/webpack-dev-server": "^2.3.0",
23-
"@lit-protocol/accs-schemas": "0.0.7",
2423
"@metamask/eth-sig-util": "5.0.2",
2524
"@mysten/sui.js": "^0.37.1",
2625
"@playwright/test": "^1.25.2",

local-tests/setup/accs/accs.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import {
2-
LPACC_EVM_ATOM,
3-
LPACC_EVM_BASIC,
4-
LPACC_SOL,
5-
} from '@lit-protocol/accs-schemas';
2+
AtomAcc,
3+
EvmBasicAcc,
4+
SolAcc,
5+
} from '@lit-protocol/access-control-conditions-schemas';
66

77
export namespace AccessControlConditions {
88
export const getEvmBasicAccessControlConditions = ({
99
userAddress,
10-
}): LPACC_EVM_BASIC[] => {
10+
}): EvmBasicAcc[] => {
1111
return [
1212
{
1313
contractAddress: '',
@@ -25,7 +25,7 @@ export namespace AccessControlConditions {
2525

2626
export const getSolBasicAccessControlConditions = ({
2727
userAddress,
28-
}): LPACC_SOL[] => {
28+
}): SolAcc[] => {
2929
return [
3030
{
3131
method: '',
@@ -45,7 +45,7 @@ export namespace AccessControlConditions {
4545

4646
export const getCosmosBasicAccessControlConditions = ({
4747
userAddress,
48-
}): LPACC_EVM_ATOM[] => {
48+
}): AtomAcc[] => {
4949
return [
5050
{
5151
conditionType: 'cosmos',

local-tests/tests/wrapped-keys/util.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { LIT_NETWORKS_KEYS } from '@lit-protocol/types';
2-
import { LIT_CHAINS } from '@lit-protocol/constants';
2+
import { LIT_CHAINS, LIT_NETWORK } from '@lit-protocol/constants';
33
import { ethers } from 'ethers';
44
import { config } from '@lit-protocol/wrapped-keys';
55
import {
@@ -51,7 +51,7 @@ export function getChainForNetwork(network: LIT_NETWORKS_KEYS): {
5151
chainId: number;
5252
} {
5353
switch (network) {
54-
case 'naga-dev':
54+
case LIT_NETWORK.NagaDev:
5555
return {
5656
chain: 'yellowstone',
5757
chainId: LIT_CHAINS['yellowstone'].chainId,
@@ -66,9 +66,9 @@ export function getGasParamsForNetwork(network: LIT_NETWORKS_KEYS): {
6666
gasLimit: number;
6767
} {
6868
switch (network) {
69-
case 'naga-dev':
69+
case LIT_NETWORK.NagaDev:
7070
return { gasLimit: 5000000 };
71-
case 'custom':
71+
case LIT_NETWORK.Custom:
7272
return { gasLimit: 5000000 };
7373
default:
7474
throw new Error(`Cannot identify chain params for ${network}`);

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
"@cosmjs/proto-signing": "0.30.1",
4141
"@cosmjs/stargate": "0.30.1",
4242
"@dotenvx/dotenvx": "^1.6.4",
43-
"@lit-protocol/accs-schemas": "^0.0.22",
4443
"@lit-protocol/contracts": "^0.0.86",
4544
"@metamask/eth-sig-util": "5.0.2",
4645
"@mysten/sui.js": "^0.37.1",
@@ -53,7 +52,6 @@
5352
"@walletconnect/utils": "2.9.2",
5453
"@walletconnect/web3wallet": "1.8.8",
5554
"abitype": "^1.0.8",
56-
"ajv": "^8.12.0",
5755
"base64url": "^3.0.1",
5856
"bech32": "^2.0.0",
5957
"cbor-web": "^9.0.2",
@@ -70,7 +68,9 @@
7068
"tslib": "^2.7.0",
7169
"tweetnacl": "^1.0.3",
7270
"tweetnacl-util": "^0.15.1",
73-
"uint8arrays": "^4.0.3"
71+
"uint8arrays": "^4.0.3",
72+
"zod": "^3.24.2",
73+
"zod-validation-error": "^3.4.0"
7474
},
7575
"devDependencies": {
7676
"@nx/devkit": "17.3.0",
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
"files": ["*.json"],
19+
"parser": "jsonc-eslint-parser",
20+
"rules": {
21+
"@nx/dependency-checks": "error"
22+
}
23+
}
24+
]
25+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Lit Protocol Access Control Condition definitions
2+
3+
The Lit Protocol Access Control Condition definitions are a set of Zod schemas that define the conditions that can be used to control access to a resource.
4+
5+
## Condition definition
6+
7+
A condition definition is a Zod schema that defines a condition that can be used to control access to a resource. More information can be found in the [Lit Protocol Access Control Condition definition specification](https://developer.litprotocol.com/v3/sdk/access-control/condition-types/unified-access-control-conditions)
8+
9+
## Condition types
10+
11+
The following condition types are defined:
12+
13+
- EVM Basic Conditions
14+
- EVM Custom Contract Conditions
15+
- Solana RPC Conditions
16+
- Cosmos or Kyve Conditions
17+
18+
Each has its own Zod schema that defines their properties.
19+
20+
## Derived types
21+
22+
Each condition type has a derived type that can be used to type the condition object when using Typescript.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* eslint-disable */
2+
export default {
3+
displayName: 'access-control-conditions-schemas',
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:
15+
'../../coverage/packages/access-control-conditions-schemas',
16+
setupFilesAfterEnv: ['../../jest.setup.js'],
17+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "@lit-protocol/access-control-conditions-schemas",
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+
"publishConfig": {
16+
"access": "public",
17+
"directory": "../../dist/packages/access-control-conditions-schemas"
18+
},
19+
"gitHead": "0d7334c2c55f448e91fe32f29edc5db8f5e09e4b",
20+
"tags": [
21+
"universal"
22+
],
23+
"version": "8.0.0-alpha.0",
24+
"main": "./dist/src/index.js",
25+
"typings": "./dist/src/index.d.ts"
26+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"name": "access-control-conditions-schemas",
3+
"$schema": "../../node_modules/nx/access-control-conditions-schemas/project-schema.json",
4+
"sourceRoot": "packages/access-control-conditions-schemas/src",
5+
"projectType": "library",
6+
"targets": {
7+
"build": {
8+
"executor": "@nx/js:tsc",
9+
"outputs": ["{options.outputPath}"],
10+
"options": {
11+
"outputPath": "dist/packages/access-control-conditions-schemas",
12+
"main": "packages/access-control-conditions-schemas/src/index.ts",
13+
"tsConfig": "packages/access-control-conditions-schemas/tsconfig.lib.json",
14+
"assets": ["packages/access-control-conditions-schemas/*.md"],
15+
"updateBuildableProjectDepsInPackageJson": true
16+
}
17+
},
18+
"generateDoc": {
19+
"executor": "nx:run-commands",
20+
"options": {
21+
"command": "yarn typedoc --entryPointStrategy expand packages/access-control-conditions-schemas/src --exclude packages/access-control-conditions-schemas/src/**/*.spec.** --tsconfig packages/access-control-conditions-schemas/tsconfig.json"
22+
}
23+
},
24+
"lint": {
25+
"executor": "@nx/linter:eslint",
26+
"outputs": ["{options.outputFile}"],
27+
"options": {
28+
"lintFilePatterns": [
29+
"packages/access-control-conditions-schemas/**/*.ts"
30+
]
31+
}
32+
},
33+
"testPackage": {
34+
"executor": "@nx/jest:jest",
35+
"outputs": [
36+
"{workspaceRoot}/coverage/packages/access-control-conditions-schemas"
37+
],
38+
"options": {
39+
"jestConfig": "packages/access-control-conditions-schemas/jest.config.ts",
40+
"passWithNoTests": true
41+
}
42+
},
43+
"testWatch": {
44+
"executor": "@nx/jest:jest",
45+
"outputs": [
46+
"{workspaceRoot}/coverage/packages/access-control-conditions-schemas"
47+
],
48+
"options": {
49+
"jestConfig": "packages/access-control-conditions-schemas/jest.config.ts",
50+
"passWithNoTests": true,
51+
"watch": true
52+
}
53+
}
54+
},
55+
"tags": []
56+
}

0 commit comments

Comments
 (0)