def get_network_proposal(self, id_: str) -> dict:
     query_request = {
         "version": self._version,
         "from": self._admin,
         "to": GOVERNANCE_SCORE_ADDRESS,
         "dataType": "call",
         "data": {
             "method": "getProposal",
             "params": {"id": bytes_to_hex(id_, "0x")}
         }
     }
     return self._query(query_request)
Esempio n. 2
0
    def create_vote_proposal_tx(self,
                                from_: 'Address',
                                id_: bytes,
                                vote: bool,
                                step_limit=DEFAULT_BIG_STEP_LIMIT) -> dict:
        method = "voteProposal"
        score_params = {"id": bytes_to_hex(id_, "0x"), "vote": hex(vote)}

        return self.create_score_call_tx(from_=from_,
                                         to_=GOVERNANCE_SCORE_ADDRESS,
                                         func_name=method,
                                         params=score_params,
                                         step_limit=step_limit)
Esempio n. 3
0
    def create_register_proposal_tx(self,
                                    from_: 'Address',
                                    title: str,
                                    description: str,
                                    type_: int,
                                    value: Union[str, int, 'Address'],
                                    step_limit: int = DEFAULT_BIG_STEP_LIMIT) -> dict:
        text = '{"address":"%s"}' % value
        json_data: bytes = text.encode("utf-8")

        method = "registerProposal"
        score_params = {
            "title": title,
            "description": description,
            "type": hex(type_),
            "value": bytes_to_hex(json_data)
        }

        return self.create_score_call_tx(from_=from_,
                                         to_=GOVERNANCE_SCORE_ADDRESS,
                                         func_name=method,
                                         params=score_params,
                                         step_limit=step_limit)
 def expected_encoder(data):
     if isinstance(data, bytes):
         return bytes_to_hex(data)
     elif isinstance(data, Address):
         return str(data)
     return data
def expected_json_data(precommit_data):
    def expected_encoder(data):
        if isinstance(data, bytes):
            return bytes_to_hex(data)
        elif isinstance(data, Address):
            return str(data)
        return data

    block = precommit_data.block

    json_dict = {
        "iconservice": __version__,
        "revision": precommit_data.revision,
        "block": {
            "height": block.height,
            "hash": bytes_to_hex(block.hash),
            "timestamp": block.timestamp,
            "prevHash": bytes_to_hex(block.prev_hash),
            "cumulativeFee": block.cumulative_fee
        },
        "isStateRootHash": bytes_to_hex(precommit_data.is_state_root_hash),
        "rcStateRootHash": None,
        "stateRootHash": bytes_to_hex(precommit_data.state_root_hash),
        "prevBlockGenerator": str(precommit_data.prev_block_generator),
        "blockBatch": [
            {"key": bytes_to_hex(k),
             "value": expected_encoder(v.value),
             "includeStateRootHash": v.include_state_root_hash,
             "txIndexes": v.tx_indexes}
            for k, v in precommit_data.block_batch.items()
        ],
        "rcBlockBatch": [
            {
                "key": bytes_to_hex(precommit_data.rc_block_batch[0].make_key()),
                "value": bytes_to_hex(precommit_data.rc_block_batch[0].make_value())
            },
            {
                "key": bytes_to_hex(precommit_data.rc_block_batch[1].make_key(0)),
                "value": bytes_to_hex(precommit_data.rc_block_batch[1].make_value())
            },
            {
                "key": bytes_to_hex(precommit_data.rc_block_batch[2].make_key(1)),
                "value": bytes_to_hex(precommit_data.rc_block_batch[2].make_value())
            }
        ]
    }
    return json_dict