TealScript - arc4 Transaction parameter either Pay or Asset transfer

44 Views Asked by At

is it possible to have multiple types of incomming transactions as arc4 parameter for the method?

  addLiquidity(
    aXfer: AssetTransferTxn | PayTxn,
    bXfer: AssetTransferTxn | PayTxn,
    poolAsset: AssetID,
    aAsset: AssetID,
    bAsset: AssetID
  ): void {

What is the best way to check if the transaction is asset transfer or pay tx?

1

There are 1 best solutions below

1
Eric Sharma On

I would use the more general type Txn and then check whether it is an AssetTransferTxn or a PayTxn within the method.

  addLiquidity(
    aXfer: Txn,
    bXfer: Txn,
    poolAsset: AssetID,
    aAsset: AssetID,
    bAsset: AssetID
  ): void {