1
1
mirror of https://github.com/anoma/juvix.git synced 2024-09-11 16:26:33 +03:00

Fix Bank Example (#2514)

While searching for any pending TODO, I came across this one and
resolved it.
This commit is contained in:
Jonathan Cubides 2023-11-13 12:07:24 +01:00 committed by GitHub
parent a05586e44f
commit 19c2aa2437
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);
-}