def constructTx(self):
        """ Construct the actual transaction and store it in the class's dict
            store
        """
        if self.peerplays.proposer:
            ops = [operations.Op_wrapper(op=o) for o in list(self.ops)]
            proposer = Account(
                self.peerplays.proposer,
                peerplays_instance=self.peerplays
            )
            ops = operations.Proposal_create(**{
                "fee": {"amount": 0, "asset_id": "1.3.0"},
                "fee_paying_account": proposer["id"],
                "expiration_time": transactions.formatTimeFromNow(
                    self.peerplays.proposal_expiration),
                "proposed_ops": [o.json() for o in ops],
                "extensions": []
            })
            ops = [Operation(ops)]
        else:
            ops = [Operation(o) for o in list(self.ops)]

        ops = transactions.addRequiredFees(self.peerplays.rpc, ops)
        expiration = transactions.formatTimeFromNow(self.peerplays.expiration)
        ref_block_num, ref_block_prefix = transactions.getBlockParams(self.peerplays.rpc)
        tx = Signed_Transaction(
            ref_block_num=ref_block_num,
            ref_block_prefix=ref_block_prefix,
            expiration=expiration,
            operations=ops
        )
        super(TransactionBuilder, self).__init__(tx.json())
Exemplo n.º 2
0
    def constructTx(self):
        """ Construct the actual transaction and store it in the class's dict
            store
        """
        ops = list()
        for op in self.ops:
            if isinstance(op, ProposalBuilder):
                # This operation is a proposal an needs to be deal with
                # differently
                proposals = op.get_raw()
                if proposals:
                    ops.append(proposals)
            else:
                # otherwise, we simply wrap ops into Operations
                ops.extend([Operation(op)])

        # We now wrap everything into an actual transaction
        ops = transactions.addRequiredFees(self.blockchain.rpc,
                                           ops,
                                           asset_id=self.fee_asset_id)
        expiration = transactions.formatTimeFromNow(
            self.expiration or self.blockchain.expiration)
        ref_block_num, ref_block_prefix = transactions.getBlockParams(
            self.blockchain.rpc)
        self.tx = Signed_Transaction(ref_block_num=ref_block_num,
                                     ref_block_prefix=ref_block_prefix,
                                     expiration=expiration,
                                     operations=ops)
        super(TransactionBuilder, self).update(self.tx.json())
        self._unset_require_reconstruction()
Exemplo n.º 3
0
 def get_raw(self):
     """ Returns an instance of base "Operations" for further processing
     """
     if not self.ops:
         return
     ops = [operations.Op_wrapper(op=o) for o in list(self.ops)]
     proposer = Account(self.proposer, blockchain_instance=self.blockchain)
     data = {
         "fee": {
             "amount": 0,
             "asset_id": "1.3.0"
         },
         "fee_paying_account":
         proposer["id"],
         "expiration_time":
         transactions.formatTimeFromNow(self.proposal_expiration),
         "proposed_ops": [o.json() for o in ops],
         "extensions": []
     }
     if self.proposal_review:
         data.update({"review_period_seconds": self.proposal_review})
     ops = operations.Proposal_create(**data)
     return Operation(ops)
Exemplo n.º 4
0
from peerplaysbase.transactions import formatTimeFromNow
from pprint import pprint
from grapheneapi.grapheneapi import GrapheneAPI
rpc = GrapheneAPI("localhost", 8092)

op = rpc.get_prototype_operation("betting_market_rules_create_operation")

op[1]["name"] = [["en", "NHL Rules v1.0"]]
op[1]["description"] = [[
    "en",
    "The winner will be the team with the most points at the end of the game.  The team with fewer points will not be the winner."
]]

handle = rpc.begin_builder_transaction()
rpc.add_operation_to_builder_transaction(handle, op)
rpc.set_fees_on_builder_transaction(handle, "1.3.0")
pprint(
    rpc.propose_builder_transaction2(handle, "init0", formatTimeFromNow(60), 0,
                                     True))