-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add fee prediction #10
base: master
Are you sure you want to change the base?
Conversation
if (hash) { | ||
return hash; | ||
} | ||
|
||
if (partialFee) { | ||
return { | ||
weight, | ||
partialFee | ||
}; | ||
} |
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.
Two questions about this:
- It just seems very hacky in general. There must be a more generic way to group return items?
- The return will either be
{ hash; }
or{ weight; class; partialFee; }
. In the latter case, can I group these into aDispatchInfo
interface? Also,class
of course is reserved, so how do I pick it out as a field ofDispatchInfo
in line 247?
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 think the root of your problems goes back to your layers of abstraction. At a glance, it looks like you're trying to do too much in this function (sidecarPost
). I would suggest creating purpose-built functions, each of which has their own singular return type and each of which calls into the POST
helper function. You may need to do some additional refactoring to achieve this, but overall I think this is the way in which you want to be thinking 👍
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.
Talked with Joe on offline about investigating a generic sidecarPost<T>
solution to this problem.
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 with Dan, I would create:
sidecarPost<T>
, whose goal is only to send a POST request to the sidecar- and maybe in
submitTransaction
andgetFeeEstimate
, do theif (hash) else ...
checks.
In the latter case, can I group these into a DispatchInfo interface? Also, class of course is reserved, so how do I pick it out as a field of DispatchInfo in line 247?
Yeah, I guess you could:
+import { RuntimeDispatchInfo } from '@polkadot/types/interfaces';
-export async function getFeeEstimate(sidecarHost: string, encodedTx: string): Promise<any> {
+export async function getFeeEstimate(sidecarHost: string, encodedTx: string): Promise<RuntimeDispatchInfo> {
No description provided.