mirror of
https://github.com/FlipsideCrypto/near-models.git
synced 2026-02-06 14:11:54 +00:00
Merge pull request #114 from MetricsDAO/nft_mint_curation
Nft mint curation
This commit is contained in:
commit
29f9e009b7
22
models/core/core__ez_nft_mints.sql
Normal file
22
models/core/core__ez_nft_mints.sql
Normal file
@ -0,0 +1,22 @@
|
||||
with mints as (
|
||||
select *
|
||||
from {{ ref('silver__nft_mints') }}
|
||||
)
|
||||
|
||||
select
|
||||
action_id,
|
||||
tx_hash,
|
||||
block_id,
|
||||
block_timestamp,
|
||||
method_name,
|
||||
_ingested_at,
|
||||
_inserted_timestamp,
|
||||
tx_signer,
|
||||
tx_receiver,
|
||||
project_name,
|
||||
token_id,
|
||||
nft_id,
|
||||
nft_address,
|
||||
network_fee,
|
||||
tx_status
|
||||
from mints
|
||||
117
models/core/core__ez_nft_mints.yml
Normal file
117
models/core/core__ez_nft_mints.yml
Normal file
@ -0,0 +1,117 @@
|
||||
version: 2
|
||||
|
||||
models:
|
||||
- name: core__ez_nft_mints
|
||||
description: |-
|
||||
This table records all the nft mints transfer in the near db
|
||||
|
||||
|
||||
columns:
|
||||
- name: BLOCK_TIMESTAMP
|
||||
description: "{{ doc('block_timestamp')}}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_NTZ
|
||||
|
||||
- name: BLOCK_ID
|
||||
description: "{{ doc('block_id')}}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: ACTION_ID
|
||||
description: "{{ doc('action_id')}}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: TX_HASH
|
||||
description: "{{ doc('tx_hash')}}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
- name: TX_SIGNER
|
||||
description: "{{ doc('tx_signer')}}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: TX_RECEIVER
|
||||
description: "{{ doc('tx_receiver')}}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: TX_STATUS
|
||||
description: "{{ doc('tx_status')}}"
|
||||
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_ADDRESS
|
||||
description: "{{ doc('nft_address') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- 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:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_NTZ
|
||||
|
||||
- name: _INSERTED_TIMESTAMP
|
||||
description: "{{ doc('_inserted_timestamp') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_NTZ
|
||||
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 %}
|
||||
100
models/silver/silver__nft_mints.sql
Normal file
100
models/silver/silver__nft_mints.sql
Normal file
@ -0,0 +1,100 @@
|
||||
{{
|
||||
config(
|
||||
materialized="incremental",
|
||||
cluster_by=["block_timestamp::DATE", "_inserted_timestamp::DATE"],
|
||||
unique_key="action_id",
|
||||
incremental_strategy="delete+insert",
|
||||
)
|
||||
}}
|
||||
|
||||
--Data pulled from action_events_function_call
|
||||
with
|
||||
function_call 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,
|
||||
_ingested_at,
|
||||
_inserted_timestamp,
|
||||
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_series_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 {{ incremental_load_filter("_inserted_timestamp") }}
|
||||
),
|
||||
|
||||
--Data Pulled from Transaction
|
||||
mint_transactions as (
|
||||
select
|
||||
tx_hash,
|
||||
tx_signer,
|
||||
tx_receiver,
|
||||
transaction_fee / pow(10, 24) as network_fee,
|
||||
tx_status
|
||||
-- tx:actions[0]:functioncall:method_name::string as method_name
|
||||
from {{ ref("silver__transactions") }}
|
||||
where
|
||||
tx_hash in (select distinct tx_hash from function_call)
|
||||
and tx_status = 'Success'
|
||||
and {{ incremental_load_filter("_inserted_timestamp") }}
|
||||
|
||||
|
||||
),
|
||||
--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 function_call)
|
||||
and {{ incremental_load_filter("_inserted_timestamp") }}
|
||||
|
||||
)
|
||||
|
||||
|
||||
select distinct
|
||||
action_id,
|
||||
function_call.tx_hash,
|
||||
block_id,
|
||||
block_timestamp,
|
||||
method_name,
|
||||
_ingested_at,
|
||||
_inserted_timestamp,
|
||||
tx_signer,
|
||||
tx_receiver,
|
||||
project_name,
|
||||
token_id,
|
||||
nft_id,
|
||||
receipts_data.receiver_id as nft_address,
|
||||
network_fee,
|
||||
tx_status
|
||||
|
||||
from function_call
|
||||
left join mint_transactions on function_call.tx_hash = mint_transactions.tx_hash
|
||||
left join receipts_data on function_call.tx_hash = receipts_data.tx_hash
|
||||
where tx_status is not null
|
||||
|
||||
121
models/silver/silver__nft_mints.yml
Normal file
121
models/silver/silver__nft_mints.yml
Normal file
@ -0,0 +1,121 @@
|
||||
version: 2
|
||||
|
||||
models:
|
||||
- name: silver__nft_mints
|
||||
description: |-
|
||||
This table records all the nft mints transfer in the near db
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- ACTION_ID
|
||||
|
||||
columns:
|
||||
- name: BLOCK_TIMESTAMP
|
||||
description: "{{ doc('block_timestamp')}}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_NTZ
|
||||
|
||||
- name: BLOCK_ID
|
||||
description: "{{ doc('block_id')}}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: ACTION_ID
|
||||
description: "{{ doc('action_id')}}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: TX_HASH
|
||||
description: "{{ doc('tx_hash')}}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
- name: TX_SIGNER
|
||||
description: "{{ doc('tx_signer')}}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: TX_RECEIVER
|
||||
description: "{{ doc('tx_receiver')}}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: TX_STATUS
|
||||
description: "{{ doc('tx_status')}}"
|
||||
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_ADDRESS
|
||||
description: "{{ doc('nft_address') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- 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:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_NTZ
|
||||
|
||||
- name: _INSERTED_TIMESTAMP
|
||||
description: "{{ doc('_inserted_timestamp') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_NTZ
|
||||
|
||||
Loading…
Reference in New Issue
Block a user