From bafda6dc93a2c7c7158a356f0ff8b7f775ea4844 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 16 May 2019 11:18:49 +0200 Subject: [PATCH] Remove struct map naming overrides (#918) --- .../types/src/json/RuntimeVersion.001.json | 39 ---------------- .../types/src/json/RuntimeVersion.002.json | 45 +++++++++++++++++++ packages/types/src/rpc/Health.ts | 7 +-- packages/types/src/rpc/PeerInfo.ts | 9 +--- packages/types/src/rpc/RuntimeVersion.spec.ts | 12 ++--- packages/types/src/rpc/RuntimeVersion.ts | 8 +--- packages/types/src/type/Justification.ts | 4 +- .../types/src/type/StoredPendingChange.ts | 5 +-- 8 files changed, 56 insertions(+), 73 deletions(-) delete mode 100644 packages/types/src/json/RuntimeVersion.001.json create mode 100644 packages/types/src/json/RuntimeVersion.002.json diff --git a/packages/types/src/json/RuntimeVersion.001.json b/packages/types/src/json/RuntimeVersion.001.json deleted file mode 100644 index 553b5bc7d3..0000000000 --- a/packages/types/src/json/RuntimeVersion.001.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "jsonrpc": "2.0", - "result": { - "apis": [ - [ - [ - 105, - 110, - 104, - 101, - 114, - 101, - 110, - 116 - ], - 1 - ], - [ - [ - 118, - 97, - 108, - 105, - 100, - 97, - 116, - 120 - ], - 1 - ] - ], - "authoring_version": 1, - "impl_name": "substrate-node", - "impl_version": 0, - "spec_name": "node", - "spec_version": 1 - }, - "id": 1 -} \ No newline at end of file diff --git a/packages/types/src/json/RuntimeVersion.002.json b/packages/types/src/json/RuntimeVersion.002.json new file mode 100644 index 0000000000..e12be0c8ff --- /dev/null +++ b/packages/types/src/json/RuntimeVersion.002.json @@ -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 +} diff --git a/packages/types/src/rpc/Health.ts b/packages/types/src/rpc/Health.ts index 39cfaa3911..4992051321 100644 --- a/packages/types/src/rpc/Health.ts +++ b/packages/types/src/rpc/Health.ts @@ -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 @@ -22,7 +17,7 @@ export default class Health extends Struct { peers: USize, isSyncing: Bool, shouldHavePeers: Bool - }, value, JSON_MAP); + }, value); } /** diff --git a/packages/types/src/rpc/PeerInfo.ts b/packages/types/src/rpc/PeerInfo.ts index 2d6c446be0..b0ca131b7b 100644 --- a/packages/types/src/rpc/PeerInfo.ts +++ b/packages/types/src/rpc/PeerInfo.ts @@ -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 @@ -28,7 +21,7 @@ export default class PeerInfo extends Struct { protocolVersion: U32, bestHash: Hash, bestNumber: BlockNumber - }, value, JSON_MAP); + }, value); } /** diff --git a/packages/types/src/rpc/RuntimeVersion.spec.ts b/packages/types/src/rpc/RuntimeVersion.spec.ts index c9a4cc668b..b65890bbc1 100644 --- a/packages/types/src/rpc/RuntimeVersion.spec.ts +++ b/packages/types/src/rpc/RuntimeVersion.spec.ts @@ -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); }); }); diff --git a/packages/types/src/rpc/RuntimeVersion.ts b/packages/types/src/rpc/RuntimeVersion.ts index 1051edf98c..c14d1ac0c9 100644 --- a/packages/types/src/rpc/RuntimeVersion.ts +++ b/packages/types/src/rpc/RuntimeVersion.ts @@ -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); } /** diff --git a/packages/types/src/type/Justification.ts b/packages/types/src/type/Justification.ts index c2022304a8..906b85c408 100644 --- a/packages/types/src/type/Justification.ts +++ b/packages/types/src/type/Justification.ts @@ -36,9 +36,7 @@ export class RhdJustification extends Struct { roundNumber: U32, hash: Hash, signatures: Vector.with(BftAuthoritySignature) - }, value, new Map([ - ['roundNumber', 'round_number'] - ])); + }, value); } /** diff --git a/packages/types/src/type/StoredPendingChange.ts b/packages/types/src/type/StoredPendingChange.ts index 58704b86df..7654bafcc5 100644 --- a/packages/types/src/type/StoredPendingChange.ts +++ b/packages/types/src/type/StoredPendingChange.ts @@ -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 {