Skip to content

Commit

Permalink
Add support for multiple datasources
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh9200 committed Feb 12, 2024
1 parent 892b018 commit 767a02c
Show file tree
Hide file tree
Showing 38 changed files with 1,520 additions and 486 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Reference/
**/target/
**/build/
**/data/
**/logs/dbt.log
**/logs/
**/*.spkg
**/buf.gen.yaml
replay.log
Expand Down
29 changes: 0 additions & 29 deletions sql/dbt/logs/dbt.log

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# Name your project! Project names should contain only lowercase characters
# and underscores. A good package name should reflect your organization's
# name or the intended use of these models
name: 'uniswap_v2'
name: 'protocol_uniswap_v2_ethereum_mainnet'
version: '1.0.0'
config-version: 2

# This setting configures which "profile" dbt uses for this project.
profile: 'uniswap_v2'
profile: 'protocol_uniswap_v2_ethereum_mainnet'

# These configurations specify where dbt should look for different types of files.
# The `model-paths` config, for example, states that models in this project can be
Expand All @@ -31,7 +31,7 @@ clean-targets: # directories to be removed by `dbt clean`
# directory as views. These settings can be overridden in the individual model
# files using the `{{ config(...) }}` macro.
models:
uniswap_v2:
protocol_uniswap_v2_ethereum_mainnet:
# Config indicated by + and applies to all files under models/example/
example:
+materialized: view
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

/*
Welcome to your first dbt model!
Did you know that you can also configure models directly within SQL files?
This will override configurations stated in dbt_project.yml
Try changing "table" to "view" below
*/

{{ config(materialized='table') }}

with source_data as (

select 1 as id
union all
select null as id

)

select *
from source_data

/*
Uncomment the line below to remove records with null `id` values
*/

-- where id is not null
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

-- Use the `ref` function to select from other models

select *
from {{ ref('my_first_dbt_model') }}
where id = 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

version: 2

models:
- name: my_first_dbt_model
description: "A starter dbt model"
columns:
- name: id
description: "The primary key for this table"
tests:
- unique
- not_null

- name: my_second_dbt_model
description: "A starter dbt model"
columns:
- name: id
description: "The primary key for this table"
tests:
- unique
- not_null
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 0 additions & 13 deletions sql/dbt/uniswap_v2/models/analytics/uniswap_v2_ethereum__burn.sql

This file was deleted.

13 changes: 0 additions & 13 deletions sql/dbt/uniswap_v2/models/analytics/uniswap_v2_ethereum__mint.sql

This file was deleted.

15 changes: 0 additions & 15 deletions sql/dbt/uniswap_v2/models/analytics/uniswap_v2_ethereum__pool.sql

This file was deleted.

25 changes: 0 additions & 25 deletions sql/dbt/uniswap_v2/models/analytics/uniswap_v2_ethereum__swaps.sql

This file was deleted.

12 changes: 0 additions & 12 deletions sql/dbt/uniswap_v2/models/analytics/uniswap_v2_ethereum__sync.sql

This file was deleted.

This file was deleted.

33 changes: 0 additions & 33 deletions sql/dbt/uniswap_v2/models/analytics/uniswap_v2_ethereum__tvl.sql

This file was deleted.

This file was deleted.

4 changes: 2 additions & 2 deletions sql/uniswap_v2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ endif

.PHONY: run
run: build
substreams run substreams.yaml map_events $(if $(START_BLOCK),-s $(START_BLOCK)) $(if $(STOP_BLOCK),-t $(STOP_BLOCK))
substreams run substreams.yaml $(if $(MODULE),$(MODULE),map_events) $(if $(START_BLOCK),-s $(START_BLOCK)) $(if $(STOP_BLOCK),-t $(STOP_BLOCK))

.PHONY: gui
gui: build
substreams gui substreams.yaml map_events $(if $(START_BLOCK),-s $(START_BLOCK)) $(if $(STOP_BLOCK),-t $(STOP_BLOCK))
substreams gui substreams.yaml $(if $(MODULE),$(MODULE),map_events) $(if $(START_BLOCK),-s $(START_BLOCK)) $(if $(STOP_BLOCK),-t $(STOP_BLOCK))

.PHONY: protogen
protogen:
Expand Down
1 change: 1 addition & 0 deletions sql/uniswap_v2/abi/factory_contract.abi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"inputs":[{"internalType":"address","name":"_feeToSetter","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token0","type":"address"},{"indexed":true,"internalType":"address","name":"token1","type":"address"},{"indexed":false,"internalType":"address","name":"pair","type":"address"},{"indexed":false,"internalType":"uint256","name":"","type":"uint256"}],"name":"PairCreated","type":"event"},{"constant":true,"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"allPairs","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"allPairsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"tokenA","type":"address"},{"internalType":"address","name":"tokenB","type":"address"}],"name":"createPair","outputs":[{"internalType":"address","name":"pair","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"feeTo","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"feeToSetter","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"getPair","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_feeTo","type":"address"}],"name":"setFeeTo","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_feeToSetter","type":"address"}],"name":"setFeeToSetter","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]
File renamed without changes.
6 changes: 4 additions & 2 deletions sql/uniswap_v2/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ use std::fs;

fn main() -> Result<(), anyhow::Error> {
let file_names = [
"abi/contract.abi.json",
"abi/factory_contract.abi.json",
"abi/pools_contract.abi.json",
];
let file_output_names = [
"src/abi/contract.rs",
"src/abi/factory_contract.rs",
"src/abi/pools_contract.rs",
];

let mut i = 0;
Expand Down
Loading

0 comments on commit 767a02c

Please sign in to comment.