diff --git a/models/core/core__ez_nft_mints.sql b/models/core/core__ez_nft_mints.sql new file mode 100644 index 0000000..268ad4f --- /dev/null +++ b/models/core/core__ez_nft_mints.sql @@ -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 diff --git a/models/core/core__ez_nft_mints.yml b/models/core/core__ez_nft_mints.yml new file mode 100644 index 0000000..b60e97d --- /dev/null +++ b/models/core/core__ez_nft_mints.yml @@ -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 \ No newline at end of file diff --git a/models/descriptions/nft_address.md b/models/descriptions/nft_address.md new file mode 100644 index 0000000..c20a00e --- /dev/null +++ b/models/descriptions/nft_address.md @@ -0,0 +1,5 @@ +{% docs nft_address %} + +The contract address of the NFT. + +{% enddocs %} \ No newline at end of file diff --git a/models/descriptions/nft_id.md b/models/descriptions/nft_id.md new file mode 100644 index 0000000..228f357 --- /dev/null +++ b/models/descriptions/nft_id.md @@ -0,0 +1,5 @@ +{% docs nft_id %} + +The token_series_id for the NFT contract. + +{% enddocs %} \ No newline at end of file diff --git a/models/descriptions/nft_project_name.md b/models/descriptions/nft_project_name.md new file mode 100644 index 0000000..9d50c81 --- /dev/null +++ b/models/descriptions/nft_project_name.md @@ -0,0 +1,5 @@ +{% docs nft_project_name %} + +The project_name is the name of the collection in the NFT exchange platform + +{% enddocs %} \ No newline at end of file diff --git a/models/descriptions/nft_token_id.md b/models/descriptions/nft_token_id.md new file mode 100644 index 0000000..f9aa0d8 --- /dev/null +++ b/models/descriptions/nft_token_id.md @@ -0,0 +1,5 @@ +{% docs nft_token_id %} + +The token ID for this NFT contract. + +{% enddocs %} \ No newline at end of file diff --git a/models/silver/silver__nft_mints.sql b/models/silver/silver__nft_mints.sql new file mode 100644 index 0000000..4090bc5 --- /dev/null +++ b/models/silver/silver__nft_mints.sql @@ -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 + diff --git a/models/silver/silver__nft_mints.yml b/models/silver/silver__nft_mints.yml new file mode 100644 index 0000000..8979d8b --- /dev/null +++ b/models/silver/silver__nft_mints.yml @@ -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 +