Skip to content
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

fix: update checks for old format #6

Merged
merged 4 commits into from
Apr 30, 2024
Merged

Conversation

frazarshad
Copy link
Collaborator

@frazarshad frazarshad commented Apr 29, 2024

Fixes: #1
This PR fixes the attribute checks in the handleStateChangeEvent function.

It checks for another format of the event.attributes property which contains different values for the key property and different encoding for the values

This now results in psm.Governances of all tokens to be indexed
image

How to test:
set startBlock and endBlock to 9813445 and 9813490 respectively and start with yarn dev

@frazarshad frazarshad changed the title fix: update checks for attribute keys fix: update checks for old format Apr 29, 2024
@@ -23,3 +23,6 @@ export const VALUE_KEY = b64encode("value");
export const STORE_KEY = b64encode("store");
export const VSTORAGE_VALUE = b64encode("vstorage");
export const KEY_KEY = b64encode("key");
export const STORE_NAME_KEY = b64encode("store_name");
export const SUBKEY_KEY = b64encode("store_subkey");
export const UNPROVED_VALUE_KEY = b64encode("unproved_value");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUBKEY_KEY ......... KEY KEY :D Perhaps, SUB_KEY?

I think this is cleaner:

export const STORE_NAME = b64encode("store_name");
export const SUB_KEY = b64encode("store_subkey");
export const UNPROVED_VALUE = b64encode("unproved_value");

Line 25 too :D

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the repetition is there intentionally to indicate the actual name of the key. for keys that end with "key" the name might look strange but i think we should keep the same pattern among all consts to avoid confusion

if (!valueAttr || !valueAttr.value) {
logger.warn("Value attribute is missing or empty.");
return;
}

const keyAttr = event.attributes.find((a: any) => a.key === KEY_KEY);
const keyAttr = event.attributes.find((a: any) => a.key === KEY_KEY || a.key === SUBKEY_KEY);
if (!keyAttr) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use :any on line 65 and 71 but not on 60?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accidentally added

@@ -10,7 +10,8 @@
"outDir": "dist",
"rootDir": "src",
"target": "es2017",
"strict": true
"strict": true,
"lib": ["es2021"]
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you added the lib option in tsconfig.json. Why make this change and which features from ES2021 you want to use?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it enables us to use replaceAll function

@toliaqat toliaqat merged commit ae2e935 into main Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support old format of vstorage events
3 participants