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

change: AssetPair API refactoring #799

Closed
testinginprod opened this issue Aug 5, 2022 · 2 comments
Closed

change: AssetPair API refactoring #799

testinginprod opened this issue Aug 5, 2022 · 2 comments
Labels
epic Project or large task that groups multiple tickets and PRs

Comments

@testinginprod
Copy link
Collaborator

testinginprod commented Aug 5, 2022

I propose to refactor AssetPair.

Remove it from proto files.

Make it a custom proto type we can use in place of string.

Make the AssetPair API safe to use, by unexporting fields.

Current problems:

  • pair somewhere is defined as string, somewhere else as AssetPair.
  • code is cluttered by conversion to AssetPair to string, and string to AssetPair
  • in some part of the code we use token0, token1
  • Validation is needed everywhere because engineers are unsure when the AssetPair is safe to use.

Example implementation:

type AssetPair struct {
    t0 string // Fields are private to avoid bad initialization
    t1 string
}

func (p AssetPair) Token1() string { return p.t1 }

func (p AssetPair) String() string { ... } 

func NewAssetPair(token1, token2 string) (AssetPair, error)
@AgentSmithMatrix
Copy link
Contributor

@NibiruHeisenberg @Unique-Divine thoughts.

@AgentSmithMatrix AgentSmithMatrix added the epic Project or large task that groups multiple tickets and PRs label Aug 30, 2022
@AgentSmithMatrix AgentSmithMatrix added this to the Testnet V2 milestone Sep 5, 2022
@NibiruHeisenberg NibiruHeisenberg modified the milestones: Testnet V2 - NibiSwap, Testnet V2 - Misc Oct 10, 2022
@k-yang k-yang removed this from the Misc milestone Apr 8, 2023
@Unique-Divine
Copy link
Member

This was completed successfully. Currently, the asset.Pair type is a type alias for string with functions that make it feel like we're working with a struct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
epic Project or large task that groups multiple tickets and PRs
Projects
Archived in project
Development

No branches or pull requests

5 participants