Esempio n. 1
0
    def betting_market_create(self,
                              payout_condition,
                              asset,
                              group_id="0.0.0",
                              account=None):
        """ Create an event group. This needs to be **proposed**.

            :param list payout_condition: Internationalized names, e.g. ``[['de', 'Foo'], ['en', 'bar']]``
            :param peerplays.asset.Asset asset: Asset to be used for this market
            :param str group_id: Group ID to create the competitors for (defaults to *relative* id ``0.0.0``)
            :param str account: (optional) the account to allow access
                to (defaults to ``default_account``)
        """
        assert self.proposer, "'betting_market_create' needs to be proposed"
        assert isinstance(payout_condition, list)
        if not account:
            if "default_account" in config:
                account = config["default_account"]
        if not account:
            raise ValueError("You need to provide an account")
        account = Account(account)
        asset = Asset(asset)
        op = operations.Betting_market_create(
            **{
                "fee": {
                    "amount": 0,
                    "asset_id": "1.3.0"
                },
                "group_id": group_id,
                "payout_condition": payout_condition,
                "asset_id": asset["id"],
                "prefix": self.rpc.chain_params["prefix"]
            })
        return self.finalizeOp(op, account["name"], "active")
Esempio n. 2
0
 def test_betting_market_create(self):
     op = operations.Betting_market_create(
         **{
             "fee": {
                 "amount": 0,
                 "asset_id": "1.3.0"
             },
             "group_id":
             "1.0.1241",
             "payout_condition": [["en", "Foo == Bar"],
                                  ["zh_Hans", "Foo == Bar"]],
             "asset_id":
             "1.3.10",
             "prefix":
             prefix,
         })
     ops = [Operation(op)]
     tx = Signed_Transaction(ref_block_num=ref_block_num,
                             ref_block_prefix=ref_block_prefix,
                             expiration=expiration,
                             operations=ops)
     tx = tx.sign([wif], chain=prefix)
     tx.verify([PrivateKey(wif).pubkey], prefix)
     txWire = hexlify(bytes(tx)).decode("ascii")
     compare = ("f68585abf4dce7c804570132000000000000000000d904"
                "0000000000010202656e0a466f6f203d3d20426172077a"
                "685f48616e730a466f6f203d3d204261720a0000011f33"
                "a517c8eec3f3d8eaf9653d96037bed0feb3ae6496a6fde"
                "201816de06187fb4768be89dc7092626b816440f41d7b0"
                "92be3cc1b54eb340868a0638ddd93b4448")
     self.assertEqual(compare[:-130], txWire[:-130])
 def test_betting_market_create(self):
     self.op = operations.Betting_market_create(
         **{
             "fee": {"amount": 0, "asset_id": "1.3.0"},
             "description": [["en", "Betting Market description"]],
             "group_id": "1.0.1241",
             "payout_condition": [["en", "Foo == Bar"], ["zh_Hans", "Foo == Bar"]],
             "prefix": prefix,
         }
     )
     self.cm = (
         "f68585abf4dce7c80457013d000000000000000000d904"
         "0000000000010102656e1a42657474696e67204d61726b"
         "6574206465736372697074696f6e0202656e0a466f6f20"
         "3d3d20426172077a685f48616e730a466f6f203d3d2042"
         "6172000001201b335c7806bc13383c85ab66fbe0908258"
         "be15fbdd9a24fccc9a66edf324086d385718c3cb537e55"
         "cf89f7539f3dbf6c0ed420e0bed67744f069ceb535d65a"
         "ee"
     )
     self.doit()