def _claim_iscore(self, wallet, address): print('\n>>> Claim IScore:') iscore = IScore(self._icon_service) result = iscore.query(address) iscore.print_status(address, result) estimated_icx = in_icx(int(result['estimatedICX'], 16)) if (estimated_icx - 1.0) <= 0: die('Error: EstimatedICX should be larger than 1.0') tx_hash = iscore.claim(wallet) self._ensure_tx_result(tx_hash, True)
def balance(args): icon_service = get_icon_service(args.endpoint) if args.keystore: address = get_address_from_keystore(args.keystore) elif args.address: address = args.address else: die('Error: keystore or address should be specified') _balance = icon_service.get_balance(address) print('ICX =', in_icx(_balance))
def _check_and_set(self, wallet, address, current_stake, auto_staking): balance = self.balance(address) status = { 'staked': in_icx(current_stake), 'unstaked': in_icx(balance), } total_icx = in_icx(current_stake + balance) print_response('Balance (in ICX)', status) print('Total ICX balance =', total_icx) if auto_staking: new_amount = int(total_icx - 1.0) # leave 1.0 ICX for future transactions else: input_value = input('\n==> New staking amount (in ICX)? ') new_amount = self._check_value(input_value, int(total_icx)) self._check_total_delegated(address, in_loop(new_amount)) print('Requested amount =', new_amount, f'({in_loop(new_amount)} loop)') tx_hash = self.set(wallet, new_amount) self._ensure_tx_result(tx_hash, auto_staking)
def print_status(address, result): print('[Stake]') print_response(address, result) print('StakedICX =', in_icx(int(result['stake'], 16)))
def print_status(self, address, result=None): print('[IScore]') if result is None: result = self.query(address) print_response(address, result) print('EstimatedICX =', in_icx(int(result['estimatedICX'], 16)))
def print_status(address, result): print('[Delegation]') print_response(address, result) print('DelegatedICX =', in_icx(int(result['totalDelegated'], 16)))