Skip to content

Commit

Permalink
feat: add ord instance
Browse files Browse the repository at this point in the history
  • Loading branch information
heueristik committed Oct 18, 2024
1 parent 345e676 commit fd171a8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 0 additions & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ jobs:
uses: jaxxstorm/[email protected]
with:
repo: anoma/juvix-nightly-builds

cache: enable
- name: Clean & Update Dependencies
run: juvix clean --global && juvix clean && juvix dependencies update
Expand Down
17 changes: 17 additions & 0 deletions Anoma/Transaction/Object.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module Anoma.Transaction.Object;

import Stdlib.Prelude open;
import Stdlib.Data.Set as Set open using {Set};
import Stdlib.Trait.Ord.Eq open using {fromOrdToEq};
import Anoma.Resource.Types as Resource;
import Anoma.State.CommitmentTree as CommitmentTree;
import Anoma.Transaction.Action open using {Action};
Expand Down Expand Up @@ -30,3 +31,19 @@ commitmentSet (transaction : Transaction) : Set Resource.Commitment := MISSING_A

--- Returns the ;Resource.Nullifier; ;Set; of a ;Transaction;.
nullifierSet (transaction : Transaction) : Set Resource.Nullifier := MISSING_ANOMA_BUILTIN;

module TransactionInternal;
--- Compares two ;Transaction; objects.
compare (lhs rhs : Transaction) : Ordering :=
let
prod (tx : Transaction) : _ := Transaction.roots tx, Transaction.actions tx;
in Ord.cmp (prod lhs) (prod rhs);

--- Implements the ;Ord; trait for ;Transaction;.
instance
Transaction-Ord : Ord Transaction := mkOrd compare;

--- Implements the ;Eq; trait for ;Transaction;.
instance
Transaction-Eq : Eq Transaction := fromOrdToEq;
end;

0 comments on commit fd171a8

Please sign in to comment.