예제 #1
0
파일: fomo3d.py 프로젝트: taschain/taschain
 def owner_withdraw(self):
     assert msg.sender == self.owner
     value = self.contract_balance / self.multiple
     if value == 0:
         return
     self.contract_balance -= value * self.multiple
     account.transfer(msg.sender, value)
예제 #2
0
파일: miner.py 프로젝트: taschain/taschain
    def withdraw(self, public_key):
        """
        提取质押金
        :param public_key:
        :return:
        """
        # 是否有质押金冻结记录
        require(public_key in self.deregister_list)

        lock_stake_block_count = 5
        return_stake_infos = []

        for info in self.deregister_list[public_key]:
            if (block.number() - info["deregisterBlockNumber"] >
                    lock_stake_block_count and info["owner"] == msg.sender):
                return_stake_infos.append(info)

        # 是否有已解冻质押金未提取,并且检查owner
        require(len(return_stake_infos) > 0)

        for info in return_stake_infos:
            self.deregister_list[public_key].remove(info)
        # 删除空KEY
        if len(self.deregister_list[public_key]) <= 0:
            self.deregister_list.pop(public_key)

        return_stake = 0
        for info in return_stake_infos:
            return_stake += info["stake"]

        # 转账
        assert return_stake > 0
        assert account.get_balance(this) > return_stake
        account.transfer(msg.sender, return_stake)
예제 #3
0
 def sale(self):
     if self.max_block_number < block.number():
         self.on_sale = False
     if not self.on_sale:
         raise Exception("not on sale")
     value = msg.value
     sender = msg.sender
     self.funding = self.funding + value
     if self.funding > self.funding_goal:
         value = self.funding_goal - self.funding
         self.on_sale = False
         account.transfer(sender, value)
         return
     balance = self.vote_dict.get(sender, 0)
     self.vote_dict[sender] = balance + value
     print(self.vote_dict)
예제 #4
0
 def test_transfer_money_correct_user_correct_pin(self):
     pin=1234
     sender = "user1"
     receiver = "user2"
     money_to_transfer = 300
     result = "The amount 300 Euro were transferred to user2. Your current balance is 1700 Euro."
     updated_account = transfer(pin, sender, receiver, money_to_transfer) 
     self.assertEqual(updated_account, result)
예제 #5
0
 def test_transfer_money_first_user_correct_pin(self):
     pin = 1234
     sender = 'Marie'
     receiver = 'Michelle'
     money_to_transfer = 300
     result = 'The amount 300 Euro were transferred to Michelle. Your current balance is 1700.'
     updated_account = transfer(pin, sender, receiver, money_to_transfer)
     self.assertEqual(updated_account, result)
예제 #6
0
    def settle(self, player_address, one_round_id, banker_point, player_point):
        send_key = player_address + str(one_round_id)
        one_game = self.games.get(send_key)
        print(self.games)
        print(one_game)
        if one_game is None:
            return
        if one_game.get("isSettled"):
            return
        one_game["bankerPoint"] = banker_point
        one_game["player_point"] = player_point
        self._determine_result(one_game)
        self._determine_loss(one_game)

        account.transfer(player_address, one_game["winLoss"])
        one_game["isSettled"] = True
        Event.emit("settle", 0, this, one_game["winLoss"])
예제 #7
0
 def test_transfer_money_second_correct_user_correct_pin(self):
     pin=2222
     sender = "user2"
     receiver = "user3"
     ##finish the tests and the function
     money_to_transfer = 300
     result = "The amount 300 Euro were transferred to user3. Your current balance is 2700 Euro."
     updated_account = transfer(pin, sender, receiver, money_to_transfer) 
     self.assertEqual(updated_account, result)
예제 #8
0
 def failed(self):
     if not self.on_sale and self.funding < self.funding_goal and self.funding >= account.get_balance(
             this):
         for k, v in self.vote_dict.items():
             account.transfer(k, v)
예제 #9
0
 def withdraw(self, addr):
     if self.owner != msg.sender:
         return
     if not self.on_sale and self.funding >= self.funding_goal:
         account.transfer(addr, self.funding)
예제 #10
0
파일: fomo3d.py 프로젝트: taschain/taschain
 def withdraw(self):
     value = self.balance[msg.sender] / self.multiple
     if value == 0:
         return
     self.balance[msg.sender] -= value * self.multiple
     account.transfer(msg.sender, value)
예제 #11
0
 def transfer(self, addr, amount):
     print("PY>>>>")
     return account.transfer(addr, amount)