-
Notifications
You must be signed in to change notification settings - Fork 13
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
Refactoring for more modularity #58
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ochaloup I really like the direction that this is taking! nice job! 🔥
I left two comments but did not dive too deep into the changes.
7a5d766
to
59510cd
Compare
@AlexStefan I updated the PR, processed your review points (I hope) and fixed the tests to get running. This is ready for next round of the review. Noticable changes:
What's missing:
|
they can be connecting to testnet network which may cause delays bigger to 5sec
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're on the right path! Would be cool if you could check the commits what I've pushed and the remaining comments. Afterwards I'll give it a try with the Marinade dApp to see if we broke anything or how hard the port would be.
}) | ||
).instruction | ||
} | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we convert this into an assert? like the one at line 59?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what you mean here about assert
to be used here.
Do you mean like assert(voteRecord, ErrorMessage.NO_PUBLIC_KEY)
.
That's not possible currently as how SDK is designed (as far as I understand it). When the voteRecord
is not provided to the method then the caller does not expect an error. It's a normal flow of code.
When the instruction is not returned back to the caller the caller behaves differently.
It's not much intuitive I assume. Maybe the way how SDK API is designed here should be adjusted to be clearer.
WDYT?
The caller should behave differently when he provides no pubkey. The original code of SDK is not mine but it's from MJ so I just trying to understand the behaviour and adapt it.
* Returns a transaction with the instructions to | ||
* Add liquidity to the liquidity pool and receive LP tokens | ||
* | ||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to update params for all the methods as this was changed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, updated. check if appropriately
PublicKey, | ||
Transaction, | ||
VersionedTransaction, | ||
} from '@solana/web3.js' | ||
|
||
export namespace MarinadeResult { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Food for thought: thinking of making this more generic and not repeating the same thing under different names, any opinions? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please elaborate on what are the places where the same thing is repeated?
Maybe you refer to usage of the interface
and similar naming of the methods? If so, then this patter was intentional from me as I wanted to have the same way to call the instruction builder for program
and referral program
and the interface made possible to join those two under uniform call. But a) maybe you refer to something else, b) maybe you have some different way to solve this or desing the sdk.
7655e4a
to
a0c5d46
Compare
hi @AlexStefan,
For the changes you provided I have a bit uncertainty about that change from provider to connection. I think I understand the point that it seems to me being to make the SDK simplier (more straightforward). What's an issue is the fact that the |
A "kick-off" refactoring that should bring better tree shakability in way of splitting the monolith class(es) to multiple method calls. This is a draft that is considered that need a discussion. The base code is drafted around
marinade.ts
but the code does not build smoothly, tests are not aligned, README misses to reflect changes...As going through the refactoring cycles I was trying to have not so many arguments on the functions params but lastly I ended up with "asking" for all as method params. I was struggling with thinking if having
MarinadeConfig
class is beneficial (all config data placed at one class that could be passed through the application or if it's rather confusing). T he current version mostly remove the usage of it and uses only default values on input params.The state should be managed by the caller as a base idea and just passed in. This is something I haven't elaborated through the whole code so depending on the feedback of this PR I will recheck that later.
I would be happy to learn some nicer syntax approaches or whatever that could be enhanced.
A question is if the API in the current for is easy to use by callers. As I do not work at FE side I'm not sure here. Maybe some wrapping of arguments of facading method calls could be easier to use but on the other way the tree shakability could be harmed.
Please, let me know what you think.
/cc @MjCage