예제 #1
0
            print('Epoch t + 1 seat price', near_blockchain.get_seat_price(epoch='next'))
            print('Epoch t + 2 seat price', near_blockchain.get_seat_price(epoch='proposals'))
            print('Percentage current epoch ', epoch_percentage)

        # Make sure bot runs only once per epoch to avoid spamming       
        if epoch_percentage > 95 and bot_has_been_executed:
            bot_has_been_executed = False
        elif epoch_percentage <= 95:
            bot_has_been_executed = True

        # if in debug mode always run
        if not bot_has_been_executed:
            # create master account
            validators_node = Validators(CONTRACT_NAME, PATH_TO_JSON_PRIVATE_KEY_FILE_MASTER_ACCOUNT, ENDPOINT_URL)
            estimated_seat_price_nextnext_epoch = near_blockchain.get_seat_price(epoch='proposals')
            amount_master_account_unlocked = int(validators_node.get_master_account().state['amount'])

            # ping contract before proceding
            # near call my_validator ping '{}' --accountId user1
            
            validators_node.get_master_account().function_call(
                contract_id = CONTRACT_NAME, 
                method_name = 'ping', 
                args = None, 
                gas = DEFAULT_ATTACHED_GAS)
            

            # if master account has more that 1 NEAR deposit it to contract
            if amount_master_account_unlocked > YOCTO_CONSTANT and DEPOSIT_ALL_TOKENS_FROM_MASTERACCOUNT_INTO_CONTRACT:
                # always try to cover for account cost by subtracting 1 NEAR from the available amount
                to_deposit_in_near = amount_master_account_unlocked - YOCTO_CONSTANT