Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/codec/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"voidpay",
"void-layer"
],
"sideEffects": ["*.wasm", "pkg/**", "pkg-node/**"],
"publishConfig": {
"access": "public",
"provenance": true
Expand All @@ -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",
Expand All @@ -76,6 +79,6 @@
"vitest": "^4.1.8"
},
"engines": {
"node": ">=24"
"node": ">=20"
}
}
6 changes: 3 additions & 3 deletions packages/codec/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
23 changes: 14 additions & 9 deletions packages/codec/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion packages/networks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 3 additions & 2 deletions packages/networks/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
"skipLibCheck": true
},
"include": [
"src/**/*"
"src/**/*.ts"
],
"exclude": [
"node_modules",
"dist"
"dist",
"src/**/*.test.ts"
]
}
2 changes: 1 addition & 1 deletion packages/types/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
"noUncheckedIndexedAccess": true
},
"include": ["src/**/*.ts"],
"exclude": ["dist", "node_modules"]
"exclude": ["dist", "node_modules", "src/**/*.test.ts"]
}
28 changes: 24 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.