Smart Contract

FastbreakVaultsCloserTransactionHandler

A.46df6b5eeec6103a.FastbreakVaultsCloserTransactionHandler

Valid From

130,582,277

Deployed

1w ago
Feb 21, 2026, 02:48:39 PM UTC

Dependents

1 imports
1import FlowTransactionScheduler from 0xe467b9dd11fa00df
2import FlowTransactionSchedulerUtils from 0xe467b9dd11fa00df
3import FastbreakVaultsCloser_V1 from 0x46df6b5eeec6103a
4import FlowToken from 0x1654653399040a61
5import FungibleToken from 0xf233dcee88fe0abe
6
7access(all)
8contract FastbreakVaultsCloserTransactionHandler {
9    /// Handler resource that implements the Scheduled Transaction interface
10    access(all) resource Handler: FlowTransactionScheduler.TransactionHandler {
11        access(FlowTransactionScheduler.Execute) fun executeTransaction(id: UInt64, data: AnyStruct?) {
12
13            let tokenHolder = FastbreakVaultsCloserTransactionHandler.account.address
14            FastbreakVaultsCloser_V1.swapToJuice()
15            
16            var delay: UFix64 = 600.0
17            let future = getCurrentBlock().timestamp + delay
18            let priority = FlowTransactionScheduler.Priority.Medium
19            let executionEffort: UInt64 = 1000
20
21            let estimate = FlowTransactionScheduler.estimate(
22                data: data,
23                timestamp: future,
24                priority: priority,
25                executionEffort: executionEffort
26            )
27
28            assert(
29                estimate.timestamp != nil || priority == FlowTransactionScheduler.Priority.Low,
30                message: estimate.error ?? "estimation failed"
31            )
32
33            // Ensure a handler resource exists in the contract account storage
34            if FastbreakVaultsCloserTransactionHandler.account.storage.borrow<&AnyResource>(from: /storage/FastbreakVaultsCloserTransactionHandler) == nil {
35                let handler <- FastbreakVaultsCloserTransactionHandler.createHandler()
36                FastbreakVaultsCloserTransactionHandler.account.storage.save(<-handler, to: /storage/FastbreakVaultsCloserTransactionHandler)
37
38                // Issue a non-entitled public capability for the handler that is publicly accessible
39                let publicCap = FastbreakVaultsCloserTransactionHandler.account.capabilities.storage
40                    .issue<&{FlowTransactionScheduler.TransactionHandler}>(/storage/FastbreakVaultsCloserTransactionHandler)
41
42                // publish the capability
43                FastbreakVaultsCloserTransactionHandler.account.capabilities.publish(publicCap, at: /public/FastbreakVaultsCloserTransactionHandler)
44            }
45
46            let vaultRef = FastbreakVaultsCloserTransactionHandler.account.storage.borrow<auth(FungibleToken.Withdraw) &FlowToken.Vault>(from: /storage/flowTokenVault)
47            ?? panic("missing FlowToken vault on contract account")
48            let feesVault <- vaultRef.withdraw(amount: estimate.flowFee ?? 0.0) as! @FlowToken.Vault
49            
50            // borrow a reference to the scheduled transaction manager
51            let manager = FastbreakVaultsCloserTransactionHandler.account.storage.borrow<auth(FlowTransactionSchedulerUtils.Owner) &{FlowTransactionSchedulerUtils.Manager}>(from: FlowTransactionSchedulerUtils.managerStoragePath)
52                ?? panic("Could not borrow a Manager reference from \(FlowTransactionSchedulerUtils.managerStoragePath)")
53
54            let handlerTypeIdentifier = manager.getHandlerTypeIdentifiers().keys[0]
55
56            manager.scheduleByHandler(
57                handlerTypeIdentifier: handlerTypeIdentifier,
58                handlerUUID: nil,
59                data: data,
60                timestamp: future,
61                priority: priority,
62                executionEffort: executionEffort,
63                fees: <-feesVault
64            )
65
66        }
67
68        access(all) view fun getViews(): [Type] {
69                return [Type<StoragePath>(), Type<PublicPath>()]
70            }
71
72        access(all) fun resolveView(_ view: Type): AnyStruct? {
73            switch view {
74                case Type<StoragePath>():
75                    return /storage/FastbreakVaultsCloserTransactionHandler
76                case Type<PublicPath>():
77                    return /public/FastbreakVaultsCloserTransactionHandler
78                default:
79                    return nil
80            }
81        }
82    }
83
84
85    /// Factory for the handler resource
86    access(all) fun createHandler(): @Handler {
87        return <- create Handler()
88    }
89}
90