From 55cd0221ef322be7673b40962bb9ff82b091159d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20=27birdy=27=20Danjou?= Date: Thu, 20 Jun 2024 16:42:01 +0200 Subject: [PATCH 1/2] chore: rework the build process --- config/paths.cjs | 2 +- config/rollup.config.js | 37 ++-- config/webpack.config.cjs | 1 - jest.config.cjs | 3 - package-lock.json | 158 +++++++----------- package.json | 20 +-- src/kms/web/package.json | 14 -- src/sdk/index.test.ts | 2 - src/sdk/index.ts | 3 - src/sdk/keypair.test.ts | 5 +- src/sdk/keypair.ts | 2 +- tsconfig.json | 3 +- tsconfig.node.rollup.json | 22 --- ...ig.web.rollup.json => tsconfig.rollup.json | 5 +- 14 files changed, 85 insertions(+), 192 deletions(-) delete mode 100644 src/kms/web/package.json delete mode 100644 tsconfig.node.rollup.json rename tsconfig.web.rollup.json => tsconfig.rollup.json (81%) diff --git a/config/paths.cjs b/config/paths.cjs index 9b0c7a2..a46e4da 100644 --- a/config/paths.cjs +++ b/config/paths.cjs @@ -3,7 +3,7 @@ const path = require('path'); const PATHS = { - web: path.resolve(__dirname, '../lib/web/index.js'), + web: path.resolve(__dirname, '../lib/web.js'), build: path.resolve(__dirname, '../bundle'), }; diff --git a/config/rollup.config.js b/config/rollup.config.js index 72d772f..267b2a5 100644 --- a/config/rollup.config.js +++ b/config/rollup.config.js @@ -12,42 +12,27 @@ import nodePolyfills from 'rollup-plugin-polyfill-node'; const require = createRequire(import.meta.url); const nodePlugins = [ - alias({ - entries: [ - { - find: 'node-kms', - replacement: require.resolve('../src/kms/node/index.js'), - }, - ], - }), copy({ targets: [ { - src: require.resolve('../src/kms/node/kms_lib_bg.wasm'), - dest: 'lib/node/', + src: './src/kms/node/*', + dest: 'lib/kms/node', }, ], }), + wasm(), commonjs(), typescript({ - tsconfig: './tsconfig.node.rollup.json', + tsconfig: './tsconfig.rollup.json', }), ]; const webPlugins = [ - alias({ - entries: [ - { - find: 'node-kms', - replacement: require.resolve('../src/kms/web/kms_lib.js'), - }, - ], - }), copy({ targets: [ { - src: require.resolve('../src/kms/web/kms_lib_bg.wasm'), - dest: 'lib/web', + src: './src/kms/web/*', + dest: 'lib/kms/web', }, ], }), @@ -55,29 +40,29 @@ const webPlugins = [ replace({ preventAssignment: true, 'node-tfhe': 'tfhe', - 'kms/node/': 'kms/web/', + 'kms/node': 'kms/web', }), typescript({ - tsconfig: './tsconfig.web.rollup.json', + tsconfig: './tsconfig.rollup.json', exclude: 'node_modules/**', }), wasm({ targetEnv: 'browser', maxFileSize: 10000000, }), + commonjs(), resolve({ browser: true, resolveOnly: ['tfhe'], extensions: ['.js', '.ts', '.wasm'], }), - commonjs(), ]; export default [ { input: 'src/web.ts', output: { - file: 'lib/web/index.js', + file: 'lib/web.js', name: 'fhevm', format: 'es', }, @@ -86,7 +71,7 @@ export default [ { input: 'src/node.ts', output: { - file: 'lib/node/index.cjs', + file: 'lib/node.cjs', name: 'fhevm', format: 'cjs', }, diff --git a/config/webpack.config.cjs b/config/webpack.config.cjs index 6b66559..a211614 100644 --- a/config/webpack.config.cjs +++ b/config/webpack.config.cjs @@ -62,7 +62,6 @@ const web = { 'tfhe_bg.wasm': require.resolve('tfhe/tfhe_bg.wasm'), 'node-tfhe': require.resolve('tfhe/tfhe'), 'kms_lib_bg.wasm': require.resolve('../src/kms/web/kms_lib_bg.wasm'), - 'node-kms': require.resolve('../src/kms/web/kms_lib.js'), buffer: require.resolve('buffer/'), crypto: require.resolve('crypto-browserify'), stream: require.resolve('stream-browserify'), diff --git a/jest.config.cjs b/jest.config.cjs index 7ade4af..a28781e 100644 --- a/jest.config.cjs +++ b/jest.config.cjs @@ -17,9 +17,6 @@ module.exports = { }, testEnvironment: 'node', moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], - moduleNameMapper: { - '^node-kms$': '/src/kms/node', - }, collectCoverageFrom: [ 'src/**/*.ts', 'src/**/*.tsx', diff --git a/package-lock.json b/package-lock.json index c24425a..4ba717e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "fhevmjs", - "version": "0.5.0-3", + "version": "0.5.0-7", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "fhevmjs", - "version": "0.5.0-3", + "version": "0.5.0-7", "license": "BSD-3-Clause-Clear", "dependencies": { "@types/keccak": "^3.0.4", @@ -15,8 +15,6 @@ "crypto-js": "^4.1.1", "ethers": "^6.6.4", "keccak": "^3.0.4", - "libsodium": "^0.7.11", - "libsodium-wrappers": "^0.7.11", "node-fetch": "^2.7.0", "node-tfhe": "^0.6.2", "tfhe": "^0.6.2", @@ -33,7 +31,6 @@ "@rollup/plugin-typescript": "^11.1.1", "@rollup/plugin-wasm": "^6.1.3", "@types/jest": "^29.5.1", - "@types/libsodium-wrappers": "^0.7.10", "@types/node-fetch": "^2.6.11", "buffer": "^6.0.3", "crypto-browserify": "^3.12.0", @@ -58,9 +55,9 @@ } }, "node_modules/@adraffy/ens-normalize": { - "version": "1.9.2", - "resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.9.2.tgz", - "integrity": "sha512-0h+FrQDqe2Wn+IIGFkTCd4aAwTJ+7834Ek1COohCyV26AXhwQ7WQaz+4F/nLOeVl/3BtWHOHLPsq46V8YB46Eg==" + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.10.1.tgz", + "integrity": "sha512-96Z2IP3mYmF1Xg2cDm8f1gWGf/HUVedQ3FMifV4kG/PQ4yEP51xDtRAEfhVNt5f/uzpNkZHwWQuUcu6D6K+Ekw==" }, "node_modules/@ampproject/remapping": { "version": "2.2.1", @@ -1159,26 +1156,15 @@ } }, "node_modules/@noble/hashes": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.1.2.tgz", - "integrity": "sha512-KYRCASVTv6aeUi1tsF8/vpyR7zpfs3FUzy2Jqm+MU+LmUKhQ0y2FpfwqkCcxSg2ua4GALJd8k2R76WxwZGbQpA==", - "funding": [ - { - "type": "individual", - "url": "https://paulmillr.com/funding/" - } - ] - }, - "node_modules/@noble/secp256k1": { - "version": "1.7.1", - "resolved": "https://registry.npmjs.org/@noble/secp256k1/-/secp256k1-1.7.1.tgz", - "integrity": "sha512-hOUk6AyBFmqVrv7k5WAw/LpszxVbj9gGN4JRkIX52fdFAj1UA61KXmZDvqVEm+pOyec3+fIeZB02LYa/pWOArw==", - "funding": [ - { - "type": "individual", - "url": "https://paulmillr.com/funding/" - } - ] + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz", + "integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", @@ -1667,12 +1653,6 @@ "@types/node": "*" } }, - "node_modules/@types/libsodium-wrappers": { - "version": "0.7.10", - "resolved": "https://registry.npmjs.org/@types/libsodium-wrappers/-/libsodium-wrappers-0.7.10.tgz", - "integrity": "sha512-BqI9B92u+cM3ccp8mpHf+HzJ8fBlRwdmyd6+fz3p99m3V6ifT5O3zmOMi612PGkpeFeG/G6loxUnzlDNhfjPSA==", - "dev": true - }, "node_modules/@types/minimatch": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-5.1.2.tgz", @@ -3153,9 +3133,9 @@ } }, "node_modules/ethers": { - "version": "6.6.4", - "resolved": "https://registry.npmjs.org/ethers/-/ethers-6.6.4.tgz", - "integrity": "sha512-r3myN2hEnydmu23iiIj5kjWnCh5JNzlqrE/z+Kw5UqH173F+JOWzU6qkFB4HVC50epgxzKSL2Hq1oNXA877vwQ==", + "version": "6.13.1", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-6.13.1.tgz", + "integrity": "sha512-hdJ2HOxg/xx97Lm9HdCWk949BfYqYWpyw4//78SiwOLgASyfrNszfMUNB2joKjvGUdwhHfaiMMFFwacVVoLR9A==", "funding": [ { "type": "individual", @@ -3167,18 +3147,29 @@ } ], "dependencies": { - "@adraffy/ens-normalize": "1.9.2", - "@noble/hashes": "1.1.2", - "@noble/secp256k1": "1.7.1", + "@adraffy/ens-normalize": "1.10.1", + "@noble/curves": "1.2.0", + "@noble/hashes": "1.3.2", "@types/node": "18.15.13", "aes-js": "4.0.0-beta.5", "tslib": "2.4.0", - "ws": "8.5.0" + "ws": "8.17.1" }, "engines": { "node": ">=14.0.0" } }, + "node_modules/ethers/node_modules/@noble/curves": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.2.0.tgz", + "integrity": "sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==", + "dependencies": { + "@noble/hashes": "1.3.2" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/ethers/node_modules/@types/node": { "version": "18.15.13", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.13.tgz", @@ -4872,19 +4863,6 @@ "node": ">=6" } }, - "node_modules/libsodium": { - "version": "0.7.11", - "resolved": "https://registry.npmjs.org/libsodium/-/libsodium-0.7.11.tgz", - "integrity": "sha512-WPfJ7sS53I2s4iM58QxY3Inb83/6mjlYgcmZs7DJsvDlnmVUwNinBCi5vBT43P6bHRy01O4zsMU2CoVR6xJ40A==" - }, - "node_modules/libsodium-wrappers": { - "version": "0.7.11", - "resolved": "https://registry.npmjs.org/libsodium-wrappers/-/libsodium-wrappers-0.7.11.tgz", - "integrity": "sha512-SrcLtXj7BM19vUKtQuyQKiQCRJPgbpauzl3s0rSwD+60wtHqSUuqcoawlMDheCJga85nKOQwxNYQxf/CKAvs6Q==", - "dependencies": { - "libsodium": "^0.7.11" - } - }, "node_modules/lines-and-columns": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", @@ -6816,15 +6794,15 @@ } }, "node_modules/ws": { - "version": "8.5.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.5.0.tgz", - "integrity": "sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg==", + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz", + "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==", "engines": { "node": ">=10.0.0" }, "peerDependencies": { "bufferutil": "^4.0.1", - "utf-8-validate": "^5.0.2" + "utf-8-validate": ">=5.0.2" }, "peerDependenciesMeta": { "bufferutil": { @@ -6900,9 +6878,9 @@ }, "dependencies": { "@adraffy/ens-normalize": { - "version": "1.9.2", - "resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.9.2.tgz", - "integrity": "sha512-0h+FrQDqe2Wn+IIGFkTCd4aAwTJ+7834Ek1COohCyV26AXhwQ7WQaz+4F/nLOeVl/3BtWHOHLPsq46V8YB46Eg==" + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.10.1.tgz", + "integrity": "sha512-96Z2IP3mYmF1Xg2cDm8f1gWGf/HUVedQ3FMifV4kG/PQ4yEP51xDtRAEfhVNt5f/uzpNkZHwWQuUcu6D6K+Ekw==" }, "@ampproject/remapping": { "version": "2.2.1", @@ -7756,14 +7734,9 @@ } }, "@noble/hashes": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.1.2.tgz", - "integrity": "sha512-KYRCASVTv6aeUi1tsF8/vpyR7zpfs3FUzy2Jqm+MU+LmUKhQ0y2FpfwqkCcxSg2ua4GALJd8k2R76WxwZGbQpA==" - }, - "@noble/secp256k1": { - "version": "1.7.1", - "resolved": "https://registry.npmjs.org/@noble/secp256k1/-/secp256k1-1.7.1.tgz", - "integrity": "sha512-hOUk6AyBFmqVrv7k5WAw/LpszxVbj9gGN4JRkIX52fdFAj1UA61KXmZDvqVEm+pOyec3+fIeZB02LYa/pWOArw==" + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz", + "integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==" }, "@nodelib/fs.scandir": { "version": "2.1.5", @@ -8123,12 +8096,6 @@ "@types/node": "*" } }, - "@types/libsodium-wrappers": { - "version": "0.7.10", - "resolved": "https://registry.npmjs.org/@types/libsodium-wrappers/-/libsodium-wrappers-0.7.10.tgz", - "integrity": "sha512-BqI9B92u+cM3ccp8mpHf+HzJ8fBlRwdmyd6+fz3p99m3V6ifT5O3zmOMi612PGkpeFeG/G6loxUnzlDNhfjPSA==", - "dev": true - }, "@types/minimatch": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-5.1.2.tgz", @@ -9291,19 +9258,27 @@ } }, "ethers": { - "version": "6.6.4", - "resolved": "https://registry.npmjs.org/ethers/-/ethers-6.6.4.tgz", - "integrity": "sha512-r3myN2hEnydmu23iiIj5kjWnCh5JNzlqrE/z+Kw5UqH173F+JOWzU6qkFB4HVC50epgxzKSL2Hq1oNXA877vwQ==", + "version": "6.13.1", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-6.13.1.tgz", + "integrity": "sha512-hdJ2HOxg/xx97Lm9HdCWk949BfYqYWpyw4//78SiwOLgASyfrNszfMUNB2joKjvGUdwhHfaiMMFFwacVVoLR9A==", "requires": { - "@adraffy/ens-normalize": "1.9.2", - "@noble/hashes": "1.1.2", - "@noble/secp256k1": "1.7.1", + "@adraffy/ens-normalize": "1.10.1", + "@noble/curves": "1.2.0", + "@noble/hashes": "1.3.2", "@types/node": "18.15.13", "aes-js": "4.0.0-beta.5", "tslib": "2.4.0", - "ws": "8.5.0" + "ws": "8.17.1" }, "dependencies": { + "@noble/curves": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.2.0.tgz", + "integrity": "sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==", + "requires": { + "@noble/hashes": "1.3.2" + } + }, "@types/node": { "version": "18.15.13", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.13.tgz", @@ -10561,19 +10536,6 @@ "integrity": "sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==", "dev": true }, - "libsodium": { - "version": "0.7.11", - "resolved": "https://registry.npmjs.org/libsodium/-/libsodium-0.7.11.tgz", - "integrity": "sha512-WPfJ7sS53I2s4iM58QxY3Inb83/6mjlYgcmZs7DJsvDlnmVUwNinBCi5vBT43P6bHRy01O4zsMU2CoVR6xJ40A==" - }, - "libsodium-wrappers": { - "version": "0.7.11", - "resolved": "https://registry.npmjs.org/libsodium-wrappers/-/libsodium-wrappers-0.7.11.tgz", - "integrity": "sha512-SrcLtXj7BM19vUKtQuyQKiQCRJPgbpauzl3s0rSwD+60wtHqSUuqcoawlMDheCJga85nKOQwxNYQxf/CKAvs6Q==", - "requires": { - "libsodium": "^0.7.11" - } - }, "lines-and-columns": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", @@ -11976,9 +11938,9 @@ } }, "ws": { - "version": "8.5.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.5.0.tgz", - "integrity": "sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg==", + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz", + "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==", "requires": {} }, "y18n": { diff --git a/package.json b/package.json index c149c07..3d1e23c 100644 --- a/package.json +++ b/package.json @@ -1,26 +1,25 @@ { "name": "fhevmjs", - "version": "0.5.0-7", + "version": "0.5.0-8", "description": "fhEVM SDK for blockchain using TFHE", - "main": "lib/node/index.js", + "main": "lib/node.js", "types": "lib/node/node.d.ts", - "browser": "lib/web/index.js", + "browser": "lib/web.js", "type": "module", "bin": { "fhevm": "./bin/fhevm.js" }, "exports": { ".": { - "import": "./lib/web/index.js", - "require": "./lib/node/index.cjs" + "import": "./lib/web.js", + "require": "./lib/node.cjs" }, "./web": { - "import": "./lib/web/index.js", - "require": "./lib/web/index.js" + "import": "./lib/web.js", + "require": "./lib/web.js" }, "./node": { - "import": "./lib/node/index.js", - "require": "./lib/node/index.cjs" + "require": "./lib/node.cjs" } }, "scripts": { @@ -49,8 +48,6 @@ "crypto-js": "^4.1.1", "ethers": "^6.6.4", "keccak": "^3.0.4", - "libsodium": "^0.7.11", - "libsodium-wrappers": "^0.7.11", "node-fetch": "^2.7.0", "node-tfhe": "^0.6.2", "tfhe": "^0.6.2", @@ -64,7 +61,6 @@ "@rollup/plugin-typescript": "^11.1.1", "@rollup/plugin-wasm": "^6.1.3", "@types/jest": "^29.5.1", - "@types/libsodium-wrappers": "^0.7.10", "@types/node-fetch": "^2.6.11", "buffer": "^6.0.3", "crypto-browserify": "^3.12.0", diff --git a/src/kms/web/package.json b/src/kms/web/package.json deleted file mode 100644 index c10d1d3..0000000 --- a/src/kms/web/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "kms", - "version": "0.1.0", - "files": [ - "kms_lib_bg.wasm", - "kms_lib.js", - "kms_lib.d.ts" - ], - "module": "kms_lib.js", - "types": "kms_lib.d.ts", - "sideEffects": [ - "./snippets/*" - ] -} \ No newline at end of file diff --git a/src/sdk/index.test.ts b/src/sdk/index.test.ts index 842dae4..62f7e74 100644 --- a/src/sdk/index.test.ts +++ b/src/sdk/index.test.ts @@ -1,4 +1,3 @@ -import sodium from 'libsodium-wrappers'; import { createInstance } from './index'; import { createTfhePublicKey } from '../tfhe'; @@ -6,7 +5,6 @@ describe('index', () => { let tfhePublicKey: string; beforeAll(async () => { - await sodium.ready; tfhePublicKey = createTfhePublicKey(); }); diff --git a/src/sdk/index.ts b/src/sdk/index.ts index a63868e..f54e190 100644 --- a/src/sdk/index.ts +++ b/src/sdk/index.ts @@ -1,4 +1,3 @@ -import sodium from 'libsodium-wrappers'; import { TfheCompactPublicKey } from 'node-tfhe'; import { fromHexString } from '../utils'; @@ -51,8 +50,6 @@ export type FhevmInstance = { export const createInstance = async ( config: FhevmInstanceConfig, ): Promise => { - await sodium.ready; - const { networkUrl, gatewayUrl, coprocessorUrl } = config; let chainId: number | undefined = config.chainId; diff --git a/src/sdk/keypair.test.ts b/src/sdk/keypair.test.ts index 46d7a1b..19c469a 100644 --- a/src/sdk/keypair.test.ts +++ b/src/sdk/keypair.test.ts @@ -1,4 +1,3 @@ -import sodium from 'libsodium-wrappers'; import { fromHexString } from '../utils'; import { generateKeypair, createEIP712 } from './keypair'; import { @@ -9,9 +8,7 @@ import { } from '../kms/node/kms_lib'; describe('token', () => { - beforeAll(async () => { - await sodium.ready; - }); + beforeAll(async () => {}); it('generate a valid keypair', async () => { const keypair = generateKeypair(); diff --git a/src/sdk/keypair.ts b/src/sdk/keypair.ts index 87e7820..0b461d3 100644 --- a/src/sdk/keypair.ts +++ b/src/sdk/keypair.ts @@ -5,7 +5,7 @@ import { cryptobox_sk_to_u8vec, cryptobox_pk_to_u8vec, cryptobox_get_pk, -} from 'node-kms'; +} from '../kms/node/kms_lib.js'; export type EIP712Type = { name: string; type: string }; diff --git a/tsconfig.json b/tsconfig.json index 3818162..3ccb020 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,8 +14,7 @@ "baseUrl": ".", "resolveJsonModule": true, "paths": { - "*": ["*"], - "node-kms": ["src/kms/node/index.js"] + "*": ["*"] } }, "include": ["src", "types"], diff --git a/tsconfig.node.rollup.json b/tsconfig.node.rollup.json deleted file mode 100644 index e5099c8..0000000 --- a/tsconfig.node.rollup.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "compilerOptions": { - "rootDir": "src", - "outDir": "lib/node", - "declaration": true, - "target": "ES2020", - "lib": ["es5", "DOM"], - "module": "esnext", - "skipLibCheck": true, - "esModuleInterop": true, - "allowJs": true, - "strict": true, - "baseUrl": ".", - "resolveJsonModule": false, - "paths": { - "*": ["*"], - "node-kms": ["src/kms/node/index.js"] - } - }, - "include": ["src"], - "exclude": ["node_modules", "src/*.test.ts"] -} diff --git a/tsconfig.web.rollup.json b/tsconfig.rollup.json similarity index 81% rename from tsconfig.web.rollup.json rename to tsconfig.rollup.json index a7bdd70..13fdbe3 100644 --- a/tsconfig.web.rollup.json +++ b/tsconfig.rollup.json @@ -1,7 +1,7 @@ { "compilerOptions": { "rootDir": "src", - "outDir": "lib/web", + "outDir": "lib", "declaration": true, "target": "ES2020", "lib": ["es5", "DOM"], @@ -13,8 +13,7 @@ "baseUrl": ".", "resolveJsonModule": false, "paths": { - "*": ["*"], - "node-kms": ["src/kms/node/index.js"] + "*": ["*"] } }, "include": ["src"], From a9a5df6ada029b788fe357e85bfa70e3b9d7ff1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20=27birdy=27=20Danjou?= Date: Thu, 20 Jun 2024 17:03:51 +0200 Subject: [PATCH 2/2] test: ignore fetch from test coverage --- src/ethCall.test.ts | 19 +++++++++++++++++++ src/ethCall.ts | 1 + 2 files changed, 20 insertions(+) create mode 100644 src/ethCall.test.ts diff --git a/src/ethCall.test.ts b/src/ethCall.test.ts new file mode 100644 index 0000000..7cbbf42 --- /dev/null +++ b/src/ethCall.test.ts @@ -0,0 +1,19 @@ +import { decodeAbiBytes } from './ethCall'; + +describe('decrypt', () => { + let clientKeySer: Uint8Array; + + it('converts a hex to bytes', async () => { + const value = '0xff'; + const bytes = decodeAbiBytes(value); + expect(bytes).toEqual(new Uint8Array([255])); + + const value2 = '0x00'; + const bytes2 = decodeAbiBytes(value2); + expect(bytes2).toEqual(new Uint8Array([])); + + const value3 = '0xf0f0'; + const bytes3 = decodeAbiBytes(value3); + expect(bytes3).toEqual(new Uint8Array([240, 240])); + }); +}); diff --git a/src/ethCall.ts b/src/ethCall.ts index e0e50d5..be72ab0 100644 --- a/src/ethCall.ts +++ b/src/ethCall.ts @@ -1,3 +1,4 @@ +/* istanbul ignore file */ import { toHexString } from './utils'; export function decodeAbiBytes(hex: string): Uint8Array {