@@ -14,8 +14,8 @@ import { accountSelectors } from 'store/account'
14
14
import {
15
15
buyUSDCFlowFailed ,
16
16
buyUSDCFlowSucceeded ,
17
- onRampOpened ,
18
- onRampCanceled
17
+ onrampOpened ,
18
+ onrampCanceled
19
19
} from 'store/buy-usdc/slice'
20
20
import { USDCOnRampProvider } from 'store/buy-usdc/types'
21
21
import { getUSDCUserBank } from 'store/buy-usdc/utils'
@@ -29,10 +29,11 @@ import { pollPremiumTrack } from '../premium-content/sagas'
29
29
import { updatePremiumTrackStatus } from '../premium-content/slice'
30
30
31
31
import {
32
- onBuyUSDC ,
33
- onPurchaseConfirmed ,
34
- onPurchaseSucceeded ,
35
- onUSDCBalanceSufficient ,
32
+ buyUSDC ,
33
+ purchaseCanceled ,
34
+ purchaseConfirmed ,
35
+ purchaseSucceeded ,
36
+ usdcBalanceSufficient ,
36
37
purchaseContentFlowFailed ,
37
38
startPurchaseContentFlow
38
39
} from './slice'
@@ -159,9 +160,9 @@ function* doStartPurchaseContentFlow({
159
160
160
161
// buy USDC if necessary
161
162
if ( initialBalance . lt ( new BN ( price ) . mul ( BN_USDC_CENT_WEI ) ) ) {
162
- yield * put ( onBuyUSDC ( ) )
163
+ yield * put ( buyUSDC ( ) )
163
164
yield * put (
164
- onRampOpened ( {
165
+ onrampOpened ( {
165
166
provider : USDCOnRampProvider . STRIPE ,
166
167
purchaseInfo : {
167
168
desiredAmount : price
@@ -171,17 +172,22 @@ function* doStartPurchaseContentFlow({
171
172
172
173
const result = yield * race ( {
173
174
success : take ( buyUSDCFlowSucceeded ) ,
174
- canceled : take ( onRampCanceled ) ,
175
+ canceled : take ( onrampCanceled ) ,
175
176
failed : take ( buyUSDCFlowFailed )
176
177
} )
177
178
178
- if ( result . canceled || result . failed ) {
179
- // Return early for failure or cancellation
179
+ // Return early for failure or cancellation
180
+ if ( result . canceled ) {
181
+ yield * put ( purchaseCanceled ( ) )
182
+ return
183
+ }
184
+ if ( result . failed ) {
185
+ yield * put ( purchaseContentFlowFailed ( ) )
180
186
return
181
187
}
182
188
}
183
189
184
- yield * put ( onUSDCBalanceSufficient ( ) )
190
+ yield * put ( usdcBalanceSufficient ( ) )
185
191
186
192
const { blocknumber, splits } = yield * getPurchaseConfig ( {
187
193
contentId,
@@ -195,13 +201,13 @@ function* doStartPurchaseContentFlow({
195
201
splits,
196
202
type : 'track'
197
203
} )
198
- yield * put ( onPurchaseSucceeded ( ) )
204
+ yield * put ( purchaseSucceeded ( ) )
199
205
200
206
// confirm purchase
201
207
yield * pollForPurchaseConfirmation ( { contentId, contentType } )
202
208
203
209
// finish
204
- yield * put ( onPurchaseConfirmed ( ) )
210
+ yield * put ( purchaseConfirmed ( ) )
205
211
206
212
yield * put (
207
213
setVisibility ( {
0 commit comments