2023-02-24 12:59:14 +00:00
from ast import Tuple
2022-07-18 08:37:37 +00:00
from enum import Enum
import time
2022-08-18 17:51:18 +00:00
import os
2022-07-18 08:37:37 +00:00
import sys
2022-08-03 17:31:59 +00:00
from common . SeedUtils import *
2022-08-24 08:23:43 +00:00
from . StatusMainScreen import StatusMainScreen
2023-02-24 12:59:14 +00:00
from . StatusMainScreen import authenticatePopupEnterPassword
from drivers . SquishDriver import type_text as type_text
2022-07-18 08:37:37 +00:00
2022-08-18 17:51:18 +00:00
class Tokens ( Enum ) :
ETH : str = " ETH "
2023-01-05 12:50:55 +00:00
2022-07-18 08:37:37 +00:00
class SigningPhrasePopUp ( Enum ) :
2022-07-29 22:51:34 +00:00
OK_GOT_IT_BUTTON : str = " signPhrase_Ok_Button "
2022-07-18 08:37:37 +00:00
class MainWalletScreen ( Enum ) :
2023-01-05 12:50:55 +00:00
ADD_ACCOUNT_BUTTON : str = " mainWallet_Add_Account_Button "
2022-07-18 08:37:37 +00:00
ACCOUNT_NAME : str = " mainWallet_Account_Name "
2022-08-18 17:51:18 +00:00
ACCOUNT_ADDRESS_PANEL : str = " mainWallet_Address_Panel "
2022-07-21 12:15:02 +00:00
SEND_BUTTON_FOOTER : str = " mainWallet_Footer_Send_Button "
2022-08-03 10:08:46 +00:00
SAVED_ADDRESSES_BUTTON : str = " mainWallet_Saved_Addresses_Button "
2022-08-08 10:07:29 +00:00
NETWORK_SELECTOR_BUTTON : str = " mainWallet_Network_Selector_Button "
2022-08-10 14:26:29 +00:00
RIGHT_SIDE_TABBAR : str = " mainWallet_Right_Side_Tab_Bar "
2022-10-21 07:17:48 +00:00
FIRST_ACCOUNT_ITEM : str = " firstWalletAccount_Item "
2022-10-20 12:58:56 +00:00
EPHEMERAL_NOTIFICATION_LIST : str = " mainWallet_Ephemeral_Notification_List "
TOTAL_CURRENCY_BALANCE : str = " mainWallet_totalCurrencyBalance "
2022-08-08 10:07:29 +00:00
class AssetView ( Enum ) :
LIST : str = " mainWallet_Assets_View_List "
2023-01-05 12:50:55 +00:00
2022-08-08 10:07:29 +00:00
class NetworkSelectorPopup ( Enum ) :
LAYER_1_REPEATER : str = " mainWallet_Network_Popup_Chain_Repeater_1 "
2022-08-03 10:08:46 +00:00
class SavedAddressesScreen ( Enum ) :
ADD_BUTTON : str = " mainWallet_Saved_Addreses_Add_Buttton "
SAVED_ADDRESSES_LIST : str = " mainWallet_Saved_Addreses_List "
2022-08-04 09:06:15 +00:00
EDIT : str = " mainWallet_Saved_Addreses_More_Edit "
DELETE : str = " mainWallet_Saved_Addreses_More_Delete "
CONFIRM_DELETE : str = " mainWallet_Saved_Addreses_More_Confirm_Delete "
2022-08-24 08:23:43 +00:00
DELEGATE_MENU_BUTTON_OBJECT_NAME : str = " savedAddressView_Delegate_menuButton "
DELEGATE_FAVOURITE_BUTTON_OBJECT_NAME : str = " savedAddressView_Delegate_favouriteButton "
2022-08-03 10:08:46 +00:00
class AddSavedAddressPopup ( Enum ) :
NAME_INPUT : str = " mainWallet_Saved_Addreses_Popup_Name_Input "
ADDRESS_INPUT : str = " mainWallet_Saved_Addreses_Popup_Address_Input "
2023-03-06 12:30:58 +00:00
ADDRESS_INPUT_EDIT : str = " mainWallet_Saved_Addreses_Popup_Address_Input_Edit "
2022-08-03 10:08:46 +00:00
ADD_BUTTON : str = " mainWallet_Saved_Addreses_Popup_Address_Add_Button "
2022-07-18 08:37:37 +00:00
2022-07-21 12:15:02 +00:00
class SendPopup ( Enum ) :
SCROLL_BAR : str = " mainWallet_Send_Popup_Main "
HEADER_ACCOUNTS_LIST : str = " mainWallet_Send_Popup_Header_Accounts "
AMOUNT_INPUT : str = " mainWallet_Send_Popup_Amount_Input "
MY_ACCOUNTS_TAB : str = " mainWallet_Send_Popup_My_Accounts_Tab "
MY_ACCOUNTS_LIST : str = " mainWallet_Send_Popup_My_Accounts_List "
NETWORKS_LIST : str = " mainWallet_Send_Popup_Networks_List "
SEND_BUTTON : str = " mainWallet_Send_Popup_Send_Button "
2022-08-09 13:52:17 +00:00
ASSET_SELECTOR : str = " mainWallet_Send_Popup_Asset_Selector "
ASSET_LIST : str = " mainWallet_Send_Popup_Asset_List "
2022-08-18 17:51:18 +00:00
HIGH_GAS_BUTTON : str = " mainWallet_Send_Popup_GasSelector_HighGas_Button "
2023-01-05 12:50:55 +00:00
2022-07-18 08:37:37 +00:00
class AddAccountPopup ( Enum ) :
SCROLL_BAR : str = " mainWallet_Add_Account_Popup_Main "
PASSWORD_INPUT : str = " mainWallet_Add_Account_Popup_Password "
ACCOUNT_NAME_INPUT : str = " mainWallet_Add_Account_Popup_Account_Name "
ADVANCE_SECTION : str = " mainWallet_Add_Account_Popup_Advanced "
TYPE_SELECTOR : str = " mainWallet_Add_Account_Popup_Type_Selector "
TYPE_WATCH_ONLY : str = " mainWallet_Add_Account_Popup_Type_Watch_Only "
TYPE_SEED_PHRASE : str = " mainWallet_Add_Account_Popup_Type_Seed_Phrase "
TYPE_PRIVATE_KEY : str = " mainWallet_Add_Account_Popup_Type_Private_Key "
ADDRESS_INPUT : str = " mainWallet_Add_Account_Popup_Watch_Only_Address "
2023-02-24 12:59:14 +00:00
ADDRESS_INPUT_PLACEHOLDER : str = " mainWallet_Add_Account_Popup_Watch_Only_Address_Placeholder "
2022-07-18 08:37:37 +00:00
PRIVATE_KEY_INPUT : str = " mainWallet_Add_Account_Popup_Private_Key "
ADD_ACCOUNT_BUTTON : str = " mainWallet_Add_Account_Popup_Footer_Add_Account "
2022-08-03 17:31:59 +00:00
SEED_PHRASE_INPUT_TEMPLATE : str = " mainWindow_Add_Account_Popup_Seed_Phrase_ "
2023-02-09 17:41:21 +00:00
SEED_PHRASE_INPUT_LAST : str = " mainWindow_Add_Account_Popup_Seed_Phrase_12 "
2023-02-24 12:59:14 +00:00
FULLY_CUSTOM_PATH_CHECKBOX : str = " mainWallet_Add_Account_Popup_Advanced_Accept_Responsibility_Checkbox "
ADD_ACCOUNT_POPUP_ROOT : str = " mainWallet_Add_Account_Popup_Root "
2023-01-05 12:50:55 +00:00
2022-08-10 14:26:29 +00:00
class CollectiblesView ( Enum ) :
2023-01-05 12:50:55 +00:00
COLLECTIONS_REPEATER : str = " mainWallet_Collections_Repeater "
COLLECTIBLES_REPEATER : str = " mainWallet_Collectibles_Repeater "
2022-08-10 14:26:29 +00:00
class WalletTabBar ( Enum ) :
ASSET_TAB = 0
COLLECTION_TAB = 1
2023-01-05 12:50:55 +00:00
ACTIVITY_TAB = 2
2022-09-20 12:27:52 +00:00
class TransactionsView ( Enum ) :
2023-01-05 12:50:55 +00:00
TRANSACTIONS_LISTVIEW : str = " mainWallet_Transactions_List "
2022-09-20 12:27:52 +00:00
TRANSACTIONS_DETAIL_VIEW_HEADER : str = " mainWallet_Transactions_Detail_View_Header "
2022-07-18 08:37:37 +00:00
class StatusWalletScreen :
2023-01-05 12:50:55 +00:00
2022-10-21 07:17:48 +00:00
#####################################
### Screen actions region:
#####################################
2023-01-05 12:50:55 +00:00
2022-07-20 08:18:27 +00:00
def accept_signing_phrase ( self ) :
2022-07-18 08:37:37 +00:00
click_obj_by_name ( SigningPhrasePopUp . OK_GOT_IT_BUTTON . value )
2023-01-05 12:50:55 +00:00
2023-02-24 12:59:14 +00:00
def add_watch_only_account ( self , account_name : str , address : str , password : str ) :
2022-07-18 08:37:37 +00:00
click_obj_by_name ( MainWalletScreen . ADD_ACCOUNT_BUTTON . value )
2023-01-05 12:50:55 +00:00
2023-02-24 12:59:14 +00:00
type_text ( AddAccountPopup . ACCOUNT_NAME_INPUT . value , account_name )
2023-01-05 12:50:55 +00:00
2023-02-24 12:59:14 +00:00
click_obj_by_name ( AddAccountPopup . ADVANCE_SECTION . value , 2000 )
2022-09-20 12:27:52 +00:00
2023-02-24 12:59:14 +00:00
# Found that all the involved controls are switching availability states very quickly based on the model data
# which makes it almost impossible to do a reliable check for different states, hence the retry for 10 seconds
# workaround.
# TODO remove workaround to retry after add account modal refactoring
max_expected_step_duration_ms = 10000
def scroll_and_type_fn ( ) :
try :
click_obj_by_name ( AddAccountPopup . TYPE_SELECTOR . value )
click_obj_by_name ( AddAccountPopup . TYPE_WATCH_ONLY . value )
2023-01-05 12:50:55 +00:00
2023-02-24 12:59:14 +00:00
scroll_item_until_item_is_visible ( AddAccountPopup . SCROLL_BAR . value , AddAccountPopup . ADDRESS_INPUT_PLACEHOLDER . value , 2000 )
wait_for_object_and_type ( AddAccountPopup . ADDRESS_INPUT_PLACEHOLDER . value , address )
except Exception as e :
log ( f " Expected fail, ignore it for { max_expected_step_duration_ms / 1000 } seconds; exception { str ( e ) } " )
do_until_validation_with_timeout (
scroll_and_type_fn ,
lambda : is_loaded_visible_and_enabled ( AddAccountPopup . ADDRESS_INPUT . value , 500 ) [ 0 ] ,
timeout_ms = max_expected_step_duration_ms ,
message = " Fill watch only account address " )
click_obj_by_name ( AddAccountPopup . ADD_ACCOUNT_BUTTON . value , 2000 )
2022-07-18 08:37:37 +00:00
2022-07-20 08:18:27 +00:00
def import_private_key ( self , account_name : str , password : str , private_key : str ) :
2022-07-18 08:37:37 +00:00
click_obj_by_name ( MainWalletScreen . ADD_ACCOUNT_BUTTON . value )
2022-10-28 16:59:53 +00:00
2023-02-24 12:59:14 +00:00
type_text ( AddAccountPopup . ACCOUNT_NAME_INPUT . value , account_name )
2023-01-05 12:50:55 +00:00
2022-07-18 08:37:37 +00:00
click_obj_by_name ( AddAccountPopup . ADVANCE_SECTION . value )
click_obj_by_name ( AddAccountPopup . TYPE_SELECTOR . value )
click_obj_by_name ( AddAccountPopup . TYPE_PRIVATE_KEY . value )
2023-01-05 12:50:55 +00:00
2023-02-09 17:41:21 +00:00
scroll_item_until_item_is_visible ( AddAccountPopup . SCROLL_BAR . value , AddAccountPopup . PRIVATE_KEY_INPUT . value )
2023-02-24 12:59:14 +00:00
type_text ( AddAccountPopup . PRIVATE_KEY_INPUT . value , private_key )
2023-01-05 12:50:55 +00:00
2022-07-18 08:37:37 +00:00
click_obj_by_name ( AddAccountPopup . ADD_ACCOUNT_BUTTON . value )
2023-01-05 12:50:55 +00:00
2023-02-24 12:59:14 +00:00
authenticatePopupEnterPassword ( password )
2023-01-05 12:50:55 +00:00
2022-07-20 08:18:27 +00:00
def import_seed_phrase ( self , account_name : str , password : str , mnemonic : str ) :
2022-07-18 08:37:37 +00:00
click_obj_by_name ( MainWalletScreen . ADD_ACCOUNT_BUTTON . value )
2023-01-05 12:50:55 +00:00
2023-02-24 12:59:14 +00:00
type_text ( AddAccountPopup . ACCOUNT_NAME_INPUT . value , account_name )
2023-01-05 12:50:55 +00:00
2022-07-18 08:37:37 +00:00
click_obj_by_name ( AddAccountPopup . ADVANCE_SECTION . value )
click_obj_by_name ( AddAccountPopup . TYPE_SELECTOR . value )
click_obj_by_name ( AddAccountPopup . TYPE_SEED_PHRASE . value )
2023-02-24 12:59:14 +00:00
is_loaded_visible_and_enabled ( AddAccountPopup . SCROLL_BAR . value , 1000 )
scroll_item_until_item_is_visible ( AddAccountPopup . SCROLL_BAR . value , AddAccountPopup . SEED_PHRASE_INPUT_LAST . value )
2022-07-18 08:37:37 +00:00
2023-02-09 17:41:21 +00:00
words = mnemonic . split ( )
2022-08-03 17:31:59 +00:00
input_seed_phrase ( AddAccountPopup . SEED_PHRASE_INPUT_TEMPLATE . value , words )
2023-01-05 12:50:55 +00:00
2022-07-18 08:37:37 +00:00
click_obj_by_name ( AddAccountPopup . ADD_ACCOUNT_BUTTON . value )
2023-01-05 12:50:55 +00:00
2023-02-24 12:59:14 +00:00
authenticatePopupEnterPassword ( password )
2023-01-05 12:50:55 +00:00
2022-07-20 08:18:27 +00:00
def generate_new_account ( self , account_name : str , password : str ) :
2022-07-18 08:37:37 +00:00
click_obj_by_name ( MainWalletScreen . ADD_ACCOUNT_BUTTON . value )
2023-01-05 12:50:55 +00:00
2023-02-24 12:59:14 +00:00
type_text ( AddAccountPopup . ACCOUNT_NAME_INPUT . value , account_name )
2023-01-05 12:50:55 +00:00
2022-10-28 16:59:53 +00:00
click_obj_by_name ( AddAccountPopup . ADD_ACCOUNT_BUTTON . value )
2023-01-05 12:50:55 +00:00
2023-02-24 12:59:14 +00:00
authenticatePopupEnterPassword ( password )
2023-01-05 12:50:55 +00:00
2022-07-21 12:15:02 +00:00
def send_transaction ( self , account_name , amount , token , chain_name , password ) :
2023-02-24 12:59:14 +00:00
is_loaded_visible_and_enabled ( AssetView . LIST . value , 2000 )
2022-10-20 12:58:56 +00:00
list = get_obj ( AssetView . LIST . value )
2023-02-24 12:59:14 +00:00
# LoadingTokenDelegate will be visible until the balance is loaded verify_account_balance_is_positive checks for TokenDelegate
do_until_validation_with_timeout ( lambda : time . sleep ( 0.1 ) , lambda : self . verify_account_balance_is_positive ( list , " ETH " ) [ 0 ] , " Wait for tokens to load " , 10000 )
2022-10-20 12:58:56 +00:00
2022-07-21 12:15:02 +00:00
click_obj_by_name ( MainWalletScreen . SEND_BUTTON_FOOTER . value )
2023-01-05 12:50:55 +00:00
2022-07-21 12:15:02 +00:00
self . _click_repeater ( SendPopup . HEADER_ACCOUNTS_LIST . value , account_name )
2023-02-24 12:59:14 +00:00
is_loaded_visible_and_enabled ( SendPopup . AMOUNT_INPUT . value , 1000 )
type_text ( SendPopup . AMOUNT_INPUT . value , amount )
2022-08-09 13:52:17 +00:00
2022-11-23 17:58:22 +00:00
click_obj_by_name ( SendPopup . ASSET_SELECTOR . value )
asset_list = get_obj ( SendPopup . ASSET_LIST . value )
for index in range ( asset_list . count ) :
tokenObj = asset_list . itemAtIndex ( index )
2023-02-24 12:59:14 +00:00
if ( not is_null ( tokenObj ) and tokenObj . objectName == " AssetSelector_ItemDelegate_ " + token ) :
2022-11-23 17:58:22 +00:00
click_obj ( asset_list . itemAtIndex ( index ) )
break
2023-01-05 12:50:55 +00:00
2022-07-21 12:15:02 +00:00
click_obj_by_name ( SendPopup . MY_ACCOUNTS_TAB . value )
2023-01-05 12:50:55 +00:00
2022-07-21 12:15:02 +00:00
accounts = get_obj ( SendPopup . MY_ACCOUNTS_LIST . value )
for index in range ( accounts . count ) :
if ( accounts . itemAtIndex ( index ) . objectName == account_name ) :
2022-10-20 12:58:56 +00:00
print ( " WE FOUND THE ACCOUNT " )
2022-07-21 12:15:02 +00:00
click_obj ( accounts . itemAtIndex ( index ) )
break
2022-10-20 12:58:56 +00:00
2022-08-18 17:51:18 +00:00
scroll_obj_by_name ( SendPopup . SCROLL_BAR . value )
2023-01-05 12:50:55 +00:00
2022-07-21 12:15:02 +00:00
click_obj_by_name ( SendPopup . SEND_BUTTON . value )
2022-10-20 12:58:56 +00:00
2023-02-24 12:59:14 +00:00
authenticatePopupEnterPassword ( password )
2022-10-20 12:58:56 +00:00
2022-07-21 12:15:02 +00:00
def _click_repeater ( self , repeater_object_name : str , object_name : str ) :
repeater = get_obj ( repeater_object_name )
for index in range ( repeater . count ) :
if ( repeater . itemAt ( index ) . objectName == object_name ) :
click_obj ( repeater . itemAt ( index ) )
break
2023-01-05 12:50:55 +00:00
2022-08-03 10:08:46 +00:00
def add_saved_address ( self , name : str , address : str ) :
click_obj_by_name ( MainWalletScreen . SAVED_ADDRESSES_BUTTON . value )
click_obj_by_name ( SavedAddressesScreen . ADD_BUTTON . value )
2023-02-24 12:59:14 +00:00
type_text ( AddSavedAddressPopup . NAME_INPUT . value , name )
2023-03-06 12:30:58 +00:00
type_text ( AddSavedAddressPopup . ADDRESS_INPUT_EDIT . value , address )
addressInput = get_obj ( AddSavedAddressPopup . ADDRESS_INPUT . value )
verify_equal ( addressInput . plainText , address )
is_loaded_visible_and_enabled ( AddSavedAddressPopup . ADD_BUTTON . value )
2022-08-03 10:08:46 +00:00
click_obj_by_name ( AddSavedAddressPopup . ADD_BUTTON . value )
2022-08-24 08:23:43 +00:00
def _get_saved_address_delegate_item ( self , name : str ) :
list = wait_and_get_obj ( SavedAddressesScreen . SAVED_ADDRESSES_LIST . value )
2022-08-04 09:06:15 +00:00
found = - 1
for index in range ( list . count ) :
2022-08-24 08:23:43 +00:00
if list . itemAtIndex ( index ) . objectName == f " savedAddressView_Delegate_ { name } " :
2022-08-04 09:06:15 +00:00
found = index
2022-08-24 08:23:43 +00:00
2022-08-04 09:06:15 +00:00
assert found != - 1 , " saved address not found "
2022-08-24 08:23:43 +00:00
return list . itemAtIndex ( found )
def _find_saved_address_and_open_menu ( self , name : str ) :
item = self . _get_saved_address_delegate_item ( name )
2023-03-06 12:30:58 +00:00
menuButton = get_child_item_with_object_name ( item , f " { SavedAddressesScreen . DELEGATE_MENU_BUTTON_OBJECT_NAME . value } _ { name } " )
is_object_loaded_visible_and_enabled ( menuButton )
click_obj ( menuButton )
2022-08-24 08:23:43 +00:00
def edit_saved_address ( self , name : str , new_name : str ) :
self . _find_saved_address_and_open_menu ( name )
2022-08-04 09:06:15 +00:00
click_obj_by_name ( SavedAddressesScreen . EDIT . value )
2023-02-24 12:59:14 +00:00
type_text ( AddSavedAddressPopup . NAME_INPUT . value , new_name )
2022-08-04 09:06:15 +00:00
click_obj_by_name ( AddSavedAddressPopup . ADD_BUTTON . value )
2022-08-24 08:23:43 +00:00
2022-08-04 09:06:15 +00:00
def delete_saved_address ( self , name : str ) :
2022-08-24 08:23:43 +00:00
self . _find_saved_address_and_open_menu ( name )
2022-08-04 09:06:15 +00:00
click_obj_by_name ( SavedAddressesScreen . DELETE . value )
click_obj_by_name ( SavedAddressesScreen . CONFIRM_DELETE . value )
2022-08-24 08:23:43 +00:00
def toggle_favourite_for_saved_address ( self , name : str ) :
# Find the saved address and click favourite to toggle
item = self . _get_saved_address_delegate_item ( name )
2023-03-06 12:30:58 +00:00
favouriteButton = item . statusListItemIcon
is_object_loaded_visible_and_enabled ( favouriteButton )
2022-08-24 08:23:43 +00:00
click_obj ( favouriteButton )
def check_favourite_status_for_saved_address ( self , name : str , favourite : bool ) :
# Find the saved address
item = self . _get_saved_address_delegate_item ( name )
2023-03-06 12:30:58 +00:00
favouriteButton = item . statusListItemIcon
wait_for_prop_value ( favouriteButton , " asset.name " , ( " star-icon " if favourite else " favourite " ) )
2022-08-24 08:23:43 +00:00
2022-08-08 10:07:29 +00:00
def toggle_network ( self , network_name : str ) :
2023-02-24 12:59:14 +00:00
is_loaded_visible_and_enabled ( MainWalletScreen . NETWORK_SELECTOR_BUTTON . value , 2000 )
2022-08-08 10:07:29 +00:00
click_obj_by_name ( MainWalletScreen . NETWORK_SELECTOR_BUTTON . value )
2023-02-24 12:59:14 +00:00
is_loaded_visible_and_enabled ( NetworkSelectorPopup . LAYER_1_REPEATER . value , 2000 )
2022-08-18 17:51:18 +00:00
list = wait_and_get_obj ( NetworkSelectorPopup . LAYER_1_REPEATER . value )
2022-08-08 10:07:29 +00:00
for index in range ( list . count ) :
2022-08-18 17:51:18 +00:00
item = list . itemAt ( index )
if item . objectName == network_name :
click_obj ( item )
2022-08-08 10:07:29 +00:00
click_obj_by_name ( MainWalletScreen . ACCOUNT_NAME . value )
return
2023-01-05 12:50:55 +00:00
2022-08-08 10:07:29 +00:00
assert False , " network name not found "
2023-01-05 12:50:55 +00:00
2022-10-21 07:17:48 +00:00
def click_first_account ( self ) :
click_obj_by_name ( MainWalletScreen . FIRST_ACCOUNT_ITEM . value )
2022-08-08 10:07:29 +00:00
2023-01-05 12:50:55 +00:00
2022-10-21 07:17:48 +00:00
#####################################
### Verifications region:
#####################################
2023-01-05 12:50:55 +00:00
2022-10-21 07:17:48 +00:00
def verify_account_name_is_present ( self , account_name : str ) :
2023-02-24 12:59:14 +00:00
# Wait 2 second for UI text to update
test . verify ( wait_for_text_matching ( MainWalletScreen . ACCOUNT_NAME . value , account_name , 2000 ) , " Account name was updated and matches expected " )
2023-01-05 12:50:55 +00:00
2023-02-24 12:59:14 +00:00
def verify_account_balance_is_positive ( self , list , symbol : str ) - > Tuple ( bool , ) :
if list is None :
return ( False , )
2022-10-27 08:45:59 +00:00
2023-02-24 12:59:14 +00:00
for index in range ( list . count ) :
tokenListItem = list . itemAtIndex ( index )
2023-03-22 22:08:36 +00:00
if tokenListItem != None and tokenListItem . item != None and tokenListItem . item . objectName == " AssetView_LoadingTokenDelegate_ " + str ( index ) :
2023-03-15 09:17:25 +00:00
return ( False , )
2023-03-22 22:08:36 +00:00
if tokenListItem != None and tokenListItem . item != None and tokenListItem . item . objectName == " AssetView_TokenListItem_ " + symbol and tokenListItem . item . balance != " 0 " :
2023-02-24 12:59:14 +00:00
return ( True , tokenListItem )
return ( False , )
2023-01-05 12:50:55 +00:00
2023-02-24 12:59:14 +00:00
def verify_positive_balance ( self , symbol : str ) :
is_loaded_visible_and_enabled ( AssetView . LIST . value , 5000 )
list = get_obj ( AssetView . LIST . value )
do_until_validation_with_timeout ( lambda : time . sleep ( 0.1 ) , lambda : self . verify_account_balance_is_positive ( list , symbol ) [ 0 ] , " Symbol " + symbol + " not found in the asset list " , 5000 )
2023-01-05 12:50:55 +00:00
2022-08-03 10:08:46 +00:00
def verify_saved_address_exists ( self , name : str ) :
2022-08-24 08:23:43 +00:00
list = wait_and_get_obj ( SavedAddressesScreen . SAVED_ADDRESSES_LIST . value )
2022-08-03 10:08:46 +00:00
for index in range ( list . count ) :
2022-08-24 08:23:43 +00:00
if list . itemAtIndex ( index ) . objectName == f " savedAddressView_Delegate_ { name } " :
return
verify_failure ( f ' FAIL: saved address { name } not found " ' )
2022-08-04 09:06:15 +00:00
def verify_saved_address_doesnt_exist ( self , name : str ) :
2022-08-24 08:23:43 +00:00
# The list should be hidden when there are no saved addresses
try :
list = wait_and_get_obj ( SavedAddressesScreen . SAVED_ADDRESSES_LIST . value , 250 )
except LookupError :
return
list = wait_and_get_obj ( SavedAddressesScreen . SAVED_ADDRESSES_LIST . value )
2022-08-04 09:06:15 +00:00
for index in range ( list . count ) :
2022-08-24 08:23:43 +00:00
if list . itemAtIndex ( index ) . objectName == f " savedAddressView_Delegate_ { name } " :
verify_failure ( f ' FAIL: saved address { name } exists ' )
2022-08-03 10:08:46 +00:00
2022-07-21 12:15:02 +00:00
def verify_transaction ( self ) :
2022-10-20 12:58:56 +00:00
pass
# TODO: figure out why it doesn t work in CI
# ephemeral_notification_list = get_obj(MainWalletScreen.EPHEMERAL_NOTIFICATION_LIST.value)
# print(ephemeral_notification_list.itemAtIndex(0).objectName)
# verify(str(ephemeral_notification_list.itemAtIndex(0).primaryText ) == "Transaction pending...", "Tx was not sent!")
2023-01-05 12:50:55 +00:00
2022-08-10 14:26:29 +00:00
def verify_collectibles_exist ( self , account_name : str ) :
tabbar = get_obj ( MainWalletScreen . RIGHT_SIDE_TABBAR . value )
click_obj ( tabbar . itemAt ( WalletTabBar . COLLECTION_TAB . value ) )
collectionsRepeater = get_obj ( CollectiblesView . COLLECTIONS_REPEATER . value )
if ( collectionsRepeater . count > 0 ) :
collectionsRepeater . itemAt ( 0 ) . expanded = True
collectiblesRepeater = get_obj ( CollectiblesView . COLLECTIBLES_REPEATER . value )
verify ( collectiblesRepeater . count > 0 , " Collectibles not retrieved for the account " )
2023-01-05 12:50:55 +00:00
2022-09-20 12:27:52 +00:00
def verify_transactions_exist ( self ) :
tabbar = get_obj ( MainWalletScreen . RIGHT_SIDE_TABBAR . value )
click_obj ( tabbar . itemAt ( WalletTabBar . ACTIVITY_TAB . value ) )
transaction_list_view = get_obj ( TransactionsView . TRANSACTIONS_LISTVIEW . value )
2023-01-05 12:50:55 +00:00
2023-02-24 12:59:14 +00:00
wait_for ( " transaction_list_view.count > 0 " , 60 * 1000 )
2022-09-20 12:27:52 +00:00
verify ( transaction_list_view . count > 1 , " Transactions not retrieved for the account " )
2023-01-05 12:50:55 +00:00
2022-09-20 12:27:52 +00:00
transaction_item = transaction_list_view . itemAtIndex ( 1 )
transaction_detail_header = get_obj ( TransactionsView . TRANSACTIONS_DETAIL_VIEW_HEADER . value )
2023-01-05 12:50:55 +00:00
2022-09-20 12:27:52 +00:00
click_obj ( transaction_item )
2023-01-05 12:50:55 +00:00
2022-09-20 12:27:52 +00:00
verify_equal ( transaction_item . item . cryptoValue , transaction_detail_header . cryptoValue )
verify_equal ( transaction_item . item . transferStatus , transaction_detail_header . transferStatus )
verify_equal ( transaction_item . item . shortTimeStamp , transaction_detail_header . shortTimeStamp )
verify_equal ( transaction_item . item . fiatValue , transaction_detail_header . fiatValue )
verify_equal ( transaction_item . item . symbol , transaction_detail_header . symbol )