async def icx_sendTransaction(**kwargs): channel = kwargs['context']['channel'] url = kwargs['context']['url'] path = urlparse(url).path del kwargs['context'] method = 'icx_sendTransaction' request = make_request(method, kwargs) score_stub = get_icon_stub_by_channel_name(channel) icon_stub = score_stub response = await icon_stub.async_task().validate_transaction(request) # Error Check response_to_json_query(response) channel_tx_creator_stub = StubCollection().channel_tx_creator_stubs[channel] response_code, tx_hash = await channel_tx_creator_stub.async_task().create_icx_tx(kwargs) if response_code == message_code.Response.fail_no_permission: return await IcxDispatcher.__relay_icx_transaction(url, path, kwargs) if response_code != message_code.Response.success: raise GenericJsonRpcServerError( code=JsonError.INVALID_REQUEST, message=message_code.responseCodeMap[response_code][1], http_status=message_code.get_response_http_status_code(response_code, status.HTTP_BAD_REQUEST) ) if tx_hash is None: raise GenericJsonRpcServerError( code=JsonError.INVALID_REQUEST, message='txHash is None', http_status=status.HTTP_BAD_REQUEST ) return convert_params(tx_hash, ParamType.send_tx_response)
async def icx_sendTransaction(**kwargs): url = kwargs['context']['url'] path = urlparse(url).path del kwargs['context'] request = make_request("icx_sendTransaction", kwargs, ParamType.send_tx) channel = StubCollection().conf[ConfigKey.CHANNEL] icon_stub = StubCollection().icon_score_stubs[channel] response = await icon_stub.async_task().validate_transaction(request) # Error Check response_to_json_query(response) channel_name = StubCollection().conf[ConfigKey.CHANNEL] channel_tx_creator_stub = StubCollection( ).channel_tx_creator_stubs[channel_name] response_code, tx_hash = await channel_tx_creator_stub.async_task( ).create_icx_tx(kwargs) if response_code == message_code.Response.fail_no_permission: return await Version2Dispatcher.__relay_icx_transaction( url, path, kwargs) response_data = {'response_code': response_code} if response_code != message_code.Response.success: response_data['message'] = message_code.responseCodeMap[ response_code][1] else: response_data['tx_hash'] = tx_hash return response_data
async def icx_call(**kwargs): channel = kwargs['context']['channel'] method = 'icx_call' request = make_request(method, kwargs) score_stub = get_icon_stub_by_channel_name(channel) response = await score_stub.async_task().query(request) return response_to_json_query(response)
async def icx_getTotalSupply(**kwargs): channel_name = StubCollection().conf[ConfigKey.CHANNEL] method = 'icx_getTotalSupply' request = make_request(method, kwargs, ParamType.get_total_supply) stub = StubCollection().icon_score_stubs[channel_name] response = await stub.async_task().query(request) return response_to_json_query(response, True)
async def ise_getStatus(**kwargs): channel = kwargs['context']['channel'] method = 'ise_getStatus' request = make_request(method, kwargs) score_stub = get_icon_stub_by_channel_name(channel) response = await score_stub.async_task().query(request) error = response.get('error') if error is None: IseDispatcher._hash_convert(None, response) return response_to_json_query(response)
async def icx_sendTransaction(**kwargs): channel = kwargs['context']['channel'] url = kwargs['context']['url'] path = urlparse(url).path del kwargs['context'] if RestProperty().node_type == NodeType.CitizenNode: dispatch_protocol = IcxDispatcher.get_dispatch_protocol_from_url( url) Logger.debug(f'Dispatch Protocol: {dispatch_protocol}') redirect_protocol = StubCollection().conf.get( ConfigKey.REDIRECT_PROTOCOL) Logger.debug(f'Redirect Protocol: {redirect_protocol}') if redirect_protocol: dispatch_protocol = redirect_protocol Logger.debug(f'Protocol: {dispatch_protocol}') return await redirect_request_to_rs(dispatch_protocol, kwargs, RestProperty().rs_target, path=path[1:]) method = 'icx_sendTransaction' request = make_request(method, kwargs) score_stub = get_icon_stub_by_channel_name(channel) icon_stub = score_stub response = await icon_stub.async_task().validate_transaction(request) # Error Check response_to_json_query(response) channel_tx_creator_stub = StubCollection( ).channel_tx_creator_stubs[channel] response_code, tx_hash = await channel_tx_creator_stub.async_task( ).create_icx_tx(kwargs) if response_code != message_code.Response.success: raise GenericJsonRpcServerError( code=JsonError.INVALID_REQUEST, message=message_code.responseCodeMap[response_code][1], http_status=status.HTTP_BAD_REQUEST) if tx_hash is None: raise GenericJsonRpcServerError( code=JsonError.INVALID_REQUEST, message='txHash is None', http_status=status.HTTP_BAD_REQUEST) return convert_params(tx_hash, ParamType.send_tx_response)
async def icx_sendTransaction(**kwargs): url = kwargs['context']['url'] path = urlparse(url).path del kwargs['context'] if RestProperty().node_type == NodeType.CitizenNode: dispatch_protocol = Version2Dispatcher.get_dispatch_protocol_from_url( url) Logger.debug(f'Dispatch Protocol: {dispatch_protocol}') redirect_protocol = StubCollection().conf.get( ConfigKey.REDIRECT_PROTOCOL) Logger.debug(f'Redirect Protocol: {redirect_protocol}') if redirect_protocol: dispatch_protocol = redirect_protocol Logger.debug(f'Protocol: {dispatch_protocol}') return await redirect_request_to_rs(dispatch_protocol, kwargs, RestProperty().rs_target, path[1:], ApiVersion.v2.name) request = make_request("icx_sendTransaction", kwargs, ParamType.send_tx) channel = StubCollection().conf[ConfigKey.CHANNEL] icon_stub = StubCollection().icon_score_stubs[channel] response = await icon_stub.async_task().validate_transaction(request) # Error Check response_to_json_query(response) channel_name = StubCollection().conf[ConfigKey.CHANNEL] channel_tx_creator_stub = StubCollection( ).channel_tx_creator_stubs[channel_name] response_code, tx_hash = await channel_tx_creator_stub.async_task( ).create_icx_tx(kwargs) response_data = {'response_code': response_code} if response_code != message_code.Response.success: response_data['message'] = message_code.responseCodeMap[ response_code][1] else: response_data['tx_hash'] = tx_hash return response_data
async def rep_getList(**kwargs): channel = kwargs['context']['channel'] score_stub = get_icon_stub_by_channel_name(channel) method = "ise_getPReps" request = make_request(method, kwargs) response = score_stub.sync_task().call(request) rep_list = [{ "id": rep_info["id"], "target": rep_info["target"] } for rep_info in response["result"]["preps"]] Logger.debug(f'rep list: {rep_list}') start_term_height = '0x0' end_term_height = '0x0' rep_hash = '' # term_height, rep_root_hash should be updated after IISS is implemented. response = { 'startTermHeight': start_term_height, 'endTermHeight': end_term_height, 'repHash': rep_hash, 'rep': rep_list } return response_to_json_query(response)