Skip to content

Commit

Permalink
nft transactions to nft events (#1279)
Browse files Browse the repository at this point in the history
After giving it some more thought and implementing the first version of it, I actually think nft.transactions shoul be changed to nft.events.

Events correspond better to the tables built on top of it (nft.mints/burns/trades), and transactions have a very precise meaning for EVM blockchains. We could actually do an nft.transactions abstraction that would only give info about transaction value/gas fees at the transaction level (not the log/transfer level) later on.

Brief comments on the purpose of your changes:


*For Dune Engine V2*
I've checked that:

* [x] I tested the query on dune.com after compiling the model with dbt compile (compiled queries are written to the target directory)
* [x] I used "refs" to reference other models in this repo and "sources" to reference raw or decoded tables 
* [x] if adding a new model, I added a test
* [x] the filename is unique and ends with .sql
* [x] each sql file is a select statement and has only one view, table or function defined  
* [x] column names are `lowercase_snake_cased`

When you are ready for a review, tag duneanalytics/data-experience. We will re-open your forked pull request as an internal pull request. Then your spells will run in dbt and the logs will be avaiable in Github Actions DBT Slim CI. This job will only run the models and tests changed by your PR compared to the production project.
  • Loading branch information
soispoke authored Jul 12, 2022
1 parent 76de6e0 commit 2fb24a4
Show file tree
Hide file tree
Showing 21 changed files with 48 additions and 48 deletions.
18 changes: 9 additions & 9 deletions spellbook/macros/alter_table_properties.sql
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ ALTER VIEW balances_ethereum.erc1155_latest SET TBLPROPERTIES('dune.public'='tru
'dune.data_explorer.contributors'='["soispoke"]');
{% endset %}

{% set opensea_transactions %}
ALTER TABLE opensea.transactions SET TBLPROPERTIES('dune.public'='true',
{% set opensea_events %}
ALTER TABLE opensea.events SET TBLPROPERTIES('dune.public'='true',
'dune.data_explorer.blockchains'='["ethereum","solana"]',
'dune.data_explorer.category'='abstraction',
'dune.data_explorer.abstraction.type'='project',
Expand Down Expand Up @@ -128,8 +128,8 @@ ALTER VIEW opensea.fees SET TBLPROPERTIES('dune.public'='true',
{% endset %}


{% set magiceden_transactions %}
ALTER TABLE magiceden.transactions SET TBLPROPERTIES('dune.public'='true',
{% set magiceden_events %}
ALTER TABLE magiceden.events SET TBLPROPERTIES('dune.public'='true',
'dune.data_explorer.blockchains'='["solana"]',
'dune.data_explorer.category'='abstraction',
'dune.data_explorer.abstraction.type'='project',
Expand All @@ -155,8 +155,8 @@ ALTER VIEW magiceden.mints SET TBLPROPERTIES('dune.public'='true',
'dune.data_explorer.contributors'='["soispoke"]');
{% endset %}

{% set nft_transactions %}
ALTER TABLE nft.transactions SET TBLPROPERTIES('dune.public'='true',
{% set nft_events %}
ALTER TABLE nft.events SET TBLPROPERTIES('dune.public'='true',
'dune.data_explorer.blockchains'='["ethereum","solana"]',
'dune.data_explorer.category'='abstraction',
'dune.data_explorer.abstraction.type'='sector',
Expand Down Expand Up @@ -290,15 +290,15 @@ ALTER VIEW ens.view_renewals SET TBLPROPERTIES('dune.public'='true',
{% do run_query(balances_ethereum_erc1155_day) %}
{% do run_query(balances_ethereum_erc1155_hour) %}
{% do run_query(balances_ethereum_erc1155_latest) %}
{% do run_query(opensea_transactions) %}
{% do run_query(opensea_events) %}
{% do run_query(opensea_trades) %}
{% do run_query(opensea_mints) %}
{% do run_query(opensea_burns) %}
{% do run_query(opensea_fees) %}
{% do run_query(magiceden_transactions) %}
{% do run_query(magiceden_events) %}
{% do run_query(magiceden_trades) %}
{% do run_query(magiceden_mints) %}
{% do run_query(nft_transactions) %}
{% do run_query(nft_events) %}
{% do run_query(nft_trades) %}
{% do run_query(nft_mints) %}
{% do run_query(nft_burns) %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ NULL::string as royalty_fee_percentage,
NULL::double as royalty_fee_receive_address,
NULL::double as royalty_fee_currency_symbol,
unique_trade_id
FROM {{ ref('magiceden_solana_transactions') }}
FROM {{ ref('magiceden_solana_events') }}

{% if is_incremental() %}
-- this filter will only be applied on an incremental run
Expand Down
6 changes: 3 additions & 3 deletions spellbook/models/magiceden/magiceden_schema.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
version: 2

models:
- name: magiceden_transactions
- name: magiceden_events
meta:
blockchain: solana
project: magiceden
contributors: soispoke
config:
tags: ['magiceden','solana','transactions']
tags: ['magiceden','solana','events']
description: >
Magic Eden transactions
Magic Eden events
columns:
- &blockchain
name: blockchain
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ config(
alias ='transactions',
alias ='events',
materialized ='incremental',
file_format ='delta',
incremental_strategy='merge',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
)
}}

SELECT * FROM {{ ref('magiceden_solana_transactions') }}
SELECT * FROM {{ ref('magiceden_solana_events') }}
WHERE evt_type = 'Mint'
6 changes: 3 additions & 3 deletions spellbook/models/magiceden/solana/magiceden_solana_schema.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
version: 2

models:
- name: magiceden_solana_transactions
- name: magiceden_solana_events
meta:
blockchain: solana
project: magiceden
contributors: soispoke
config:
tags: ['magiceden','solana','transactions']
tags: ['magiceden','solana','events']
description: >
Magic Eden transactions on Solana
Magic Eden events on Solana
columns:
- &blockchain
name: blockchain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
)
}}

SELECT * FROM {{ ref('magiceden_solana_transactions') }}
SELECT * FROM {{ ref('magiceden_solana_events') }}
WHERE evt_type = 'Trade'
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ config(
alias ='transactions',
alias ='events',
materialized ='incremental',
file_format ='delta',
incremental_strategy='merge',
Expand All @@ -9,9 +9,9 @@


SELECT * FROM (
SELECT * FROM {{ ref('opensea_transactions') }}
SELECT * FROM {{ ref('opensea_events') }}
UNION
SELECT * FROM {{ ref('magiceden_transactions') }})
SELECT * FROM {{ ref('magiceden_events') }})

{% if is_incremental() %}
-- this filter will only be applied on an incremental run
Expand Down
6 changes: 3 additions & 3 deletions spellbook/models/nft/nft_schema.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
version: 2

models:
- name: nft_transactions
- name: nft_events
meta:
blockchain: ethereum, solana
sector: nft
contributors: soispoke
config:
tags: ['nft', 'opensea', 'magiceden', 'ethereum', 'solana', 'transactions']
tags: ['nft', 'opensea', 'magiceden', 'ethereum', 'solana', 'events']
description: >
NFT transactions
NFT events
columns:
- &blockchain
name: blockchain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ tx_hash,
tx_from,
tx_to,
unique_trade_id
FROM ({{ ref('opensea_ethereum_transactions') }})
FROM ({{ ref('opensea_ethereum_events') }})
WHERE evt_type = 'Burn'
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ config(
alias ='transactions',
alias ='events',
materialized ='incremental',
file_format ='delta',
incremental_strategy='merge',
Expand Down Expand Up @@ -44,7 +44,7 @@ royalty_fee_percentage,
royalty_fee_receive_address,
royalty_fee_currency_symbol,
unique_trade_id
FROM ({{ ref('opensea_v1_ethereum_transactions') }})
FROM ({{ ref('opensea_v1_ethereum_events') }})

{% if is_incremental() %}
-- this filter will only be applied on an incremental run
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ tx_hash,
tx_from,
tx_to,
unique_trade_id
FROM ({{ ref('opensea_ethereum_transactions') }})
FROM ({{ ref('opensea_ethereum_events') }})
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ tx_hash,
tx_from,
tx_to,
unique_trade_id
FROM ({{ ref('opensea_ethereum_transactions') }})
FROM ({{ ref('opensea_ethereum_events') }})
WHERE evt_type = 'Mint'
10 changes: 5 additions & 5 deletions spellbook/models/opensea/ethereum/opensea_ethereum_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ models:
- name: fee_currency_symbol
description: "Currency symbol in which fees were paid"

- name: opensea_v1_ethereum_transactions
- name: opensea_v1_ethereum_events
meta:
blockchain: ethereum
project: opensea
contributors: soispoke
config:
tags: ['ethereum','opensea','v1','transactions']
tags: ['ethereum','opensea','v1','events']
description: >
OpenSea v1 trades on Ethereum
columns:
Expand Down Expand Up @@ -156,15 +156,15 @@ models:
- name: unique_trade_id
description: "Unique trade ID"

- name: opensea_ethereum_transactions
- name: opensea_ethereum_events
meta:
blockchain: ethereum
project: opensea
contributors: soispoke
config:
tags: ['ethereum','opensea','transactions']
tags: ['ethereum','opensea','events']
description: >
OpenSea transactions on Ethereum
OpenSea events on Ethereum
columns:
- *blockchain
- *project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ tx_hash,
tx_from,
tx_to,
unique_trade_id
FROM (SELECT * FROM {{ ref('opensea_v1_ethereum_transactions') }} )
FROM (SELECT * FROM {{ ref('opensea_v1_ethereum_events') }} )
WHERE evt_type = 'Trade'
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ config(schema = 'opensea_v1_ethereum',
alias='transactions') }}
alias='events') }}

WITH wyvern_call_data as (
SELECT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ config(
alias ='transactions',
alias ='events',
materialized ='incremental',
file_format ='delta',
incremental_strategy='merge',
Expand Down Expand Up @@ -44,7 +44,7 @@ royalty_fee_receive_address,
royalty_fee_currency_symbol,
unique_trade_id
FROM
(SELECT * FROM {{ ref('opensea_ethereum_transactions') }}
(SELECT * FROM {{ ref('opensea_ethereum_events') }}

UNION

Expand Down Expand Up @@ -84,7 +84,7 @@ NULL::string as royalty_fee_percentage,
NULL::double as royalty_fee_receive_address,
NULL::double as royalty_fee_currency_symbol,
unique_trade_id
FROM {{ ref('opensea_solana_transactions') }})
FROM {{ ref('opensea_solana_events') }})

{% if is_incremental() %}
-- this filter will only be applied on an incremental run
Expand Down
6 changes: 3 additions & 3 deletions spellbook/models/opensea/opensea_schema.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
version: 2

models:
- name: opensea_transactions
- name: opensea_events
meta:
blockchain: ethereum, solana
project: opensea
contributors: rchen8, soispoke
config:
tags: ['ethereum','solana','opensea','transactions']
tags: ['ethereum','solana','opensea','events']
description: >
OpenSea transactions on Ethereum and Solana
OpenSea events on Ethereum and Solana
columns:
- &blockchain
name: blockchain
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ config(
alias ='transactions',
alias ='events',
materialized ='incremental',
file_format ='delta',
incremental_strategy='merge',
Expand Down
6 changes: 3 additions & 3 deletions spellbook/models/opensea/solana/opensea_solana_schema.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
version: 2

models:
- name: opensea_solana_transactions
- name: opensea_solana_events
meta:
blockchain: solana
project: opensea
contributors: rchen8, soispoke
config:
tags: ['solana','opensea','transactions']
tags: ['solana','opensea','events']
description: >
OpenSea transactions on Solana
OpenSea events on Solana
columns:
- &blockchain
name: blockchain
Expand Down
2 changes: 1 addition & 1 deletion spellbook/models/opensea/solana/opensea_solana_trades.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
)
}}

SELECT * FROM {{ ref('opensea_solana_transactions') }}
SELECT * FROM {{ ref('opensea_solana_events') }}
WHERE evt_type = 'Trade'

0 comments on commit 2fb24a4

Please sign in to comment.