-
Notifications
You must be signed in to change notification settings - Fork 28
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
refactor: kill extrinsic errors, use metadata error matching instead #452
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.
That looks SO MUCH better!
Just some nitpicks
while working on this I wrote this little gadget which I had included in the export function throwExtrinsicError(extrinsicResult: ISubmittableResult): void {
const { dispatchError } = extrinsicResult
if (!dispatchError) return
if (dispatchError.isModule) {
const moduleError = dispatchError.registry.findMetaError(
dispatchError.asModule
)
const { section, index, name, docs } = moduleError
throw new ExtrinsicError(
`Module Error ${section}.${name}(${index}): ${docs.join(' ')}`
)
}
if (dispatchError.isToken || dispatchError.isArithmetic) {
throw new ExtrinsicError(
`${dispatchError.type} Error: ${(dispatchError.value as TokenError).type}`
)
}
throw new ExtrinsicError(`${dispatchError.type} Error`)
} It's not used or needed anywhere, do you think that's something users would want to use? |
Regarding #452 (comment): |
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.
fixes KILTProtocol/ticket#1652
This makes use of module error matching based on chain metadata info.
Our internal extrinsic error matching is removed.
Minor changes necessary to get this done relate to the recovery by resign functionality, and the SubscriptionPromise maker.
How to test:
test & integration tests suffice
Checklist: