Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
drethereum committed Nov 8, 2024
1 parent f2b7884 commit 3b831c4
Showing 1 changed file with 40 additions and 33 deletions.
73 changes: 40 additions & 33 deletions models/decoder_package/abis/bronze/bronze_api__contract_abis.sql
Original file line number Diff line number Diff line change
Expand Up @@ -43,35 +43,38 @@ WITH base AS (
FROM
{{ ref('silver__relevant_contracts') }}
WHERE
1=1
1 = 1
AND total_interaction_count > {{ block_explorer_abi_interaction_limit }}

{% if is_incremental() %}
AND contract_address NOT IN (
SELECT
contract_address
FROM
{{ this }}
WHERE
1=1 and
abi_data:error is null
1 = 1
AND abi_data :error IS NULL
)
{% endif %}
ORDER BY
total_interaction_count DESC
LIMIT
{{ block_explorer_abi_limit }}
), all_contracts AS (
{{ block_explorer_abi_limit }}
),
all_contracts AS (
SELECT
contract_address
FROM
base
{% if is_incremental() %}
UNION
SELECT
contract_address
FROM
{{ ref('_retry_abis') }}
{% endif %}

{% if is_incremental() %}
UNION
SELECT
contract_address
FROM
{{ ref('_retry_abis') }}
{% endif %}
),
row_nos AS (
SELECT
Expand All @@ -83,28 +86,32 @@ row_nos AS (
FROM
all_contracts
),
batched AS ({% for item in range(block_explorer_abi_limit * 2) %}
SELECT
rn.contract_address,
live.udf_api('GET',
CONCAT(
'{{ block_explorer_abi_url }}',
rn.contract_address,
'&apikey={key}'
),
{'User-Agent': 'FlipsideStreamline'},
{},
'{{ block_explorer_vault_path }}'
) AS abi_data
FROM
row_nos rn
WHERE
row_no = {{ item }}
batched AS (
{% for item in range(
block_explorer_abi_limit * 2
) %}
SELECT
rn.contract_address,
live.udf_api('GET',
CONCAT(
'{{ block_explorer_abi_url }}',
rn.contract_address,
'&apikey={key}'
),
{'User-Agent': 'FlipsideStreamline'},
{},
'{{ block_explorer_vault_path }}'
) AS abi_data
FROM
row_nos rn
WHERE
row_no = {{ item }}

{% if not loop.last %}
UNION ALL
{% endif %}
{% endfor %})
{% if not loop.last %}
UNION ALL
{% endif %}
{% endfor %}
)
SELECT
contract_address,
abi_data,
Expand Down

0 comments on commit 3b831c4

Please sign in to comment.