diff --git a/packages/types/src/primitive/Method.ts b/packages/types/src/primitive/Method.ts index 04e0a817e1..82c73ce094 100644 --- a/packages/types/src/primitive/Method.ts +++ b/packages/types/src/primitive/Method.ts @@ -86,7 +86,7 @@ export default class Method extends Struct implements IMethod { * @param _meta - Metadata to use, so that `injectMethods` lookup is not * necessary. */ - private static decodeMethod (value: DecodedMethod | Uint8Array | string, _meta?: FunctionMetadataV4): DecodedMethod { + private static decodeMethod (value: DecodedMethod | Uint8Array | string = new Uint8Array(), _meta?: FunctionMetadataV4): DecodedMethod { if (isHex(value)) { return Method.decodeMethod(hexToU8a(value), _meta); } else if (isU8a(value)) { @@ -122,14 +122,7 @@ export default class Method extends Struct implements IMethod { }; } - console.error(`Method: cannot decode value '${value}' of type ${typeof value}`); - - return { - args: new Uint8Array(), - argsDef: {}, - meta: new FunctionMetadataV4(), - callIndex: new Uint8Array([255, 255]) - }; + throw new Error(`Method: Cannot decode value '${value}' of type ${typeof value}`); } // If the extrinsic function has an argument of type `Origin`, we ignore it diff --git a/packages/types/src/type/Extrinsic.ts b/packages/types/src/type/Extrinsic.ts index fe0b960e67..e35d1a4f82 100644 --- a/packages/types/src/type/Extrinsic.ts +++ b/packages/types/src/type/Extrinsic.ts @@ -38,10 +38,10 @@ export default class Extrinsic extends Struct implements IExtrinsic { super({ signature: ExtrinsicSignature, method: Method - }, Extrinsic.decodeExtrinsic(value || {})); + }, Extrinsic.decodeExtrinsic(value)); } - static decodeExtrinsic (value: ExtrinsicValue | AnyU8a | Method): ExtrinsicValue | Array | Uint8Array { + static decodeExtrinsic (value: ExtrinsicValue | AnyU8a | Method = new Uint8Array()): ExtrinsicValue | Array | Uint8Array { if (Array.isArray(value) || isHex(value)) { // Instead of the block below, it should simply be: // return Extrinsic.decodeExtrinsic(hexToU8a(value as string));