Additional historic DispatchError variant (#5075)

This commit is contained in:
Jaco
2022-07-15 18:39:59 +03:00
committed by GitHub
parent 63d72e7d36
commit 67325dbc09
8 changed files with 53 additions and 4 deletions
+4 -2
View File
@@ -119,7 +119,7 @@ export abstract class AbstractArray<T extends Codec> extends Array<T> implements
const result = new Array<AnyJson>(this.length);
for (let i = 0; i < this.length; i++) {
result[i] = this[i].toHuman(isExtended);
result[i] = this[i] && this[i].toHuman(isExtended);
}
return result;
@@ -132,7 +132,9 @@ export abstract class AbstractArray<T extends Codec> extends Array<T> implements
const result = new Array<AnyJson>(this.length);
for (let i = 0; i < this.length; i++) {
result[i] = this[i].toJSON();
// We actually log inside the U8a decoding and use JSON.stringify(...), which
// means that the Vec may be partially populated (same applies to toHuman, same check)
result[i] = this[i] && this[i].toJSON();
}
return result;
@@ -285,6 +285,8 @@ export class Struct<
for (const [k, v] of this.entries()) {
const jsonKey = this.#jsonMap.get(k) || k;
// We actually log inside the U8a decoding and use JSON.stringify(...), which
// means that the Vec may be partially populated (same applies to toHuman, same check)
json[jsonKey as string] = v && v.toJSON();
}
@@ -42,6 +42,8 @@ export function decodeU8a <T extends Codec = Codec> (registry: Registry, result:
i++;
}
} catch (error) {
// console.error(JSON.stringify(result, null, 2));
throw new Error(formatFailure(registry, error as Error, u8a.subarray(offset), i, count, Types[i], keys[i]));
}
@@ -68,6 +70,8 @@ export function decodeU8aStruct (registry: Registry, result: [string, Codec][],
i++;
}
} catch (error) {
// console.error(JSON.stringify(result, null, 2));
throw new Error(formatFailure(registry, error as Error, u8a.subarray(offset), i, count, Types[i], keys[i]));
}
@@ -94,6 +98,8 @@ export function decodeU8aVec <T extends Codec = Codec> (registry: Registry, resu
i++;
}
} catch (error) {
console.error(JSON.stringify(result, null, 2));
throw new Error(formatFailure(registry, error as Error, u8a.subarray(offset), i, count, Type));
}