Fix toStroops precision (#88), service isolation (#91), event data (#83), slug guard (#86) - #161
Merged
Merged
Conversation
|
@Spagero763 is attempting to deploy a commit to the Deejah Team on Vercel. A member of the Team first needs to authorize it. |
Stellar-Deejah#91) instead of the lossy Math.round(amount * 10_000_000), which silently truncated sub-stroop fractional amounts to 0. Guards NaN/Infinity, malformed strings, sub-stroop precision, and i128 overflow with SDKError('INVALID_AMOUNT'). Added utils tests covering one-stroop precision (string and number), the guards, and fromStroops round-trips. functions (createEscrowService/createEnrollmentService/createQueueService) over an injected storage adapter, plus a default singleton and backward-compatible standalone re-exports so route handlers are unchanged. Service tests construct a fresh service over a new MemoryAdapter per test, replacing the vi.resetModules() and import('...?t='+Date.now()) workarounds that left tests order-dependent. docs/testing-strategy.md documents the pattern. Also repaired a pre-existing broken test fixture: the SDK client tests used a contract id with an invalid StrKey checksum ('...F4H') that validateContractId rejects; replaced with the valid all-zeros contract id ('...BSC4').
…lar-Deejah#86) Stellar-Deejah#83 — every contract's emit() prefixed its data params with `_` and published an empty `()` body, so on-chain events carried only a namespace, kind, and id. Auditors could not tell who enrolled, how much was deposited, or which position advanced. emit() now publishes the data as the event payload: - lineproof-queue: (identity, timestamp) - lineproof-escrow: (identity, amount) - lineproof-identity: (identity, timestamp) - lineproof-queue-factory: (contract_id, version) (lineproof-enrollment already emitted identity/timestamp/hash.) The typed event interfaces in sdk/src/events.ts already declare these fields, so they now match what the contracts emit. Stellar-Deejah#86 — a queue slug longer than Soroban's 9-char Symbol limit panics on-chain with no actionable cause, and neither the SDK nor the backend guarded against it. Added validateSlug() to @lineproof/sdk (lowercase alphanumeric words joined by single hyphens, <=64 chars) with tests, and tightened the backend CreateQueueSchema slug validator to the same shape so an invalid slug is rejected with 400 before any transaction is built. docs/concepts.md documents the format. See the PR description for the pre-existing, repo-wide contract build breakage (SDK-22 API drift in the contract libs and test files, missing trait methods, the wasm panic_impl clash) that blocks compile-verifying the contract-side changes and `cargo test --workspace`; that is out of scope here and tracked for the maintainers.
Spagero763
force-pushed
the
fix/all-open-issues
branch
from
July 28, 2026 13:25
25d15d7 to
679c1c3
Compare
Contributor
Author
|
Rebased onto the current |
Contributor
Author
|
@k-deejah seeeee |
Closed
10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #88
Closes #91
Closes #83
Closes #86
One PR for all four open issues. This supersedes #127 (which covered #88/#91 against an older
main); #127 can be closed in favour of this.#88 —
toStroopsfloating-point precision (SDK) ✅ verifiedtoStroopsusedMath.round(amount * 10_000_000), which silently truncatedsub-stroop fractional amounts to
0n(e.g.toStroops(0.0000001)→0n). It now:string | number;toFixed(7)), never multiplying the scaled value in floating point;SDKError('INVALID_AMOUNT', …)forNaN,Infinity, malformed strings, sub-stroop precision, andi128overflow.Added
sdk/tests/utils.test.tscases: one-stroop precision (string and number), the guards, andfromStroopsround-trips. 48 utils tests pass.#91 — service test isolation (backend) ✅ verified
escrowService,enrollmentService, andqueueServicenow expose factory functions (createEscrowService(store?), etc.) over an injected storage adapter, plus a default singleton and backward-compatible standalone re-exports (route handlers are unchanged). The service tests construct a fresh service over anew MemoryAdapter()per test, replacing thevi.resetModules()andimport('…?t=' + Date.now())workarounds that left tests order-dependent.docs/testing-strategy.mddocuments the pattern. 137 backend tests pass.#83 — events carry data ✅ source,⚠️ can't compile-verify (see below)
Every contract's
emit()prefixed its data params with_and published an empty()body, so events carried only namespace/kind/id.emit()now publishes the payload:lineproof-queue(identity, timestamp)lineproof-escrow(identity, amount)lineproof-identity(identity, timestamp)lineproof-queue-factory(contract_id, version)(
lineproof-enrollmentalready emittedidentity/timestamp/hash.) The typed interfaces insdk/src/events.tsalready declare these fields, so they now match what's emitted.#86 — queue slug length guard ✅ verified (client + API),⚠️ contract migration deferred
A slug longer than Soroban's 9-char
Symbollimit panics on-chain with no actionable cause. Guarded at both boundaries so an invalid slug is rejected long before a transaction is built:validateSlug(slug)added to@lineproof/sdk(lowercase alphanumeric words joined by single hyphens, ≤64 chars), exported and tested (6 cases).CreateQueueSchemaslug validator tightened to the same shape (400 on invalid). Existing 137 backend tests still pass.docs/concepts.mddocuments the format.The complementary contract change (migrating the on-chain
Symbolid/slug fields tosoroban_sdk::String) is noted in the docs and left with the contract build repair below.maindoes not build or pass CI independent of this PR (all upstream workflows — Test, Lint, CodeQL, Docker, Security — are currently red). Specifically, the Soroban contract workspace is broadly broken against SDK 22:BytesN::new/Address::newremoved in SDK 22, a missingregister_approved_hashtrait method, mismatched types).lineproof-queue-factory's tests call methods that no longer exist (deploy_queue,register_queue, …).duplicate lang item panic_implclash.Because of this, I could not compile-verify the #83
emit()changes or the contract side of #86, andcargo test --workspacecannot pass yet. Thoseemit()edits are minimal and correct per #83's acceptance criteria; they will compile once the workspace is repaired. Repairing the entire contract build is a separate, large effort beyond these four issues and is left for the maintainers.Also fixed in passing: the SDK client tests used a contract id with an invalid StrKey checksum (
…F4H) thatvalidateContractIdrejects — replaced with the valid all-zeros id (…BSC4). Seven further SDK client-test failures remain from pre-existing@stellar/stellar-sdkaccount/source mocking, unrelated to these issues.Verification