Conversation
| if (hash) { | ||
| return hash; | ||
| } | ||
|
|
||
| if (partialFee) { | ||
| return { | ||
| weight, | ||
| partialFee | ||
| }; | ||
| } |
There was a problem hiding this comment.
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 aDispatchInfointerface? Also,classof course is reserved, so how do I pick it out as a field ofDispatchInfoin line 247?
There was a problem hiding this comment.
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.
Talked with Joe on offline about investigating a generic sidecarPost<T> solution to this problem.
There was a problem hiding this comment.
+1 with Dan, I would create:
sidecarPost<T>, whose goal is only to send a POST request to the sidecar- and maybe in
submitTransactionandgetFeeEstimate, 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.