mirror of
https://github.com/FlipsideCrypto/osmosis-models.git
synced 2026-02-06 11:26:55 +00:00
AN-1371_msg sub group and body/auth info to txns (#35)
This commit is contained in:
parent
23d1d5119d
commit
51e3935630
@ -3,16 +3,20 @@
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
block_id,
|
||||
block_timestamp,
|
||||
blockchain,
|
||||
chain_id,
|
||||
tx_id,
|
||||
msg_group,
|
||||
msg_index,
|
||||
msg_type,
|
||||
attribute_index,
|
||||
attribute_key,
|
||||
attribute_value
|
||||
FROM
|
||||
{{ ref('silver__msg_attributes') }}
|
||||
block_id,
|
||||
block_timestamp,
|
||||
blockchain,
|
||||
chain_id,
|
||||
tx_id,
|
||||
CONCAT(
|
||||
msg_group,
|
||||
':',
|
||||
msg_sub_group
|
||||
) AS msg_group,
|
||||
msg_index,
|
||||
msg_type,
|
||||
attribute_index,
|
||||
attribute_key,
|
||||
attribute_value
|
||||
FROM
|
||||
{{ ref('silver__msg_attributes') }}
|
||||
|
||||
@ -3,15 +3,19 @@
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
block_id,
|
||||
block_timestamp,
|
||||
blockchain,
|
||||
chain_id,
|
||||
tx_id,
|
||||
tx_status,
|
||||
msg_group,
|
||||
msg_index,
|
||||
msg_type,
|
||||
block_id,
|
||||
block_timestamp,
|
||||
blockchain,
|
||||
chain_id,
|
||||
tx_id,
|
||||
tx_status,
|
||||
CONCAT(
|
||||
msg_group,
|
||||
':',
|
||||
msg_sub_group
|
||||
) AS msg_group,
|
||||
msg_index,
|
||||
msg_type,
|
||||
msg
|
||||
FROM
|
||||
{{ ref('silver__msgs') }}
|
||||
FROM
|
||||
{{ ref('silver__msgs') }}
|
||||
|
||||
5
models/descriptions/auth_info.md
Normal file
5
models/descriptions/auth_info.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs auth_info %}
|
||||
|
||||
The top level auth information for the transaction
|
||||
|
||||
{% enddocs %}
|
||||
@ -1,5 +1,5 @@
|
||||
{% docs msg_group %}
|
||||
|
||||
Numeric value grouping different messages together to represent a single action. NULL group means messages are related to the header (overall transaction)
|
||||
Value grouping different messages together to represent a single action. Format will include the numeric msg_group and msg_sub_group with a ":" seperator. The subgroup will always be 0 except for "Exec" actions. NULL group means messages are related to the header (overall transaction)
|
||||
|
||||
{% enddocs %}
|
||||
5
models/descriptions/msg_sub_group.md
Normal file
5
models/descriptions/msg_sub_group.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs msg_sub_group %}
|
||||
|
||||
Silver only -- Numeric value grouping different messages together to represent a single action within a group. This is relevent for exec actions that contain mutiple underlying actions. NULL sub group means messages are related to the header (overall transaction)
|
||||
|
||||
{% enddocs %}
|
||||
5
models/descriptions/silver_msg_group.md
Normal file
5
models/descriptions/silver_msg_group.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs silver_msg_group %}
|
||||
|
||||
Numeric value grouping different messages together to represent a single action. NULL group means messages are related to the header (overall transaction)
|
||||
|
||||
{% enddocs %}
|
||||
5
models/descriptions/tx_body.md
Normal file
5
models/descriptions/tx_body.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs tx_body %}
|
||||
|
||||
The top level transaction body for the transaction
|
||||
|
||||
{% enddocs %}
|
||||
@ -13,6 +13,7 @@ SELECT
|
||||
chain_id,
|
||||
tx_id,
|
||||
msg_group,
|
||||
msg_sub_group,
|
||||
msg_index,
|
||||
msg_type,
|
||||
b.index AS attribute_index,
|
||||
|
||||
@ -36,7 +36,9 @@ models:
|
||||
tests:
|
||||
- not_null
|
||||
- name: MSG_GROUP
|
||||
description: "{{ doc('msg_group') }}"
|
||||
description: "{{ doc('silver_msg_group') }}"
|
||||
- name: MSG_SUB_GROUP
|
||||
description: "{{ doc('msg_sub_group') }}"
|
||||
- name: MSG_INDEX
|
||||
description: "{{ doc('msg_index') }}"
|
||||
tests:
|
||||
|
||||
@ -25,32 +25,113 @@ WITH b AS (
|
||||
TRUE,
|
||||
FALSE
|
||||
) AS is_action,
|
||||
IFF(
|
||||
TRY_BASE64_DECODE_STRING(
|
||||
msg :attributes [0] :key :: STRING
|
||||
) = 'module',
|
||||
TRUE,
|
||||
FALSE
|
||||
) AS is_module,
|
||||
TRY_BASE64_DECODE_STRING(
|
||||
msg :attributes [0] :key :: STRING
|
||||
) attribute_key,
|
||||
TRY_BASE64_DECODE_STRING(
|
||||
msg :attributes [0] :value :: STRING
|
||||
) attribute_value,
|
||||
_ingested_at
|
||||
FROM
|
||||
{{ ref('silver__transactions') }} A,
|
||||
LATERAL FLATTEN(input => A.msgs)
|
||||
LATERAL FLATTEN(
|
||||
input => A.msgs
|
||||
)
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
_ingested_at :: DATE >= CURRENT_DATE - 2
|
||||
{% endif %}
|
||||
),
|
||||
prefinal AS (
|
||||
SELECT
|
||||
block_id,
|
||||
block_timestamp,
|
||||
blockchain,
|
||||
chain_id,
|
||||
tx_id,
|
||||
tx_status,
|
||||
NULLIF(
|
||||
(conditional_true_event(is_action) over (PARTITION BY tx_id
|
||||
ORDER BY
|
||||
msg_index) -1),
|
||||
-1
|
||||
) AS msg_group,
|
||||
msg_index,
|
||||
msg_type,
|
||||
msg,
|
||||
is_module,
|
||||
attribute_key,
|
||||
attribute_value,
|
||||
_ingested_at
|
||||
FROM
|
||||
b
|
||||
),
|
||||
exec_actions AS (
|
||||
SELECT
|
||||
DISTINCT tx_id,
|
||||
msg_group
|
||||
FROM
|
||||
prefinal
|
||||
WHERE
|
||||
msg_type = 'message'
|
||||
AND attribute_key = 'action'
|
||||
AND LOWER(attribute_value) LIKE '%exec%'
|
||||
),
|
||||
grp AS (
|
||||
SELECT
|
||||
A.tx_id,
|
||||
A.msg_index,
|
||||
RANK() over(
|
||||
PARTITION BY A.tx_id,
|
||||
A.msg_group
|
||||
ORDER BY
|
||||
A.msg_index
|
||||
) -1 msg_sub_group
|
||||
FROM
|
||||
prefinal A
|
||||
JOIN exec_actions b
|
||||
ON A.tx_id = b.tx_id
|
||||
AND A.msg_group = b.msg_group
|
||||
WHERE
|
||||
A.is_module = TRUE
|
||||
AND A.msg_type = 'message'
|
||||
)
|
||||
SELECT
|
||||
block_id,
|
||||
block_timestamp,
|
||||
blockchain,
|
||||
chain_id,
|
||||
tx_id,
|
||||
A.tx_id,
|
||||
tx_status,
|
||||
NULLIF(
|
||||
(conditional_true_event(is_action) over (PARTITION BY tx_id
|
||||
ORDER BY
|
||||
msg_index) -1),
|
||||
-1
|
||||
) AS msg_group,
|
||||
msg_index,
|
||||
msg_group,
|
||||
CASE
|
||||
WHEN msg_group IS NULL THEN NULL
|
||||
ELSE COALESCE(
|
||||
LAST_VALUE(
|
||||
b.msg_sub_group ignore nulls
|
||||
) over(
|
||||
PARTITION BY A.tx_id,
|
||||
msg_group
|
||||
ORDER BY
|
||||
A.msg_index DESC rows unbounded preceding
|
||||
),
|
||||
0
|
||||
)
|
||||
END AS msg_sub_group,
|
||||
A.msg_index,
|
||||
msg_type,
|
||||
msg,
|
||||
_ingested_at
|
||||
FROM
|
||||
b
|
||||
prefinal A
|
||||
LEFT JOIN grp b
|
||||
ON A.tx_id = b.tx_id
|
||||
AND A.msg_index = b.msg_index
|
||||
|
||||
@ -37,7 +37,9 @@ models:
|
||||
tests:
|
||||
- not_null
|
||||
- name: MSG_GROUP
|
||||
description: "{{ doc('msg_group') }}"
|
||||
description: "{{ doc('silver_msg_group') }}"
|
||||
- name: MSG_SUB_GROUP
|
||||
description: "{{ doc('msg_sub_group') }}"
|
||||
- name: MSG_INDEX
|
||||
description: "{{ doc('msg_index') }}"
|
||||
tests:
|
||||
|
||||
@ -59,7 +59,7 @@ models:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
- name: MSG_GROUP
|
||||
description: "{{ doc('msg_group') }}"
|
||||
description: "{{ doc('silver_msg_group') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: DELEGATOR_ADDRESS
|
||||
|
||||
@ -59,7 +59,7 @@ models:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
- name: MSG_GROUP
|
||||
description: "{{ doc('msg_group') }}"
|
||||
description: "{{ doc('silver_msg_group') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: DELEGATOR_ADDRESS
|
||||
|
||||
@ -20,6 +20,8 @@ SELECT
|
||||
END AS tx_status,
|
||||
tx :tx_result :code :: INT tx_code,
|
||||
tx :tx_result :events AS msgs,
|
||||
tx :auth_info AS auth_info,
|
||||
tx :body AS tx_body,
|
||||
ingested_at AS _ingested_at
|
||||
FROM
|
||||
{{ ref('bronze__transactions') }}
|
||||
|
||||
@ -67,6 +67,10 @@ models:
|
||||
description: "The underlying json from the messages or events within the transactions"
|
||||
tests:
|
||||
- not_null
|
||||
- name: AUTH_INFO
|
||||
description: "{{ doc('auth_info') }}"
|
||||
- name: TX_BODY
|
||||
description: "{{ doc('tx_body') }}"
|
||||
- name: _INGESTED_AT
|
||||
description: "{{ doc('ingested_at') }}"
|
||||
tests:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user