stacks.js icon indicating copy to clipboard operation
stacks.js copied to clipboard

Consider using type generics with the StacksTransactionWire type

Open aryzing opened this issue 1 year ago • 0 comments

Problem

Different transaction types often require dedicated code. However, even after checking the payload type, the payload needs to be kept in its own variable to preserve any type checks or assertions. There is no way to assert that a transaction has a given payload type

Solution

Introduce generics for transaction types. Something like

type StacksTransactionWire<TPayload = PayloadWire> = {
  payload: TPayload
  // ... other props
}

This would allow typing a given transaction's payload (and possibly other internal structures) without having to keep them as separate variables.

aryzing avatar Dec 17 '24 11:12 aryzing