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

Spike [handlers]: explicit relationship between query and buildCallData signatures #196

Closed
wants to merge 9 commits into from

Conversation

agualis
Copy link
Contributor

@agualis agualis commented Jan 10, 2024

Description

Refactors AddLiquidityHandler interface to depend on generic TS types.

The new code is more verbose but also more explicit and type-safe.

Now we can have

  • Default SDK handlers where:

    • Preview query returns a SdkQueryAddLiquidityOutput that contains a mandatory sdkQueryOutput: AddLiquidityQueryOutput field
    • Build callData query expects an input containing the previous type
  • Edge case handlers (added a fake Twamm handler example )where:

    • Preview query does not contain sdkQueryOutput: AddLiquidityQueryOutput field
    • Build callData query does not expect the previous type but just the generic bptOut field

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as
    expected)
  • Dependency changes
  • Code refactor / cleanup
  • Documentation or wording changes
  • Other

How should this be tested?

Please provide instructions so we can test. Please also list any relevant details for your test
configuration.

  • Test A
  • Test B

Visual context

Please provide any relevant visual context for UI changes or additions. This could be static
screenshots or a loom screencast.

Checklist:

  • I have performed a self-review of my own code
  • I have requested at least 1 review (If the PR is significant enough, use best judgement here)
  • I have commented my code where relevant, particularly in hard-to-understand areas
  • If package-lock.json has changes, it was intentional.

Copy link

vercel bot commented Jan 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
frontend-v3 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 10, 2024 3:40pm

Comment on lines +46 to +56
const isSdkHandler = 'sdkQueryOutput' in queryOutput && queryOutput.sdkQueryOutput

if (isSdkHandler) {
const sdkBuildInput: SdkBuildAddLiquidityInputs = {
...baseInput,
sdkQueryOutput: queryOutput.sdkQueryOutput,
}
return handler.buildAddLiquidityCallData(sdkBuildInput)
}
if (handler instanceof TwammAddLiquidityHandler) {
return handler.buildAddLiquidityCallData(baseInput)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not pass the whole queryOutput into the handler build call on the handler?

Copy link
Contributor

Choose a reason for hiding this comment

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

Feels like it doesn't make sense to do this conditional deconstruction in this query. The handler should just know what it's getting because of the type, shouldn't it?

@agualis agualis marked this pull request as draft January 11, 2024 11:21
@agualis agualis changed the title Refactor: add liquidity handler types Spike: explicit relationship between query output and buildCallData input Jan 11, 2024
@agualis agualis changed the title Spike: explicit relationship between query output and buildCallData input Spike [handlers]: explicit relationship between query output and buildCallData input Jan 11, 2024
@agualis agualis changed the title Spike [handlers]: explicit relationship between query output and buildCallData input Spike [handlers]: explicit relationship between query and buildCallData signatures Jan 11, 2024
@agualis agualis mentioned this pull request Jan 16, 2024
13 tasks
@agualis
Copy link
Contributor Author

agualis commented Jan 16, 2024

Closed by #211

@agualis agualis closed this Jan 16, 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.

2 participants