Skip to content

Commit

Permalink
Fix Bank Example (#2514)
Browse files Browse the repository at this point in the history
While searching for any pending TODO, I came across this one and
resolved it.
  • Loading branch information
jonaprieto authored Nov 13, 2023
1 parent a05586e commit 19c2aa2
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions examples/milestone/Bank/Bank.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -99,37 +99,25 @@ issue : Address -> Address -> Nat -> Token
| caller owner amount :=
assert (caller == bankAddress) (mkToken owner 0 amount);

{-
-- TODO: Uncomment this block once we fix
-- https://github.com/anoma/juvix/issues/2056
--- Deposits some amount of money into the bank.
deposit : Balances -> Token -> Nat -> Token;
deposit bal token amount :=
deposit (bal : Balances) (token : Token) (amount : Nat)
: Token :=
let
difference : Nat := sub (getAmount token) amount;
remaining :
Token :=
mkToken (getOwner token) (getGates token) difference;
hash : Field := hashAddress (getOwner token); # TODO: This raise an error
remaining : Token :=
mkToken (getOwner token) (getGates token) difference;
hash : Field := hashAddress (getOwner token);
bal' : Balances := increment hash amount bal;
in runOnChain (commitBalances bal') remaining;

--- Returns a new ;Token; containing the amount of money withdrawn.
withdraw :
Balances
-> Address
-> Address
-> Nat
-> Nat
-> Nat
-> Token;
withdraw bal caller recipient amount rate periods :=
withdraw (bal : Balances) (caller : Address) (recipient : Address) (amount : Nat) (rate : Nat) (periods : Nat)
: Token :=
assert
(caller == bankAddress)
(let
hash : Field := hashAddress recipient; # TODO: Idem
hash : Field := hashAddress recipient;
total : Nat := calculateInterest amount rate periods;
token : Token := mkToken recipient 0 total;
bal' : Balances := decrement hash amount bal;
in runOnChain (commitBalances bal') token);
-}

0 comments on commit 19c2aa2

Please sign in to comment.