Smart Contract
TestFlowCallbackHandler
A.7d19efcd8e5b4a4a.TestFlowCallbackHandler
1import FlowTransactionScheduler from 0xe467b9dd11fa00df
2
3access(all) contract TestFlowCallbackHandler {
4 access(all) let HandlerStoragePath: StoragePath
5 access(all) let HandlerPublicPath: PublicPath
6
7 access(all) event CallbackExecuted(data: String)
8
9 access(all) resource Handler: FlowTransactionScheduler.TransactionHandler {
10
11 access(FlowTransactionScheduler.Execute)
12 fun executeTransaction(id: UInt64, data: AnyStruct?) {
13 if let stringRef = data as? &String {
14 if *stringRef == "fail" {
15 panic("Callback execution failed as requested")
16 }
17 emit CallbackExecuted(data: *stringRef)
18 } else if let string: String = data as? String {
19 if string == "fail" {
20 panic("Callback execution failed as requested")
21 }
22 emit CallbackExecuted(data: string)
23 } else {
24 emit CallbackExecuted(data: "bloop")
25 }
26 }
27 }
28
29 access(all) fun createHandler(): @Handler {
30 return <- create Handler()
31 }
32
33 access(all) init() {
34 self.HandlerStoragePath = /storage/testCallbackHandler
35 self.HandlerPublicPath = /public/testCallbackHandler
36 }
37}