@@ -6,7 +6,7 @@ pub mod interface;
66pub struct BankAccount {
77 pub name : ByteArray ,
88 pub address : ContractAddress ,
9- pub balance : u128 ,
9+ pub balance : u64 ,
1010 pub opened : bool ,
1111}
1212
@@ -47,13 +47,13 @@ pub mod SimpleBank {
4747 self . emit (Event :: AccountCreated (AccountCreated { name , address , balance : 0 }));
4848 }
4949
50- fn deposit (ref self : ContractState , amount : u128 ) {
50+ fn deposit (ref self : ContractState , amount : u64 ) {
5151 let address = get_caller_address ();
5252
5353 let mut bank_account : BankAccount = self . bank_accounts. read (address );
5454 assert (bank_account . opened, ' Nonexistent Account' );
5555
56- let balance : u128 = bank_account . balance;
56+ let balance : u64 = bank_account . balance;
5757
5858 let (new_balance , is_overflow ) = balance . overflowing_add (amount );
5959 assert (! is_overflow , ' Balance Overflow' );
@@ -63,13 +63,13 @@ pub mod SimpleBank {
6363 self . emit (Event :: DepositMade (DepositMade { amount , address }))
6464 }
6565
66- fn withdraw (ref self : ContractState , amount : u128 ) {
66+ fn withdraw (ref self : ContractState , amount : u64 ) {
6767 let address = get_caller_address ();
6868
6969 let mut bank_account : BankAccount = self . bank_accounts. read (address );
7070 assert (bank_account . opened, ' Nonexistent Account' );
7171
72- let balance : u128 = bank_account . balance;
72+ let balance : u64 = bank_account . balance;
7373
7474 let (new_balance , is_underflow ) = balance . overflowing_sub (amount );
7575 assert (! is_underflow , ' Balance Underflow' );
@@ -80,7 +80,7 @@ pub mod SimpleBank {
8080 self . emit (Event :: WithdrawalMade (WithdrawalMade { amount , address }))
8181 }
8282
83- fn transfer (ref self : ContractState , amount : u128 , recipient : ContractAddress ) {
83+ fn transfer (ref self : ContractState , amount : u64 , recipient : ContractAddress ) {
8484 let from = get_caller_address ();
8585
8686 let mut bank_account_from : BankAccount = self . bank_accounts. read (from );
@@ -89,8 +89,8 @@ pub mod SimpleBank {
8989 assert (bank_account_from . opened, ' Nonexistent Account' );
9090 assert (bank_account_to . opened, ' Nonexistent Account' );
9191
92- let balance_from : u128 = bank_account_from . balance;
93- let balance_to : u128 = bank_account_to . balance;
92+ let balance_from : u64 = bank_account_from . balance;
93+ let balance_to : u64 = bank_account_to . balance;
9494
9595 let (balance_from_new_amount , is_underflow ) = balance_from . overflowing_sub (amount );
9696 assert (! is_underflow , ' Insufficient Funds' );
@@ -132,7 +132,7 @@ pub mod SimpleBank {
132132 )
133133 }
134134
135- fn get_balance (self : @ ContractState ) -> u128 {
135+ fn get_balance (self : @ ContractState ) -> u64 {
136136 self . get_account_details (). balance
137137 }
138138
0 commit comments