From 5dfee9dee192f9ca49c78a59eadeaae3f2aba6b4 Mon Sep 17 00:00:00 2001 From: danisharora099 Date: Wed, 24 Jan 2024 18:33:35 +0530 Subject: [PATCH] move @waku/message-hash into @waku/core --- package-lock.json | 36 +++--- packages/core/src/index.ts | 2 + packages/core/src/lib/filter/index.ts | 2 +- .../src/lib/message_hash.spec.ts} | 2 +- .../index.ts => core/src/lib/message_hash.ts} | 0 packages/message-hash/.eslintrc.cjs | 6 - packages/message-hash/.mocha.reporters.json | 6 - packages/message-hash/.mocharc.cjs | 26 ---- packages/message-hash/.prettierignore | 5 - packages/message-hash/CHANGELOG.md | 122 ------------------ packages/message-hash/README.md | 26 ---- packages/message-hash/karma.conf.cjs | 3 - packages/message-hash/package.json | 86 ------------ packages/message-hash/rollup.config.js | 24 ---- packages/message-hash/tsconfig.dev.json | 3 - packages/message-hash/tsconfig.json | 10 -- packages/message-hash/typedoc.json | 4 - 17 files changed, 19 insertions(+), 344 deletions(-) rename packages/{message-hash/src/index.spec.ts => core/src/lib/message_hash.spec.ts} (97%) rename packages/{message-hash/src/index.ts => core/src/lib/message_hash.ts} (100%) delete mode 100644 packages/message-hash/.eslintrc.cjs delete mode 100644 packages/message-hash/.mocha.reporters.json delete mode 100644 packages/message-hash/.mocharc.cjs delete mode 100644 packages/message-hash/.prettierignore delete mode 100644 packages/message-hash/CHANGELOG.md delete mode 100644 packages/message-hash/README.md delete mode 100644 packages/message-hash/karma.conf.cjs delete mode 100644 packages/message-hash/package.json delete mode 100644 packages/message-hash/rollup.config.js delete mode 100644 packages/message-hash/tsconfig.dev.json delete mode 100644 packages/message-hash/tsconfig.json delete mode 100644 packages/message-hash/typedoc.json diff --git a/package-lock.json b/package-lock.json index 8a01ff6a1c..eea40100ca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5521,8 +5521,16 @@ "link": true }, "node_modules/@waku/message-hash": { - "resolved": "packages/message-hash", - "link": true + "version": "0.1.10", + "resolved": "https://registry.npmjs.org/@waku/message-hash/-/message-hash-0.1.10.tgz", + "integrity": "sha512-STrORf0vDy5ozYo7QKF04FWlDqg0ZBNdE1kFmpi/NOeN3Wt5eEI9tzAOTBt50u3gf0t7/JLr8p5NbK19PmJlrQ==", + "dependencies": { + "@noble/hashes": "^1.3.2", + "@waku/utils": "0.0.14" + }, + "engines": { + "node": ">=18" + } }, "node_modules/@waku/peer-exchange": { "resolved": "packages/peer-exchange", @@ -27806,6 +27814,7 @@ "packages/message-hash": { "name": "@waku/message-hash", "version": "0.1.10", + "extraneous": true, "license": "MIT OR Apache-2.0", "dependencies": { "@noble/hashes": "^1.3.2", @@ -31979,27 +31988,12 @@ } }, "@waku/message-hash": { - "version": "file:packages/message-hash", + "version": "0.1.10", + "resolved": "https://registry.npmjs.org/@waku/message-hash/-/message-hash-0.1.10.tgz", + "integrity": "sha512-STrORf0vDy5ozYo7QKF04FWlDqg0ZBNdE1kFmpi/NOeN3Wt5eEI9tzAOTBt50u3gf0t7/JLr8p5NbK19PmJlrQ==", "requires": { "@noble/hashes": "^1.3.2", - "@rollup/plugin-commonjs": "^25.0.7", - "@rollup/plugin-json": "^6.0.0", - "@rollup/plugin-node-resolve": "^15.2.3", - "@types/chai": "^4.3.11", - "@types/debug": "^4.1.12", - "@types/mocha": "^10.0.1", - "@waku/build-utils": "*", - "@waku/interfaces": "0.0.21", - "@waku/utils": "0.0.14", - "chai": "^4.3.10", - "cspell": "^7.3.2", - "fast-check": "^3.14.0", - "ignore-loader": "^0.1.2", - "isomorphic-fetch": "^3.0.0", - "mocha": "^10.2.0", - "npm-run-all": "^4.1.5", - "process": "^0.11.10", - "rollup": "^4.9.5" + "@waku/utils": "0.0.14" } }, "@waku/peer-exchange": { diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index d20bdc977f..044dfe4fa9 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -28,3 +28,5 @@ export { KeepAliveManager } from "./lib/keep_alive_manager.js"; export { StreamManager } from "./lib/stream_manager.js"; export { MetadataCodec, wakuMetadata } from "./lib/metadata/index.js"; + +export * from "./lib/message_hash.js"; diff --git a/packages/core/src/lib/filter/index.ts b/packages/core/src/lib/filter/index.ts index 7e6353964c..8dab24f074 100644 --- a/packages/core/src/lib/filter/index.ts +++ b/packages/core/src/lib/filter/index.ts @@ -17,7 +17,6 @@ import type { Unsubscribe } from "@waku/interfaces"; import { DefaultPubsubTopic } from "@waku/interfaces"; -import { messageHashStr } from "@waku/message-hash"; import { WakuMessage } from "@waku/proto"; import { ensurePubsubTopicIsConfigured, @@ -31,6 +30,7 @@ import * as lp from "it-length-prefixed"; import { pipe } from "it-pipe"; import { BaseProtocol } from "../base_protocol.js"; +import { messageHashStr } from "../message_hash.js"; import { FilterPushRpc, diff --git a/packages/message-hash/src/index.spec.ts b/packages/core/src/lib/message_hash.spec.ts similarity index 97% rename from packages/message-hash/src/index.spec.ts rename to packages/core/src/lib/message_hash.spec.ts index 11b32dad78..6332dd6954 100644 --- a/packages/message-hash/src/index.spec.ts +++ b/packages/core/src/lib/message_hash.spec.ts @@ -2,7 +2,7 @@ import type { IProtoMessage } from "@waku/interfaces"; import { bytesToHex, hexToBytes } from "@waku/utils/bytes"; import { expect } from "chai"; -import { messageHash } from "./index.js"; +import { messageHash } from "./message_hash.js"; // https://rfc.vac.dev/spec/14/#test-vectors describe("RFC Test Vectors", () => { diff --git a/packages/message-hash/src/index.ts b/packages/core/src/lib/message_hash.ts similarity index 100% rename from packages/message-hash/src/index.ts rename to packages/core/src/lib/message_hash.ts diff --git a/packages/message-hash/.eslintrc.cjs b/packages/message-hash/.eslintrc.cjs deleted file mode 100644 index 2299ed822e..0000000000 --- a/packages/message-hash/.eslintrc.cjs +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - parserOptions: { - tsconfigRootDir: __dirname, - project: "./tsconfig.dev.json" - } -}; diff --git a/packages/message-hash/.mocha.reporters.json b/packages/message-hash/.mocha.reporters.json deleted file mode 100644 index 8c00e441fc..0000000000 --- a/packages/message-hash/.mocha.reporters.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "reporterEnabled": "spec, allure-mocha", - "allureMochaReporter": { - "outputDir": "allure-results" - } -} diff --git a/packages/message-hash/.mocharc.cjs b/packages/message-hash/.mocharc.cjs deleted file mode 100644 index 423c0517bd..0000000000 --- a/packages/message-hash/.mocharc.cjs +++ /dev/null @@ -1,26 +0,0 @@ -const config = { - extension: ['ts'], - spec: 'src/**/*.spec.ts', - require: ['ts-node/register', 'isomorphic-fetch'], - loader: 'ts-node/esm', - 'node-option': [ - 'experimental-specifier-resolution=node', - 'loader=ts-node/esm' - ], - exit: true -}; - -if (process.env.CI) { - console.log("Running tests in parallel"); - config.parallel = true; - config.jobs = 6; - console.log("Activating allure reporting"); - config.reporter = 'mocha-multi-reporters'; - config.reporterOptions = { - configFile: '.mocha.reporters.json' - }; -} else { - console.log("Running tests serially. To enable parallel execution update mocha config"); -} - -module.exports = config; diff --git a/packages/message-hash/.prettierignore b/packages/message-hash/.prettierignore deleted file mode 100644 index d8763f9fc7..0000000000 --- a/packages/message-hash/.prettierignore +++ /dev/null @@ -1,5 +0,0 @@ -build -bundle -dist -node_modules -CHANGELOG.md diff --git a/packages/message-hash/CHANGELOG.md b/packages/message-hash/CHANGELOG.md deleted file mode 100644 index 9fbb005c3e..0000000000 --- a/packages/message-hash/CHANGELOG.md +++ /dev/null @@ -1,122 +0,0 @@ -# Changelog - -### Dependencies - -* The following workspace dependencies were updated - * dependencies - * @waku/utils bumped from 0.0.6 to 0.0.7 - * devDependencies - * @waku/interfaces bumped from 0.0.13 to 0.0.14 - -### Dependencies - -* The following workspace dependencies were updated - * dependencies - * @waku/utils bumped from 0.0.7 to 0.0.8 - * devDependencies - * @waku/interfaces bumped from 0.0.14 to 0.0.15 - -### Dependencies - -* The following workspace dependencies were updated - * dependencies - * @waku/utils bumped from 0.0.8 to 0.0.9 - * devDependencies - * @waku/interfaces bumped from 0.0.15 to 0.0.16 - -### Dependencies - -* The following workspace dependencies were updated - * dependencies - * @waku/utils bumped from 0.0.9 to 0.0.10 - * devDependencies - * @waku/interfaces bumped from 0.0.16 to 0.0.17 - -### Dependencies - -* The following workspace dependencies were updated - * dependencies - * @waku/utils bumped from 0.0.12 to 0.0.13 - * devDependencies - * @waku/interfaces bumped from 0.0.19 to 0.0.20 - -### Dependencies - -* The following workspace dependencies were updated - * dependencies - * @waku/utils bumped from 0.0.13 to 0.0.14 - * devDependencies - * @waku/interfaces bumped from 0.0.20 to 0.0.21 - -## [0.1.8](https://github.com/waku-org/js-waku/compare/message-hash-v0.1.7...message-hash-v0.1.8) (2023-10-16) - - -### Features - -* Add Firefox and Webkit to karma ([#1598](https://github.com/waku-org/js-waku/issues/1598)) ([d9e4bcb](https://github.com/waku-org/js-waku/commit/d9e4bcbe3f7bcc092f20621bd362d76426701dab)) - - -### Dependencies - -* The following workspace dependencies were updated - * dependencies - * @waku/utils bumped from 0.0.11 to 0.0.12 - * devDependencies - * @waku/interfaces bumped from 0.0.18 to 0.0.19 - -## [0.1.7](https://github.com/waku-org/js-waku/compare/message-hash-v0.1.6...message-hash-v0.1.7) (2023-09-11) - - -### ⚠ BREAKING CHANGES - -* @waku/relay ([#1316](https://github.com/waku-org/js-waku/issues/1316)) - -### Features - -* @waku/relay ([#1316](https://github.com/waku-org/js-waku/issues/1316)) ([50c2c25](https://github.com/waku-org/js-waku/commit/50c2c2540f3c5ff78d93f3fea646da0eee246e17)) -* Implement deterministic message hash logic ([fe57461](https://github.com/waku-org/js-waku/commit/fe574613290875d1c142aa51c18641346208401d)) - - -### Dependencies - -* The following workspace dependencies were updated - * dependencies - * @waku/utils bumped from 0.0.10 to 0.0.11 - * devDependencies - * @waku/interfaces bumped from 0.0.17 to 0.0.18 - -## [0.1.2](https://github.com/waku-org/js-waku/compare/message-hash-v0.1.1...message-hash-v0.1.2) (2023-05-18) - - -### ⚠ BREAKING CHANGES - -* @waku/relay ([#1316](https://github.com/waku-org/js-waku/issues/1316)) - -### Features - -* @waku/relay ([#1316](https://github.com/waku-org/js-waku/issues/1316)) ([50c2c25](https://github.com/waku-org/js-waku/commit/50c2c2540f3c5ff78d93f3fea646da0eee246e17)) - - -### Dependencies - -* The following workspace dependencies were updated - * dependencies - * @waku/utils bumped from * to 0.0.6 - * devDependencies - * @waku/interfaces bumped from * to 0.0.13 - -## [0.1.1](https://github.com/waku-org/js-waku/compare/message-hash-v0.1.0...message-hash-v0.1.1) (2023-05-09) - - -### Features - -* Implement deterministic message hash logic ([fe57461](https://github.com/waku-org/js-waku/commit/fe574613290875d1c142aa51c18641346208401d)) - - -### Dependencies - -* The following workspace dependencies were updated - * dependencies - * @waku/utils bumped from * to 0.0.5 - * devDependencies - * @waku/interfaces bumped from * to 0.0.12 diff --git a/packages/message-hash/README.md b/packages/message-hash/README.md deleted file mode 100644 index 4d936787a5..0000000000 --- a/packages/message-hash/README.md +++ /dev/null @@ -1,26 +0,0 @@ -[![NPM](https://nodei.co/npm/@waku/message-hash.png)](https://npmjs.org/package/@waku/message-hash) - -![GitHub Action](https://img.shields.io/github/workflow/status/waku-org/js-waku/CI) -[![Discord chat](https://img.shields.io/discord/864066763682218004.svg?logo=discord&colorB=7289DA)](https://discord.gg/Nrac59MfSX) - -# @waku/message-hash - -TypeScript implementation of the _Deterministic Message Hashing_ as specified in [14/WAKU2-MESSAGE](https://rfc.vac.dev/spec/14/). - -See [JS-Waku README](https://github.com/waku-org/js-waku) for more information. - -## Contributing - -See [CONTRIBUTING.md](https://github.com/waku-org/js-waku/blob/master/CONTRIBUTING.md). - -## License - -Licensed and distributed under either of - -- MIT license: [LICENSE-MIT](https://github.com/waku-org/js-waku/blob/master/LICENSE-MIT) or http://opensource.org/licenses/MIT - -or - -- Apache License, Version 2.0, ([LICENSE-APACHE-v2](https://github.com/waku-org/js-waku/blob/master/LICENSE-APACHE-v2) or http://www.apache.org/licenses/LICENSE-2.0) - -at your option. These files may not be copied, modified, or distributed except according to those terms. diff --git a/packages/message-hash/karma.conf.cjs b/packages/message-hash/karma.conf.cjs deleted file mode 100644 index 1acbc3dd2a..0000000000 --- a/packages/message-hash/karma.conf.cjs +++ /dev/null @@ -1,3 +0,0 @@ -const config = require("../../karma.conf.cjs"); - -module.exports = config; diff --git a/packages/message-hash/package.json b/packages/message-hash/package.json deleted file mode 100644 index f69178265f..0000000000 --- a/packages/message-hash/package.json +++ /dev/null @@ -1,86 +0,0 @@ -{ - "name": "@waku/message-hash", - "version": "0.1.10", - "description": "TypeScript implementation of the Deterministic Message Hashing as specified in 14/WAKU2-MESSAGE", - "types": "./dist/index.d.ts", - "module": "./dist/index.js", - "exports": { - ".": { - "types": "./dist/index.d.ts", - "import": "./dist/index.js" - } - }, - "type": "module", - "homepage": "https://github.com/waku-org/js-waku/tree/master/packages/message-hash#readme", - "repository": { - "type": "git", - "url": "https://github.com/waku-org/js-waku.git" - }, - "bugs": { - "url": "https://github.com/waku-org/js-waku/issues" - }, - "license": "MIT OR Apache-2.0", - "keywords": [ - "waku", - "decentralised", - "communication", - "web3", - "ethereum", - "dapps" - ], - "scripts": { - "build": "run-s build:**", - "build:esm": "tsc", - "build:bundle": "rollup --config rollup.config.js", - "fix": "run-s fix:*", - "fix:lint": "eslint src *.js --fix", - "check": "run-s check:*", - "check:tsc": "tsc -p tsconfig.dev.json", - "check:lint": "eslint src *.js", - "check:spelling": "cspell \"{README.md,src/**/*.ts}\"", - "test": "NODE_ENV=test run-s test:*", - "test:node": "NODE_ENV=test TS_NODE_PROJECT=./tsconfig.dev.json mocha", - "test:browser": "NODE_ENV=test karma start karma.conf.cjs", - "watch:build": "tsc -p tsconfig.json -w", - "watch:test": "mocha --watch", - "prepublish": "npm run build", - "reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build" - }, - "engines": { - "node": ">=18" - }, - "dependencies": { - "@noble/hashes": "^1.3.2", - "@waku/utils": "0.0.14" - }, - "devDependencies": { - "@rollup/plugin-commonjs": "^25.0.7", - "@rollup/plugin-json": "^6.0.0", - "@rollup/plugin-node-resolve": "^15.2.3", - "@types/chai": "^4.3.11", - "@types/debug": "^4.1.12", - "@types/mocha": "^10.0.1", - "@waku/build-utils": "*", - "@waku/interfaces": "0.0.21", - "chai": "^4.3.10", - "cspell": "^7.3.2", - "fast-check": "^3.14.0", - "ignore-loader": "^0.1.2", - "isomorphic-fetch": "^3.0.0", - "mocha": "^10.2.0", - "npm-run-all": "^4.1.5", - "process": "^0.11.10", - "rollup": "^4.9.5" - }, - "files": [ - "dist", - "bundle", - "src/*.ts", - "src/lib/**/*.ts", - "!**/*.spec.*", - "!**/*.json", - "CHANGELOG.md", - "LICENSE", - "README.md" - ] -} diff --git a/packages/message-hash/rollup.config.js b/packages/message-hash/rollup.config.js deleted file mode 100644 index 4d0757b1c9..0000000000 --- a/packages/message-hash/rollup.config.js +++ /dev/null @@ -1,24 +0,0 @@ -import commonjs from "@rollup/plugin-commonjs"; -import json from "@rollup/plugin-json"; -import { nodeResolve } from "@rollup/plugin-node-resolve"; -import { extractExports } from "@waku/build-utils"; - -import * as packageJson from "./package.json" assert { type: "json" }; - -const input = extractExports(packageJson); - -export default { - input, - output: { - dir: "bundle", - format: "esm" - }, - plugins: [ - commonjs(), - json(), - nodeResolve({ - browser: true, - preferBuiltins: false - }) - ] -}; diff --git a/packages/message-hash/tsconfig.dev.json b/packages/message-hash/tsconfig.dev.json deleted file mode 100644 index 4f7c34af3c..0000000000 --- a/packages/message-hash/tsconfig.dev.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "../../tsconfig.dev" -} diff --git a/packages/message-hash/tsconfig.json b/packages/message-hash/tsconfig.json deleted file mode 100644 index eebbc51585..0000000000 --- a/packages/message-hash/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "../../tsconfig", - "compilerOptions": { - "outDir": "dist/", - "rootDir": "src", - "tsBuildInfoFile": "dist/.tsbuildinfo" - }, - "include": ["src"], - "exclude": ["src/**/*.spec.ts", "src/test_utils"] -} diff --git a/packages/message-hash/typedoc.json b/packages/message-hash/typedoc.json deleted file mode 100644 index 00aa3dc064..0000000000 --- a/packages/message-hash/typedoc.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": ["../../typedoc.base.json"], - "entryPoints": ["src/index.ts"] -} \ No newline at end of file