Skip to content

Commit

Permalink
Remove the quantity type from the codebase
Browse files Browse the repository at this point in the history
This type isn't useful and leaks the constructor everywhere, making it
harmful at best
  • Loading branch information
mariari committed Dec 18, 2024
1 parent bea7142 commit 55bc8d5
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 61 deletions.
25 changes: 0 additions & 25 deletions Anoma/Resource/Types.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,6 @@ KindEq : Eq Kind :=
eq (a b : Kind) : Bool := anomaEncode a == anomaEncode b;
};

--- A fixed-size data type encoding the quantity of a resource.
type Quantity :=
mkQuantity@{
unQuantity : Nat;
};

instance
FromNaturalQuantityI : FromNatural Quantity := mkFromNatural mkQuantity;

instance
NaturalQuantityI : Natural Quantity :=
mkNatural@{
+ : Quantity -> Quantity -> Quantity
| (mkQuantity a) (mkQuantity b) := mkQuantity (a Natural.+ b);

* : Quantity -> Quantity -> Quantity
| (mkQuantity a) (mkQuantity b) := mkQuantity (a Natural.* b);
};

--- A fixed-size data type encoding the public commitment to the private nullifier key.
type NullifierKeyCommitment :=
mkNullifierKeyCommitment@{
Expand Down Expand Up @@ -109,12 +90,6 @@ Value-Ord : Ord Value;
deriving instance
Value-Eq : Eq Value;

deriving instance
Quantity-Ord : Ord Quantity;

deriving instance
Quantity-Eq : Eq Quantity;

--- Implements the ;FixedSize; trait for ;NullifierKeyCommitment;.
instance
NullifierKeyCommitment-FixedSize : FixedSize NullifierKeyCommitment :=
Expand Down
11 changes: 0 additions & 11 deletions Applib/Projection/TotalQuantity.juvix

This file was deleted.

1 change: 0 additions & 1 deletion Applib/Resource/Traits.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ module Applib.Resource.Traits;
-- import Applib.Resource.Traits.NullifierKey open public;
-- import Applib.Resource.Traits.Originator open public;
-- import Applib.Resource.Traits.Owner open public;
import Applib.Resource.Traits.Quantity open public;
-- import Applib.Resource.Traits.Supply open public;
-- import Applib.Resource.Traits.Transferability open public;

Expand Down
20 changes: 0 additions & 20 deletions Applib/Resource/Traits/Quantity.juvix

This file was deleted.

6 changes: 2 additions & 4 deletions Applib/Transaction/Errors.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ type InsufficientElementsError :=

type InsufficientHasQuantityError :=
mkInsufficientHasQuantityError@{
limit : Quantity;
actual : Quantity;
limit : Nat;
actual : Nat;
};

type InvalidLogicError :=
Expand Down Expand Up @@ -139,13 +139,11 @@ InsufficientHasQuantityError-Show : Show InsufficientHasQuantityError :=
++str "limit : "
++str (e
|> InsufficientHasQuantityError.limit
|> Quantity.unQuantity
|> Show.show)
++str ", "
++str "actual"
++str (e
|> InsufficientHasQuantityError.actual
|> Quantity.unQuantity
|> Show.show)
++str "}"};

Expand Down

0 comments on commit 55bc8d5

Please sign in to comment.