Skip to content

Commit 23f00ae

Browse files
authored
feat: add dispatchError docs to transactions (#22)
1 parent 8bb5891 commit 23f00ae

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

docs/pages/typed/tx.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ It'll get back the whole `SignedExtrinsic` that needs to be broadcasted. If the
145145
146146
## `signAndSubmit`
147147
148-
`signAndSubmit` will sign (exactly the same way as `sign`) and then broadcast the transaction. If any error happens (both in the signing or if the transaction fails, i.e. wrong nonce, mortality period ended, etc) the promise will be rejected with an error. We're working to make this errors strongly typed. The promise will resolve as soon as the transaction is found in a finalized block, and will reject if the transaction fails. Note that this promise is not abortable. Let's see the interface:
148+
`signAndSubmit` will sign (exactly the same way as `sign`) and then broadcast the transaction. If any error happens (both in the signing or if the transaction fails, i.e. wrong nonce, mortality period ended, etc) the promise will be rejected with an error. The promise will resolve as soon as the transaction is found in a finalized block, and will reject if the transaction fails. Note that this promise is not abortable. Let's see the interface:
149149
150150
```ts
151151
type TxPromise = (
@@ -157,6 +157,7 @@ type TxFinalized = {
157157
txHash: HexString
158158
ok: boolean
159159
events: Array<SystemEvent["event"]>
160+
dispatchError?: DispatchError
160161
block: { hash: string; number: number; index: number }
161162
}
162163
```
@@ -232,6 +233,7 @@ type TxBestBlocksState = {
232233
found: true
233234
ok: boolean
234235
events: Array<SystemEvent["event"]>
236+
dispatchError?: DispatchError
235237
block: { hash: string; number: number; index: number }
236238
}
237239
)
@@ -259,6 +261,7 @@ interface TxBestBlockFound {
259261
found: true
260262
ok: boolean
261263
events: Array<SystemEvent["event"]>
264+
dispatchError?: DispatchError
262265
block: { hash: string; number: number; index: number }
263266
}
264267
```
@@ -273,12 +276,14 @@ type TxFinalized = {
273276
txHash: HexString
274277
ok: boolean
275278
events: Array<SystemEvent["event"]>
279+
dispatchError?: DispatchError
276280
block: { hash: string; number: number; index: number }
277281
}
278282
```
279283
280284
At this stage, the transaction is valid and already in the canonical chain, in a finalized block. We pass, besides the `txHash` as in the other events, the following stuff:
281285
282-
- `ok`: it tells if the extrinsic was successful in its purpose. Under the hood it verifies if the event `System.ExtrinsicSuccess` is present.
286+
- `ok`: it tells if the extrinsic was successful in its purpose. Under the hood it basically checks that the event `System.ExtrinsicFailed` was not emitted.
283287
- `events`: array of all events emitted by the extrinsic. They are ordered as emitted on-chain.
288+
- `dispatchError`: in case the transaction failed, this will have the `dispatchError` value of `System.ExtrinsicFailed`.
284289
- `block`: information of the block where the `tx` is present. `hash` of the block, `number` of the block, `index` of the tx in the block.

0 commit comments

Comments
 (0)