Skip to content

Scheduled Txs: Add event for failed executions #570

Description

@joshuahannan

Issue To Be Solved

Many implementations of scheduled transactions have organically emitted an event to emit when a scheduled transaction fails. It would be good to standardize this.

Suggest A Solution

An event + emitter method so block explorers could watch for interface-level events and add failure states.

// inside FlowTransactionScheduler

access(all) event HandlerExecutionFailed(
    id: UInt64,
    handlerType: String,
    address: Address?,
    uuid: UInt64,
    error: String
)

access(all) resource interface TransactionHandler {
    // ...
    // default implementation emits an event - can be overridden
    access(contract) fun emitExecutionFailed(
        id: UInt64,
        error: String
    ) {
        post {
            emit HandlerExecutionFailed(
                whileExecuting: whileExecuting,
                handlerType: self.getType().identifier,
                address: self.owner?.address,
                uuid: self.uuid,
                error: String
            )
        }
    }
}

// ---------

// inside consuming resource
access(all) resource COAHandler : TransactionHandler {
    access(FlowTransactionScheduler.Execute) fun executeTransaction(id: UInt64, data: AnyStruct?) {
        // some failure state encountered
        self.emitExecutionFailed(id: id, error: "CALL_FAILED")
        return
    }
}

The main concern would be id spoofing, but maybe there's something workable there to consider in the future.

This would be upgradeable

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

Status
🏗 In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions