fix(create): check and request SEP-41 allowance before depositing (#218) - #298
Merged
Jaydbrown merged 1 commit intoJul 30, 2026
Conversation
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).
|
@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! 🚀 |
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
create_streampulls the deposit from the sender via the token's SEP-41transfer_from, which requires a pre-existing allowance from sender → factory.app/create/page.tsxnever 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.lib/token-allowance-gateway.tsinto the deposit flow inapp/create/page.tsx: before callingcreateStream, it now checks the current allowance and, if insufficient, prompts anapprove()transaction and waits for it to confirm before proceeding. The submit button reflects each stage (Checking token allowance…/Requesting approval…/Signing transaction…).lib/factory.ts's internalisMock()is now exported so the allowance step is skipped under the exact same demo/mock-mode conditioncreateStream()itself already uses to skip the real RPC call.Closes #218.
Closes #217
Closes #214
Related, not closed by this PR:
lib/token-allowance-gateway.tsits first real caller, butlib/tokens.ts's redundantgetAllowance/checkAllowance/approveAllowanceare left in place and still unused. Tracked separately; left for a follow-up PR to avoid scope creep here.pruneOldestTerminalretention cap not enforced for >20 simultaneous non-terminal transactions inlib/store.ts) — unrelated file/concern to the deposit-allowance flow, left for a follow-up 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.