Commit 8c2b99d
Auto-create USDC userbank on gated track upload/edit (#14227)
## Summary
- When a user uploads or edits a track with USDC stream/download gating,
fire `createUserBankIfNeeded(mint: 'USDC')` in parallel with the SDK
call so the seller's userbank exists as a side effect of listing gated
content — not just after they open Add Cash, withdraw, or claim flows.
- Best-effort: errors are logged but never block the save. Underlying
`getOrCreateUserBank` is idempotent, so duplicate triggers (e.g. album
publish that fans out to `publishTracks`) are safe.
## Scope
- `useUpdateTrack` (track edit) —
`packages/common/src/api/tan-query/tracks/useUpdateTrack.ts`
- `publishTracks` (track upload, also reused by album upload) —
`packages/common/src/api/tan-query/upload/usePublishTracks.ts`
## Why not the album-level hooks
- `usePublishCollection` already delegates to `publishTracks` for each
child track of a premium album, so the trigger fires there.
- `useUpdateCollection` only edits the album's price metadata; the album
was already gated at upload time, so the userbank trigger has already
fired via the original track publish.
## Test plan
- [ ] Upload a track with USDC download gating → seller's USDC userbank
exists after upload (verify via Solana account lookup or a follow-up
purchase)
- [ ] Edit an existing non-gated track to enable USDC downloads →
userbank exists after save
- [ ] Edit a USDC-gated track's price (no gate change) → no error,
userbank trigger short-circuits via `didExist`
- [ ] Upload a premium album → seller userbank exists once, even with
multiple child tracks
- [ ] Upload/edit a non-USDC (free / follow-gated / token-gated) track →
no userbank call fires
- [ ] Network failure on userbank creation → upload/edit still succeeds;
warning logged
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>1 parent c712104 commit 8c2b99d
2 files changed
Lines changed: 49 additions & 0 deletions
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| 33 | + | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
| |||
107 | 109 | | |
108 | 110 | | |
109 | 111 | | |
| 112 | + | |
110 | 113 | | |
111 | 114 | | |
112 | 115 | | |
| |||
134 | 137 | | |
135 | 138 | | |
136 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
137 | 160 | | |
138 | 161 | | |
139 | 162 | | |
| |||
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
| |||
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| 50 | + | |
48 | 51 | | |
49 | 52 | | |
50 | 53 | | |
| |||
58 | 61 | | |
59 | 62 | | |
60 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
61 | 86 | | |
62 | 87 | | |
63 | 88 | | |
| |||
189 | 214 | | |
190 | 215 | | |
191 | 216 | | |
| 217 | + | |
192 | 218 | | |
193 | 219 | | |
194 | 220 | | |
| |||
0 commit comments