Decode runtime metadata (#162)

* WIP

* Some output, still borken...

* Events decoded correctly

* WIP, metadata decoded

* String cleanups

* Expand with generics

* Add getters

* Start docs...

* Additional docs

* Extra whitespace on Compact

* CodecLength FIXME

* Remove FIXME (impl. takes care)

* Swap in LengthCompact encoding

* Extend docs, play with auto-type for struct

* Trim strings, add Type for type-specific String

* More string-type hackery

* Don't allow Type re-encoding

* Remove struct experiment

* Cleanup Option

* Remove extra type defs from CodecStruct usage

* Expand Storage function with map (and type returns)

* Description around BaseCodec

* Cleanup linting, add Metadata test

* Move to api-codec

* Extract uniq types

* Uniq updates

* Unwrap, ungeneric
This commit is contained in:
Jaco Greeff
2018-09-24 13:51:20 +02:00
committed by GitHub
parent baaf394ccc
commit d9b05cf9f2
30 changed files with 3604 additions and 38 deletions
@@ -0,0 +1,62 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import Api from '../../api/src';
import Ws from '../src/ws';
describe.skip('e2e basics', () => {
let api;
beforeEach(() => {
jest.setTimeout(30000);
api = new Api(new Ws('ws://127.0.0.1:9944'));
});
it('subscribes to chain_newHead', (done) => {
let count = 0;
// tslint:disable-next-line
api.chain
.newHead((error, data) => {
if (error) {
return done(error);
}
expect(data).toBeDefined();
if (++count === 3) {
done();
}
})
.then((subscriptionId) => {
console.log('newHead: subscriptionId =', subscriptionId);
});
});
it('retrieves the pending extrinsics', () => {
return api.author
.pendingExtrinsics()
.then((extrinsics) => {
console.error('extrinsics', extrinsics);
})
.catch((error) => {
console.error(error);
throw error;
});
});
it('retrieves the wasm metadata', () => {
return api.state
.getMetadata()
.then((meta) => {
console.error(JSON.stringify(meta.toJSON()));
})
.catch((error) => {
console.error(error);
throw error;
});
});
});
@@ -7,7 +7,7 @@ import storage from '@polkadot/storage';
import Api from '../../api/src';
import Ws from '../src/ws';
describe.skip('e2e', () => {
describe.skip('e2e krumme lanke', () => {
let api;
beforeEach(() => {
@@ -15,27 +15,6 @@ describe.skip('e2e', () => {
api = new Api(new Ws('ws://127.0.0.1:9944'));
});
it('subscribes to chain_newHead', (done) => {
let count = 0;
// tslint:disable-next-line
api.chain
.newHead((error, data) => {
if (error) {
return done(error);
}
expect(data).toBeDefined();
if (++count === 3) {
done();
}
})
.then((subscriptionId) => {
console.log('newHead: subscriptionId =', subscriptionId);
});
});
it('subscribes to storage', (done) => {
api.state
.subscribeStorage(
@@ -85,17 +64,4 @@ describe.skip('e2e', () => {
throw error;
});
});
it('retrieves the pending extrinsics', () => {
return api.author
.pendingExtrinsics()
.then((extrinsics) => {
console.error('extrinsics', extrinsics);
})
.catch((error) => {
console.error(error);
throw error;
});
});
});