Skip to content

fix(create): check and request SEP-41 allowance before depositing (#218) - #298

Merged
Jaydbrown merged 1 commit into
conduit-protocol:mainfrom
daniella-techie:fix/218-217-214-sep41-allowance-check
Jul 30, 2026
Merged

fix(create): check and request SEP-41 allowance before depositing (#218)#298
Jaydbrown merged 1 commit into
conduit-protocol:mainfrom
daniella-techie:fix/218-217-214-sep41-allowance-check

Conversation

@daniella-techie

@daniella-techie daniella-techie commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • create_stream pulls the deposit from the sender via the token's SEP-41 transfer_from, which requires a pre-existing allowance from sender → factory. app/create/page.tsx never checked or requested this allowance, so a user's first deposit for a given token would hit an opaque contract-level failure with no actionable UI guidance.
  • Wires the existing (previously-unused) lib/token-allowance-gateway.ts into the deposit flow in app/create/page.tsx: before calling createStream, it now checks the current allowance and, if insufficient, prompts an approve() transaction and waits for it to confirm before proceeding. The submit button reflects each stage (Checking token allowance… / Requesting approval… / Signing transaction…).
  • A transient allowance-check failure (network/RPC error) is surfaced as an error and does not get treated as a genuine zero allowance (consistent with fix: distinguish transient network errors from genuine zero allowance #291's transient-vs-zero distinction) — it aborts before any approve/create call.
  • lib/factory.ts's internal isMock() is now exported so the allowance step is skipped under the exact same demo/mock-mode condition createStream() itself already uses to skip the real RPC call.

Closes #218.
Closes #217
Closes #214

Related, not closed by this PR:

Test plan

  • npx vitest run app/create/__tests__/page.test.tsx — added 4 new tests covering: insufficient allowance → approve → create, sufficient allowance → skip approve, approve failure → actionable error + no create, allowance-check failure (transient) → actionable error + no approve/create. All 7 tests in the file pass.
  • npx vitest run — full suite passes (27 files, 343 tests).
  • npx tsc --noEmit — clean.
  • npx next lint — clean.

DripFactory::create_stream pulls the deposit from the sender via the
token's SEP-41 transfer_from, which requires a pre-existing allowance
from sender -> factory. The create-stream flow never checked or
requested this allowance, so a user's first deposit for a given token
hit an opaque contract-level failure with no actionable guidance.

Wires the existing (previously unused) lib/token-allowance-gateway.ts
into app/create/page.tsx: check allowance before submitting, and
prompt approval when insufficient. lib/factory.ts's isMock() is now
exported so the allowance step is skipped under the same condition
create_stream itself already skips the real RPC call.

Closes conduit-protocol#218.
Related: conduit-protocol#217 (lib/tokens.ts still has a redundant, now-more-clearly
unused allowance implementation — left in place, tracked separately),
conduit-protocol#214 (pruneOldestTerminal retention-cap gap in lib/store.ts — unrelated
file, tracked separately).
@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@daniella-techie 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! 🚀

Learn more about application limits

@Jaydbrown
Jaydbrown merged commit 0a65635 into conduit-protocol:main Jul 30, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants