`Value` doesn't normalize across different `mint`s
Renegatto opened this issue · comments
Renegatto commented
Example
Given:
v1 :: Value
v1 = singleton "123a" "feea" 3
v2 :: Value
v2 = singleton "124b" "feeb" 12
make :: SpendingBuilder -> ScriptContext
make = buildSpending mempty . mkNormalized . mappend minimalCtx
minimalCtx :: SpendingBuilder
minimalCtx = withSpendingOutRef ref <> input (withRef ref)
where ref = TxOutRef "a0" 0
getMint :: ScriptContext -> [(CurrencySymbol, Map TokenName Integer)]
getMint = toList . getValue . txInfoMint . scriptContextTxInfo
Expected:
ghci> getMint (make $ mint $ mconcat [v1,v2]) == getMint (make $ mint v1 <> mint v2)
True
Got:
ghci> getMint (make $ mint $ mconcat [v1,v2]) == getMint (make $ mint v1 <> mint v2)
False
Details:
ghci> getMint (make (mint $ mconcat [v1,v2]))
[(124b,Map {unMap = [("feeb",12)]}),(,Map {unMap = [("",0)]}),(123a,Map {unMap = [("feea",3)]})]
ghci> getMint (make (mint v1 <> mint v2))
[(123a,Map {unMap = [("feea",3)]}),(,Map {unMap = [("",0)]}),(124b,Map {unMap = [("feeb",12)]})]
Renegatto commented
Wrong example
Renegatto commented
Fixed example.
SeungheonOh commented
Sort is missing somewhere I think
Michał Adamczyk commented
Basically, it looks like the values in ScriptContexts built by PCB lose their guarantees, which is wrong - Plutarch expects them in place.
I wasn't sure if I should open another issue for this.