From ed8beea3386a871f784295059b38db90081dc41c Mon Sep 17 00:00:00 2001 From: drethereum Date: Tue, 23 May 2023 08:38:00 -0600 Subject: [PATCH 1/7] updated readme and testing versions --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index dca43ef..66da103 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,22 @@ dbt run-operation create_udfs --var 'UPDATE_UDFS_AND_SPS": True' --args 'drop_:f dbt run-operation create_udfs --var 'UPDATE_UDFS_AND_SPS": True' --args 'drop_:true' ``` +## Adding Release Versions + +1. Make the necessary changes to your code in your dbt package repository (e.g., fsc-utils). +2. Commit your changes with `git add .` and `git commit -m "Your commit message"`. +3. Tag your commit with a version number using `git tag -a v1.1.0 -m "version 1.1.0"`. +4. Push your commits to the remote repository with `git push origin ...`. +5. Push your tags to the remote repository with `git push origin --tags`. +6. In the packages.yml file of your other dbt project, specify the new version of the package with: +``` +packages: + - git: "https://github.com/FlipsideCrypto/fsc-utils.git" + revision: "v1.1.0" +``` +7. Run dbt deps in the other dbt project to pull the specific version of the package or follow the steps on `adding the dbt package` below. + + ## Adding the `fsc_utils` dbt package The `fsc_utils` dbt package is a centralized repository consisting of various dbt macros and snowflake functions that can be utilized across other repos. From 2d0a9eb74927d163c20f526fe46d38d8767279ff Mon Sep 17 00:00:00 2001 From: drethereum Date: Tue, 23 May 2023 09:19:59 -0600 Subject: [PATCH 2/7] spacing --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 66da103..64b3cc6 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ dbt run-operation create_udfs --var 'UPDATE_UDFS_AND_SPS": True' --args 'drop_:t packages: - git: "https://github.com/FlipsideCrypto/fsc-utils.git" revision: "v1.1.0" -``` +``` 7. Run dbt deps in the other dbt project to pull the specific version of the package or follow the steps on `adding the dbt package` below. From 3d4b5ee29f1f3e2e795f967b86dcc38b6b48426a Mon Sep 17 00:00:00 2001 From: drethereum Date: Tue, 23 May 2023 09:43:22 -0600 Subject: [PATCH 3/7] spacing --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 64b3cc6..2be2b0d 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ dbt run-operation create_udfs --var 'UPDATE_UDFS_AND_SPS": True' --args 'drop_:t packages: - git: "https://github.com/FlipsideCrypto/fsc-utils.git" revision: "v1.1.0" -``` +``` 7. Run dbt deps in the other dbt project to pull the specific version of the package or follow the steps on `adding the dbt package` below. From a7cc6816e7acb8c7138319de00211013fe0cc31a Mon Sep 17 00:00:00 2001 From: drethereum Date: Tue, 23 May 2023 10:44:35 -0600 Subject: [PATCH 4/7] new functions --- macros/streamline/configs.yaml.sql | 22 +++++++++++++++++++ macros/streamline/functions.py.sql | 34 ++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/macros/streamline/configs.yaml.sql b/macros/streamline/configs.yaml.sql index 01c9eb5..86c8c69 100644 --- a/macros/streamline/configs.yaml.sql +++ b/macros/streamline/configs.yaml.sql @@ -95,6 +95,28 @@ sql: | {{ fsc_utils.sql_udf_json_rpc_call(False) }} +- name: {{ schema }}.udf_simple_event_name + signature: + - [abi, VARIANT] + return_type: TEXT + options: | + LANGUAGE PYTHON + RUNTIME_VERSION = '3.8' + HANDLER = 'get_simplified_signature' + sql: | + {{ fsc_utils.create_udf_simple_event_names() }} + +- name: {{ schema }}.udf_keccak + signature: + - [event_name, VARCHAR(255)] + return_type: TEXT + options: | + LANGUAGE PYTHON + RUNTIME_VERSION = '3.8' + PACKAGES = ('pycryptodome==3.15.0') + HANDLER = 'udf_encode' + sql: | + {{ fsc_utils.create_udf_keccak() }} {% endmacro %} diff --git a/macros/streamline/functions.py.sql b/macros/streamline/functions.py.sql index 7f3acbc..ca8aa0d 100644 --- a/macros/streamline/functions.py.sql +++ b/macros/streamline/functions.py.sql @@ -39,4 +39,38 @@ def hex_to_int(encoding, hex) -> str: return str(value) else: return str(int(hex, 16)) +{% endmacro %} + +{% macro create_udf_keccak() %} +from Crypto.Hash import keccak + +def udf_encode(event_name): + keccak_hash = keccak.new(digest_bits=256) + keccak_hash.update(event_name.encode('utf-8')) + return '0x' + keccak_hash.hexdigest() +{% endmacro %} + +{% macro create_udf_simple_event_names() %} + +def get_simplified_signature(abi): + def generate_signature(inputs): + signature_parts = [] + for input_data in inputs: + if 'components' in input_data: + component_signature_parts = [] + components = input_data['components'] + component_signature_parts.extend(generate_signature(components)) + component_signature_parts[-1] = component_signature_parts[-1].rstrip(",") + if input_data['type'].endswith('[]'): + signature_parts.append("(" + "".join(component_signature_parts) + ")[],") + else: + signature_parts.append("(" + "".join(component_signature_parts) + "),") + else: + signature_parts.append(input_data['type'].replace('enum ', '').replace(' payable', '') + ",") + return signature_parts + + signature_parts = [abi['name'] + "("] + signature_parts.extend(generate_signature(abi['inputs'])) + signature_parts[-1] = signature_parts[-1].rstrip(",") + ")" + return "".join(signature_parts) {% endmacro %} \ No newline at end of file From d53d89059102c247a5428dc70841c4d535ebf327 Mon Sep 17 00:00:00 2001 From: drethereum Date: Tue, 23 May 2023 10:55:21 -0600 Subject: [PATCH 5/7] indent --- macros/streamline/configs.yaml.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/macros/streamline/configs.yaml.sql b/macros/streamline/configs.yaml.sql index 86c8c69..dd18814 100644 --- a/macros/streamline/configs.yaml.sql +++ b/macros/streamline/configs.yaml.sql @@ -104,7 +104,7 @@ RUNTIME_VERSION = '3.8' HANDLER = 'get_simplified_signature' sql: | - {{ fsc_utils.create_udf_simple_event_names() }} + {{ fsc_utils.create_udf_simple_event_names() | indent(4) }} - name: {{ schema }}.udf_keccak signature: @@ -116,7 +116,7 @@ PACKAGES = ('pycryptodome==3.15.0') HANDLER = 'udf_encode' sql: | - {{ fsc_utils.create_udf_keccak() }} + {{ fsc_utils.create_udf_keccak() | indent(4) }} {% endmacro %} From e75c4effd72c466fa8d223c3f6357e3a60944c6c Mon Sep 17 00:00:00 2001 From: drethereum Date: Tue, 23 May 2023 11:25:09 -0600 Subject: [PATCH 6/7] rename new functions --- macros/streamline/configs.yaml.sql | 8 ++++---- macros/streamline/functions.py.sql | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/macros/streamline/configs.yaml.sql b/macros/streamline/configs.yaml.sql index dd18814..0f82e7d 100644 --- a/macros/streamline/configs.yaml.sql +++ b/macros/streamline/configs.yaml.sql @@ -95,7 +95,7 @@ sql: | {{ fsc_utils.sql_udf_json_rpc_call(False) }} -- name: {{ schema }}.udf_simple_event_name +- name: {{ schema }}.udf_evm_text_signature signature: - [abi, VARIANT] return_type: TEXT @@ -104,9 +104,9 @@ RUNTIME_VERSION = '3.8' HANDLER = 'get_simplified_signature' sql: | - {{ fsc_utils.create_udf_simple_event_names() | indent(4) }} + {{ fsc_utils.create_udf_evm_text_signature() | indent(4) }} -- name: {{ schema }}.udf_keccak +- name: {{ schema }}.udf_keccak256 signature: - [event_name, VARCHAR(255)] return_type: TEXT @@ -116,7 +116,7 @@ PACKAGES = ('pycryptodome==3.15.0') HANDLER = 'udf_encode' sql: | - {{ fsc_utils.create_udf_keccak() | indent(4) }} + {{ fsc_utils.create_udf_keccak256() | indent(4) }} {% endmacro %} diff --git a/macros/streamline/functions.py.sql b/macros/streamline/functions.py.sql index ca8aa0d..b095f3a 100644 --- a/macros/streamline/functions.py.sql +++ b/macros/streamline/functions.py.sql @@ -41,7 +41,7 @@ def hex_to_int(encoding, hex) -> str: return str(int(hex, 16)) {% endmacro %} -{% macro create_udf_keccak() %} +{% macro create_udf_keccak256() %} from Crypto.Hash import keccak def udf_encode(event_name): @@ -50,7 +50,7 @@ def udf_encode(event_name): return '0x' + keccak_hash.hexdigest() {% endmacro %} -{% macro create_udf_simple_event_names() %} +{% macro create_udf_evm_text_signature() %} def get_simplified_signature(abi): def generate_signature(inputs): From 2e1b717ebb40e619307213a7fd4ed6a8101e0310 Mon Sep 17 00:00:00 2001 From: drethereum Date: Tue, 23 May 2023 11:44:44 -0600 Subject: [PATCH 7/7] readme versioning --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 2be2b0d..a297482 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,13 @@ packages: ``` 7. Run dbt deps in the other dbt project to pull the specific version of the package or follow the steps on `adding the dbt package` below. +Regarding Semantic Versioning; +1. Semantic versioning is a versioning scheme for software that aims to convey meaning about the underlying changes with each new release. +2. It's typically formatted as MAJOR.MINOR.PATCH (e.g. v1.2.3), where: +- MAJOR version (first number) should increment when there are potential breaking or incompatible changes. +- MINOR version (second number) should increment when functionality or features are added in a backwards-compatible manner. +- PATCH version (third number) should increment when bug fixes are made without adding new features. +3. Semantic versioning helps package users understand the degree of changes in a new release, and decide when to adopt new versions. With dbt packages, when you tag a release with a semantic version, users can specify the exact version they want to use in their projects. ## Adding the `fsc_utils` dbt package