From 2bed1ddf139a11daf1516276f1e7e339fd158a40 Mon Sep 17 00:00:00 2001 From: Michael Heuer Date: Fri, 8 Nov 2024 18:52:40 +0100 Subject: [PATCH] refactor: AppDataValue into a record --- Anoma/Transaction/AppData.juvix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Anoma/Transaction/AppData.juvix b/Anoma/Transaction/AppData.juvix index 9850332..c2da092 100644 --- a/Anoma/Transaction/AppData.juvix +++ b/Anoma/Transaction/AppData.juvix @@ -22,7 +22,10 @@ type AppDataKey := mkAppDataKey@{unAppDataKey : Nat}; --- A data type encoding the lookup value of application data. --- TODO Add an equivalent to `anomaEncode` and `anomaDecode` to be able to change this to ;ByteArray;. type AppDataValue := - mkAppDataValue@{unAppDataValue : Pair Nat DeletionCriterion}; + mkAppDataValue@{ + value : Nat; + deletionCriterion : DeletionCriterion; + }; --- A type describing an app data map. AppData : Type := Map AppDataKey AppDataValue; @@ -58,7 +61,10 @@ end; module AppDataValueInternal; --- Compares two ;AppDataValue;s. compare (lhs rhs : AppDataValue) : Ordering := - Ord.cmp (AppDataValue.unAppDataValue lhs) (AppDataValue.unAppDataValue rhs); + let + prod (value : AppDataValue) : _ := + AppDataValue.value value, AppDataValue.deletionCriterion value; + in Ord.cmp (prod lhs) (prod rhs); --- Implements the ;Ord; trait for ;AppDataValue;. instance