Repository navigation
feat(sdk): memo payload, 502 failover, abortable confirmation, vested amount (#1170, #1171, #1172, #1173) - #1207
Merged
Jaydbrown merged 7 commits intoNov 26, 2026
Conversation
A stray line break split the 'navigator.credentials' literal in WebAuthnSigner.defaultCredentialsContainer, so src/signer.ts failed to parse. That stopped 'npm ci' (which runs the build via 'prepare') and any test importing the signer module from working. Restores the literal to a single line with the original message text.
…col#1171, conduit-protocol#1172, conduit-protocol#1173 Describe the behaviour the four issues ask for. These are expected to fail on main: - conduit-protocol#1170: StreamBuilder.build() does not emit the memo set via withMemo(). The payload should carry it as base64 Memo XDR. - conduit-protocol#1171: an HTTP 502 from the primary RPC should rotate to the next endpoint in the group. Only 503 currently does. - conduit-protocol#1172: clawback() accepts an AbortSignal but drops it before the confirmation poll, so aborting it does not stop polling. - conduit-protocol#1173: calculateVestedAmount() does not exist. It should interpolate vested stroops from millisecond timestamps. Refs conduit-protocol#1170 Refs conduit-protocol#1171 Refs conduit-protocol#1172 Refs conduit-protocol#1173
… amount conduit-protocol#1170: StreamBuilder.build() now emits the memo set via withMemo() as base64 Memo XDR under 'memo', so off-chain systems can reconcile a stream against an invoice or employee reference. The memo is omitted when unset. conduit-protocol#1171: an HTTP 502 from an RPC endpoint is classified as RpcServiceUnavailableError, the same as 503. The endpoint group then rotates to the next URL instead of retrying the failing one. conduit-protocol#1172: pollForConfirmation waits through a sleepOrAbort helper that rejects with AbortError as soon as the signal aborts, not after the full poll interval. clawback() now forwards its signal to the confirmation poll, where it was previously dropped. conduit-protocol#1173: new calculateVestedAmount(stream, currentTimestampMs) returns vested stroops with millisecond interpolation for live counters. It is exported from the package entry point. Closes conduit-protocol#1170 Closes conduit-protocol#1171 Closes conduit-protocol#1172 Closes conduit-protocol#1173
…it-protocol#1173 Covers the boundaries the feature commit could still get wrong: - conduit-protocol#1170: an over-long text memo still throws and leaves no memo in the payload; an id memo keeps its full 64-bit value; replacing the memo replaces the payload field. - conduit-protocol#1171: an HTTP 400 must not trigger failover (only server-side gateway errors should rotate endpoints); 502 maps to RpcServiceUnavailableError. - conduit-protocol#1172: waitForConfirmation rejects at abort time rather than after the poll interval, does not poll when already aborted, and keeps polling normally when not aborted. - conduit-protocol#1173: endTime boundary returns the full deposit; withdrawn does not reduce the vested total; a future pausedAt is ignored; very large rates keep full bigint precision; a paused stream at its start returns 0.
- docs/api.md: new calculateVestedAmount entry (units, interpolation, whole-second agreement with calculateWithdrawableAmount); build() memo field; clawback(streamId, signal?); waitForConfirmation abort timing; HTTP 502 in the failover list. - CHANGELOG.md: Added and Fixed entries under [Unreleased] for conduit-protocol#1170, conduit-protocol#1171, conduit-protocol#1172 and conduit-protocol#1173.
Fixes the TypeScript errors that stopped 'npm run build' and 'npm run typecheck' on main. None of them changed the public API: - src/events.ts: a cliff-reached event is attributed to its recipient. The old code read a 'sender' field that event does not have, so the recipient was silently dropped from the history actor list. - src/token.ts: 'window' is read through globalThis so the file compiles without the DOM lib. Browser behaviour is unchanged. - src/tests/mock-event-stream.test.ts: narrow the union before reading 'sequence', which cliff-reached events do not carry. Lint reports no errors on the touched files.
|
@gbemisola299 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Closes #1170
Closes #1171
Closes #1172
Closes #1173
Summary
Four SDK enhancements on one branch, each in its own area of the code. Before implementing, I checked what already existed on
main, since some of the requested behaviour was partly there. The gaps I found and closed are listed per issue below.#1170: memo in the stream-creation payload
Already on main:
StreamBuilder.withMemo()stored the memo and applied it tobuildTransaction()/simulate().Gap:
build()(the off-chain payload) never included it, so a backend reconciling streams had nothing to match on.Change:
build()now addsmemoas base64MemoXDR whenwithMemo()was called. The field is omitted when unset. Decode withxdr.Memo.fromXDR(memo, 'base64'). Text, hash, id and return memos all work.#1171: RPC failover on 502 / 503
Already on main: endpoint groups (
ConduitConfig.rpcUrls), rotation on 429/503, timeouts and open circuits, with tests.Gap: HTTP 502 was never classified as a service-unavailable error, so a bad gateway retried the same dead endpoint instead of rotating.
Change: 502 maps to
RpcServiceUnavailableError, same as 503. Tests confirm a 502 rotates to the next endpoint and a 400 does not.Not done: 504 is not included. I kept the change to the two statuses the issue names. It's a one-line addition if you want it.
#1172: AbortSignal on confirmation watchers
Already on main:
waitForConfirmation(),builder.submit()andpollForConfirmation()accepted a signal.Gaps:
clawback()accepted a signal and then dropped it before the confirmation poll.confirmationPollIntervalMsis set).Change: the poll sleep is now abortable (
sleepOrAbort), so an abort rejects withAbortErrorimmediately.clawback()forwards its signal.Not done:
createBatchStreams()and the deprecatedcreate()still take no signal. Adding one is a public signature change, so I left it for a follow-up.#1173: sub-second vested amount
Added:
calculateVestedAmount(stream, currentTimestampMs = Date.now()), exported from the package root.ratePerSecond × elapsedMs / 1000, computed inbigint(no float rounding; tested at 10¹⁸).endTimeand cancellation rules ascalculateWithdrawableAmount. It does not subtractwithdrawn, because it reports total vested.Note on "matching on-chain": the contract records accrual in whole seconds. At whole-second timestamps this matches
calculateWithdrawableAmount + withdrawnexactly (tested). Between seconds, the value is a client-side estimate for display, not a value the contract has recorded yet.Other fixes needed to build and test
These were blocking
npm ci/npm run buildonmain, so they are included in this PR:src/signer.ts: a broken string literal (a stray line break inside`navigator.credentials`) that stopped the file from parsing.src/events.ts: a cliff-reached event was attributed to an undefinedsender, so the recipient was silently dropped from history actors. Now it's attributed torecipient. This is a behaviour change, so it has a CHANGELOG entry.src/token.ts:windowis read viaglobalThis. Browser behaviour is unchanged.src/tests/mock-event-stream.test.ts: narrowed a union type that broke typecheck.Commits
Follows the CONTRIBUTING 5-commit convention. The signer fix comes first, since nothing else builds without it.
fix(signer): restore the broken literaltest(sdk): failing tests for all four issues (verified to fail onmain)feat(sdk): implementationtest(sdk): edge cases and error pathsdocs(sdk):docs/api.mdandCHANGELOG.mdchore(sdk): typecheck and build passTesting
npm run typecheck: passesnpm run build: passes (previously failed onmain)npm run lint: 0 errors. The warnings in touched files are pre-existing (SorobanRpcimport,Number()calls in older code). None are new.npx vitest run: 1875 passed, 2 failed. Both failures also occur onmain:custom-fetch.test.ts > keeps non-2xx status visible so 429s still map to RateLimitErrortimes out at 10 s.builder-create-stream-args.test.ts > rejects a startTime in the pastexpects the old messagestartTime cannot be in the past.mainnow sayscannot be more than 30 days in the past. The assertion is stale; I did not change it, since it is outside these issues.Review notes
calculateVestedAmount). Per CONTRIBUTING, it needs the mandatory owner review plus one more maintainer approval, and the CHANGELOG entry is included.Closeslines are in the feature commit as well, as CONTRIBUTING asks.