aiken-lang / stdlib

The Aiken Standard Library

Home Page:https://aiken-lang.github.io/stdlib

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inability to create the Transaction Type because of Opaque MintValue Type

logicalmechanism opened this issue · comments

In v1.1.0 the type for the mint field inside a transaction has changed into the opaque type MintValue. This value can not be created which restricts the ability to create fake Transaction types for unit tests.

Before, we use to be able to do something like this:

let tx =
    Transaction {
      ...
      mint: value.from_asset(#"acab", #"beef", 1),
      ...
    }

But without the ability to create a MintValue type, we lose our ability to write unit tests that require a fake transaction type.

Potential solutions:

  • Having a specific helper for creating a MintValue for testing.
  • Remove opaqueness from MintValue but restrict public access to type creation functions.
  • Revert back to Value as in 1.0.0

Another option would be to provide safe conversion functions from Value. A Value is already sanitized, to it is safe to convert from Value to MintedValue.