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

support contract 0.3.2 and reduce fetch records on the history page #134

Merged
merged 3 commits into from
Nov 2, 2023

Conversation

rueshyna
Copy link
Collaborator

@rueshyna rueshyna commented Nov 2, 2023

  • support contract 0.3.2
    • in the future, if we should spend time to enhance the way to support new version of contract. Now, it becomes a bit painful. the version change is everywhere.. polymorphism is our good friend.
  • reduce fetch records on the history page to enhance loading performance

@rueshyna rueshyna requested a review from JulesGuesnon November 2, 2023 05:50
@@ -50,7 +51,7 @@ abstract class Versioned {
readonly version: version;
readonly contractAddress: string;

public static FETCH_COUNT = 20;
public static FETCH_COUNT = 5;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe 10 would be better? I think 5 by 5 may be a bit slow

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I changed to 10

Comment on lines +141 to +156
} else if (c.version === "0.3.2") {
return fetch(
`${TZKT_API_URL}/v1/bigmaps/${bigmapId}/keys?value.state.in=[{"executed":{}}, {"rejected":{}}, {"expired": {}}]${common}`
).then(res => res.json());
`${TZKT_API_URL}/v1/contracts/events?contract=${address}&tag=proof_of_event${common}`
)
.then(res => res.json())
.then((events: Array<proofOfEvent>) =>
events.map(event => ({
key: event.payload.challenge_id,
value: proposalSchema_0_3_2.Execute(
unpackDataBytes({
bytes: event.payload.payload,
})
),
}))
);
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we can remove this and do a condition on the schema: (c.version === '0.3.1' ? proposalSchema_0_3_1 : proposalSchema_0_3_2)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I prefer to split them as they are different cases. because:

  • otherwise, next time if there is new version, the conditions will be complicated.
  • also you will have to check condition multiple times.

In the future, I think we refactor "proposalType" to solve this kind of thing.

version: "0.3.2",
};
}
private static mapContent(content: content): proposalContent {
Copy link
Collaborator

Choose a reason for hiding this comment

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

add_or_update_metadata is not handled at all, even if we don't handle it on the UI side, I think it should be handled here just in case

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

no, it will throw error. as we don't have any unit test here, it's no way to know if you do it right or wrong. It will be better going with UI.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So should we just ignore it for now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, for now, nothing will go wrong.

@JulesGuesnon JulesGuesnon merged commit 119ae98 into main Nov 2, 2023
4 checks passed
@rueshyna rueshyna deleted the cc@contract0.3.2 branch November 2, 2023 12:48
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.

2 participants