Skip to content

Fixed checkAllowance false-negative - #411

Merged
Jaydbrown merged 2 commits into
conduit-protocol:mainfrom
therealjhay:main
Aug 30, 2026
Merged

Fixed checkAllowance false-negative #411
Jaydbrown merged 2 commits into
conduit-protocol:mainfrom
therealjhay:main

Conversation

@therealjhay

@therealjhay therealjhay commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Fixed checkAllowance false-negative on RPC failure and pushed in 2 batches:

Batch 1 — lib/tokens.ts:94-104,158-184: Changed AllowanceResult.hasAllowance to boolean | undefined with docs: true = sufficient, false = checked insufficient (needs approve()), undefined = couldn't check (transient RPC). catch now returns { hasAllowance: undefined, currentAllowance: 0n, error } instead of false, so callers must check error and retry rather than defaulting to an unnecessary SEP-41 approve() tx. app/create/page.tsx:248-276 already correctly checks gateway.checkAllowance().success before approve() (mirrors #291).

Closes #384

Batch 2 — lib/soroban.ts:122-127,395-392 + tests: Restored broken invokeContract/pollForConfirmation plumbing from #379 (stray status block made file unparsable): pollForConfirmation now returns Promise surfacing returnValue on SUCCESS, __clearFeeStatsCache/resetServer clears fee-stats cache. Fixed lib/soroban-pipeline.test.ts:203-230, lib/tokens.test.ts:105-130 (mock type, added hasAllowance === undefined failure test), lib/stream.test.ts:116-123 (flags-order), app/create/tests/page.test.tsx:45-99 (mock checkRecipientExists + 700 ms debounce wait) — all 411 tests pass.

…heckAllowance

checkAllowance previously swallowed getAllowance RPC/network errors and
returned { hasAllowance: false }. The create-stream flow keys off
hasAllowance to decide whether to prompt an SEP-41 approve(), so a
transient hiccup incorrectly triggered an extra signed transaction and
fee even when allowance was already sufficient.

Return { hasAllowance: undefined, error } on failure so callers can
distinguish 'checked, insufficient' (hasAllowance === false) from
'couldn't check' (hasAllowance === undefined) and retry the read
instead of defaulting to needs-approval. Update AllowanceResult docs
accordingly.
…solate test state

soroban.ts was broken since conduit-protocol#379: duplicated poll logic with a stray
status check left the file syntactically invalid and pollForConfirmation
still returned string instead of InvokeContractResult. Make poll return
{ hash, returnValue } on SUCCESS and { hash } on pending timeout so
create_stream's stream_id surfaces correctly, and clean up the stray
block. Also clear the inclusion-fee cache on resetServer / via
__clearFeeStatsCache so fee-stats tests don't leak cached p70 across
cases.

Tests: update soroban-pipeline mocks to expect object shape, fix
tokens.test mock type, add checkAllowance RPC-failure distinguishing
test, fix stream.test missing-field order, and mock
checkRecipientExists in create/page tests with debounce-aware waits.
@Jaydbrown
Jaydbrown merged commit 2871e2b into conduit-protocol:main Aug 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: checkAllowance maps any allowance-check failure to hasAllowance: false, prompting a redundant approval transaction on a transient RPC error

2 participants