-
Notifications
You must be signed in to change notification settings - Fork 27
Refactor checkResult()
#886
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
Conversation
aaea545
to
7484bd5
Compare
let status: TransactionResult['status'] | undefined | ||
let blockHash | ||
let blockNumber | ||
let error |
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.
let's use returns inside of the switch instead
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.
let error | ||
txEvents.forEach(({ event }) => { |
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.
let error | |
txEvents.forEach(({ event }) => { | |
return txEvents.find(({ event }) => { |
combine this with returns (I'll make one example below) and our function becomes simpler and faster (exits on first error)
const isSuccess = !error && eventMatch | ||
|
||
status = isSuccess ? 'confirmed' : 'failed' | ||
if (!isSuccess && !error) { |
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.
if (!isSuccess && !error) { | |
if (!isSuccess && !eventMatch) { |
why not be more explicit?
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.
} from './interfaces.js' | ||
|
||
function mapError(err: SpRuntimeDispatchError, api: ApiPromise): Error { | ||
export function mapError(err: SpRuntimeDispatchError, api: ApiPromise): Error { |
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.
this one and the next are only used in checkResult rn, so they could move there too
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.
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.
Nice!
No description provided.