Integrate Reservoir and OpenSea (#37)

This commit is contained in:
Jim Myers 2023-08-14 17:57:54 -04:00 committed by GitHub
parent d9e0dfb3c9
commit 5f4077015e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 180 additions and 8 deletions

View File

@ -1,5 +1,5 @@
name: dbt_run_adhoc
run-name: ${{ inputs.dbt_command }}
run-name: ${{ inputs.environment }} - ${{ inputs.dbt_command }}
on:
workflow_dispatch:
@ -62,7 +62,7 @@ jobs:
dbt deps
- name: Run DBT Jobs
run: |
dbt --debug ${{ inputs.dbt_command }}
dbt ${{ inputs.dbt_command }}
- name: Store logs
uses: actions/upload-artifact@v3

View File

@ -15,7 +15,7 @@ env:
PASSWORD: "${{ secrets.PASSWORD }}"
REGION: "${{ vars.REGION }}"
DATABASE: "${{ vars.DATABASE }}"
WAREHOUSE: "${{ inputs.warehouse }}"
WAREHOUSE: "${{ vars.WAREHOUSE }}"
SCHEMA: "${{ vars.SCHEMA }}"
concurrency:

View File

@ -58,8 +58,8 @@ vars:
UPDATE_SNOWFLAKE_TAGS: true
STREAMLINE_INVOKE_STREAMS: False
STREAMLINE_USE_DEV_FOR_EXTERNAL_TABLES: False
REST_API_ID_PROD: ARPK1G9P37
REST_API_ID_DEV: QG6A9ZS6R7
API_INTEGRATION: AWS_LIVE_QUERY{{ '_DEV' if target.name != 'prod' else '' }}
REST_API_PREFIX_PROD: bqco8lkjsb.execute-api.us-east-1.amazonaws.com/prod/
REST_API_PREFIX_DEV: u5z0tu43sc.execute-api.us-east-1.amazonaws.com/stg/
API_INTEGRATION: AWS_LIVE_QUERY{{ '_STG' if target.name != 'prod' else '' }}
AWS_REGION: us-east-1
STUDIO_TEST_USER_ID: 98d15c30-9fa5-43cd-9c69-3d4c0bb269f5

View File

@ -224,5 +224,16 @@
NOT NULL
RETURNS NULL ON NULL INPUT
sql: evm/decode/log
- name: {{ schema }}.udf_evm_decode_log
signature:
- [abi, OBJECT]
- [data, OBJECT]
return_type: ARRAY
func_type: EXTERNAL
api_integration: '{{ var("API_INTEGRATION") }}'
options: |
NOT NULL
RETURNS NULL ON NULL INPUT
sql: evm/decode/log
{% endmacro %}

View File

@ -6,7 +6,7 @@
{% endmacro %}
{%- macro construct_api_route(route) -%}
'https://{{ var("REST_API_ID_PROD") if target.name == "prod" else var("REST_API_ID_DEV") }}.execute-api.{{ var( aws_region, "us-east-1" ) }}.amazonaws.com/{{ target.name }}/{{ route }}'
'https://{{ var("REST_API_PREFIX_PROD") | lower if target.name == "prod" else var("REST_API_PREFIX_DEV") | lower }}{{ route }}'
{%- endmacro -%}
{%- macro compile_signature(

View File

@ -0,0 +1,42 @@
{% macro config_opensea_udfs(schema_name = "opensea", utils_schema_name="opensea_utils") -%}
{#
This macro is used to generate the OpenSea Base endpoints
#}
- name: {{ schema_name -}}.get
signature:
- [PATH, STRING, The path starting with '/']
- [QUERY_ARGS, OBJECT, The query arguments]
return_type:
- "VARIANT"
options: |
COMMENT = $$Used to issue a 'GET' request to the OpenSea API. [OpenSea docs here](https://docs.opensea.io/reference/api-overview).$$
sql: |
SELECT
live.udf_api(
'GET',
concat('https://api.opensea.io', PATH, '?', utils.udf_object_to_url_query_string(QUERY_ARGS)),
{'X-API-KEY': '{API_KEY}'},
{},
'_FSC_SYS/OPENSEA'
) as response
- name: {{ schema_name -}}.post
signature:
- [PATH, STRING, The path starting with '/']
- [BODY, OBJECT, The request body]
return_type:
- "VARIANT"
options: |
COMMENT = $$Used to issue a 'POST' request to the OpenSea API. [OpenSea docs here](https://docs.opensea.io/reference/api-overview).$$
sql: |
SELECT
live.udf_api(
'POST',
concat('https://api.opensea.io', PATH),
{'X-API-KEY': '{API_KEY}'},
BODY,
'_FSC_SYS/OPENSEA'
) as response
{% endmacro %}

View File

@ -0,0 +1,42 @@
{% macro config_reservoir_udfs(schema_name = "reservoir", utils_schema_name="reservoir_utils") -%}
{#
This macro is used to generate the Reservoir Base endpoints
#}
- name: {{ schema_name -}}.get
signature:
- [PATH, STRING, The path starting with '/']
- [QUERY_ARGS, OBJECT, The query arguments]
return_type:
- "VARIANT"
options: |
COMMENT = $$Used to issue a 'GET' request to the Reservoir NFT Data API. [Reservoir docs here](https://docs.reservoir.tools/reference/nft-data-overview).$$
sql: |
SELECT
live.udf_api(
'GET',
concat('https://api.reservoir.tools', PATH, '?', utils.udf_object_to_url_query_string(QUERY_ARGS)),
{'x-api-key': '{API_KEY}'},
{},
'_FSC_SYS/RESERVOIR'
) as response
- name: {{ schema_name -}}.post
signature:
- [PATH, STRING, The path starting with '/']
- [BODY, OBJECT, The request body]
return_type:
- "VARIANT"
options: |
COMMENT = $$Used to issue a 'POST' request to the Reservoir NFT Data API. [Reservoir docs here](https://docs.reservoir.tools/reference/nft-data-overview).$$
sql: |
SELECT
live.udf_api(
'POST',
concat('https://api.reservoir.tools', PATH),
{'x-api-key': '{API_KEY}'},
BODY,
'_FSC_SYS/RESERVOIR'
) as response
{% endmacro %}

View File

@ -196,4 +196,45 @@ models:
args: >
[['array', [0, 1, 2]]]
assertions:
- result = 'array=%5B0%2C+1%2C+2%5D'
- result = 'array=%5B0%2C+1%2C+2%5D'
- name: udf_evm_decode_log
tests:
- test_udf:
name: test_utils__udf_evm_decode_log
args: >
{
'anonymous': false,
'inputs': [
{
'indexed': false,
'name': 'nonce',
'type': 'uint256'
}
],
'name': 'NonceChanged',
'type': 'event'
}::variant,
{
'address': '0x55032650b14df07b85bf18a3a3ec8e0af2e028d5',
'data': '0x000000000000000000000000000000000000000000000000000000000000279c',
'topics': [
'0x7220970e1f1f12864ecccd8942690a837c7a8dd45d158cb891eb45a8a69134aa'
]
}::variant
assertions:
- >
result = [
{
'address': '0x55032650b14df07b85bF18A3a3eC8E0Af2e028d5',
'data': [
{
'decoded': true,
'name': 'nonce',
'type': 'uint256',
'value': 10140
}
],
'decoded': true,
'name': 'NonceChanged'
}
]

View File

@ -0,0 +1,5 @@
-- depends_on: {{ ref('live') }}
{%- set configs = [
config_opensea_udfs,
] -%}
{{- ephemeral_deploy_marketplace(configs) -}}

View File

@ -0,0 +1,13 @@
version: 2
models:
- name: opensea__
columns:
- name: get
tests:
- test_udf:
name: test_opensea__get_status_200
args: >
'/health'
, {}
assertions:
- result:status_code = 200

View File

@ -0,0 +1,5 @@
-- depends_on: {{ ref('live') }}
{%- set configs = [
config_reservoir_udfs,
] -%}
{{- ephemeral_deploy_marketplace(configs) -}}

View File

@ -0,0 +1,13 @@
version: 2
models:
- name: reservoir__
columns:
- name: get
tests:
- test_udf:
name: test_reservoir__get_status_200
args: >
'/tokens/floor/v1'
, {'collection': '0x8d04a8c79ceb0889bdd12acdf3fa9d207ed3ff63'}
assertions:
- result:status_code = 200