diff --git a/.husky/_/pre-push b/.husky/_/pre-push new file mode 100755 index 00000000..b00d00ff --- /dev/null +++ b/.husky/_/pre-push @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +npm run test && npm run commentSniff \ No newline at end of file diff --git a/.huskyrc b/.huskyrc deleted file mode 100644 index 67b20643..00000000 --- a/.huskyrc +++ /dev/null @@ -1,6 +0,0 @@ -{ - "hooks": { - "pre-push": "npm run lint && npm run test", - "pre-commit": "npm run lint && npm run test && npm run commentSniff" - } -} \ No newline at end of file diff --git a/examples/example-react-vite/package-lock.json b/examples/example-react-vite/package-lock.json index 63b8c62e..44e37279 100644 --- a/examples/example-react-vite/package-lock.json +++ b/examples/example-react-vite/package-lock.json @@ -1,16 +1,17 @@ { "name": "example-react-vite", - "version": "3.8.1", + "version": "3.8.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "example-react-vite", - "version": "3.8.1", + "version": "3.8.2", + "hasInstallScript": true, "dependencies": { "@microlink/react-json-view": "1.22.2", "@provenanceio/wallet-utils": "2.8.0", - "@provenanceio/walletconnect-js": "file:../provenanceio-walletconnect-js-3.8.1.tgz", + "@provenanceio/walletconnect-js": "file:../provenanceio-walletconnect-js-3.8.2.tgz", "react": "^18.2.0", "react-dom": "^18.2.0", "react-helmet-async": "1.3.0", @@ -1016,9 +1017,9 @@ } }, "node_modules/@provenanceio/walletconnect-js": { - "version": "3.8.1", - "resolved": "file:../provenanceio-walletconnect-js-3.8.1.tgz", - "integrity": "sha512-HfkMx3BSZxMTUMVGWLRbpqzO4J1QRQo+4M1QzI0ZbRNgVPuP9KrxvXiDk+tc48u22WYVCO64kgshUtuwJGL7xw==", + "version": "3.8.2", + "resolved": "file:../provenanceio-walletconnect-js-3.8.2.tgz", + "integrity": "sha512-cqtARX1fB1ZchGEczXrQbpxKA3QUFeFJt/wgSXgWDN9wkmlSJn6j4rrnksOHo1+EPScbb0eeGZu+t6x5p2/n/g==", "license": "Apache-2.0", "dependencies": { "@walletconnect/client": "1.8.0", @@ -7238,8 +7239,8 @@ } }, "@provenanceio/walletconnect-js": { - "version": "file:../provenanceio-walletconnect-js-3.8.1.tgz", - "integrity": "sha512-HfkMx3BSZxMTUMVGWLRbpqzO4J1QRQo+4M1QzI0ZbRNgVPuP9KrxvXiDk+tc48u22WYVCO64kgshUtuwJGL7xw==", + "version": "file:../provenanceio-walletconnect-js-3.8.2.tgz", + "integrity": "sha512-cqtARX1fB1ZchGEczXrQbpxKA3QUFeFJt/wgSXgWDN9wkmlSJn6j4rrnksOHo1+EPScbb0eeGZu+t6x5p2/n/g==", "requires": { "@walletconnect/client": "1.8.0", "@walletconnect/utils": "1.8.0", diff --git a/examples/example-react-vite/package.json b/examples/example-react-vite/package.json index 85edb819..8c499a46 100644 --- a/examples/example-react-vite/package.json +++ b/examples/example-react-vite/package.json @@ -1,7 +1,7 @@ { "name": "example-react-vite", "private": true, - "version": "3.8.1", + "version": "3.8.2", "homepage": "/walletconnect-demo", "type": "module", "scripts": { @@ -9,13 +9,14 @@ "build": "tsc && vite build", "preview": "vite preview", "clean:cache": "rm -rf ./node_modules/.vite", - "start": "npm run clean:cache && npm i ../provenanceio-walletconnect-js-${npm_package_version}.tgz && npm run dev", + "start": "npm run install && npm run dev", + "install": "npm run clean:cache && npm i ../provenanceio-walletconnect-js-${npm_package_version}.tgz", "start:host": "npm run dev --host" }, "dependencies": { "@microlink/react-json-view": "1.22.2", "@provenanceio/wallet-utils": "2.8.0", - "@provenanceio/walletconnect-js": "file:../provenanceio-walletconnect-js-3.8.1.tgz", + "@provenanceio/walletconnect-js": "file:../provenanceio-walletconnect-js-3.8.2.tgz", "react": "^18.2.0", "react-dom": "^18.2.0", "react-helmet-async": "1.3.0", @@ -52,4 +53,4 @@ "prettier" ] } -} \ No newline at end of file +} diff --git a/package-lock.json b/package-lock.json index 1e44292c..7b4afe69 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@provenanceio/walletconnect-js", - "version": "3.8.0", + "version": "3.8.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@provenanceio/walletconnect-js", - "version": "3.8.0", + "version": "3.8.2", "license": "Apache-2.0", "dependencies": { "@walletconnect/client": "1.8.0", @@ -61,7 +61,7 @@ "eslint-plugin-react": "7.32.2", "eslint-plugin-react-hooks": "4.6.0", "file-loader": "6.2.0", - "husky": "8.0.1", + "husky": "^9.0.10", "jest": "29.4.3", "json-schema-to-typescript": "11.0.2", "nodemon": "2.0.20", @@ -7148,15 +7148,15 @@ } }, "node_modules/husky": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/husky/-/husky-8.0.1.tgz", - "integrity": "sha512-xs7/chUH/CKdOCs7Zy0Aev9e/dKOMZf3K1Az1nar3tzlv0jfqnYtu235bstsWTmXOR0EfINrPa97yy4Lz6RiKw==", + "version": "9.0.10", + "resolved": "https://registry.npmjs.org/husky/-/husky-9.0.10.tgz", + "integrity": "sha512-TQGNknoiy6bURzIO77pPRu+XHi6zI7T93rX+QnJsoYFf3xdjKOur+IlfqzJGMHIK/wXrLg+GsvMs8Op7vI2jVA==", "dev": true, "bin": { - "husky": "lib/bin.js" + "husky": "bin.mjs" }, "engines": { - "node": ">=14" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/typicode" @@ -17912,9 +17912,9 @@ "dev": true }, "husky": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/husky/-/husky-8.0.1.tgz", - "integrity": "sha512-xs7/chUH/CKdOCs7Zy0Aev9e/dKOMZf3K1Az1nar3tzlv0jfqnYtu235bstsWTmXOR0EfINrPa97yy4Lz6RiKw==", + "version": "9.0.10", + "resolved": "https://registry.npmjs.org/husky/-/husky-9.0.10.tgz", + "integrity": "sha512-TQGNknoiy6bURzIO77pPRu+XHi6zI7T93rX+QnJsoYFf3xdjKOur+IlfqzJGMHIK/wXrLg+GsvMs8Op7vI2jVA==", "dev": true }, "icss-utils": { diff --git a/package.json b/package.json index 17684fc6..a1206683 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@provenanceio/walletconnect-js", - "version": "3.8.1", + "version": "3.8.2", "private": false, "sideEffects": false, "main": "esm/index.js", @@ -81,7 +81,7 @@ "eslint-plugin-react": "7.32.2", "eslint-plugin-react-hooks": "4.6.0", "file-loader": "6.2.0", - "husky": "8.0.1", + "husky": "^9.0.10", "jest": "29.4.3", "json-schema-to-typescript": "11.0.2", "nodemon": "2.0.20", @@ -109,7 +109,8 @@ "prebuild": "npm run test", "start:watch": "nodemon -e js,ts,tsx,css --watch src --exec 'npm run build:pack && npm run watch:example-react'", "start": "npm run start:watch && npm run start:example-react", - "test": "jest", + "test": "jest && npm run test:example-build", + "test:example-build": "npm run build:pack && cd examples/example-react-vite && npm run install && npm run build", "tsc:commonjs": "tsc --module commonjs --outDir lib", "tsc:esm": "tsc --module es2015 --outDir esm", "vup:major": "npm version major --no-git-tag-version && cd examples/example-react-vite && npm version major --no-git-tag-version", diff --git a/scripts/commentSniffer.js b/scripts/commentSniffer.js index 48258af3..aaaca0a5 100644 --- a/scripts/commentSniffer.js +++ b/scripts/commentSniffer.js @@ -1,96 +1,96 @@ -"use strict"; +'use strict'; exports.__esModule = true; module.exports.commentSniffer = function () { - var glob = require('glob'); // eslint-disable-line @typescript-eslint/no-var-requires - var fs = require('fs'); // eslint-disable-line @typescript-eslint/no-var-requires - var PrettyError = require('pretty-error'); // eslint-disable-line @typescript-eslint/no-var-requires - var getDirectories = function (src, callback) { - var res = glob.sync(src + '/**/*'); - callback(res); - }; - var fileTypes = ['.ts', '.tsx', '.js', '.jsx', '.md', '.mdx']; - var comments = [ - 'TEMP:', - 'TEMPONLY:', - 'TESTING:', - 'TEST:', - 'TESTONLY:', - 'TESTINGONLY:', - 'REMOVEME:', - 'REMOVE:', - 'HACK:', - ]; - var rootDirs = ['src', 'webDemo/src']; - var checkIfValidFile = function (fileSrc) { - var valid = false; - fileTypes.forEach(function (fileType) { - if (fileSrc.includes(fileType)) { - valid = true; + var glob = require('glob'); // eslint-disable-line @typescript-eslint/no-var-requires + var fs = require('fs'); // eslint-disable-line @typescript-eslint/no-var-requires + var PrettyError = require('pretty-error'); // eslint-disable-line @typescript-eslint/no-var-requires + var getDirectories = function (src, callback) { + var res = glob.sync(src + '/**/*'); + callback(res); + }; + var fileTypes = ['.ts', '.tsx', '.js', '.jsx', '.md', '.mdx']; + var comments = [ + '// TEMP:', + '// TEMPONLY:', + '// TESTING:', + '// TEST:', + '// TESTONLY:', + '// TESTINGONLY:', + '// REMOVEME:', + '// REMOVE:', + '// HACK:', + ]; + var rootDirs = ['src', 'webDemo/src']; + var checkIfValidFile = function (fileSrc) { + var valid = false; + fileTypes.forEach(function (fileType) { + if (fileSrc.includes(fileType)) { + valid = true; + } + }); + return valid; + }; + var checkIfCommentMatches = function (fileData) { + var commentExists = false; + comments.forEach(function (comment) { + if (fileData.includes(comment)) { + commentExists = true; + } + }); + return commentExists; + }; + var runSniffer = function () { + var allErrors = []; + rootDirs.forEach(function (rootDir) { + getDirectories(rootDir, function (res) { + // Look at each file + res.forEach(function (fileLocation) { + var valid = checkIfValidFile(fileLocation); + if (valid) { + var data = fs.readFileSync(fileLocation); + var hasComment = checkIfCommentMatches(data); + if (hasComment) { + allErrors.push(fileLocation); } + } }); - return valid; - }; - var checkIfCommentMatches = function (fileData) { - var commentExists = false; - comments.forEach(function (comment) { - if (fileData.includes(comment)) { - commentExists = true; - } - }); - return commentExists; - }; - var runSniffer = function () { - var allErrors = []; - rootDirs.forEach(function (rootDir) { - getDirectories(rootDir, function (res) { - // Look at each file - res.forEach(function (fileLocation) { - var valid = checkIfValidFile(fileLocation); - if (valid) { - var data = fs.readFileSync(fileLocation); - var hasComment = checkIfCommentMatches(data); - if (hasComment) { - allErrors.push(fileLocation); - } - } - }); - }); - }); - if (allErrors.length) { - var message_1 = 'Dev Local Only Comments Found! Please Fix/Remove:\n --------------------------------------------------\n'; - allErrors.forEach(function (msg) { - message_1 += " \n \u2022 ".concat(msg); - }); - var pe = new PrettyError(); - pe.appendStyle({ - 'pretty-error > header > title > kind': { display: 'none' }, - 'pretty-error > header > colon': { display: 'none' }, - 'pretty-error > header > message': { - color: 'bright-white', - background: 'red', - padding: '0 1' - }, - 'pretty-error > trace > item': { display: 'none' } - }); - var renderedError = pe.render(new Error(message_1)); - console.log(renderedError); // eslint-disable-line no-console - process.exit(1); - } - else { - var pe = new PrettyError(); - pe.appendStyle({ - 'pretty-error > header > title > kind': { display: 'none' }, - 'pretty-error > header > colon': { display: 'none' }, - 'pretty-error > header > message': { - color: 'bright-white', - background: 'green', - padding: '0 1' - }, - 'pretty-error > trace > item': { display: 'none' } - }); - var renderedSuccess = pe.render(new Error('All comment checks passed')); - console.log(renderedSuccess); // eslint-disable-line no-console - } - }; - runSniffer(); + }); + }); + if (allErrors.length) { + var message_1 = + 'Dev Local Only Comments Found! Please Fix/Remove:\n --------------------------------------------------\n'; + allErrors.forEach(function (msg) { + message_1 += ' \n \u2022 '.concat(msg); + }); + var pe = new PrettyError(); + pe.appendStyle({ + 'pretty-error > header > title > kind': { display: 'none' }, + 'pretty-error > header > colon': { display: 'none' }, + 'pretty-error > header > message': { + color: 'bright-white', + background: 'red', + padding: '0 1', + }, + 'pretty-error > trace > item': { display: 'none' }, + }); + var renderedError = pe.render(new Error(message_1)); + console.log(renderedError); // eslint-disable-line no-console + process.exit(1); + } else { + var pe = new PrettyError(); + pe.appendStyle({ + 'pretty-error > header > title > kind': { display: 'none' }, + 'pretty-error > header > colon': { display: 'none' }, + 'pretty-error > header > message': { + color: 'bright-white', + background: 'green', + padding: '0 1', + }, + 'pretty-error > trace > item': { display: 'none' }, + }); + var renderedSuccess = pe.render(new Error('All comment checks passed')); + console.log(renderedSuccess); // eslint-disable-line no-console + } + }; + runSniffer(); }; diff --git a/src/services/walletConnectService.ts b/src/services/walletConnectService.ts index 538501c5..19dbe4a9 100644 --- a/src/services/walletConnectService.ts +++ b/src/services/walletConnectService.ts @@ -1,6 +1,5 @@ import { Buffer } from 'buffer'; import events from 'events'; -import { version } from '../../package.json'; import type { AccountAttribute, BroadcastEventData, @@ -66,7 +65,7 @@ const defaultState: WCSState = { representedGroupPolicy: null, signedJWT: '', status: 'disconnected', - version, + version: '3.8.2', walletAppId: undefined, walletInfo: {}, };