mirror of
https://github.com/FlipsideCrypto/livequery-models.git
synced 2026-02-06 10:56:46 +00:00
refactor evm_live_view_bronze_blocks macro to include blockchain and network parameters; add sql_live_rpc_batch_call helper macro for batch JSON RPC calls
This commit is contained in:
parent
2bdf24eaf3
commit
1eecc8f048
@ -44,7 +44,7 @@
|
||||
{% endmacro %}
|
||||
|
||||
-- Get Raw EVM chain data
|
||||
{% macro evm_live_view_bronze_blocks(schema, table_name) %}
|
||||
{% macro evm_live_view_bronze_blocks(schema, blockchain, network, table_name) %}
|
||||
WITH blocks_agg AS (
|
||||
SELECT
|
||||
batch_id,
|
||||
@ -60,13 +60,7 @@ WITH blocks_agg AS (
|
||||
),
|
||||
|
||||
get_batch_result AS (
|
||||
SELECT
|
||||
live.udf_api(
|
||||
'{endpoint}',
|
||||
params
|
||||
):data AS result,
|
||||
COALESCE(value:result, {'error':value:error}) AS data
|
||||
FROM blocks_agg, LATERAL FLATTEN(input => result) v
|
||||
{{ sql_live_rpc_batch_call('blocks_agg', 'params', blockchain, network) | indent(4) }}
|
||||
)
|
||||
|
||||
SELECT
|
||||
@ -776,7 +770,7 @@ WITH spine AS (
|
||||
{{ evm_live_view_target_blocks(schema, blockchain, network) | indent(4) -}}
|
||||
),
|
||||
raw_block_txs AS (
|
||||
{{ evm_live_view_bronze_blocks( schema, 'spine') | indent(4) -}}
|
||||
{{ evm_live_view_bronze_blocks(schema, blockchain, network, 'spine') | indent(4) -}}
|
||||
),
|
||||
silver_blocks AS (
|
||||
{{ evm_live_view_silver_blocks('raw_block_txs') | indent(4) -}}
|
||||
@ -859,7 +853,7 @@ WITH spine AS (
|
||||
{{ evm_live_view_target_blocks(schema, blockchain, network) | indent(4) -}}
|
||||
),
|
||||
raw_block_txs AS (
|
||||
{{ evm_live_view_bronze_blocks(schema, 'spine') | indent(4) -}}
|
||||
{{ evm_live_view_bronze_blocks(schema, blockchain, network, 'spine') | indent(4) -}}
|
||||
),
|
||||
raw_receipts AS (
|
||||
{{ evm_live_view_bronze_receipts(schema, 'spine') | indent(4) -}}
|
||||
@ -945,7 +939,7 @@ raw_receipts AS (
|
||||
{{ evm_live_view_bronze_receipts(schema, 'spine') | indent(4) -}}
|
||||
),
|
||||
raw_block_txs AS (
|
||||
{{ evm_live_view_bronze_blocks(schema, 'spine') | indent(4) -}}
|
||||
{{ evm_live_view_bronze_blocks(schema, blockchain, network, 'spine') | indent(4) -}}
|
||||
),
|
||||
raw_transactions AS (
|
||||
{{ evm_live_view_bronze_transactions('raw_block_txs') | indent(4) -}}
|
||||
@ -1015,7 +1009,7 @@ raw_receipts AS (
|
||||
{{ evm_live_view_bronze_receipts(schema, 'spine') | indent(4) -}}
|
||||
),
|
||||
raw_block_txs AS (
|
||||
{{ evm_live_view_bronze_blocks(schema, 'spine') | indent(4) -}}
|
||||
{{ evm_live_view_bronze_blocks(schema, blockchain, network, 'spine') | indent(4) -}}
|
||||
),
|
||||
raw_transactions AS (
|
||||
{{ evm_live_view_bronze_transactions('raw_block_txs') | indent(4) -}}
|
||||
@ -1083,7 +1077,7 @@ raw_receipts AS (
|
||||
{{ evm_live_view_bronze_receipts(schema, 'spine') | indent(4) -}}
|
||||
),
|
||||
raw_block_txs AS (
|
||||
{{ evm_live_view_bronze_blocks(schema, 'spine') | indent(4) -}}
|
||||
{{ evm_live_view_bronze_blocks(schema, blockchain, network, 'spine') | indent(4) -}}
|
||||
),
|
||||
raw_transactions AS (
|
||||
{{ evm_live_view_bronze_transactions('raw_block_txs') | indent(4) -}}
|
||||
@ -1405,7 +1399,7 @@ raw_receipts AS (
|
||||
{{ evm_live_view_bronze_receipts(schema, 'spine') | indent(4) -}}
|
||||
),
|
||||
raw_block_txs AS (
|
||||
{{ evm_live_view_bronze_blocks(schema, 'spine') | indent(4) -}}
|
||||
{{ evm_live_view_bronze_blocks(schema, blockchain, network, 'spine') | indent(4) -}}
|
||||
),
|
||||
raw_transactions AS (
|
||||
{{ evm_live_view_bronze_transactions('raw_block_txs') | indent(4) -}}
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
Parameters:
|
||||
method (string): The JSON RPC method to call.
|
||||
params (string): The JSON RPC parameters to pass to the method.
|
||||
params (array): 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:
|
||||
@ -15,10 +15,34 @@
|
||||
live.udf_api(
|
||||
'{endpoint}'
|
||||
,utils.udf_json_rpc_call({{ method }}, {{ params }})
|
||||
,concat_ws('/', 'integration', _utils.udf_provider(), {{ blockchain }}, {{ network }})
|
||||
,concat_ws('/', 'integration', _utils.udf_provider(), '{{ blockchain }}', '{{ network }}')
|
||||
)::VARIANT:data AS data
|
||||
)
|
||||
SELECT
|
||||
COALESCE(data:result, {'error':data:error})
|
||||
FROM result
|
||||
{% endmacro -%}
|
||||
|
||||
{% macro sql_live_rpc_batch_call(from, calls, blockchain, network) %}
|
||||
{#
|
||||
Helper macro to batch call a JSON RPC method on a live node.
|
||||
|
||||
Parameters:
|
||||
calls (array): 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}'
|
||||
,{{ calls }}
|
||||
,concat_ws('/', 'integration', _utils.udf_provider(), {{ blockchain }}, {{ network }})
|
||||
)::VARIANT:data::ARRAY AS data
|
||||
)
|
||||
SELECT
|
||||
COALESCE(value:result, {'error':value:error})
|
||||
FROM result, LATERAL FLATTEN(input => result.data) v
|
||||
{% endmacro -%}
|
||||
Loading…
Reference in New Issue
Block a user