From 95b489d67aed588bf7bbee08a528d13c6451aeaf Mon Sep 17 00:00:00 2001
From: Piotr Roslaniec
Date: Fri, 17 Nov 2023 07:37:23 +0100
Subject: [PATCH] refactor(packaging): remove peer dependencies where not
needed
---
demos/taco-demo/package.json | 5 +-
demos/taco-nft-demo/package.json | 5 +-
examples/pre/nextjs/package.json | 7 +-
examples/pre/nodejs/package.json | 4 +-
examples/pre/react/package.json | 6 +-
examples/pre/webpack-5/package.json | 4 +-
examples/pre/webpack-5/src/index.ts | 2 +-
examples/taco/nextjs/package.json | 4 -
examples/taco/nodejs/package.json | 4 +-
examples/taco/webpack-5/src/index.ts | 2 +-
package.json | 2 +-
packages/pre/package.json | 6 +-
packages/shared/package.json | 2 +-
packages/shared/scripts/typechain.ts | 1 -
.../src/contracts/agents/coordinator.ts | 2 +-
packages/taco/package.json | 6 +-
.../taco/src/conditions/compound-condition.ts | 9 +-
.../conditions/compound-condition.test.ts | 87 +++++++++++--------
packages/taco/test/conditions/context.test.ts | 48 +++++-----
packages/test-utils/package.json | 2 +-
pnpm-lock.yaml | 31 +++----
21 files changed, 113 insertions(+), 126 deletions(-)
diff --git a/demos/taco-demo/package.json b/demos/taco-demo/package.json
index 3170785f8..83fb52dc3 100644
--- a/demos/taco-demo/package.json
+++ b/demos/taco-demo/package.json
@@ -13,6 +13,7 @@
},
"dependencies": {
"@nucypher/taco": "^0.1.0-rc.6",
+ "@nucypher/shared": "^0.1.0-rc.4",
"@usedapp/core": "^1.2.13",
"buffer": "^6.0.3",
"ethers": "^5.7.1",
@@ -22,10 +23,6 @@
"react-dom": "^18.2.0",
"react-spinners": "^0.13.6"
},
- "peerDependencies": {
- "@nucypher/taco": "workspace:*",
- "@nucypher/shared": "workspace:*"
- },
"devDependencies": {
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.7",
"@types/react": "^18.2.33",
diff --git a/demos/taco-nft-demo/package.json b/demos/taco-nft-demo/package.json
index 733d8ca15..2a02e6fbc 100644
--- a/demos/taco-nft-demo/package.json
+++ b/demos/taco-nft-demo/package.json
@@ -13,6 +13,7 @@
},
"dependencies": {
"@nucypher/taco": "^0.1.0-rc.6",
+ "@nucypher/shared": "^0.1.0-rc.4",
"@usedapp/core": "^1.2.13",
"buffer": "^6.0.3",
"ethers": "^5.7.1",
@@ -22,10 +23,6 @@
"react-dom": "^18.2.0",
"react-spinners": "^0.13.6"
},
- "peerDependencies": {
- "@nucypher/taco": "workspace:*",
- "@nucypher/shared": "workspace:*"
- },
"devDependencies": {
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.7",
"@types/react": "^18.2.33",
diff --git a/examples/pre/nextjs/package.json b/examples/pre/nextjs/package.json
index 4b9096196..988d049b3 100644
--- a/examples/pre/nextjs/package.json
+++ b/examples/pre/nextjs/package.json
@@ -19,11 +19,6 @@
"ethers": "^5.7.2",
"next": "13.5.6",
"react": "18.2.0",
- "react-dom": "18.2.0",
- "typescript": "5.2.2"
- },
- "peerDependencies": {
- "ethers": "^5.7.2",
- "typescript": "5.2.2"
+ "react-dom": "18.2.0"
}
}
diff --git a/examples/pre/nodejs/package.json b/examples/pre/nodejs/package.json
index dff9ae870..35a479f94 100644
--- a/examples/pre/nodejs/package.json
+++ b/examples/pre/nodejs/package.json
@@ -11,9 +11,7 @@
},
"dependencies": {
"@nucypher/pre": "workspace:*",
- "dotenv": "^16.3.1"
- },
- "peerDependencies": {
+ "dotenv": "^16.3.1",
"ethers": "^5.7.2"
}
}
diff --git a/examples/pre/react/package.json b/examples/pre/react/package.json
index 46729881b..4b362961d 100644
--- a/examples/pre/react/package.json
+++ b/examples/pre/react/package.json
@@ -25,15 +25,13 @@
"dependencies": {
"@nucypher/pre": "workspace:*",
"react": "^18.2.0",
- "react-dom": "^18.2.0"
+ "react-dom": "^18.2.0",
+ "ethers": "^5.7.2"
},
"devDependencies": {
"@types/node": "^16.18.50",
"@types/react": "^18.2.33",
"@types/react-dom": "^18.2.14",
"react-scripts": "^5.0.1"
- },
- "peerDependencies": {
- "ethers": "^5.7.2"
}
}
diff --git a/examples/pre/webpack-5/package.json b/examples/pre/webpack-5/package.json
index a3863a3b5..14a0f6413 100644
--- a/examples/pre/webpack-5/package.json
+++ b/examples/pre/webpack-5/package.json
@@ -19,9 +19,7 @@
"esbuild-loader": "^2.11.0",
"webpack": "^5.4.0",
"webpack-cli": "^5.1.4",
- "webpack-dev-server": "^4.7.4"
- },
- "peerDependencies": {
+ "webpack-dev-server": "^4.7.4",
"ethers": "^5.7.2"
}
}
diff --git a/examples/pre/webpack-5/src/index.ts b/examples/pre/webpack-5/src/index.ts
index 4d132918a..eb555dc06 100644
--- a/examples/pre/webpack-5/src/index.ts
+++ b/examples/pre/webpack-5/src/index.ts
@@ -7,7 +7,7 @@ import {
SecretKey,
} from '@nucypher/pre';
import { ethers } from 'ethers';
-import { hexlify } from "ethers/lib/utils";
+import { hexlify } from 'ethers/lib/utils';
declare global {
interface Window {
diff --git a/examples/taco/nextjs/package.json b/examples/taco/nextjs/package.json
index 4e1d3a45a..901170625 100644
--- a/examples/taco/nextjs/package.json
+++ b/examples/taco/nextjs/package.json
@@ -21,9 +21,5 @@
"react": "18.2.0",
"react-dom": "18.2.0",
"typescript": "5.2.2"
- },
- "peerDependencies": {
- "ethers": "^5.7.2",
- "typescript": "5.2.2"
}
}
diff --git a/examples/taco/nodejs/package.json b/examples/taco/nodejs/package.json
index aa9eef320..ecf9cdb3b 100644
--- a/examples/taco/nodejs/package.json
+++ b/examples/taco/nodejs/package.json
@@ -11,9 +11,7 @@
},
"dependencies": {
"@nucypher/taco": "workspace:*",
- "dotenv": "^16.3.1"
- },
- "peerDependencies": {
+ "dotenv": "^16.3.1",
"ethers": "^5.7.2"
}
}
diff --git a/examples/taco/webpack-5/src/index.ts b/examples/taco/webpack-5/src/index.ts
index 2a6b722c8..831647afd 100644
--- a/examples/taco/webpack-5/src/index.ts
+++ b/examples/taco/webpack-5/src/index.ts
@@ -9,7 +9,7 @@ import {
toBytes,
} from '@nucypher/taco';
import { ethers } from 'ethers';
-import { hexlify } from "ethers/lib/utils";
+import { hexlify } from 'ethers/lib/utils';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
declare const window: any;
diff --git a/package.json b/package.json
index 45821d444..5b58161fd 100644
--- a/package.json
+++ b/package.json
@@ -25,7 +25,7 @@
},
"dependencies": {
"@changesets/cli": "^2.26.2",
- "@nucypher/nucypher-core": "0.13.0-alpha.1"
+ "@nucypher/nucypher-core": "^0.13.0-alpha.1"
},
"devDependencies": {
"@skypack/package-check": "^0.2.2",
diff --git a/packages/pre/package.json b/packages/pre/package.json
index 3cd1fa2fd..54d0b2434 100644
--- a/packages/pre/package.json
+++ b/packages/pre/package.json
@@ -39,14 +39,12 @@
},
"dependencies": {
"@nucypher/nucypher-core": "^0.13.0-alpha.1",
- "@nucypher/shared": "workspace:*"
+ "@nucypher/shared": "workspace:*",
+ "ethers": "^5.7.2"
},
"devDependencies": {
"@nucypher/test-utils": "workspace:*"
},
- "peerDependencies": {
- "ethers": "^5.7.2"
- },
"engines": {
"node": ">=18",
"pnpm": ">=8.0.0"
diff --git a/packages/shared/package.json b/packages/shared/package.json
index 543acf7eb..af7f27bd5 100644
--- a/packages/shared/package.json
+++ b/packages/shared/package.json
@@ -43,7 +43,7 @@
"@ethersproject/abi": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@nucypher/nucypher-contracts": "^0.9.0",
- "@nucypher/nucypher-core": "0.13.0-alpha.1",
+ "@nucypher/nucypher-core": "^0.13.0-alpha.1",
"axios": "^1.5.0",
"deep-equal": "^2.2.1",
"ethers": "^5.7.2",
diff --git a/packages/shared/scripts/typechain.ts b/packages/shared/scripts/typechain.ts
index f7b2b1d35..c214dbf97 100644
--- a/packages/shared/scripts/typechain.ts
+++ b/packages/shared/scripts/typechain.ts
@@ -11,7 +11,6 @@ import {
import * as tmp from 'tmp';
import { glob, runTypeChain } from 'typechain';
-
const parseContractRegistry = (registry: ContractRegistry): Contract[] =>
Object.keys(registry)
.map((chainId) => {
diff --git a/packages/shared/src/contracts/agents/coordinator.ts b/packages/shared/src/contracts/agents/coordinator.ts
index dcd8ef701..016786584 100644
--- a/packages/shared/src/contracts/agents/coordinator.ts
+++ b/packages/shared/src/contracts/agents/coordinator.ts
@@ -1,4 +1,4 @@
-import { getContract } from '@nucypher/nucypher-contracts'
+import { getContract } from '@nucypher/nucypher-contracts';
import {
DkgPublicKey,
SessionStaticKey,
diff --git a/packages/taco/package.json b/packages/taco/package.json
index 08325b9b4..8fb539396 100644
--- a/packages/taco/package.json
+++ b/packages/taco/package.json
@@ -40,8 +40,9 @@
},
"dependencies": {
"@ethersproject/abstract-signer": "^5.7.0",
- "@nucypher/nucypher-core": "0.13.0-alpha.1",
+ "@nucypher/nucypher-core": "^0.13.0-alpha.1",
"@nucypher/shared": "^0.1.0-rc.4",
+ "ethers": "^5.7.2",
"semver": "^7.5.2",
"zod": "^3.22.4"
},
@@ -50,8 +51,7 @@
"@types/semver": "^7.5.4"
},
"peerDependencies": {
- "@nucypher/shared": "workspace:*",
- "ethers": "^5.7.2"
+ "@nucypher/shared": "workspace:*"
},
"engines": {
"node": ">=18",
diff --git a/packages/taco/src/conditions/compound-condition.ts b/packages/taco/src/conditions/compound-condition.ts
index 16e34b848..772fa55e2 100644
--- a/packages/taco/src/conditions/compound-condition.ts
+++ b/packages/taco/src/conditions/compound-condition.ts
@@ -40,11 +40,10 @@ export const compoundConditionSchema: z.ZodSchema = z
// We test positive cases exhaustively, so we return false here:
return false;
},
- ({ operands, operator }) => ({
- message: `Invalid number of operands ${operands.length} for operator "${operator}"`,
- path: ['operands'],
- })
+ ({ operands, operator }) => ({
+ message: `Invalid number of operands ${operands.length} for operator "${operator}"`,
+ path: ['operands'],
+ }),
);
-
export type CompoundConditionProps = z.infer;
diff --git a/packages/taco/test/conditions/compound-condition.test.ts b/packages/taco/test/conditions/compound-condition.test.ts
index 8e33b94ec..f08788284 100644
--- a/packages/taco/test/conditions/compound-condition.test.ts
+++ b/packages/taco/test/conditions/compound-condition.test.ts
@@ -17,16 +17,20 @@ import {
} from '../test-utils';
describe('validation', () => {
- it.each([{
- operator: 'and',
- operands: [testContractConditionObj, testTimeConditionObj]
- }, {
- operator: 'or',
- operands: [testContractConditionObj, testTimeConditionObj]
- }, {
- operator: 'not',
- operands: [testContractConditionObj]
- }])('accepts "$operator" operator', ({operator, operands}) => {
+ it.each([
+ {
+ operator: 'and',
+ operands: [testContractConditionObj, testTimeConditionObj],
+ },
+ {
+ operator: 'or',
+ operands: [testContractConditionObj, testTimeConditionObj],
+ },
+ {
+ operator: 'not',
+ operands: [testContractConditionObj],
+ },
+ ])('accepts "$operator" operator', ({ operator, operands }) => {
const conditionObj: CompoundConditionProps = {
conditionType: CompoundConditionType,
operator,
@@ -61,31 +65,38 @@ describe('validation', () => {
});
});
- it.each([{
- operator: 'and',
- nrOfOperands: 1,
- }, {
- operator: 'or',
- nrOfOperands: 1,
- }, {
- operator: 'not',
- nrOfOperands: 2,
- }])('rejects invalid number of operands $nrOfOperands for operator $operator', ({operator, nrOfOperands}) => {
- const result = CompoundCondition.validate(compoundConditionSchema, {
- operator,
- operands: Array(nrOfOperands).fill(testRpcConditionObj)
- });
-
- expect(result.error).toBeDefined();
- expect(result.data).toBeUndefined();
- expect(result.error?.format()).toMatchObject({
- operands: {
- _errors: [
- `Invalid number of operands ${nrOfOperands} for operator "${operator}"`,
- ],
- },
- });
- });
+ it.each([
+ {
+ operator: 'and',
+ nrOfOperands: 1,
+ },
+ {
+ operator: 'or',
+ nrOfOperands: 1,
+ },
+ {
+ operator: 'not',
+ nrOfOperands: 2,
+ },
+ ])(
+ 'rejects invalid number of operands $nrOfOperands for operator $operator',
+ ({ operator, nrOfOperands }) => {
+ const result = CompoundCondition.validate(compoundConditionSchema, {
+ operator,
+ operands: Array(nrOfOperands).fill(testRpcConditionObj),
+ });
+
+ expect(result.error).toBeDefined();
+ expect(result.data).toBeUndefined();
+ expect(result.error?.format()).toMatchObject({
+ operands: {
+ _errors: [
+ `Invalid number of operands ${nrOfOperands} for operator "${operator}"`,
+ ],
+ },
+ });
+ },
+ );
it('accepts recursive compound conditions', () => {
const conditionObj = {
@@ -185,9 +196,9 @@ describe('validation', () => {
])('accepts shorthand for "%s" operator', (operator, operands, expected) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const compoundConditionShorthands: Record = {
- 'and': CompoundCondition.and,
- 'or': CompoundCondition.or,
- 'not': CompoundCondition.not,
+ and: CompoundCondition.and,
+ or: CompoundCondition.or,
+ not: CompoundCondition.not,
};
const compoundCondition = compoundConditionShorthands[operator](operands);
diff --git a/packages/taco/test/conditions/context.test.ts b/packages/taco/test/conditions/context.test.ts
index 71c177e9b..cfcceae7a 100644
--- a/packages/taco/test/conditions/context.test.ts
+++ b/packages/taco/test/conditions/context.test.ts
@@ -67,13 +67,16 @@ describe('context', () => {
const context = conditionExpr.buildContext(provider, {}, signer);
describe('custom parameters', () => {
- it("serializes bytes as hex strings", async () => {
+ it('serializes bytes as hex strings', async () => {
const customParamsWithBytes: Record = {};
const customParam = toBytes('hello');
// Uint8Array is not a valid CustomContextParam, override the type:
- customParamsWithBytes[customParamKey] = customParam as unknown as string;
+ customParamsWithBytes[customParamKey] =
+ customParam as unknown as string;
- const asJson = await context.withCustomParams(customParamsWithBytes).toJson();
+ const asJson = await context
+ .withCustomParams(customParamsWithBytes)
+ .toJson();
const asObj = JSON.parse(asJson);
expect(asObj).toBeDefined();
expect(asObj[customParamKey]).toEqual(`0x${toHexString(customParam)}`);
@@ -216,24 +219,27 @@ describe('context', () => {
expect(asObj[USER_ADDRESS_PARAM]).toBeDefined();
});
- it.each([0, ''])('accepts on a falsy parameter value: %s', async (falsyParam) => {
- const customParamKey = ':customParam';
- const customContractCondition = new ContractCondition({
- ...contractConditionObj,
- parameters: [USER_ADDRESS_PARAM, customParamKey],
- });
- const customParameters: Record = {};
- customParameters[customParamKey] = falsyParam;
- const conditionContext = new ConditionExpression(
- customContractCondition,
- ).buildContext(provider, customParameters, signer);
-
- const asObj = await conditionContext.toObj();
- expect(asObj).toBeDefined();
- expect(asObj[USER_ADDRESS_PARAM]).toBeDefined();
- expect(asObj[customParamKey]).toBeDefined();
- expect(asObj[customParamKey]).toEqual(falsyParam);
- });
+ it.each([0, ''])(
+ 'accepts on a falsy parameter value: %s',
+ async (falsyParam) => {
+ const customParamKey = ':customParam';
+ const customContractCondition = new ContractCondition({
+ ...contractConditionObj,
+ parameters: [USER_ADDRESS_PARAM, customParamKey],
+ });
+ const customParameters: Record = {};
+ customParameters[customParamKey] = falsyParam;
+ const conditionContext = new ConditionExpression(
+ customContractCondition,
+ ).buildContext(provider, customParameters, signer);
+
+ const asObj = await conditionContext.toObj();
+ expect(asObj).toBeDefined();
+ expect(asObj[USER_ADDRESS_PARAM]).toBeDefined();
+ expect(asObj[customParamKey]).toBeDefined();
+ expect(asObj[customParamKey]).toEqual(falsyParam);
+ },
+ );
});
});
});
diff --git a/packages/test-utils/package.json b/packages/test-utils/package.json
index a9534c268..5c0ad8e19 100644
--- a/packages/test-utils/package.json
+++ b/packages/test-utils/package.json
@@ -29,7 +29,7 @@
"lint:fix": "pnpm lint --fix"
},
"dependencies": {
- "@nucypher/nucypher-core": "0.13.0-alpha.1",
+ "@nucypher/nucypher-core": "^0.13.0-alpha.1",
"@nucypher/shared": "workspace:*",
"axios": "^1.5.0",
"ethers": "^5.7.2",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 4d795b9a4..08eff0922 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -18,7 +18,7 @@ importers:
specifier: ^2.26.2
version: 2.26.2
'@nucypher/nucypher-core':
- specifier: 0.13.0-alpha.1
+ specifier: ^0.13.0-alpha.1
version: 0.13.0-alpha.1
devDependencies:
'@skypack/package-check':
@@ -106,10 +106,10 @@ importers:
demos/taco-demo:
dependencies:
'@nucypher/shared':
- specifier: workspace:*
+ specifier: ^0.1.0-rc.4
version: link:../../packages/shared
'@nucypher/taco':
- specifier: 0.1.0-rc.6
+ specifier: ^0.1.0-rc.6
version: link:../../packages/taco
'@usedapp/core':
specifier: ^1.2.13
@@ -182,10 +182,10 @@ importers:
demos/taco-nft-demo:
dependencies:
'@nucypher/shared':
- specifier: workspace:*
+ specifier: ^0.1.0-rc.4
version: link:../../packages/shared
'@nucypher/taco':
- specifier: 0.1.0-rc.6
+ specifier: ^0.1.0-rc.6
version: link:../../packages/taco
'@usedapp/core':
specifier: ^1.2.13
@@ -287,9 +287,6 @@ importers:
react-dom:
specifier: 18.2.0
version: 18.2.0(react@18.2.0)
- typescript:
- specifier: 5.2.2
- version: 5.2.2
examples/pre/nodejs:
dependencies:
@@ -336,9 +333,6 @@ importers:
'@nucypher/pre':
specifier: workspace:*
version: link:../../../packages/pre
- ethers:
- specifier: ^5.7.2
- version: 5.7.2
devDependencies:
copy-webpack-plugin:
specifier: ^11.0.0
@@ -346,6 +340,9 @@ importers:
esbuild-loader:
specifier: ^2.11.0
version: 2.21.0(webpack@5.88.2)
+ ethers:
+ specifier: ^5.7.2
+ version: 5.7.2
webpack:
specifier: ^5.4.0
version: 5.88.2(webpack-cli@5.1.4)
@@ -460,7 +457,7 @@ importers:
packages/pre:
dependencies:
'@nucypher/nucypher-core':
- specifier: 0.13.0-alpha.1
+ specifier: ^0.13.0-alpha.1
version: 0.13.0-alpha.1
'@nucypher/shared':
specifier: workspace:*
@@ -482,10 +479,10 @@ importers:
specifier: ^5.7.2
version: 5.7.2
'@nucypher/nucypher-contracts':
- specifier: 0.9.0
+ specifier: ^0.9.0
version: 0.9.0
'@nucypher/nucypher-core':
- specifier: 0.13.0-alpha.1
+ specifier: ^0.13.0-alpha.1
version: 0.13.0-alpha.1
axios:
specifier: ^1.5.0
@@ -528,10 +525,10 @@ importers:
specifier: ^5.7.0
version: 5.7.0
'@nucypher/nucypher-core':
- specifier: 0.13.0-alpha.1
+ specifier: ^0.13.0-alpha.1
version: 0.13.0-alpha.1
'@nucypher/shared':
- specifier: 0.1.0-rc.4
+ specifier: ^0.1.0-rc.4
version: link:../shared
ethers:
specifier: ^5.7.2
@@ -553,7 +550,7 @@ importers:
packages/test-utils:
dependencies:
'@nucypher/nucypher-core':
- specifier: 0.13.0-alpha.1
+ specifier: ^0.13.0-alpha.1
version: 0.13.0-alpha.1
'@nucypher/shared':
specifier: workspace:*