def send_transaction_with_logger(icon_service, signed_transaction, uri): tx_dict = make_dict_to_rpc_dict(signed_transaction.signed_transaction_dict, 'icx_transaction') Logger.info(f"Send request to {uri}. Request body: {tx_dict}", TBEARS_CLI_TAG) return icon_service.send_transaction(signed_transaction, True)
def run(self, args): if not hasattr(self, args.command): print(f"Wrong command {args.command}") return Logger.info(f"Run '{args.command}' command", TBEARS_CLI_TAG) # run command return getattr(self, args.command)(vars(args))
def run(self, args): if not hasattr(self, args.command): raise TBearsCommandException(f"Invalid command {args.command}") user_input = vars(args) conf = self.get_icon_conf(args.command, args=user_input) Logger.info(f"Run '{args.command}' command with config: {conf}", TBEARS_CLI_TAG) # run command return getattr(self, args.command)(conf)
def send(self, request) -> dict: """Send request to URI :param request: JSON-RPC request :return: response dictionary of request. """ Logger.info(f"Send request to {self.__uri}. Request body: {request}", TBEARS_CLI_TAG) # if query doesn't change any state of iconservice or loopchain, use 'send' method response = requests.post(url=self.__uri, json=request) try: response_json = response.json() except ValueError: if not response.ok: raise IconClientException( f"Got error response. Response status_code: [{response.status_code}]" ) else: return response_json
def call_with_logger(icon_service, call_obj, uri): call_dict = make_call_dict_to_rpc_dict(call_obj) Logger.info(f"Send request to {uri}. Request body: {call_dict}", TBEARS_CLI_TAG) return icon_service.call(call_obj, True)