• Type guard to check if a transaction is of a specific type

    Type Parameters

    Parameters

    • tx: Transaction

      The transaction to check

    • type: T["content"]["type"]

      The expected transaction type

    Returns tx is T

    True if the transaction is of the specified type

    const tx: Transaction = { ... }
    if (isTransactionType(tx, 'l2psEncryptedTx')) {
    // tx is now typed as L2PSTransaction
    const [_, payload] = tx.content.data
    // payload is typed as L2PSEncryptedPayload
    }