Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use Int as Datum property type #3161

Closed
tdiesler opened this issue May 11, 2021 · 4 comments
Closed

Cannot use Int as Datum property type #3161

tdiesler opened this issue May 11, 2021 · 4 comments
Labels

Comments

@tdiesler
Copy link

Area

[] Plutus Foundation Related to the GHC plugin, Haskell-to-Plutus compiler, on-chain code

Summary

When I use Int as property type in a Datum like this ...

data PayoutDatum = PayoutDatum {
    pdEpoch :: Int,
    pdActive :: Bool,
    pdPayout :: Integer,
    pdRemaining :: Integer
  } deriving Show

I get ...

src/Astor/Payout.hs:46:1: error:
    • No instance for (PlutusTx.IsData Int)
        arising from a use of ‘PlutusTx.toData’
    • In the expression: PlutusTx.toData arg_a96t
      In the second argument of ‘PlutusTx.Constr’, namely
        ‘[PlutusTx.toData arg_a96t, PlutusTx.toData arg_a96u,
          PlutusTx.toData arg_a96v, PlutusTx.toData arg_a96w]’
      In the expression:
        (PlutusTx.Constr 0)
          [PlutusTx.toData arg_a96t, PlutusTx.toData arg_a96u,
           PlutusTx.toData arg_a96v, PlutusTx.toData arg_a96w]
   |
46 | PlutusTx.unstableMakeIsData ''PayoutDatum
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Could you perhaps clarify the restrictions on data types in Datum properties?

@tdiesler tdiesler added the bug label May 11, 2021
@tdiesler tdiesler changed the title Cannot use Int as Datum property Cannot use Int as Datum property type May 11, 2021
@ghost
Copy link

ghost commented May 11, 2021

That's because Plutus uses unbounded integers and there is no point in supporting Int with additional conversions. You can just use Integer.

@ghost ghost closed this as completed May 11, 2021
@tdiesler
Copy link
Author

merci

@effectfully
Copy link
Contributor

How about providing a dummy IsData Int instance throwing a TypeError telling the user to use Integer instead?

@ghost
Copy link

ghost commented May 12, 2021

@effectfully sounds great! I've opened a PR.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants