Skip to content

Commit

Permalink
Remove struct map naming overrides (polkadot-js#918)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacogr authored and ianhe8x committed Jun 12, 2019
1 parent 7c8ec1f commit f070b63
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 73 deletions.
39 changes: 0 additions & 39 deletions packages/types/src/json/RuntimeVersion.001.json

This file was deleted.

45 changes: 45 additions & 0 deletions packages/types/src/json/RuntimeVersion.002.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"jsonrpc": "2.0",
"result": {
"apis": [
[
"0xdf6acb689907609b",
2
],
[
"0x37e397fc7c91f5e4",
1
],
[
"0x40fe3ad401f8959a",
3
],
[
"0xd2bc9897eed08f15",
1
],
[
"0xf78b278be53f454c",
1
],
[
"0xed99c5acb25eedf5",
2
],
[
"0xdd718d5cc53262d4",
1
],
[
"0x7801759919ee83e5",
1
]
],
"authoringVersion": 10,
"implName": "substrate-node",
"implVersion": 60,
"specName": "node",
"specVersion": 60
},
"id": 21
}
7 changes: 1 addition & 6 deletions packages/types/src/rpc/Health.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ import Struct from '../codec/Struct';
import Bool from '../primitive/Bool';
import USize from '../primitive/USize';

const JSON_MAP = new Map([
['isSyncing', 'is_syncing'],
['shouldHavePeers', 'should_have_peers']
]);

/**
* @name Health
* @description
Expand All @@ -22,7 +17,7 @@ export default class Health extends Struct {
peers: USize,
isSyncing: Bool,
shouldHavePeers: Bool
}, value, JSON_MAP);
}, value);
}

/**
Expand Down
9 changes: 1 addition & 8 deletions packages/types/src/rpc/PeerInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ import U32 from '../primitive/U32';
import Hash from '../primitive/Hash';
import BlockNumber from '../type/BlockNumber';

const JSON_MAP = new Map([
['bestHash', 'best_hash'],
['bestNumber', 'best_number'],
['protocolVersion', 'protocol_version'],
['peerId', 'peer_id']
]);

/**
* @name PeerInfo
* @description
Expand All @@ -28,7 +21,7 @@ export default class PeerInfo extends Struct {
protocolVersion: U32,
bestHash: Hash,
bestNumber: BlockNumber
}, value, JSON_MAP);
}, value);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions packages/types/src/rpc/RuntimeVersion.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.

import rpc from '../json/RuntimeVersion.001.json';
import rpc from '../json/RuntimeVersion.002.json';
import RuntimeVersion from './RuntimeVersion';

describe('RuntimeVersion', () => {
const version = new RuntimeVersion(rpc.result);

it('has the correct authoring', () => {
expect(version.authoringVersion.toNumber()).toEqual(1);
expect(version.authoringVersion.toNumber()).toEqual(10);
});

it('has the apis', () => {
const api = version.apis[0];

expect(api.id.toHex()).toEqual('0x696e686572656e74');
expect(api.version.toNumber()).toEqual(1);
expect(api.id.toHex()).toEqual('0xdf6acb689907609b');
expect(api.version.toNumber()).toEqual(2);
});

it('has the correct implementation', () => {
expect(version.implName.toString()).toEqual('substrate-node');
expect(version.implVersion.toNumber()).toEqual(0);
expect(version.implVersion.toNumber()).toEqual(60);
});

it('has the correct spec', () => {
expect(version.specName.toString()).toEqual('node');
expect(version.specVersion.toNumber()).toEqual(1);
expect(version.specVersion.toNumber()).toEqual(60);
});
});
8 changes: 1 addition & 7 deletions packages/types/src/rpc/RuntimeVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,7 @@ export default class RuntimeVersion extends Struct implements RuntimeVersionInte
specVersion: U32,
implVersion: U32,
apis: Vector.with(RuntimeVersionApi)
}, value, new Map([
['authoringVersion', 'authoring_version'],
['implName', 'impl_name'],
['implVersion', 'impl_version'],
['specName', 'spec_name'],
['specVersion', 'spec_version']
]));
}, value);
}

/**
Expand Down
4 changes: 1 addition & 3 deletions packages/types/src/type/Justification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ export class RhdJustification extends Struct {
roundNumber: U32,
hash: Hash,
signatures: Vector.with(BftAuthoritySignature)
}, value, new Map([
['roundNumber', 'round_number']
]));
}, value);
}

/**
Expand Down
5 changes: 1 addition & 4 deletions packages/types/src/type/StoredPendingChange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ export default class StoredPendingChange extends Struct {
scheduledAt: BlockNumber,
delay: BlockNumber,
nextAuthorities: Vector.with(NextAuthority)
}, value, new Map([
['scheduledAt', 'scheduled_at'],
['nextAuthorities', 'next_authorities']
]));
}, value);
}

get delay (): BlockNumber {
Expand Down

0 comments on commit f070b63

Please sign in to comment.