Skip to content

Commit

Permalink
fix: Catch errors decoding opaque calls (#347)
Browse files Browse the repository at this point in the history
* fix: Catch errors decoding opaque calls

* Add docs to explain the undecoded opaquecalls are not valid

* Builld docs

* Update docs/src/openapi-v1.yaml

Co-authored-by: David <dvdplm@gmail.com>

* Update src/controllers/blocks/BlocksController.ts

Co-authored-by: David <dvdplm@gmail.com>

Co-authored-by: David <dvdplm@gmail.com>
  • Loading branch information
emostov and dvdplm authored Nov 24, 2020
1 parent 260e554 commit d128e54
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/dist/app.bundle.js

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion docs/src/openapi-v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,10 @@ components:
format: unsignedInteger
args:
type: object
description: Object of arguments keyed by parameter name.
description: >-
Object of arguments keyed by parameter name. Note: if you are expecting an [`OpaqueCall`](https://substrate.dev/rustdocs/v2.0.0/pallet_multisig/type.OpaqueCall.html)
and it is not decoded in the response (i.e. it is just a hex string), then Sidecar was
not able to decode it and likely that it is not a valid call for the runtime.
tip:
type: string
description: Any tip added to the transaction.
Expand Down
4 changes: 3 additions & 1 deletion src/controllers/blocks/BlocksController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ import AbstractController from '../AbstractController';
* - `method`: Extrinsic method.
* - `signature`: Object with `signature` and `signer`, or `null` if unsigned.
* - `nonce`: Account nonce, if applicable.
* - `args`: Array of arguments.
* - `args`: Array of arguments. Note: if you are expecting an [`OpaqueCall`](https://substrate.dev/rustdocs/v2.0.0/pallet_multisig/type.OpaqueCall.html)
* and it is not decoded in the response (i.e. it is just a hex string), then Sidecar was not
* able to decode it and likely that it is not a valid call for the runtime.
* - `tip`: Any tip added to the transaction.
* - `hash`: The transaction's hash.
* - `info`: `RuntimeDispatchInfo` for the transaction. Includes the `partialFee`.
Expand Down
14 changes: 12 additions & 2 deletions src/services/blocks/BlocksService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,18 @@ export class BlocksService extends AbstractService {
) {
// multiSig.asMulti.args.call is an OpaqueCall (Vec<u8>) that we
// serialize to a polkadot-js Call and parse so it is not a hex blob.
const call = registry.createType('Call', argument.toHex());
newArgs[paramName] = this.parseGenericCall(call, registry);
try {
const call = registry.createType(
'Call',
argument.toHex()
);
newArgs[paramName] = this.parseGenericCall(
call,
registry
);
} catch {
newArgs[paramName] = argument;
}
} else {
newArgs[paramName] = argument;
}
Expand Down

0 comments on commit d128e54

Please sign in to comment.