@@ -12,13 +12,12 @@ import { ethers } from 'ethers'
1212import pc from 'picocolors'
1313import {
1414 calculateDepositCapacity ,
15- checkAllowances ,
15+ checkAndSetAllowances ,
1616 checkFILBalance ,
1717 checkUSDFCBalance ,
1818 DEFAULT_LOCKUP_DAYS ,
1919 depositUSDFC ,
2020 getPaymentStatus ,
21- setMaxAllowances ,
2221 validatePaymentRequirements ,
2322} from '../core/payments/index.js'
2423import { cleanupProvider , cleanupSynapseService } from '../core/synapse/index.js'
@@ -155,41 +154,6 @@ export async function runInteractiveSetup(options: PaymentSetupOptions): Promise
155154 let depositAmount = 0n
156155 let actionsTaken = false // Track if any changes were made
157156
158- // Check and optionally set max allowances for WarmStorage
159- s . start ( 'Checking WarmStorage permissions...' )
160- const allowanceCheck = await checkAllowances ( synapse )
161-
162- if ( allowanceCheck . needsUpdate ) {
163- s . stop ( `${ pc . yellow ( '⚠' ) } WarmStorage authorization required` )
164- log . line ( '' )
165- log . line ( pc . bold ( 'WarmStorage Service Authorization' ) )
166- log . line ( 'WarmStorage needs permissions to manage storage payments on your behalf.' )
167- log . line ( 'This is a one-time setup.' )
168- log . line ( '' )
169-
170- const shouldSetAllowances = await confirm ( {
171- message : 'Authorize WarmStorage?' ,
172- initialValue : true ,
173- } )
174-
175- if ( isCancel ( shouldSetAllowances ) ) {
176- cancel ( 'Setup cancelled' )
177- process . exit ( 1 )
178- }
179-
180- if ( shouldSetAllowances ) {
181- s . start ( 'Setting WarmStorage permissions...' )
182- const setResult = await setMaxAllowances ( synapse )
183- s . stop ( `${ pc . green ( '✓' ) } WarmStorage permissions configured` )
184- log . indent ( pc . gray ( `Transaction: ${ setResult . transactionHash } ` ) )
185- actionsTaken = true
186- } else {
187- log . line ( pc . yellow ( '⚠ Skipping WarmStorage authorization. You may need to set this before using storage.' ) )
188- }
189- } else {
190- s . stop ( `${ pc . green ( '✓' ) } WarmStorage permissions already configured` )
191- }
192-
193157 // Show current deposit capacity
194158 const currentCapacity = calculateDepositCapacity ( status . filecoinPayBalance , pricePerTiBPerEpoch )
195159 log . line ( pc . bold ( 'Current Storage Capacity:' ) )
@@ -258,12 +222,9 @@ export async function runInteractiveSetup(options: PaymentSetupOptions): Promise
258222 depositAmount = ethers . parseUnits ( amountStr , 18 )
259223
260224 s . start ( 'Depositing USDFC...' )
261- const { approvalTx , depositTx } = await depositUSDFC ( synapse , depositAmount )
225+ const { depositTx } = await depositUSDFC ( synapse , depositAmount )
262226 s . stop ( `${ pc . green ( '✓' ) } Deposit complete` )
263227
264- if ( approvalTx ) {
265- log . indent ( pc . gray ( `Approval tx: ${ approvalTx } ` ) )
266- }
267228 log . indent ( pc . gray ( `Deposit tx: ${ depositTx } ` ) )
268229 actionsTaken = true
269230
@@ -278,6 +239,13 @@ export async function runInteractiveSetup(options: PaymentSetupOptions): Promise
278239 log . indent ( `Total deposit: ${ formatUSDFC ( status . filecoinPayBalance + depositAmount ) } USDFC` )
279240 log . indent ( `Capacity: ~${ newCapacityStr } for 1 month` )
280241 log . flush ( )
242+ } else {
243+ const { updated, transactionHash } = await checkAndSetAllowances ( synapse )
244+ if ( updated ) {
245+ log . indent ( `${ pc . green ( '✓' ) } Updated payment allowances, tx: ${ transactionHash } ` )
246+ } else {
247+ log . indent ( `${ pc . green ( '✓' ) } Deposit already sufficient (${ formatUSDFC ( status . filecoinPayBalance ) } USDFC)` )
248+ }
281249 }
282250
283251 // Final summary
0 commit comments