Skip to content

Commit

Permalink
Revert some stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
amaury1093 committed Oct 15, 2018
1 parent d107da0 commit a48e192
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/rpc-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export default class Rpc implements RpcInterface {
}

private formatOutput (method: RpcMethod, params: Array<Base>, result?: any): Base | Array<Base | null | undefined> {
const base = createType(method.type as string, result);
const base = createType(method.type as string).fromJSON(result);

if (method.type === 'StorageData') {
// single return value (via state.getStorage), decode the value based on the
Expand Down
19 changes: 19 additions & 0 deletions packages/types/src/codec/Tuple.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,25 @@ describe('Tuple', () => {
]);
});

// FIXME Remove fromJSON
it('fromJSON still works', () => {
const test = new (Tuple.with({
a: Text,
b: U32,
c: Text
}))();

expect(
test.fromJSON([
'bazzing', 32
]).toJSON()
).toEqual([
'bazzing',
32,
''
]);
});

it('creates properly via actual hex string', () => {
const test = new (Tuple.with({
blockNumber: BlockNumber,
Expand Down
7 changes: 5 additions & 2 deletions packages/types/src/codec/Vector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,12 @@ export default class Vector<
const result = [];

for (let index = 0; index < length; index++) {
const decoded = new Type(u8a.subarray(offset));
// FIXME replace by
// const decoded = new Type(u8a.subarray(offset));
// @ts-ignore Not sure why we get "Property 'fromU8a' does not exist on type 'T'.", T extends Base in def?
const decoded = new Type().fromU8a(u8a.subarray(offset));

result.push(decoded);
result.push(decoded as T);
offset += decoded.byteLength();
}

Expand Down

0 comments on commit a48e192

Please sign in to comment.