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_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 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_sendTransaction(**kwargs): url = kwargs['context']['url'] path = urlparse(url).path del kwargs['context'] request = make_request("icx_sendTransaction", kwargs, RequestParamType.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, relay_target = \ 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, channel, relay_target) 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_getBalance(**kwargs): channel_name = StubCollection().conf[ConfigKey.CHANNEL] method = 'icx_getBalance' request = make_request(method, kwargs, RequestParamType.get_balance) 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(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_getTotalSupply(context: Dict[str, str], **kwargs): channel_name = StubCollection().conf[ConfigKey.CHANNEL] method = 'icx_getTotalSupply' request = make_request(method, kwargs, RequestParamType.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 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 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, 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( url, path, kwargs, channel, 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)