diff --git a/packages/codec/package.json b/packages/codec/package.json index 9e77546..d8b570b 100644 --- a/packages/codec/package.json +++ b/packages/codec/package.json @@ -43,6 +43,7 @@ "voidpay", "void-layer" ], + "sideEffects": ["*.wasm", "pkg/**", "pkg-node/**"], "publishConfig": { "access": "public", "provenance": true @@ -62,11 +63,13 @@ "lint": "cargo clippy --all-targets --all-features --locked -- -D warnings && cargo fmt --manifest-path Cargo.toml -- --check && eslint src", "size": "ls -la pkg/void_layer_codec_bg.wasm" }, + "dependencies": { + "@void-layer/types": "workspace:^" + }, "peerDependencies": { "brotli-wasm": "^3.0.1" }, "devDependencies": { - "@void-layer/types": "workspace:^", "@types/node": "25.9.1", "@vitest/coverage-v8": "4.1.8", "brotli-wasm": "^3.0.1", @@ -76,6 +79,6 @@ "vitest": "^4.1.8" }, "engines": { - "node": ">=24" + "node": ">=20" } } diff --git a/packages/codec/src/index.test.ts b/packages/codec/src/index.test.ts index 6869911..e3585b5 100644 --- a/packages/codec/src/index.test.ts +++ b/packages/codec/src/index.test.ts @@ -156,11 +156,11 @@ describe('decodeInvoiceWire decompression-bomb guard', () => { }) // --------------------------------------------------------------------------- -// G-11 T5: write_quantity rejects > 9 significant decimals (PrecisionLoss). -// T5 changed silent clamp → explicit CodecError::PrecisionLoss throw. +// G-11 T5: write_quantity rejects > 9 significant decimals (InvalidAmount). +// T5 changed silent clamp → explicit CodecError::InvalidAmount throw. // --------------------------------------------------------------------------- -describe('G-11: write_quantity PrecisionLoss on >9 decimals (T5)', () => { +describe('G-11: write_quantity InvalidAmount on >9 decimals (T5)', () => { it('G-11: write_quantity rejects > 9 significant decimals (T5)', () => { const inv: Invoice = { ...MINIMAL_INVOICE, diff --git a/packages/codec/src/index.ts b/packages/codec/src/index.ts index 178094f..52448f3 100644 --- a/packages/codec/src/index.ts +++ b/packages/codec/src/index.ts @@ -15,15 +15,20 @@ import type { BrotliWasmType } from 'brotli-wasm' import type { Invoice } from '@void-layer/types' import { encodeWire, decodeWire } from './wire.js' -// Import the canonical WASM functions for use in the wire shim below, and -// re-export them as part of the public API. -import { - encodeInvoiceCanonical, - decodeInvoiceCanonical, - receiptHash, -} from '../pkg/void_layer_codec.js' - -export { encodeInvoiceCanonical, decodeInvoiceCanonical, receiptHash } +// Import the canonical WASM module and cast to a typed surface so that +// consumers get proper Invoice types (not `any`) in the generated .d.ts. +// Runtime behaviour is unchanged — these are the same WASM functions. +import * as _wasmPkg from '../pkg/void_layer_codec.js' + +const _wasm = _wasmPkg as unknown as { + encodeInvoiceCanonical: (invoice: Invoice) => Uint8Array + decodeInvoiceCanonical: (bytes: Uint8Array) => Invoice + receiptHash: (canonical_bytes: Uint8Array) => Uint8Array +} + +export const encodeInvoiceCanonical = _wasm.encodeInvoiceCanonical +export const decodeInvoiceCanonical = _wasm.decodeInvoiceCanonical +export const receiptHash = _wasm.receiptHash // --------------------------------------------------------------------------- // Brotli lazy init (mirrors compressPayload reference pattern) diff --git a/packages/networks/package.json b/packages/networks/package.json index fcee9cf..0023368 100644 --- a/packages/networks/package.json +++ b/packages/networks/package.json @@ -23,9 +23,10 @@ "homepage": "https://github.com/void-layer/codec/tree/main/packages/networks#readme", "bugs": { "url": "https://github.com/void-layer/codec/issues" }, "keywords": ["voidpay","void-layer","ethereum","chains","tokens","web3"], + "sideEffects": false, "publishConfig": { "access": "public", "provenance": true }, "dependencies": { - "@void-layer/types": "workspace:*" + "@void-layer/types": "workspace:^" }, "peerDependencies": { "viem": ">=2.0.0 <3.0.0" diff --git a/packages/networks/tsconfig.json b/packages/networks/tsconfig.json index ef3e2e4..9b5d940 100644 --- a/packages/networks/tsconfig.json +++ b/packages/networks/tsconfig.json @@ -14,10 +14,11 @@ "skipLibCheck": true }, "include": [ - "src/**/*" + "src/**/*.ts" ], "exclude": [ "node_modules", - "dist" + "dist", + "src/**/*.test.ts" ] } diff --git a/packages/types/tsconfig.json b/packages/types/tsconfig.json index 7e8f270..981f506 100644 --- a/packages/types/tsconfig.json +++ b/packages/types/tsconfig.json @@ -15,5 +15,5 @@ "noUncheckedIndexedAccess": true }, "include": ["src/**/*.ts"], - "exclude": ["dist", "node_modules"] + "exclude": ["dist", "node_modules", "src/**/*.test.ts"] } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 733c758..5354e62 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -28,6 +28,10 @@ importers: version: 8.60.1(eslint@10.4.1)(typescript@6.0.3) packages/codec: + dependencies: + '@void-layer/types': + specifier: workspace:^ + version: link:../types devDependencies: '@types/node': specifier: 25.9.1 @@ -35,9 +39,6 @@ importers: '@vitest/coverage-v8': specifier: 4.1.8 version: 4.1.8(vitest@4.1.8) - '@void-layer/types': - specifier: workspace:^ - version: link:../types brotli-wasm: specifier: ^3.0.1 version: 3.0.1 @@ -57,7 +58,7 @@ importers: packages/networks: dependencies: '@void-layer/types': - specifier: workspace:* + specifier: workspace:^ version: link:../types devDependencies: '@vitest/coverage-v8': @@ -471,66 +472,79 @@ packages: resolution: {integrity: sha512-DxH0P3wxm+Yzs/p3zrk9dw1rURu8p0Nv5+MRK/L7OtnLNg5rLZraSBFZ8iUXOd9f2BlhJyEpIZUH/emjq4UJ4g==} cpu: [arm] os: [linux] + libc: [glibc] '@rollup/rollup-linux-arm-musleabihf@4.61.0': resolution: {integrity: sha512-T6ZvMNe84kAz6TBWHC7hGAoEtzP1LWYw/AqayGWEF6uISt3Abk/st06LqRD9THd7Xz3NxzurUpzAuEAUbZf+nw==} cpu: [arm] os: [linux] + libc: [musl] '@rollup/rollup-linux-arm64-gnu@4.61.0': resolution: {integrity: sha512-q/4hzvQkDs8b4jIBab1pnLiiM0ayTZsN2amBFPDzuyZxjEd4wDwx0UJFYM3cOZzSf5Kw8fnWSprJzIBMkcR44Q==} cpu: [arm64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-arm64-musl@4.61.0': resolution: {integrity: sha512-vvYWX3akdEAY6km+9wAqFDnk6pQsbJKVnj7xawcvs/+fdlYBGp+U+Qq/lLfpIxYIZvZLHMAKD9HLdacSx/r3dw==} cpu: [arm64] os: [linux] + libc: [musl] '@rollup/rollup-linux-loong64-gnu@4.61.0': resolution: {integrity: sha512-DePa5cqOxDP/Zp0VOXpeWaGew5iIv5DXp9NYbzkX5PFQyWVX9184WCTh3hvr/7lhXo8ZVlbFLkz8+o/q1dU6gA==} cpu: [loong64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-loong64-musl@4.61.0': resolution: {integrity: sha512-LV8aWMB8UChglMCEzs7RkN0GsH29RJaLLqwm9fCIjlqwxQTiWAqNcc7wjBkH31hV0PU/yVxGYvrYsgfea2qw6g==} cpu: [loong64] os: [linux] + libc: [musl] '@rollup/rollup-linux-ppc64-gnu@4.61.0': resolution: {integrity: sha512-QoNSnwQtaeNu5grdBbsL0tt1uyl5EnS8DA8Mr3nluMXbhdQNyhN+G4tBax7VCdxLKj8YJ0/4OO9Ho84jMnJtKA==} cpu: [ppc64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-ppc64-musl@4.61.0': resolution: {integrity: sha512-/zZp5MKapIIApE8trN8qLGNSiRN9TUoaUZ1cmVu4XnVdd5LQLOXTtyi+vtfUbNnT3iyjzpPqYeKXmvJ+gJGYWw==} cpu: [ppc64] os: [linux] + libc: [musl] '@rollup/rollup-linux-riscv64-gnu@4.61.0': resolution: {integrity: sha512-RbrzcD3aJ1k3UbtMRRBNwojdVVyXjuVAFTfn/xPa6EEl6GE9Sm/akPgFTb9aAC9pMKGJ6CtWxaGrqWcabH+ySg==} cpu: [riscv64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-riscv64-musl@4.61.0': resolution: {integrity: sha512-ZF+onDsBso8PJf1XaG9lB+O9RnBpKGnY6OrzC4CSHrtC1jb6jWLTKK4bRqdoCXHd22gyr2hiYmEAm8Wns/BOCw==} cpu: [riscv64] os: [linux] + libc: [musl] '@rollup/rollup-linux-s390x-gnu@4.61.0': resolution: {integrity: sha512-Atk0aSIk5Zx2Wuh9dgRQgLP0Koc8hOeYpbWryMXyk8G8/HmPkwPPkMqIIDhrXHHYqfUzSJA/I7IWSBv8xSmRBA==} cpu: [s390x] os: [linux] + libc: [glibc] '@rollup/rollup-linux-x64-gnu@4.61.0': resolution: {integrity: sha512-0uMOcf3eZ5K+K4cYHkdxShFMPlPXCOdfDFEFn9dNYAEEd2cVvmOfH7zFgRVoDgmtQ1m9k5q7qfrHzyMAubKYUA==} cpu: [x64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-x64-musl@4.61.0': resolution: {integrity: sha512-mvFtE4A/t/7hRJ7X8Ozmu8FsIkAUat2nzl12pgU337BRmq87AQUJztwHz2Zv5/tjo9/C95E66CK03SI/ToEDJw==} cpu: [x64] os: [linux] + libc: [musl] '@rollup/rollup-openbsd-x64@4.61.0': resolution: {integrity: sha512-z9b9+aTxvt8n2rNltMPvyaUfB8NJ+CVyOrGK/MdIKHx7B+lXmZpm/XbRsU7Rpf3fRqJ2uS6mBJiJveCtq8LHDg==} @@ -597,36 +611,42 @@ packages: engines: {node: '>=10'} cpu: [arm64] os: [linux] + libc: [glibc] '@swc/core-linux-arm64-musl@1.15.33': resolution: {integrity: sha512-il7tYM+CpUNzieQbwAjFT1P8zqAhmGWNAGhQZBnxurXZ0aNn+5nqYFTEUKNZl7QibtT0uQXzTZrNGHCIj6Y1Og==} engines: {node: '>=10'} cpu: [arm64] os: [linux] + libc: [musl] '@swc/core-linux-ppc64-gnu@1.15.33': resolution: {integrity: sha512-ZtNBwN0Z7CFj9Il0FcPaKdjgP7URyKu/3RfH46vq+0paOBqLj4NYldD6Qo//Duif/7IOtAraUfDOmp0PLAufog==} engines: {node: '>=10'} cpu: [ppc64] os: [linux] + libc: [glibc] '@swc/core-linux-s390x-gnu@1.15.33': resolution: {integrity: sha512-De1IyajoOmhOYYjw/lx66bKlyDpHZTueqwpDrWgf5O7T6d1ODeJJO9/OqMBmrBQc5C+dNnlmIufHsp4QVCWufA==} engines: {node: '>=10'} cpu: [s390x] os: [linux] + libc: [glibc] '@swc/core-linux-x64-gnu@1.15.33': resolution: {integrity: sha512-mGTH0YxmUN+x6vRN/I6NOk5X0ogNktkwPnJ94IMvR7QjhRDwL0O8RXEDhyUM0YtwWrryBOqaJQBX4zruxEPRGw==} engines: {node: '>=10'} cpu: [x64] os: [linux] + libc: [glibc] '@swc/core-linux-x64-musl@1.15.33': resolution: {integrity: sha512-hj628ZkSEJf6zMf5VMbYrG2O6QqyTIp2qwY6VlCjvIa9lAEZ5c2lfPblCLVGYubTeLJDxadLB/CxqQYOQABeEQ==} engines: {node: '>=10'} cpu: [x64] os: [linux] + libc: [musl] '@swc/core-win32-arm64-msvc@1.15.33': resolution: {integrity: sha512-GV2oohtN2/5+KSccl86VULu3aT+LrISC8uzgSq0FRnikpD+Zwc+sBlXmoKQ+Db6jI57ITUOIB8jRkdGMABC29g==}