Improve Dispatch Errors (#878)

* better dispatch errors

* dry_run to use same DispatchError

* fix dry_run_fails; use correct transfer amount

* Hide ModuleError impl and avoid pulling details from metadata unless user needs them

* fix tests

* actually fix the tests (hopefully..)

* Add a couple more DispatchError test cases

* Add a comment about where the error was copied from

* Also expose a way to obtain the raw module error data

* Remove redundant variant prefixes

* explicit lifetime on From<str> for clarity

* fmt
This commit is contained in:
James Wilson
2023-03-23 09:50:44 +00:00
committed by GitHub
parent 7c252fccf7
commit b5194be5a2
14 changed files with 673 additions and 474 deletions
+3 -3
View File
@@ -324,7 +324,7 @@ impl<T: Config, C: OnlineClientT<T>> TxInBlock<T, C> {
let ev = ev?;
if ev.pallet_name() == "System" && ev.variant_name() == "ExtrinsicFailed" {
let dispatch_error =
DispatchError::decode_from(ev.field_bytes(), &self.client.metadata());
DispatchError::decode_from(ev.field_bytes(), self.client.metadata())?;
return Err(dispatch_error.into());
}
}
@@ -344,7 +344,7 @@ impl<T: Config, C: OnlineClientT<T>> TxInBlock<T, C> {
.rpc()
.block(Some(self.block_hash))
.await?
.ok_or(Error::Transaction(TransactionError::BlockHashNotFound))?;
.ok_or(Error::Transaction(TransactionError::BlockNotFound))?;
let extrinsic_idx = block
.block
@@ -357,7 +357,7 @@ impl<T: Config, C: OnlineClientT<T>> TxInBlock<T, C> {
})
// If we successfully obtain the block hash we think contains our
// extrinsic, the extrinsic should be in there somewhere..
.ok_or(Error::Transaction(TransactionError::BlockHashNotFound))?;
.ok_or(Error::Transaction(TransactionError::BlockNotFound))?;
let events = EventsClient::new(self.client.clone())
.at(Some(self.block_hash))