Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into deploy-web-test
Browse files Browse the repository at this point in the history
  • Loading branch information
qiweiii committed Sep 13, 2023
2 parents bd02c39 + d5f0e15 commit 70e17ab
Show file tree
Hide file tree
Showing 2 changed files with 16 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
6 changes: 6 additions & 0 deletions packages/e2e/src/author.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ describe('author rpc', async () => {
await expect(tx.send()).rejects.toThrow('1010: {"invalid":{"badProof":null}}')
})

it('reject unsigned extrinsic', async () => {
const tx = api.tx.balances.transfer(bob.address, 100)

await expect(tx.send()).rejects.toThrow('1011: {"unknown":{"noUnsignedValidator":null}}')
})

it('failed apply extirinsic', async () => {
const finalized = defer<void>()
const invalid = defer<string>()
Expand Down

0 comments on commit 70e17ab

Please sign in to comment.