-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added modified PARSE_ABI_FUNCTIONS and PARSE_ABI_EVENTS udf functions #1
base: main
Are you sure you want to change the base?
Conversation
This function takes a dune_name and abi string and returns an array of each function in the abi. I use it within a decode contracts dbt model which creates a the information needed to create decoded views of contracts for dune compatibility. Differences are: 1. Adds the dune name 2. Maps the ABI types to BQ types 3. If there is no name for the inputs or outputs, the name is "input_number" or "output_number"
This function takes a dune_name and abi string and returns an array of each event in the abi. I use it within a decode contracts dbt model which creates a the information needed to create decoded views of contracts for dune compatibility. Differences are: 1. Adds the dune name 2. Maps the ABI types to BQ types 3. If there is no name for the inputs, the name is "input_number"
"uint16[]": "INT64", | ||
"uint8[]": "INT64", | ||
"uint64[]": "INT64", | ||
"uint128[]": "INT64", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Above int64 please use string to avoid precision loss
"uint16[]": "INT64", | ||
"uint8[]": "INT64", | ||
"uint64[]": "INT64", | ||
"uint128[]": "INT64", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Above int64 please use string to avoid precision loss
@@ -0,0 +1,81 @@ | |||
CREATE OR REPLACE FUNCTION `blocktrekker.udfs.PARSE_ABI_EVENTS`(abi STRING, dune_name STRING) RETURNS ARRAY<STRUCT<name STRING, anonymous BOOL, hash_id STRING, inputs STRING, types STRING>> LANGUAGE js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Factor out blocktrekker.udfs
to $UDF_PROJECT.$UDF_DATASET
using DECLARE.
Rename dune_name to contract_prefix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merge this file with the base file from which it is cloned
|
||
abi.forEach(function(x){ | ||
tuple = []; | ||
tuple['name'] = dune_name + "_evt_" + x.name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guard against dune_name is null with a default value
if (y.type in typeMap) { | ||
pair.type = typeMap[y.type]; | ||
} else { | ||
if (y.type.slice(0, 4).toLowerCase() === "uint") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to throw an error on unknown types
if (y.type.slice(0, 4).toLowerCase() === "uint") { | ||
pair.type = "BIGNUMERIC"; | ||
} else { | ||
pair.type = "STRING"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise. Throw.
sql/PARSE_ABI_FUNCTIONS_UDF.sql
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merge into base file
These were modified to allow for integration with the decode_projects.sql file the dbt project decoding contracts.
Please feel free to rebuke any and all aspects of files or this pull request, as I am truly a rookie :)