@@ -82,8 +82,52 @@ def generate_new_key(self):
8282 acct = w3 .eth .account .create ()
8383 return acct .privateKey
8484
85- def get_total_balance (self ):
86- pass
85+ def get_total_balance (self , address : str ) -> dict :
86+ celo_token = self .base_wrapper .create_and_get_contract_by_name ('GoldToken' )
87+ stable_token = self .base_wrapper .create_and_get_contract_by_name ('StableToken' )
88+ locked_celo = self .base_wrapper .create_and_get_contract_by_name ('LockedGold' )
89+
90+ gold_balance = celo_token .balance_of (address )
91+ locked_balance = locked_celo .get_account_total_locked_gold (address )
92+ dollar_balance = stable_token .balance_of (address )
93+ pending = 0
94+ try :
95+ pending = locked_celo .get_pending_withdrawals_total_value (address )
96+ except :
97+ pass # Just means that it's not an account
98+ return {
99+ 'CELO' : gold_balance ,
100+ 'locked_CELO' : locked_balance ,
101+ 'cUSD' : dollar_balance ,
102+ 'pending' : pending
103+ }
87104
88105 def get_network_config (self ):
89- pass
106+ token1 = self .base_wrapper .registry .registry .functions .getAddressForString ('GoldToken' )
107+ token2 = self .base_wrapper .registry .registry .functions .getAddressForString ('StableToken' )
108+
109+ exchange_contract = self .base_wrapper .create_and_get_contract_by_name ('Exchange' )
110+ election_contract = self .base_wrapper .create_and_get_contract_by_name ('Election' )
111+ attestation_contract = self .base_wrapper .create_and_get_contract_by_name ('Attestation' )
112+ governance_contract = self .base_wrapper .create_and_get_contract_by_name ('Governance' )
113+ locked_gold_contract = self .base_wrapper .create_and_get_contract_by_name ('LockedGold' )
114+ sorted_oracles_contract = self .base_wrapper .create_and_get_contract_by_name ('SortedOracles' )
115+ gas_price_minimum_contract = self .base_wrapper .create_and_get_contract_by_name ('GasPriceMinimum' )
116+ reserve_contract = self .base_wrapper .create_and_get_contract_by_name ('Reserve' )
117+ stable_token_contract = self .base_wrapper .create_and_get_contract_by_name ('StableToken' )
118+ validators_contract = self .base_wrapper .create_and_get_contract_by_name ('Validators' )
119+ downtime_slasher_contract = self .base_wrapper .create_and_get_contract_by_name ('DowntimeSlasher' )
120+
121+ return {
122+ 'exchange' : exchange_contract .get_config (),
123+ 'election' : election_contract .get_config (),
124+ 'attestation' : attestation_contract .get_config ([token1 , token2 ]),
125+ 'governance' : governance_contract .get_config (),
126+ 'locked_gold' : locked_gold_contract .get_config (),
127+ 'sorted_oracles' : sorted_oracles_contract .get_config (),
128+ 'gas_price_minimum' : gas_price_minimum_contract .get_config (),
129+ 'reserve' : reserve_contract .get_config (),
130+ 'stable_token' : stable_token_contract .get_config (),
131+ 'validators' : validators_contract .get_config (),
132+ 'downtime_slasher' : downtime_slasher_contract .get_config ()
133+ }
0 commit comments