-
Notifications
You must be signed in to change notification settings - Fork 1.3k
WIP: Adds a spell for NEAR blockchain ft_transfer_calls #7900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
91 changes: 91 additions & 0 deletions
91
dbt_subprojects/daily_spellbook/models/near/near_ft_transfer_calls.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
{{ | ||
config( | ||
schema = 'near', | ||
alias = 'ft_transfer_calls', | ||
materialized = 'incremental', | ||
file_format = 'delta', | ||
incremental_strategy = 'merge', | ||
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')], | ||
unique_key = ['block_date', 'receipt_id', 'resolve_receipt_id'], | ||
post_hook = '{{ expose_spells(\'["near"]\', | ||
"sector", | ||
"transfers", | ||
\'["danzipie"]\') }}' | ||
) | ||
}} | ||
|
||
WITH | ||
ft_transfer_calls AS ( | ||
SELECT | ||
block_date, | ||
block_height, | ||
block_time, | ||
block_hash, | ||
chunk_hash, | ||
shard_id, | ||
tx_hash, | ||
action_function_call_args_parsed, | ||
receipt_id, | ||
execution_outcome_receipt_ids | ||
FROM | ||
{{ source('near', 'actions') }} | ||
WHERE | ||
action_function_call_call_method_name = 'ft_transfer_call' | ||
{% if is_incremental() %} | ||
AND {{ incremental_predicate('block_date') }} | ||
{% endif %} | ||
) | ||
SELECT | ||
ft_transfer_calls.block_date, | ||
ft_transfer_calls.block_height, | ||
ft_transfer_calls.block_time, | ||
ft_transfer_calls.block_hash, | ||
ft_transfer_calls.chunk_hash, | ||
ft_transfer_calls.shard_id, | ||
'nep141' AS standard, | ||
ft_resolve_transfers.receipt_receiver_account_id AS contract_account_id, | ||
ft_transfer_calls.receipt_id, | ||
ft_resolve_transfers.receipt_id as resolve_receipt_id, | ||
ft_resolve_transfers.tx_status AS resolve_status, | ||
ft_resolve_transfers.tx_hash, | ||
'ft_transfer_call' AS cause, | ||
CAST( | ||
json_extract(ft_transfer_calls.action_function_call_args_parsed, '$.memo') AS varchar | ||
) AS memo, | ||
CAST( | ||
json_extract( | ||
ft_resolve_transfers.action_function_call_args_parsed, | ||
'$.receiver_id' | ||
) AS varchar | ||
) AS affected_account_id, | ||
CAST( | ||
json_extract( | ||
ft_resolve_transfers.action_function_call_args_parsed, | ||
'$.sender_id' | ||
) AS varchar | ||
) AS involved_account_id, | ||
CAST( | ||
json_extract( | ||
ft_resolve_transfers.action_function_call_args_parsed, | ||
'$.amount' | ||
) AS varchar | ||
) AS delta_amount, | ||
ft_resolve_transfers._updated_at, | ||
ft_resolve_transfers._ingested_at | ||
FROM | ||
{{ source('near', 'actions') }} AS ft_resolve_transfers | ||
JOIN ft_transfer_calls ON ( | ||
ft_resolve_transfers.tx_hash = ft_transfer_calls.tx_hash | ||
AND ft_resolve_transfers.block_date >= ft_transfer_calls.block_date | ||
) | ||
WHERE | ||
ft_resolve_transfers.receipt_predecessor_account_id = ft_resolve_transfers.receipt_receiver_account_id | ||
AND ft_resolve_transfers.action_function_call_call_method_name = 'ft_resolve_transfer' | ||
AND json_extract( | ||
ft_resolve_transfers.action_function_call_args_parsed, | ||
'$.amount' | ||
) IS NOT NULL -- this excludes the contract_account_id 'aurora' that is not fully nep141 compliant | ||
AND contains(ft_transfer_calls.execution_outcome_receipt_ids, ft_resolve_transfers.receipt_id) | ||
{% if is_incremental() %} | ||
AND {{ incremental_predicate('ft_resolve_transfers.block_date') }} | ||
{% endif %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
version: 2 | ||
|
||
models: | ||
- name: near_ft_transfer_calls | ||
meta: | ||
blockchain: near | ||
sector: transfers | ||
project: ft_transfer_calls | ||
contributors: danzipie | ||
config: | ||
tags: | ||
["near", "nep141"] | ||
description: > | ||
This table contains token transfers on the NEAR blockchain for the `ft_transfer_call` function. | ||
columns: | ||
- name: block_date | ||
description: "Date of the block of the ft_transfer_call" | ||
tests: | ||
- not_null | ||
- name: block_height | ||
description: "Height of the block of the ft_transfer_call" | ||
tests: | ||
- not_null | ||
- name: block_time | ||
description: "Timestamp of the block of the ft_transfer_call" | ||
tests: | ||
- not_null | ||
- name: block_hash | ||
description: "Hash of the block of the ft_transfer_call" | ||
tests: | ||
- not_null | ||
- name: chunk_hash | ||
description: "Hash of the chunk of the ft_transfer_call" | ||
tests: | ||
- not_null | ||
- name: shard_id | ||
description: "ID of the shard of the ft_transfer_call" | ||
tests: | ||
- not_null | ||
- name: standard | ||
description: "Token standard" | ||
tests: | ||
- not_null | ||
- name: contract_account_id | ||
description: "ID of the token contract account" | ||
tests: | ||
- not_null | ||
- name: receipt_id | ||
description: "ID of the receipt of the ft_transfer_call" | ||
tests: | ||
- not_null | ||
- name: resolve_receipt_id | ||
description: "ID of the receipt of the ft_resolve_call" | ||
tests: | ||
- not_null | ||
- name: resolve_status | ||
description: "Status of the ft_resolve_call" | ||
tests: | ||
- not_null | ||
- name: tx_hash | ||
description: "Hash of the transaction" | ||
tests: | ||
- not_null | ||
- name: cause | ||
description: "Cause of the transfer" | ||
tests: | ||
- not_null | ||
- name: memo | ||
description: "Memo field of the transaction" | ||
- name: affected_account_id | ||
description: "Account ID affected by the transfer" | ||
tests: | ||
- not_null | ||
- name: involved_account_id | ||
description: "Account ID involved in the transfer" | ||
tests: | ||
- not_null | ||
- name: delta_amount | ||
description: "Amount of tokens transferred" | ||
tests: | ||
- not_null | ||
- name: _updated_at | ||
description: "Last update timestamp" | ||
tests: | ||
- not_null | ||
- name: _ingested_at | ||
description: "Ingestion timestamp" | ||
tests: | ||
- not_null |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.