Box that only has 1 token can't pass an if else statement when the if condition supposed to skip the token check

Viewed 22

I have a guardscript that checks 2 tokens to see if its full. However, this can't compile due to the box not have a 2nd token.

val checkTokens: Boolean                 =
    if (SELF.tokens.size < 2) true
    else {
        SELF.tokens(1)._1 == _tokenId.get && SELF.tokens(1)._2 < x
    }

How can we deal with this kind of situation?

1 Answers

This is limitation of v4.x ErgoTree interpreter due to the bugs in AOT costing. Such script should work just fine once v5.0 is activated.

Related