1616
1717DROP VIEW IF EXISTS {SCHEMA_NAME}.user_activities CASCADE;
1818CREATE VIEW {SCHEMA_NAME}.user_activities AS
19- WITH execution_outcomes_prep AS (
20- SELECT
21- receipt_id
22- , status
23- , logs
24- FROM {SCHEMA_NAME}.execution_outcomes
25- )
26- , receipt_actions_prep AS (
19+ WITH receipt_actions_prep AS (
2720 SELECT
2821 decode(ra .args_base64 , ' base64' ) AS args_decoded
2922 , CASE
@@ -35,10 +28,11 @@ WITH execution_outcomes_prep AS (
3528 , eo .logs AS logs
3629 , ra.*
3730 FROM {SCHEMA_NAME}.receipt_actions AS ra
38- LEFT JOIN execution_outcomes_prep AS eo
31+ LEFT JOIN {SCHEMA_NAME}.execution_outcomes AS eo
3932 ON ra .receipt_id = eo .receipt_id
4033 WHERE
4134 ra .action_kind = ' FunctionCall'
35+ AND ra .method_name IN (' on_lockup_deployed' , ' lock_near' , ' on_lockup_update' , ' delegate_all' , ' undelegate' , ' begin_unlock_near' , ' lock_pending_near' )
4236)
4337-- ------------------
4438-- Account Creation--
@@ -58,8 +52,8 @@ WITH execution_outcomes_prep AS (
5852 , ra .signer_account_id AS account_id
5953 , ra .predecessor_id AS hos_contract_address
6054 , CASE
61- WHEN safe_json_parse(CONVERT_FROM(DECODE( ra .args_base64 , ' base64 ' ) , ' UTF8' ))- >> ' error' IS NULL
62- THEN (safe_json_parse(CONVERT_FROM(DECODE( ra .args_base64 , ' base64 ' ) , ' UTF8' ))- >> ' lockup_deposit' )::NUMERIC
55+ WHEN safe_json_parse(CONVERT_FROM(ra .args_decoded , ' UTF8' ))- >> ' error' IS NULL
56+ THEN (safe_json_parse(CONVERT_FROM(ra .args_decoded , ' UTF8' ))- >> ' lockup_deposit' )::NUMERIC
6357 ELSE NULL
6458 END AS near_amount
6559 , CASE
@@ -94,9 +88,9 @@ WITH execution_outcomes_prep AS (
9488 , ra .event_status
9589 , ra .signer_account_id AS account_id
9690 , SUBSTRING (ra .receiver_id FROM POSITION(' .' IN ra .receiver_id ) + 1 ) AS hos_contract_address
97- , CASE
98- WHEN safe_json_parse(CONVERT_FROM(DECODE( ra .args_base64 , ' base64 ' ) , ' UTF8' ))- >> ' error' IS NULL
99- THEN (safe_json_parse(CONVERT_FROM(DECODE( ra .args_base64 , ' base64 ' ) , ' UTF8' ))- >> ' amount' )::NUMERIC
91+ , CASE
92+ WHEN safe_json_parse(CONVERT_FROM(ra .args_decoded , ' UTF8' ))- >> ' error' IS NULL
93+ THEN (safe_json_parse(CONVERT_FROM(ra .args_decoded , ' UTF8' ))- >> ' amount' )::NUMERIC
10094 ELSE NULL
10195 END AS near_amount
10296 , CASE
@@ -229,8 +223,8 @@ WITH execution_outcomes_prep AS (
229223 , ra .signer_account_id AS account_id
230224 , SUBSTRING (ra .receiver_id FROM POSITION(' .' IN ra .receiver_id ) + 1 ) AS hos_contract_address
231225 , CASE
232- WHEN safe_json_parse(CONVERT_FROM(DECODE( ra .args_base64 , ' base64 ' ) , ' UTF8' ))- >> ' error' IS NULL
233- THEN (safe_json_parse(CONVERT_FROM(DECODE( ra .args_base64 , ' base64 ' ) , ' UTF8' ))- >> ' amount' )::NUMERIC
226+ WHEN safe_json_parse(CONVERT_FROM(ra .args_decoded , ' UTF8' ))- >> ' error' IS NULL
227+ THEN (safe_json_parse(CONVERT_FROM(ra .args_decoded , ' UTF8' ))- >> ' amount' )::NUMERIC
234228 ELSE NULL
235229 END AS near_amount
236230 , NULL ::NUMERIC AS locked_near_balance -- There ARE NO logs FOR this event_type
@@ -258,8 +252,8 @@ WITH execution_outcomes_prep AS (
258252 , ra .signer_account_id AS account_id
259253 , SUBSTRING (ra .receiver_id FROM POSITION(' .' IN ra .receiver_id ) + 1 ) AS hos_contract_address
260254 , CASE
261- WHEN safe_json_parse(CONVERT_FROM(DECODE( ra .args_base64 , ' base64 ' ) , ' UTF8' ))- >> ' error' IS NULL
262- THEN (safe_json_parse(CONVERT_FROM(DECODE( ra .args_base64 , ' base64 ' ) , ' UTF8' ))- >> ' amount' )::NUMERIC
255+ WHEN safe_json_parse(CONVERT_FROM(ra .args_decoded , ' UTF8' ))- >> ' error' IS NULL
256+ THEN (safe_json_parse(CONVERT_FROM(ra .args_decoded , ' UTF8' ))- >> ' amount' )::NUMERIC
263257 ELSE NULL
264258 END AS near_amount
265259 , NULL ::NUMERIC AS locked_near_balance -- There ARE NO logs FOR this event_type
0 commit comments