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

Small nit suggestions #147

Merged
merged 10 commits into from
Aug 24, 2023
Merged

Small nit suggestions #147

merged 10 commits into from
Aug 24, 2023

Conversation

anxolin
Copy link
Contributor

@anxolin anxolin commented Aug 22, 2023

This is a misc on some NIT suggestions.

Happy to take any of this back, but I feel is still early (we are still doing a RC), and we can arrange things a bit.

I tried to explain the changes in the code, mainly

  • Rename things around: like BaseConditionalOrder is now ConditionalOrder, and TWAP is Twap
  • Created a utils.ts with helpers
  • Created a types.ts with main types
  • Moved some static methods from the abstract class to the utils.ts
  • Changed the name of the twap orders type to twap to match what we store onchain in orderClass for the appData

To review

I left some comments in the code too

@github-actions
Copy link

CLA Assistant Lite bot:
Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request

@coveralls
Copy link
Collaborator

coveralls commented Aug 22, 2023

Coverage Status

coverage: 81.422% (-0.1%) from 81.541% when pulling a4c398c on small-nit-suggestions into 0aad903 on main.

@anxolin anxolin marked this pull request as ready for review August 22, 2023 18:32
@anxolin anxolin requested review from mfw78 and a team August 23, 2023 10:02
src/composable/ConditionalOrder.spec.ts Show resolved Hide resolved
@@ -68,21 +66,25 @@ describe('ConditionalOrder', () => {
'0x910d00a310f7Dc5B29FE73458F47f519be547D3d',
'0x9379a0bf532ff9a66ffde940f94b1a025d6f18803054c1aef52dc94b15255bbe'
)
expect(BaseConditionalOrder.leafToId(order.leaf)).toEqual(
expect(ConditionalOrder.leafToId(order.leaf)).toEqual(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just to keep things simple, i suggest we just call the abstract class ConditionalOrder instead of BaseConditionalOrder

Copy link
Contributor

Choose a reason for hiding this comment

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

There needs to be some room left for further generalisation.

All conditional orders that are done now are generators - but these are a subset of conditional orders. There may be conditional order types that only specify a verify, and these require custom logic to know what to provide them for offChain input etc.

I'm not sure where this logic would be implemented idiomatically.

src/composable/ConditionalOrder.spec.ts Show resolved Hide resolved
hasOffChainInput = false
) {
constructor(params: ConditionalOrderArguments<Params>) {
const { handler, salt = utils.keccak256(utils.randomBytes(32)), staticInput, hasOffChainInput = false } = params
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe is better to use name parameters than a list of parameters, especially with optional ones.
This reduces errors using it and make params more explicit and easy to read

src/composable/ConditionalOrder.ts Show resolved Hide resolved
src/composable/Multiplexer.ts Show resolved Hide resolved
src/composable/types.ts Show resolved Hide resolved
src/composable/types/Twap.ts Show resolved Hide resolved
src/composable/utils.spec.ts Show resolved Hide resolved
src/composable/utils.ts Show resolved Hide resolved
Copy link
Contributor

@mfw78 mfw78 left a comment

Choose a reason for hiding this comment

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

Looks great, thanks for the detailed, comprehensive review.

Mostly minor nits, but the one that stands out the most is the name of the generic used on ConditionalOrder. My fear in that using the generic Params may cause the SDK user to conflate this with the IConditionalOrder.ConditionalOrderParams struct.

@@ -68,21 +66,25 @@ describe('ConditionalOrder', () => {
'0x910d00a310f7Dc5B29FE73458F47f519be547D3d',
'0x9379a0bf532ff9a66ffde940f94b1a025d6f18803054c1aef52dc94b15255bbe'
)
expect(BaseConditionalOrder.leafToId(order.leaf)).toEqual(
expect(ConditionalOrder.leafToId(order.leaf)).toEqual(
Copy link
Contributor

Choose a reason for hiding this comment

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

There needs to be some room left for further generalisation.

All conditional orders that are done now are generators - but these are a subset of conditional orders. There may be conditional order types that only specify a verify, and these require custom logic to know what to provide them for offChain input etc.

I'm not sure where this logic would be implemented idiomatically.

src/composable/utils.ts Show resolved Hide resolved
src/composable/types.ts Show resolved Hide resolved
src/composable/types/Twap.ts Show resolved Hide resolved
src/composable/types/Twap.ts Show resolved Hide resolved
src/composable/types/Twap.ts Show resolved Hide resolved
src/composable/types/Twap.ts Show resolved Hide resolved
src/composable/Multiplexer.spec.ts Show resolved Hide resolved
src/composable/ConditionalOrder.ts Show resolved Hide resolved
src/composable/ConditionalOrder.ts Outdated Show resolved Hide resolved
Co-authored-by: mfw78 <[email protected]>
@anxolin
Copy link
Contributor Author

anxolin commented Aug 23, 2023

Nice comments!

I will address!

@anxolin anxolin merged commit f878bdd into main Aug 24, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Aug 24, 2023
@alfetopito alfetopito deleted the small-nit-suggestions branch August 24, 2023 14:13
@alfetopito
Copy link
Contributor

@anxolin unit tests also broken here

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants