mirror of
https://github.com/FlipsideCrypto/near-models.git
synced 2026-02-06 11:26:52 +00:00
chenge_files, add docs
This commit is contained in:
parent
bcb9cd664d
commit
edf61e1bde
5
models/descriptions/nft_address.md
Normal file
5
models/descriptions/nft_address.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs nft_address %}
|
||||
|
||||
The contract address of the NFT.
|
||||
|
||||
{% enddocs %}
|
||||
5
models/descriptions/nft_id.md
Normal file
5
models/descriptions/nft_id.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs nft_id %}
|
||||
|
||||
The token_series_id for the NFT contract.
|
||||
|
||||
{% enddocs %}
|
||||
5
models/descriptions/nft_project_name.md
Normal file
5
models/descriptions/nft_project_name.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs nft_project_name %}
|
||||
|
||||
The project_name is the name of the collection in the NFT exchange platform
|
||||
|
||||
{% enddocs %}
|
||||
5
models/descriptions/nft_token_id.md
Normal file
5
models/descriptions/nft_token_id.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs nft_token_id %}
|
||||
|
||||
The token ID for this NFT contract.
|
||||
|
||||
{% enddocs %}
|
||||
@ -1,150 +0,0 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
cluster_by = ['block_timestamp::DATE', '_inserted_timestamp::DATE'],
|
||||
unique_key = 'action_id',
|
||||
incremental_strategy = 'delete+insert'
|
||||
) }}
|
||||
|
||||
|
||||
--data from silver_action_event table
|
||||
WITH nft_mint AS (
|
||||
Select
|
||||
action_id,
|
||||
tx_hash,
|
||||
block_id,
|
||||
block_timestamp,
|
||||
action_index,
|
||||
action_name,
|
||||
CASE
|
||||
WHEN action_data :method_name in ('nft_mint', 'nft_mint_batch') THEN action_data :method_name :: STRING
|
||||
END AS method_name,
|
||||
_ingested_at,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
{{ref ('silver__actions_events')}}
|
||||
|
||||
where method_name in ('nft_mint', 'nft_mint_batch')
|
||||
|
||||
|
||||
)
|
||||
--Data pulled from action_events_function_call
|
||||
,function_call_data AS (
|
||||
select
|
||||
ACTION_ID,
|
||||
TX_HASH,
|
||||
BLOCK_ID,
|
||||
BLOCK_TIMESTAMP,
|
||||
try_parse_json(args) as args_json,
|
||||
METHOD_NAME,
|
||||
DEPOSIT,
|
||||
ATTACHED_GAS,
|
||||
|
||||
Case
|
||||
when method_name in (
|
||||
'nft_mint',
|
||||
'nft_batch_mint'
|
||||
) THEN args_json:receiver_id::string
|
||||
when method_name in (
|
||||
'nft_mint',
|
||||
'nft_batch_mint'
|
||||
|
||||
) THEN args_json:receiver_ids :: STRING
|
||||
END AS Project_name,
|
||||
CASE
|
||||
WHEN method_name in (
|
||||
'nft_mint',
|
||||
'nft_batch_mint'
|
||||
) THEN try_parse_json ( --args_json :token_id :: STRING,
|
||||
args_json :token_series_id :: STRING)
|
||||
WHEN method_name in (
|
||||
'nft_mint',
|
||||
'nft_batch_mint'
|
||||
) THEN try_parse_json ( args_json :token_owner_id :: STRING)
|
||||
END AS nft_id,
|
||||
CASE
|
||||
WHEN method_name in (
|
||||
'nft_mint',
|
||||
'nft_batch_mint'
|
||||
) THEN try_parse_json ( args_json :token_id :: STRING) END AS token_id
|
||||
FROM
|
||||
{{ ref ('silver__actions_events_function_call') }}
|
||||
|
||||
where method_name in ('nft_mint', 'nft_mint_batch')
|
||||
AND tx_hash in (
|
||||
SELECT Distinct
|
||||
tx_hash from nft_mint)
|
||||
|
||||
)
|
||||
--Data Pulled from Transaction
|
||||
,mint_transactions AS (
|
||||
select
|
||||
tx_hash,
|
||||
tx_signer AS Signer,
|
||||
tx_receiver As receiver,
|
||||
transaction_fee as network_fee,
|
||||
GAS_USED,
|
||||
ATTACHED_GAS,
|
||||
tx_status,
|
||||
tx :actions[0] :FunctionCall :method_name :: STRING as method_name
|
||||
--try_parse_json(tx) :outcome :id :: STRING AS nft_id
|
||||
FROM
|
||||
{{ ref ('silver__transactions' )}}
|
||||
|
||||
where method_name in ('nft_mint','nft_mint_batch')
|
||||
AND TX_STATUS = 'Success'
|
||||
|
||||
)
|
||||
--Data pulled from Receipts Table
|
||||
,receipts_data AS (
|
||||
Select
|
||||
|
||||
Tx_Hash,
|
||||
Receipt_index,
|
||||
Receipt_object_id As Receipt_Id,
|
||||
Receipt_outcome_id :: STRING AS RECEIPT_OUTCOME_ID,
|
||||
Receiver_ID,
|
||||
Gas_Burnt
|
||||
FROM
|
||||
{{ ref ('silver__receipts' )}}
|
||||
WHERE
|
||||
TX_HASH in (
|
||||
SELECT DISTINCT TX_Hash
|
||||
FROM nft_mint)
|
||||
|
||||
)
|
||||
|
||||
|
||||
SELECT DISTINCT
|
||||
A.action_id,
|
||||
A.tx_hash,
|
||||
A.block_id,
|
||||
A.block_timestamp,
|
||||
A.action_index,
|
||||
A.action_name,
|
||||
A.method_name,
|
||||
A._ingested_at,
|
||||
A._inserted_timestamp,
|
||||
Signer,
|
||||
Receiver,
|
||||
project_name,
|
||||
token_id,
|
||||
nft_id,
|
||||
R.Receiver_id AS NFT_address,
|
||||
Deposit,
|
||||
B.Attached_GAS,
|
||||
Gas_used,
|
||||
Gas_Burnt,
|
||||
network_fee,
|
||||
R.Receipt_index,
|
||||
R.Receipt_Id,
|
||||
R.RECEIPT_OUTCOME_ID,
|
||||
T.tx_status
|
||||
|
||||
FROM nft_mint A
|
||||
LEFT JOIN function_call_data B
|
||||
ON A.tx_hash = B.tx_hash
|
||||
LEFT JOIN mint_transactions T
|
||||
ON A.tx_hash = T.tx_hash
|
||||
LEFT JOIN receipts_data R
|
||||
ON A.tx_hash = R.tx_hash
|
||||
where tx_status is not null
|
||||
122
models/silver/silver__nft_mints.sql
Normal file
122
models/silver/silver__nft_mints.sql
Normal file
@ -0,0 +1,122 @@
|
||||
{{
|
||||
config(
|
||||
materialized="incremental",
|
||||
cluster_by=["block_timestamp::DATE", "_inserted_timestamp::DATE"],
|
||||
unique_key="action_id",
|
||||
incremental_strategy="delete+insert",
|
||||
)
|
||||
}}
|
||||
|
||||
|
||||
-- data from silver_action_event table
|
||||
with
|
||||
nft_mint as (
|
||||
select
|
||||
action_id,
|
||||
tx_hash,
|
||||
block_id,
|
||||
block_timestamp,
|
||||
action_index,
|
||||
action_name,
|
||||
action_data:method_name::string as method_name,
|
||||
_ingested_at,
|
||||
_inserted_timestamp
|
||||
from {{ ref("silver__actions_events") }}
|
||||
|
||||
where
|
||||
method_name in ('nft_mint', 'nft_mint_batch')
|
||||
AND {{ incremental_load_filter("_inserted_timestamp") }}
|
||||
|
||||
-- {% if is_incremental() %}
|
||||
-- and ingested_at >= (select max(ingested_at)::date - 2 from {{ this }})
|
||||
-- {% endif %}
|
||||
|
||||
|
||||
-- Data pulled from action_events_function_call
|
||||
),
|
||||
function_call_data as (
|
||||
select
|
||||
action_id,
|
||||
tx_hash,
|
||||
block_id,
|
||||
block_timestamp,
|
||||
try_parse_json(args) as args_json,
|
||||
method_name,
|
||||
deposit/pow(10,24) AS deposit,
|
||||
attached_gas,
|
||||
|
||||
case
|
||||
when args_json:receiver_id is not null
|
||||
then args_json:receiver_id::string
|
||||
when args_json:receiver_ids is not null
|
||||
then args_json:receiver_ids::string
|
||||
end as project_name,
|
||||
case
|
||||
when args_json:token_series_id is not null
|
||||
then try_parse_json(args_json:token_series_id)::string
|
||||
when args_json:token_owner_id is not null
|
||||
then try_parse_json(args_json:token_owner_id)::string
|
||||
end as nft_id,
|
||||
try_parse_json(args_json:token_id)::string as token_id
|
||||
|
||||
from {{ ref("silver__actions_events_function_call") }}
|
||||
|
||||
where
|
||||
method_name in ('nft_mint', 'nft_mint_batch')
|
||||
and tx_hash in (select distinct tx_hash from nft_mint)
|
||||
|
||||
-- Data Pulled from Transaction
|
||||
),
|
||||
mint_transactions as (
|
||||
select
|
||||
tx_hash,
|
||||
tx_signer as signer,
|
||||
tx_receiver as receiver,
|
||||
transaction_fee as network_fee,
|
||||
gas_used,
|
||||
attached_gas,
|
||||
tx_status,
|
||||
tx:actions[0]:functioncall:method_name::string as method_name
|
||||
-- try_parse_json(tx) :outcome :id :: STRING AS nft_id
|
||||
from {{ ref("silver__transactions") }}
|
||||
|
||||
where method_name in ('nft_mint', 'nft_mint_batch') and tx_status = 'Success'
|
||||
|
||||
-- Data pulled from Receipts Table
|
||||
),
|
||||
receipts_data as (
|
||||
select
|
||||
|
||||
tx_hash,
|
||||
receipt_index,
|
||||
receipt_object_id as receipt_id,
|
||||
receipt_outcome_id::string as receipt_outcome_id,
|
||||
receiver_id,
|
||||
gas_burnt
|
||||
from {{ ref("silver__receipts") }}
|
||||
where tx_hash in (select distinct tx_hash from nft_mint)
|
||||
|
||||
)
|
||||
|
||||
|
||||
select distinct
|
||||
nft_mint.action_id,
|
||||
nft_mint.tx_hash,
|
||||
nft_mint.block_id,
|
||||
nft_mint.block_timestamp,
|
||||
nft_mint.method_name,
|
||||
nft_mint._ingested_at,
|
||||
nft_mint._inserted_timestamp,
|
||||
signer,
|
||||
receiver,
|
||||
project_name,
|
||||
token_id,
|
||||
nft_id,
|
||||
receipts_data.receiver_id as nft_address,
|
||||
tx_status
|
||||
|
||||
from nft_mint
|
||||
left join function_call_data on nft_mint.tx_hash = function_call_data.tx_hash
|
||||
left join mint_transactions on nft_mint.tx_hash = mint_transactions.tx_hash
|
||||
left join receipts_data on nft_mint.tx_hash = receipts_data.tx_hash
|
||||
where tx_status is not null
|
||||
@ -1,7 +1,7 @@
|
||||
version: 2
|
||||
|
||||
models:
|
||||
- name: silver__nft_mint
|
||||
- name: silver__nft_mints
|
||||
description: |-
|
||||
This table records all the nft mints transfer in the near db
|
||||
columns:
|
||||
@ -24,6 +24,7 @@ models:
|
||||
- name: ACTION_ID
|
||||
description: "{{ doc('action_id')}}"
|
||||
tests:
|
||||
- unique
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
@ -38,7 +39,7 @@ models:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
- name: Signer
|
||||
- name: SIGNER
|
||||
description: "{{ doc('tx_signer')}}"
|
||||
tests:
|
||||
- not_null
|
||||
@ -65,15 +66,17 @@ models:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
# - name: NFT_PROJECT
|
||||
# tests:
|
||||
# - not_null
|
||||
# - dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
# column_type_list:
|
||||
# - STRING
|
||||
# - VARCHAR
|
||||
- name: PROJECT_NAME
|
||||
description: "{{ doc('nft_project_name') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
|
||||
- name: NFT_ID
|
||||
- name: NFT_ADDRESS
|
||||
description: "{{ doc('nft_address') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
@ -81,6 +84,21 @@ models:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: NFT_ID
|
||||
description: "{{ doc('nft_id') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
- name: TOKEN_ID
|
||||
description: "{{ doc ('nft_token_id') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: _INGESTED_AT
|
||||
description: "{{ doc('_ingested_at') }}"
|
||||
tests:
|
||||
@ -97,12 +115,3 @@ models:
|
||||
column_type_list:
|
||||
- TIMESTAMP_NTZ
|
||||
|
||||
- name: RECEIPT_ID
|
||||
description: "{{ doc('receipt_object_id') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- unique
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
Loading…
Reference in New Issue
Block a user