Fix ToPlutusData serializer for V3
This is intense, as we still want to preserve the serializer for V1 &
V2, and I've tried as much as possible to avoid polluting the
application layer with many enum types such as:
```
pub enum TxOut {
V1(TransactionOutput),
V2(TransactionOutput),
V3(TransactionOutput),
}
```
Those types make working with the script context cumbersome, and are
only truly required to provide different serialisation strategies. So
instead, we keep one top-level `TxInfo V1/V2/V3` type, and we ensure
to pass serialization strategies as type wrappers.
This way, the strategy propagates through the structure up until it's
eliminated when it reaches the relevant types.
All-in-all, this strikes a correct balance between maintainability and
repetition; and it makes it possible to define _different but mostly
identical_ encoders for the various versions.
With it, I've been able to successfully encode a V3 script context and
match it against one produced using the Haskell libraries. More to
come.
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
AIKEN=${1:-"cargo run -r --quiet --"}
|
||||
|
||||
TESTS=()
|
||||
for lang in $(ls script_context); do
|
||||
for interaction in $(find script_context/$lang/validators -type f); do
|
||||
title=$(basename $interaction)
|
||||
title="${title%.*}"
|
||||
cd script_context/$lang
|
||||
./test.sh $title &
|
||||
./test.sh $title "$AIKEN" &
|
||||
TESTS+=("$title,$lang,$!")
|
||||
cd - 1>/dev/null
|
||||
done
|
||||
|
||||
@@ -13,4 +13,4 @@ requirements = []
|
||||
source = "github"
|
||||
|
||||
[etags]
|
||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1723298787, nanos_since_epoch = 494542000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"]
|
||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1723298816, nanos_since_epoch = 935691000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"]
|
||||
|
||||
@@ -12,6 +12,8 @@ if [ -z $TITLE ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
AIKEN=${2:-"cargo run -r --quiet --"}
|
||||
|
||||
if ! command -v jq &> /dev/null
|
||||
then
|
||||
echo "\033[1mjq\033[0m missing from system but required."
|
||||
@@ -24,7 +26,7 @@ then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cargo run -r --quiet -- build 2>/dev/null
|
||||
$AIKEN build 2>/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $?
|
||||
fi
|
||||
@@ -39,4 +41,4 @@ cp ctx/$TITLE/inputs.cbor.template ctx/$TITLE/inputs.cbor
|
||||
sed "s/{{ VALIDATOR_HASH }}/$VALIDATOR_HASH/" ctx/$TITLE/outputs.cbor.template > ctx/$TITLE/outputs.cbor
|
||||
sed "s/{{ VALIDATOR }}/$VALIDATOR/" ctx/$TITLE/tx.cbor.template | sed "s/{{ VALIDATOR_HASH }}/$VALIDATOR_HASH/" > ctx/$TITLE/tx.cbor
|
||||
|
||||
cargo run -r --quiet -- tx simulate 1>$TITLE.log 2>&1 ctx/$TITLE/tx.cbor ctx/$TITLE/inputs.cbor ctx/$TITLE/outputs.cbor
|
||||
$AIKEN tx simulate 1>$TITLE.log 2>&1 ctx/$TITLE/tx.cbor ctx/$TITLE/inputs.cbor ctx/$TITLE/outputs.cbor
|
||||
|
||||
Reference in New Issue
Block a user