clean up tests on transfers

This commit is contained in:
Jack Forgash 2025-04-29 16:00:44 -06:00
parent 7dfd01f583
commit 883d080f7d
18 changed files with 53 additions and 158 deletions

View File

@ -16,7 +16,7 @@ SELECT
block_id,
block_timestamp,
tx_hash,
receipt_id,
receipt_id AS action_id,
contract_address,
from_address,
to_address,

View File

@ -8,12 +8,6 @@ models:
vesting schedules, and release durations. The model processes actions with method names
'on_lockup_create', 'create', and 'new' from lockup.near contracts.
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- tx_hash
- action_index
columns:
- name: LOCKUP_ACTIONS_ID
description: Unique identifier for each lockup action, generated from tx_hash and action_index
@ -33,17 +27,8 @@ models:
tests:
- not_null
- name: RECEIPT_ID
description: The receipt ID associated with the lockup action
tests:
- not_null
- name: ACTION_INDEX
description: The index of the action within the transaction
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_of_type:
column_type: NUMBER
- name: RECEIPT_OBJECT_IDS
description: The receipt IDs associated with the lockup action
- name: LOCKUP_ACCOUNT_ID
description: The account ID of the lockup contract
@ -66,13 +51,13 @@ models:
description: The duration of the lockup period in nanoseconds
tests:
- dbt_expectations.expect_column_values_to_be_of_type:
column_type: STRING
column_type: VARCHAR
- name: LOCKUP_TIMESTAMP
description: The timestamp when the lockup period starts
tests:
- dbt_expectations.expect_column_values_to_be_of_type:
column_type: STRING
column_type: VARCHAR
- name: LOCKUP_TIMESTAMP_NTZ
description: The lockup timestamp converted to TIMESTAMP_NTZ format
@ -84,19 +69,19 @@ models:
description: The duration over which tokens are released after the lockup period
tests:
- dbt_expectations.expect_column_values_to_be_of_type:
column_type: STRING
column_type: VARCHAR
- name: VESTING_SCHEDULE
description: The vesting schedule configuration for the lockup contract
tests:
- dbt_expectations.expect_column_values_to_be_of_type:
column_type: STRING
column_type: VARCHAR
- name: TRANSFERS_INFORMATION
description: Additional information about token transfer restrictions
tests:
- dbt_expectations.expect_column_values_to_be_of_type:
column_type: STRING
column_type: VARCHAR
- name: MODIFIED_TIMESTAMP
description: Timestamp when the record was last modified

View File

@ -46,10 +46,10 @@ SELECT
tx_hash,
block_id,
block_timestamp,
receipt_id AS action_id,
receipt_id,
action_index,
predecessor_id,
signer_id,
receiver_id,
amount_unadj,
amount_unadj :: DOUBLE / pow(10, 24) AS amount_adj,

View File

@ -26,23 +26,12 @@ models:
- name: receipt_id
description: "{{ doc('receipt_id')}}"
tests:
- not_null
- name: action_index
description: "{{ doc('action_index')}}"
tests:
- not_null
- name: predecessor_id
description: "{{ doc('predecessor_id')}}"
tests:
- not_null
- name: signer_id
description: "{{ doc('signer_id')}}"
tests:
- not_null
- name: receiver_id
description: "{{ doc('receiver_id')}}"
@ -53,8 +42,6 @@ models:
description: "{{ doc('amount_unadj')}}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_greater_than:
value: 0
- name: amount_adj
description: "{{ doc('amount_adj')}}"

View File

@ -48,13 +48,13 @@ SELECT
tx_hash,
block_id,
block_timestamp,
receipt_id AS action_id,
receipt_id,
action_index,
amount_unadj,
amount_unadj :: DOUBLE / pow(10, 24) AS amount_adj,
predecessor_id,
receiver_id,
signer_id,
receipt_succeeded,
gas_price,
gas_burnt,

View File

@ -26,20 +26,14 @@ models:
- name: receipt_id
description: "{{ doc('receipt_id')}}"
tests:
- not_null
- name: action_index
description: "{{ doc('action_index')}}"
tests:
- not_null
- name: amount_unadj
description: "{{ doc('amount_unadj')}}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_greater_than:
value: 0
- name: amount_adj
description: "{{ doc('amount_adj')}}"
@ -58,11 +52,6 @@ models:
tests:
- not_null
- name: signer_id
description: "{{ doc('signer_id')}}"
tests:
- not_null
- name: receipt_succeeded
description: "{{ doc('receipt_succeeded')}}"
tests:

View File

@ -75,18 +75,18 @@ SELECT
block_timestamp,
block_id,
tx_hash,
receipt_id AS action_id,
receipt_id,
contract_address,
predecessor_id,
signer_id,
from_address,
to_address,
amount_unadj,
memo,
event_index,
event_index AS rn,
_partition_by_block_number,
{{ dbt_utils.generate_surrogate_key(
['receipt_id', 'contract_address', 'amount_unadj', 'from_address', 'to_address', 'event_index']
['receipt_id', 'contract_address', 'amount_unadj', 'from_address', 'to_address', 'rn']
) }} AS transfers_event_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,

View File

@ -29,8 +29,6 @@ models:
- name: RECEIPT_ID
description: "{{doc('receipt_id')}}"
tests:
- not_null
- name: CONTRACT_ADDRESS
description: "{{doc('contract_address')}}"
@ -39,8 +37,6 @@ models:
- name: PREDECESSOR_ID
description: "{{doc('predecessor_id')}}"
tests:
- not_null
- name: SIGNER_ID
description: "{{doc('signer_id')}}"
@ -59,18 +55,14 @@ models:
description: "{{doc('amount_unadj')}}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_of_type:
column_type: FLOAT
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
- name: MEMO
description: "{{doc('memo')}}"
tests:
- dbt_expectations.expect_column_values_to_be_of_type:
column_type: STRING
column_type: VARCHAR
- name: EVENT_INDEX
- name: RN
description: "{{doc('event_index')}}"
tests:
- not_null

View File

@ -104,6 +104,7 @@ SELECT
block_timestamp,
block_id,
tx_hash,
receipt_id AS action_id,
receipt_id,
contract_address,
predecessor_id,
@ -112,10 +113,10 @@ SELECT
to_address,
amount_unadj,
memo,
event_index,
event_index AS rn,
_partition_by_block_number,
{{ dbt_utils.generate_surrogate_key(
['receipt_id', 'contract_address', 'amount_unadj', 'from_address', 'to_address', 'event_index']
['receipt_id', 'contract_address', 'amount_unadj', 'from_address', 'to_address', 'rn']
) }} AS transfers_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,

View File

@ -28,8 +28,6 @@ models:
- name: RECEIPT_ID
description: "{{doc('receipt_id')}}"
tests:
- not_null
- name: CONTRACT_ADDRESS
description: "{{doc('contract_address')}}"
@ -38,13 +36,9 @@ models:
- name: PREDECESSOR_ID
description: "{{doc('predecessor_id')}}"
tests:
- not_null
- name: SIGNER_ID
description: "{{doc('signer_id')}}"
tests:
- not_null
- name: FROM_ADDRESS
description: "{{doc('from_address')}}"
@ -60,18 +54,14 @@ models:
description: "{{doc('amount_unadj')}}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_of_type:
column_type: FLOAT
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
- name: MEMO
description: "{{doc('memo')}}"
tests:
- dbt_expectations.expect_column_values_to_be_of_type:
column_type: STRING
column_type: VARCHAR
- name: EVENT_INDEX
- name: RN
description: "{{doc('event_index')}}"
tests:
- not_null

View File

@ -86,18 +86,18 @@ SELECT
block_timestamp,
block_id,
tx_hash,
receipt_id AS action_id,
receipt_id,
contract_address,
from_address,
to_address,
amount_unadj,
memo,
event_index,
event_index AS rn,
predecessor_id,
signer_id,
_partition_by_block_number,
{{ dbt_utils.generate_surrogate_key(
['receipt_id', 'contract_address', 'amount_unadj', 'to_address', 'event_index']
['receipt_id', 'contract_address', 'amount_unadj', 'to_address', 'rn']
) }} AS transfers_liquidity_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,

View File

@ -28,8 +28,6 @@ models:
- name: RECEIPT_ID
description: "{{doc('receipt_id')}}"
tests:
- not_null
- name: CONTRACT_ADDRESS
description: "{{doc('contract_address')}}"
@ -48,10 +46,6 @@ models:
description: "{{doc('amount_unadj')}}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_of_type:
column_type: FLOAT
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
- name: MEMO
description: "{{doc('memo')}}"
@ -60,7 +54,7 @@ models:
- dbt_expectations.expect_column_values_to_be_in_set:
value_set: ['add_liquidity']
- name: EVENT_INDEX
- name: RN
description: "{{doc('event_index')}}"
tests:
- not_null
@ -69,13 +63,6 @@ models:
- name: PREDECESSOR_ID
description: "{{doc('predecessor_id')}}"
tests:
- not_null
- name: SIGNER_ID
description: "{{doc('signer_id')}}"
tests:
- not_null
- name: _PARTITION_BY_BLOCK_NUMBER
description: "{{doc('_partition_by_block_number')}}"

View File

@ -74,18 +74,18 @@ SELECT
block_timestamp,
block_id,
tx_hash,
receipt_id AS action_id,
receipt_id,
contract_address,
from_address,
to_address,
amount_unadj,
memo,
event_index,
event_index AS rn,
predecessor_id,
signer_id,
_partition_by_block_number,
{{ dbt_utils.generate_surrogate_key(
['receipt_id', 'contract_address', 'amount_unadj', 'to_address', 'event_index']
['receipt_id', 'contract_address', 'amount_unadj', 'to_address', 'rn']
) }} AS mint_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,

View File

@ -29,8 +29,6 @@ models:
- name: RECEIPT_ID
description: "{{doc('receipt_id')}}"
tests:
- not_null
- name: CONTRACT_ADDRESS
description: "{{doc('contract_address')}}"
@ -48,19 +46,15 @@ models:
- name: AMOUNT_UNADJ
description: "{{doc('amount_unadj')}}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_of_type:
column_type: FLOAT
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
- not_null`
- name: MEMO
description: "{{doc('memo')}}"
tests:
- dbt_expectations.expect_column_values_to_be_of_type:
column_type: STRING
column_type: VARCHAR
- name: EVENT_INDEX
- name: RN
description: "{{doc('event_index')}}"
tests:
- not_null
@ -69,13 +63,6 @@ models:
- name: PREDECESSOR_ID
description: "{{doc('predecessor_id')}}"
tests:
- not_null
- name: SIGNER_ID
description: "{{doc('signer_id')}}"
tests:
- not_null
- name: _PARTITION_BY_BLOCK_NUMBER
description: "{{doc('_partition_by_block_number')}}"

View File

@ -69,18 +69,18 @@ SELECT
block_timestamp,
block_id,
tx_hash,
receipt_id AS action_id,
receipt_id,
contract_address,
predecessor_id,
signer_id,
from_address,
to_address,
amount_unadj,
memo,
event_index,
event_index AS rn,
_partition_by_block_number,
{{ dbt_utils.generate_surrogate_key(
['receipt_id', 'contract_address', 'amount_unadj', 'from_address', 'to_address', 'event_index']
['receipt_id', 'contract_address', 'amount_unadj', 'from_address', 'to_address', 'rn']
) }} AS transfers_orders_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,

View File

@ -29,8 +29,6 @@ models:
- name: RECEIPT_ID
description: "{{doc('receipt_id')}}"
tests:
- not_null
- name: CONTRACT_ADDRESS
description: "{{doc('contract_address')}}"
@ -39,13 +37,6 @@ models:
- name: PREDECESSOR_ID
description: "{{doc('predecessor_id')}}"
tests:
- not_null
- name: SIGNER_ID
description: "{{doc('signer_id')}}"
tests:
- not_null
- name: FROM_ADDRESS
description: "{{doc('from_address')}}"
@ -61,19 +52,11 @@ models:
description: "{{doc('amount_unadj')}}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_of_type:
column_type: FLOAT
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
- name: MEMO
description: "{{doc('memo')}}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_set:
value_set: ['order']
- name: EVENT_INDEX
- name: RN
description: "{{doc('event_index')}}"
tests:
- not_null

View File

@ -54,8 +54,8 @@ WITH native_transfers AS (
block_id,
block_timestamp,
tx_hash,
receipt_id,
action_index AS event_index,
action_id,
action_index AS rn,
'wrap.near' AS contract_address,
predecessor_id AS from_address,
receiver_id AS to_address,
@ -79,8 +79,8 @@ native_deposits AS (
block_id,
block_timestamp,
tx_hash,
receipt_id,
action_index AS event_index,
action_id,
action_index AS rn,
'wrap.near' AS contract_address,
predecessor_id AS from_address,
receiver_id AS to_address,
@ -104,8 +104,8 @@ ft_transfers_method AS (
block_id,
block_timestamp,
tx_hash,
receipt_id,
event_index,
action_id,
rn,
contract_address,
from_address,
to_address,
@ -128,8 +128,8 @@ ft_transfers_event AS (
block_id,
block_timestamp,
tx_hash,
receipt_id,
event_index,
action_id,
rn,
contract_address,
from_address,
to_address,
@ -152,8 +152,8 @@ mints AS (
block_id,
block_timestamp,
tx_hash,
receipt_id,
event_index,
action_id,
rn,
contract_address,
from_address,
to_address,
@ -176,8 +176,8 @@ orders AS (
block_id,
block_timestamp,
tx_hash,
receipt_id,
event_index,
action_id,
rn,
contract_address,
from_address,
to_address,
@ -200,8 +200,8 @@ liquidity AS (
block_id,
block_timestamp,
tx_hash,
receipt_id,
event_index,
action_id,
rn,
contract_address,
from_address,
to_address,
@ -240,8 +240,8 @@ final_transfers AS (
block_timestamp,
block_id,
tx_hash,
receipt_id,
event_index,
action_id,
rn,
contract_address,
from_address,
to_address,
@ -250,7 +250,7 @@ final_transfers AS (
transfer_type,
_partition_by_block_number,
{{ dbt_utils.generate_surrogate_key(
['receipt_id', 'contract_address', 'amount_unadj', 'from_address', 'to_address', 'event_index']
['action_id', 'contract_address', 'amount_unadj', 'from_address', 'to_address', 'rn']
) }} AS transfers_complete_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,

View File

@ -25,11 +25,9 @@ models:
- name: RECEIPT_ID
description: "{{ doc('receipt_id')}}"
tests:
- not_null
- name: EVENT_INDEX
description: "The index of the event within the receipt, used to maintain order of events"
- name: RN
description: "{{ doc('event_index')}}"
tests:
- not_null
@ -40,8 +38,6 @@ models:
- name: FROM_ADDRESS
description: "{{ doc('from_address')}}"
tests:
- not_null
- name: TO_ADDRESS
description: "{{ doc('to_address')}}"
@ -55,8 +51,6 @@ models:
description: "{{ doc('amount_unadj')}}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_of_type:
column_type: FLOAT
- name: TRANSFER_TYPE
description: "{{ doc('transfer_type')}}"