Smart Contract
CounterTransactionHandler
A.ca7ee55e4fc3251a.CounterTransactionHandler
1import FlowTransactionScheduler from 0xe467b9dd11fa00df
2import Counter from 0xca7ee55e4fc3251a
3
4access(all) contract CounterTransactionHandler {
5
6 /// Handler resource that implements the Scheduled Transaction interface
7 access(all) resource Handler: FlowTransactionScheduler.TransactionHandler {
8 access(FlowTransactionScheduler.Execute) fun executeTransaction(id: UInt64, data: AnyStruct?) {
9 Counter.increment()
10 let newCount = Counter.getCount()
11 log("Transaction executed (id: ".concat(id.toString()).concat(") newCount: ").concat(newCount.toString()))
12 }
13
14 access(all) view fun getViews(): [Type] {
15 return [Type<StoragePath>(), Type<PublicPath>()]
16 }
17
18 access(all) fun resolveView(_ view: Type): AnyStruct? {
19 switch view {
20 case Type<StoragePath>():
21 return /storage/CounterTransactionHandler
22 case Type<PublicPath>():
23 return /public/CounterTransactionHandler
24 default:
25 return nil
26 }
27 }
28 }
29
30 /// Factory for the handler resource
31 access(all) fun createHandler(): @Handler {
32 return <- create Handler()
33 }
34}
35