Skip to content

Commit

Permalink
fix: pass error to polkadot
Browse files Browse the repository at this point in the history
  • Loading branch information
qiweiii committed Sep 12, 2023
1 parent f507c1e commit 1ffacd8
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions packages/chopsticks/src/rpc/substrate/author.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,17 @@ const handlers: Handlers = {
done(id)
}

context.chain
.submitExtrinsic(extrinsic)
.then(() => {
callback({
Ready: null,
})
})
.catch((error: TransactionValidityError) => {
logger.error({ error }, 'ExtrinsicFailed')
callback(error?.toJSON?.() ?? error)
done(id)
try {
await context.chain.submitExtrinsic(extrinsic)
callback({
Ready: null,
})
} catch (error) {
logger.error({ error }, 'ExtrinsicFailed')
const code = (error as TransactionValidityError).isInvalid ? 1010 : 1011
done(id)
throw new ResponseError(code, (error as TransactionValidityError).toString())
}
return id
},
author_unwatchExtrinsic: async (_context, [subid], { unsubscribe }) => {
Expand Down

0 comments on commit 1ffacd8

Please sign in to comment.