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 debug_getAccount(context, **kwargs): channel = context.get('channel') method = "debug_getAccount" 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_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_call(context: Dict[str, str], **kwargs): channel = context.get('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 ise_getStatus(context, **kwargs): channel = context.get('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(context: Dict[str, str], **kwargs): channel = context.get('channel') url = context.get('url') path = urlparse(url).path 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) # DosGuard if StubCollection().conf.get(ConfigKey.DOS_GUARD_ENABLE, False): response = await icon_stub.async_task().dos_guard(kwargs) # Error Check response_to_json_query(response) channel_tx_creator_stub = StubCollection( ).channel_tx_creator_stubs[channel] response_code, tx_hash, relay_target = \ 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( path, kwargs, relay_target) 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, ResponseParamType.send_tx)
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)