• Type guard to check if a transaction's data matches the expected type

    Type Parameters

    • T extends
          | "web2Request"
          | "crosschainOperation"
          | "native"
          | "demoswork"
          | "identity"
          | "instantMessaging"
          | "nativeBridge"
          | "l2psEncryptedTx"

    Parameters

    • tx: Transaction

      The transaction to check

    • dataType: T

      The expected data type

    Returns tx is Transaction & {
        content: {
            data: [T, any];
        };
    }

    True if the transaction's data is of the specified type

    const tx: Transaction = { ... }
    if (isTransactionDataType(tx, 'l2psEncryptedTx')) {
    // tx.content.data[0] is 'l2psEncryptedTx'
    // tx.content.data[1] is L2PSEncryptedPayload
    }