diff --git a/bittensor/_subtensor/subtensor_mock.py b/bittensor/_subtensor/subtensor_mock.py index 5346a42c26..919cc9ebb3 100644 --- a/bittensor/_subtensor/subtensor_mock.py +++ b/bittensor/_subtensor/subtensor_mock.py @@ -887,7 +887,7 @@ def _do_delegation( amount: 'bittensor.Balance', wait_for_inclusion: bool = True, wait_for_finalization: bool = False, - ) -> bool: + ) -> Tuple[bool, Optional[str]]: # Check if delegate if not self.is_hotkey_delegate( hotkey_ss58 = delegate_ss58 @@ -895,7 +895,7 @@ def _do_delegation( raise Exception("Not a delegate") # do stake - success = self._do_stake( + success, error_msg = self._do_stake( wallet = wallet, hotkey_ss58 = delegate_ss58, amount = amount, @@ -903,7 +903,7 @@ def _do_delegation( wait_for_finalization = wait_for_finalization, ) - return success + return success, error_msg def _do_undelegation( @@ -913,7 +913,7 @@ def _do_undelegation( amount: 'bittensor.Balance', wait_for_inclusion: bool = True, wait_for_finalization: bool = False, - ) -> bool: + ) -> Tuple[bool, Optional[str]]: # Check if delegate if not self.is_hotkey_delegate( hotkey_ss58 = delegate_ss58 @@ -921,20 +921,22 @@ def _do_undelegation( raise Exception("Not a delegate") # do unstake - self._do_unstake( + response = self._do_unstake( wallet = wallet, hotkey_ss58 = delegate_ss58, amount = amount, wait_for_inclusion = wait_for_inclusion, wait_for_finalization = wait_for_finalization, ) + + return response def _do_nominate( self, wallet: 'bittensor.Wallet', wait_for_inclusion: bool = True, wait_for_finalization: bool = False, - ) -> bool: + ) -> Tuple[bool, Optional[str]]: hotkey_ss58 = wallet.hotkey.ss58_address coldkey_ss58 = wallet.coldkeypub.ss58_address @@ -942,13 +944,13 @@ def _do_nominate( if self.is_hotkey_delegate( hotkey_ss58=hotkey_ss58 ): - return True + return True, None else: subtensor_state['Delegates'][hotkey_ss58] = {} subtensor_state['Delegates'][hotkey_ss58][self.block_number] = 0.18 # Constant for now - return True + return True, None def get_transfer_fee( self, @@ -1048,7 +1050,7 @@ def _do_stake( amount: 'bittensor.Balance', wait_for_inclusion: bool = True, wait_for_finalization: bool = False, - ) -> bool: + ) -> Tuple[bool, Optional[str]]: subtensor_state = self.chain_state['SubtensorModule'] bal = self.get_balance( wallet.coldkeypub.ss58_address ) @@ -1101,7 +1103,7 @@ def _do_stake( # Remove from free balance self.chain_state['System']['Account'][wallet.coldkeypub.ss58_address]['data']['free'][self.block_number] = (bal - amount).rao - return True + return True, None def _do_unstake( self, @@ -1110,7 +1112,7 @@ def _do_unstake( amount: 'bittensor.Balance', wait_for_inclusion: bool = True, wait_for_finalization: bool = False, - ) -> bool: + ) -> Tuple[bool, Optional[str]]: subtensor_state = self.chain_state['SubtensorModule'] bal = self.get_balance( wallet.coldkeypub.ss58_address ) @@ -1127,7 +1129,7 @@ def _do_unstake( stake_state = subtensor_state['Stake'] if curr_stake.rao == 0: - return True + return True, None # Unstake the funds # We know that the hotkey has stake, so we can just remove it @@ -1158,7 +1160,7 @@ def _do_unstake( self.chain_state['System']['Account'][wallet.coldkeypub.ss58_address]['data']['free'][self.block_number] = (bal + amount).rao - return True + return True, None def get_delegate_by_hotkey( self, hotkey_ss58: str, block: Optional[int] = None ) -> Optional['bittensor.DelegateInfo']: