def setup_contract(self):
        file_dir = os.path.dirname(os.path.realpath(__file__))
        self.contract = get_contract_instance(source=os.path.join(file_dir, "contracts/fixed_supply_token.sol"),
                                                   contract_name="FixedSupplyToken")
        self.log.info("Initializing contract")

        transaction = self.call_contract_function(self.contract, "constructor", [], self.default_account_key, storage_limit=20000)
        self.contract_address = self.wait_for_tx([transaction], True)[0]['contractCreated']
        self.accounts = [a[0] for a in self.new_address_and_transfer(2)]
예제 #2
0
def retire_tx_data():
    register_contract_dict = json.loads(
        open(
            os.path.join(file_dir,
                         "../../internal_contract/metadata/PoSRegister.json"),
            "r").read())
    register_contract = get_contract_instance(
        contract_dict=register_contract_dict)
    return get_contract_function_data(register_contract,
                                      "retire",
                                      args=[2_000])
예제 #3
0
def unstake_tx_data(unstaking_value: int):
    staking_contract_dict = json.loads(
        open(
            os.path.join(file_dir,
                         "../../internal_contract/metadata/Staking.json"),
            "r").read())
    staking_contract = get_contract_instance(
        contract_dict=staking_contract_dict)
    return get_contract_function_data(staking_contract,
                                      "withdraw",
                                      args=[unstaking_value * 10**18])
예제 #4
0
        REQUEST_BASE = {
            'gas': 3_000_000,
            'gasPrice': 1,
            'chainId': 10,
            "value": 0,
        }
        tx_conf = REQUEST_BASE
        tx_conf["nonce"] = 0
        tx_conf["to"] = Web3.toChecksumAddress(
            "0888000000000000000000000000000000000002")
        file_path = os.path.join(file_dir, "..", "..", "internal_contract",
                                 "metadata", "Staking.json")
        staking_contract_dict = json.loads(
            open(os.path.join(file_path), "r").read())
        staking_contract = get_contract_instance(
            contract_dict=staking_contract_dict)
        tx_data = decode_hex(
            staking_contract.functions.deposit(
                10**18).buildTransaction(tx_conf)["data"])
        tx = self.new_tx(data=tx_data,
                         gas=tx_conf["gas"],
                         receiver=tx_conf["to"],
                         value=0)
        self.send_tx(tx, True)
        # Stake 10**18 drip, and generating 5 blocks does not affect rewards
        info = self.get_supply_info()
        assert_equal(int(info["totalIssued"], 16),
                     10000005000000000000000000000000000)
        assert_equal(int(info["totalStaking"], 16), 10**18)
        assert_equal(int(info["totalCollateral"], 16), 0)