-
Notifications
You must be signed in to change notification settings - Fork 121
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
Fix --dry-run
error deserialization and report error details
#534
Conversation
use subxt::{ | ||
rpc::NumberOrHex, | ||
ClientBuilder, | ||
Config, | ||
DefaultConfig, | ||
}; | ||
|
||
type ContractExecResult = pallet_contracts_primitives::ContractExecResult<Balance>; | ||
type ContractExecResult = | ||
ContractResult<result::Result<ExecReturnValue, RuntimeDispatchError>, Balance>; |
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.
This is the crux of the change, it is using the subxt
generated RuntimeDispatchError
instead of the default sp_runtime::DispatchError
. This means it is using the same DispatchError
type as would be returned in case of an error on calling the extrinsic.
@@ -15,6 +15,17 @@ | |||
// along with cargo-contract. If not, see <http://www.gnu.org/licenses/>. | |||
|
|||
#[subxt::subxt( | |||
runtime_metadata_path = "src/cmd/extrinsics/runtime_api/contracts_runtime.scale" | |||
runtime_metadata_path = "src/cmd/extrinsics/runtime_api/contracts_runtime.scale", | |||
derive_for_type(type = "sp_runtime::DispatchError", derive = "::serde::Deserialize"), |
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.
Adding these derives to these generated types is necessary so that they can be used to deserialize the RPC --dry-run
error responses.
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.
LGTM
Closes #533.
This now parameterizes the RPC results with the generated
DispatchError
type fromsubxt
so the types line up with the latest contracts node for deserializataion.This also allows us to retrieve the
DispatchError
details from the metadata so we can map to a user friendly error: