def create_deploy_score_tx(self, score_root: str, score_name: str, from_: Union['EOAAccount', 'Address', None], to_: Union['EOAAccount', 'Address'], deploy_params: dict = None, timestamp_us: int = None, data: bytes = None, is_sys: bool = False, pre_validation_enabled: bool = True, step_limit: int = DEFAULT_DEPLOY_STEP_LIMIT) -> dict: addr_from: Optional['Address'] = self._convert_address_from_address_type(from_) addr_to: 'Address' = self._convert_address_from_address_type(to_) if deploy_params is None: deploy_params = {} score_path = get_score_path(score_root, score_name) if is_sys: deploy_data = {'contentType': 'application/tbears', 'content': score_path, 'params': deploy_params} else: if data is None: mz = InMemoryZip() mz.zip_in_memory(score_path) data = f'0x{mz.data.hex()}' else: data = f'0x{bytes.hex(data)}' deploy_data = {'contentType': 'application/zip', 'content': data, 'params': deploy_params} if timestamp_us is None: timestamp_us = create_timestamp() nonce = 0 request_params = { "version": self._version, "from": addr_from, "to": addr_to, "stepLimit": step_limit, "timestamp": timestamp_us, "nonce": nonce, "signature": self._signature, "dataType": "deploy", "data": deploy_data } origin_params = {'params': self.make_origin_params(request_params)} method = 'icx_sendTransaction' # Insert txHash into request params request_params['txHash'] = create_tx_hash() tx = { 'method': method, 'params': request_params } if pre_validation_enabled: self.icon_service_engine.validate_transaction(tx, origin_params) return tx
def _make_deploy_tx(self, score_root: str, score_name: str, addr_from: Union['Address', None], addr_to: 'Address', deploy_params: dict = None, timestamp_us: int = None, data: bytes = None, is_sys: bool = False): if deploy_params is None: deploy_params = {} score_path = get_score_path(score_root, score_name) if is_sys: deploy_data = { 'contentType': 'application/tbears', 'content': score_path, 'params': deploy_params } else: if data is None: mz = InMemoryZip() mz.zip_in_memory(score_path) data = f'0x{mz.data.hex()}' else: data = f'0x{bytes.hex(data)}' deploy_data = { 'contentType': 'application/zip', 'content': data, 'params': deploy_params } if timestamp_us is None: timestamp_us = create_timestamp() nonce = 0 request_params = { "version": self._version, "from": addr_from, "to": addr_to, "stepLimit": self._step_limit, "timestamp": timestamp_us, "nonce": nonce, "signature": self._signature, "dataType": "deploy", "data": deploy_data } method = 'icx_sendTransaction' # Insert txHash into request params request_params['txHash'] = create_tx_hash() tx = {'method': method, 'params': request_params} self.icon_service_engine.validate_transaction(tx) return tx