Type guard to check if a transaction is of a specific type
The transaction to check
The expected transaction type
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} Copy
const tx: Transaction = { ... }if (isTransactionType(tx, 'l2psEncryptedTx')) { // tx is now typed as L2PSTransaction const [_, payload] = tx.content.data // payload is typed as L2PSEncryptedPayload}
Type guard to check if a transaction is of a specific type