mirror of
https://github.com/FlipsideCrypto/near-models.git
synced 2026-02-06 11:26:52 +00:00
modified usn table
This commit is contained in:
parent
85b0f21e98
commit
d6b374949f
243
data.json
243
data.json
@ -1,243 +0,0 @@
|
||||
{
|
||||
"actions": [
|
||||
{
|
||||
"FunctionCall": {
|
||||
"args": "eyJhbW91bnQiOiIxMDAwMDAwMCIsInJlY2VpdmVyX2lkIjoidXNuMS5uZWFyIn0=",
|
||||
"deposit": "1",
|
||||
"gas": 30000000000000,
|
||||
"method_name": "ft_transfer"
|
||||
}
|
||||
}
|
||||
],
|
||||
"hash": "SoGCFuZggxKNyBVqPcZo5TydP7E9cJ371otR85y4e8v",
|
||||
"nonce": 60115413000004,
|
||||
"outcome": {
|
||||
"block_hash": "JDBag9RRGqmFNxi86FKkn73effLfBnjDDLS26yMcVmbL",
|
||||
"id": "SoGCFuZggxKNyBVqPcZo5TydP7E9cJ371otR85y4e8v",
|
||||
"outcome": {
|
||||
"executor_id": "eb712b03ea457877fec784e3736c25c7317a00d744f55f7a717c8b058090c050",
|
||||
"gas_burnt": 2428050684172,
|
||||
"logs": [],
|
||||
"metadata": {
|
||||
"gas_profile": null,
|
||||
"version": 1
|
||||
},
|
||||
"receipt_ids": [
|
||||
"EkrhpRaD8jMq8FL9SA77aYChr6gjdN2YmPZWF9c5kkTz"
|
||||
],
|
||||
"status": {
|
||||
"SuccessReceiptId": "EkrhpRaD8jMq8FL9SA77aYChr6gjdN2YmPZWF9c5kkTz"
|
||||
},
|
||||
"tokens_burnt": "242805068417200000000"
|
||||
},
|
||||
"proof": [
|
||||
{
|
||||
"direction": "Left",
|
||||
"hash": "J7WfqvcZUHma1HobB4LdAEPYH4SvYS4UFU445r6TEpqy"
|
||||
},
|
||||
{
|
||||
"direction": "Right",
|
||||
"hash": "67Nwwh9siDgat8ae7bpf7QBuvGTt5bLWthnMEwy46LGK"
|
||||
},
|
||||
{
|
||||
"direction": "Right",
|
||||
"hash": "8AcCPaF3MVLScmGQcJhXNQFmh2zorb7AoDGQSTuDHvxu"
|
||||
}
|
||||
]
|
||||
},
|
||||
"public_key": "ed25519:9VuxvBzTpqUY1BHssDsLynK1rBd9n9uB4EDk3MmgWF6X",
|
||||
"receipt": [
|
||||
{
|
||||
"block_hash": "CwCuuyjpAGcj9tHcHSSbwrzB7qQWeqPWXUqR6rUXW666",
|
||||
"id": "EkrhpRaD8jMq8FL9SA77aYChr6gjdN2YmPZWF9c5kkTz",
|
||||
"outcome": {
|
||||
"executor_id": "usn",
|
||||
"gas_burnt": 5018083181965,
|
||||
"logs": [
|
||||
"EVENT_JSON:{\"standard\":\"nep141\",\"version\":\"1.0.0\",\"event\":\"ft_transfer\",\"data\":[{\"old_owner_id\":\"eb712b03ea457877fec784e3736c25c7317a00d744f55f7a717c8b058090c050\",\"new_owner_id\":\"usn1.near\",\"amount\":\"10000000\"}]}"
|
||||
],
|
||||
"metadata": {
|
||||
"gas_profile": [
|
||||
{
|
||||
"cost": "BASE",
|
||||
"cost_category": "WASM_HOST_COST",
|
||||
"gas_used": "9002115774"
|
||||
},
|
||||
{
|
||||
"cost": "CONTRACT_COMPILE_BASE",
|
||||
"cost_category": "WASM_HOST_COST",
|
||||
"gas_used": "35445963"
|
||||
},
|
||||
{
|
||||
"cost": "CONTRACT_COMPILE_BYTES",
|
||||
"cost_category": "WASM_HOST_COST",
|
||||
"gas_used": "68359265250"
|
||||
},
|
||||
{
|
||||
"cost": "LOG_BASE",
|
||||
"cost_category": "WASM_HOST_COST",
|
||||
"gas_used": "3543313050"
|
||||
},
|
||||
{
|
||||
"cost": "LOG_BYTE",
|
||||
"cost_category": "WASM_HOST_COST",
|
||||
"gas_used": "2798143692"
|
||||
},
|
||||
{
|
||||
"cost": "READ_MEMORY_BASE",
|
||||
"cost_category": "WASM_HOST_COST",
|
||||
"gas_used": "31318358400"
|
||||
},
|
||||
{
|
||||
"cost": "READ_MEMORY_BYTE",
|
||||
"cost_category": "WASM_HOST_COST",
|
||||
"gas_used": "2630522436"
|
||||
},
|
||||
{
|
||||
"cost": "READ_REGISTER_BASE",
|
||||
"cost_category": "WASM_HOST_COST",
|
||||
"gas_used": "25171651860"
|
||||
},
|
||||
{
|
||||
"cost": "READ_REGISTER_BYTE",
|
||||
"cost_category": "WASM_HOST_COST",
|
||||
"gas_used": "44648586"
|
||||
},
|
||||
{
|
||||
"cost": "STORAGE_READ_BASE",
|
||||
"cost_category": "WASM_HOST_COST",
|
||||
"gas_used": "281784228750"
|
||||
},
|
||||
{
|
||||
"cost": "STORAGE_READ_KEY_BYTE",
|
||||
"cost_category": "WASM_HOST_COST",
|
||||
"gas_used": "6995272458"
|
||||
},
|
||||
{
|
||||
"cost": "STORAGE_READ_VALUE_BYTE",
|
||||
"cost_category": "WASM_HOST_COST",
|
||||
"gas_used": "1021202910"
|
||||
},
|
||||
{
|
||||
"cost": "STORAGE_WRITE_BASE",
|
||||
"cost_category": "WASM_HOST_COST",
|
||||
"gas_used": "192590208000"
|
||||
},
|
||||
{
|
||||
"cost": "STORAGE_WRITE_EVICTED_BYTE",
|
||||
"cost_category": "WASM_HOST_COST",
|
||||
"gas_used": "5331472962"
|
||||
},
|
||||
{
|
||||
"cost": "STORAGE_WRITE_KEY_BYTE",
|
||||
"cost_category": "WASM_HOST_COST",
|
||||
"gas_used": "6202492296"
|
||||
},
|
||||
{
|
||||
"cost": "STORAGE_WRITE_VALUE_BYTE",
|
||||
"cost_category": "WASM_HOST_COST",
|
||||
"gas_used": "5149077474"
|
||||
},
|
||||
{
|
||||
"cost": "TOUCHING_TRIE_NODE",
|
||||
"cost_category": "WASM_HOST_COST",
|
||||
"gas_used": "1755113195934"
|
||||
},
|
||||
{
|
||||
"cost": "UTF8_DECODING_BASE",
|
||||
"cost_category": "WASM_HOST_COST",
|
||||
"gas_used": "3111779061"
|
||||
},
|
||||
{
|
||||
"cost": "UTF8_DECODING_BYTE",
|
||||
"cost_category": "WASM_HOST_COST",
|
||||
"gas_used": "61815061548"
|
||||
},
|
||||
{
|
||||
"cost": "WASM_INSTRUCTION",
|
||||
"cost_category": "WASM_HOST_COST",
|
||||
"gas_used": "62143583436"
|
||||
},
|
||||
{
|
||||
"cost": "WRITE_MEMORY_BASE",
|
||||
"cost_category": "WASM_HOST_COST",
|
||||
"gas_used": "30841743471"
|
||||
},
|
||||
{
|
||||
"cost": "WRITE_MEMORY_BYTE",
|
||||
"cost_category": "WASM_HOST_COST",
|
||||
"gas_used": "1277449068"
|
||||
},
|
||||
{
|
||||
"cost": "WRITE_REGISTER_BASE",
|
||||
"cost_category": "WASM_HOST_COST",
|
||||
"gas_used": "31520747346"
|
||||
},
|
||||
{
|
||||
"cost": "WRITE_REGISTER_BYTE",
|
||||
"cost_category": "WASM_HOST_COST",
|
||||
"gas_used": "2231518068"
|
||||
}
|
||||
],
|
||||
"version": 1
|
||||
},
|
||||
"receipt_ids": [
|
||||
"5oZVqWnmPpSLXCWDKg9eoZ2pPC4G2L8rn9AtGsujvqdC"
|
||||
],
|
||||
"status": {
|
||||
"SuccessValue": ""
|
||||
},
|
||||
"tokens_burnt": "501808318196500000000"
|
||||
},
|
||||
"proof": [
|
||||
{
|
||||
"direction": "Right",
|
||||
"hash": "4hu7gkTGmT4jM2p9vD6AKhb9qB2JgsLyEMYwLRzoJh1g"
|
||||
},
|
||||
{
|
||||
"direction": "Left",
|
||||
"hash": "4KDEFpjxUtEZuv1kx7iTMH8BopBGQpBD14mFhtXLjEwJ"
|
||||
},
|
||||
{
|
||||
"direction": "Right",
|
||||
"hash": "BGPPRFkgYF9TpQWXShiQFCDw1rEjyZKCKB5UgEMShK72"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"block_hash": "DgmxHxDTRcUkopTumEWQjYXFALmBA3W45utE1mPGXBnf",
|
||||
"id": "5oZVqWnmPpSLXCWDKg9eoZ2pPC4G2L8rn9AtGsujvqdC",
|
||||
"outcome": {
|
||||
"executor_id": "eb712b03ea457877fec784e3736c25c7317a00d744f55f7a717c8b058090c050",
|
||||
"gas_burnt": 424555062500,
|
||||
"logs": [],
|
||||
"metadata": {
|
||||
"gas_profile": [],
|
||||
"version": 1
|
||||
},
|
||||
"receipt_ids": [],
|
||||
"status": {
|
||||
"SuccessValue": ""
|
||||
},
|
||||
"tokens_burnt": "0"
|
||||
},
|
||||
"proof": [
|
||||
{
|
||||
"direction": "Left",
|
||||
"hash": "5G1SZLHtYxVSgaJTxDzgMwDZCmMXuGqqD64FEf4U96fZ"
|
||||
},
|
||||
{
|
||||
"direction": "Right",
|
||||
"hash": "C91xThtgMZiW4NStvBSTCzAyMwRdvQF2ZjUDd8r1yrpN"
|
||||
},
|
||||
{
|
||||
"direction": "Right",
|
||||
"hash": "DHZQLUcTbjBWvB1h6L15DQcijdUGHyz4KzXetLNxoPJY"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"receiver_id": "usn",
|
||||
"signature": "ed25519:29phPrYyBucsiKevoqYeVXZzfbR1BU6rnopvCRucGxQDuewADzAnrd9Bb5LFrTRfsx3cGS8Lx9isD3zaLVXPu7sV",
|
||||
"signer_id": "eb712b03ea457877fec784e3736c25c7317a00d744f55f7a717c8b058090c050"
|
||||
}
|
||||
@ -13,11 +13,11 @@ WITH transactions AS (
|
||||
SELECT
|
||||
block_timestamp,
|
||||
block_id,
|
||||
method_names,
|
||||
tx_hash,
|
||||
tx_receiver,
|
||||
tx_signer,
|
||||
tx_status,
|
||||
status,
|
||||
event,
|
||||
from_address,
|
||||
to_address,
|
||||
amount
|
||||
FROM
|
||||
transactions
|
||||
|
||||
@ -4,10 +4,6 @@ models:
|
||||
- name: core__ez_usn_supply
|
||||
description: |-
|
||||
This table records all the usn transaction in the near db
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- tx_hash
|
||||
|
||||
columns:
|
||||
- name: BLOCK_TIMESTAMP
|
||||
@ -27,8 +23,8 @@ models:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
|
||||
- name: METHOD_NAMES
|
||||
description: "{{ doc('method_names')}}"
|
||||
- name: STATUS
|
||||
description: "{{ doc('tx_status')}}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
@ -45,8 +41,8 @@ models:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: TX_RECEIVER
|
||||
description: "{{ doc('tx_receiver')}}"
|
||||
- name: FROM_ADDRESS
|
||||
description: "{{ doc('from_address')}}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
@ -54,17 +50,16 @@ models:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: TX_SIGNER
|
||||
description: "{{ doc('tx_signer')}}"
|
||||
- name: TO_ADDRESS
|
||||
description: "{{ doc('to_address')}}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: TX_STATUS
|
||||
description: "{{ doc('tx_status')}}"
|
||||
- name: EVENT
|
||||
description: "{{ doc('event')}}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
@ -79,4 +74,4 @@ models:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- FLOAT
|
||||
8
models/descriptions/event.md
Normal file
8
models/descriptions/event.md
Normal file
@ -0,0 +1,8 @@
|
||||
{% docs event %}
|
||||
|
||||
The specific event of the transaction.
|
||||
f_transfer - mainly contains swap transactions involving usn.
|
||||
ft_mint - event that indicates when a new usn token is created.
|
||||
ft_burn - event that indicates when usn is burnt.
|
||||
|
||||
{% enddocs %}
|
||||
5
models/descriptions/from_address.md
Normal file
5
models/descriptions/from_address.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs from_address %}
|
||||
|
||||
The address the sends the token.
|
||||
|
||||
{% enddocs %}
|
||||
5
models/descriptions/to_address.md
Normal file
5
models/descriptions/to_address.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs to_address %}
|
||||
|
||||
The receiver of usn token.
|
||||
|
||||
{% enddocs %}
|
||||
@ -29,7 +29,9 @@ logs AS (
|
||||
REGEXP_SUBSTR(
|
||||
status_value,
|
||||
'Success'
|
||||
) AS reg_success
|
||||
) AS reg_success,
|
||||
_ingested_at,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
txs,
|
||||
TABLE(FLATTEN(input => logs))
|
||||
@ -54,7 +56,9 @@ FINAL AS (
|
||||
VALUE :owner_id,
|
||||
VALUE :old_owner_id
|
||||
) :: STRING AS from_address,
|
||||
VALUE :new_owner_id :: STRING AS to_address
|
||||
VALUE :new_owner_id :: STRING AS to_address,
|
||||
_ingested_at,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
logs,
|
||||
TABLE(FLATTEN(input => data_log))
|
||||
|
||||
@ -4,11 +4,7 @@ models:
|
||||
- name: silver__usn_supply
|
||||
description: |-
|
||||
This table records all the usn transaction in the near db
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- tx_hash
|
||||
|
||||
|
||||
columns:
|
||||
- name: BLOCK_TIMESTAMP
|
||||
description: "{{ doc('block_timestamp')}}"
|
||||
@ -27,8 +23,8 @@ models:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
|
||||
- name: METHOD_NAMES
|
||||
description: "{{ doc('method_names')}}"
|
||||
- name: STATUS
|
||||
description: "{{ doc('tx_status')}}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
@ -45,8 +41,8 @@ models:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: TX_RECEIVER
|
||||
description: "{{ doc('tx_receiver')}}"
|
||||
- name: FROM_ADDRESS
|
||||
description: "{{ doc('from_address')}}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
@ -54,8 +50,16 @@ models:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: TX_SIGNER
|
||||
description: "{{ doc('tx_signer')}}"
|
||||
- name: TO_ADDRESS
|
||||
description: "{{ doc('to_address')}}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: EVENT
|
||||
description: "{{ doc('event')}}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
@ -63,16 +67,6 @@ models:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: TX_STATUS
|
||||
description: "{{ doc('tx_status')}}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
|
||||
- name: AMOUNT
|
||||
description: "{{ doc('amount')}}"
|
||||
tests:
|
||||
|
||||
28
schema.md
28
schema.md
@ -1,28 +0,0 @@
|
||||
buyer - receiver-id
|
||||
seller - tx-signer/sendser-id
|
||||
platform - tx-receiver
|
||||
price - amount
|
||||
tx status - tx_status
|
||||
network fee - tx fee
|
||||
currency
|
||||
nft address
|
||||
nft project, if available
|
||||
nft id, if available
|
||||
platform fee or royalty, if available
|
||||
platform contract and/or version, if available
|
||||
|
||||
|
||||
buyer - receiver_id*
|
||||
seller - tx-signer/sender-id*
|
||||
tx status - tx_status*
|
||||
nft project - tx_receiver
|
||||
nft id - token-id
|
||||
network fee - tx fee
|
||||
|
||||
|
||||
platform - nft-collection - NA
|
||||
currency - not determined
|
||||
price - amount
|
||||
nft_address- not available, token-id fits the profile
|
||||
platform fee or royalty, not available
|
||||
platform contract and/or version, not available
|
||||
161
shema.sql
161
shema.sql
@ -1,161 +0,0 @@
|
||||
WITH txs AS (
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
{{ ref('silver__transactions') }}
|
||||
WHERE
|
||||
{{ incremental_load_filter('_inserted_timestamp') }}
|
||||
),
|
||||
usn_tx AS (
|
||||
SELECT
|
||||
block_id,
|
||||
tx_hash,
|
||||
block_timestamp,
|
||||
tx_receiver,
|
||||
tx_signer,
|
||||
tx,
|
||||
tx: actions[0]: FunctionCall: method_name :: STRING AS method_names,
|
||||
_ingested_at,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
txs
|
||||
WHERE
|
||||
tx_receiver = 'usn'
|
||||
OR tx_signer = 'usn'
|
||||
),
|
||||
|
||||
transfer_call_withdraw_events AS (
|
||||
SELECT
|
||||
block_id,
|
||||
tx_hash,
|
||||
block_timestamp,
|
||||
tx_receiver,
|
||||
tx_signer,
|
||||
tx,
|
||||
method_names,
|
||||
tx: receipt[0]: outcome: logs :: VARIANT AS events,
|
||||
_ingested_at,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
usn_tx
|
||||
WHERE
|
||||
method_names = 'ft_transfer_call'
|
||||
OR method_names = 'withdraw'
|
||||
),
|
||||
buy_sell_events AS (
|
||||
SELECT
|
||||
block_id,
|
||||
tx_hash,
|
||||
block_timestamp,
|
||||
tx_receiver,
|
||||
tx_signer,
|
||||
method_names,
|
||||
tx,
|
||||
tx: receipt[3]: outcome: logs :: VARIANT AS events,
|
||||
_ingested_at,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
usn_tx
|
||||
WHERE
|
||||
method_names = 'buy'
|
||||
OR method_names = 'sell'
|
||||
),
|
||||
parse_buy_sell_event AS (
|
||||
SELECT
|
||||
block_timestamp,
|
||||
block_id,
|
||||
tx_hash,
|
||||
tx_receiver,
|
||||
tx_signer,
|
||||
method_names,
|
||||
flatten_events.value AS events,
|
||||
_ingested_at,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
buy_sell_events,
|
||||
LATERAL FLATTEN(
|
||||
input => buy_sell_events.events
|
||||
) AS flatten_events
|
||||
),
|
||||
parse_transfer_withdraw_event AS (
|
||||
SELECT
|
||||
block_timestamp,
|
||||
block_id,
|
||||
tx_hash,
|
||||
tx_receiver,
|
||||
tx_signer,
|
||||
method_names,
|
||||
flatten_events.value AS events,
|
||||
_ingested_at,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
transfer_call_withdraw_events,
|
||||
LATERAL FLATTEN(
|
||||
input => transfer_call_withdraw_events.events
|
||||
) AS flatten_events
|
||||
),
|
||||
combined AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
parse_buy_sell_event
|
||||
UNION
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
parse_transfer_withdraw_event
|
||||
),
|
||||
extract_events_logs AS (
|
||||
SELECT
|
||||
block_timestamp,
|
||||
block_id,
|
||||
tx_hash,
|
||||
tx_receiver,
|
||||
tx_signer,
|
||||
method_names,
|
||||
SUBSTR(
|
||||
events,
|
||||
12,
|
||||
1000
|
||||
) AS event_string,
|
||||
_ingested_at,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
combined
|
||||
),
|
||||
extract_logs_data AS (
|
||||
SELECT
|
||||
block_timestamp,
|
||||
block_id,
|
||||
tx_hash,
|
||||
tx_receiver,
|
||||
tx_signer,
|
||||
method_names,
|
||||
PARSE_JSON(event_string) AS event_data,
|
||||
_ingested_at,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
extract_events_logs
|
||||
),
|
||||
FINAL AS (
|
||||
SELECT
|
||||
block_timestamp,
|
||||
block_id,
|
||||
tx_hash,
|
||||
tx_receiver,
|
||||
tx_signer,
|
||||
method_names,
|
||||
event_data: data[0]: amount :: DOUBLE / pow(
|
||||
10,
|
||||
18
|
||||
) AS amount,
|
||||
_ingested_at,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
extract_logs_data
|
||||
)
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
FINAL
|
||||
Loading…
Reference in New Issue
Block a user