mirror of
https://github.com/FlipsideCrypto/livequery-base.git
synced 2026-02-06 11:16:44 +00:00
24 lines
865 B
SQL
24 lines
865 B
SQL
{% macro sql_live_rpc_call(method, params, blockchain, network) %}
|
|
{#
|
|
Helper macro to call a JSON RPC method on a live node.
|
|
|
|
Parameters:
|
|
method (string): The JSON RPC method to call.
|
|
params (string): The JSON RPC parameters to pass to the method.
|
|
blockchain (string): The blockchain to call the method on.
|
|
network (string): The network to call the method on.
|
|
Returns:
|
|
string: The SQL to call the method.
|
|
#}
|
|
WITH result as (
|
|
SELECT
|
|
live.udf_api(
|
|
'{endpoint}'
|
|
,utils.udf_json_rpc_call('{{ method }}', {{ params }})
|
|
,concat_ws('/', 'integration', _utils.udf_provider(), '{{ blockchain }}', {{ network }})
|
|
)::VARIANT:data AS data
|
|
)
|
|
SELECT
|
|
COALESCE(data:result, {'error':data:error})
|
|
FROM result
|
|
{%- endmacro -%} |